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

Bole Volume Calculator Version 1.0. More...

#include <BoleVolumeCalculator.h>

Inheritance diagram for clBoleVolumeCalculator:
clBehaviorBase clWorkerBase

Public Member Functions

 clBoleVolumeCalculator (clSimManager *p_oSimManager)
 Constructor. More...
 
 ~clBoleVolumeCalculator ()
 Destructor. More...
 
void Action ()
 Makes volume calculations. More...
 
void GetData (xercesc::DOMDocument *p_oDoc)
 Does setup for this behavior. More...
 
void RegisterTreeDataMembers ()
 Registers the "Bole Vol" float data member. 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 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 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...
 

Protected Member Functions

int GetBoleHeight (const float &fDBH, const int &iSpecies)
 Gets the merchantable bole height of a tree. More...
 
void GetParameterFileData (xercesc::DOMDocument *p_oDoc)
 Reads values from the parameter file. More...
 
void FormatQueryString ()
 Formats the string in m_sQuery. More...
 
void PopulateTaperTable ()
 Populates the taper table. 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_fB0
 b0 in the volume equation. More...
 
double * mp_fB1
 b1 in the volume equation. More...
 
double * mp_fB2
 b2 in the volume equation. More...
 
double * mp_fB3
 b3 in the volume equation. More...
 
double * mp_fB4
 b4 in the volume equation. More...
 
double * mp_fB5
 b5 in the volume equation. More...
 
double * mp_fFormClass
 Form classes. More...
 
float ** mp_fTaperTable
 Taper table. More...
 
short int * mp_iIndexes
 For quick access to the species-specific arrays. More...
 
std::string m_sQuery
 String to pass to clTreePopulation::Find() in order to get the trees for which to calculate volume. More...
 
short int ** mp_iVolumeCodes
 Holds data member codes for "Bole Vol" float data member. More...
 
short int m_iMaxLogs
 The maximum number of logs a tree can have. More...
 
short int m_iDBHIncs
 Number of DBH increments in the taper table. 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

Bole Volume Calculator Version 1.0.

This class calculates merchantable tree volume according to a US Forest Service equation. The volume value is stored in an float tree data member that this behavior adds as a value in cubic feet.

Tree volume is calculated as follows:

V = b0 + b1*DBHb2 + b3* DBHb4 * Heightb5

Where:

The bole length is the number of 16-foot logs the tree can provide. The base of the bole is the top of the cut stump (whatever that is; it's ignored by this behavior); the top of the bole is the merchantable height. This behavior defines the merchantable height as the height at which the trunk diameter inside the bark tapers to 60% of DBH.

To determine at what bole length the merchantable height occurs, we try fitting as many 16-foot logs as possible in to see how many fit before the 60% taper occurs. The amount of taper at the top of the first 16-foot log is established by the form classes and is a fixed percentage entered by the user as a parameter.

The amount of taper at the top of the first 16-foot log is subtracted from the DBH, to see how much taper is left before the 60% merchantable-height taper is reached. There is no formula that establishes clearly how many logs will fit; we use a trial-and-error approach on a table until we find the correct number of logs. The table below, adapted from Messavage and Girard, is contained in the code. It represents the amount of taper at the top of the last log in a tree containing different numbers of logs.

DBH (in)2-log3-log4-log5-log6-log
101.42.6
121.62.84.4
141.734.7
161.93.24.9
1823.45.2
202.13.65.67.8
222.23.85.98
242.346.38.4
262.44.26.58.7
282.54.46.8912
302.64.67.29.412.1
322.74.77.39.912.3
342.84.87.610.212.6
362.84.97.810.413
382.94.97.910.513.4
402.95810.913.9

Consider a maple tree with a 20-inch DBH. The user enters its form class as 79%. We calculate the merchantable height to be that height at which the tree diameter inside the bark is 20 * 0.6 = 12 inches. The diameter at the top of the first 16-foot log = 20 * 0.79 = 15.8 inches.

The diameter at merchantable height is 12 inches; at the top of the first log it is 15.8 inches. This means there is 3.8 inches of taper available left. The next job is to use the lookup table to determine how many logs will fit into this amount of taper.

Our DBH is 20 inches, which has an entry for itself in the lookup table. If our DBH was not an even multiple of 2 inches, we would round down to the next lowest multiple of 2. Any tree larger than 40 inches of DBH will use the 40-inch entry. Trees must have a DBH of at least 10 inches to get a volume.

We begin by assuming that our tree is a 2-log tree. The amount of taper to the top of the second log in the table is given as 2.1. This means our diameter at the top of the second log is 15.8 - 2.1 = 13.7 inches. This is greater than 12 inches; so we will go back and try to fit three logs in.

For a 3-log tree of 20 inches, the taper at the top of the third log is 3.6 inches. The diameter at the top of this log is 15.8 - 3.6 = 12.2. This is still greater than 12, so we will try to fit in four logs.

The diameter at the top of the fourth log of a 4-log tree of 20 inches DBH is 15.8 - 1.4 - 1.8 - 2.4, or 10.2. This is less than 12. Thus, 4 logs don't fit. Our bole length is 3 * 16 = 48 feet.

This behavior adds an float data member called "Bole Vol" to trees that holds the final volume calculation as a value in square meters.

This class's namestring and parameter call string are both "TreeBoleVolumeCalculator".

This behavior may not be applied to seedlings.


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

Constructor & Destructor Documentation

◆ clBoleVolumeCalculator()

clBoleVolumeCalculator::clBoleVolumeCalculator ( clSimManager p_oSimManager)

Constructor.

Parameters
p_oSimManagerclSimManager object.

◆ ~clBoleVolumeCalculator()

clBoleVolumeCalculator::~clBoleVolumeCalculator ( )

Destructor.

Deletes arrays.

Member Function Documentation

◆ Action()

void clBoleVolumeCalculator::Action ( )
virtual

Makes volume calculations.

A query is sent to the tree population to get all trees to which this behavior is applied. For each, the volume is calculated by GetTreeVolume(). This value is placed in the "Bole Vol" float tree data member.

Reimplemented from clBehaviorBase.

◆ FormatQueryString()

void clBoleVolumeCalculator::FormatQueryString ( )
protected

Formats the string in m_sQuery.

This value will be used in Action() to pass to clTreePopulation::Find() in order to get the trees to act on.

◆ GetBoleHeight()

int clBoleVolumeCalculator::GetBoleHeight ( const float &  fDBH,
const int &  iSpecies 
)
protected

Gets the merchantable bole height of a tree.

This function calculates the taper to the top of the first log using the form class for the species. After determining how much taper is left, it uses the taper table to determine how many logs to add. It determines the DBH increment index by rounding down to the nearest even number and subtracting 10 (with a max index of 15). Then, for that index, it moves from 0 to m_iMaxLogs across the table until it finds the greatest entry that is less than or equal to the remaining taper. That array index is equal to the number of logs to add to the first one. Then the result is multiplied by 16 and returned.

This function does not weed out trees with a DBH of less than 10 inches.

Parameters
fDBHSORTIE's DBH value, in in
iSpeciesTree's species.
Returns
Bole height as an integer number of feet.

◆ GetData()

void clBoleVolumeCalculator::GetData ( xercesc::DOMDocument *  p_oDoc)
virtual

Does setup for this behavior.

Calls:

  1. GetParameterFileData
  2. FormatQueryString
  3. PopulateTaperTable
  4. Action() so that the initial conditions volume will be added
Parameters
p_oDocDOM tree of parsed input file.

Implements clWorkerBase.

◆ GetParameterFileData()

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

Reads values from the parameter file.

Parameters
p_oDocDOM tree of parsed input file.
Exceptions
modelErrif any value for form class is less than 60%.

◆ PopulateTaperTable()

void clBoleVolumeCalculator::PopulateTaperTable ( )
protected

Populates the taper table.

The taper array is declared and the values populated according to the values in the documentation above.

◆ RegisterTreeDataMembers()

void clBoleVolumeCalculator::RegisterTreeDataMembers ( )
virtual

Registers the "Bole Vol" float data member.

The return codes are captured in the mp_iVolumeCodes array.

Exceptions
modelErrif this behavior is being applied to any tree type except saplings, adults, and snags.

Reimplemented from clBehaviorBase.

Member Data Documentation

◆ m_iDBHIncs

short int clBoleVolumeCalculator::m_iDBHIncs
protected

Number of DBH increments in the taper table.

Equal to 16 (DBH in 2-in increments from 10 to 40 inches).

◆ m_iMaxLogs

short int clBoleVolumeCalculator::m_iMaxLogs
protected

The maximum number of logs a tree can have.

Equal to 6.

◆ m_sQuery

std::string clBoleVolumeCalculator::m_sQuery
protected

String to pass to clTreePopulation::Find() in order to get the trees for which to calculate volume.

This will instigate a species/type search for all the species and types to which this behavior applies.

◆ mp_fB0

double* clBoleVolumeCalculator::mp_fB0
protected

b0 in the volume equation.

Array size is # behavior species.

◆ mp_fB1

double* clBoleVolumeCalculator::mp_fB1
protected

b1 in the volume equation.

Array size is # behavior species.

◆ mp_fB2

double* clBoleVolumeCalculator::mp_fB2
protected

b2 in the volume equation.

Array size is # behavior species.

◆ mp_fB3

double* clBoleVolumeCalculator::mp_fB3
protected

b3 in the volume equation.

Array size is # behavior species.

◆ mp_fB4

double* clBoleVolumeCalculator::mp_fB4
protected

b4 in the volume equation.

Array size is # behavior species.

◆ mp_fB5

double* clBoleVolumeCalculator::mp_fB5
protected

b5 in the volume equation.

Array size is # behavior species.

◆ mp_fFormClass

double* clBoleVolumeCalculator::mp_fFormClass
protected

Form classes.

This is the proportion of DBH that the diameter is at the top of the first log. This is entered by the user as a percentage between 60 and 100 but to save math we convert to a proportion and subtract it from 1 so it's the inverse. Array size is # behavior species.

◆ mp_fTaperTable

float** clBoleVolumeCalculator::mp_fTaperTable
protected

Taper table.

This is the amount by which diameter is reduced, in inches, at the top of the last log in a 2-, 3-, 4-, 5-, or 6-log tree. First array index is 16 (m_iDBHIncs, DBH in 2-in increments from 10 to 40 inches); second index is 6 (m_iMaxLogs).

◆ mp_iIndexes

short int* clBoleVolumeCalculator::mp_iIndexes
protected

For quick access to the species-specific arrays.

Array size is # total species.

◆ mp_iVolumeCodes

short int** clBoleVolumeCalculator::mp_iVolumeCodes
protected

Holds data member codes for "Bole Vol" float data member.

First array index is # behavior species, second is number types (3 - sapling, adult, snag)


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