SORTIE Core C++ Documentation
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
clSpatialDispersal Class Reference

Spatial dispersal - Version 1.0. More...

#include <SpatialDisperse.h>

Inheritance diagram for clSpatialDispersal:
clDisperseBase clBehaviorBase clWorkerBase

Public Member Functions

 clSpatialDispersal (clSimManager *p_oSimManager)
 Constructor. More...
 
 ~clSpatialDispersal ()
 Destructor. More...
 
void SetNameData (std::string sNameString)
 Captures the behavior name passed from the parameter file. More...
 
- Public Member Functions inherited from clDisperseBase
 clDisperseBase (clSimManager *p_oSimManager)
 Constructor. More...
 
virtual ~clDisperseBase ()
 Destroys common objects. More...
 
void Action ()
 Performs all disperse calculations. More...
 
void TimestepCleanup ()
 Resets all values in the seed grid to 0 and sets the static m_bUpdatedGapStatus to false if this is a hooked object. 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 EndOfRunCleanup ()
 Performs any necessary cleanup operations at the end of a run. More...
 

Protected Member Functions

void DoShellSetup (xercesc::DOMDocument *p_oDoc)
 Reads in values from the parameter file. More...
 
float CalculateFunctionValue (float fDistance, int iSpecies, function iFunction, cover iCover)
 Calculates the function value at a particular point. More...
 
void DeclareArrays ()
 Declares the arrays. More...
 
void SpatialDisperse (clTree *p_oTree, clTreePopulation *p_oPop, clPlot *p_oPlot, float fDbh)
 Performs dispersal of seeds for one tree according to gap disperse. More...
 
void NonSpatialDisperse (clTree *p_oTree, clTreePopulation *p_oPop, clPlot *p_oPlot, float fDbh)
 Performs dispersal of seeds for one tree according to non-gap disperse. More...
 
void GetParameterFileData (xercesc::DOMDocument *p_oDoc)
 Extracts needed parameter file data. More...
 
void CalcFecAndFunctions ()
 Calculates fecundity and the probability distribution functions. More...
 
void PopulateUsedTable (clTreePopulation *p_oPop)
 Declares and populates the mp_bIsUsed array. More...
 
void CalculateGapStatus (clTreePopulation *p_oPop)
 Updates the gap status of the seed grid, if this is "GapDisperse". More...
 
void CalculateProbabilityDistribution (double *p_fProbArray, int iMaxDistance, int iSpecies, function iFunction, cover iCover)
 Calculates the normalized probability distribution for a function for one species. More...
 
void AddSeeds ()
 Performs dispersal. More...
 
float GetNumberOfSeeds (float fDbh, short int iSp, int iCover, int iFunc)
 Gets the number of seeds to disperse for a tree, corrected for the number of years per timestep. More...
 
- Protected Member Functions inherited from clDisperseBase
void GetData (xercesc::DOMDocument *p_oDoc)
 Triggers all disperse setup if an object is hooked. More...
 
void SetUpBase ()
 Does disperse base setup. 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

double *** mp_fDispersalX0
 For testing. More...
 
double *** mp_fThetaXb
 Theta (weibull) or Xb (lognormal) parameter. More...
 
double *** mp_fStr
 STR parameter. More...
 
double *** mp_fBeta
 Beta parameter. More...
 
double *** mp_fFecundity
 Fecundity for 30 cm dbh tree for each species. More...
 
double * mp_fStumpBeta
 Beta parameter for stumps. More...
 
double * mp_fStumpStr
 STR parameter for stumps. More...
 
double * mp_fStumpFecundity
 Fecundity for stumps. More...
 
double * mp_fDbhForReproduction
 Array of species with each one's dbh for reproduction. More...
 
double **** mp_fCumProb
 Cumulative probability array for gap and canopy cover. More...
 
int m_iNumYearsPerTimestep
 Number of years per timestep. More...
 
int m_iMaxDistance
 Maximum distance, in meters, a seed can disperse. More...
 
int m_iMaxGapDensity
 Maximum number of reproductively mature trees allowed in a grid cell for the grid cell to retain gap status. More...
 
short int * mp_iIndexes
 This will speed access to the other arrays by storing each species' array index so the other arrays only have to be as big as the number of unique species for this behavior. More...
 
short int m_iNumFunctions
 How many functions there are - 2. More...
 
short int m_iNumCovers
 How many cover types there are - 2. More...
 
function ** mp_iWhatFunction
 Which function is used - array indexes are cover by species. More...
 
