GCBM
Public Member Functions | Private Member Functions | Private Attributes | List of all members
CBMTransitionRulesModule Class Reference

#include <cbmtransitionrulesmodule.h>

Inheritance diagram for CBMTransitionRulesModule:
Inheritance graph
Collaboration diagram for CBMTransitionRulesModule:
Collaboration graph

Public Member Functions

 CBMTransitionRulesModule (std::shared_ptr< StandGrowthCurveFactory > gcFactory, std::shared_ptr< VolumeToBiomassCarbonGrowth > volumeToBioGrowth)
 
virtual ~CBMTransitionRulesModule ()=default
 
void subscribe (NotificationCenter &notificationCenter) override
 
flint::ModuleTypes moduleType ()
 
virtual void doDisturbanceEvent (DynamicVar) override
 
virtual void doLocalDomainInit () override
 
virtual void doTimingInit () override
 
virtual void doTimingShutdown () override
 
- Public Member Functions inherited from CBMModuleBase
virtual ~CBMModuleBase ()=default
 
void onSystemInit () override
 
void onSystemShutdown () override
 
void onLocalDomainInit () override
 
void onLocalDomainShutdown () override
 
void onLocalDomainProcessingUnitInit () override
 
void onLocalDomainProcessingUnitShutdown () override
 
void onPreTimingSequence () override
 
void onTimingInit () override
 
void onTimingPrePostInit () override
 
void onTimingPostInit () override
 
void onTimingPostInit2 () override
 
void onTimingShutdown () override
 
void onTimingStep () override
 
void onTimingPreEndStep () override
 
void onTimingEndStep () override
 
void onTimingPostStep () override
 
void onOutputStep () override
 
void onPrePostDisturbanceEvent () override
 
void onPostDisturbanceEvent () override
 
void onPostDisturbanceEvent2 () override
 
void onError (std::string msg) override
 
void onDisturbanceEvent (DynamicVar e) override
 
void onPostNotification (short preMessageSignal) override
 
virtual void doSystemInit ()
 
virtual void doSystemShutdown ()
 
virtual void doLocalDomainShutdown ()
 
virtual void doLocalDomainProcessingUnitInit ()
 
virtual void doLocalDomainProcessingUnitShutdown ()
 
virtual void doPreTimingSequence ()
 
virtual void doTimingPrePostInit ()
 
virtual void doTimingPostInit ()
 
virtual void doTimingPostInit2 ()
 
virtual void doTimingStep ()
 
virtual void doTimingPreEndStep ()
 
virtual void doTimingEndStep ()
 
virtual void doTimingPostStep ()
 
virtual void doOutputStep ()
 
virtual void doError (std::string msg)
 
virtual void doPrePostDisturbanceEvent ()
 
virtual void doPostDisturbanceEvent ()
 
virtual void doPostDisturbanceEvent2 ()
 
virtual void doPostNotification (short preMessageSignal)
 

Private Member Functions

int findTransitionRule (const std::string &disturbanceType)
 
int findYieldCurveAge ()
 
double calculateBiomass ()
 

Private Attributes

flint::IVariable * _age
 
flint::IVariable * _cset
 
flint::IVariable * _regenDelay
 
flint::IVariable * _transitionRuleMatches
 
std::unordered_map< int, TransitionRule_transitions
 
bool _allowMatchingRules = false
 
std::shared_ptr< VolumeToBiomassCarbonGrowth_volumeToBioGrowth
 
std::shared_ptr< StandGrowthCurveFactory_gcFactory
 
const flint::IPool * _softwoodMerch
 
const flint::IPool * _softwoodOther
 
const flint::IPool * _softwoodFoliage
 
const flint::IPool * _softwoodCoarseRoots
 
const flint::IPool * _softwoodFineRoots
 
const flint::IPool * _hardwoodMerch
 
const flint::IPool * _hardwoodOther
 
const flint::IPool * _hardwoodFoliage
 
const flint::IPool * _hardwoodCoarseRoots
 
const flint::IPool * _hardwoodFineRoots
 
flint::IVariable * _gcId
 
flint::IVariable * _spuId
 
Int64 _standSpuId
 

Constructor & Destructor Documentation

