Subversion Repositories public iLand

Rev

Rev 1221 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1221 Rev 1222
1
Redirecting to URL 'https://iland.boku.ac.at/svn/iland/tags/release_1.0/src/core/tree.h':
1
Redirecting to URL 'https://iland.boku.ac.at/svn/iland/tags/release_1.0/src/core/tree.h':
2
/********************************************************************************************
2
/********************************************************************************************
3
**    iLand - an individual based forest landscape and disturbance model
3
**    iLand - an individual based forest landscape and disturbance model
4
**    http://iland.boku.ac.at
4
**    http://iland.boku.ac.at
5
**    Copyright (C) 2009-  Werner Rammer, Rupert Seidl
5
**    Copyright (C) 2009-  Werner Rammer, Rupert Seidl
6
**
6
**
7
**    This program is free software: you can redistribute it and/or modify
7
**    This program is free software: you can redistribute it and/or modify
8
**    it under the terms of the GNU General Public License as published by
8
**    it under the terms of the GNU General Public License as published by
9
**    the Free Software Foundation, either version 3 of the License, or
9
**    the Free Software Foundation, either version 3 of the License, or
10
**    (at your option) any later version.
10
**    (at your option) any later version.
11
**
11
**
12
**    This program is distributed in the hope that it will be useful,
12
**    This program is distributed in the hope that it will be useful,
13
**    but WITHOUT ANY WARRANTY; without even the implied warranty of
13
**    but WITHOUT ANY WARRANTY; without even the implied warranty of
14
**    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
**    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
**    GNU General Public License for more details.
15
**    GNU General Public License for more details.
16
**
16
**
17
**    You should have received a copy of the GNU General Public License
17
**    You should have received a copy of the GNU General Public License
18
**    along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
**    along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
********************************************************************************************/
19
********************************************************************************************/
20
20
21
#ifndef TREE_H
21
#ifndef TREE_H
22
#define TREE_H
22
#define TREE_H
23
#include <QPointF>
23
#include <QPointF>
24
24
25
#include "grid.h"
25
#include "grid.h"
26
26
27
27
28
// mortality workshop 2015 / COST Action with H. Bugmann
28
// mortality workshop 2015 / COST Action with H. Bugmann
29
//#define ALT_TREE_MORTALITY
29
//#define ALT_TREE_MORTALITY
30
30
31
31
32
// forwards
32
// forwards
33
class Species;
33
class Species;
34
class Stamp;
34
class Stamp;
35
class ResourceUnit;
35
class ResourceUnit;
36
struct HeightGridValue;
36
struct HeightGridValue;
37
struct TreeGrowthData;
37
struct TreeGrowthData;
38
class TreeOut;
38
class TreeOut;
39
class TreeRemovedOut;
39
class TreeRemovedOut;
40
class LandscapeRemovedOut;
40
class LandscapeRemovedOut;
41
41
42
class Tree
42
class Tree
43
{
43
{
44
public:
44
public:
45
    // lifecycle
45
    // lifecycle
46
    Tree();
46
    Tree();
47
    void setup(); ///< calculates initial values for biomass pools etc. after dimensions are set.
47
    void setup(); ///< calculates initial values for biomass pools etc. after dimensions are set.
48
48
49
    // access to properties
49
    // access to properties
50
    int id() const { return mId; } ///< numerical unique ID of the tree
50
    int id() const { return mId; } ///< numerical unique ID of the tree
51
    int age() const { return mAge; } ///< the tree age (years)
51
    int age() const { return mAge; } ///< the tree age (years)
52
    /// @property position The tree does not store the floating point coordinates but only the index of pixel on the LIF grid
52
    /// @property position The tree does not store the floating point coordinates but only the index of pixel on the LIF grid
53
    const QPointF position() const { Q_ASSERT(mGrid!=0); return mGrid->cellCenterPoint(mPositionIndex); }
53
    const QPointF position() const { Q_ASSERT(mGrid!=0); return mGrid->cellCenterPoint(mPositionIndex); }
54
    const QPoint positionIndex() const { return mPositionIndex; }
54
    const QPoint positionIndex() const { return mPositionIndex; }
55
    const Species* species() const { Q_ASSERT(mRU!=0); return mSpecies; } ///< pointer to the tree species of the tree.
55
    const Species* species() const { Q_ASSERT(mRU!=0); return mSpecies; } ///< pointer to the tree species of the tree.
56
    const ResourceUnit *ru() const { Q_ASSERT(mRU!=0); return mRU; } ///< pointer to the ressource unit the tree belongs to.
56
    const ResourceUnit *ru() const { Q_ASSERT(mRU!=0); return mRU; } ///< pointer to the ressource unit the tree belongs to.
57
57
58
    // properties
58
    // properties
59
    float dbh() const { return mDbh; } ///< dimater at breast height in cm
59
    float dbh() const { return mDbh; } ///< dimater at breast height in cm
60
    float height() const { return mHeight; } ///< tree height in m
60
    float height() const { return mHeight; } ///< tree height in m
61
    float lightResourceIndex() const { return mLRI; } ///< LRI of the tree (updated during readStamp())
61
    float lightResourceIndex() const { return mLRI; } ///< LRI of the tree (updated during readStamp())
62
    float leafArea() const { return mLeafArea; } ///< leaf area (m2) of the tree
62
    float leafArea() const { return mLeafArea; } ///< leaf area (m2) of the tree
63
    double volume() const; ///< volume (m3) of stem volume based on geometry and density calculated on the fly.
63
    double volume() const; ///< volume (m3) of stem volume based on geometry and density calculated on the fly.
64
    double basalArea() const; ///< basal area of the tree at breast height in m2
64
    double basalArea() const; ///< basal area of the tree at breast height in m2
65
    bool isDead() const { return flag(Tree::TreeDead); } ///< returns true if the tree is already dead.
65
    bool isDead() const { return flag(Tree::TreeDead); } ///< returns true if the tree is already dead.
66
    float crownRadius() const; ///< fetch crown radius (m) from the attached stamp
66
    float crownRadius() const; ///< fetch crown radius (m) from the attached stamp
67
    // biomass properties
67
    // biomass properties
68
    float biomassFoliage() const { return mFoliageMass; } ///< mass (kg) of foliage
68
    float biomassFoliage() const { return mFoliageMass; } ///< mass (kg) of foliage
69
    float biomassBranch() const;  ///< mass (kg) of branches
69
    float biomassBranch() const;  ///< mass (kg) of branches
70
    float biomassFineRoot() const { return mFineRootMass; } ///< mass (kg) of fine roots
70
    float biomassFineRoot() const { return mFineRootMass; } ///< mass (kg) of fine roots
71
    float biomassCoarseRoot() const { return mCoarseRootMass; } ///< mass (kg) of coarse roots
71
    float biomassCoarseRoot() const { return mCoarseRootMass; } ///< mass (kg) of coarse roots
72
    float biomassStem() const { return mWoodyMass; } ///< mass (kg) of stem
72
    float biomassStem() const { return mWoodyMass; } ///< mass (kg) of stem
73
    double barkThickness() const; ///< thickness of the bark (cm)
73
    double barkThickness() const; ///< thickness of the bark (cm)
74
    float stressIndex() const { return mStressIndex; } ///< the scalar stress rating (0..1)
74
    float stressIndex() const { return mStressIndex; } ///< the scalar stress rating (0..1)
75
75
76
    // actions
76
    // actions
77
    enum TreeRemovalType { TreeDeath=0, TreeHarvest=1, TreeDisturbance=2, TreeSalavaged=3, TreeKilled=4, TreeCutDown=5};
77
    enum TreeRemovalType { TreeDeath=0, TreeHarvest=1, TreeDisturbance=2, TreeSalavaged=3, TreeKilled=4, TreeCutDown=5};
78
    /// the tree dies (is killed)
78
    /// the tree dies (is killed)
79
    void die(TreeGrowthData *d=0);
79
    void die(TreeGrowthData *d=0);
80
    /// remove the tree (management). removalFractions for tree compartments: if 0: all biomass stays in the system, 1: all is "removed"
80
    /// remove the tree (management). removalFractions for tree compartments: if 0: all biomass stays in the system, 1: all is "removed"
81
    /// default values: all biomass remains in the forest (i.e.: kill()).
81
    /// default values: all biomass remains in the forest (i.e.: kill()).
82
    void remove(double removeFoliage=0., double removeBranch=0., double removeStem=0. );
82
    void remove(double removeFoliage=0., double removeBranch=0., double removeStem=0. );
83
    /// remove the tree due to an special event (disturbance)
83
    /// remove the tree due to an special event (disturbance)
84
    /// the part of the biomass that goes not to soil/snags is removed (e.g. fire)
84
    /// the part of the biomass that goes not to soil/snags is removed (e.g. fire)
85
    /// @param stem_to_soil_fraction (0..1) of stem biomass that is routed to the soil
85
    /// @param stem_to_soil_fraction (0..1) of stem biomass that is routed to the soil
86
    /// @param stem_to_snag_fraction (0..1) of the stem biomass continues as standing dead
86
    /// @param stem_to_snag_fraction (0..1) of the stem biomass continues as standing dead
87
    /// @param branch_to_soil_fraction (0..1) of branch biomass that is routed to the soil
87
    /// @param branch_to_soil_fraction (0..1) of branch biomass that is routed to the soil
88
    /// @param branch_to_snag_fraction (0..1) of the branch biomass continues as standing dead
88
    /// @param branch_to_snag_fraction (0..1) of the branch biomass continues as standing dead
89
    /// @param foliage_to_soil_fraciton (0..1) fraction of biomass that goes directly to the soil. The rest (1.-fraction) is removed.
89
    /// @param foliage_to_soil_fraciton (0..1) fraction of biomass that goes directly to the soil. The rest (1.-fraction) is removed.
90
    void removeDisturbance(const double stem_to_soil_fraction, const double stem_to_snag_fraction,
90
    void removeDisturbance(const double stem_to_soil_fraction, const double stem_to_snag_fraction,
91
                           const double branch_to_soil_fraction, const double branch_to_snag_fraction,
91
                           const double branch_to_soil_fraction, const double branch_to_snag_fraction,
92
                           const double foliage_to_soil_fraction);
92
                           const double foliage_to_soil_fraction);
93
93
94
    void enableDebugging(const bool enable=true) {setFlag(Tree::TreeDebugging, enable); }
94
    void enableDebugging(const bool enable=true) {setFlag(Tree::TreeDebugging, enable); }
95
    /// removes fractions (0..1) for foliage, branches, stem from a tree, e.g. due to a fire.
95
    /// removes fractions (0..1) for foliage, branches, stem from a tree, e.g. due to a fire.
96
    /// values of "0" remove nothing, "1" removes the full compartent.
96
    /// values of "0" remove nothing, "1" removes the full compartent.
97
    void removeBiomassOfTree(const double removeFoliageFraction, const double removeBranchFraction, const double removeStemFraction);
97
    void removeBiomassOfTree(const double removeFoliageFraction, const double removeBranchFraction, const double removeStemFraction);
98
98
99
    // setters for initialization
99
    // setters for initialization
100
    void setNewId() { mId = m_nextId++; } ///< force a new id for this object (after copying trees)
100
    void setNewId() { mId = m_nextId++; } ///< force a new id for this object (after copying trees)
101
    void setId(const int id) { mId = id; } ///< set a spcific ID (if provided in stand init file).
101
    void setId(const int id) { mId = id; } ///< set a spcific ID (if provided in stand init file).
102
    void setPosition(const QPointF pos) { Q_ASSERT(mGrid!=0); mPositionIndex = mGrid->indexAt(pos); }
102
    void setPosition(const QPointF pos) { Q_ASSERT(mGrid!=0); mPositionIndex = mGrid->indexAt(pos); }
103
    void setPosition(const QPoint posIndex) { mPositionIndex = posIndex; }
103
    void setPosition(const QPoint posIndex) { mPositionIndex = posIndex; }
104
    void setDbh(const float dbh) { mDbh=dbh; }
104
    void setDbh(const float dbh) { mDbh=dbh; }
105
    void setHeight(const float height);
105
    void setHeight(const float height);
106
    void setSpecies(Species *ts) { mSpecies=ts; }
106
    void setSpecies(Species *ts) { mSpecies=ts; }
107
    void setRU(ResourceUnit *ru) { mRU = ru; }
107
    void setRU(ResourceUnit *ru) { mRU = ru; }
108
    void setAge(const int age, const float treeheight);
108
    void setAge(const int age, const float treeheight);
109
109
110
    // management flags (used by ABE management system)
110
    // management flags (used by ABE management system)
111
    void markForHarvest(bool do_mark) { setFlag(Tree::MarkForHarvest, do_mark);}
111
    void markForHarvest(bool do_mark) { setFlag(Tree::MarkForHarvest, do_mark);}
112
    bool isMarkedForHarvest() const { return flag(Tree::MarkForHarvest);}
112
    bool isMarkedForHarvest() const { return flag(Tree::MarkForHarvest);}
113
    void markForCut(bool do_mark) { setFlag(Tree::MarkForCut, do_mark);}
113
    void markForCut(bool do_mark) { setFlag(Tree::MarkForCut, do_mark);}
114
    bool isMarkedForCut() const { return flag(Tree::MarkForCut);}
114
    bool isMarkedForCut() const { return flag(Tree::MarkForCut);}
115
    void markCropTree(bool do_mark) { setFlag(Tree::MarkCropTree, do_mark);}
115
    void markCropTree(bool do_mark) { setFlag(Tree::MarkCropTree, do_mark);}
116
    bool isMarkedAsCropTree() const { return flag(Tree::MarkCropTree);}
116
    bool isMarkedAsCropTree() const { return flag(Tree::MarkCropTree);}
117
    void markCropCompetitor(bool do_mark) { setFlag(Tree::MarkCropCompetitor, do_mark);}
117
    void markCropCompetitor(bool do_mark) { setFlag(Tree::MarkCropCompetitor, do_mark);}
118
    bool isMarkedAsCropCompetitor() const { return flag(Tree::MarkCropCompetitor);}
118
    bool isMarkedAsCropCompetitor() const { return flag(Tree::MarkCropCompetitor);}
119
    // death reasons
119
    // death reasons
120
    void setDeathReasonWind()  { setFlag(Tree::TreeDeadWind, true); }
120
    void setDeathReasonWind()  { setFlag(Tree::TreeDeadWind, true); }
121
    void setDeathReasonBarkBeetle()  { setFlag(Tree::TreeDeadBarkBeetle, true); }
121
    void setDeathReasonBarkBeetle()  { setFlag(Tree::TreeDeadBarkBeetle, true); }
122
    void setDeathReasonFire()  { setFlag(Tree::TreeDeadFire, true); }
122
    void setDeathReasonFire()  { setFlag(Tree::TreeDeadFire, true); }
123
    void setDeathCutdown()  { setFlag(Tree::TreeDeadKillAndDrop, true); }
123
    void setDeathCutdown()  { setFlag(Tree::TreeDeadKillAndDrop, true); }
124
    void setIsHarvested()  { setFlag(Tree::TreeHarvested, true); }
124
    void setIsHarvested()  { setFlag(Tree::TreeHarvested, true); }
125
125
126
    bool isDeadWind() const { return flag(Tree::TreeDeadWind);}
126
    bool isDeadWind() const { return flag(Tree::TreeDeadWind);}
127
    bool isDeadBarkBeetle() const { return flag(Tree::TreeDeadBarkBeetle);}
127
    bool isDeadBarkBeetle() const { return flag(Tree::TreeDeadBarkBeetle);}
128
    bool isDeadFire() const { return flag(Tree::TreeDeadFire);}
128
    bool isDeadFire() const { return flag(Tree::TreeDeadFire);}
129
    bool isCutdown() const { return flag(Tree::TreeDeadKillAndDrop);}
129
    bool isCutdown() const { return flag(Tree::TreeDeadKillAndDrop);}
130
    bool isHarvested() const { return flag(Tree::TreeHarvested);}
130
    bool isHarvested() const { return flag(Tree::TreeHarvested);}
131
131
132
    // grid based light-concurrency functions
132
    // grid based light-concurrency functions
133
    void applyLIP(); ///< apply LightInfluencePattern onto the global grid
133
    void applyLIP(); ///< apply LightInfluencePattern onto the global grid
134
    void readLIF(); ///< calculate the lightResourceIndex with multiplicative approach
134
    void readLIF(); ///< calculate the lightResourceIndex with multiplicative approach
135
    void heightGrid(); ///< calculate the height grid
135
    void heightGrid(); ///< calculate the height grid
136
136
137
    void applyLIP_torus(); ///< apply LightInfluencePattern on a closed 1ha area
137
    void applyLIP_torus(); ///< apply LightInfluencePattern on a closed 1ha area
138
    void readLIF_torus(); ///< calculate LRI from a closed 1ha area
138
    void readLIF_torus(); ///< calculate LRI from a closed 1ha area
139
    void heightGrid_torus(); ///< calculate the height grid
139
    void heightGrid_torus(); ///< calculate the height grid
140
140
141
    void calcLightResponse(); ///< calculate light response
141
    void calcLightResponse(); ///< calculate light response
142
    // growth, etc.
142
    // growth, etc.
143
    void grow(); ///< main growth function to update the tree state.
143
    void grow(); ///< main growth function to update the tree state.
144
144
145
    // static functions
145
    // static functions
146
    static void setGrid(FloatGrid* gridToStamp, Grid<HeightGridValue> *dominanceGrid);
146
    static void setGrid(FloatGrid* gridToStamp, Grid<HeightGridValue> *dominanceGrid);
147
    // statistics
147
    // statistics
148
    static void resetStatistics();
148
    static void resetStatistics();
149
    static int statPrints() { return m_statPrint; }
149
    static int statPrints() { return m_statPrint; }
150
    static int statCreated() { return m_statCreated; }
150
    static int statCreated() { return m_statCreated; }
151
#ifdef ALT_TREE_MORTALITY
151
#ifdef ALT_TREE_MORTALITY
152
    static void mortalityParams(double dbh_inc_threshold, int stress_years, double stress_mort_prob);
152
    static void mortalityParams(double dbh_inc_threshold, int stress_years, double stress_mort_prob);
153
#endif
153
#endif
154
154
155
    QString dump();
155
    QString dump();
156
    void dumpList(QList<QVariant> &rTargetList);
156
    void dumpList(QList<QVariant> &rTargetList);
157
    const Stamp *stamp() const { return mStamp; } ///< TODO: only for debugging purposes
157
    const Stamp *stamp() const { return mStamp; } ///< TODO: only for debugging purposes
158
158
159
private:
159
private:
160
    // helping functions
160
    // helping functions
161
    void partitioning(TreeGrowthData &d); ///< split NPP into various plant pools.
161
    void partitioning(TreeGrowthData &d); ///< split NPP into various plant pools.
162
    double relative_height_growth(); ///< estimate height growth based on light status.
162
    double relative_height_growth(); ///< estimate height growth based on light status.
163
    void grow_diameter(TreeGrowthData &d); ///< actual growth of the tree's stem.
163
    void grow_diameter(TreeGrowthData &d); ///< actual growth of the tree's stem.
164
    void mortality(TreeGrowthData &d); ///< main function that checks whether trees is to die
164
    void mortality(TreeGrowthData &d); ///< main function that checks whether trees is to die
165
#ifdef ALT_TREE_MORTALITY
165
#ifdef ALT_TREE_MORTALITY
166
    void altMortality(TreeGrowthData &d); ///< alternative version of the mortality sub module
166
    void altMortality(TreeGrowthData &d); ///< alternative version of the mortality sub module
167
#endif
167
#endif
168
    void notifyTreeRemoved(TreeRemovalType reason); ///< record the removed volume in the height grid
168
    void notifyTreeRemoved(TreeRemovalType reason); ///< record the removed volume in the height grid
169
169
170
    // state variables
170
    // state variables
171
    int mId; ///< unique ID of tree
171
    int mId; ///< unique ID of tree
172
    int mAge; ///< age of tree in years
172
    int mAge; ///< age of tree in years
173
    float mDbh; ///< diameter at breast height [cm]
173
    float mDbh; ///< diameter at breast height [cm]
174
    float mHeight; ///< tree height [m]
174
    float mHeight; ///< tree height [m]
175
    QPoint mPositionIndex; ///< index of the trees position on the basic LIF grid
175
    QPoint mPositionIndex; ///< index of the trees position on the basic LIF grid
176
    // biomass compartements
176
    // biomass compartements
177
    float mLeafArea; ///< m2 leaf area
177
    float mLeafArea; ///< m2 leaf area
178
    float mOpacity; ///< multiplier on LIP weights, depending on leaf area status (opacity of the crown)
178
    float mOpacity; ///< multiplier on LIP weights, depending on leaf area status (opacity of the crown)
179
    float mFoliageMass; ///< kg of foliage (dry)
179
    float mFoliageMass; ///< kg of foliage (dry)
180
    float mWoodyMass; ///< kg biomass of aboveground stem biomass
180
    float mWoodyMass; ///< kg biomass of aboveground stem biomass
181
    float mFineRootMass; ///< kg biomass of fine roots (linked to foliage mass)
181
    float mFineRootMass; ///< kg biomass of fine roots (linked to foliage mass)
182
    float mCoarseRootMass; ///< kg biomass of coarse roots (allometric equation)
182
    float mCoarseRootMass; ///< kg biomass of coarse roots (allometric equation)
183
    // production relevant
183
    // production relevant
184
    float mNPPReserve; ///< NPP reserve pool [kg] - stores a part of assimilates for use in less favorable years
184
    float mNPPReserve; ///< NPP reserve pool [kg] - stores a part of assimilates for use in less favorable years
185
    float mLRI; ///< resulting lightResourceIndex
185
    float mLRI; ///< resulting lightResourceIndex
186
    float mLightResponse; ///< light response used for distribution of biomass on RU level
186
    float mLightResponse; ///< light response used for distribution of biomass on RU level
187
    // auxiliary
187
    // auxiliary
188
    float mDbhDelta; ///< diameter growth [cm]
188
    float mDbhDelta; ///< diameter growth [cm]
189
    float mStressIndex; ///< stress index (used for mortality)
189
    float mStressIndex; ///< stress index (used for mortality)
190
190
191
    // Stamp, Species, Resource Unit
191
    // Stamp, Species, Resource Unit
192
    const Stamp *mStamp;
192
    const Stamp *mStamp;
193
    Species *mSpecies;
193
    Species *mSpecies;
194
    ResourceUnit *mRU;
194
    ResourceUnit *mRU;
195
195
196
    // various flags
196
    // various flags
197
    int mFlags;
197
    int mFlags;
198
    /// (binary coded) tree flags
198
    /// (binary coded) tree flags
199
    enum Flags { TreeDead=1, TreeDebugging=2,
199
    enum Flags { TreeDead=1, TreeDebugging=2,
200
                 TreeDeadBarkBeetle=16, TreeDeadWind=32, TreeDeadFire=64, TreeDeadKillAndDrop=128, TreeHarvested=256,
200
                 TreeDeadBarkBeetle=16, TreeDeadWind=32, TreeDeadFire=64, TreeDeadKillAndDrop=128, TreeHarvested=256,
201
                 MarkForCut=512, // mark tree for being cut down
201
                 MarkForCut=512, // mark tree for being cut down
202
                 MarkForHarvest=1024, // mark tree for being harvested
202
                 MarkForHarvest=1024, // mark tree for being harvested
203
                 MarkCropTree=2048, // mark as crop tree
203
                 MarkCropTree=2048, // mark as crop tree
204
                 MarkCropCompetitor=4096 // mark as competitor for a crop tree
204
                 MarkCropCompetitor=4096 // mark as competitor for a crop tree
205
               };
205
               };
206
    /// set a Flag 'flag' to the value 'value'.
206
    /// set a Flag 'flag' to the value 'value'.
207
    void setFlag(const Tree::Flags flag, const bool value) { if (value) mFlags |= flag; else mFlags &= (flag ^ 0xffffff );}
207
    void setFlag(const Tree::Flags flag, const bool value) { if (value) mFlags |= flag; else mFlags &= (flag ^ 0xffffff );}
208
    /// set a number of flags (need to be constructed by or'ing flags together) at the same time to the Boolean value 'value'.
208
    /// set a number of flags (need to be constructed by or'ing flags together) at the same time to the Boolean value 'value'.
209
    void setFlag(const int flag, const bool value) { if (value) mFlags |= flag; else mFlags &= (flag ^ 0xffffff );}
209
    void setFlag(const int flag, const bool value) { if (value) mFlags |= flag; else mFlags &= (flag ^ 0xffffff );}
210
    /// retrieve the value of the flag 'flag'.
210
    /// retrieve the value of the flag 'flag'.
211
    bool flag(const Tree::Flags flag) const { return mFlags & flag; }
211
    bool flag(const Tree::Flags flag) const { return mFlags & flag; }
212
212
213
    // special functions
213
    // special functions
214
    bool isDebugging() { return flag(Tree::TreeDebugging); }
214
    bool isDebugging() { return flag(Tree::TreeDebugging); }
215
215
216
    // static data
216
    // static data
217
    static FloatGrid *mGrid;
217
    static FloatGrid *mGrid;
218
    static Grid<HeightGridValue> *mHeightGrid;
218
    static Grid<HeightGridValue> *mHeightGrid;
219
    static TreeRemovedOut *mRemovalOutput;
219
    static TreeRemovedOut *mRemovalOutput;
220
    static void setTreeRemovalOutput(TreeRemovedOut *rout) { mRemovalOutput=rout; }
220
    static void setTreeRemovalOutput(TreeRemovedOut *rout) { mRemovalOutput=rout; }
221
    static LandscapeRemovedOut *mLSRemovalOutput;
221
    static LandscapeRemovedOut *mLSRemovalOutput;
222
    static void setLandscapeRemovalOutput(LandscapeRemovedOut *rout) { mLSRemovalOutput=rout; }
222
    static void setLandscapeRemovalOutput(LandscapeRemovedOut *rout) { mLSRemovalOutput=rout; }
223
223
224
    // statistics
224
    // statistics
225
    static int m_statPrint;
225
    static int m_statPrint;
226
    static int m_statAboveZ;
226
    static int m_statAboveZ;
227
    static int m_statCreated;
227
    static int m_statCreated;
228
    static int m_nextId;
228
    static int m_nextId;
229
229
230
    // friends
230
    // friends
231
    friend class TreeWrapper;
231
    friend class TreeWrapper;
232
    friend class StandStatistics;
232
    friend class StandStatistics;
233
    friend class TreeOut;
233
    friend class TreeOut;
234
    friend class TreeRemovedOut;
234
    friend class TreeRemovedOut;
235
    friend class LandscapeRemovedOut;
235
    friend class LandscapeRemovedOut;
236
    friend class Snapshot;
236
    friend class Snapshot;
237
};
237
};
238
238
239
/// internal data structure which is passed between function and to statistics
239
/// internal data structure which is passed between function and to statistics
240
struct TreeGrowthData
240
struct TreeGrowthData
241
{
241
{
242
    double NPP; ///< total NPP (kg)
242
    double NPP; ///< total NPP (kg)
243
    double NPP_above; ///< NPP aboveground (kg) (NPP - fraction roots), no consideration of tree senescence
243
    double NPP_above; ///< NPP aboveground (kg) (NPP - fraction roots), no consideration of tree senescence
244
    double NPP_stem;  ///< NPP used for growth of stem (dbh,h)
244
    double NPP_stem;  ///< NPP used for growth of stem (dbh,h)
245
    double stress_index; ///< stress index used for mortality calculation
245
    double stress_index; ///< stress index used for mortality calculation
246
    TreeGrowthData(): NPP(0.), NPP_above(0.), NPP_stem(0.) {}
246
    TreeGrowthData(): NPP(0.), NPP_above(0.), NPP_stem(0.) {}
247
};
247
};
248
#endif // TREE_H
248
#endif // TREE_H
249
 
249