C++ API Reference

This section will contain the C++ API reference, automatically generated from source code comments using Doxygen and Breathe.

Key C++ classes providing the core functionality of ForeFire include:

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 double&, FFPoint&, FFPoint&)

Constructor with boundaries and time.

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.

FDCell *getCell(FireNode*)

cell containing a firenode

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

void setBoundariesFront(FireFront*)

Mutators.

virtual void input()

input function (overloads ‘input()’ from ‘ForeFireAtom’)

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

DataLayer<double> *getDataLayer(const string&)

getting the layer associated with a property

FluxLayer<double> *getFluxLayer(const string&)

getting a specified flux layer

FireNode *getFireNodeByID(const long&)

searching a firenode by ID

virtual void accept(Visitor*)

visitor function

bool striclyWithinDomain(FFPoint&)

Test on the location.

bool isInInnerHalo(FireNode*)

Test to see if the firenode is in one of the halos.

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

bool isBurning(FFPoint&, const double&)

checking if a location is burning

double computeFrontDepth(FireNode*)

Computing the front depth a given firenode.

double getPropagationSpeed(FireNode*)

Computing the propagation speed of a given firenode.

double getModelValueAt(int&, FFPoint&, const double&, const double&, const double&)

Computing the propagation speed of a given firenode.

void addFireNodeInCell(FireNode*)

recycle/create a firenode

void removeFireNodeInCell(FireNode*)

finds the related cell and remove a given firenode to the list

void updateFireNodeInCells(FireNode*)

update the position of a given firenode in the cells

void hasMoved(FireNode*, FFPoint, double)

callback function from a firenode after it moved

void checkTopology(FireNode*)

callback function from a firenode to check the topology

void merge(FireNode*, FireNode*)

handling the merges in the domain

void relateLinkNodes(FireNode*, FireNode*)

relating two link nodes with respect to the frontiers

void addToTrashNodes(FireNode*)

managing the trash of the simulation

FireNode *FireNodeFactory()

creating new atoms in the domain

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 firenodeBurningScan(FireNode*)

local scanning around a firenode for burning matrix

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

void areaBurningScan(FFPoint&, FFPoint&, double)

scanning a region with respect to all fire fronts

std::vector<std::vector<double>> getDataMatrix(const std::string&)

retrun a diag matrix

bool checkForBurningStatus(FFPoint&)

checking the burning status of a given location

Public Members

FFPoint SWLngLat

SouthWest Corner of the mesh

FFPoint NELngLat

NorthEast Corner of the mesh

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

static const FFPoint outPoint = FFPoint(numeric_limits<double>::infinity(), numeric_limits<double>::infinity(), 0)

finding the intersection between a segment and the frontier

struct CellData
struct DistributedDomainBCellList
struct distributedDomainInfo
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
enum NormalScheme

normal scheme

Values:

enumerator medians
enumerator weightedMedians
enumerator spline
enum CurvatureScheme

curvature scheme

Values:

enumerator circumradius
enumerator angle

Public Functions

FireNode(FireDomain* = 0)

Default constructor.

virtual ~FireNode()

Destructor.

FFPoint getLoc()

Accessors to the location of the FireNode

void initialize(FFPoint&, FFVector&, double&, double&, double = 0., FireDomain* = 0, FireFront* = 0, FireNode* = 0)

Object initialization.

FFPoint getNextLoc()

Accessor to the next location of the FireNode

FFVector getVel()

Accessors to the velocity of the FireNode

FFVector getNormal()

Accessor to the local normal to the front

double getSpeed()

Accessor to the rate of spread of the fire front

FireFront *getFront()

Accessor to the fire front

FireFront *getContFront()

Accessor to the upper fire front

State getState()

Accessor to the state of the firenode

string getStateString(State)

string value of the state

FireNode *getNext()

Accessor to next FireNode in the fire front

FireNode *getPrev()

Accessor to previous FireNode in 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 setState(State)

mutator of the state of the firenode

void setNext(FireNode*)

mutator of the pointer to the next FireNode

void setPrev(FireNode*)

mutator of the pointer to the previous FireNode

void setLoc(FFPoint&)

Mutator of the location of the FireNode

void setNextLoc(FFPoint&)

Mutator of the next location of the FireNode

void setVel(FFVector)

Mutator of the velocity of the FireNode

void setCurvature(double)

Mutator of the curvature of the front at the marker’s location

void setMergingNode(FireNode*)

Mutator of the merging node

void setDomain(FireDomain*)

declaration of the containing ‘FireDomain

void setFront(FireFront*)

declaration of the ‘FireFront

