GCBM
cbmtransitionrulesmodule.h
Go to the documentation of this file.
1 #ifndef MOJA_MODULES_CBM_CBMTRANSITIONRULESMODULE_H_
2 #define MOJA_MODULES_CBM_CBMTRANSITIONRULESMODULE_H_
3 
4 #include "moja/flint/modulebase.h"
5 #include "moja/hash.h"
9 
10 #include <unordered_map>
11 
12 namespace moja {
13  namespace modules {
14  namespace cbm {
15 
16  enum class AgeResetType {
17  Absolute,
18  Relative,
19  Yield
20  };
21 
23  public:
25  TransitionRule(const DynamicObject& data);
28 
29  int id() { return _id; }
31  int resetAge() { return _resetAge; }
32  int regenDelay() { return _regenDelay; }
33 
34  const std::unordered_map<std::string, std::string> classifiers() const {
35  return _classifiers;
36  }
37 
38  void addClassifier(std::string name, std::string value) {
39  _classifiers[name] = value;
40  }
41 
42  private:
43  int _id;
45  int _resetAge;
47  std::unordered_map<std::string, std::string> _classifiers;
48  };
49 
51  public:
52  CBMTransitionRulesModule(std::shared_ptr<StandGrowthCurveFactory> gcFactory, std::shared_ptr<VolumeToBiomassCarbonGrowth> volumeToBioGrowth)
53  : CBMModuleBase(), _gcFactory(gcFactory), _volumeToBioGrowth(volumeToBioGrowth) {};
54 
55  virtual ~CBMTransitionRulesModule() = default;
56 
57  void subscribe(NotificationCenter& notificationCenter) override;
58 
59  flint::ModuleTypes moduleType() { return flint::ModuleTypes::DisturbanceEvent; };
60 
61  virtual void doDisturbanceEvent(DynamicVar) override;
62  virtual void doLocalDomainInit() override;
63  virtual void doTimingInit() override;
64  virtual void doTimingShutdown() override;
65 
66  private:
67  flint::IVariable* _age;
68  flint::IVariable* _cset;
69  flint::IVariable* _regenDelay;
70  flint::IVariable* _transitionRuleMatches;
71  std::unordered_map<int, TransitionRule> _transitions;
72  bool _allowMatchingRules = false;
73  std::shared_ptr<VolumeToBiomassCarbonGrowth> _volumeToBioGrowth;
74  std::shared_ptr<StandGrowthCurveFactory> _gcFactory;
75  const flint::IPool* _softwoodMerch;
76  const flint::IPool* _softwoodOther;
77  const flint::IPool* _softwoodFoliage;
78  const flint::IPool* _softwoodCoarseRoots;
79  const flint::IPool* _softwoodFineRoots;
80  const flint::IPool* _hardwoodMerch;
81  const flint::IPool* _hardwoodOther;
82  const flint::IPool* _hardwoodFoliage;
83  const flint::IPool* _hardwoodCoarseRoots;
84  const flint::IPool* _hardwoodFineRoots;
85  flint::IVariable* _gcId;
86  flint::IVariable* _spuId;
87  Int64 _standSpuId;
88 
89  int findTransitionRule(const std::string& disturbanceType);
90  int findYieldCurveAge();
91  double calculateBiomass();
92  };
93 
94  }
95  }
96 } // namespace moja::modules::cbm
97 #endif // MOJA_MODULES_CBM_CBMTRANSITIONRULESMODULE_H_
moja::modules::cbm::TransitionRule::_resetAge
int _resetAge
Definition: cbmtransitionrulesmodule.h:45
moja::modules::cbm::CBMTransitionRulesModule::doTimingInit
virtual void doTimingInit() override
Definition: cbmtransitionrulesmodule.cpp:124
moja::modules::cbm::CBMTransitionRulesModule::findTransitionRule
int findTransitionRule(const std::string &disturbanceType)
Definition: cbmtransitionrulesmodule.cpp:144
volumetobiomasscarbongrowth.h
moja::modules::cbm::CBMTransitionRulesModule::_gcFactory
std::shared_ptr< StandGrowthCurveFactory > _gcFactory
Definition: cbmtransitionrulesmodule.h:74
moja::modules::cbm::TransitionRule::TransitionRule
TransitionRule()
Definition: cbmtransitionrulesmodule.h:24
moja::modules::cbm::TransitionRule::_id
int _id
Definition: cbmtransitionrulesmodule.h:43
moja::modules::cbm::CBMTransitionRulesModule::_softwoodOther
const flint::IPool * _softwoodOther
Definition: cbmtransitionrulesmodule.h:76
moja::modules::cbm
Definition: ageclasshelper.cpp:12
moja::modules::cbm::TransitionRule::_classifiers
std::unordered_map< std::string, std::string > _classifiers
Definition: cbmtransitionrulesmodule.h:47
moja::modules::cbm::CBMTransitionRulesModule::doDisturbanceEvent
virtual void doDisturbanceEvent(DynamicVar) override
Definition: cbmtransitionrulesmodule.cpp:173
moja::modules::cbm::CBMTransitionRulesModule::_softwoodCoarseRoots
const flint::IPool * _softwoodCoarseRoots
Definition: cbmtransitionrulesmodule.h:78
moja::modules::cbm::CBMTransitionRulesModule::_standSpuId
Int64 _standSpuId
Definition: cbmtransitionrulesmodule.h:87
moja::modules::cbm::TransitionRule::id
int id()
Definition: cbmtransitionrulesmodule.h:29
moja::modules::cbm::TransitionRule::regenDelay
int regenDelay()
Definition: cbmtransitionrulesmodule.h:32
moja::modules::cbm::CBMTransitionRulesModule::doTimingShutdown
virtual void doTimingShutdown() override
Definition: cbmtransitionrulesmodule.cpp:133
moja::modules::cbm::CBMTransitionRulesModule::_softwoodFineRoots
const flint::IPool * _softwoodFineRoots
Definition: cbmtransitionrulesmodule.h:79
moja::modules::cbm::AgeResetType::Absolute
@ Absolute
moja::modules::cbm::CBMModuleBase
Definition: cbmmodulebase.h:22
moja::modules::cbm::TransitionRule::classifiers
const std::unordered_map< std::string, std::string > classifiers() const
Definition: cbmtransitionrulesmodule.h:34
moja::modules::cbm::CBMTransitionRulesModule::_hardwoodFoliage
const flint::IPool * _hardwoodFoliage
Definition: cbmtransitionrulesmodule.h:82
moja::modules::cbm::CBMTransitionRulesModule::_softwoodFoliage
const flint::IPool * _softwoodFoliage
Definition: cbmtransitionrulesmodule.h:77
moja::modules::cbm::CBMTransitionRulesModule::calculateBiomass
double calculateBiomass()
Definition: cbmtransitionrulesmodule.cpp:291
moja::modules::cbm::CBMTransitionRulesModule::_age
flint::IVariable * _age
Definition: cbmtransitionrulesmodule.h:67
moja::modules::cbm::CBMTransitionRulesModule::moduleType
flint::ModuleTypes moduleType()
Definition: cbmtransitionrulesmodule.h:59
moja::modules::cbm::TransitionRule::addClassifier
void addClassifier(std::string name, std::string value)
Definition: cbmtransitionrulesmodule.h:38
moja::modules::cbm::CBMTransitionRulesModule::_hardwoodOther
const flint::IPool * _hardwoodOther
Definition: cbmtransitionrulesmodule.h:81
moja::modules::cbm::CBMTransitionRulesModule::_allowMatchingRules
bool _allowMatchingRules
Definition: cbmtransitionrulesmodule.h:72
moja::modules::cbm::CBMTransitionRulesModule::_hardwoodFineRoots
const flint::IPool * _hardwoodFineRoots
Definition: cbmtransitionrulesmodule.h:84
moja::modules::cbm::CBMTransitionRulesModule::_regenDelay
flint::IVariable * _regenDelay
Definition: cbmtransitionrulesmodule.h:69
moja::modules::cbm::CBMTransitionRulesModule::_transitionRuleMatches
flint::IVariable * _transitionRuleMatches
Definition: cbmtransitionrulesmodule.h:70
moja::modules::cbm::CBMTransitionRulesModule::_hardwoodMerch
const flint::IPool * _hardwoodMerch
Definition: cbmtransitionrulesmodule.h:80
moja::modules::cbm::CBMTransitionRulesModule::doLocalDomainInit
virtual void doLocalDomainInit() override
Definition: cbmtransitionrulesmodule.cpp:57
moja::modules::cbm::CBMTransitionRulesModule
Definition: cbmtransitionrulesmodule.h:50
moja::modules::cbm::AgeResetType
AgeResetType
Definition: cbmtransitionrulesmodule.h:16
moja::modules::cbm::TransitionRule::TransitionRule
TransitionRule(int id, int resetAge, int regenDelay)
Definition: cbmtransitionrulesmodule.h:26
moja::modules::cbm::TransitionRule::_resetType
AgeResetType _resetType
Definition: cbmtransitionrulesmodule.h:44
moja::modules::cbm::TransitionRule
Definition: cbmtransitionrulesmodule.h:22
moja::modules::cbm::CBMTransitionRulesModule::_cset
flint::IVariable * _cset
Definition: cbmtransitionrulesmodule.h:68
moja::modules::cbm::CBMTransitionRulesModule::_volumeToBioGrowth
std::shared_ptr< VolumeToBiomassCarbonGrowth > _volumeToBioGrowth
Definition: cbmtransitionrulesmodule.h:73
moja::modules::cbm::CBMTransitionRulesModule::_gcId
flint::IVariable * _gcId
Definition: cbmtransitionrulesmodule.h:85
moja::modules::cbm::CBMTransitionRulesModule::_spuId
flint::IVariable * _spuId
Definition: cbmtransitionrulesmodule.h:86
moja::modules::cbm::CBMTransitionRulesModule::~CBMTransitionRulesModule
virtual ~CBMTransitionRulesModule()=default
moja::modules::cbm::CBMTransitionRulesModule::_softwoodMerch
const flint::IPool * _softwoodMerch
Definition: cbmtransitionrulesmodule.h:75
moja::modules::cbm::TransitionRule::_regenDelay
int _regenDelay
Definition: cbmtransitionrulesmodule.h:46
moja::modules::cbm::TransitionRule::resetAge
int resetAge()
Definition: cbmtransitionrulesmodule.h:31
moja::modules::cbm::AgeResetType::Yield
@ Yield
moja::modules::cbm::CBMTransitionRulesModule::findYieldCurveAge
int findYieldCurveAge()
Definition: cbmtransitionrulesmodule.cpp:253
moja::modules::cbm::CBMTransitionRulesModule::_transitions
std::unordered_map< int, TransitionRule > _transitions
Definition: cbmtransitionrulesmodule.h:71
moja::modules::cbm::CBMTransitionRulesModule::_hardwoodCoarseRoots
const flint::IPool * _hardwoodCoarseRoots
Definition: cbmtransitionrulesmodule.h:83
moja::modules::cbm::CBMTransitionRulesModule::subscribe
void subscribe(NotificationCenter &notificationCenter) override
Definition: cbmtransitionrulesmodule.cpp:27
standgrowthcurvefactory.h
moja::modules::cbm::AgeResetType::Relative
@ Relative
moja
Definition: ageclasshelper.cpp:10
moja::modules::cbm::TransitionRule::resetType
AgeResetType resetType()
Definition: cbmtransitionrulesmodule.h:30
cbmmodulebase.h
moja::modules::cbm::CBMTransitionRulesModule::CBMTransitionRulesModule
CBMTransitionRulesModule(std::shared_ptr< StandGrowthCurveFactory > gcFactory, std::shared_ptr< VolumeToBiomassCarbonGrowth > volumeToBioGrowth)
Definition: cbmtransitionrulesmodule.h:52