Subversion Repositories public iLand

Rev

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