Subversion Repositories public iLand

Rev

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