Subversion Repositories public iLand

Rev

Rev 234 | Rev 241 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1
 
187 iland 2
#ifndef RESOURCEUNIT_H
3
#define RESOURCEUNIT_H
92 Werner 4
 
5
#include "tree.h"
189 iland 6
#include "resourceunitspecies.h"
180 werner 7
#include "standstatistics.h"
92 Werner 8
 
9
class SpeciesSet;
208 werner 10
class Climate;
92 Werner 11
 
187 iland 12
class ResourceUnit
92 Werner 13
{
14
public:
187 iland 15
    ResourceUnit(const int index);
234 werner 16
    // access to elements
145 Werner 17
    int index() const { return mIndex; }
208 werner 18
    Climate *climate() const { return mClimate; } ///< link to the climate on this resource unit
111 Werner 19
    SpeciesSet *speciesSet() const { return  mSpeciesSet; } ///< get SpeciesSet this RU links to.
20
    /// get RU-Species-container of @p species from the RU
200 werner 21
    ResourceUnitSpecies &resourceUnitSpecies(const Species *species);
234 werner 22
    const QVector<ResourceUnitSpecies> ruSpecies() const { return mRUSpecies; }
111 Werner 23
    const QRectF &boundingBox() const { return mBoundingBox; }
105 Werner 24
    QVector<Tree> &trees() { return mTrees; } ///< reference to the tree list.
143 Werner 25
    const QVector<Tree> &constTrees() const { return mTrees; } ///< reference to the tree list.
234 werner 26
    // properties
27
    double area() const { return mPixelCount*100; } ///< get the resuorce unit area in m2
28
    double stockedArea() const { return mStockedArea; } ///< get the stocked area in m2
107 Werner 29
    // actions
111 Werner 30
    /// returns a modifiable reference to a free space inside the tree-vector. should be used for tree-init.
31
    Tree &newTree();
32
    /// addWLA() is called by each tree to aggregate the total weighted leaf area on a unit
212 werner 33
    void addWLA(const float LA, const float LRI) { mAggregatedWLA += LA*LRI; mAggregatedLA += LA; }
230 werner 34
    /// function that distributes effective interception area according to the weight of Light response and LeafArea of the indivudal (@sa production())
35
    double interceptedArea(const double LA, const double LRI) { return mEffectiveArea_perWLA * LA * LRI; }
111 Werner 36
 
37
    // model flow
107 Werner 38
    void newYear(); ///< reset values for a new simulation year
112 Werner 39
    void production(); ///< called after the LIP/LIF calc, before growth of individual trees
180 werner 40
    void yearEnd(); ///< called after the growth of individuals
107 Werner 41
 
151 iland 42
    // stocked area calculation
43
    void countStockedPixel(bool pixelIsStocked) { mPixelCount++; if (pixelIsStocked) mStockedPixelCount++; }
240 werner 44
    void createStandStatistics();
94 Werner 45
    // setup/maintenance
157 werner 46
    void cleanTreeList();
111 Werner 47
    void setSpeciesSet(SpeciesSet *set);
208 werner 48
    void setClimate(Climate* climate) { mClimate = climate; }
105 Werner 49
    void setBoundingBox(const QRectF &bb) { mBoundingBox = bb; }
92 Werner 50
private:
113 Werner 51
    int mIndex; // internal index
208 werner 52
    Climate *mClimate; ///< pointer to the climate object of this RU
92 Werner 53
    SpeciesSet *mSpeciesSet; ///< pointer to the species set for this RU
187 iland 54
    QVector<ResourceUnitSpecies> mRUSpecies; ///< data for this ressource unit per species
92 Werner 55
    QVector<Tree> mTrees; ///< storage container for tree individuals
105 Werner 56
    QRectF mBoundingBox; ///< bounding box (metric) of the RU
110 Werner 57
    float mAggregatedLA; ///< sum of leafArea
230 werner 58
    float mAggregatedWLA; ///< sum of lightResponse * LeafArea for all trees
59
    double mEffectiveArea_perWLA; ///<
60
 
151 iland 61
    int mPixelCount; ///< count of (Heightgrid) pixels thare are inside the RU
62
    int mStockedPixelCount;  ///< count of pixels that are stocked with trees
234 werner 63
    double mStockedArea; ///< size of stocked area
180 werner 64
    StandStatistics mStatistics; ///< aggregate values on stand value
92 Werner 65
 
183 werner 66
    friend class RUWrapper;
92 Werner 67
};
68
 
200 werner 69
#endif // RESOURCEUNIT_H