BG_Flood  0.1
Documentation (Work-in-progress)
Forcing.h
Go to the documentation of this file.
1 
2 #ifndef FORCING_H
3 #define FORCING_H
4 
5 #include "General.h"
6 #include "Input.h"
7 
8 struct TexSetP
9 {
10  float xo, yo, dx, dy; // used to calculate coordinates insode the device function
11  float nowvalue;
12  bool uniform;
13  cudaArray* CudArr;
14  cudaChannelFormatDesc channelDesc = cudaCreateChannelDesc(32, 0, 0, 0, cudaChannelFormatKindFloat);
15  //texture<float, 2, cudaReadModeElementType> tex;
16  struct cudaResourceDesc resDesc;
17  struct cudaTextureDesc texDesc;
18  cudaTextureObject_t tex = 0;
19 };
20 
21 struct bndTexP
22 {
26 };
27 
28 class forcingmap : public inputmap {
29 public:
30 
31  int nt;
32  bool uniform = false;
33  double to, tmax;
34  double dt;
35  int instep = 0; // last step that was read
36  std::string inputfile;
37  std::vector<Windin> unidata; // only used if uniform forcing
38  double nowvalue; // temporary storage for value at a given time
40 
41 };
42 
43 template <class T>
44 class deformmap : public inputmap
45 {
46  //Deform are maps to applie to both zs and zb; this is often co-seismic vertical deformation used to generate tsunami initial wave
47  // Here you can spread the deformation across a certain amount of time and apply it at any point in the model
48 public:
49  double startime = 0.0;
50  double duration = 0.0;
51  bool iscavity = false;
52  T* val;
53 
54  T clampedge = 0.0;
56 };
57 
58 
59 template <class T>
60 struct DynForcingP: public forcingmap
61 {
62  T *now;
63  T *before, *after;
64  T* val; // useful for reading from file
65 
66  // gpu version of these array
67  T* now_g;
69 
70  T clampedge=0.0;
71 
72 };
73 
74 
75 
76 
77 
78 template <class T>
79 struct StaticForcingP : public inputmap
80 {
81  T *val;
82 
83 };
84 
85 //bnd
86 class bndparam {
87 public:
88  std::vector<SLTS> data;
89  bool on = false;
90  //If changing this default value, please change documentation later on the file
91  int type = 1; // 0:Wall (no slip); 1:neumann (zeros gradient) [Default]; 2:sealevel dirichlet; 3: Absorbing 1D 4: Absorbing 2D (not yet implemented)
92  std::string inputfile;
93  int nbnd; // number of forcing bnds along the side (>=1 is side is on)
94  int nblk = 0; //number of blocks where this bnd applies
95  int side = 0; // 0: top bnd, 1: rightbnd, 2: bot bnd, 3, Left bnd
96  int isright = 0;
97  int istop = 0;
99  int* blks; // array of block where bnd applies
100  int* blks_g; // Also needed for GPU (because it should be a gpu allocated pointer) This is not pretty at all! In the future maybe using pagelocked memory or other new type may be beneficial
101  float* qmean;
102  float* qmean_g;
103 };
104 
106 public:
107  int nblk=0;
108  int* blk;
109  int* blk_g;
110  float* qmean;
111  float* qmean_g;
112  int isright = 0;
113  int istop = 0;
114  // 8 digit binary where 1 is a mask and 0 is not a mask with the first digit represent the left bottom side the rest is clockwise (i.e.left-bot left-top, top-left, top-right, right-top, right-bot, bot-right, bot-left)
115  //int* side; // e.g. 11000000 for the entire left side being a mask
116 };
117 
118 
119 class bndsegment {
120 public:
121  std::vector<Windin> data;
122  std::string inputfile;
124  std::string polyfile;
125  bool on = false;
126  bool uniform = true;
127  //If changing this default value, please change documentation later on the file
128  int type = 1; // 0:Wall (no slip); 1:neumann (zeros gradient) [Default]; 2:sealevel dirichlet; 3: Absorbing 1D 4: Absorbing 2D (not yet implemented)
129 
130  int nbnd; // number of forcing bnds along the side (>=1 is side is on)
131  int nblk = 0; //number of blocks where this bnd applies
132 
133 
134 
135 
137 
142 
143 };
144 
145 
146 class AOIinfo {
147 public:
148  std::string file;
150  bool active=false;
151 };
152 
153 
154 template <class T>
155 struct Forcing
156 {
159  //Forcing the Wind;
160  /*Spacially varying: 2 files are given, 1st file is U wind and second is V wind ( no rotation of the data is performed)
161  Spacially uniform: 1 file is given then a 3 column file is expected, showing time, windspeed and direction.
162  Wind direction is rotated (later) to the grid direction (using grdalpha input parameter)
163  Ex: Wind = mywind.nc?uw,mywind.nc?vw
164  Ex: Wind = MyWind.txt
165  Default: None
166  */
167 
168 
170  /* This allow to force a time varying, space varying rain intensity on the model, in mm/h.
171  Spacially varrying (rain map), a netcdf file is expected (with the variable associated to the rain after "?").
172  Spacially uniform: the rain is forced using a time serie using a 2 column values table containing time (not necessary unformly distributed) and rain.
173  Ex: rain=rain_forcing.txt
174  Ex: rain=rain_forcing.nc?RainIntensity
175  Default: None
176  */
177 
179  /* The forcing pressure is expected to be in Pa and the effect of the atmospheric pressure gradient is calculated as the difference to a reference pressure Paref, converted to a height using Pa2.
180  Ex: Atmp=AtmosphericPressure.nc?p
181  Default: None
182  */
183 
184 
185  std::vector<StaticForcingP<T>> Bathy; //Should be a vector at some point
186  /* Bathymetry/Topography input, ONLY NECESSARY INPUT
187  Different format are accepted: .asc, .nc, .md. , the grid must be regular with growing coordinate.
188  This grid will define the extend of the model domain and model resolution (if not inform by the user).
189  The coordinate can be cartesian or spherical (still in development).
190  A list of file can also be use to provide a thiner resolution localy by using the key word each time on a different line.
191  The first file will be use to define the domain area and base resolution but the following file
192  will be used during the refinement process.
193  Ex: bathy=Westport_DEM_2020.nc?z
194  Ex: topo=Westport_DEM_2020.asc
195  Default: None but input NECESSARY
196  */
197 
198  std::vector<StaticForcingP<T>> cf;
199  /*Bottom friction coefficient map (associated to the chosen bottom friction model)
200  A list of roughness map can be provide. At any grid point, the last one defined will be used.
201  Ex: cf=0.001;
202  Ex: cf=bottom_friction.nc?bfc;
203  Default: (see constant in parameters)
204  */
205 
207  /*Initial Rain loss coefficient map (in mm)
208  Ex: il=rain_loss.nc?initial_loss;
209  Default: (see constant in parameters)
210  */
211 
213  /*Continuous Rain loss coefficient map (in mm/h)
214  Ex: cl=rain_loss.nc?continuous_loss;
215  Default: (see constant in parameters)
216  */
217 
218  std::vector<StaticForcingP<int>> targetadapt;
219 
220  std::vector<deformmap<T>> deform;
221  /*Deform are maps to apply to both zs and zb; this is often co-seismic vertical deformation used to generate tsunami initial wave
222  Here you can spread the deformation across a certain amount of time and apply it at any point in the model.
223  Ex: deform = myDeform.nc?z_def,3.0,10.0;
224  Ex: deform = *filename*, *time of initial rupture*, *rising time*;
225  Default: None
226  */
227 
228 
229  std::vector<River> rivers;
230  /*The river is added as a vertical discharge on a chosen area (the user input consisting in a Time serie and a rectangular area definition).
231  The whole cells containing the corners of the area will be included in the area, no horizontal velocity is applied.
232  To add multiple rivers, just add different lines in the input file (one by river).
233  Ex: river = Votualevu_R.txt,1867430,1867455,3914065,3914090;
234  Ex: river = *Fluxfile*, *xstart*, *xend*, *ystart*, *yend*;
235  Default: None
236  */
237 
239  /* 0:Wall (no slip); 1:neumann (zeros gradient) [Default]; 2:sealevel dirichlet; 3: Absorbing 1D 4: Absorbing 2D (not yet implemented)
240  For type 2 and 3 boundary, a file need to be added to determine the vaules at the boundary. This file will consist in a first column containing time (with possibly variable time steps) and forcing values in the following columns (1 column of values corresponding to a constant value along the boundary, 2 columns correspond to values at boundary edges with linear evolution in between, n columns correspond to n regularly spaced values applied along the boundary)
241  Ex: left = 0;
242  Ex: left = leftBnd.txt,2;
243  Default: 1
244  */
245 
247  /*Same as left boundary
248  Ex: right = 0;
249  Ex: right = rightBnd.txt,2;
250  Default: 1
251  */
252 
254  /*Same as left boundary
255  Ex: top = 0;
256  Ex: top = topBnd.txt,2;
257  Default: 1
258  */
259 
261  /*Same as left boundary
262  Ex: bot = 0;
263  Ex: bot = botBnd.txt,2;
264  Default: 1
265  */
266 
267 
268  std::vector<bndsegment> bndseg;
269  /* boundary segment; Only applies to AOI bnds
270  Ex: bndseg=area.txt,waterlevelforcing,1;
271  Default: none
272  */
273 
275  /*Area of interest polygon
276  Ex: AOI=myarea.gmt;
277  the input file is a text file with 2 columns containing the coordinate of a closed polygon (last line==first line)
278  Default: N/A
279  */
280 
281 };
282 
283 
284 
285 
286 
287 
288 
289 
290 
291 
292 
293 // End of global definition
294 #endif
Definition: Forcing.h:146
bool active
Definition: Forcing.h:150
std::string file
Definition: Forcing.h:148
Polygon poly
Definition: Forcing.h:149
Definition: Input.h:96
Definition: Forcing.h:86
std::vector< SLTS > data
Definition: Forcing.h:88
int * blks
Definition: Forcing.h:99
float * qmean
Definition: Forcing.h:101
bndTexP GPU
Definition: Forcing.h:98
int istop
Definition: Forcing.h:97
int isright
Definition: Forcing.h:96
int side
Definition: Forcing.h:95
int * blks_g
Definition: Forcing.h:100
std::string inputfile
Definition: Forcing.h:92
int nbnd
Definition: Forcing.h:93
float * qmean_g
Definition: Forcing.h:102
int nblk
Definition: Forcing.h:94
int type
Definition: Forcing.h:91
bool on
Definition: Forcing.h:89
Definition: Forcing.h:119
bndsegmentside right
Definition: Forcing.h:139
bndsegmentside top
Definition: Forcing.h:140
std::vector< Windin > data
Definition: Forcing.h:121
bool uniform
Definition: Forcing.h:126
Polygon poly
Definition: Forcing.h:123
int type
Definition: Forcing.h:128
DynForcingP< float > WLmap
Definition: Forcing.h:136
bndsegmentside bot
Definition: Forcing.h:141
std::string inputfile
Definition: Forcing.h:122
std::string polyfile
Definition: Forcing.h:124
bool on
Definition: Forcing.h:125
bndsegmentside left
Definition: Forcing.h:138
int nblk
Definition: Forcing.h:131
int nbnd
Definition: Forcing.h:130
Definition: Forcing.h:105
int nblk
Definition: Forcing.h:107
int isright
Definition: Forcing.h:112
float * qmean
Definition: Forcing.h:110
int * blk
Definition: Forcing.h:108
float * qmean_g
Definition: Forcing.h:111
int * blk_g
Definition: Forcing.h:109
int istop
Definition: Forcing.h:113
Definition: Forcing.h:45
bool iscavity
Definition: Forcing.h:51
T * val
Definition: Forcing.h:52
TexSetP GPU
Definition: Forcing.h:55
T clampedge
Definition: Forcing.h:54
double startime
Definition: Forcing.h:49
double duration
Definition: Forcing.h:50
Definition: Forcing.h:28
double to
Definition: Forcing.h:33
std::vector< Windin > unidata
Definition: Forcing.h:37
TexSetP GPU
Definition: Forcing.h:39
double tmax
Definition: Forcing.h:33
double dt
Definition: Forcing.h:34
std::string inputfile
Definition: Forcing.h:36
double nowvalue
Definition: Forcing.h:38
bool uniform
Definition: Forcing.h:32
int instep
Definition: Forcing.h:35
int nt
Definition: Forcing.h:31
Definition: Input.h:45
Definition: Forcing.h:61
T * val
Definition: Forcing.h:64
T * before
Definition: Forcing.h:63
T * before_g
Definition: Forcing.h:68
T * after
Definition: Forcing.h:63
T * now
Definition: Forcing.h:62
T * now_g
Definition: Forcing.h:67
T * after_g
Definition: Forcing.h:68
T clampedge
Definition: Forcing.h:70
Definition: Forcing.h:156
std::vector< StaticForcingP< T > > cf
Definition: Forcing.h:198
DynForcingP< T > VWind
Definition: Forcing.h:158
StaticForcingP< T > cl
Definition: Forcing.h:212
std::vector< deformmap< T > > deform
Definition: Forcing.h:220
AOIinfo AOI
Definition: Forcing.h:274
DynForcingP< T > Rain
Definition: Forcing.h:169
DynForcingP< T > Atmp
Definition: Forcing.h:178
std::vector< bndsegment > bndseg
Definition: Forcing.h:268
std::vector< StaticForcingP< T > > Bathy
Definition: Forcing.h:185
bndparam left
Definition: Forcing.h:238
std::vector< StaticForcingP< int > > targetadapt
Definition: Forcing.h:218
bndparam right
Definition: Forcing.h:246
DynForcingP< T > UWind
Definition: Forcing.h:157
StaticForcingP< T > il
Definition: Forcing.h:206
std::vector< River > rivers
Definition: Forcing.h:229
bndparam top
Definition: Forcing.h:253
bndparam bot
Definition: Forcing.h:260
Definition: Forcing.h:80
T * val
Definition: Forcing.h:81
Definition: Forcing.h:9
struct cudaResourceDesc resDesc
Definition: Forcing.h:16
cudaArray * CudArr
Definition: Forcing.h:13
float nowvalue
Definition: Forcing.h:11
cudaChannelFormatDesc channelDesc
Definition: Forcing.h:14
float xo
Definition: Forcing.h:10
struct cudaTextureDesc texDesc
Definition: Forcing.h:17
cudaTextureObject_t tex
Definition: Forcing.h:18
float dy
Definition: Forcing.h:10
bool uniform
Definition: Forcing.h:12
float yo
Definition: Forcing.h:10
float dx
Definition: Forcing.h:10
Definition: Forcing.h:22
TexSetP Uvel
Definition: Forcing.h:24
TexSetP WLS
Definition: Forcing.h:23
TexSetP Vvel
Definition: Forcing.h:25