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; // 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 
87 //bnd
88 class bndparam {
89 public:
90  std::vector<SLTS> data;
91  bool on = false;
92  //If changing this default value, please change documentation later on the file
93  int type = 1; // 0:Wall (no slip); 1:neumann (zeros gradient) [Default]; 2:sealevel dirichlet; 3: Absorbing 1D 4: Absorbing 2D (not yet implemented)
94  std::string inputfile;
95  int nbnd; // number of forcing bnds along the side (>=1 is side is on)
96  int nblk = 0; //number of blocks where this bnd applies
97  int side = 0; // 0: top bnd, 1: rightbnd, 2: bot bnd, 3, Left bnd
98  int isright = 0;
99  int istop = 0;
101  int* blks; // array of block where bnd applies
102  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
103 };
104 
105 
106 class AOIinfo {
107 public:
108  std::string file;
110  bool active=false;
111 };
112 
113 
114 template <class T>
115 struct Forcing
116 {
119  //Forcing the Wind;
120  /*Spacially varying (.nc): 2 files are given, 1st file is U wind and second is V wind (no rotation of the data is performed)
121  Spacially uniform (.txt): 1 file is given then a 3 column file is expected, showing time, windspeed and direction.
122  Wind direction is rotated (later) to the grid direction (using grdalpha input parameter)
123  Ex: Wind = mywind.nc?uw,mywind.nc?vw
124  Ex: Wind = MyWind.txt
125  Default: None
126  */
127 
128 
130  /* This allow to force a time varying, space varying rain intensity on the model, in mm/h.
131  Spacially varrying (rain map), a netcdf file is expected (with the variable associated to the rain after "?").
132  Spacially uniform: the rain is forced using a time serie using a 2 column values table containing time (not necessary unformly distributed) and rain.
133  Ex: rain=rain_forcing.txt
134  Ex: rain=rain_forcing.nc?RainIntensity
135  Default: None
136  */
137 
139  /* 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.
140  Ex: Atmp=AtmosphericPressure.nc?p
141  Default: None
142  */
143 
144 
145  std::vector<StaticForcingP<T>> Bathy; //Should be a vector at some point
146  /* Bathymetry/Topography input, ONLY NECESSARY INPUT
147  Different format are accepted: .asc, .nc, .md. , the grid must be regular with growing coordinate.
148  This grid will define the extend of the model domain and model resolution (if not inform by the user).
149  The coordinate can be cartesian or spherical (still in development).
150  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.
151  The first file will be use to define the domain area and base resolution but the following file
152  will be used during the refinement process.
153  Ex: bathy=Westport_DEM_2020.nc?z
154  Ex: topo=Westport_DEM_2020.asc
155  Default: None but input NECESSARY
156  */
157 
159  /*Bottom friction coefficient map (associated to the chosen bottom friction model: n, z0,...)
160  Ex: cf=0.001;
161  Ex: cf=bottom_friction.nc?bfc;
162  Default: (see constant in parameters)
163  */
164 
166  /*Initial Rain loss coefficient map (in mm)
167  Ex: il=rain_loss.nc?initial_loss;
168  Default: (see constant in parameters)
169  */
170 
172  /*Continuous Rain loss coefficient map (in mm/h)
173  Ex: cl=rain_loss.nc?continuous_loss;
174  Default: (see constant in parameters)
175  */
176 
177  std::vector<StaticForcingP<int>> targetadapt;
178 
179  std::vector<deformmap<T>> deform;
180  /*Deform are maps to apply to both zs and zb; this is often co-seismic vertical deformation used to generate tsunami initial wave
181  Here you can spread the deformation across a certain amount of time and apply it at any point in the model.
182  Ex: deform = myDeform.nc?z_def,3.0,10.0;
183  Ex: deform = *filename*, *time of initial rupture*, *rising time*;
184  Default: None
185  */
186 
187 
188  std::vector<River> rivers;
189  /*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).
190  The whole cells containing the corners of the area will be included in the area, no horizontal velocity is applied.
191  To add multiple rivers, just add different lines in the input file (one by river).
192  Ex: river = Votualevu_R.txt,1867430,1867455,3914065,3914090;
193  Ex: river = *Fluxfile*, *xstart*, *xend*, *ystart*, *yend*;
194  Default: None
195  */
196 
198  /* 0:Wall (no slip); 1:neumann (zeros gradient) [Default]; 2:sealevel dirichlet; 3: Absorbing 1D 4: Absorbing 2D (not yet implemented)
199  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)
200  Ex: left = 0;
201  Ex: left = leftBnd.txt,2;
202  Default: 1
203  */
204 
206  /*Same as left boundary
207  Ex: right = 0;
208  Ex: right = rightBnd.txt,2;
209  Default: 1
210  */
211 
213  /*Same as left boundary
214  Ex: top = 0;
215  Ex: top = topBnd.txt,2;
216  Default: 1
217  */
218 
220  /*Same as left boundary
221  Ex: bot = 0;
222  Ex: bot = botBnd.txt,2;
223  Default: 1
224  */
225 
227  /*Area of interest polygon
228  Ex: AOI=myarea.gmt;
229  the input file is a text file with 2 columns containing the coordinate of a closed polygon (last line==first line)
230  Default: N/A
231  */
232 
233 };
234 
235 
236 
237 
238 
239 
240 
241 
242 
243 
244 
245 // End of global definition
246 #endif
Definition: Forcing.h:106
bool active
Definition: Forcing.h:110
std::string file
Definition: Forcing.h:108
Polygon poly
Definition: Forcing.h:109
Definition: Input.h:94
Definition: Forcing.h:88
std::vector< SLTS > data
Definition: Forcing.h:90
int * blks
Definition: Forcing.h:101
bndTexP GPU
Definition: Forcing.h:100
int istop
Definition: Forcing.h:99
int isright
Definition: Forcing.h:98
int side
Definition: Forcing.h:97
int * blks_g
Definition: Forcing.h:102
std::string inputfile
Definition: Forcing.h:94
int nbnd
Definition: Forcing.h:95
int nblk
Definition: Forcing.h:96
int type
Definition: Forcing.h:93
bool on
Definition: Forcing.h:91
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:45
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:116
StaticForcingP< T > cf
Definition: Forcing.h:158
DynForcingP< T > VWind
Definition: Forcing.h:118
StaticForcingP< T > cl
Definition: Forcing.h:171
std::vector< deformmap< T > > deform
Definition: Forcing.h:179
AOIinfo AOI
Definition: Forcing.h:226
DynForcingP< T > Rain
Definition: Forcing.h:129
DynForcingP< T > Atmp
Definition: Forcing.h:138
std::vector< StaticForcingP< T > > Bathy
Definition: Forcing.h:145
bndparam left
Definition: Forcing.h:197
std::vector< StaticForcingP< int > > targetadapt
Definition: Forcing.h:177
bndparam right
Definition: Forcing.h:205
DynForcingP< T > UWind
Definition: Forcing.h:117
StaticForcingP< T > il
Definition: Forcing.h:165
std::vector< River > rivers
Definition: Forcing.h:188
bndparam top
Definition: Forcing.h:212
bndparam bot
Definition: Forcing.h:219
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
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