Cell2Fire
A large-scale forest fire simulator.
Loading...
Searching...
No Matches
Cells Class Reference

Public Member Functions

 Cells (int _id, double _area, std::vector< int > _coord, int _fType, std::string _fType2, double _perimeter, int _status, int _realId)
 Constructs a Cell object for the wildfire simulation.
 
void initializeFireFields (std::vector< std::vector< int > > &coordCells, std::unordered_set< int > &availSet, int cols, int rows)
 Initializes fire-related fields for the cell during ignition.
 
void ros_distr_old (double thetafire, double forward, double flank, double back)
 
double rhoTheta (double theta, double a, double b)
 Calculates the radial distance for a given angle in an ellipse defined by its semi-major and semi-minor axes.
 
void ros_distr (double thetafire, double forward, double flank, double back, double EFactor)
 
void ros_distr_V2 (double thetafire, double a, double b, double c, double EFactor)
 Distributes the Rate of Spread (ROS) across the cell's neighbors based on fire direction and ellipse geometry.
 
std::vector< int > manageFire (int period, std::unordered_set< int > &AvailSet, inputs df[], fuel_coefs *coef, std::vector< std::vector< int > > &coordCells, std::unordered_map< int, Cells > &Cells_Obj, arguments *args, weatherDF *wdf_ptr, std::vector< double > *FSCell, std::vector< float > *crownMetrics, bool &activeCrown, double randomROS, int perimeterCells, std::vector< int > &crownState, std::vector< float > &crownFraction, std::vector< float > &surfFraction, std::vector< float > &Intensities, std::vector< float > &RateOfSpreads, std::vector< float > &SurfaceFlameLengths, std::vector< float > &CrownFlameLengths, std::vector< float > &CrownIntensities, std::vector< float > &MaxFlameLengths)
 Manage's the cell's response to being reached by fire.
 
std::vector< int > manageFireBBO (int period, std::unordered_set< int > &AvailSet, inputs *df_ptr, fuel_coefs *coef, std::vector< std::vector< int > > &coordCells, std::unordered_map< int, Cells > &Cells_Obj, arguments *args, weatherDF *wdf_ptr, std::vector< double > *FSCell, std::vector< float > *crownMetrics, bool &activeCrown, double randomROS, int perimeterCells, std::vector< float > &EllipseFactors, std::vector< int > &crownState, std::vector< float > &crownFraction, std::vector< float > &surfFraction, std::vector< float > &Intensities, std::vector< float > &RateOfSpreads, std::vector< float > &FlameLengths)
 
bool get_burned (int period, int season, int NMsg, inputs df[], fuel_coefs *coef, arguments *args, weatherDF *wdf_ptr, bool &activeCrown, int perimeterCells)
 Checks if a cell that has been reached by fire begins to burn.
 
void setStatus (int status_int)
 Sets a cell's fire status (0: Available, 1: Burning, 2: Burnt, 3: Harvested, 4: Non Fuel).
 
std::string getStatus ()
 Retrieve the cell's fire status.
 
bool ignition (int period, int year, std::vector< int > &ignitionPoints, inputs *df_ptr, fuel_coefs *coef, arguments *args, weatherDF *wdf_ptr, bool &activeCrown, int perimeterCells)
 Ignites a cell.
 
void harvested (int id, int period)
 
void print_info ()
 

Public Attributes

int id
 
int fType
 
int realId
 
double _ctr2ctrdist
 
double area
 
double perimeter
 
std::string fType2
 
std::vector< int > coord
 
string FTypeD [3]
 
string StatusD [5]
 
int status
 
int hPeriod
 
int fireStarts
 
int harvestStarts
 
int fireStartsSeason
 
int burntP
 
int tYears
 
std::unordered_map< int, std::vector< int > > gMsgList
 
std::unordered_map< int, std::vector< int > > gMsgListSeason
 
std::unordered_map< int, double > fireProgress
 
std::unordered_map< int, double > angleDict
 
std::unordered_map< int, double > ROSAngleDir
 
std::unordered_map< int, double > distToCenter
 
std::unordered_map< int, int > angleToNb
 

Constructor & Destructor Documentation

◆ Cells()

Cells::Cells ( int  _id,
double  _area,
std::vector< int >  _coord,
int  _fType,
std::string  _fType2,
double  _perimeter,
int  _status,
int  _realId 
)

Constructs a Cell object for the wildfire simulation.

Initializes the cell's properties, such as its unique identifier, geographical attributes, fuel type, fire status, and other internal parameters used in the simulation. Validates the cell's area and perimeter consistency during initialization.

Parameters
_idThe unique identifier for the cell (0 to size of landscape - 1).
_areaThe area of the cell.
_coordThe coordinates of the cell, represented as a vector of integers.
_fTypeThe primary fuel type of the cell (0: NonBurnable, 1: Normal, 2: Burnable).
_fType2The secondary fuel type as a descriptive string.
_perimeterThe perimeter of the cell.
_statusThe fire status of the cell (0: Available, 1: Burning, 2: Burnt, 3: Harvested, 4: Non Fuel).
_realIdAlternative identifier of the cell (1 to size of the landscape).

Member Function Documentation

◆ get_burned()

bool Cells::get_burned ( int  period,
int  season,
int  NMsg,
inputs  df[],
fuel_coefs coef,
arguments args,
weatherDF wdf_ptr,
bool &  activeCrown,
int  perimeterCells 
)

Checks if a cell that has been reached by fire begins to burn.

If the ROS is above a threshold for burning then the cell ignites.

Returns
True if the cell starts to burn, False if not.
Parameters
periodCurrent simulation period or time step.
NMsgCurrent simulation year.
seasonint
dfArray containing cell-specific environmental and fuel data.
coefPointer to a structure containing fuel coefficients used in ROS calculations.
argsPointer to a structure containing global simulation arguments and configurations. The ROS threshold should be stored here with the key "ROSThreshold".
wdf_ptrPointer to the weather data structure containing wind speed, direction, and other weather variables.
activeCrownA boolean reference indicating whether crown fire activity is ongoing.
perimeterCellsCell size, perimeter of a cell.

◆ getStatus()

std::string Cells::getStatus ( )

Retrieve the cell's fire status.

Returns
The cell's fire status as a descriptive string.

◆ ignition()

bool Cells::ignition ( int  period,
int  year,
std::vector< int > &  ignitionPoints,
inputs df_ptr,
fuel_coefs coef,
arguments args,
weatherDF wdf_ptr,
bool &  activeCrown,
int  perimeterCells 
)

Ignites a cell.

Sets the following cell's attributes to represent ignition: status, fireStarts, fireStartsSeason, burnt.

Parameters
periodCurrent simulation period or timestep.
df_ptrArray containing cell-specific environmental and fuel data.
coefPointer to a structure containing fuel coefficients used in ROS calculations.
yearCurrent simulation year
ignitionPointsVector with ignition point.
argsPointer to a structure containing global simulation arguments and configurations. The ROS threshold should be stored here with the key "ROSThreshold".
wdf_ptrPointer to the weather data structure containing wind speed, direction, and other weather variables.
activeCrownA boolean reference indicating whether crown fire activity is ongoing.
perimeterCellssize of a cell.
Returns
True if ignition happens, False if not.

◆ initializeFireFields()

void Cells::initializeFireFields ( std::vector< std::vector< int > > &  coordCells,
std::unordered_set< int > &  availSet,
int  cols,
int  rows 
)

Initializes fire-related fields for the cell during ignition.

Populates the angles and distances to adjacent cells, and initializes the Rate of Spread (ROS) per axis using cell area to compute distances in meters. Initializes the internal dictionaries used for managing fire spread to the cell's neighbors.

Parameters
coordCellsA 2D vector representing the coordinates of all cells in the landscape.
availSetA set of available cells that can participate in fire spread.
colsThe number of columns in the grid.
rowsThe number of rows in the grid.
Returns
void

◆ manageFire()

std::vector< int > Cells::manageFire ( int  period,
std::unordered_set< int > &  AvailSet,
inputs  df_ptr[],
fuel_coefs coef,
std::vector< std::vector< int > > &  coordCells,
std::unordered_map< int, Cells > &  Cells_Obj,
arguments args,
weatherDF wdf_ptr,
std::vector< double > *  FSCell,
std::vector< float > *  crownMetrics,
bool &  activeCrown,
double  randomROS,
int  perimeterCells,
std::vector< int > &  crownState,
std::vector< float > &  crownFraction,
std::vector< float > &  surfFraction,
std::vector< float > &  Intensities,
std::vector< float > &  RateOfSpreads,
std::vector< float > &  SurfaceFlameLengths,
std::vector< float > &  CrownFlameLengths,
std::vector< float > &  CrownIntensities,
std::vector< float > &  MaxFlameLengths 
)

Manage's the cell's response to being reached by fire.

Calculates fire dynamics such as rate of spread (ROS), intensity, flame length, and other metrics based on the simulation's parameters and environmental inputs. It determines if the cell begins to spread fire, if so, messages are sent to neighboring cells. It also logs fire metrics for further analysis.

