forked from forefireAPI/firefront
-
Notifications
You must be signed in to change notification settings - Fork 0
/
FireNode.h
312 lines (248 loc) · 9.13 KB
/
FireNode.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
/*
Copyright (C) 2012 ForeFire Team, SPE, UniversitŽ de Corse.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 US
*/
#ifndef FIRENODE_H_
#define FIRENODE_H_
#include "FFPoint.h"
#include "FFVector.h"
#include "ForeFireAtom.h"
#include "Visitable.h"
#include "FFConstants.h"
#include "SimulationParameters.h"
#include "Futils.h"
using namespace std;
namespace libforefire{
class FireDomain;
class FireFront;
class FireNodeData;
/*! \class FireNode
* \brief 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.
*/
class FireNode : public ForeFireAtom, Visitable {
static const double Pi;
static SimulationParameters* params;
FFPoint location; /*!< location of the FireNode */
FFVector velocity; /*!< velocity of the fire node */
FFVector normal; /*!< local normal to the fire front at marker location */
double speed; /*!< rate of spread of the fire front at marker location */
double frontDepth; /*!< depth of the fire front at marker location */
double curvature; /*!< curvature of the fire front at marker location */
FFPoint nextloc; /*!< next location of the FireNode */
FireDomain* domain; /*!< FireDomain where the FireNode evolves */
FireFront* front; /*!< front containing the firenode */
FireNode* nextInFront; /*!< pointer to the next FireNode in the FireFront */
FireNode* previousInFront; /*!< pointer to the previous FireNode in the FireFront */
FireNode* mergingNode; /*!< pointer to the firnode to be merged with */
static const string altitude; /*!< string shortcut for altitude */
static const string slope; /*!< string shortcut for slope */
static bool fdepth; /*!< boolean for the computation of the front depth */
static bool ccurvature; /*!< boolean for the computation of the curvature */
static double smoothing; /*!< spatial smoothing for the velocity */
static double relax; /*!< relaxation for the velocity */
static double minSpeed; /*!< minimum speed allowed */
static double minFrontDepth;
public:
static bool outputs; /*! boolean for outputs */
/*! \brief state of the firenode */
enum State {
init = 0,
moving = 1,
merging = 2,
splitting = 3,
final = 4,
link = 5
} ;
State currentState; /*!< current state of the firenode */
// Definition of the state aliases
typedef map<string,State> stringToState;
typedef map<State,string> stateToString;
/* A map of the strings to their State equivalent, and inverse one */
static stringToState createStateMap(){
stringToState m;
m["init"] = init;
m["moving"] = moving;
m["splitting"] = splitting;
m["merging"] = merging;
m["final"] = final;
m["link"] = link;
return m;
}
static stateToString createStringMap(){
stateToString m;
m[init] = "init";
m[moving] = "moving";
m[splitting] = "splitting";
m[merging] = "merging";
m[final] = "final";
m[link] = "link";
return m;
}
static const stringToState strtost;
stringToState::const_iterator istrtost;
static const stateToString sttostr;
stateToString::const_iterator isttostr;
/*! \brief normal scheme */
enum NormalScheme {
medians = 0,
weightedMedians = 1,
spline = 2
} ;
static NormalScheme nmlScheme; /*!< normal scheme */
static void setNormalScheme(string);
/*! \brief curvature scheme */
enum CurvatureScheme {
circumradius = 0,
angle = 1
} ;
static CurvatureScheme curvScheme; /*!< curvature scheme */
static void setCurvatureScheme(string);
/*! \brief booleans for the computation of
* the local and global interface properties */
static void setCurvatureComputation(const int&);
static void setFrontDepthComputation(const int&);
/*! \brief smoothing in the speed computation */
static void setSmoothing(double);
static void setMinDepth(double);
/*! \brief relaxation in the speed computation */
static void setRelax(double);
/*! \brief minimum speed allowed */
static void setMinSpeed(double);
/*! \brief Default constructor */
FireNode(FireDomain* = 0);
/*! \brief Destructor */
virtual ~FireNode();
/*! \brief Accessors to the location of the FireNode */
FFPoint getLoc();
double getX();
double getY();
double getZ();
/*! \brief Object initialization */
void initialize(FFPoint&, FFVector&, double&, double&, double = 0.
, FireDomain* = 0, FireFront* = 0, FireNode* = 0);
void initialize(FireNodeData*, FireDomain*
, FireFront* = 0, FireNode* = 0);
/*! \brief Accessor to the next location of the FireNode */
FFPoint getNextLoc();
/*! \brief Accessors to the velocity of the FireNode */
FFVector getVel();
double getVx();
double getVy();
double getVz();
/*! \brief Accessor to the local normal to the front */
FFVector getNormal();
/*! \brief Accessor to the rate of spread of the fire front */
double getSpeed();
/*! \brief Accessor to the fire front */
FireFront* getFront();
/*! \brief Accessor to the upper fire front */
FireFront* getContFront();
/*! \brief Accessor to the state of the firenode */
State getState();
/*! \brief string value of the state */
string getStateString(State);
/*! \brief Accessor to next FireNode in the fire front */
FireNode* getNext();
/*! \brief Accessor to previous FireNode in the fire front */
FireNode* getPrev();
/*! \brief front depth getter */
double getFrontDepth();
/*! \brief curvature getter */
double getCurvature();
/*! \brief Gives the position in the front relative to the current head */
size_t getPosInFront();
/*! \brief mutator of the state of the firenode */
void setState(State);
/*! \brief mutator of the pointer to the next FireNode */
void setNext(FireNode*);
/*! \brief mutator of the pointer to the previous FireNode */
void setPrev(FireNode*);
/*! \brief Mutator of the location of the FireNode */
void setLoc(FFPoint&);
/*! \brief Mutator of the next location of the FireNode */
void setNextLoc(FFPoint&);
/*! \brief Mutator of the velocity of the FireNode */
void setVel(FFVector);
/*! \brief Mutator of the curvature of the front at the marker's location */
void setCurvature(double);
/*! \brief Mutator of the merging node */
void setMergingNode(FireNode*);
/*! \brief declaration of the containing 'FireDomain' */
void setDomain(FireDomain*);
/*! \brief declaration of the 'FireFront' */
void setFront(FireFront*);
/*! \brief front depth setter */
void setFrontDepth(const double&);
/*! \brief trashing the node */
void makeTrash();
/*! input function (overloads 'input()' from 'ForeFireAtom') */
void input();
/*! updates the 'FireNode' properties
* (overloads 'update()' from 'ForeFireAtom') */
void update();
/*! computes the next 'FireNode' properties
* and the time of update.
* overloads 'timeAdvance()' from 'ForeFireAtom') */
void timeAdvance();
/*! Output function */
void output();
/*! updating the firenode if new information in the halo */
void haloUpdate(FireNodeData*, FireDomain*);
/*! Visitor function */
void accept(Visitor *);
/*! inserting a firenode relative to an another one */
void insertBefore(FireNode*);
void insertAfter(FireNode*);
/*! erasing topology of a firenode */
void eraseTopology();
/*! testing membership of a list */
bool isInList(const list<FireNode*>&);
/*! \brief computing the front properties at marker location */
void computeLocalFrontProperties();
/*! \brief asserting that local topology is compatible with properties' computation */
bool assertCompatibleTopology();
/*! \brief computing the normal at marker location */
FFVector computeNormal();
/*! \brief computing the curvature at marker location */
double computeCurvature();
/*! \brief split related procedures */
void setSplitting();
bool isSplitting();
bool splitAllowed();
/*! \brief checking if a firenode can merge with another one */
void setMerging(FireNode*);
bool isMerging();
bool mergeAllowed();
/*! \brief distance functions to another firenode */
double distance(FireNode*);
double distance(FFPoint);
double distance2D(FireNode*);
double distance2D(FFPoint);
double getLowestNearby(double );
/*! \brief approximated location at a given time */
FFPoint locAtTime(double);
string toString();
string toShort();
};
}
#endif /* FIRENODE_H_ */