SORTIE Core C++ Documentation
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
clDisturbance Class Reference

Disturbance - Version 2.1. More...

#include <Disturbance.h>

Inheritance diagram for clDisturbance:
clBehaviorBase clWorkerBase

Classes

struct  stcGridList
 Holds a linked list of grid cells. More...
 
struct  stcTreeGridList
 Holds a linked list of tree grid cells that correspond to the harvest area. More...
 

Public Types

enum  cutType { partial, gap, clear }
 Types of harvest cuts. More...
 
enum  amtType { percentBA, absBA, percentDen, absDen }
 How amount to cut is defined. More...
 
enum  priorityDataType { intType, floatType, boolType }
 Tree data member type for priority. More...
 

Public Member Functions

 clDisturbance (clSimManager *p_oSimManager)
 Constructor. More...
 
 ~clDisturbance ()
 Destructor. More...
 
void Action ()
 Performs the harvest or mortality episode for a timestep. More...
 
void SetNameData (std::string sNameString)
 Captures the parameter file behavior string passed to this behavior. More...
 
- Public Member Functions inherited from clBehaviorBase
virtual float GetBehaviorVersion ()
 Gets the behavior version number. More...
 
 clBehaviorBase (clSimManager *p_oSimManager)
 Constructor. More...
 
virtual ~clBehaviorBase ()
 Destructor. More...
 
virtual short int ValidateVersionNumber (float fTestVersion)
 Makes sure that the version number of a file passed is between the minimum and current version numbers. More...
 
virtual void RegisterTreeDataMembers ()
 Registers tree data members. More...
 
virtual void SetSpeciesTypeCombos (short int iNumCombos, stcSpeciesTypeCombo *p_whatCombos)
 Sets the species/type combos for a behavior. More...
 
virtual short int GetNewTreeInts ()
 Gets the number of new tree integer data members this behavior wants to register. More...
 
virtual short int GetNewTreeFloats ()
 Gets the number of new tree float data members this behavior wants to register. More...
 
virtual short int GetNewTreeChars ()
 Gets the number of new tree character data members this behavior wants to register. More...
 
virtual short int GetNewTreeBools ()
 Gets the number of new tree bool data members this behavior wants to register. More...
 
virtual short int GetNumSpeciesTypeCombos ()
 Gets the number of species/type combos to which this behavior applies. More...
 
virtual short int GetNumBehaviorSpecies ()
 Gets the number of unique tree species to which this behavior applies. More...
 
struct stcSpeciesTypeCombo GetSpeciesTypeCombo (short int iIndex)
 Gets one of this behavior's type/species combos. More...
 
virtual short int GetBehaviorSpecies (short int iIndex)
 Gets one of the behavior's species. More...
 
short int GetBehaviorListNumber ()
 Gets the behavior list number for this behavior, which differentiates between multiple copies of the behavior in the behavior list. More...
 
void SetBehaviorListNumber (short int iNumber)
 Sets the behavior list number for this behavior, which differentiates between multiple copies of the behavior in the behavior list. More...
 
std::string FormatSpeciesTypeQueryString ()
 Formats the string for species/types query. More...
 
virtual DOMElement * GetParentParametersElement (xercesc::DOMDocument *p_oDoc)
 This will get the correct set of parameters for this behavior based on the behavior list position number. More...
 
- Public Member Functions inherited from clWorkerBase
 clWorkerBase (clSimManager *p_oSimManager)
 Constructor. More...
 
virtual ~clWorkerBase ()
 Destructor. More...
 
std::string GetName ()
 Gets the object's namestring. More...
 
clSimManagerGetSimManager ()
 
void DoObjectSetup (xercesc::DOMDocument *p_oDoc, fileType iFileType)
 Triggers the setup process. More...
 
virtual void TimestepCleanup ()
 Performs any necessary cleanup operations at the end of a timestep. More...
 
virtual void EndOfRunCleanup ()
 Performs any necessary cleanup operations at the end of a run. More...
 

Static Public Member Functions

static int GetNumberOfCutRanges ()
 Gets the number of total allowed cut ranges. More...
 

Protected Member Functions

void ResetResultsGrid ()
 Resets all the values in the Harvest Results or Episodic Mortality Results grid. More...
 
void GetData (xercesc::DOMDocument *p_oDoc)
 Performs setup. More...
 
void ReadHarvestParameterFileData (xercesc::DOMDocument *p_oDoc)
 Reads harvest data from the parameter file. More...
 
void ReadMortEpParameterFileData (xercesc::DOMDocument *p_oDoc)
 Reads episodic mortality data from the parameter file. More...
 
void SetupGrids ()
 Sets up the harvest or mortality episode grids and gets all the return codes. More...
 
void ValidatePackages ()
 Makes sure that the data in the event harvest packages makes sense. More...
 
void CutTrees (clPackage *p_oMasterPackage)
 Performs the tree cutting for a master cut package. More...
 
void CutSpeciesAbsDen (int iSp, stcGridList *&p_cutArea, stcTreeGridList *&p_treeArea, float *p_fLoDbh, float *p_fHiDbh, float *p_fAmountToRemove, float *p_fAmountRemoved, bool bTallestFirst)
 Cut trees for a species - absolute density. More...
 
void CutSpeciesAbsDenPriority (int iSp, stcGridList *&p_cutArea, stcTreeGridList *&p_treeArea, float *p_fLoDbh, float *p_fHiDbh, float *p_fAmountToRemove, float *p_fAmountRemoved, std::string sPriorityName, int &iPriorityType, float &fPriorityMin, float &fPriorityMax, bool bTallestFirst)
 Cut trees for a species with a priority - absolute density. More...
 
void CutSpeciesAbsBA (int iSp, stcGridList *&p_cutArea, stcTreeGridList *&p_treeArea, float *p_fLoDbh, float *p_fHiDbh, float *p_fAmountToRemove, float *p_fAmountRemoved, bool bTallestFirst)
 Cut trees for a species - absolute basal area. More...
 
