![]() |
Cell2Fire
A large-scale forest fire simulator.
|
Public Member Functions | |
Cell2Fire (arguments args) | |
Constructs and initializes the Cell2Fire object to run a simulation. | |
void | InitCell (int id) |
Initializes a cell within the simulation and adds it to the cell collection. | |
void | reset (int rnumber, double rnumber2, int simExt) |
Resets the simulation environment for a new run. | |
bool | RunIgnition (std::default_random_engine generator, int ep) |
Simulates the ignition phase of the fire spread model for a single simulation year. | |
std::unordered_map< int, std::vector< int > > | SendMessages () |
Message-sending phase of the fire spread model, where burning cells propagate fire messages to neighboring cells. | |
void | GetMessages (std::unordered_map< int, std::vector< int > > sendMessageList) |
Processes incoming fire messages to determine the ignition and progression of fire in cells. | |
void | Results () |
Generates and outputs simulation results, including fire behavior metrics, final grid status, and logs. | |
void | outputGrid () |
Outputs the current state of the forest grid to a CSV file. | |
void | updateWeather () |
Updates the weather conditions during the simulation based on specified criteria. | |
void | Step (std::default_random_engine generator, int ep) |
Executes a single simulation step in the forest fire model. | |
void | InitHarvested () |
std::vector< float > | getROSMatrix () |
Retrieves the Rate of Spread (ROS) matrix for all cells. | |
std::vector< float > | getFireProgressMatrix () |
Retrieves the Fire Progress matrix for all cells. | |
Public Attributes | |
arguments | args |
arguments * | args_ptr |
fuel_coefs * | coef_ptr |
fuel_coefs | coefs [18] |
int | sim |
int | rows |
int | cols |
int | widthSims |
int | weatherPeriod = 0 |
int | year = 1 |
int | gridNumber = 0 |
int | weatherperiod = 0 |
int | counter_wt = 0 |
long int | nCells |
int | nIgnitions = 0 |
double | xllcorner |
double | yllcorner |
bool | noIgnition = true |
bool | activeCrown = false |
bool | messagesSent = false |
bool | repeatFire = false |
bool | done = false |
bool | noMessages = false |
double | cellSide |
double | areaCells |
double | perimeterCells |
double | ROSRV |
string | gridFolder |
string | messagesFolder |
string | rosFolder |
string | crownFolder |
string | surfaceIntensityFolder |
string | crownIntensityFolder |
string | sfbFolder |
string | cfbFolder |
string | surfaceFlameLengthFolder |
string | maxFlameLengthFolder |
string | crownFlameLengthFolder |
string | historyFolder |
string | ignitionsFolder |
std::vector< int > | fire_period |
std::vector< std::vector< int > > | coordCells |
std::vector< std::unordered_map< std::string, int > > | adjCells |
std::vector< std::vector< std::string > > | DF |
std::vector< std::vector< std::string > > | WDist |
std::vector< std::string > | WeatherHistory |
std::vector< float > | ignProb |
std::vector< int > | statusCells |
std::vector< int > | fTypeCells |
std::vector< string > | fTypeCells2 |
std::vector< std::vector< std::string > > | WeatherDF |
std::vector< int > | IgnitionPoints |
vector< int > | burnedOutList |
std::vector< double > | FSCell |
std::vector< float > | crownMetrics |
std::vector< int > | crownState |
std::vector< float > | surfaceIntensities |
std::vector< float > | crownIntensities |
std::vector< float > | crownFraction |
std::vector< float > | surfFraction |
std::vector< float > | RateOfSpreads |
std::vector< float > | surfaceFlameLengths |
std::vector< float > | crownFlameLengths |
std::vector< float > | maxFlameLengths |
std::vector< std::vector< int > > | IgnitionSets |
std::unordered_set< int > | availCells |
std::unordered_set< int > | nonBurnableCells |
std::unordered_set< int > | burningCells |
std::unordered_set< int > | burntCells |
std::unordered_set< int > | harvestCells |
std::unordered_map< int, Cells > | Cells_Obj |
Cell2Fire::Cell2Fire | ( | arguments | _args | ) |
Constructs and initializes the Cell2Fire object to run a simulation.
This constructor initializes the Cell2Fire
object by reading configuration and data files required for simulating fire spread in a forested environment. It populates various member variables, including fuel coefficients, forest structure, weather data, ignition points, and other simulation-related parameters. It also performs preprocessing steps to categorize cells into burnable and non-burnable types and to establish fire ignition sets.
_args | List of command line arguments containing configuration and file paths needed for the simulation. |
Cell2Fire
object ready for simulation.fuels
data and Data.csv
files.Weather.csv
and optionally WeatherDistribution.csv
.Ignitions.csv
(if provided) and computes adjacent cells based on the ignition radius.BBOFuels.csv
.std::vector< float > Cell2Fire::getFireProgressMatrix | ( | ) |
Retrieves the Fire Progress matrix for all cells.
void Cell2Fire::GetMessages | ( | std::unordered_map< int, std::vector< int > > | sendMessageList | ) |
Processes incoming fire messages to determine the ignition and progression of fire in cells.
This method handles the reception and processing of messages sent by burning cells. Based on the received messages, cells may ignite, continue burning, or be marked as burnt out. The method also manages the transitions between fire periods and updates relevant cell sets (e.g., available, burning, burnt).
sendMessageList | A map where each key is the ID of a burning cell, and the associated value is a list of neighboring cell IDs that received fire messages from that cell. |
burntCells
: Updated with cells that are fully burnt.burningCells
: Updated with newly ignited cells.availCells
: Reduced by removing newly burning cells.fire_period
: Incremented at the end of each fire period.year
: Incremented if no messages are sent and repeatFire
is false.When args.verbose
is enabled:
updateWeather
to apply weather conditions for the next fire period.std::vector< float > Cell2Fire::getROSMatrix | ( | ) |
Retrieves the Rate of Spread (ROS) matrix for all cells.
void Cell2Fire::InitCell | ( | int | id | ) |
Initializes a cell within the simulation and adds it to the cell collection.
This method creates a Cells
object for the specified cell ID, populates it with the necessary parameters, and stores it in the Cells_Obj
unordered map. It also initializes the fire-related fields for the cell and, if verbose mode is enabled, prints debugging information about the cell.
id | The ID of the cell to initialize. |
Cells
object is constructed using the cell's properties, including:areaCells
: The area of the cell.coordCells
: The coordinates of the cell.fTypeCells
: The fuel type of the cell.fTypeCells2
: A textual description of the fuel type.perimeterCells
: The perimeter of the cell.statusCells
: The status of the cell (e.g., burning, available).id
: The identifier for the cell.Cells_Obj
unordered map. void Cell2Fire::outputGrid | ( | ) |
Outputs the current state of the forest grid to a CSV file.
This method generates a binary representation of the forest grid, with cell statuses indicating their condition (burning, burnt, harvested, etc.) during the simulation. The file is saved with a unique name in the designated output folder.
statusCells2
) to reflect the current statuses of cells:1
for burning or burnt cells.-1
for harvested cells.0
for all other cells.gridNumber
and saves it in the gridFolder
directory.ForestGrid<gridNumber>.csv
.args.verbose
is enabled.statusCells2
.gridFolder
directory, with the grid's state for the current simulation step.gridFolder
directory exists before calling this method to avoid file I/O errors.gridNumber
after each call to ensure unique file names. void Cell2Fire::reset | ( | int | rnumber, |
double | rnumber2, | ||
int | simExt = 1 |
||
) |
Resets the simulation environment for a new run.
This method initializes and resets all relevant parameters, structures, and files needed for the simulation. It handles:
rnumber | Random seed or identifier for weather selection. |
rnumber2 | Random value for initializing ROS (Rate of Spread) variations. |
simExt | Simulation extension identifier (default: 1). |
void Cell2Fire::Results | ( | ) |
Generates and outputs simulation results, including fire behavior metrics, final grid status, and logs.
This method processes the results of the fire simulation, updating cell statuses and generating various outputs such as grid data, fire spread metrics, and intensity logs. It supports multiple file formats (e.g., CSV, ASCII) and organizes output into designated folders for easy analysis and debugging.
burntCells
and burningCells
are marked as fully burnt (status = 2
).args.FinalGrid
is enabled.args.OutMessages
is enabled.args.IgnitionsLog
is enabled.args.OutFolder
).sim
) to ensure unique file names.bool Cell2Fire::RunIgnition | ( | std::default_random_engine | generator, |
int | ep | ||
) |
Simulates the ignition phase of the fire spread model for a single simulation year.
This method is responsible for selecting ignition points, either randomly or from predefined data (e.g., CSV files), and attempting to ignite those points based on the conditions of the cells (availability, burnability, etc.). The simulation state is updated accordingly, including tracking ignited, burnt, and available cells, as well as the fire and weather periods.
generator | A random engine used to generate random values for ignition point selection. |
ep | The current simulation epoch, used to seed the secondary random generator for parallel simulations. |
When args.verbose
is true, detailed logs of the ignition process, including selected points, random values, and status updates, are printed to the console.
std::unordered_map< int, std::vector< int > > Cell2Fire::SendMessages | ( | ) |
Message-sending phase of the fire spread model, where burning cells propagate fire messages to neighboring cells.
This method iterates through all burning cells, updates their fire progress, and determines whether fire messages should be sent to neighboring cells. A fire message is sent to a cell if fire reaches its center. Burnt-out cells are also identified and removed from the burning set.
manageFire
or manageFireBBO
methods, depending on tuning options.sendMessageList
) that receive fire messages for potential ignition.burningCells
: Updated to exclude cells that have burnt out.burnedOutList
: Contains cells that are no longer burning after this phase.messagesSent
: A flag indicating if any fire messages were sent during this phase.When args.verbose
is enabled:
args.MaxFirePeriods
). Send messages logic
void Cell2Fire::Step | ( | std::default_random_engine | generator, |
int | ep | ||
) |
Executes a single simulation step in the forest fire model.
This method simulates one fire period, handling all related processes such as ignition, message exchange, weather updates, and transitioning between simulation years or scenarios. It is the core operational logic for advancing the simulation in discrete steps.
verbose
is enabled, prints details about the current simulation state, including the year, fire period, weather period, and grid status.TotalYears
).MaxFirePeriods
), advances to the next year.void Cell2Fire::updateWeather | ( | ) |
Updates the weather conditions during the simulation based on specified criteria.
This method dynamically updates the weather parameters used in the simulation based on the simulation's fire period and weather options. It can optionally output the current state of the forest grid and log weather updates if verbose mode is enabled.
WeatherOpt
argument is not set to "constant"
.weatherPeriod
.weatherPeriod
is incremented.OutputGrids
argument is enabled, the current forest grid is output using the outputGrid
method.verbose
mode is enabled:CSVWeather.printWeatherDF
.