BG_Flood  0.1
Documentation (Work-in-progress)
Arrays.h
Go to the documentation of this file.
1 
2 #ifndef ARRAYS_H
3 #define ARRAYS_H
4 
5 #include "General.h"
6 #include "Input.h"
7 
8 
9 template <class T>
10 struct GradientsP
11 {
12  T* dzsdx;
13  T* dhdx;
14  T* dudx;
15  T* dvdx;
16 
17  T* dzsdy;
18  T* dhdy;
19  T* dudy;
20  T* dvdy;
21 
22  T* dzbdx;
23  T* dzbdy;
24 };
25 
26 
27 template <class T>
28 struct EvolvingP
29 {
30  T* zs;
31  T* h;
32  T* u;
33  T* v;
34 };
35 
36 //subclass inheriting from EvolvingP for Mean/Max
37 template <class T>
38 struct EvolvingP_M : public EvolvingP<T>
39 {
40  T* U; //Norm of the velocity
41  T* hU; //h*sqrt(u^2+v^2)
42 };
43 
44 template <class T>
45 struct FluxP
46 {
47  T* Su,* Sv;
48  T* Fqux, * Fquy;
49  T* Fqvx, * Fqvy;
50  T* Fhu, * Fhv;
51 };
52 
53 template <class T>
54 struct AdvanceP
55 {
56  T* dh;
57  T* dhu;
58  T* dhv;
59 };
60 
61 
62 struct outP
63 {
64  float* z;
65  short* z_s;
66  int level;
67  double xmin, xmax, ymin, ymax;
68 };
69 
70 
71 struct maskinfo
72 {
73 
74  int nblk = 0; //number of blocks where this bnd applies
75 
76  int* blks; // array of block where bnd applies
77  // 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)
78  int* side; // e.g. 11000000 for the entire left side being a mask
79 
80  int type = 0;
81 
82 
83 };
84 
85 
86 // outzone info used to actually write the nc files (one nc file by zone, the default zone is the full domain)
87 struct outzoneB
88 {
89  int nblk; //number of blocks concerned
90  int* blk; // one zone will spread across multiple blocks (entire blocks containing a part of the area will be output)
91  double xo, xmax, yo, ymax; // Real zone for output (because we output full blocks)(corner of cells, as Xparam.xo)
92  std::string outname; // name for the output file (one for each zone)
93  int maxlevel; // maximum level in the zone
94  int minlevel; //minimum level in the zone
95 };
96 
97 
98 template <class T>
99 struct BlockP
100 {
101  T* xo, *yo;
104  int* LeftBot, *LeftTop;
106 
107  int* level;
108  int* active; // active blocks
109  int* activeCell; //To apply forcings (rain) only on these
110 
112 
113  std::vector<outzoneB> outZone;
114 };
115 
116 
117 struct AdaptP
118 {
119  int *newlevel;
120  int *availblk, * csumblk;
121  int *invactive;
122  bool * coarsen, *refine;
123 
124 };
125 
126 
127 
128 
129 struct BndblockP
130 {
132  int* river;
133  int* Tsout;
134  //int * DrainSink;
135  //int * DrainSource;
136  //int * Bridges;
137 
138  int* left;
139  int* right;
140  int* top;
141  int* bot;
142 
143 
144 
145 
146 };
147 
148 
149 
150 
151 
152 
153 
154 template <class T>
155 struct TimeP
156 {
158  T dt;
159  T* dtmax;
161 };
162 
163 template <class T>
164 struct Model
165 {
168 
172 
173  //external forcing
174  T* zb;
175  T* cf;
176  T* il;
177  T* cl;
178 
179  //GroundWater elevation (due to the accumulation of water by infiltration during the simulation)
180  T* hgw;
181 
182  // Used for external forcing too
183  // May need a better placeholder
185 
187 
188 
189 
190  //
191  std::map<std::string, T *> OutputVarMap;
192  std::map<std::string, std::string> Outvarlongname;
193  std::map<std::string, std::string> Outvarstdname;
194  std::map<std::string, std::string> Outvarunits;
195 
196 
197  //other output
198  //std::vector< std::vector< Pointout > > TSallout;
199  T* TSstore;//buffer for TS data so not to save to disk too often
200  //T* vort;
201  //T* U;
204  T* wettime; //Inundation duration (h > 0.1)
205 
206  //Block information
208 
210 
212 
213 
214 
215 
216 };
217 
218 // structure of useful variable for runing the main loop
219 template <class T>
220 struct Loop
221 {
223  double dt;
224  double dtmax;
225  double totaltime;
226 
227 
228  // Needed to average mean varable for output
229  int nstep = 0;
230  //useful for calculating avg timestep
231  int nstepout = 0;
232 
233  // usefull for Time series output
234  int nTSsteps = 0;
235  std::vector< std::vector< Pointout > > TSAllout;
236 
237  int windstep = 1;
238  int atmpstep = 1;
239  int rainstep = 1;
240 
244 
245  T uwinduni = T(0.0);
246  T vwinduni = T(0.0);
248  T rainuni = T(0.0);
249 
250  // CUDA specific stuff
251 
252  dim3 blockDim;// (16, 16, 1);
253  dim3 gridDim;
254 
255  const int num_streams = 4;
256 
257  cudaStream_t streams[4];
258 
262 
263 };
264 
265 
266 
267 // End of global definition
268 #endif
Definition: Arrays.h:118
int * newlevel
Definition: Arrays.h:119
int * availblk
Definition: Arrays.h:120
int * invactive
Definition: Arrays.h:121
bool * coarsen
Definition: Arrays.h:122
bool * refine
Definition: Arrays.h:122
int * csumblk
Definition: Arrays.h:120
Definition: Arrays.h:55
T * dhv
Definition: Arrays.h:58
T * dhu
Definition: Arrays.h:57
T * dh
Definition: Arrays.h:56
Definition: Arrays.h:100
int * active
Definition: Arrays.h:108
int * LeftBot
Definition: Arrays.h:104
int * activeCell
Definition: Arrays.h:109
int * RightBot
Definition: Arrays.h:105
int * TopRight
Definition: Arrays.h:103
T * xo
Definition: Arrays.h:101
int * BotRight
Definition: Arrays.h:102
T * yo
Definition: Arrays.h:101
int * level
Definition: Arrays.h:107
int * BotLeft
Definition: Arrays.h:102
std::vector< outzoneB > outZone
Definition: Arrays.h:113
int * LeftTop
Definition: Arrays.h:104
int * RightTop
Definition: Arrays.h:105
int * TopLeft
Definition: Arrays.h:103
maskinfo mask
Definition: Arrays.h:111
Definition: Arrays.h:130
int * top
Definition: Arrays.h:140
int * left
Definition: Arrays.h:138
int nbndblkright
Definition: Arrays.h:131
int * Tsout
Definition: Arrays.h:133
int nbndblkleft
Definition: Arrays.h:131
int nblkriver
Definition: Arrays.h:131
int * right
Definition: Arrays.h:139
int nblkTs
Definition: Arrays.h:131
int * river
Definition: Arrays.h:132
int nbndblkbot
Definition: Arrays.h:131
int nbndblktop
Definition: Arrays.h:131
int * bot
Definition: Arrays.h:141
Definition: Arrays.h:39
T * hU
Definition: Arrays.h:41
T * U
Definition: Arrays.h:40
Definition: Arrays.h:29
T * h
Definition: Arrays.h:31
T * v
Definition: Arrays.h:33
T * zs
Definition: Arrays.h:30
T * u
Definition: Arrays.h:32
Definition: Arrays.h:46
T * Fhu
Definition: Arrays.h:50
T * Fhv
Definition: Arrays.h:50
T * Fqvy
Definition: Arrays.h:49
T * Su
Definition: Arrays.h:47
T * Sv
Definition: Arrays.h:47
T * Fqux
Definition: Arrays.h:48
T * Fquy
Definition: Arrays.h:48
T * Fqvx
Definition: Arrays.h:49
Definition: Arrays.h:11
T * dudx
Definition: Arrays.h:14
T * dhdx
Definition: Arrays.h:13
T * dzbdx
Definition: Arrays.h:22
T * dzsdy
Definition: Arrays.h:17
T * dvdx
Definition: Arrays.h:15
T * dhdy
Definition: Arrays.h:18
T * dudy
Definition: Arrays.h:19
T * dzsdx
Definition: Arrays.h:12
T * dvdy
Definition: Arrays.h:20
T * dzbdy
Definition: Arrays.h:23
Definition: Arrays.h:221
T atmpuni
Definition: Arrays.h:247
double dtmax
Definition: Arrays.h:224
T hugeposval
Definition: Arrays.h:260
bool atmpuniform
Definition: Arrays.h:243
T hugenegval
Definition: Arrays.h:261
int nstepout
Definition: Arrays.h:231
int nstep
Definition: Arrays.h:229
dim3 gridDim
Definition: Arrays.h:253
double totaltime
Definition: Arrays.h:225
bool winduniform
Definition: Arrays.h:241
int rainstep
Definition: Arrays.h:239
bool rainuniform
Definition: Arrays.h:242
dim3 blockDim
Definition: Arrays.h:252
double dt
Definition: Arrays.h:223
T vwinduni
Definition: Arrays.h:246
T uwinduni
Definition: Arrays.h:245
double nextoutputtime
Definition: Arrays.h:222
cudaStream_t streams[4]
Definition: Arrays.h:257
int nTSsteps
Definition: Arrays.h:234
T rainuni
Definition: Arrays.h:248
T epsilon
Definition: Arrays.h:259
std::vector< std::vector< Pointout > > TSAllout
Definition: Arrays.h:235
int windstep
Definition: Arrays.h:237
const int num_streams
Definition: Arrays.h:255
int atmpstep
Definition: Arrays.h:238
Definition: Arrays.h:165
EvolvingP_M< T > evmax
Definition: Arrays.h:203
T * datmpdy
Definition: Arrays.h:184
std::map< std::string, std::string > Outvarunits
Definition: Arrays.h:194
T * Patm
Definition: Arrays.h:184
T * hgw
Definition: Arrays.h:180
GradientsP< T > grad
Definition: Arrays.h:169
EvolvingP< T > evolv_o
Definition: Arrays.h:167
AdaptP adapt
Definition: Arrays.h:209
T * il
Definition: Arrays.h:176
T * wettime
Definition: Arrays.h:204
std::map< std::string, std::string > Outvarstdname
Definition: Arrays.h:193
TimeP< T > time
Definition: Arrays.h:186
AdvanceP< T > adv
Definition: Arrays.h:171
std::map< std::string, T * > OutputVarMap
Definition: Arrays.h:191
EvolvingP_M< T > evmean
Definition: Arrays.h:202
T * TSstore
Definition: Arrays.h:199
std::map< std::string, std::string > Outvarlongname
Definition: Arrays.h:192
T * datmpdx
Definition: Arrays.h:184
T * cl
Definition: Arrays.h:177
BlockP< T > blocks
Definition: Arrays.h:207
T * cf
Definition: Arrays.h:175
BndblockP bndblk
Definition: Arrays.h:211
FluxP< T > flux
Definition: Arrays.h:170
EvolvingP< T > evolv
Definition: Arrays.h:166
T * zb
Definition: Arrays.h:174
Definition: Arrays.h:156
T * dtmax
Definition: Arrays.h:159
T totaltime
Definition: Arrays.h:157
T dt
Definition: Arrays.h:158
T * arrmin
Definition: Arrays.h:160
T * arrmax
Definition: Arrays.h:160
Definition: Arrays.h:72
int * blks
Definition: Arrays.h:76
int type
Definition: Arrays.h:80
int nblk
Definition: Arrays.h:74
int * side
Definition: Arrays.h:78
Definition: Arrays.h:63
double xmax
Definition: Arrays.h:67
double xmin
Definition: Arrays.h:67
float * z
Definition: Arrays.h:64
double ymax
Definition: Arrays.h:67
double ymin
Definition: Arrays.h:67
short * z_s
Definition: Arrays.h:65
int level
Definition: Arrays.h:66
Definition: Arrays.h:88
int * blk
Definition: Arrays.h:90
double xo
Definition: Arrays.h:91
int nblk
Definition: Arrays.h:89
double ymax
Definition: Arrays.h:91
int minlevel
Definition: Arrays.h:94
double yo
Definition: Arrays.h:91
std::string outname
Definition: Arrays.h:92
int maxlevel
Definition: Arrays.h:93
double xmax
Definition: Arrays.h:91