![]() |
Cell2Fire
A large-scale forest fire simulator.
|
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 () |
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.
_id | The unique identifier for the cell (0 to size of landscape - 1). |
_area | The area of the cell. |
_coord | The coordinates of the cell, represented as a vector of integers. |
_fType | The primary fuel type of the cell (0: NonBurnable, 1: Normal, 2: Burnable). |
_fType2 | The secondary fuel type as a descriptive string. |
_perimeter | The perimeter of the cell. |
_status | The fire status of the cell (0: Available, 1: Burning, 2: Burnt, 3: Harvested, 4: Non Fuel). |
_realId | Alternative identifier of the cell (1 to size of the landscape). |
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.
period | Current simulation period or time step. |
NMsg | Current simulation year. |
season | int |
df | Array containing cell-specific environmental and fuel data. |
coef | Pointer to a structure containing fuel coefficients used in ROS calculations. |
args | Pointer to a structure containing global simulation arguments and configurations. The ROS threshold should be stored here with the key "ROSThreshold". |
wdf_ptr | Pointer to the weather data structure containing wind speed, direction, and other weather variables. |
activeCrown | A boolean reference indicating whether crown fire activity is ongoing. |
perimeterCells | Cell size, perimeter of a cell. |
std::string Cells::getStatus | ( | ) |
Retrieve the cell's fire status.
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.
period | Current simulation period or timestep. |
df_ptr | Array containing cell-specific environmental and fuel data. |
coef | Pointer to a structure containing fuel coefficients used in ROS calculations. |
year | Current simulation year |
ignitionPoints | Vector with ignition point. |
args | Pointer to a structure containing global simulation arguments and configurations. The ROS threshold should be stored here with the key "ROSThreshold". |
wdf_ptr | Pointer to the weather data structure containing wind speed, direction, and other weather variables. |
activeCrown | A boolean reference indicating whether crown fire activity is ongoing. |
perimeterCells | size of a cell. |
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.
coordCells | A 2D vector representing the coordinates of all cells in the landscape. |
availSet | A set of available cells that can participate in fire spread. |
cols | The number of columns in the grid. |
rows | The number of rows in the grid. |
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.
period | Current simulation period or timestep. |
AvailSet | A set of available cells in the simulation (unused in this function, included for compatibility). |
df_ptr | Array containing cell-specific environmental and fuel data. |
coef | Pointer to a structure containing fuel coefficients used in ROS calculations. |
coordCells | A vector of coordinate mappings for the cells. |
Cells_Obj | A mapping of cell IDs to their corresponding Cells objects. |
args | Pointer to a structure containing global simulation arguments and configurations. |
wdf_ptr | Pointer to the weather data structure containing wind speed, direction, and other weather variables. |
FSCell | A vector to store fire spread information, including source cell, target cell, period, and ROS values. |
crownMetrics | A vector to store metrics related to crown fire behavior. |
activeCrown | A boolean reference indicating whether crown fire activity is ongoing. |
randomROS | A random value applied to ROS calculations when stochasticity is enabled. |
perimeterCells | Cell size, perimeter of a cell. |
crownState | A vector tracking the crown fire state of each cell. |
crownFraction | A vector tracking the fraction of fire in the crown layer for each cell. |
surfFraction | A vector tracking the fraction of fire in the surface layer for each cell. |
Intensities | A vector tracking the fire intensity for each cell. |
RateOfSpreads | A vector tracking the rate of spread for each cell. |
SurfaceFlameLengths | A vector tracking the flame length for each cell. |
CrownFlameLengths | A vector tracking the crownfire flame length for each cell. |
CrownIntensities | A vector tracking the crown fire intensity for each cell. |
MaxFlameLengths | A vector tracking the maximum between surface and crown flame lengths. |
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
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.
theta | The angle (in degrees) from the ellipse's major axis. |
a | The length of the semi-major axis of the ellipse. |
b | The length of the semi-minor axis of the ellipse. |
void Cells::ros_distr | ( | double | thetafire, |
double | forward, | ||
double | flank, | ||
double | back, | ||
double | EFactor | ||
) |
thetafire | |
forward | |
flank | |
back | |
EFactor |
void Cells::ros_distr_old | ( | double | thetafire, |
double | forward, | ||
double | flank, | ||
double | back | ||
) |
thetafire | |
forward | |
flank | |
back |
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.
thetafire | The direction of the fire's spread (in degrees). |
a | The semi-major axis of the ellipse representing fire spread. |
b | The semi-minor axis of the ellipse representing fire spread. |
EFactor | A scaling factor. |
void Cells::setStatus | ( | int | status_int | ) |
Sets a cell's fire status (0: Available, 1: Burning, 2: Burnt, 3: Harvested, 4: Non Fuel).
status_int | Code for new status. |