C++ API Reference
This section provides a high-level overview of the most fundamental C++ classes and interfaces that constitute the ForeFire simulation engine. For a comprehensive, detailed API reference for all classes and functions, please consult the full Doxygen-generated documentation.
Core Simulation Objects
These classes represent the primary entities in a wildfire simulation.
-
class FireDomain : public libforefire::ForeFireAtom, private libforefire::Visitable
Class describing the “world” of the simulation.
FireDomain represents all the data and models provided to simulate the fire propagation. It embodies the ‘FireFronts’, the ‘boundaries’, the ‘dataBroker’ and physical models necessary for the simulation.
Public Functions
-
FireDomain()
Default constructor.
boolean if some has been read
-
FireDomain(const int&, const int&, const int&, const int&, const double&, const double&, const double&, const int&, const double*, const int&, const double*, const int&, const double&)
Constructor with boundaries, time and reference longitude and latitude.
-
virtual ~FireDomain()
Destructor.
-
double getSimulationTime()
present time of the simulation
-
void backupState()
Storing information of the simulation.
-
void restoreValidState()
Returning to a valid state of simulation.
-
int getReferenceYear()
Accessors.
-
void validateTopology(string)
validating the topology for the nodes in the simulation
-
void setSafeTopologyMode(bool)
Setting the safe mode for topology.
-
int getMaxComNodes()
give Max com nodes
-
virtual void update()
updates the ‘FireDomain’ (overloads ‘update()’ from ‘ForeFireAtom’)
-
virtual void timeAdvance()
computes the next FireDomain properties (overloads ‘timeAdvance()’ from ‘ForeFireAtom’)
-
virtual void output()
Output function
-
void addNewAtomToSimulation(ForeFireAtom*)
inserting a newly created atom in the simulation
-
void deleteAtomOfSimulation(ForeFireAtom*)
deleting an atom in the simulation
-
FluxLayer<double> *getFluxLayer(const string&)
getting a specified flux layer
-
virtual void accept(Visitor*)
visitor function
-
bool firenodeInList(FireNode*, const list<FireNode*>&)
Test to see if a firenode pertains to a list.
-
FireNodeData *idInList(const double&, const list<FireNodeData*>&)
Test to see if a firenode data pertains to a list.
-
FireNodeData *posInList(const double&, const double&, const list<FireNodeData*>&)
Test to see if a position is in a list.
-
FFPoint findIntersection(FFPoint&, FFPoint&, FFPoint&, FFPoint&)
finding the intersection between two segments
-
FFPoint findIntersectionWithBoundingBox(FFPoint&, FFPoint&, FFPoint&, FFPoint&, int&)
finding the intersection with a bounding box
-
double getModelValueAt(int&, FFPoint&, const double&, const double&, const double&)
Computing the propagation speed of a given firenode.
-
void removeFireNodeInCell(FireNode*)
finds the related cell and remove a given firenode to the list
-
list<FireNode*> getNodesWithin(FireNode*, const double&, bool = true)
listing all the firenodes close to a given one
-
list<FireNode*> getPhysicalDomainNodesWithin(FFPoint&, const double&, bool = true)
listing all the firenodes, in the physical domain, close to a given one
-
void saveArrivalTimeNC()
saving the simulation
-
void loadArrivalTimeNC(string)
loading the simulation
-
void dumpBurningMatrixAsBinary()
dumping the map of arrival times for debugging
-
virtual string toString()
print function
-
void computeBoundingBox(FireNode*, FireNode*, FireNode*, FFPoint&, FFPoint&)
defining a bounding box containing three fire nodes
-
void constructLocalSurroundingPolygon(FireNode*, FFPoint&, FFPoint&, vector<double>&, vector<double>&)
defining an optimized polygon around a firenode and its neighbors
-
void frontInitialBurningScan(const double&, FireFront*, const double&, const double&)
initial burning scan
-
void frontBurningScan(FireFront*, const double&)
global scanning for burning matrix during simulation
-
void singlePolygonAreaBurningScan(FFPoint&, FFPoint&, double, bool, size_t&, double*, double*)
scanning a region according to one polygon
-
std::vector<std::vector<double>> getDataMatrix(const std::string&)
retrun a diag matrix
Public Members
-
bool parallel
boolean for coupled simulations
-
bool isFireActive
boolean for parallel simulations
Public Static Attributes
-
static const size_t NUM_MAX_PROPMODELS = 50
maximum number of propagation models
-
static const size_t NUM_MAX_FLUXMODELS = 500
maximum number of flux models
-
static bool outputs = false
boolean for command outputs
-
static bool recycleNodes = false
boolean for outputs
-
struct CellData
-
struct DistributedDomainBCellList
-
struct distributedDomainInfo
-
FireDomain()
-
class FireFront : public libforefire::ForeFireAtom, private libforefire::Visitable
Class describing a fire front.
A FireFront implements a pointer to the so-called ‘headNode’ and all its ‘innerFronts’ (also of type FireFront). Thanks to ‘nextInFront’ and ‘previousInFront’ pointers of the FireNode class all the FireNodes constituting the FireFront are linked. An iterator is setVal up in order to go through all the FireNodes of the FireFront.
Public Functions
-
FireFront(FireDomain* = 0)
Default constructor, to be avoided.
boolean for outputs
-
FireFront(const double&, FireDomain*, FireFront* = 0)
Constructor for a front included in a ‘FireDomain’ and a containing front.
-
virtual ~FireFront()
Destructor.
-
FireDomain *getDomain()
Accesssor to the domain.
-
virtual void update()
updates the ‘FireFront’ properties (overloads ‘update()’ from ‘ForeFireAtom’)
-
virtual void timeAdvance()
computes the next ‘FireFront’ properties and the time of update. (overloads ‘timeAdvance()’ from ‘ForeFireAtom’)
-
virtual void output()
Output function
-
virtual void accept(Visitor*)
Visitor function.
-
bool isExpanding()
behavior of th firefront
-
double getArea()
Area of the front.
-
int getNumInnerFronts()
getter of the number of inner fronts
-
void extend()
extending the firefront in one direction
-
void storeVertices(double*, double*, size_t&)
constructing arrays storing the coordinates of the vertices constituting the front
-
void increaseNumFN()
managing the number of firenodes in the front
-
void makeTrash()
making the front a trash one
-
virtual string toString()
print function
-
FireFront(FireDomain* = 0)
-
class FireNode : public libforefire::ForeFireAtom, private libforefire::Visitable
Object constituting the fire front.
FireNode defines the lagrangian tracking particles for the fire front. Their properties are: the location, the normal to the front and the rate of spread. Pointers are setVal to the nextInFront and previous fire nodes of the front. The next location of the node is computed in ‘timeAdvance()’ function overloaded from the ForeFireAtom class. The ‘update()’ function also overloads the virtual function from the ForeFireAtom class and setVal the new properties of the FireNode.
Public Types
-
enum State
state of the firenode
boolean for outputs
Values:
-
enumerator init
-
enumerator moving
-
enumerator merging
-
enumerator splitting
-
enumerator final
-
enumerator link
-
enumerator init
Public Functions
-
FireNode(FireDomain* = 0)
Default constructor.
-
virtual ~FireNode()
Destructor.
-
void initialize(FFPoint&, FFVector&, double&, double&, double = 0., FireDomain* = 0, FireFront* = 0, FireNode* = 0)
Object initialization.
-
double getSpeed()
Accessor to the rate of spread of the fire front
-
double getFrontDepth()
front depth getter
-
double getCurvature()
curvature getter
-
size_t getPosInFront()
Gives the position in the front relative to the current head
-
void setCurvature(double)
Mutator of the curvature of the front at the marker’s location
-
void setDomain(FireDomain*)
declaration of the containing ‘FireDomain’
-
void setFrontDepth(const double&)
front depth setter
-
void makeTrash()
trashing the node
-
virtual void timeAdvance()
computes the next ‘FireNode’ properties and the time of update. overloads ‘timeAdvance()’ from ‘ForeFireAtom’)
-
virtual void output()
Output function
-
void haloUpdate(FireNodeData*, FireDomain*)
updating the firenode if new information in the halo
-
virtual void accept(Visitor*)
Visitor function
-
void eraseTopology()
erasing topology of a firenode
-
void computeLocalFrontProperties()
computing the front properties at marker location
-
bool assertCompatibleTopology()
asserting that local topology is compatible with properties’ computation
-
double computeCurvature()
computing the curvature at marker location
-
void setSplitting()
split related procedures
-
virtual string toString()
print function
Public Static Functions
-
static void setCurvatureComputation(const int&)
booleans for the computation of the local and global interface properties
-
static void setSmoothing(double)
smoothing in the speed computation
-
static void setRelax(double)
relaxation in the speed computation
-
static void setMinSpeed(double)
minimum speed allowed
Public Static Attributes
-
static NormalScheme nmlScheme = FireNode::medians
normal scheme
-
static CurvatureScheme curvScheme = FireNode::circumradius
curvature scheme
-
enum State
Data Management
These classes are central to how ForeFire handles environmental and simulation data.
-
class DataBroker
Data Broker for a fire simulation.
DataBroker implements a data management tool tailored for FireDomain. Several layers of available data are stored and methods to communicate the desired values to the FireDomain are defined. The FireDomain has first registered the properties needed by the propagation model and DataBroker is responsible for accessing these values at given location and time. DataBroker also manages the storing of atmospheric properties (for coupled fire/atmopshere simulations) and parallel-related arrays (for parallel simulations).
Public Functions
-
DataBroker(FireDomain* = 0)
default constructor
-
virtual ~DataBroker()
destructor
-
void registerPropagationModel(PropagationModel*)
registering a propagation model
-
void registerFluxLayer(string, FluxLayer<double>*)
registering a flux layer in the data broker
-
void loadFromNCFile(string)
loadFromNCFile function for NetCDF files
-
void readTableFromAsciiFile(string, vector<map<string, double>>&)
reading a table from an ascii file
-
void readTableFromString(const std::string&, vector<map<string, double>>&)
reading a table from an sttring variable
-
void tokenize(const string&, vector<string>&, const string&)
splitting a string according to a delimiter
-
void setAtmosphericDomain(const FFPoint&, const FFPoint&, const size_t&, const size_t&)
initializing the atmospheric layers
-
void insureLayersExistence()
insuring the presence of all needed layers
-
void initFluxLayers(const double&)
initialize flux layers
-
void addConstantLayer(const string&, const string&, const string&, double, const FFPoint &S, const FFPoint&)
default constant layer constructor
-
DataLayer<double> *getLayer(const string&)
typical double layer constructor
accessor to the desired data layer
-
FluxLayer<double> *getFluxLayer(const string&)
accessor to the desired flux layer
-
void getPropagationData(PropagationModel*, FireNode*)
accessor to the desired set of properties for propagation models
-
DataBroker(FireDomain* = 0)
-
template<typename T>
class DataLayer Purely virtual template data layer object.
DataLayer implements common behavior for all data layers
Subclassed by libforefire::FluxLayer< double >, libforefire::PropagativeLayer< double >, libforefire::XYZTDataLayer< double >, libforefire::Array2DdataLayer< T >, libforefire::Array3DdataLayer< T >, libforefire::BurningMapLayer< T >, libforefire::BurningRatioLayer< T >, libforefire::FluxLayer< T >, libforefire::FuelDataLayer< T >, libforefire::GradientDataLayer< T >, libforefire::MultiplicativeLayer< T >, libforefire::PropagativeLayer< T >, libforefire::RosLayer< T >, libforefire::TimeGradientDataLayer< T >, libforefire::TwoTimeArrayLayer< T >, libforefire::WeatherDataLayer< T >, libforefire::XYZTDataLayer< T >
Public Functions
-
inline DataLayer()
Default constructor.
-
inline DataLayer(string name)
Constructor with key.
-
inline string getKey()
getter to the key of the layer
-
inline void setKey(string name)
setter of the key of the layer
-
virtual size_t getValuesAt(FireNode*, PropagationModel*, size_t) = 0
directly stores the desired values in a given array
-
virtual size_t getValuesAt(FFPoint, const double&, FluxModel*, size_t) = 0
directly stores the desired values in a given array
-
virtual void setMatrix(string&, double*, const size_t&, size_t&, const double&) = 0
stores data from a given array
-
virtual string print() = 0
print the related data
-
inline DataLayer()
Note
ForeFire provides various specializations of DataLayer (e.g., for 2D/3D arrays, NetCDF files, fuel properties, atmospheric data) to handle different data sources and types. Refer to the full Doxygen documentation for details on specific implementations like Array2DdataLayer, NCXYZTDataLayer, FuelDataLayer, etc.
Scientific Model Interfaces
These abstract base classes define how new scientific models for fire spread and flux calculations can be integrated.
-
class PropagationModel : public libforefire::ForeFireModel
Subclassed by libforefire::ANNPropagationModel, libforefire::BMapLoggerForANNTraining, libforefire::Balbi2015, libforefire::Balbi2020, libforefire::BalbiNov2011, libforefire::BalbiNov2011Curv, libforefire::BalbiNov2011TMdMl, libforefire::BalbiUnsteady, libforefire::CurvatureDrivenPropagationModel, libforefire::Farsite, libforefire::FrontDepthDrivenPropagationModel, libforefire::IsotropicFuelPropagationModel, libforefire::IsotropicIsospeed, libforefire::LavaPropagationModel, libforefire::Rothermel, libforefire::RothermelAndrews2018, libforefire::SamplePropagationModel, libforefire::TroisPourcent, libforefire::WindDrivenPropagationModel
-
class FluxModel : public libforefire::ForeFireModel
Subclassed by libforefire::BurnupHeatFluxModel, libforefire::CraterHeatFluxModel, libforefire::CraterVaporFluxModel, libforefire::FactorChemFluxModel, libforefire::ForeFireV1HeatFluxModel, libforefire::ForeFireV1VaporFluxModel, libforefire::HeatFluxBasicModel, libforefire::HeatFluxFromObsModel, libforefire::HeatFluxNominalModel, libforefire::LavaSO2FluxModel, libforefire::ScalarFluxNominalModel, libforefire::ScalarFromObsModel, libforefire::SpottingFluxBasicModel, libforefire::VaporFluxBasicModel, libforefire::VaporFluxFromObsModel, libforefire::VaporFluxNominalModel
User Interaction & Configuration
These components manage user commands and simulation parameters.
-
class Command
Commands for driving a ForeFire simulation (singleton class)
Command is a singleton class that defines the entry points for user-defined actions thus enabling driving a ForeFire simulation.
Public Static Functions
-
static void setReferenceTime(const double&)
setting the reference time
-
static void setStartTime(const double&)
setting the start time of the step of simulation
-
static double getTime()
getting the current time of simulation
-
static void increaseLevel()
managing the level
-
static FireDomain *getDomain()
accessor to the domain
-
static void setOstringstream(ostringstream*)
command to redirect the ostringstream
-
static void ExecuteCommand(string&)
execute the desired command
-
static string dumpString()
backup of the simulation
Public Static Attributes
-
static Session currentSession = {SimulationParameters::GetInstance(), 0, 0, 0, 0, 0, 0, 0, &cout, 0, 0,}
session containing all the data of the ForeFire simulation
-
static vector<string> outputDirs
vector of outputs directories
-
struct Session
-
static void setReferenceTime(const double&)
-
class SimulationParameters
Public Static Functions
-
static string FormatISODate(double secs, int year, int yday)
returns an ISO date string from secs, year and day of the year
-
static bool ISODateDecomposition(string date, double &secs, int &year, int &yday)
store into secs, year and yday respectively secs, year and day of the year from an ISO date string
-
static double SecsBetween(double t1, int y1, int yday1, double t2, int y2, int yday2)
returns the number of seconds between two dates
-
static string GetPath(string arg)
returns the correct absolute path from a relative or absolute path
-
static string FormatISODate(double secs, int year, int yday)
Fundamental Utilities
Basic geometric data types used throughout the simulation.
-
class FFPoint
3d points for LibForeFire
FFPoint defines 3d points and methods associated with it.
Public Functions
-
FFPoint()
Default constructor.
-
FFPoint(double, double, double)
3d Constructor
-
virtual ~FFPoint()
Destructor.
-
void setX(const double&)
mutator of the variable ‘x’
-
void setY(const double&)
mutator of the variable ‘y’
-
void setZ(const double&)
mutator of the variable ‘z’
-
void setLoc(const double&, const double&, const double& = 0)
mutator of the point itself
-
double &getX()
Accessor to ‘x’
-
double &getY()
Accessor to ‘y’
-
double &getZ()
Accessor to ‘z’
-
double norm()
norm of the point
- Returns:
norm of the point
-
double distance(FFPoint)
distance with another point
- Parameters:
'p' – [in] : other point
- Returns:
distance between the two points
-
double scalarProduct(FFPoint)
scalar product with another point
- Parameters:
'p' – [in] : other point
- Returns:
scalar product between the two vectors
-
FFPoint crossProduct(FFPoint)
cross product with another point
- Parameters:
'p' – [in] : other point
- Returns:
cross product of the two points
-
double angle2D(FFPoint)
2D angle with another point
- Parameters:
'p' – [in] : other point
- Returns:
angle between the two vectors
-
double signedDistanceToPolygon(size_t&, double*, double*, bool)
signed distance between a point and a polygon
-
double distanceToSegment(double&, double&, double&, double&)
distance between a point and a segment
-
double projectLat(double, double)
projetct a latitude value given a ref latitude (the one a 0.0) and a meters per lat
-
double projectLon(double, double)
projetct a latitude value given a ref latitude (the one a 0.0) and a meters per lon
-
bool pointInPolygon(size_t&, double*, double*)
Point in polygon algorithm.
-
string print()
printing function
-
FFPoint()
-
class FFVector
3d vectors for LibForeFire
FFPoint defines 3d vectors and methods associated with it.
Public Functions
-
FFVector()
Default constructor.
-
FFVector(double, double)
2d Constructor (vz=0.)
-
FFVector(double, double, double)
3d Constructor
-
virtual ~FFVector()
Destructor.
-
double getVx()
accessor to ‘vx’
-
double getVy()
accessor to ‘vy’
-
double getVz()
accessor to ‘vz’
-
void setVx(const double&)
mutator of the variable ‘vx’
-
void setVy(const double&)
mutator of the variable ‘vy’
-
void setVz(const double&)
mutator of the variable ‘vz’
-
void setVec(const double&, const double&, const double&)
mutator of the vector itself
-
double toAngle()
computing the angle in a spherical representation
-
double norm()
norm of the vector
- Returns:
norm of the vector
-
void normalize()
normalization of the vector
-
FFVector normed()
normalized version of the vector
- Returns:
a normalized vector with the same direction
-
double scalarProduct(const FFVector &vec)
scalar product with another vector
- Parameters:
'vec' – [in] : other vector
- Returns:
scalar product between the two vectors
-
FFVector crossProduct(const FFVector &vec)
vector product with another vector
- Parameters:
'vec' – [in] : other vector
- Returns:
vector product between the two vectors
-
string print()
printing function
-
FFVector()