bool CutSpeciesAbsBAPriority (int iSp, stcGridList *&p_cutArea, stcTreeGridList *&p_treeArea, float *p_fLoDbh, float *p_fHiDbh, float *p_fAmountToRemove, float *p_fAmountRemoved, std::string sPriorityName, int &iPriorityType, float &fPriorityMin, float &fPriorityMax, bool bTallestFirst)
 Cut trees for a species with a priority - absolute basal area. More...
 
void CutSpeciesPercentDen (int iSp, stcGridList *&p_cutArea, stcTreeGridList *&p_treeArea, float *p_fLoDbh, float *p_fHiDbh, float *p_fAmountToRemove, float *p_fAmountRemoved)
 Cut trees for a species - percent density. More...
 
void CutSpeciesPercentBA (int iSp, stcGridList *&p_cutArea, stcTreeGridList *&p_treeArea, float *p_fLoDbh, float *p_fHiDbh, float *p_fAmountToRemove, float *p_fAmountRemoved, float *p_fTotalBasalArea, bool bTallestFirst)
 Cut trees for a species - percent basal area. More...
 
bool CutSpeciesPercentBAPriority (int iSp, stcGridList *&p_cutArea, stcTreeGridList *&p_treeArea, float *p_fLoDbh, float *p_fHiDbh, float *p_fAmountToRemove, float *p_fAmountRemoved, float *p_fTotalBasalArea, std::string sPriorityName, int &iPriorityType, float &fPriorityMin, float &fPriorityMax, bool bTallestFirst)
 Cut trees for a species with a priority - percent basal area. More...
 
void AddTreeStatsToResults (clTree *p_oTree, float *p_fLoDbh, float *p_fHiDbh, float &fDbh)
 Add tree to results grid. More...
 
int AssembleCutArea (clPackage *p_oMasterPackage, const int &iNumXCells, const int &iNumYCells, stcGridList *&p_cutArea, stcTreeGridList *&p_treeArea, float *p_fLoDbh, float *p_fHiDbh, float *p_fAmountToRemove, bool *p_bSpeciesCut)
 Finds all the grid cells affected by a given cut. More...
 
void GetBasalArea (stcGridList *p_cutArea, stcTreeGridList *&p_treeArea, const short int &iSpecies, float *p_fTotalBasalArea, float *p_fLoDbh, float *p_fHiDbh)
 Gets the basal area in a cut area for a single species. More...
 
void KillSeedlings (stcGridList *p_cutArea, stcTreeGridList *&p_treeArea, float *p_fKillProb)
 Kills seedlings for a harvest or mortality episode event. More...
 
clTreeGetFirstTreeInCutArea (stcGridList *&p_cutArea, stcTreeGridList *&p_treeArea, const short int &iSpecies, const bool bTallestFirst)
 Finds the first tree of a species within a cut area to cut, based on bTallestFirst. More...
 
clTreeGetTallestTreeInCutArea (stcGridList *&p_cutArea, stcTreeGridList *&p_treeArea, const short int &iSpecies)
 Finds the tallest tree of a species within a cut area. More...
 
clTreeGetShortestTreeInCutArea (stcGridList *&p_cutArea, stcTreeGridList *&p_treeArea, const short int &iSpecies)
 Finds the shortest tree of a species within a cut area. More...
 
clTreeGetNextTreeInCutArea (stcGridList *&p_cutArea, stcTreeGridList *&p_treeArea, const short int &iSpecies, const bool bTallestFirst)
 Finds the next tree of a species within a cut area to cut, based on bTallestFirst. More...
 
clTreeGetNextTallestTreeInCutArea (stcGridList *&p_cutArea, stcTreeGridList *&p_treeArea, const short int &iSpecies)
 Gets the next tallest tree of a species within a cut area. More...
 
clTreeGetNextShortestTreeInCutArea (stcGridList *&p_cutArea, stcTreeGridList *&p_treeArea, const short int &iSpecies)
 Gets the next shortest tree of a species within a cut area. More...
 
void SetCutFlags (stcGridList *p_cutArea, const int &iCutType)
 Sets the Harvest Type data member of the Harvest Results grid. More...
 
bool IsTreeInCutArea (clTree *p_oTree, stcGridList *p_cutArea)
 Figures out whether or not a tree falls in a disturbance cut area. More...
 
- Protected Member Functions inherited from clWorkerBase
void AssembleFileCode (int iFileType, int iFileVersion, char *cCode)
 Creates the proper identifying filecode for an XML file. More...
 

Protected Attributes

clTreePopulationmp_oPop
 Stashed pointer to tree population. More...
 
clGridmp_oMasterCutsGrid
 MASTER CUTS GRID. More...
 
clGridmp_oCutEventsGrid
 CUT EVENTS GRID. More...
 
clGridmp_oResultsGrid
 RESULTS GRID. More...
 
short int m_iMasterTimestepCode
 Timestep data member code in "harvestmastercuts" grid. More...
 
short int m_iMasterIDCode
 ID data member code in "harvestmastercuts" grid. More...
 
short int * mp_iSpeciesCodes
 Species data member code in "harvestmastercuts" grid. More...
 
short int m_iCutTypeCode
 cuttype data member code in "harvestmastercuts" grid More...
 
short int m_iAmountTypeCode
 amttype data member code in "harvestmastercuts" grid More...
 
short int m_iTallestFirstCode
 tallestfirst data member code in "harvestmastercuts" grid More...
 
short int * mp_iRangeMinCodes
 rangeminx data member codes in "harvestmastercuts" grid. More...
 
short int * mp_iRangeMaxCodes
 rangemaxx data member codes in "harvestmastercuts" grid. More...
 
short int * mp_iRangeAmountCodes
 rangeamtx data member codes in "harvestmastercuts" grid. More...
 
short int * mp_iSeedlingCodes
 Seedlings to cut data member code in "harvestmastercuts" grid. More...
 
short int * mp_iPriorityNameCodes
 prioritynamex data member codes in "harvestmastercuts" grid. More...
 
short int * mp_iPriorityTypeCodes
 prioritytypex data member codes in "harvestmastercuts" grid. More...
 