void setFrontDepth(const double&)

front depth setter

void makeTrash()

trashing the node

virtual void input()

input function (overloads ‘input()’ from ‘ForeFireAtom’)

virtual void update()

updates the ‘FireNode’ properties (overloads ‘update()’ from ‘ForeFireAtom’)

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 insertBefore(FireNode*)

inserting a firenode relative to an another one

void eraseTopology()

erasing topology of a firenode

bool isInList(const list<FireNode*>&)

testing membership of a list

void computeLocalFrontProperties()

computing the front properties at marker location

bool assertCompatibleTopology()

asserting that local topology is compatible with properties’ computation

FFVector computeNormal()

computing the normal at marker location

double computeCurvature()

computing the curvature at marker location

void setSplitting()

split related procedures

void setMerging(FireNode*)

checking if a firenode can merge with another one

double distance(FireNode*)

distance functions to another firenode

FFPoint locAtTime(double)

approximated location at a given time

virtual string toString()

print function

Public Members

State currentState

current state of the firenode

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

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.

FireFront *getContFront()

Accesssor to the containing firefront.

void setContFront(FireFront*)

Mutator of the containing firefront.

FireNode *getHead()

Accesssor to the head FireNode.

void setHead(FireNode*)

Mutator of the head FireNode.

Mutators of the inner fronts

virtual void input()

input function (overloads ‘input()’ from ‘ForeFireAtom’)

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.

void initialize(double, FireFront*)

Initialize function.

bool isExpanding()

behavior of th firefront

double getArea()

Area of the front.

size_t getNumFN(FireNode*)

accessor to the number of firenodes in the firefront

size_t getPositionInFront(FireNode*)

getter of the position of a firenode in the front

int getNumInnerFronts()

getter of the number of inner fronts

void splineInterp(FireNode*, FFVector&, double&)

spline interpolation of the firefront

void addFireNode(FireNode*, FireNode* = 0)

adding a firenode in the firefront

void dropFireNode(FireNode*)

erasing a firenode from the firefront

bool contains(FireNode*)

test to see if a marker belongs to this front

void extend()

extending the firefront in one direction

void split(FireNode*, const double&)

handling the possible splits in the firefront

void merge(FireNode*, FireNode*)

handling the possible merges in the firefront

void storeVertices(double*, double*, size_t&)

constructing arrays storing the coordinates of the vertices constituting the front

bool checkForBurningStatus(FFPoint&)

checking the burning status of a given location

void computeBoundingBox(FFPoint&, FFPoint&)

computes a rectangle containing the entire front

void increaseNumFN()

managing the number of firenodes in the front

void makeTrash()

making the front a trash one

virtual string toString()

print function

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 registerFluxModel(FluxModel*)

registering a flux model

void registerLayer(string, DataLayer<double>*)

registering a layer in the data broker

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 computeActiveSurfacesFlux(const double&)

recomputes flux actives surfaces for each model

void getPropagationData(PropagationModel*, FireNode*)

accessor to the desired set of properties for propagation models

void getFluxData(FluxModel*, FFPoint&, const double&)

accessor to the desired set of properties for flux models

void getMatrix(string, const FFPoint&, const FFPoint&, const double&, FFArray<double>**)

accessor to the data contained in the desired layer

Public Static Attributes

static FluxLayer<double> *heatFluxLayer = 0

predefined layer for heat flux

static XYZTDataLayer<double> *PwindULayer = 0

predefined layer for longitudinal wind (optimization)

static XYZTDataLayer<double> *PwindVLayer = 0

predefined layer for lateral wind (optimization)

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 T getValueAt(FireNode*) = 0

computes the value at a given firenode

virtual T getValueAt(FFPoint, const double&) = 0

computes the value at a given location and time

virtual void setValueAt(FFPoint, double, T) = 0

set the value at a given location and time

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 getMatrix(FFArray<T>**, const double&) = 0

getter to the desired data

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

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 Functions

Command()

Default constructor.

virtual ~Command()

Destructor.

Public Static Functions

static inline Command &instance()

getter of the singleton

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 void completeFront(FireFront*)

complete the last front

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
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

class Simulator

Class providing control over the simulation.

The ‘Simulator’ class provides methods in order to search through a ‘schedule’ (’TimeTable’ object) and treating events of the simulation one after the other

Public Functions

Simulator()

Default constructor.

Simulator(TimeTable*, bool = false)

Constructor provided a ‘TimeTable’.

virtual ~Simulator()

Default destructor.

void goTo(const double&)

Advancing the simulation of the prescribed step.

void treatNextEvent()

treating the next event and updating the ‘schedule’