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

#include <peatlanddisturbancemodule.h>

Inheritance diagram for PeatlandDisturbanceModule:
Inheritance graph
Collaboration diagram for PeatlandDisturbanceModule:
Collaboration graph

Public Member Functions

 PeatlandDisturbanceModule ()
 
virtual ~PeatlandDisturbanceModule ()
 
void configure (const DynamicObject &config) override
 
void subscribe (NotificationCenter &notificationCenter) override
 
void doDisturbanceEvent (DynamicVar) override
 
void doLocalDomainInit () override
 
void doTimingInit () override
 
void fetchPeatlandDistMatrices ()
 
void fetchPeatlandDMAssociations ()
 
void fetchPeatlandDistModifiers ()
 
- 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 doTimingShutdown ()
 
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)
 

Public Attributes

std::string fireEvent = "fire"
 

Private Types

typedef std::vector< CBMDistEventTransferEventVector
 
typedef std::unordered_map< int, EventVectorEventMap
 
typedef std::vector< std::string > modifierVector
 

Private Attributes

EventMap _matrices
 
std::unordered_map< std::pair< int, std::string >, std::pair< int, int > > _dmAssociations
 
std::unordered_map< int, modifierVector_modifiers
 
flint::IVariable * _wtdModifier
 
int _peatlandId { -1 }
 
bool _runPeatland { false }
 

Member Typedef Documentation

◆ EventMap

typedef std::unordered_map<int, EventVector> EventMap
private

◆ EventVector

typedef std::vector<CBMDistEventTransfer> EventVector
private

◆ modifierVector

typedef std::vector<std::string> modifierVector
private

Constructor & Destructor Documentation

◆ PeatlandDisturbanceModule()

◆ ~PeatlandDisturbanceModule()

virtual ~PeatlandDisturbanceModule ( )
virtual

Member Function Documentation

◆ configure()

void configure ( const DynamicObject &  config)
override

Configuration function

Parameters
configDynamicObject&
Returns
void

◆ doDisturbanceEvent()

void doDisturbanceEvent ( DynamicVar  n)
overridevirtual

Assign string variable disturbanceType as "disturbance" in parameter n.
Find the disturbance module using PeatlandDisturbanceModule._peatlandId and disturbanceType in PeatlandDisturbanceModule._dmAssociations.
If the disturbance module is not equal to the last value of PeatlandDisturbanceModule._dmAssociations,
Initialise variables distMatrix as "transfers" in parameter n,
dmIDandWtdModifer as the second value of the disturbance module, dmId as the first value of dmIDandWtdModifer,
wtdModifierId as the second value of dmIDandWtdModifier.Find wtdModifierId in PeatlandDisturbanceModule._modifiers and assign the second value to modifierVector variable vec.
Join vec by "," and assign the value to string variable modifiers. apply the modifier(WTD) up to years. If years is greater than 0, set PeatlandDisturbanceModule._wtdModifier value as modifiers.
find dmId in PeatlandDisturbanceModule._matrices and assign the value to a constant variable it.
if it is not equal to the last value of PeatlandDisturbanceModule._matrices
for each transfer in the second value of it, invoke CBMDistEventTransfer() using transfer and add to distMatrix.
else print out a log.

Parameters
nDynamicVar
Returns
void

Reimplemented from CBMModuleBase.

◆ doLocalDomainInit()

void doLocalDomainInit ( )
overridevirtual

Invoke fetchPeatlandDistMatrices(),fetchPeatlandDMAssociations() and fetchPeatlandDistModifiers().
Assign PeatlandDisturbanceModule._wtdModifier as "peatland_annual_wtd_modifiers" in _landUnitData.

Returns
void

Reimplemented from CBMModuleBase.

◆ doTimingInit()

void doTimingInit ( )
overridevirtual

Assign PeatlandDisturbanceModule._peatlandId as "peatland_class" in _landUnitData,if not empty else assign it as 1.
Assign PeatlandDisturbanceModule._runPeatland as PeatlandDisturbanceModule._peatlandId greater than 0.
Reset PeatlandDisturbanceModule._wtdModifier value.

Returns
void

Reimplemented from CBMModuleBase.

◆ fetchPeatlandDistMatrices()

void fetchPeatlandDistMatrices ( )

Clear PeatlandDisturbanceModule._matrices
For each transfer in variable "peatland_disturbance_matrices" in _landUnitData, create an object of CBMDistEventTransfer with *_landUnitData, transfer, and check if the disturbance matrix id, is present in PeatlandDisturbanceModule._matrices
If it is present, add the value of the disturbance matrix id, transfer to PeatlandDisturbanceModule._matrices, else the transfer to the iterator resulting from the value of disturbanceId in PeatlandDisturbanceModule._matrices

Returns
void

◆ fetchPeatlandDistModifiers()

void fetchPeatlandDistModifiers ( )

Clear PeatlandDisturbanceModule._modifiers
For each modifier in "peatland_wtd_modifiers" in _landUnitData, get the value of "id", "year" and "modifier" and set it to variables modifierId, year and modifier.
If the modifierId is not in PeatlandDisturbanceModule._modifiers, each modifier will be recorded as "year_modifier" and added into PeatlandDisturbanceModule._modifiers, else add it to the iterator resulting from the value of modifierId in PeatlandDisturbanceModule._modifiers.

Returns
void

◆ fetchPeatlandDMAssociations()

void fetchPeatlandDMAssociations ( )

Clear PeatlandDisturbanceModule._dmAssociations.
For each dmAssociation in "peatland_dm_associations" in _landUnitData, Initialise variables peatlandId as "peatland_id" in dmAssociation,
distType as "disturbance_type" in dmAssociation, dmId as "peatland_dm_id" in dmAssociation and wtdModifierId as "wtd_modifier_id" in dmAssociation.
Insert peatlandId,distType,dmId and wtdModifierId into PeatlandDisturbanceModule._dmAssociations.

Returns
void

◆ subscribe()

void subscribe ( NotificationCenter &  notificationCenter)
override

Subscribe signals LocalDomainInit,DisturbanceEvent and TimingInit

Parameters
notificationCenterNotificationCenter&
Returns
void

Member Data Documentation

◆ _dmAssociations

std::unordered_map<std::pair<int, std::string>, std::pair<int, int> > _dmAssociations
private

◆ _matrices

EventMap _matrices
private

◆ _modifiers

std::unordered_map<int, modifierVector> _modifiers
private

◆ _peatlandId

int _peatlandId { -1 }
private

◆ _runPeatland

bool _runPeatland { false }
private

◆ _wtdModifier

flint::IVariable* _wtdModifier
private

◆ fireEvent

std::string fireEvent = "fire"

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