short int * mp_iPriorityMinCodes
 priorityminx data member codes in "harvestmastercuts" grid. More...
 
short int * mp_iPriorityMaxCodes
 prioritymaxx data member codes in "harvestmastercuts" grid. More...
 
short int m_iCutTimestepCode
 timestep data member code in "harvestcutevents" grid More...
 
short int m_iCutIDCode
 id data member code in "harvestcutevents" grid More...
 
short int m_iHarvestTypeCode
 Harvest Type data member code in "Harvest Results" grid. More...
 
short int ** mp_iDenCutCodes
 Cut Density data member codes in "Harvest Results" grid. More...
 
short int ** mp_iBaCutCodes
 Cut Basal Area data member codes in "Harvest Results" grid. More...
 
short int * mp_iSeedlingCutCodes
 Cut Seedlings data member codes in "Harvest Results" grid. More...
 
float m_fDistXCellLen
 Disturbance grid cell X length. More...
 
float m_fDistYCellLen
 Disturbance grid cell Y length. More...
 
float m_fPopCellLen
 Tree population grid cell length. More...
 
deadCode m_iReasonCode
 Reason code to pass to the tree population when trees are killed. More...
 
bool m_bIsHarvest
 What kind of behavior this is. More...
 
- Protected Attributes inherited from clBehaviorBase
short int m_iNumSpeciesTypeCombos
 How many type/species combos a behavior will act on. More...
 
short int m_iNumBehaviorSpecies
 How many distinct species are in the combo list - important for filling species-specific values from parameter file. More...
 
short int * mp_iWhatSpecies
 List of distinct species - for filling species-specific values from parameter file. More...
 
stcSpeciesTypeCombomp_whatSpeciesTypeCombos
 Array of species/type combos that the behavior will act on. More...
 
short int m_iNewTreeInts
 The number of new tree integer data members this behavior wants to add. More...
 
short int m_iNewTreeFloats
 The number of new tree float data members this behavior wants to add. More...
 
short int m_iNewTreeChars
 The number of new tree character data members this behavior wants to add. More...
 
short int m_iNewTreeBools
 The number of new tree boolean data members this behavior wants to add. More...
 
short int m_iBehaviorListNumber
 The number of this behavior in the behavior list, to differentiate between possible multiple copies of this behavior. More...
 
float m_fVersionNumber
 Version number - this will be rounded to 2 digits after the decimal place. More...
 
std::string m_sXMLRoot
 XML root that encloses the parameters for this behavior. More...
 
float m_fMinimumVersionNumber
 Minimum version number - this behavior will run parameter data for a file marked between this number and the current version number, inclusive. More...
 
- Protected Attributes inherited from clWorkerBase
std::string m_sNameString
 If a behavior has registered a command line command with the sim manager, this allows it to be called. More...
 
clSimManagermp_oSimManager
 Pointer to the simulation manager object. More...
 
int * mp_iAllowedFileTypes
 List of the input file types this object can handle. More...
 
int m_iNumAllowedTypes
 Number of input file types this object can handle. More...
 

Static Protected Attributes

static short int m_iNumAllowedCutRanges
 Number of cut ranges allowed. More...
 
static short int m_iNumAllowedPriorities
 Number of allowed priorities. More...
 

Detailed Description

Disturbance - Version 2.1.

This class allows for highly specific disturbance events. Two kinds of disturbance can be performed: harvest or episodic mortality (disease, insect outbreaks, etc). They work the exact same way, differing only in the reason code passed to the tree population when killing the tree (Harvest in the case of harvest, and disease in the case of episodic mortality).

Harvest/mortality episodes can be defined on a grid cell level for each timestep for each species. If more than one event is defined for a species for a single grid cell and timestep, the user takes a chance on what happens. Cells with common disturbance criteria are grouped by the user into groups which will be evaluated together.

