BG_Flood  0.8
Documentation (Work-in-progress)
Param.h
Go to the documentation of this file.
1 #ifndef PARAM_H
2 #define PARAM_H
3 
4 #include "General.h"
5 #include "Input.h"
6 
10 class Param {
11 public:
12 
13  //*General parameters
14  int test = -1; //-1: no test, 99: run all independent tests, X: run test X
15  double g = 9.81; // Acceleration of gravity in m.s-2
16  double rho = 1025.0; // Fluid density in kg.m-3
17  double eps = 0.0001; // Drying height in m (if h<eps, the surface is concidered dry)
18  double dt = 0.0; // Model time step in s.
19  double CFL = 0.5; // Current Freidrich Limiter criterium (between 0 and 1. Higher values may make the model unstable)
20  double theta = 1.3; // Minmod limiter parameter, theta in [1,2]. <br>Can be used to tune the momentum dissipation (theta=1 gives minmod the most dissipative limiter and theta = 2 gives superbee, the least dissipative).
21  double VelThreshold = -1.0; // Using Velocity threshold if the the velocuity exceeds that threshold. Advice value of 16.0 to use or negative value (-1) to turn off
22  int frictionmodel = 0; // Bottom friction model flag (-1: Manning model, 0: quadratic, 1: Smart roughtness length model)
23  double cf = 0.0001; // Bottom friction coefficient for the model (if constant)
24  double Cd = 0.002; // Wind drag coefficient
25  double il = 0.0; //Initial Loss (if constant)
26  double cl = 0.0; //Continuous Loss (if constant)
27  bool windforcing = false; //not working yet
28  bool atmpforcing = false;
29  bool rainforcing = false;
30  bool infiltration = false;
31 
32  bool conserveElevation = false; //Switch to force the conservation of zs instead of h at the interface between coarse and fine blocks
33  bool wetdryfix = true; // Switch to remove wet/dry instability (i.e. true reoves instability and false leaves the model as is)
34  bool ForceMassConserve = false; // Switch to enforce mass conservation only useful on steep slope
35 
36  double Pa2m = 0.00009916; // Conversion between atmospheric pressure changes to water level changes in Pa (if unit is hPa then user should use 0.009916)
37  double Paref = 101300.0; // Reference pressure in Pa (if unit is hPa then user should use 1013.0)
38  double lat = 0.0; // Model latitude. This is ignored in spherical case
39  int GPUDEVICE = 0; // 0: first available GPU, -1: CPU single core, 2+: other GPU
40 
41  int doubleprecision = 0; // 0: float precision, 1: double precision (for the solver and math)
42 
43  int engine = 1; // 1: Buttinger-Kreuzhuber et al. 2019, 2: Kurganov (Popinet 2011), 3: KurganovATMP same as Kurganov but with atmospheric forcing terms
44 
45  //*Grid parameters
46  double dx = nan(""); // Grid resolution, in m for a metric grid or in decimal degree for a sperical grid.
47  double delta; // Grid resolution for the model. in Spherical coordinates this is dx * Radius*pi / 180.0
48  int nx = 0; // Initial/input grid size (number of nodes) in x direction
49  int ny = 0; //Initial/input grid size (number of nodes) in y direction
50  int nblk = 0; // Number of compute blocks
51  int blkwidth = 16; //Block width in number of cells
52  int blkmemwidth = 0; // Calculated in sanity check as blkwidth+2*halowidth
53  int blksize = 0; // Calculated in sanity check as blkmemwidth*blkmemwidth
54  int halowidth = 1; // Use a halo around the blocks default is 1 cell: the memory for each blk is 18x18 when blkwidth is 16
55 
56 
57  double xo = nan(""); // Grid x origin (if not alter by the user, will be defined based on the topography/bathymetry input map)
58  double yo = nan(""); // Grid y origin (if not alter by the user, will be defined based on the topography/bathymetry input map)
59  double ymax = nan(""); // Grid ymax (if not alter by the user, will be defined based on the topography/bathymetry input map)
60  double xmax = nan(""); // Grid xmax (if not alter by the user, will be defined based on the topography/bathymetry input map)
61  double grdalpha = nan(""); // Grid rotation on Y axis from the North input in degrees but later converted to rad
62  int posdown = 0; // Flag for bathy input. Model requirement is positive up so if posdown ==1 then zb=zb*-1.0f
63  bool spherical = 0; // Flag for sperical coordinate (still in development)
64  double Radius = 6371220.; //Earth radius [m]
65  double mask = 9999.0; //Mask any zb above this value. If the entire Block is masked then it is not allocated in the memory
66 
67  //*Adaptation
68  int initlevel = 0; //Initial level of grid adaptation (based on dx if defined by the user or on the resolution of the topography/bathymetry input)
69  int maxlevel = -99999; //Maximum level for grid adaptation (overwrite the adaptation map if use)
70  int minlevel = -99999; //Minumim level for grid adaptation (overwrite the adaptation map if use)
71  int nblkmem = 0;
72  int navailblk = 0;
73  double membuffer = 1.05; //Needs to allocate more memory than initially needed so adaptation can happen without memory reallocation
74 
75 
76 
77  //*Timekeeping
78  //double outputtimeinit = -99999; //Initial time for the output, initialised to initial running time
79  double outputtimestep = 0.0; //Number of seconds between netCDF outputs, 0.0 for none
80  double endtime = std::numeric_limits<double>::max(); // Total runtime in s, will be calculated based on bnd input as min(length of the shortest time series, user defined) and should be shorter than any time-varying forcing
81  double totaltime = 0.0; // Total simulation time in s
82  double inittime = 0.0; // Initital model time. At start of simulation inittime==totaltime
83  double dtinit = -1; // Maximum initial time steps in s (should be positive, advice 0.1 if dry domain initialement)
84  double dtmin = 0.0005; //Minimum accepted time steps in s (a lower value will be concidered a crash of the code, and stop the run)
85 
86  T_output Toutput; /* Flexible time definition for outputs (nc files)
87  Example: "Toutput = 0.0:3600:7200,7000,7100; which mean every 3600s from 0 to 7200s, and the two times 7000 and 7100"
88  Default = First and last timne steps*/
89 
90  //*Boundaries
91  bool leftbnd = false; // bnd is forced (i.e. not a wall or neuman)
92  bool rightbnd = false; // bnd is forced (i.e. not a wall or neuman)
93  bool topbnd = false; // bnd is forced (i.e. not a wall or neuman)
94  bool botbnd = false; // bnd is forced (i.e. not a wall or neuman)
95 
96  int aoibnd = 0; // Boundary type for AOI: 0=wall; 1 neumann; 3 absorbing
97  double bndrelaxtime = 3600.0; // Realxation time for absorbing boundary
98  double bndfiltertime = 60.0; // Filtering time for absorbing boundary
99 
100 
101  //* Initialisation
102  double zsinit = nan(""); //Init zs for cold start in m. If not specified by user and no bnd file = 1 then sanity check will set it to 0.0
103 
104  double zsoffset = nan(""); //Add a water level offset in m to initial conditions and boundaries (0.0 by default)
105 
106  std::string hotstartfile;
107  /*Allow to hotstart (or restart) the computation providing a netcdf file containing at least zb, h or zs, u and v
108  Default: None
109  */
110  //std::string deformfile;
111  int hotstep = 0; //Step to read if hotstart file has multiple steps (step and not (computation) time)
112 
113 
114  double bndtaper = 0.0; // number of second to taper boundary values to smooth transition with initial conditions default is no tapering but 600s is good practice
115  //other
118 
119 
120  //*Outputs
121  //std::string Bathymetryfile;// bathymetry file name
122  //inputmap Bathymetry;
123 
124 
125  //Timeseries output (save as a vector containing information for each Time Serie output)
126  std::vector<TSoutnode> TSnodesout;
127  /*Time serie output, giving a file name and a (x,y) position
128  (which will be converted to nearest grid position).
129  This keyword can be used multiple times to extract time series at different locations.
130  The data is stocked for each timestep and written by flocs.
131  The resulting file contains (t,zs,h,u,v)
132  Example: "TSnodesout = Offshore.txt,3101.00,4982.57" (*filename,x,y*)
133  Default: None
134  */
135 
136  std::string outfile = "Output.nc"; // Netcdf output file name (if it exists, a number will be happened to the file name to not overwrite it)
137  std::vector<std::string> outvars;
138  /*List of names of the variables to output (for 2D maps)
139  Supported variables = "zb", "zs", "u", "v", "h", "hmean", "zsmean", "umean", "vmean", "hUmean", "Umean", "hmax", "zsmax", "umax", "vmax", "hUmax", "Umax", "twet", "dhdx","dhdy","dzsdx","dzsdy","dudx","dudy","dvdx","dvdy","Fhu","Fhv","Fqux","Fqvy","Fquy","Fqvx","Su","Sv","dh","dhu","dhv","cf","Patm", "datmpdx","datmpdy","il","cl","hgw";
140  Example: "outvars = zs,h,u,v,zb,hmax,Umax;"
141  Default: "zb", "zs", "u", "v", "h"
142  */
143  double wet_threshold = 0.1; //in m. Limit to consider a cell wet for the twet output (duration of inundation (s))
144 
145  std::vector<outzoneP> outzone;
146  /*Zoned output (netcdf file), giving a file name and the position of two corner points
147  (which will be converted to a rectagle containing full blocks).
148  Time vector or values can also be added to specified special outputs for this one in particular.
149  This keyword can be used multiple times to output maps of different areas.
150  Example: "outzone=zoomed.nc,5.3,5.4,0.5,0.8;" (*filename,x1,x2,y1,y2*) or "outzone=zoomed.nc,5.3,5.4,0.5,0.8, 3600:360:7200;" (*filename,x1,x2,y1,y2, t_init:t_step:t_end*)
151  Default: Full domain
152  */
153 
154  int maxTSstorage = 16384; //maximum strorage (nTSnodes*4*nTSsteps) before time series output are flushed to disk [2^14]
155 
156 
157 
158 
159  // Output switch controls
160  bool resetmax = false; //Switch to reset the "max" outputs after each output (reset if 1, no reset if 0)
161  bool outmax = false;
162  bool outmean = false;
163  //bool outvort = false;
164  bool outtwet = false;
165  //bool outU = false;
166 
167  // WARNING FOR DEBUGGING PURPOSE ONLY
168 // For debugging one can shift the output by 1 or -1 in the i and j direction.
169 // this will save the value in the halo to the output file allowing debugging of values there.
170  int outishift = 0; //DEBUGGING ONLY: allow cell shift (1 or -1) in x direction to visualise the halo around blocks in the output
171  int outjshift = 0; //DEBUGGING ONLY: allow cell shift (1 or -1) in y direction to visualise the halo around blocks in the output
172 
173 
174  //Rivers
175  //std::vector<River> Rivers; // empty vector to hold river location and discharge time series
176  int nrivers = 0;
177  int nblkriver = 0;
178 
179  // length of bnd blk, redundant from XForcing but useful
180  int nbndblkleft = 0;
181  int nbndblkright = 0;
182  int nbndblktop = 0;
183  int nbndblkbot = 0;
184 
185  int nmaskblk = 0;
186 
187 
188 
189  //*Netcdf parameters
190  int smallnc = 1; //Short integer conversion for netcdf outputs. 1: save as short integer for the netcdf file, if 0 then save all variables as float
191  float scalefactor = 0.01f; //Scale factor used for the short integer conversion for netcdf outputs. This follow the COARDS convention.
192  float addoffset = 0.0f; //Offset add during the short integer conversion for netcdf outputs (follow the COARDS convention)
193 
194 #ifdef USE_CATALYST
195  //* ParaView Catalyst parameters (SPECIAL USE WITH PARAVIEW)
196  int use_catalyst = 0; // Switch to use ParaView Catalyst
197  int catalyst_python_pipeline = 0; //Pipeline to use ParaView Catalyst
198  int vtk_output_frequency = 0; // Output frequency for ParaView Catalyst
199  double vtk_output_time_interval = 1.0; // Output time step for ParaView Catalyst
200  std::string vtk_outputfile_root = "bg_out"; //output file name for ParaView Catalyst
201  std::string python_pipeline = "coproc.py"; //python pipeline for ParaView Catalyst
202 #endif
203 
204 
205 
206 
207  // info of the mapped cf
208  //inputmap roughnessmap;
209 
210  //forcingmap windU;
211  //forcingmap windV;
212  //forcingmap atmP;
213  //forcingmap Rainongrid;
214 
215  // deformation forcing for tsunami generation
216  //std::vector<deformmap> deform;
217  double deformmaxtime = 0.0; // time (s) after which no deformation occurs (internal parameter to cut some of the loops)
218  bool rainbnd = false; // when false it force the rain foring on the bnd cells to be null.
219 
220  // This here should be stored in a structure at a later stage
221 
222  std::string AdaptCrit;
224 
226  int adaptmaxiteration = 20; // Maximum number of iteration for adaptation. default 20
227 
228  std::string reftime = ""; // Reference time string as yyyy-mm-ddTHH:MM:SS
229  std::string crs_ref = "no_crs"; //"PROJCS[\"NZGD2000 / New Zealand Transverse Mercator 2000\",GEOGCS[\"NZGD2000\",DATUM[\"New_Zealand_Geodetic_Datum_2000\",SPHEROID[\"GRS 1980\",6378137,298.257222101]],PRIMEM[\"Greenwich\",0],UNIT[\"degree\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9122\"]],AUTHORITY[\"EPSG\",\"4167\"]],PROJECTION[\"Transverse_Mercator\"],PARAMETER[\"latitude_of_origin\",0],PARAMETER[\"central_meridian\",173],PARAMETER[\"scale_factor\",0.9996],PARAMETER[\"false_easting\",1600000],PARAMETER[\"false_northing\",10000000],UNIT[\"metre\",1],AXIS[\"Northing\",NORTH],AXIS[\"Easting\",EAST],AUTHORITY[\"EPSG\",\"2193\"]]";
230 
231 
232  bool savebyblk = true;
233 
234 };
235 
236 
237 
238 // End of global definition
239 #endif
Definition: Param.h:10
int outjshift
Definition: Param.h:171
bool outtwet
Definition: Param.h:164
double outputtimestep
Definition: Param.h:79
int adaptmaxiteration
Definition: Param.h:226
int nbndblkbot
Definition: Param.h:183
std::string Adapt_arg3
Definition: Param.h:225
std::string reftime
Definition: Param.h:228
bool resetmax
Definition: Param.h:160
double inittime
Definition: Param.h:82
double xmax
Definition: Param.h:60
double ymax
Definition: Param.h:59
bool spherical
Definition: Param.h:63
std::vector< std::string > outvars
Definition: Param.h:137
double bndfiltertime
Definition: Param.h:98
std::vector< TSoutnode > TSnodesout
Definition: Param.h:126
double dtmin
Definition: Param.h:84
double Cd
Definition: Param.h:24
int outishift
Definition: Param.h:170
int aoibnd
Definition: Param.h:96
int GPUDEVICE
Definition: Param.h:39
int halowidth
Definition: Param.h:54
double eps
Definition: Param.h:17
int nbndblkright
Definition: Param.h:181
double endtime
Definition: Param.h:80
double zsoffset
Definition: Param.h:104
size_t GPU_totalmem_byte
Definition: Param.h:117
size_t GPU_initmem_byte
Definition: Param.h:117
double wet_threshold
Definition: Param.h:143
double lat
Definition: Param.h:38
int maxTSstorage
Definition: Param.h:154
std::string Adapt_arg4
Definition: Param.h:225
std::string outfile
Definition: Param.h:136
double bndtaper
Definition: Param.h:114
int engine
Definition: Param.h:43
double mask
Definition: Param.h:65
int nrivers
Definition: Param.h:176
clock_t endcputime
Definition: Param.h:116
bool outmax
Definition: Param.h:161
int nblkriver
Definition: Param.h:177
double il
Definition: Param.h:25
int posdown
Definition: Param.h:62
int maxlevel
Definition: Param.h:69
double VelThreshold
Definition: Param.h:21
double cf
Definition: Param.h:23
int smallnc
Definition: Param.h:190
bool windforcing
Definition: Param.h:27
int doubleprecision
Definition: Param.h:41
double zsinit
Definition: Param.h:102
double rho
Definition: Param.h:16
int hotstep
Definition: Param.h:111
int ny
Definition: Param.h:49
double yo
Definition: Param.h:58
int blkmemwidth
Definition: Param.h:52
double totaltime
Definition: Param.h:81
bool leftbnd
Definition: Param.h:91
int frictionmodel
Definition: Param.h:22
bool rainbnd
Definition: Param.h:218
double membuffer
Definition: Param.h:73
int navailblk
Definition: Param.h:72
std::string crs_ref
Definition: Param.h:229
double Radius
Definition: Param.h:64
double Paref
Definition: Param.h:37
int nmaskblk
Definition: Param.h:185
double dt
Definition: Param.h:18
int minlevel
Definition: Param.h:70
float addoffset
Definition: Param.h:192
std::string Adapt_arg1
Definition: Param.h:225
int blkwidth
Definition: Param.h:51
T_output Toutput
Definition: Param.h:86
double g
Definition: Param.h:15
double deformmaxtime
Definition: Param.h:217
std::string AdaptCrit
Definition: Param.h:222
int initlevel
Definition: Param.h:68
clock_t setupcputime
Definition: Param.h:116
bool savebyblk
Definition: Param.h:232
int nblk
Definition: Param.h:50
bool atmpforcing
Definition: Param.h:28
double cl
Definition: Param.h:26
bool wetdryfix
Definition: Param.h:33
int blksize
Definition: Param.h:53
std::string Adapt_arg2
Definition: Param.h:225
double xo
Definition: Param.h:57
double theta
Definition: Param.h:20
double CFL
Definition: Param.h:19
int * AdaptCrit_funct_pointer
Definition: Param.h:223
int nblkmem
Definition: Param.h:71
clock_t startcputime
Definition: Param.h:116
bool rainforcing
Definition: Param.h:29
int nbndblktop
Definition: Param.h:182
bool ForceMassConserve
Definition: Param.h:34
int nx
Definition: Param.h:48
double Pa2m
Definition: Param.h:36
double dtinit
Definition: Param.h:83
bool conserveElevation
Definition: Param.h:32
double bndrelaxtime
Definition: Param.h:97
double delta
Definition: Param.h:47
std::vector< outzoneP > outzone
Definition: Param.h:145
int test
Definition: Param.h:14
int nbndblkleft
Definition: Param.h:180
bool rightbnd
Definition: Param.h:92
bool outmean
Definition: Param.h:162
float scalefactor
Definition: Param.h:191
bool botbnd
Definition: Param.h:94
double dx
Definition: Param.h:46
double grdalpha
Definition: Param.h:61
std::string hotstartfile
Definition: Param.h:106
bool infiltration
Definition: Param.h:30
bool topbnd
Definition: Param.h:93
std::string Adapt_arg5
Definition: Param.h:225
Definition: Input.h:16
__host__ __device__ const T & max(const T &a, const T &b)
Definition: Util_CPU.cu:38