Parameters
periodCurrent simulation period or timestep.
AvailSetA set of available cells in the simulation (unused in this function, included for compatibility).
df_ptrArray containing cell-specific environmental and fuel data.
coefPointer to a structure containing fuel coefficients used in ROS calculations.
coordCellsA vector of coordinate mappings for the cells.
Cells_ObjA mapping of cell IDs to their corresponding Cells objects.
argsPointer to a structure containing global simulation arguments and configurations.
wdf_ptrPointer to the weather data structure containing wind speed, direction, and other weather variables.
FSCellA vector to store fire spread information, including source cell, target cell, period, and ROS values.
crownMetricsA vector to store metrics related to crown fire behavior.
activeCrownA boolean reference indicating whether crown fire activity is ongoing.
randomROSA random value applied to ROS calculations when stochasticity is enabled.
perimeterCellsCell size, perimeter of a cell.
crownStateA vector tracking the crown fire state of each cell.
crownFractionA vector tracking the fraction of fire in the crown layer for each cell.
surfFractionA vector tracking the fraction of fire in the surface layer for each cell.
IntensitiesA vector tracking the fire intensity for each cell.
RateOfSpreadsA vector tracking the rate of spread for each cell.
SurfaceFlameLengthsA vector tracking the flame length for each cell.
CrownFlameLengthsA vector tracking the crownfire flame length for each cell.
CrownIntensitiesA vector tracking the crown fire intensity for each cell.
MaxFlameLengthsA vector tracking the maximum between surface and crown flame lengths.
Returns
A vector of integers representing the list of neighboring cells that should receive a message indicating fire has reached them.
Here is the call graph for this function:

◆ manageFireBBO()

std::vector< int > Cells::manageFireBBO ( int  period,
std::unordered_set< int > &  AvailSet,
inputs df_ptr,
fuel_coefs coef,
std::vector< std::vector< int > > &  coordCells,
std::unordered_map< int, Cells > &  Cells_Obj,
arguments args,
weatherDF wdf_ptr,
std::vector< double > *  FSCell,
std::vector< float > *  crownMetrics,
bool &  activeCrown,
double  randomROS,
int  perimeterCells,
std::vector< float > &  EllipseFactors,
std::vector< int > &  crownState,
std::vector< float > &  crownFraction,
std::vector< float > &  surfFraction,
std::vector< float > &  Intensities,
std::vector< float > &  RateOfSpreads,
std::vector< float > &  FlameLengths 
)

Manage fire for BBO tuning version

Here is the call graph for this function:

◆ rhoTheta()

double Cells::rhoTheta ( double  theta,
double  a,
double  b 
)

Calculates the radial distance for a given angle in an ellipse defined by its semi-major and semi-minor axes.

Computes the distance from the center of an ellipse to its perimeter at a specified angle using the polar equation of an ellipse. The semi-major axis (a) and semi-minor axis (b) define the ellipse's geometry.

Parameters
thetaThe angle (in degrees) from the ellipse's major axis.
aThe length of the semi-major axis of the ellipse.
bThe length of the semi-minor axis of the ellipse.
Returns
The radial distance from the ellipse's center to its perimeter at the given angle.
Here is the caller graph for this function:

◆ ros_distr()

void Cells::ros_distr ( double  thetafire,
double  forward,
double  flank,
double  back,
double  EFactor 
)
Parameters
thetafire
forward
flank
back
EFactor
Here is the call graph for this function:

◆ ros_distr_old()

void Cells::ros_distr_old ( double  thetafire,
double  forward,
double  flank,
double  back 
)
Parameters
thetafire
forward
flank
back

◆ ros_distr_V2()

void Cells::ros_distr_V2 ( double  thetafire,
double  a,
double  b,
double  c,
double  EFactor 
)

Distributes the Rate of Spread (ROS) across the cell's neighbors based on fire direction and ellipse geometry.

Updates the ROS for each neighbor in the ROSAngleDir dictionary using an elliptical model. The ROS is scaled by the elliptical geometry parameters and a factor (EFactor), with adjustments based on the fire's heading direction.

Parameters
thetafireThe direction of the fire's spread (in degrees).
aThe semi-major axis of the ellipse representing fire spread.
bThe semi-minor axis of the ellipse representing fire spread.
EFactorA scaling factor.
Returns
void
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setStatus()

void Cells::setStatus ( int  status_int)

Sets a cell's fire status (0: Available, 1: Burning, 2: Burnt, 3: Harvested, 4: Non Fuel).

Parameters
status_intCode for new status.

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