If the disturbance is harvest, there are three kinds of harvests that can be performed: gap cut, partial cut, and clear cut. Partial cuts may remove only a portion of the trees, but otherwise, there is no difference in how the trees are removed for each cut type. The type of cut is recorded for the benefit of other behaviors for whom this might be important. The user can define different ranges of dbh values to cut, and each can have a portion of the trees removed, as defined by percentage of basal area, percentage of density, absolute amount of basal area (in square meters per hectare), or absolute amount of density (in stems per hectare). For gap cut and clear cut, for all species affected, all trees are removed. Any attempt to define cut ranges etc. for gap and clear cuts will cause an error to be thrown (the cut ranges could be ignored but throwing an error alerts the user in case they didn't know, so they could amend the parameter file to get what they meant to get).

Trees can be cut either largest to smallest or smallest to largest.

Trees can be prioritized by any tree data member. Trees meeting the criterion will be cut before any others. There can be up to three priorities. The trees meeting each priority will be exhausted before moving to the next priority. If a priority does not apply to a tree or cut, it will be ignored. Prioritizing data members cannot be of type char. Priorities are not allowed in percent of density cut types because they would be nonsensical.

Harvests can affect seedlings as well, by randomly killing a proportion of those found in the cut area. The kill rate is species specific and does not have to be the same as the species being harvested.

Episodic mortality events are processed like harvest partial cuts.

The disturbance event data is stored in a grid. Each cut event, defined as the killing to be done for one species for one timestep for one grid cell, is stored in a grid package. These packages are sorted in timestep order. Each timestep, all the cut events that are defined for that timestep are executed, then those packages are removed.

This behavior can be called from the parameter file by either "Harvest" or "EpisodicMortality". The namestring is "harvest".

Copyright 2003 Charles D. Canham.

Author
Lora E. Murphy


Edit history:
--------------—
October 20, 2011 - Wiped the slate clean for SORTIE 7.0 (LEM)
February 23, 2012 - Added priorities (LEM)
April 18, 2017 - Allowed reverse cut order (LEM)

Member Enumeration Documentation

◆ amtType

How amount to cut is defined.

Enumerator
percentBA 

As a percentage of total basal area in cut range.

absBA 

As an amount of BA in sq m in that cut range.

percentDen 

As a percentage of total density in that cut range.

absDen 

As a total number of trees in that cut range.

◆ cutType

Types of harvest cuts.

These are listed in increasing order of severity (that's important!)

Enumerator
partial 

Partial cut.

gap 

Gap cut.

clear 

Clear cut.

◆ priorityDataType

Tree data member type for priority.

Enumerator
intType 
floatType 
boolType 

Constructor & Destructor Documentation

◆ clDisturbance()

clDisturbance::clDisturbance ( clSimManager p_oSimManager)

Constructor.

Parameters
p_oSimManagerSim Manager object.

◆ ~clDisturbance()

clDisturbance::~clDisturbance ( )

Destructor.

Member Function Documentation

◆ Action()

void clDisturbance::Action ( )
virtual

Performs the harvest or mortality episode for a timestep.

This goes through the master package lists in either the harvestmastercuts or mortepisodemastercuts grid and calls CutTrees() for each one that is for this timestep.

Reimplemented from clBehaviorBase.

◆ AddTreeStatsToResults()

void clDisturbance::AddTreeStatsToResults ( clTree p_oTree,
float *  p_fLoDbh,
float *  p_fHiDbh,
float &  fDbh 
)
protected

Add tree to results grid.

Parameters
p_oTreeTree to add.
p_fLoDbhArray (sized m_iNumAllowedCutRanges) into which to put the low dbhs of the package's cut ranges.
p_fHiDbhArray (sized m_iNumAllowedCutRanges) into which to put the high dbhs of the package's cut ranges.
fDbhDBH.

◆ AssembleCutArea()

int clDisturbance::AssembleCutArea ( clPackage p_oMasterPackage,
const int &  iNumXCells,
const int &  iNumYCells,
stcGridList *&  p_cutArea,
stcTreeGridList *&  p_treeArea,
float *  p_fLoDbh,
float *  p_fHiDbh,
float *  p_fAmountToRemove,
bool *  p_bSpeciesCut 
)
protected

Finds all the grid cells affected by a given cut.

The cut in question is found in one master cut package. The grid cells are identified by matching ID numbers on packages in the "harvestcutevents" / "mortepisodecutevents" grid. The cut area cells are assembled into a linked list. All packages which went into the linked list are then deleted. This also extracts the cut range data and cut amount data.

Parameters
p_oMasterPackageThe master package for which the cut area list is being assembled. (This package will be deleted.)
iNumXCellsNumber of X cells in mp_oCutEventsGrid.
iNumYCellsNumber of Y cells in mp_oCutEventsGrid.
p_cutAreaPointer in which to start the linked list.
p_treeAreaTree cell linked list. Helps resolve cell size differences between disturbance and tree grid cell sizes.
p_fLoDbhArray (sized m_iNumAllowedCutRanges) into which to put the low dbhs of the package's cut ranges.
p_fHiDbhArray (sized m_iNumAllowedCutRanges) into which to put the high dbhs of the package's cut ranges.
p_fAmountToRemoveArray (sized m_iNumAllowedCutRanges) into which to put the amount of basal area to remove for each of the package's cut ranges.
p_bSpeciesCutArray of all species for whether or not a species is affected by this cut.
Returns
The number of the cells in the cut area.

◆ CutSpeciesAbsBA()

void clDisturbance::CutSpeciesAbsBA ( int  iSp,
stcGridList *&  p_cutArea,
stcTreeGridList *&  p_treeArea,
float *  p_fLoDbh,
float *  p_fHiDbh,
float *  p_fAmountToRemove,
float *  p_fAmountRemoved,
bool  bTallestFirst 
)
protected

Cut trees for a species - absolute basal area.

Parameters
iSpSpecies
p_cutAreaPointer to the linked list of cut grid cells.
p_treeAreaPointer to the linked list of tree grid cells.
p_fLoDbhArray of the low dbhs of the package's cut ranges.
p_fHiDbhArray of the high dbhs of the package's cut ranges.
p_fAmountToRemoveAmount to remove in each cut range.
p_fAmountRemovedAmount already removed.
bTallestFirstWhether to cut the tallest trees first (true) or shortest first (false).

◆ CutSpeciesAbsBAPriority()

bool clDisturbance::CutSpeciesAbsBAPriority ( int  iSp,
stcGridList *&  p_cutArea,
stcTreeGridList *&  p_treeArea,
float *  p_fLoDbh,
float *  p_fHiDbh,
float *  p_fAmountToRemove,
float *  p_fAmountRemoved,
std::string  sPriorityName,
int &  iPriorityType,
float &  fPriorityMin,
float &  fPriorityMax,
bool  bTallestFirst 
)
protected

Cut trees for a species with a priority - absolute basal area.

Parameters
iSpSpecies
p_cutAreaPointer to the linked list of cut grid cells.
p_treeAreaPointer to the linked list of tree grid cells.
p_fLoDbhArray of the low dbhs of the package's cut ranges.
p_fHiDbhArray of the high dbhs of the package's cut ranges.
p_fAmountToRemoveAmount to remove in each cut range.
p_fAmountRemovedAmount already removed.
sPriorityNameName of priority data member.
iPriorityTypePriority type.
fPriorityMinPriority minimum value.
fPriorityMaxPriority maximum value.
bTallestFirstWhether to cut the tallest trees first (true) or shortest first (false).
Returns
Whether to keep cutting (true) or stop the harvest (false). False indicates that there are more priority trees left but they were not cut because we were too close to the target. It would not make sense then in this case to cut other trees.

◆ CutSpeciesAbsDen()

void clDisturbance::CutSpeciesAbsDen ( int  iSp,
stcGridList *&  p_cutArea,
stcTreeGridList *&  p_treeArea,
float *  p_fLoDbh,
float *  p_fHiDbh,
float *  p_fAmountToRemove,
float *  p_fAmountRemoved,
bool  bTallestFirst 
)
protected

Cut trees for a species - absolute density.

Parameters
iSpSpecies
p_cutAreaPointer to the linked list of cut grid cells.
p_treeAreaPointer to the linked list of tree grid cells.
p_fLoDbhArray of the low dbhs of the package's cut ranges.
p_fHiDbhArray of the high dbhs of the package's cut ranges.
p_fAmountToRemoveAmount to remove in each cut range.
p_fAmountRemovedAmount already removed.
bTallestFirstWhether to cut the tallest trees first (true) or shortest first (false).

◆ CutSpeciesAbsDenPriority()

void clDisturbance::CutSpeciesAbsDenPriority ( int  iSp,
stcGridList *&  p_cutArea,
stcTreeGridList *&  p_treeArea,
float *  p_fLoDbh,
float *  p_fHiDbh,
float *  p_fAmountToRemove,
float *  p_fAmountRemoved,
std::string  sPriorityName,
int &  iPriorityType,
float &  fPriorityMin,
float &  fPriorityMax,
bool  bTallestFirst 
)
protected

Cut trees for a species with a priority - absolute density.

Parameters
iSpSpecies
p_cutAreaPointer to the linked list of cut grid cells.
p_treeAreaPointer to the linked list of tree grid cells.
p_fLoDbhArray of the low dbhs of the package's cut ranges.
p_fHiDbhArray of the high dbhs of the package's cut ranges.
p_fAmountToRemoveAmount to remove in each cut range.
p_fAmountRemovedAmount already removed.
sPriorityNameName of priority data member.
iPriorityTypePriority type.
fPriorityMinPriority minimum value.
fPriorityMaxPriority maximum value.
bTallestFirstWhether to cut the tallest trees first (true) or shortest first (false).

◆ CutSpeciesPercentBA()

void clDisturbance::CutSpeciesPercentBA ( int  iSp,
stcGridList *&  p_cutArea,
stcTreeGridList *&  p_treeArea,
float *  p_fLoDbh,
float *  p_fHiDbh,
float *  p_fAmountToRemove,
float *  p_fAmountRemoved,
float *  p_fTotalBasalArea,
bool  bTallestFirst 
)
protected

Cut trees for a species - percent basal area.

Parameters
iSpSpecies
p_cutAreaPointer to the linked list of cut grid cells.
p_treeAreaPointer to the linked list of tree grid cells.
p_fLoDbhArray of the low dbhs of the package's cut ranges.
p_fHiDbhArray of the high dbhs of the package's cut ranges.
p_fAmountToRemoveAmount to remove in each cut range.
p_fAmountRemovedAmount already removed.
p_fTotalBasalAreaTotal basal area.
bTallestFirstWhether to cut the tallest trees first (true) or shortest first (false).

◆ CutSpeciesPercentBAPriority()

bool clDisturbance::CutSpeciesPercentBAPriority ( int  iSp,
stcGridList *&  p_cutArea,
stcTreeGridList *&  p_treeArea,
float *  p_fLoDbh,
float *  p_fHiDbh,
float *  p_fAmountToRemove,
float *  p_fAmountRemoved,
float *  p_fTotalBasalArea,
std::string  sPriorityName,
int &  iPriorityType,
float &  fPriorityMin,
float &  fPriorityMax,
bool  bTallestFirst 
)
protected

Cut trees for a species with a priority - percent basal area.

Parameters
iSpSpecies
p_cutAreaPointer to the linked list of cut grid cells.
p_treeAreaPointer to the linked list of tree grid cells.
p_fLoDbhArray of the low dbhs of the package's cut ranges.
p_fHiDbhArray of the high dbhs of the package's cut ranges.
p_fAmountToRemoveAmount to remove in each cut range.
p_fAmountRemovedAmount already removed.
p_fTotalBasalAreaTotal basal area.
sPriorityNameName of priority data member.
iPriorityTypePriority type.
fPriorityMinPriority minimum value.
fPriorityMaxPriority maximum value.
bTallestFirstWhether to cut the tallest trees first (true) or shortest first (false).
Returns
Whether to keep cutting (true) or stop the harvest (false). False indicates that there are more priority trees left but they were not cut because we were too close to the target. It would not make sense then in this case to cut other trees.

◆ CutSpeciesPercentDen()

void clDisturbance::CutSpeciesPercentDen ( int  iSp,
stcGridList *&  p_cutArea,
stcTreeGridList *&  p_treeArea,
float *  p_fLoDbh,
float *  p_fHiDbh,
float *  p_fAmountToRemove,
float *  p_fAmountRemoved 
)
protected

Cut trees for a species - percent density.

Parameters
iSpSpecies
p_cutAreaPointer to the linked list of cut grid cells.
p_treeAreaPointer to the linked list of tree grid cells.
p_fLoDbhArray of the low dbhs of the package's cut ranges.
p_fHiDbhArray of the high dbhs of the package's cut ranges.
p_fAmountToRemoveAmount to remove in each cut range.
p_fAmountRemovedAmount already removed.

◆ CutTrees()

void clDisturbance::CutTrees ( clPackage p_oMasterPackage)
protected

Performs the tree cutting for a master cut package.

It starts by getting a linked list of cells to cut and their tallest trees of a given species, then selects trees to cut according to the cut type.

Parameters
p_oMasterPackageThe master package to cut

◆ GetBasalArea()

void clDisturbance::GetBasalArea ( stcGridList p_cutArea,
stcTreeGridList *&  p_treeArea,
const short int &  iSpecies,
float *  p_fTotalBasalArea,
float *  p_fLoDbh,
float *  p_fHiDbh 
)
protected

Gets the basal area in a cut area for a single species.

The cut area is defined by a linked list of grid cells. This gets the basal area in each cut range and puts it in an array whose pointer was passed.

Parameters
p_cutAreaPointer to the linked list.
p_treeAreaPointer to the linked list of tree grid cells.
iSpeciesSpecies of tree for which to calculate basal area.
p_fTotalBasalAreaArray (size m_iNumAllowedCutRanges) in which to put the total basal area calculation.
p_fLoDbhArray (size m_iNumAllowedCutRanges) of lower-limit dbhs for the cut ranges that have been defined.
p_fHiDbhArray (size m_iNumAllowedCutRanges) of upper-limit dbhs for the cut ranges that have been defined.

◆ GetData()

void clDisturbance::GetData ( xercesc::DOMDocument *  p_oDoc)
protectedvirtual

Performs setup.

First, SetUpGrids() is called to create our grids. Then, if this is harvest, ReadHarvestParameterFileData() is called; if episodic mortality, ReadEpMortParameterFileData() is called. Then ValidatePackages() is called to validate data from the parameter file.

Parameters
p_oDocDOM tree of parsed input file.

Implements clWorkerBase.

◆ GetFirstTreeInCutArea()

clTree* clDisturbance::GetFirstTreeInCutArea ( stcGridList *&  p_cutArea,
stcTreeGridList *&  p_treeArea,
const short int &  iSpecies,
const bool  bTallestFirst 
)
protected

Finds the first tree of a species within a cut area to cut, based on bTallestFirst.

This is a convenience function that will call either GetTallestTreeInCutArea or GetShortestTreeInCutArea.

Parameters
p_cutAreaPointer to the linked list of cut grid cells.
p_treeAreaPointer to the linked list of tree grid cells.
iSpeciesSpecies of tree to populate.
bTallestFirstWhether to cut trees from tallest to shortest (true) or the reverse (false).
Returns
Either the tallest or the shortest tree in the area, depending on m_bTallestFirst, or NULL if there are no trees of the desired species.

◆ GetNextShortestTreeInCutArea()

clTree* clDisturbance::GetNextShortestTreeInCutArea ( stcGridList *&  p_cutArea,
stcTreeGridList *&  p_treeArea,
const short int &  iSpecies 
)
protected

Gets the next shortest tree of a species within a cut area.

The cut area is defined by a linked list of grid cells. This assumes that the pointers to the shortest trees for each grid cell are populated, and that the current shortest tree is no longer wanted (although if it is to be killed it hasn't been killed yet). The current shortest tree could still be alive; but it will be ignored for further consideration.

Parameters
p_cutAreaPointer to the linked list of cut grid cells.
p_treeAreaPointer to the linked list of tree grid cells.
iSpeciesSpecies being cut.
Returns
Next tallest tree in the area, or NULL if there are no trees of the desired species.

◆ GetNextTallestTreeInCutArea()

clTree* clDisturbance::GetNextTallestTreeInCutArea ( stcGridList *&  p_cutArea,
stcTreeGridList *&  p_treeArea,
const short int &  iSpecies 
)
protected

Gets the next tallest tree of a species within a cut area.

The cut area is defined by a linked list of grid cells. This assumes that the pointers to the tallest trees for each grid cell are populated, and that the current tallest tree is no longer wanted (although if it is to be killed it hasn't been killed yet). The current tallest tree could still be alive; but it will be ignored for further consideration.

Parameters
p_cutAreaPointer to the linked list of cut grid cells.
p_treeAreaPointer to the linked list of tree grid cells.
iSpeciesSpecies being cut.
Returns
Next tallest tree in the area, or NULL if there are no trees of the desired species.

◆ GetNextTreeInCutArea()

clTree* clDisturbance::GetNextTreeInCutArea ( stcGridList *&  p_cutArea,
stcTreeGridList *&  p_treeArea,
const short int &  iSpecies,
const bool  bTallestFirst 
)
protected

Finds the next tree of a species within a cut area to cut, based on bTallestFirst.

This is a convenience function that will call either GetNextTallestTreeInCutArea or GetNextShortestTreeInCutArea.

Parameters
p_cutAreaPointer to the linked list of cut grid cells.
p_treeAreaPointer to the linked list of tree grid cells.
iSpeciesSpecies being cut.
bTallestFirstWhether to cut trees from tallest to shortest (true) or the reverse (false).
Returns
Next tallest tree in the area, or NULL if there are no trees of the desired species.

◆ GetNumberOfCutRanges()

static int clDisturbance::GetNumberOfCutRanges ( )
inlinestatic

Gets the number of total allowed cut ranges.

Returns
Number of total allowed cut ranges.

◆ GetShortestTreeInCutArea()

clTree* clDisturbance::GetShortestTreeInCutArea ( stcGridList *&  p_cutArea,
stcTreeGridList *&  p_treeArea,
const short int &  iSpecies 
)
protected

Finds the shortest tree of a species within a cut area.

The cut area is defined by a linked list of grid cells. This assumes that the shortest tree pointers for each grid cell in the linked list is not populated. This will populate and sort them. Which means that the pointer p_treeArea could be changed.

Parameters
p_cutAreaPointer to the linked list of cut grid cells.
p_treeAreaPointer to the linked list of tree grid cells.
iSpeciesSpecies of tree to populate.
Returns
Shortest tree in the area, or NULL if there are no trees of the desired species.

◆ GetTallestTreeInCutArea()

clTree* clDisturbance::GetTallestTreeInCutArea ( stcGridList *&  p_cutArea,
stcTreeGridList *&  p_treeArea,
const short int &  iSpecies 
)
protected

Finds the tallest tree of a species within a cut area.

The cut area is defined by a linked list of grid cells. This assumes that the tallest tree pointers for each grid cell in the linked list is not populated. This will populate and sort them. Which means that the pointer p_treeArea could be changed.

Parameters
p_cutAreaPointer to the linked list of cut grid cells.
p_treeAreaPointer to the linked list of tree grid cells.
iSpeciesSpecies of tree to populate.
Returns
Tallest tree in the area, or NULL if there are no trees of the desired species.

◆ IsTreeInCutArea()

bool clDisturbance::IsTreeInCutArea ( clTree p_oTree,
stcGridList p_cutArea 
)
protected

Figures out whether or not a tree falls in a disturbance cut area.

Parameters
p_oTreeTree to check
p_cutAreaCut area to check
Returns
True if the tree falls in the cut area, false if not

◆ KillSeedlings()

void clDisturbance::KillSeedlings ( stcGridList p_cutArea,
stcTreeGridList *&  p_treeArea,
float *  p_fKillProb 
)
protected

Kills seedlings for a harvest or mortality episode event.

Unlike with larger trees, all species are done at the same time. Each seedling found within the affected area gets a random number comparison to the kill probability for its species.

Parameters
p_cutAreaPointer to the linked list of cut grid cells.
p_treeAreaPointer to the linked list of tree grid cells.
p_fKillProbKill probability for each species.

◆ ReadHarvestParameterFileData()

void clDisturbance::ReadHarvestParameterFileData ( xercesc::DOMDocument *  p_oDoc)
protected

Reads harvest data from the parameter file.

It doesn't perform validation other than basic data types - more in-depth logical validation is left to ValidatePackages().

Parameters
p_oDocDOM tree of parsed input file.

◆ ReadMortEpParameterFileData()

void clDisturbance::ReadMortEpParameterFileData ( xercesc::DOMDocument *  p_oDoc)
protected

Reads episodic mortality data from the parameter file.

It doesn't perform validation other than basic data types - more in-depth logical validation is left to ValidatePackages().

Parameters
p_oDocDOM tree of parsed input file.

◆ ResetResultsGrid()

void clDisturbance::ResetResultsGrid ( )
protected

Resets all the values in the Harvest Results or Episodic Mortality Results grid.

If Harvest, Harvest Type becomes -1; all others are 0.

◆ SetCutFlags()

void clDisturbance::SetCutFlags ( stcGridList p_cutArea,
const int &  iCutType 
)
protected

Sets the Harvest Type data member of the Harvest Results grid.

For each grid cell in the cut area, this makes sure that the data member is set to the most severe cut type that occurred in a timestep.

Parameters
p_cutAreaPointer to the linked list of the cut area.
iCutTypeMost severe cut type from this cut area.

◆ SetNameData()

void clDisturbance::SetNameData ( std::string  sNameString)
virtual

Captures the parameter file behavior string passed to this behavior.

This is overridden from clBehaviorBase so we can capture the namestring passed. Since this class can create multiple kinds of behaviors that function differently, this will capture what kind of behavior this is supposed to be.

Parameters
sNameStringBehavior's parameter file names.
Exceptions
modelErrif the name is not recognized.

Reimplemented from clBehaviorBase.

◆ SetupGrids()

void clDisturbance::SetupGrids ( )
protected

Sets up the harvest or mortality episode grids and gets all the return codes.

◆ ValidatePackages()

void clDisturbance::ValidatePackages ( )
protected

Makes sure that the data in the event harvest packages makes sense.

For each cut event (each package) - this checks the following:

  • No negative values in cut ranges
  • Cut ranges do not overlap
  • Cut amounts expressed in percentages do not have values over 100
  • There are no cut ranges defined for gap and clear cuts

For harvest gap and clear cuts, this will set up one cut range so the cut happens correctly. The cut range will cover dbhs from 0 to 3000, removing 100% of density.

Member Data Documentation

◆ m_bIsHarvest

bool clDisturbance::m_bIsHarvest
protected

What kind of behavior this is.

If true, it's a harvest. If false, it's episodic mortality.

◆ m_fDistXCellLen

float clDisturbance::m_fDistXCellLen
protected

Disturbance grid cell X length.

◆ m_fDistYCellLen

float clDisturbance::m_fDistYCellLen
protected

Disturbance grid cell Y length.

◆ m_fPopCellLen

float clDisturbance::m_fPopCellLen
protected

Tree population grid cell length.

◆ m_iAmountTypeCode

short int clDisturbance::m_iAmountTypeCode
protected

amttype data member code in "harvestmastercuts" grid

◆ m_iCutIDCode

short int clDisturbance::m_iCutIDCode
protected

id data member code in "harvestcutevents" grid

◆ m_iCutTimestepCode

short int clDisturbance::m_iCutTimestepCode
protected

timestep data member code in "harvestcutevents" grid

◆ m_iCutTypeCode

short int clDisturbance::m_iCutTypeCode
protected

cuttype data member code in "harvestmastercuts" grid

◆ m_iHarvestTypeCode

short int clDisturbance::m_iHarvestTypeCode
protected

Harvest Type data member code in "Harvest Results" grid.

◆ m_iMasterIDCode

short int clDisturbance::m_iMasterIDCode
protected

ID data member code in "harvestmastercuts" grid.

◆ m_iMasterTimestepCode

short int clDisturbance::m_iMasterTimestepCode
protected

Timestep data member code in "harvestmastercuts" grid.

◆ m_iNumAllowedCutRanges

short int clDisturbance::m_iNumAllowedCutRanges
staticprotected

Number of cut ranges allowed.

◆ m_iNumAllowedPriorities

short int clDisturbance::m_iNumAllowedPriorities
staticprotected

Number of allowed priorities.

◆ m_iReasonCode

deadCode clDisturbance::m_iReasonCode
protected

Reason code to pass to the tree population when trees are killed.

This is HARVEST in the case of harvest, and DISEASE in the case of episodic mortality.

◆ m_iTallestFirstCode

short int clDisturbance::m_iTallestFirstCode
protected

tallestfirst data member code in "harvestmastercuts" grid

◆ mp_iBaCutCodes

short int** clDisturbance::mp_iBaCutCodes
protected

Cut Basal Area data member codes in "Harvest Results" grid.

Array size is number cut ranges by number of species

◆ mp_iDenCutCodes

short int** clDisturbance::mp_iDenCutCodes
protected

Cut Density data member codes in "Harvest Results" grid.

Array size is number of cut ranges by number of species

◆ mp_iPriorityMaxCodes

short int* clDisturbance::mp_iPriorityMaxCodes
protected

prioritymaxx data member codes in "harvestmastercuts" grid.

Array size is number priorities

◆ mp_iPriorityMinCodes

short int* clDisturbance::mp_iPriorityMinCodes
protected

priorityminx data member codes in "harvestmastercuts" grid.

Array size is number priorities

◆ mp_iPriorityNameCodes

short int* clDisturbance::mp_iPriorityNameCodes
protected

prioritynamex data member codes in "harvestmastercuts" grid.

Array size is number priorities

◆ mp_iPriorityTypeCodes

short int* clDisturbance::mp_iPriorityTypeCodes
protected

prioritytypex data member codes in "harvestmastercuts" grid.

Array size is number priorities

◆ mp_iRangeAmountCodes

short int* clDisturbance::mp_iRangeAmountCodes
protected

rangeamtx data member codes in "harvestmastercuts" grid.

Array size is number cut ranges

◆ mp_iRangeMaxCodes

short int* clDisturbance::mp_iRangeMaxCodes
protected

rangemaxx data member codes in "harvestmastercuts" grid.

Array size is number cut ranges

◆ mp_iRangeMinCodes

short int* clDisturbance::mp_iRangeMinCodes
protected

rangeminx data member codes in "harvestmastercuts" grid.

Array size is number cut ranges

◆ mp_iSeedlingCodes

short int* clDisturbance::mp_iSeedlingCodes
protected

Seedlings to cut data member code in "harvestmastercuts" grid.

Array size is number species. Array index matches species number

◆ mp_iSeedlingCutCodes

short int* clDisturbance::mp_iSeedlingCutCodes
protected

Cut Seedlings data member codes in "Harvest Results" grid.

Array size is number of species.

◆ mp_iSpeciesCodes

short int* clDisturbance::mp_iSpeciesCodes
protected

Species data member code in "harvestmastercuts" grid.

Array size is number species. Array index matches species number

◆ mp_oCutEventsGrid

clGrid* clDisturbance::mp_oCutEventsGrid
protected

CUT EVENTS GRID.

If this behavior is harvesting, the grid is called "harvestcutevents"; if it is episodic mortality, the grid is called "mortepisodecutevents". This is where data about cutting events is stored.

Grid cell size matches the master cuts grid.

The need to cut a grid cell is signaled by the presence of a package. The package has an ID number which matches a package in either the "harvestmastercuts" or "mortepisodemastercuts" grid, which contains the information about how the cut is actually to be performed. Packages are in timestep order, earliest first.

It is possible that a grid map will have been read in for this grid; it will be ignored, and any grid created with such a map will be overwritten.

Data members - all for packages:

Data member nameData typeDescription
id int ID number matching master package in "harvestmastercuts"
timestep int Timestep at which to apply the cut

◆ mp_oMasterCutsGrid

clGrid* clDisturbance::mp_oMasterCutsGrid
protected

MASTER CUTS GRID.

If this behavior is harvesting, the grid is called "harvestmastercuts"; if it is episodic mortality, the grid is called "mortepisodemastercuts". The grid has a single cell. This is where the cut events are defined.

Grid cell size defaults to match the tree population. A map is allowed only to set cell size.

Each cut event is one package and is applied to a list of species. It has a timestep, cut amount, cut type, and number of cut ranges defined. It also has a unique ID number. The grid cells to which it is applied are in either the "harvestcutevents" or "mortepisodecutevents" grid, depending on what this behavior is.

Species are treated individually. A cut event removing 20% of three species removes 20% of each species individually; one that removes 5 sq.m/ha of basal area removes 5 from each species.

For the cut ranges, four dbh ranges can be defined to which the cuts will be applied. The ranges are ordered as 1 is the smallest minimum dbh. Ranges cannot overlap.

The packages are in timestep order, earliest first.

It is possible that a grid map will have been read in for this grid; it will be ignored, and any grid created with such a map will be overwritten.

Data members - all for packages:

Name Type Description
id int ID number of cut
timestep int Timestep at which to apply the cut
cuttype int Matches a value of the enum "cutType"
amttype int Matches a value of the enum "amtType". Not used if episodic mortality
tallestfirst bool Whether to cut the tallest trees first (true) or shortest (false)
species(x) bool One of each of these for each species. If true, this species is being cut.
rangeamt(x) floatRange amount to cut. There are one of each of the following for m_iNumAllowedCutRanges, where x is the index, starting at 0 (thus "rangemin0" and "rangeamt2"). Units depend on amttype and are either % BA, % density, absolute amount BA (in square m/ha), or absolute amount of density (in stems per ha)
rangemin(x) floatRange min dbh value. There are one of each of the following for m_iNumAllowedCutRanges, where x is the index, starting at 0.
rangemax(x) floatRange max dbh value. There are one of each of the following for m_iNumAllowedCutRanges, where x is the index, starting at 0.
priorityname(x)char The name of the tree data member for priority X.
prioritytype(x)int The tree data member type for priority X. Matches one of the values in enum priorityDataType.
prioritymin(x) floatMin value. A boolean should be 0 or 1.
prioritymax(x) floatMax value. Can equal min value if only a single value is acceptable.
seedling(x) floatProportion (0-1) of seedlings of each species to destroy.

◆ mp_oPop

clTreePopulation* clDisturbance::mp_oPop
protected

Stashed pointer to tree population.

◆ mp_oResultsGrid

clGrid* clDisturbance::mp_oResultsGrid
protected

RESULTS GRID.

If this behavior is harvesting, the grid is called "Harvest Results"; if it is episodic mortality, the grid is called "Mortality Episode Results". The grid has a cell resolution matching that of "harvestcutevents/ mortepisodecutevents". This is where data on actual cut/kill results is stored. The data is stored raw - no conversion to per-hectare amounts.

It is possible that a grid map will have been read in for this grid; it will be ignored, and any grid created with such a map will be overwritten.

Data member name Data type Description
Harvest Type int Type of harvest that occurred in the current timestep - -1 if none has occurred. This data member is not registered if this grid is "Mortality Episode Results".
Cut Density_x_sp int Number of trees cut in the current timestep. There are one of each of the following for m_iNumAllowedCutRanges times number of species, where x is the cut range index, starting at 0, and sp is the species number.
Cut Basal Area_x_spfloat Total basal area cut in the current timestep. There are one of each of the following for m_iNumAllowedCutRanges times number of species, where x is the cut range index, starting at 0, and sp is the species number.
Cut Seedlings_sp int Number of seedlings cut in the current timestep.

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