char * m_cQuery
 Query to perform to search for trees. More...
 
bool ** mp_bIsUsed
 Whether this behavior is used by a species/type combo. More...
 
bool m_bIsGap
 True if this is gap disperse; false if not. More...
 
bool m_bStumps
 True if this behavior applies to stumps. More...
 
- Protected Attributes inherited from clDisperseBase
bool m_bHooked
 
- 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...
 

Additional Inherited Members

- Protected Types inherited from clDisperseBase
enum  function { weibull, lognormal }
 What PDF is used by a species. More...
 
enum  cover { gap, canopy }
 Cover status. More...
 
- Static Protected Attributes inherited from clDisperseBase
static clDisperseOrgmp_oDisperseOrg
 clDisperseOrg object - this pointer is held in common by all shells More...
 
static clGridmp_oSeedGrid
 Seed grid. More...
 
static short int * mp_iNumSeedsCode
 Data member codes for "dispersed seeds" grid for "seeds_x" data member. More...
 
static short int m_iGapCountCode
 Data member code - for counting trees for gap status. More...
 
static short int m_iIsGapCode
 Data member code for substrate grid for gap status. More...
 
static short int m_iTotalSpecies
 Total number of species. More...
 
static bool m_bUpdatedGapStatus
 A flag indicating whether or not the gap status of the seed grid has been updated this timestep. More...
 
static bool m_bIsStochastic
 Whether dispersal is stochastic (true) or deterministic (false). More...
 

Detailed Description

Spatial dispersal - Version 1.0.

This class creates and disperses seeds according to the spatially-explicit model. Parent trees of greater than the minimum reproductive DBH have the number of seeds calculated. The seeds are dispersed around the plot according to either the Weibull or Lognormal probability distribution functions.

Forest cover can be taken into account during seed distribution (gap) or ignored (non-gap).

This behavior can also be used for suckering of stumps. If this is desired, apply this to the species which sucker, tree type stump. If this is gap disperse, stumps reproduce pretending they're always in gap conditions. They use the probability distribution function of their species' gap function. If this is non-gap disperse, they reproduce like other adults of their species.

The "seeds" are actually tallies by species in a grid. This behavior does not produce any seedlings. A separate recruitment behavior must "germinate" the seeds into seedlings according to its own rules.

To call this as gap disperse in the parameter file, use the string "GapDisperse". To call this as non-gap disperse, use the string "NonGapDisperse". There is a place in the parameters for indicating which probability distribution function should be used under each cover type. The namestring for this class is "SpatialDisperse".

Copyright 2011 Charles D. Canham.

Author
Lora E. Murphy


Edit history:
--------------—
October 20, 2011 - Wiped the slate clean for SORTIE 7.0 (LEM)

Constructor & Destructor Documentation

◆ clSpatialDispersal()

clSpatialDispersal::clSpatialDispersal ( clSimManager p_oSimManager)

Constructor.

Parameters
p_oSimManagerSim Manager object.

◆ ~clSpatialDispersal()

clSpatialDispersal::~clSpatialDispersal ( )

Destructor.

Member Function Documentation

◆ AddSeeds()

void clSpatialDispersal::AddSeeds ( )
protectedvirtual

Performs dispersal.

This searches for all types to which it is applied. For trees which are of the appropriate species/type combo, either SpatialDisperse() or NonSpatialDisperse() is called.

Implements clDisperseBase.

◆ CalcFecAndFunctions()

void clSpatialDispersal::CalcFecAndFunctions ( )
protected

Calculates fecundity and the probability distribution functions.

Fecundity is calculated as

fec = STR/30beta

◆ CalculateFunctionValue()

float clSpatialDispersal::CalculateFunctionValue ( float  fDistance,
int  iSpecies,
function  iFunction,
cover  iCover 
)
protected

Calculates the function value at a particular point.

Parameters
fDistanceDistance at which to calculate function value.
iSpeciesSpecies for which to calculate function value.
iFunctionWhich function to calculate (weibull or lognormal).
iCoverCover for which to calculate function value.
Returns
Value of function.

◆ CalculateGapStatus()

void clSpatialDispersal::CalculateGapStatus ( clTreePopulation p_oPop)
protected

Updates the gap status of the seed grid, if this is "GapDisperse".

It counts all parent trees present in each grid cell (those that have a DBH of at least the minimum reproductive age for their species). The counts are placed in each grid cell and when the count is higher than the cutoff for gap status, the grid is under canopy; otherwise, it is under gap.

This counts all species, not just the ones to which this behavior applies. However, for those species that do not use this behavior, their minimum adult DBH will be used as the cutoff for counting, even if they have a minimum reproductive DBH listed. That's because I haven't bothered with the logistics of figuring out if a species uses another disperse behavior.

Parameters
p_oPopTree population object.

◆ CalculateProbabilityDistribution()

void clSpatialDispersal::CalculateProbabilityDistribution ( double *  p_fProbArray,
int  iMaxDistance,
int  iSpecies,
function  iFunction,
cover  iCover 
)
protected

Calculates the normalized probability distribution for a function for one species.

Parameters
p_fProbArrayThe array into which to put the normalized values.
iMaxDistanceThe maximum distance out to which to calculate the function - which must equal the size of p_fProbArray.
iSpeciesSpecies for which we're calculating.
iFunctionFunction flag.
iCoverCover flag.

◆ DeclareArrays()

void clSpatialDispersal::DeclareArrays ( )
protected

Declares the arrays.

◆ DoShellSetup()

void clSpatialDispersal::DoShellSetup ( xercesc::DOMDocument *  p_oDoc)
protectedvirtual

Reads in values from the parameter file.

Parameters
p_oDocDOM tree of parsed input file.

Implements clDisperseBase.

◆ GetNumberOfSeeds()

float clSpatialDispersal::GetNumberOfSeeds ( float  fDbh,
short int  iSp,
int  iCover,
int  iFunc 
)
protected

Gets the number of seeds to disperse for a tree, corrected for the number of years per timestep.

The equation is seeds = fecundity * DBHβ, where all parameters are appropriate for forest cover if this is gap disperse.

Parameters
fDbhDBH of the tree, in cm
iSpTree species number
iCoverForest cover
iFuncDisperse function used
Returns
Number of seeds.

◆ GetParameterFileData()

void clSpatialDispersal::GetParameterFileData ( xercesc::DOMDocument *  p_oDoc)
protected

Extracts needed parameter file data.

This function takes into account whether or not this is gap.

The minimum reproductive DBH array is pre-loaded with the minimum adult DBH values, so if there is a species that is not used by this behavior, CalculateGapStatus() still has something to use.

Parameters
p_oDocParsed parameter file document.
Exceptions
stcErrif:
  • A weibull theta value is not less than 50 (to prevent pow overflows)
  • The function codes are not valid enums
  • A beta value is greater than 25 (to prevent pow overflows)

◆ NonSpatialDisperse()

void clSpatialDispersal::NonSpatialDisperse ( clTree p_oTree,
clTreePopulation p_oPop,
clPlot p_oPlot,
float  fDbh 
)
protected

Performs dispersal of seeds for one tree according to non-gap disperse.

The number of seeds is calculated. Each seed is given a random azimuth direction from the parent. Then each seed is given a random distance from the parent that conforms to the chosen probability distribution function. This is done by comparing a random value to successive values in the cumulative probability array until the first array bucket that has a greater value than the random number. Once the seed has an azimuth direction and a distance, it is added to the species total in the appropriate grid cell.

Parameters
p_oTreeTree for which to perform dispersal.
fDbhDBH of the tree, in cm.
p_oPlotPlot object
p_oPopTree Population object

◆ PopulateUsedTable()

void clSpatialDispersal::PopulateUsedTable ( clTreePopulation p_oPop)
protected

Declares and populates the mp_bIsUsed array.

Parameters
p_oPopTree Population object

◆ SetNameData()

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

Captures the behavior name passed from the parameter file.

This is useful since this class can produce a few different kinds of behaviors.

Parameters
sNameStringBehavior name from parameter file.

Reimplemented from clBehaviorBase.

◆ SpatialDisperse()

void clSpatialDispersal::SpatialDisperse ( clTree p_oTree,
clTreePopulation p_oPop,
clPlot p_oPlot,
float  fDbh 
)
protected

Performs dispersal of seeds for one tree according to gap disperse.

The number of seeds for a tree is calculated with the higher of gap or canopy STR.

Each seed is given a random azimuth angle. It is then given a random distance that conforms to the probability distribution function of the current forest cover of the parent. (This distance is gotten by comparing a random value to successive values in the appropriate cumulative probability array until the first array bucket that has a greater value than the random number.) Once the seed has an azimuth and a distance, the function determines which grid cell it should drop in.

Once the seed has a target grid cell, that cell's cover is checked. Then the seed's survival is evaluated. If the seed is in the cover type with the higher STR, it automatically survives. Otherwise, a random number is compared to the ratio of the lower STR to the higher STR to determine if it survives.

