BG_Flood  0.8
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  // To modify only zs, use the same structure with the key word "cavity"
49 public:
50  double startime = 0.0;
51  double duration = 0.0;
52  bool iscavity = false;
53  T* val;
54 
55  T clampedge = 0.0;
57 };
58 
59 
60 template <class T>
61 struct DynForcingP: public forcingmap
62 {
63  T *now;
64  T *before, *after;
65  T* val; // useful for reading from file
66 
67  // gpu version of these array
68  T* now_g;
70 
71  T clampedge=0.0;
72 
73 };
74 
75 
76 
77 
78 
79 template <class T>
80 struct StaticForcingP : public inputmap
81 {
82  T *val;
83 
84 };
85 
86 //bnd
87 class bndparam {
88 public:
89  std::vector<SLTS> data;
90  bool on = false;
91  //If changing this default value, please change documentation later on the file
92  int type = 1; // 0:Wall (no slip); 1:neumann (zeros gradient) [Default]; 2:sealevel dirichlet; 3: Absorbing 1D 4: Absorbing 2D (not yet implemented)
93  std::string inputfile;
94  int nbnd; // number of forcing bnds along the side (>=1 is side is on)
95  int nblk = 0; //number of blocks where this bnd applies
96  int side = 0; // 0: top bnd, 1: rightbnd, 2: bot bnd, 3, Left bnd
97  int isright = 0;
98  int istop = 0;
100  int* blks; // array of block where bnd applies
101  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
102  float* qmean;
103  float* qmean_g;
104 };
105 
107 public:
108  int nblk=0;
109  int* blk;
110  int* blk_g;
111  float* qmean;
112  float* qmean_g;
113  int isright = 0;
114  int istop = 0;
115  // 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)
116  //int* side; // e.g. 11000000 for the entire left side being a mask
117 };
118 
119 
120 class bndsegment {
121 public:
122  std::vector<Windin> data;
123  std::string inputfile;
125  std::string polyfile;
126  bool on = false;
127  bool uniform = true;
128  //If changing this default value, please change documentation later on the file
129  int type = 1; // 0:Wall (no slip); 1:neumann (zeros gradient) [Default]; 2:sealevel dirichlet; 3: Absorbing 1D 4: Absorbing 2D (not yet implemented)
130 
131  int nbnd; // number of forcing bnds along the side (>=1 is side is on)
132  int nblk = 0; //number of blocks where this bnd applies
133 
134 
135 
136 
138 
143 
144 };
145 
146 
147 class AOIinfo {
148 public:
149  std::string file;
151  bool active=false;
152 };
153 
154 
155 template <class T>
156 struct Forcing
157 {
160  //Forcing the Wind;
161  /*Spacially varying (.nc): 2 files are given, 1st file is U wind and second is V wind (no rotation of the data is performed)
162  Spacially uniform (.txt): 1 file is given then a 3 column file is expected, showing time, windspeed and direction.
163  Wind direction is rotated (later) to the grid direction (using grdalpha input parameter)
164  Ex: Wind = mywind.nc?uw,mywind.nc?vw
165  Ex: Wind = MyWind.txt
166  Default: None
167  */
168 
169 
171  /* This allow to force a time varying, space varying rain intensity on the model, in mm/h.
172  Spacially varrying (rain map), a netcdf file is expected (with the variable associated to the rain after "?").
173  Spacially uniform: the rain is forced using a time serie using a 2 column values table containing time (not necessary unformly distributed) and rain.
174  Ex: rain=rain_forcing.txt
175  Ex: rain=rain_forcing.nc?RainIntensity
176  Default: None
177  */
178 
180  /* Atmospheric forcing file. 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 the Pa2m parameter.
181  Ex: Atmp=AtmosphericPressure.nc?p
182  Default: None
183  */
184 
185 
186  std::vector<StaticForcingP<T>> Bathy; //Should be a vector at some point
187  /* Bathymetry/Topography input, ONLY NECESSARY INPUT
188  Different format are accepted: .asc, .nc, .md. , the grid must be regular with growing coordinate.
189  This grid will define the extend of the model domain and model resolution (if not inform by the user).
190  The coordinate can be cartesian or spherical (still in development).
191  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.
192  The first file will be use to define the domain area and base resolution but the following file
193  will be used during the refinement process.
194  Ex: bathy=Westport_DEM_2020.nc?z
195  Ex: topo=Westport_DEM_2020.asc
196  Default: None but input NECESSARY
197  */
198 
199 
200  std::vector<StaticForcingP<T>> cf;
201  /*Bottom friction coefficient map (associated to the chosen bottom friction model: n, z0, ...)
202  A list of roughness map can be provide. At any grid point, the last one defined will be used.
203  Ex: cf=0.001;
204  Ex: cf=bottom_friction.nc?bfc;
205  Default: (see constant in parameters)
206  */
207 
209  /*Initial Rain loss coefficient map (in mm)
210  Ex: il=rain_loss.nc?initial_loss;
211  Default: (see constant in parameters)
212  */
213 
215  /*Continuous Rain loss coefficient map (in mm/h)
216  Ex: cl=rain_loss.nc?continuous_loss;
217  Default: (see constant in parameters)
218  */
219 
220  std::vector<StaticForcingP<int>> targetadapt;
221 
222  std::vector<deformmap<T>> deform;
223  /*Deform are maps to apply to both zs and zb; this is often co-seismic vertical deformation used to generate tsunami initial wave
224  Here you can spread the deformation across a certain amount of time and apply it at any point in the model.
225  Ex: deform = myDeform.nc?z_def,3.0,10.0;
226  Ex: deform = *filename*, *time of initial rupture*, *rising time*;
227  Default: None
228  */
229 
230 
231  std::vector<River> rivers;
232  /*The river is added as a vertical discharge (m3/s) on a chosen area (the user input consists in a time serie and a rectangular area definition).
233  The whole cells containing the corners of the area will be included in the area, no horizontal velocity is applied.
234  To add multiple rivers, just add different lines in the input file (one by river).
235  Ex: river = Votualevu_R.txt,1867430,1867455,3914065,3914090;
236  Ex: river = *Fluxfile*, *xstart*, *xend*, *ystart*, *yend*;
237  Default: None
238  */
239 
241  /* 0:Wall (no slip); 1:neumann (zeros gradient) [Default]; 2:sealevel dirichlet; 3: Absorbing 1D 4: Absorbing 2D (not yet implemented)
242  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)
243  Ex: left = 0;
244  Ex: left = leftBnd.txt,2;
245  Default: 1
246  */
247 
249  /*Same as left boundary
250  Ex: right = 0;
251  Ex: right = rightBnd.txt,2;
252  Default: 1
253  */
254 
256  /*Same as left boundary
257  Ex: top = 0;
258  Ex: top = topBnd.txt,2;
259  Default: 1
260  */
261 
263  /*Same as left boundary
264  Ex: bot = 0;
265  Ex: bot = botBnd.txt,2;
266  Default: 1
267  */
268 
269 
270  std::vector<bndsegment> bndseg;
271  /* boundary segment; Only applies to AOI bnds
272  Ex: bndseg=area.txt,waterlevelforcing,1;
273  Default: none
274  */
275 
277  /*Area of interest polygon
278  Ex: AOI=myarea.gmt;
279  the input file is a text file with 2 columns containing the coordinate of a closed polygon (last line==first line)
280  Default: N/A
281  */
282 
283 };
284 
285 
286 
287 
288 
289 
290 
291 
292 
293 
294 
295 // End of global definition
296 #endif
Definition: Forcing.h:147
bool active
Definition: Forcing.h:151
std::string file
Definition: Forcing.h:149
Polygon poly
Definition: Forcing.h:150
Definition: Input.h:107
Definition: Forcing.h:87
std::vector< SLTS > data
Definition: Forcing.h:89
int * blks
Definition: Forcing.h:100
float * qmean
Definition: Forcing.h:102
bndTexP GPU
Definition: Forcing.h:99
int istop
Definition: Forcing.h:98
int isright
Definition: Forcing.h:97
int side
Definition: Forcing.h:96
int * blks_g
Definition: Forcing.h:101
std::string inputfile
Definition: Forcing.h:93
int nbnd
Definition: Forcing.h:94
float * qmean_g
Definition: Forcing.h:103
int nblk
Definition: Forcing.h:95
int type
Definition: Forcing.h:92
bool on
Definition: Forcing.h:90
Definition: Forcing.h:120
bndsegmentside right
Definition: Forcing.h:140
bndsegmentside top
Definition: Forcing.h:141
std::vector< Windin > data
Definition: Forcing.h:122
bool uniform
Definition: Forcing.h:127
Polygon poly
Definition: Forcing.h:124
int type
Definition: Forcing.h:129
DynForcingP< float > WLmap
Definition: Forcing.h:137
bndsegmentside bot
Definition: Forcing.h:142
std::string inputfile
Definition: Forcing.h:123
std::string polyfile
Definition: Forcing.h:125
bool on
Definition: Forcing.h:126
bndsegmentside left
Definition: Forcing.h:139
int nblk
Definition: Forcing.h:132
int nbnd
Definition: Forcing.h:131
Definition: Forcing.h:106
int nblk
Definition: Forcing.h:108
int isright
Definition: Forcing.h:113
float * qmean
Definition: Forcing.h:111
int * blk
Definition: Forcing.h:109
float * qmean_g
Definition: Forcing.h:112
int * blk_g
Definition: Forcing.h:110
int istop
Definition: Forcing.h:114
Definition: Forcing.h:45
bool iscavity
Definition: Forcing.h:52
T * val
Definition: Forcing.h:53
TexSetP GPU
Definition: Forcing.h:56
T clampedge
Definition: Forcing.h:55
double startime
Definition: Forcing.h:50
double duration
Definition: Forcing.h:51
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:56
Definition: Forcing.h:62
T * val
Definition: Forcing.h:65
T * before
Definition: Forcing.h:64
T * before_g
Definition: Forcing.h:69
T * after
Definition: Forcing.h:64
T * now
Definition: Forcing.h:63
T * now_g
Definition: Forcing.h:68
T * after_g
Definition: Forcing.h:69
T clampedge
Definition: Forcing.h:71
Definition: Forcing.h:157
std::vector< StaticForcingP< T > > cf
Definition: Forcing.h:200
DynForcingP< T > VWind
Definition: Forcing.h:159
StaticForcingP< T > cl
Definition: Forcing.h:214
std::vector< deformmap< T > > deform
Definition: Forcing.h:222
AOIinfo AOI
Definition: Forcing.h:276
DynForcingP< T > Rain
Definition: Forcing.h:170
DynForcingP< T > Atmp
Definition: Forcing.h:179
std::vector< bndsegment > bndseg
Definition: Forcing.h:270
std::vector< StaticForcingP< T > > Bathy
Definition: Forcing.h:186
bndparam left
Definition: Forcing.h:240
std::vector< StaticForcingP< int > > targetadapt
Definition: Forcing.h:220
bndparam right
Definition: Forcing.h:248
DynForcingP< T > UWind
Definition: Forcing.h:158
StaticForcingP< T > il
Definition: Forcing.h:208
std::vector< River > rivers
Definition: Forcing.h:231
bndparam top
Definition: Forcing.h:255
bndparam bot
Definition: Forcing.h:262
Definition: Forcing.h:81
T * val
Definition: Forcing.h:82
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