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

Planting - Version 1.0. More...

#include <Planting.h>

Inheritance diagram for clPlant:
clBehaviorBase clWorkerBase

Classes

struct  stcGridList
 Holds a linked list of grid cells. More...
 

Public Types

enum  spaceType { gridded, random }
 Type of plant spacing. More...
 

Public Member Functions

 clPlant (clSimManager *p_oSimManager)
 Constructor. More...
 
 ~clPlant ()
 Destructor. More...
 
void TimestepCleanup ()
 Resets the values in the plantresults grid to 0. More...
 
void Action ()
 Performs the planting for a timestep. 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 void SetNameData (std::string sNameString)
 Sets the string for the parameter file 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 GetData (xercesc::DOMDocument *p_oDoc)
 Reads all the plant events from the parameter file. More...
 
void SetupPlantGrids ()
 Sets up the plant grids and gets all the return codes. More...
 
void ValidatePackages ()
 Makes sure that the data in the plant master packages makes sense. More...
 
void PlantTrees (clPackage *p_oMasterPackage)
 Performs the tree planting for a master plant package. More...
 
int AssemblePlantArea (clPackage *p_oMasterPackage, const int &iNumXCells, const int &iNumYCells, stcGridList *&p_plantArea)
 Finds the planting area for a planting event. 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_oPlantMasterGrid
 PLANTING MASTER. More...
 
clGridmp_oPlantEventsGrid
 PLANT EVENTS. More...
 
clGridmp_oPlantResultsGrid
 PLANT RESULTS. More...
 
float * mp_fInitialDiam10
 Size of seedlings to plant. More...
 
short int m_iMasterTimestepCode
 timestep data member code in "planttmaster" grid More...
 
short int m_iMasterIDCode
 id code in "planttmaster" grid More...
 
short int * mp_iAmtPlantCodes
 amtPlant code in "planttmaster" grid. More...
 
short int m_iSpaceTypeCode
 spacetype code in "planttmaster" grid More...
 
short int m_iSpacingOrDensityCode
 spcorden code in "planttmaster" grid More...
 
short int m_iPlantTimestepCode
 timestep code in "plantevents" grid More...
 
short int m_iPlantIDCode
 id code in "plantevents" grid More...
 
short int * mp_iPlantedCodes
 planted codes in "plantresults" grid. 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...
 

Detailed Description

Planting - Version 1.0.

Planting events 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 planting criteria are grouped by the user into groups which will be evaluated together.

Seedlings to be planted can be placed either randomly around the planting cells or in a gridded fashion. When random, each seedling is placed randomly within the entire chunk being planted. When gridded, each seedling is placed within a given grid cell. This means that gridded plantings are likely to be suboptimal unless they divide nicely into the length of a grid cell. I have not figured out a better way to do gridded plantings.

The size of new seedlings can be left as the standard new seedling size or it can be changed.

The relative amounts of each species are in the parameter file. When reading the file, this behavior expects values as percentages.

The planting data is stored in a grid. Each plant event, defined as the planting 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 planting events that are defined for that timestep are executed, then those packages are removed.

A word on planting grids: It is possible for there to be grid maps for these grids in the parameter file. These will be ignored, and any grids created with these maps will be replaced.

The namestring and parameter file call string for this behavior is "Plant."

Copyright 2011 Charles D. Canham.

Author
Lora E. Murphy


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

Member Enumeration Documentation

◆ spaceType

Type of plant spacing.

Enumerator
gridded 

Plants are spaced on a grid.

random 

Constructor & Destructor Documentation

◆ clPlant()

clPlant::clPlant ( clSimManager p_oSimManager)

Constructor.

Parameters
p_oSimManagerSim Manager object.

◆ ~clPlant()

clPlant::~clPlant ( )

Destructor.

Member Function Documentation

◆ Action()

void clPlant::Action ( )
virtual

Performs the planting for a timestep.

For a timestep, this goes through the master package lists in plantmaster and calls PlantTrees() for each one that is for this timestep.

Reimplemented from clBehaviorBase.

◆ AssemblePlantArea()

int clPlant::AssemblePlantArea ( clPackage p_oMasterPackage,
const int &  iNumXCells,
const int &  iNumYCells,
stcGridList *&  p_plantArea 
)
protected

Finds the planting area for a planting event.

For a master plant package, this finds all the grid cells affected by this planting by matching ID numbers on packages in the plantevents grid. The plant area cells are assembled into a linked list. All packages which went into the linked list are then deleted.