◆ CBMTransitionRulesModule()

CBMTransitionRulesModule ( std::shared_ptr< StandGrowthCurveFactory gcFactory,
std::shared_ptr< VolumeToBiomassCarbonGrowth volumeToBioGrowth 
)

◆ ~CBMTransitionRulesModule()

virtual ~CBMTransitionRulesModule ( )
virtualdefault

Member Function Documentation

◆ calculateBiomass()

double calculateBiomass ( )
private

Assign double variable totalAgBiomass as 0.0
for each pool in the array,add the pool value to totalAgBiomass.
return totalAgBiomass.

Returns
double

◆ doDisturbanceEvent()

void doDisturbanceEvent ( DynamicVar  n)
overridevirtual

Assign transitionRuleId as -1.
if parameter n contains "transition", assign transitionRuleId as "transition" of parameter n.
if CBMTransitionRulesModule._allowMatchingRules and transitionRuleId are both equal to -1,
Invoke findTransitionRule() using "disturbance" of parameter n as a parameter and assign the value to transitionRuleId. Assign transition as transitionRuleId of CBMTransitionRulesModule._transitions value.
Assign CBMTransitionRulesModule._regenDelay value as transition CBMTransitionRulesModule._regenDelay.
Assign cset as CBMTransitionRulesModule._cset value. For each classifer in transition CBMTransitionRulesModule._classifers,
if the second element of classifer is not equal to "?", Assign first element of classifer of cset as second element of classifier.
Assign CBMTransitionRulesModule._cset value as cset.
Assign variables resetType as transition TransitionRule._resetType and resetAge as transition TransitionRule._resetAge .
if resetAge is equal to AgeResetType::Absolute and resetAge is greater than -1, Assign CBMTransitionRulesModule._age value as resetAge. else if resetAge is equal to AgeResetType::Relative, assign integer variables currentAge as CBMTransitionRulesModule._age value and
newAge as the max of 0 and sum of currentAge and resetAge.
Assign CBMTransitionRulesModule._age value as newAge.
else if resetType is equal to AgeResetType::Yield, invoke findYieldCurveAge() and assign the value to integer variable newAge.
Assign CBMTransitionRulesModule._age value as newAge.

Exceptions
SimulationError : Handles error during simulation.
Parameters
nDynamicVar
Returns
void

Reimplemented from CBMModuleBase.

◆ doLocalDomainInit()

void doLocalDomainInit ( )
overridevirtual

Initialise CBMTransitionRulesModule._gcId,CBMTransitionRulesModule._spuId,CBMTransitionRulesModule._age,
CBMTransitionRulesModule._cset,CBMTransitionRulesModule._regenDelay,CBMTransitionRulesModule._softwoodMerch,
CBMTransitionRulesModule._softwoodFoliage,CBMTransitionRulesModule._softwoodOther,CBMTransitionRulesModule._softwoodCoarseRoots,
CBMTransitionRulesModule._softwoodFineRoots,CBMTransitionRulesModule._hardwoodMerch,CBMTransitionRulesModule._hardwoodFoliage,
CBMTransitionRulesModule._hardwoodOther,CBMTransitionRulesModule._hardwoodCoarseRoots and CBMTransitionRulesModule._hardwoodFineRoots.
If _landUnitData has variable "transition_rules_matches", assign CBMTransitionRulesModule._transitionRuleMatches as "transition_rule_matches" in _landUnitData and
CBMTransitionRulesModule._allowMatchingRules as true.
Assign a constant variable transitionRules as "transition_rules" value in _landUnitData.
If transitionRules is a vector,
for each transitionRuleData in transitionRules, create a TransitionRule object using transitionRuleData as a parameter and
assign the index TransitionRule object Id in CBMTransitionRulesModule._transitions as the TransitionRule object.
else, create a TransitionRule object using a dynamic object of transitionRules and
assign the index TransistionRule object Id in CBMTransitionRulesModule._transitions as the TransitionRule object.
Assign a constant variable transitionRuleClassifiers as "transition_rule_classifiers" value in _landUnitData.
if transitionRuleClassifers is not empty,check if transitionRuleClassifiers is a vector and
for each transitionRule in transitionRuleClassifiers,
add classifier using "classifer_name" and "classifer_value" in transistionRule to index transitionRule id in CBMTransitionRulesModule._transitions.
if transistionRuleClassifiers is not a vector,
add classifier using "classifer_name" and "classifer_value" in transistionRuleClassifers to index transitionRuleClassifers id in CBMTransitionRulesModule._transitions.