If the seed survives, it may need to be repositioned. If both parent and seed are under closed canopy, the seed is dropped where it is. If the parent is in gap and seedling is in canopy, a new distance is calculated as though the parent was also in canopy. The shortest of the two distances is used to determine where the seed lands. If the seed lands in a gap cell, the function "walks out" the line of the seed's path from parent to target landing cell, checking each intermediate grid cell's cover along the way. If any of the grid cells in the line are under canopy cover, the seed drops in the first canopy cell it reaches.

Parameters
p_oTreeTree for which to perform dispersal.
fDbhDBH of the tree, in cm.
p_oPlotPlot object
p_oPopTree Population object

Member Data Documentation

◆ m_bIsGap

bool clSpatialDispersal::m_bIsGap
protected

True if this is gap disperse; false if not.

◆ m_bStumps

bool clSpatialDispersal::m_bStumps
protected

True if this behavior applies to stumps.

◆ m_cQuery

char* clSpatialDispersal::m_cQuery
protected

Query to perform to search for trees.

◆ m_iMaxDistance

int clSpatialDispersal::m_iMaxDistance
protected

Maximum distance, in meters, a seed can disperse.

◆ m_iMaxGapDensity

int clSpatialDispersal::m_iMaxGapDensity
protected

Maximum number of reproductively mature trees allowed in a grid cell for the grid cell to retain gap status.

◆ m_iNumCovers

short int clSpatialDispersal::m_iNumCovers
protected

How many cover types there are - 2.

◆ m_iNumFunctions

short int clSpatialDispersal::m_iNumFunctions
protected

How many functions there are - 2.

◆ m_iNumYearsPerTimestep

int clSpatialDispersal::m_iNumYearsPerTimestep
protected

Number of years per timestep.

◆ mp_bIsUsed

bool** clSpatialDispersal::mp_bIsUsed
protected

Whether this behavior is used by a species/type combo.

First array index is species, second is type.

◆ mp_fBeta

double*** clSpatialDispersal::mp_fBeta
protected

Beta parameter.

The array is 3D - first index is which disperse function is used. The second index is cover. The third index is species. This value comes from the parameter file.

◆ mp_fCumProb

double**** clSpatialDispersal::mp_fCumProb
protected

Cumulative probability array for gap and canopy cover.

Array size is

functions by # covers by # species by max distance.

◆ mp_fDbhForReproduction

double* clSpatialDispersal::mp_fDbhForReproduction
protected

Array of species with each one's dbh for reproduction.

◆ mp_fDispersalX0

double*** clSpatialDispersal::mp_fDispersalX0
protected

For testing.

Dispersal (weibull) or X0 (lognormal) parameter. The array is 3D - first index is which disperse function is used. The second index is cover. The third index is species. This value comes from the parameter file.

◆ mp_fFecundity

double*** clSpatialDispersal::mp_fFecundity
protected

Fecundity for 30 cm dbh tree for each species.

The array is 3D - first index is which disperse function is used. The second index is cover. The third index is species.

◆ mp_fStr

double*** clSpatialDispersal::mp_fStr
protected

STR parameter.

The array is 3D - first index is which disperse function is used. The second index is cover. The third index is species. This value comes from the parameter file.

◆ mp_fStumpBeta

double* clSpatialDispersal::mp_fStumpBeta
protected

Beta parameter for stumps.

This matches the beta parameter for live trees for this species.

◆ mp_fStumpFecundity

double* clSpatialDispersal::mp_fStumpFecundity
protected

Fecundity for stumps.

◆ mp_fStumpStr

double* clSpatialDispersal::mp_fStumpStr
protected

STR parameter for stumps.

This matches the STR parameter for live trees for this species.

◆ mp_fThetaXb

double*** clSpatialDispersal::mp_fThetaXb
protected

Theta (weibull) or Xb (lognormal) parameter.

If this is theta, this value must be less than 50 to protect against pow overflows. The array is 3D - first index is which disperse function is used. The second index is cover. The third index is species. This value comes from the parameter file.

◆ mp_iIndexes

short int* clSpatialDispersal::mp_iIndexes
protected

This will speed access to the other arrays by storing each species' array index so the other arrays only have to be as big as the number of unique species for this behavior.

◆ mp_iWhatFunction

function** clSpatialDispersal::mp_iWhatFunction
protected

Which function is used - array indexes are cover by species.


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