Subversion Repositories public iLand

Rev

Rev 241 | Rev 255 | 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; }
251 werner 36
    void addLR(const float LA, const float LightResponse) { mAggregatedLR += LA*LightResponse; }
230 werner 37
    /// function that distributes effective interception area according to the weight of Light response and LeafArea of the indivudal (@sa production())
251 werner 38
    double interceptedArea(const double LA, const double LightResponse) { return mEffectiveArea_perWLA * LA * LightResponse; }
39
    void calculateInterceptedArea();
40
    const double &LRImodifier() const { return mLRI_modification; }
111 Werner 41
 
42
    // model flow
107 Werner 43
    void newYear(); ///< reset values for a new simulation year
112 Werner 44
    void production(); ///< called after the LIP/LIF calc, before growth of individual trees
180 werner 45
    void yearEnd(); ///< called after the growth of individuals
107 Werner 46
 
151 iland 47
    // stocked area calculation
48
    void countStockedPixel(bool pixelIsStocked) { mPixelCount++; if (pixelIsStocked) mStockedPixelCount++; }
240 werner 49
    void createStandStatistics();
94 Werner 50
    // setup/maintenance
157 werner 51
    void cleanTreeList();
111 Werner 52
    void setSpeciesSet(SpeciesSet *set);
241 werner 53
    void setup(); ///< setup operations after the creation of the model space.
208 werner 54
    void setClimate(Climate* climate) { mClimate = climate; }
105 Werner 55
    void setBoundingBox(const QRectF &bb) { mBoundingBox = bb; }
92 Werner 56
private:
113 Werner 57
    int mIndex; // internal index
208 werner 58
    Climate *mClimate; ///< pointer to the climate object of this RU
92 Werner 59
    SpeciesSet *mSpeciesSet; ///< pointer to the species set for this RU
241 werner 60
    WaterCycle *mWater; ///< link to the Soil water calculation engine
187 iland 61
    QVector<ResourceUnitSpecies> mRUSpecies; ///< data for this ressource unit per species
92 Werner 62
    QVector<Tree> mTrees; ///< storage container for tree individuals
105 Werner 63
    QRectF mBoundingBox; ///< bounding box (metric) of the RU
251 werner 64
    double mAggregatedLA; ///< sum of leafArea
65
    double mAggregatedWLA; ///< sum of lightResponse * LeafArea for all trees
66
    double mAggregatedLR; ///< sum of lightresponse*LA of the current unit
67
    double mEffectiveArea; ///< total "effective" area per resource unit, i.e. area of RU - non-stocked - beerLambert-loss
230 werner 68
    double mEffectiveArea_perWLA; ///<
251 werner 69
    double mLRI_modification;
230 werner 70
 
151 iland 71
    int mPixelCount; ///< count of (Heightgrid) pixels thare are inside the RU
72
    int mStockedPixelCount;  ///< count of pixels that are stocked with trees
234 werner 73
    double mStockedArea; ///< size of stocked area
180 werner 74
    StandStatistics mStatistics; ///< aggregate values on stand value
92 Werner 75
 
183 werner 76
    friend class RUWrapper;
92 Werner 77
};
78
 
200 werner 79
#endif // RESOURCEUNIT_H