Returns
void

Reimplemented from CBMModuleBase.

◆ doTimingInit()

void doTimingInit ( )
overridevirtual

◆ doTimingShutdown()

void doTimingShutdown ( )
overridevirtual

Assign CBMTransitionRulesModule._regenDelay value as 0.

Returns
void

Reimplemented from CBMModuleBase.

◆ findTransitionRule()

int findTransitionRule ( const std::string &  disturbanceType)
private

If CBMTransitionRulesModule._transitionRuleMatches value contains parameter disturbanceType, return the index disturbanceType in CBMTransitionRulesModule._transitionRuleMatches. else return -1.

Parameters
disturbanceTypestring
Returns
int

◆ findYieldCurveAge()

int findYieldCurveAge ( )
private

If CBMTransitionRulesModule._gcId is empty, assign variable standGrowthCurveId as - 1,
else assign standGrowthCurveId as CBMTransitionRulesModule._gcId.
Assign boolean variable carbonCurveFound as stand growth curve and related yield table from memory.
If carbonCurveFound is false, Create stand growth curve using standGrowthCurveId, CBMTransitionRulesModule._standSpuId and *_landUnitData.
Generate Biomass Carbon curve using standGrowthCurve as a parameter.
Invoke calculateBiomass() and assign the value to standBiomass.
Invoke VolumeToBiomassCarbonGrowth.getAboveGroundCarbonCurve() using standGrowthCurveId and CBMTransitionRulesModule._standSpuId and assign it to agCarbonCurve.
Assign integer variable matchingAge as the size of agCarbonCurve -1.
For each iteration in ageCarbonCurve, check if ageCarbonCurve is greater than standBiomass and
assign matchingAge as the index. return matchingAge.

Returns
int

◆ moduleType()

flint::ModuleTypes moduleType ( )

◆ subscribe()

void subscribe ( NotificationCenter &  notificationCenter)
override

Subscribe to signals LocalDomainInit,DisturbanceEvent,TimingInit and TimingShutdown.

Parameters
notificationCenterNotificationCenter&
Returns
void

Member Data Documentation

◆ _age

flint::IVariable* _age
private

◆ _allowMatchingRules

bool _allowMatchingRules = false
private

◆ _cset

flint::IVariable* _cset
private

◆ _gcFactory

std::shared_ptr<StandGrowthCurveFactory> _gcFactory
private

◆ _gcId

flint::IVariable* _gcId
private

◆ _hardwoodCoarseRoots

const flint::IPool* _hardwoodCoarseRoots
private

◆ _hardwoodFineRoots

const flint::IPool* _hardwoodFineRoots
private

◆ _hardwoodFoliage

const flint::IPool* _hardwoodFoliage
private

◆ _hardwoodMerch

const flint::IPool* _hardwoodMerch
private

◆ _hardwoodOther

const flint::IPool* _hardwoodOther
private

◆ _regenDelay

flint::IVariable* _regenDelay
private

◆ _softwoodCoarseRoots

const flint::IPool* _softwoodCoarseRoots
private

◆ _softwoodFineRoots

const flint::IPool* _softwoodFineRoots
private

◆ _softwoodFoliage

const flint::IPool* _softwoodFoliage
private

◆ _softwoodMerch

const flint::IPool* _softwoodMerch
private

◆ _softwoodOther

const flint::IPool* _softwoodOther
private

◆ _spuId

flint::IVariable* _spuId
private

◆ _standSpuId

Int64 _standSpuId
private

◆ _transitionRuleMatches

flint::IVariable* _transitionRuleMatches
private

◆ _transitions

std::unordered_map<int, TransitionRule> _transitions
private

◆ _volumeToBioGrowth

std::shared_ptr<VolumeToBiomassCarbonGrowth> _volumeToBioGrowth
private

The documentation for this class was generated from the following files: