-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathsettings.hpp
458 lines (380 loc) · 10 KB
/
settings.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
/*
* FILE:
* settings.hpp
*
* AUTHORS:
* Sasan Tavakkol <[email protected]> or <[email protected]>
* Stephen Thompson <[email protected]>
*
* LAST UPDATE:
* 26-Aug-2016
* CREATED:
* 24-Oct-2011
*
COPYRIGHT:
* Copyright (C) 2016, Sasan Tavakkol.
* Copyright (C) 2012, Stephen Thompson.
*
* This file is part of Celeris software. Celeris is an interactive
* Boussinesq-type, coastal wave solver and visualizer.
*
* Celeris is free software: you can redistribute it
* and/or modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* The Shallow Water Demo is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the Shallow Water Demo. If not, see
* <http://www.gnu.org/licenses/>.
*
*/
#ifndef SETTINGS_HPP
#define SETTINGS_HPP
#include <vector>
enum SettingType {
S_NULL,
S_NEW_TAB,
S_LABEL,
S_SLIDER,
S_SLIDER_INT,
S_SLIDER_MULT_4,
S_CHECKBOX,
S_WATER_SURFACE_SHADING,
S_WATER_SURFACE_SHADING_VARIABLE,
S_TERRAIN_TEXTURE,
S_SKYBOX_TEXTURE,
S_BOUNDARY_DROPDOWN,
S_BOUNDARY_OPTIONS_DROPDOWN,
S_LEFT_MOUSE_DROPDOWN,
S_TEXTFIELD
};
// Sasan: This enum's use case is changed and comments are not correct
enum ResetType {
R_NONE,
R_TERRAIN,
R_MESH, // remesh, no water
R_VALLEY, // remesh, setup water in valley
R_SEA, // remesh, fill to sea level
R_SQUARE // remesh, fill in a square in the middle
};
enum LeftMouseSettings {
LM_ADD_WATER,
LM_REMOVE_WATER,
LM_STIR_WATER,
LM_RAISE_TERRAIN,
LM_LOWER_TERRAIN
};
enum ShadingOptions{
PHOTOREALISTIC,
PARULA,
JET,
ZEBRA,
CUSTOM
};
enum BoundaryType{
B_SOLID,
B_SPONGE,
B_SINEWAVE,
B_IRREGULARWAVE,
B_UNIFORMTIMESERIES
};
enum BoundarySide{
B_WEST,
B_EAST,
B_SOUTH,
B_NORTH
};
struct Setting {
const char * name;
const char * unit;
SettingType type;
ResetType reset_type;
double min;
double max;
double value;
};
struct SineWaveSetting {
float amplitude;
float period;
float theta; //angle in radians to x direction.
SineWaveSetting (): amplitude(0), period(0), theta(0){}
};
struct IrregularWaveSpectrumSetting {
bool useSpectrum;
float significant_waveheight;
float peak_period;
float mean_theta; //angle in radians to x direction.
float depth_at_source;
IrregularWaveSpectrumSetting (): significant_waveheight(0), peak_period(0), mean_theta(0), depth_at_source(0), useSpectrum(false){}
};
struct FlowParameters {
float w;
float hu;
float hv;
};
struct UniformTimeSeries{
std::string fileName;
std::vector<std::vector<float>> data;
int iter;
UniformTimeSeries () : iter(1), fileName("NA"){}
void reset_iter (){
iter = 1;
}
};
struct BoundarySetting {
std::string type;
int width; //number of cells in boundary.
float waterLevel; // this can be sea level, or a control depth at river output. It is measured from datum.
SineWaveSetting sineWaveSetting;
IrregularWaveSpectrumSetting IrrWaveSpectrumSetting;
UniformTimeSeries uniformTimeSeries;
// FlowParameters ForcedInput;
bool hasChanged;
BoundarySetting (): type("Solid"), width(2), waterLevel(0), hasChanged(false) {}
};
struct Point {
int x;
int y;
Point ():x(0),y(0){}
Point (int j, int i):x(j),y(i){}
Point (const Point &p): x(p.x), y(p.y){}
};
struct Range {
std::string name;
Point bottomLeft;
Point topRight;
Range (): bottomLeft(0,0), topRight(0,0){}
Range (Point bl, Point tr): bottomLeft(bl), topRight (tr) {}
Range (std::string n, Point bl, Point tr): name(n), bottomLeft(bl), topRight (tr) {}
};
// a soliton is a solitary wave
struct Soliton{
float param_h;
float theta;
float length;
float xc;
float yc;
Soliton () : param_h(0), theta (0), xc(0), yc(0), length(0){}
Soliton (float H,float theta_in, float xcenter,float ycenter, float length_in) : param_h(H), theta (theta_in), xc(xcenter), yc(ycenter), length(length_in){}
void setSoliton(float H, float theta_in, float xcenter, float ycenter, float length_in){
param_h = H; theta = theta_in; xc = xcenter; yc = ycenter; length = length_in;
}
};
struct CameraSetting{
float fov;
float x, y, z;
float pitch, yaw;
CameraSetting() : fov(50), x(0), y(0), z(0), pitch(0), yaw(0){}
};
struct SurfaceShadingSetting{
ShadingOptions type;
int shadingVariable;
bool autoColormap;
bool autoInundationDepth;
bool showInundatedArea;
float drylandDepthOfInundation;
bool showDissipation;
float dissipationThreshold;
float whiteWaterDecay;
float colormapMin;
float colormapMax;
float minInundation; // for visualization purposes
float maxInundation; // for visualization purposes
SurfaceShadingSetting(){
type = PHOTOREALISTIC;
shadingVariable = 0; // 0 is eta
autoColormap = true;
autoInundationDepth = true;
showInundatedArea = false;
drylandDepthOfInundation = 0.1; // 10 cm.
dissipationThreshold = 0.25;
whiteWaterDecay = 0.25;
showDissipation = false;
colormapMin = -1.0f;
colormapMax = 1.0f;
minInundation = 0.001; // 1 mm
maxInundation = 1; // 1 m
}
};
struct TerrainTextureSetting{
int type;
bool autoColormap;
float colormapMin;
float colormapMax;
TerrainTextureSetting(){
type = 0; // 0 is SAND
autoColormap = true;
colormapMin = -1.0f;
colormapMax = 1.0f;
}
};
struct Lighting{
float ambientLight;
float sun_altitude; // in degrees
float sun_azimuth; // in degrees
Lighting(){
ambientLight = 1.0f;
sun_altitude = 45.0f;
sun_azimuth = 30.0f;
}
};
struct GraphicsSetting{
bool autoCam;
// If windows must be maximized
bool maximized;
SurfaceShadingSetting surfaceShading;
TerrainTextureSetting terrainTexture;
int skyboxType;
Lighting lighting;
bool gridOn;
float gridScale;
float verticalScale;
float fresnelCoef,refractive_index, att_1, att_2;
CameraSetting camera;
GraphicsSetting (){
autoCam = true;
maximized = false;
skyboxType = 0;
gridOn = true;
gridScale = 1.0f;
verticalScale = 1.0f;
fresnelCoef = 0.5f; refractive_index = 0.5f; att_1 = 0.5f; att_2 = 0.5f;
}
};
struct TideSurgeSLR{
bool autoValue;
float maxValue, minValue, setValue;
TideSurgeSLR(){
autoValue = true;
maxValue = +1;
minValue = -1;
setValue = 0;
}
};
enum TimeIntegrationScheme : signed int { euler, predictor, corrector, predictor_adaptive };
struct InitSetting {
//name
std::string project_name;
//Paths
std::string exePath;
std::string initCMLName;
std::string initWFileName;
std::string bathymetryFileName;
std::string westIrrWaveFileName, eastIrrWaveFileName;
std::string southIrrWaveFileName, northIrrWaveFileName;
bool rereadBathy;
TideSurgeSLR tideSurgeSLR;
std::string logPath;
//Model
bool isBoussinesq;
float epsilon;
float theta;
float friction;
int isManning; // 1 is manning, anything else is quadratic.
int correctionStepsNum;
float timestep;
// min_timestep_ratio*timestep is the minimum timestep targeted
// in the adaptive timestepping scheme.
float min_timestep_ratio;
float exponential_moving_average_alpha;
bool initialized_timesteps;
TimeIntegrationScheme time_scheme;
//Field
int nx;
int ny;
float width; //x direction
float length; // y direction
float stillWaterElevation;
//Boundaries
BoundarySetting westBoundary;
BoundarySetting eastBoundary;
BoundarySetting southBoundary;
BoundarySetting northBoundary;
//solitary waves
static const int MAX_NUM_SOLITARY = 100;
Soliton solitons[MAX_NUM_SOLITARY];
int countOfSolitons;
bool is_there_new_solitary_wave;
//Log
bool doLog;
int logStep;
static const int MAX_NUM_RANGE = 100;
Range logRange[MAX_NUM_RANGE];
int countOfRanges;
bool saveBathymetry, saveInundation;
static const int MAX_NUM_GAUGE = 1000;
std::string gaugesFilename;
Point logGauges[MAX_NUM_GAUGE];
int countOfGauges;
std::string timeAxisFilename;
float max_positive_bathy, min_negative_bathy, min_bathy;
GraphicsSetting graphics;
InitSetting(){
project_name = "NA";
//Paths
exePath = "NA";
initCMLName = "NA";
initWFileName = "NA";
bathymetryFileName = "NA";
westIrrWaveFileName = "NA"; eastIrrWaveFileName = "NA";
southIrrWaveFileName = "NA"; northIrrWaveFileName = "NA";
rereadBathy = true;
logPath = "NA";
//Model
isBoussinesq = true;
epsilon = 5e-8f;
theta = 2;
friction = 0;
isManning = 0; // 1 is manning, anything else is quadratic.
correctionStepsNum = 0;
timestep = 0.0001;
min_timestep_ratio = 0.05;
exponential_moving_average_alpha = 0.5;
initialized_timesteps = false;
time_scheme = predictor;
//Field
nx = 100;
ny = 100;
width = 100; //x direction
length = 100; // y direction
stillWaterElevation = 0;
//Boundaries
westBoundary = BoundarySetting ();
eastBoundary = BoundarySetting ();
southBoundary = BoundarySetting ();
northBoundary = BoundarySetting ();
//solitary waves
countOfSolitons = 0;
is_there_new_solitary_wave = false;
//Log
doLog = false;
logStep = 100;
countOfRanges = 0;
saveBathymetry = false;
saveInundation = false;
gaugesFilename = "gauges";
countOfGauges = 0;
timeAxisFilename = "time_axis";
max_positive_bathy = 0; min_negative_bathy = 0; min_bathy = 0;
}
~ InitSetting() {}
};
extern InitSetting & initSetting;
// global array of settings, 'null terminated'
extern Setting g_settings[];
// flag to communicate when the settings have changed
extern ResetType g_reset_type;
// helper functions
float GetSetting(const char * name);
inline float GetSetting(const std::string &s) { return GetSetting(s.c_str()); }
int GetIntSetting(const char *name);
void SetSetting(const char *name, float new_value);
void SetSettingMax(const char *name, float new_value);
void SetSettingMin(const char *name, float new_value);
inline void SetSettingD(const char *name, double val) { SetSetting(name, float(val)); }
#endif