Rev 1176 | Rev 1178 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1176 | Rev 1177 | ||
---|---|---|---|
Line 10... | Line 10... | ||
10 | 10 | ||
11 | struct SaplingTree { |
11 | struct SaplingTree { |
12 | SaplingTree() { clear(); } |
12 | SaplingTree() { clear(); } |
13 | short unsigned int age; // number of consectuive years the sapling suffers from dire conditions |
13 | short unsigned int age; // number of consectuive years the sapling suffers from dire conditions |
14 | short signed int species_index; // index of the species within the resource-unit-species container |
14 | short signed int species_index; // index of the species within the resource-unit-species container |
15 | unsigned char stress_years; // (upper 16bits) + age of sapling (lower 16 bits) |
- | |
- | 15 | unsigned char stress_years; // number of consecutive years that a sapling suffers from stress |
|
16 | unsigned char flags; // flags, e.g. whether sapling stems from sprouting |
16 | unsigned char flags; // flags, e.g. whether sapling stems from sprouting |
17 | float height; // height of the sapling in meter |
17 | float height; // height of the sapling in meter |
18 | bool is_occupied() const { return height>0.f; } |
18 | bool is_occupied() const { return height>0.f; } |
19 | void clear() { age=0; species_index=-1; stress_years=0; flags=0; height=0.f; } |
19 | void clear() { age=0; species_index=-1; stress_years=0; flags=0; height=0.f; } |
20 | void setSapling(const float h_m, const int age_yrs, const int species_idx) { height=h_m; age=static_cast<short unsigned int>(age_yrs); stress_years=0; species_index=static_cast<short signed int>(species_idx); } |
- | |
- | 20 | void setSapling(const float h_m, const int age_yrs, const int species_idx) { height=h_m; |
|
- | 21 | age=static_cast<short unsigned int>(age_yrs); |
|
- | 22 | stress_years=0; |
|
- | 23 | species_index=static_cast<short signed int>(species_idx); } |
|
21 | // flags
|
24 | // flags
|
22 | bool is_sprout() const { return flags & 1; } |
25 | bool is_sprout() const { return flags & 1; } |
23 | void set_sprout(const bool sprout) {if (sprout) flags |= 1; else flags &= (1 ^ 0xffffff ); } |
26 | void set_sprout(const bool sprout) {if (sprout) flags |= 1; else flags &= (1 ^ 0xffffff ); } |
24 | // get resource unit species of the sapling tree
|
27 | // get resource unit species of the sapling tree
|
25 | ResourceUnitSpecies *resourceUnitSpecies(const ResourceUnit *ru); |
28 | ResourceUnitSpecies *resourceUnitSpecies(const ResourceUnit *ru); |
Line 91... | Line 94... | ||
91 | {
|
94 | {
|
92 | public: |
95 | public: |
93 | SaplingStat() { clearStatistics(); } |
96 | SaplingStat() { clearStatistics(); } |
94 | void clearStatistics(); |
97 | void clearStatistics(); |
95 | /// calculate statistics (and carbon flows) for the saplings of species 'species' on 'ru'.
|
98 | /// calculate statistics (and carbon flows) for the saplings of species 'species' on 'ru'.
|
96 | /// The 'cohorts_per_area' gives the average cohort density on the RU (avg. cohorts/pixel).
|
- | |
97 | void calculate(const Species *species, ResourceUnit *ru, double cohorts_per_area); |
- | |
- | 99 | void calculate(const Species *species, ResourceUnit *ru); |
|
98 | // actions
|
100 | // actions
|
99 | void addCarbonOfDeadSapling(float dbh) { mDied++; mSumDbhDied+=dbh; } |
101 | void addCarbonOfDeadSapling(float dbh) { mDied++; mSumDbhDied+=dbh; } |
100 | 102 | ||
101 | // access to statistics
|
103 | // access to statistics
|
102 | int newSaplings() const { return mAdded; } |
104 | int newSaplings() const { return mAdded; } |
103 | int diedSaplings() const { return mDied; } |
105 | int diedSaplings() const { return mDied; } |
104 | int livingSaplings() const { return mLiving; } ///< get the number |
- | |
- | 106 | int livingCohorts() const { return mLiving; } ///< get the number of cohorts |
|
- | 107 | double livingSaplings() const { return mLivingSaplings; } |
|
- | 108 | double livingSaplingsSmall() const { return mLivingSmallSaplings; } |
|
105 | int recruitedSaplings() const { return mRecruited; } |
109 | int recruitedSaplings() const { return mRecruited; } |
106 | /// returns the *represented* (Reineke's Law) number of trees (N/ha) and the mean dbh/height (cm/m)
|
110 | /// returns the *represented* (Reineke's Law) number of trees (N/ha) and the mean dbh/height (cm/m)
|
107 | double livingStemNumber(const Species *species, double &rAvgDbh, double &rAvgHeight, double &rAvgAge) const; |
111 | double livingStemNumber(const Species *species, double &rAvgDbh, double &rAvgHeight, double &rAvgAge) const; |
108 | 112 | ||
109 | double averageHeight() const { return mAvgHeight; } |
113 | double averageHeight() const { return mAvgHeight; } |
Line 113... | Line 117... | ||
113 | // carbon and nitrogen
|
117 | // carbon and nitrogen
|
114 | const CNPair &carbonLiving() const { return mCarbonLiving; } ///< state of the living |
118 | const CNPair &carbonLiving() const { return mCarbonLiving; } ///< state of the living |
115 | const CNPair &carbonGain() const { return mCarbonGain; } ///< state of the living |
119 | const CNPair &carbonGain() const { return mCarbonGain; } ///< state of the living |
116 | 120 | ||
117 | private: |
121 | private: |
118 | int mAdded; ///< number of trees added |
- | |
119 | int mRecruited; ///< number recruited (i.e. grown out of regeneration layer) |
- | |
120 | int mDied; ///< number of trees died |
- | |
- | 122 | int mAdded; ///< number of tree cohorts added |
|
- | 123 | int mRecruited; ///< number of cohorts recruited (i.e. grown out of regeneration layer) |
|
- | 124 | int mDied; ///< number of tree cohorts died |
|
121 | double mSumDbhDied; ///< running sum of dbh of died trees (used to calculate detritus) |
125 | double mSumDbhDied; ///< running sum of dbh of died trees (used to calculate detritus) |
122 | int mLiving; ///< number of trees (cohorts!!!) currently in the regeneration layer |
126 | int mLiving; ///< number of trees (cohorts!!!) currently in the regeneration layer |
123 | double mLivingSaplings; ///< number of individual trees in the regen layer (using Reinekes R) |
- | |
- | 127 | double mLivingSaplings; ///< number of individual trees in the regen layer (using Reinekes R), with h>1.3m |
|
- | 128 | double mLivingSmallSaplings; ///< number of individual trees of cohorts < 1.3m height |
|
124 | double mAvgHeight; ///< average height of saplings (m) |
129 | double mAvgHeight; ///< average height of saplings (m) |
125 | double mAvgAge; ///< average age of saplings (years) |
130 | double mAvgAge; ///< average age of saplings (years) |
126 | double mAvgDeltaHPot; ///< average height increment potential (m) |
131 | double mAvgDeltaHPot; ///< average height increment potential (m) |
127 | double mAvgHRealized; ///< average realized height increment |
132 | double mAvgHRealized; ///< average realized height increment |
128 | CNPair mCarbonLiving; ///< kg Carbon (kg/ru) of saplings |
133 | CNPair mCarbonLiving; ///< kg Carbon (kg/ru) of saplings |
Line 159... | Line 164... | ||
159 | 164 | ||
160 | static void setRecruitmentVariation(const double variation) { mRecruitmentVariation = variation; } |
165 | static void setRecruitmentVariation(const double variation) { mRecruitmentVariation = variation; } |
161 | static void updateBrowsingPressure(); |
166 | static void updateBrowsingPressure(); |
162 | 167 | ||
163 | private: |
168 | private: |
164 | bool growSapling(const ResourceUnit *ru, SaplingCell &scell, SaplingTree &tree, int isc, float dom_height, float lif_value); |
- | |
- | 169 | bool growSapling(const ResourceUnit *ru, SaplingCell &scell, SaplingTree &tree, int isc, float dom_height, float lif_value, int cohorts_on_px); |
|
165 | //Grid<SaplingCell> mGrid;
|
170 | //Grid<SaplingCell> mGrid;
|
166 | static double mRecruitmentVariation; |
171 | static double mRecruitmentVariation; |
167 | static double mBrowsingPressure; |
172 | static double mBrowsingPressure; |
168 | }; |
173 | }; |
169 | 174 |