Parameters
p_oMasterPackageThe master package for which the plant area list is being assembled. (This package will NOT be deleted.)
iNumXCellsmp_oPlantEventsGrid's number of cells in the X direction.
iNumYCellsmp_oPlantEventsGrid's number of cells in the Y direction.
p_plantAreaPointer in which to place the linked list of grid cells.
Returns
The number of the cells in the planting area.

◆ GetData()

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

Reads all the plant events from the parameter file.

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

Parameters
p_oDocDOM tree of parsed input file.

Implements clWorkerBase.

◆ PlantTrees()

void clPlant::PlantTrees ( clPackage p_oMasterPackage)
protected

Performs the tree planting for a master plant package.

It starts by getting a linked list of cells to plant from the package. When planting randomly, for each tree being planted, a cell is selected at random and then a point within that cell is selected at random. For gridded plantings, each cell is evaluated separately. For a location in the cell, one of the species is picked based on a random number compared to the desired relative amounts of each species.

Parameters
p_oMasterPackageThe master package to plant

◆ SetupPlantGrids()

void clPlant::SetupPlantGrids ( )
protected

Sets up the plant grids and gets all the return codes.

◆ TimestepCleanup()

void clPlant::TimestepCleanup ( )
virtual

Resets the values in the plantresults grid to 0.

Reimplemented from clWorkerBase.

◆ ValidatePackages()

void clPlant::ValidatePackages ( )
protected

Makes sure that the data in the plant master packages makes sense.

For each one this checks the following:

  • No negative values
  • Relative amounts in percentages add up to 100
  • For gridded plantings - grid spacing is less than the grid length

Member Data Documentation

◆ m_iMasterIDCode

short int clPlant::m_iMasterIDCode
protected

id code in "planttmaster" grid

◆ m_iMasterTimestepCode

short int clPlant::m_iMasterTimestepCode
protected

timestep data member code in "planttmaster" grid

◆ m_iPlantIDCode

short int clPlant::m_iPlantIDCode
protected

id code in "plantevents" grid

◆ m_iPlantTimestepCode

short int clPlant::m_iPlantTimestepCode
protected

timestep code in "plantevents" grid

◆ m_iSpaceTypeCode

short int clPlant::m_iSpaceTypeCode
protected

spacetype code in "planttmaster" grid

◆ m_iSpacingOrDensityCode

short int clPlant::m_iSpacingOrDensityCode
protected

spcorden code in "planttmaster" grid

◆ mp_fInitialDiam10

float* clPlant::mp_fInitialDiam10
protected

Size of seedlings to plant.

Actual values are randomized slightly around these values. Array size is number of species.

◆ mp_iAmtPlantCodes

short int* clPlant::mp_iAmtPlantCodes
protected

amtPlant code in "planttmaster" grid.

Array size is number of species - array index matches species number

◆ mp_iPlantedCodes

short int* clPlant::mp_iPlantedCodes
protected

planted codes in "plantresults" grid.

Array size is number of species.

◆ mp_oPlantEventsGrid

clGrid* clPlant::mp_oPlantEventsGrid
protected

PLANT EVENTS.

The grid called "plantevents" will have a cell resolution that matches the tree population. This is where data about planting events is stored.

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

Data members - all for packages:

Data member Type Description
id int ID number matching master package in "plantmaster"
timestep int Timestep at which to apply the plant

◆ mp_oPlantMasterGrid

clGrid* clPlant::mp_oPlantMasterGrid
protected

PLANTING MASTER.

The grid called "plantmaster" will have a single cell. This is where the plant events are defined.

Each plant event is one package and is applied to a list of species. It has a unique ID number. The grid cells to which it is applied are in the "plantevents" grid.

The packages are in timestep order, earliest first.

Data members - all for packages:

Data member Type Description
id int ID number of plant event
timestep int Timestep to plant
spacetype int Matches a value of the enum "spaceType"
spcorden float If spacetype = gridded, spacing of trees, in m. If spacetype = random, total density/ha for all species.
amtPlant(x) float One of each of these for each species (species # = x). This is the percentage, between 0 and 100, of each species desired. If a species is not to be planted, its value is 0.

◆ mp_oPlantResultsGrid

clGrid* clPlant::mp_oPlantResultsGrid
protected

PLANT RESULTS.

The grid called "Planting Results" will have a grid cell resolution matching that of "plantevents". This is where data on planting results is stored. The data is stored raw - no conversion to per-hectare amounts.

Data member Type Description
planted(x) int Number of trees planted in the current timestep - one of these for each species (x = species number)

◆ mp_oPop

clTreePopulation* clPlant::mp_oPop
protected

Stashed pointer to tree population.


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