BG_Flood  0.8
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 maskinfo
63 {
64 
65  int nblk = 0; //number of blocks where this bnd applies
66 
67  int* blks; // array of block where bnd applies
68  // 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)
69  int* side; // e.g. 11000000 for the entire left side being a mask
70 };
71 
72 // outzone info used to actually write the nc files (one nc file by zone, the default zone is the full domain)
73 struct outzoneB
74 {
75  int nblk; //number of blocks concerned
76  int* blk; // one zone will spread across multiple blocks (entire blocks containing a part of the area will be output)
77  double xo, xmax, yo, ymax; // Real zone for output (because we output full blocks)(corner of cells, as Xparam.xo)
78  std::string outname; // name for the output file (one for each zone)
79  int maxlevel; // maximum level in the zone
80  int minlevel; //minimum level in the zone
81 };
82 
83 
84 template <class T>
85 struct BlockP
86 {
87  T* xo, *yo;
88  int* BotLeft, *BotRight;
89  int* TopLeft, *TopRight;
90  int* LeftBot, *LeftTop;
92 
93  int* level;
94  int* active; // active blocks
95  int* activeCell; //To apply forcings (rain) only on these
96 
98 
99  std::vector<outzoneB> outZone;
100 };
101 
102 
103 struct AdaptP
104 {
105  int *newlevel;
106  int *availblk, * csumblk;
107  int *invactive;
108  bool * coarsen, *refine;
109 
110 };
111 
112 
113 
114 
115 struct BndblockP
116 {
118  int* river;
119  int* Tsout;
120  //int * DrainSink;
121  //int * DrainSource;
122  //int * Bridges;
123 
124  int* left;
125  int* right;
126  int* top;
127  int* bot;
128 
129 
130 
131 
132 };
133 
134 
135 
136 
137 
138 
139 
140 template <class T>
141 struct TimeP
142 {
144  T dt;
145  T* dtmax;
147 };
148 
149 template <class T>
150 struct Model
151 {
154 
158 
159  //external forcing
160  T* zb;
161  T* cf;
162  T* il;
163  T* cl;
164 
165  //GroundWater elevation (due to the accumulation of water by infiltration during the simulation)
166  T* hgw;
167 
168  // Used for external forcing too
169  // May need a better placeholder
171 
173 
174 
175 
176  //
177  std::map<std::string, T *> OutputVarMap;
178 
179  //other output
180  //std::vector< std::vector< Pointout > > TSallout;
181  T* TSstore;//buffer for TS data so not to save to disk too often
182  //T* vort;
183  //T* U;
186  T* wettime; //Inundation duration (h > 0.1)
187 
188  //Block information
190 
192 
194 
195 
196 
197 
198 };
199 
200 // structure of useful variable for runing the main loop
201 template <class T>
202 struct Loop
203 {
205  double dt;
206  double dtmax;
207  double totaltime;
208 
209 
210  // Needed to average mean varable for output
211  int nstep = 0;
212  //useful for calculating avg timestep
213  int nstepout = 0;
214 
215  // usefull for Time series output
216  int nTSsteps = 0;
217  std::vector< std::vector< Pointout > > TSAllout;
218 
219  int windstep = 1;
220  int atmpstep = 1;
221  int rainstep = 1;
222 
226 
227  T uwinduni = T(0.0);
228  T vwinduni = T(0.0);
230  T rainuni = T(0.0);
231 
232  // CUDA specific stuff
233 
234  dim3 blockDim;// (16, 16, 1);
235  dim3 gridDim;
236 
237  const int num_streams = 4;
238 
239  cudaStream_t streams[4];
240 
244 
245 };
246 
247 
248 
249 // End of global definition
250 #endif
Definition: Arrays.h:104
int * newlevel
Definition: Arrays.h:105
int * availblk
Definition: Arrays.h:106
int * invactive
Definition: Arrays.h:107
bool * coarsen
Definition: Arrays.h:108
bool * refine
Definition: Arrays.h:108
int * csumblk
Definition: Arrays.h:106
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:86
int * active
Definition: Arrays.h:94
int * LeftBot
Definition: Arrays.h:90
int * activeCell
Definition: Arrays.h:95
int * RightBot
Definition: Arrays.h:91
int * TopRight
Definition: Arrays.h:89
T * xo
Definition: Arrays.h:87
int * BotRight
Definition: Arrays.h:88
T * yo
Definition: Arrays.h:87
int * level
Definition: Arrays.h:93
int * BotLeft
Definition: Arrays.h:88
std::vector< outzoneB > outZone
Definition: Arrays.h:99
int * LeftTop
Definition: Arrays.h:90
int * RightTop
Definition: Arrays.h:91
int * TopLeft
Definition: Arrays.h:89
maskinfo mask
Definition: Arrays.h:97
Definition: Arrays.h:116
int * top
Definition: Arrays.h:126
int * left
Definition: Arrays.h:124
int nbndblkright
Definition: Arrays.h:117
int * Tsout
Definition: Arrays.h:119
int nbndblkleft
Definition: Arrays.h:117
int nblkriver
Definition: Arrays.h:117
int * right
Definition: Arrays.h:125
int nblkTs
Definition: Arrays.h:117
int * river
Definition: Arrays.h:118
int nbndblkbot
Definition: Arrays.h:117
int nbndblktop
Definition: Arrays.h:117
int * bot
Definition: Arrays.h:127
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:203
T atmpuni
Definition: Arrays.h:229
double dtmax
Definition: Arrays.h:206
T hugeposval
Definition: Arrays.h:242
bool atmpuniform
Definition: Arrays.h:225
T hugenegval
Definition: Arrays.h:243
int nstepout
Definition: Arrays.h:213
int nstep
Definition: Arrays.h:211
dim3 gridDim
Definition: Arrays.h:235
double totaltime
Definition: Arrays.h:207
bool winduniform
Definition: Arrays.h:223
int rainstep
Definition: Arrays.h:221
bool rainuniform
Definition: Arrays.h:224
dim3 blockDim
Definition: Arrays.h:234
double dt
Definition: Arrays.h:205
T vwinduni
Definition: Arrays.h:228
T uwinduni
Definition: Arrays.h:227
double nextoutputtime
Definition: Arrays.h:204
cudaStream_t streams[4]
Definition: Arrays.h:239
int nTSsteps
Definition: Arrays.h:216
T rainuni
Definition: Arrays.h:230
T epsilon
Definition: Arrays.h:241
std::vector< std::vector< Pointout > > TSAllout
Definition: Arrays.h:217
int windstep
Definition: Arrays.h:219
const int num_streams
Definition: Arrays.h:237
int atmpstep
Definition: Arrays.h:220
Definition: Arrays.h:151
EvolvingP_M< T > evmax
Definition: Arrays.h:185
T * datmpdy
Definition: Arrays.h:170
T * Patm
Definition: Arrays.h:170
T * hgw
Definition: Arrays.h:166
GradientsP< T > grad
Definition: Arrays.h:155
EvolvingP< T > evolv_o
Definition: Arrays.h:153
AdaptP adapt
Definition: Arrays.h:191
T * il
Definition: Arrays.h:162
T * wettime
Definition: Arrays.h:186
TimeP< T > time
Definition: Arrays.h:172
AdvanceP< T > adv
Definition: Arrays.h:157
std::map< std::string, T * > OutputVarMap
Definition: Arrays.h:177
EvolvingP_M< T > evmean
Definition: Arrays.h:184
T * TSstore
Definition: Arrays.h:181
T * datmpdx
Definition: Arrays.h:170
T * cl
Definition: Arrays.h:163
BlockP< T > blocks
Definition: Arrays.h:189
T * cf
Definition: Arrays.h:161
BndblockP bndblk
Definition: Arrays.h:193
FluxP< T > flux
Definition: Arrays.h:156
EvolvingP< T > evolv
Definition: Arrays.h:152
T * zb
Definition: Arrays.h:160
Definition: Arrays.h:142
T * dtmax
Definition: Arrays.h:145
T totaltime
Definition: Arrays.h:143
T dt
Definition: Arrays.h:144
T * arrmin
Definition: Arrays.h:146
T * arrmax
Definition: Arrays.h:146
Definition: Arrays.h:63
int * blks
Definition: Arrays.h:67
int nblk
Definition: Arrays.h:65
int * side
Definition: Arrays.h:69
Definition: Arrays.h:74
int * blk
Definition: Arrays.h:76
double xo
Definition: Arrays.h:77
int nblk
Definition: Arrays.h:75
double ymax
Definition: Arrays.h:77
int minlevel
Definition: Arrays.h:80
double yo
Definition: Arrays.h:77
std::string outname
Definition: Arrays.h:78
int maxlevel
Definition: Arrays.h:79
double xmax
Definition: Arrays.h:77