forked from forefireAPI/firefront
-
Notifications
You must be signed in to change notification settings - Fork 0
/
GradientDataLayer.h
130 lines (101 loc) · 4.03 KB
/
GradientDataLayer.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
/*
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 GRADIENTDATALAYER_H_
#define GRADIENTDATALAYER_H_
#include "DataLayer.h"
#include "FireNode.h"
#include "SimulationParameters.h"
using namespace std;
namespace libforefire {
/*! \class GradientDataLayer
* \brief Implicit data layer for having a view on the gradient of a given data layer
*
* GradientDataLayer implements an implicit data layer (no data stored) to compute
* at a given location, and for a given directions, the gradient of a given "parent" property.
*/
template<typename T> class GradientDataLayer: public DataLayer<T> {
DataLayer<T>* parent; /*!< pointer to the data layer for the parent property */
double dx; /*!< spatial increment for the calculation of the gradient */
public:
/*! \brief Default constructor */
GradientDataLayer() : DataLayer<T>() {};
/*! \brief Constructor with all necessary information */
GradientDataLayer(string name, DataLayer<T>* primary, const double ddx)
: DataLayer<T>(name), parent(primary), dx(ddx) {
// nothing more to do
}
/*! \brief Destructor */
~GradientDataLayer(){};
/*! \brief computes the value at a given firenode */
T getValueAt(FireNode*);
/*! \brief computes the value at a given location and time */
T getValueAt(FFPoint, const double&);
/*! \brief directly stores the desired values in a given array */
size_t getValuesAt(FireNode*, PropagationModel*, size_t);
/*! \brief directly stores the desired values in a given array */
size_t getValuesAt(FFPoint, const double&, FluxModel*, size_t);
/*! \brief getter to the desired data (should not be used) */
void getMatrix(FFArray<T>**, const double&);
/*! \brief stores data from a given array (should not be used) */
void setMatrix(string&, double*, const size_t&, size_t&, const double&);
/*! \brief print the related data (should not be used) */
string print();
void dumpAsBinary(string, const double&
, FFPoint&, FFPoint&, size_t&, size_t&);
};
template<typename T>
T GradientDataLayer<T>::getValueAt(FireNode* fn){
/* Computing the gradient between the next and present location */
T currentValue = parent->getValueAt(fn);
T nextValue;
FFPoint nextLoc = fn->getLoc() + dx*(fn->getNormal().toPoint());
nextValue = parent->getValueAt(nextLoc,fn->getUpdateTime());
return (nextValue - currentValue)/dx;
}
template<typename T>
T GradientDataLayer<T>::getValueAt(FFPoint loc, const double& time){
cout << "this call shouln't be used in a gradient layer" << endl;
return 0.;
}
template<typename T>
size_t GradientDataLayer<T>::getValuesAt(FireNode* fn
, PropagationModel* model, size_t curItem){
return 0;
}
template<typename T>
size_t GradientDataLayer<T>::getValuesAt(FFPoint loc, const double& t
, FluxModel* model, size_t curItem){
return 0;
}
template<typename T>
void GradientDataLayer<T>::getMatrix(
FFArray<T>** matrix, const double& time){
}
template<typename T>
void GradientDataLayer<T>::setMatrix(string& mname, double* inMatrix
, const size_t& sizein, size_t& sizeout, const double& time){
// writing the incoming data in matrix
// should not be done with this type of layer
}
template<typename T>
string GradientDataLayer<T>::print(){
return "";
}
template<typename T>
void GradientDataLayer<T>::dumpAsBinary(string filename, const double& time
, FFPoint& SWC, FFPoint& NEC, size_t& nnx, size_t& nny){
}
}
#endif /* GRADIENTDATALAYER_H_ */