DamBreak++ Wave Simulator 0.3
DamBreak++ Simulation Framework
Loading...
Searching...
No Matches
Sfx_DamBreakData.h
Go to the documentation of this file.
1#pragma once
2
3#include <cassert>
4// // C++ includes
5#include <iostream>
6#include <utility>
7#include <string>
8// // STL include
9#include <vector>
10// SfxBase19 include
11#include "include/Sfx_DefineTypes.h"
12
13namespace Sfx
14{
16 class DamBreakData final
17 {
18 public:
19 using pairofloat64 = std::pair<float64, float64>;
23 enum class eDataTypes
24 {
25 emcneil = 0,
26 hudson = 1
27 };
28
32 explicit DamBreakData( eDataTypes aDiscrType = eDataTypes::emcneil) : m_discrType{ aDiscrType }
33 {
35 {
37 }
38 else
39 {
41 }
42 }
43
47 DamBreakData( std::string aDataType) // pass by copy?? move?
48 {
49 // only 2 supported for now
50 if (std::string{"emcneildata"} == aDataType)
51 {
53 }
54 else
55 {
57 }
58 }
59
64 float64 x_min() const noexcept { return m_Xmin; }
69 float64 x_max() const noexcept { return m_Xmax; }
70 // std::vector<float64> Xcoord() const { return m_X; }
71 // does it use move semantic for this return?
72 //std::vector<float64> Xcoord() const { return std::vector<float64>(&X[0], &X[0] + m_NbSects); }
73 float64 getS0am() const noexcept { return m_S0am; }
74 float64 getS0av() const noexcept { return m_S0av; }
79 float64 getCFL() const noexcept { return m_cfl; }
84 float64 dX() const noexcept { return m_dX; }
85 int32 nbSections() const noexcept { return m_NbSects; }
90 float64 getPhi0() const noexcept { return m_Phi0; }
95 float64 getPhi1() const noexcept { return m_Phi1; }
100 float64 getWidth() const noexcept { return m_sectWidth; }
105 float64 getShockLocation() const noexcept { return m_shockLocation; }
110 pairofloat64 domainExtent() const noexcept { return m_domainExtent; }
115 pairofloat64 dambreakExtent() const noexcept { return m_dambreakExtent; }
120 eDataTypes getDiscrType() const noexcept { return m_discrType; }
125 bool isUnitSectionWidth() const noexcept { return m_unitSectWidth; }
130 bool isFrictionLess() const noexcept { return m_frictionLess; }
135 bool isFlatBed() const noexcept { return m_flatBed; }
141 std::string toString(eDataTypes aDisc) noexcept
142 {
143 if (aDisc == eDataTypes::emcneil)
144 {
145 return std::string("d=1 [0,1000] [1:100]");
146 }
147 else if (aDisc == eDataTypes::hudson)
148 {
149 return std::string("d=1 [0,1] [1:10]");
150 }
151 else
152 {
153 // Sfx::Logger::instance()->OutputError("Discretization not supported");
154 return std::string{};
155 }
156 }
157
162 std::string toString(eDataTypes aDisc) const noexcept
163 {
164 if (aDisc == eDataTypes::emcneil)
165 {
166 return std::string("d=1 [0,1000] [1:100]");
167 }
168 else if (aDisc == eDataTypes::hudson)
169 {
170 return std::string("d=1 [0,1] [1:10]");
171 }
172 else
173 {
174 //Sfx::Logger::instance()->OutputError("Discretization not supported");
175 return std::string{};
176 }
177 }
178
179 private:
183 float64 m_S0am;
184 float64 m_S0av;
185 float64 m_dX;
186 float64 m_Phi0;
187 float64 m_Phi1;
188 float64 m_cfl;
189 int32 m_NbSects;
190 float64 m_Xmin;
191 float64 m_Xmax;
192 float64 m_sectWidth;
197
201 void setEMcNeilParams() noexcept
202 {
203 // configure the simulation property.
204 m_S0am = 0.; // ...
205 m_S0av = 0.; // ...
206 m_Phi1 = 10.; // water level at upstream
207 m_Phi0 = 1.; // water level at downstream
208 //m_cfl = 0.6; this is a simulation parameter and handle by SimulationMgr class
209 m_sectWidth = 1.; //
210 m_NbSects = 101; // number of sections
211 m_Xmin = 0.; // x-coordinate of the left bound. node
212 m_Xmax = 1000.; // x-coordinate of the right bound. node
213 m_domainExtent.first = m_Xmin; // ...
214 m_domainExtent.second = m_Xmax; // ...
215 m_dambreakExtent.first = m_Phi0; // dam-break water level at downstream
216 m_dambreakExtent.second = m_Phi1; // dam-break water level at upstream
217 m_shockLocation = 500.;
218 m_unitSectWidth = true; //
219 m_frictionLess = true;
220 m_flatBed = true;
221 assert(m_Xmin < m_Xmax);
222 // spatial step
223 m_dX = 10.; // no point to calculate that,
224 // (m_Xmax - m_Xmin) / boost::numeric_cast<float64>(m_NbSects - 1);
225 assert(m_Phi0 < m_Phi1);
226 assert(m_dX != 0.);
227 }
228
231 void setHudsonParams() noexcept
232 {
233 m_S0am = 0.; // ...
234 m_S0av = 0.; // ...
235 m_Phi1 = 1.; // water level at upstream
236 m_Phi0 = 0.5; // water level at downstream
237 //m_cfl = 0.6; this is a simulation parameter and handle by SimulationMgr class
238 m_sectWidth = 1.; //
239 m_NbSects = 101; // number of sections
240 m_Xmin = 0.; // x-coordinate of the left bound. node
241 m_Xmax = 1.; // x-coordinate of the right bound. node
242 m_domainExtent.first = m_Xmin; // ...
243 m_domainExtent.second = m_Xmax; // ...
244 m_dambreakExtent.first = m_Phi0; // dam-break water level at downstream
245 m_dambreakExtent.second = m_Phi1; // dam-break water level at upstream
246 m_shockLocation = 0.5;
247 m_unitSectWidth = true; //
248 m_frictionLess = true;
249 m_flatBed = true;
250 assert(m_Xmin < m_Xmax);
251 // spatial step
252 m_dX = 0.01; // no point to calculate that,
253 // (m_Xmax - m_Xmin) / boost::numeric_cast<float64>(m_NbSects - 1);
254 assert(m_Phi0 < m_Phi1);
255 assert(m_dX != 0.);
256 }
257
262 {
263 switch (m_discrType)
264 {
266 {
268 break;
269 }
271 {
273 break;
274 }
275 default:
276 std::cerr << "Discretization not supported yet\n";
277 break;
278 }
279 }
280 };
281} // End of namespace
float64 m_Phi1
Definition Sfx_DamBreakData.h:187
float64 m_shockLocation
Definition Sfx_DamBreakData.h:193
eDataTypes m_discrType
Definition Sfx_DamBreakData.h:180
float64 x_min() const noexcept
domain extent
Definition Sfx_DamBreakData.h:64
eDataTypes getDiscrType() const noexcept
Type of DamBeak data.
Definition Sfx_DamBreakData.h:120
float64 getPhi0() const noexcept
water level right side of the dam
Definition Sfx_DamBreakData.h:90
DamBreakData(std::string aDataType)
Definition Sfx_DamBreakData.h:47
eDataTypes
Definition Sfx_DamBreakData.h:24
@ hudson
Definition Sfx_DamBreakData.h:26
@ emcneil
Definition Sfx_DamBreakData.h:25
float64 x_max() const noexcept
domain extent
Definition Sfx_DamBreakData.h:69
bool isFrictionLess() const noexcept
use friction
Definition Sfx_DamBreakData.h:130
int32 nbSections() const noexcept
Definition Sfx_DamBreakData.h:85
float64 getPhi1() const noexcept
water level left side of the dam
Definition Sfx_DamBreakData.h:95
bool m_unitSectWidth
Definition Sfx_DamBreakData.h:194
std::pair< float64, float64 > pairofloat64
Definition Sfx_DamBreakData.h:19
float64 m_Phi0
Definition Sfx_DamBreakData.h:186
std::string toString(eDataTypes aDisc) noexcept
string representation of spatial discretization
Definition Sfx_DamBreakData.h:141
float64 getShockLocation() const noexcept
location of the shock
Definition Sfx_DamBreakData.h:105
float64 m_Xmax
Definition Sfx_DamBreakData.h:191
float64 getS0av() const noexcept
Definition Sfx_DamBreakData.h:74
float64 dX() const noexcept
spatial step
Definition Sfx_DamBreakData.h:84
std::string toString(eDataTypes aDisc) const noexcept
string representation of spatial discretization
Definition Sfx_DamBreakData.h:162
void setEMcNeilParams() noexcept
E. McNeil data.
Definition Sfx_DamBreakData.h:201
float64 m_cfl
Definition Sfx_DamBreakData.h:188
float64 m_dX
Definition Sfx_DamBreakData.h:185
void setDiscrType()
Discretization type.
Definition Sfx_DamBreakData.h:261
float64 m_S0am
Definition Sfx_DamBreakData.h:183
pairofloat64 dambreakExtent() const noexcept
DamBreak init config (water level)
Definition Sfx_DamBreakData.h:115
float64 getWidth() const noexcept
section width
Definition Sfx_DamBreakData.h:100
bool isFlatBed() const noexcept
type of bathymetry
Definition Sfx_DamBreakData.h:135
int32 m_NbSects
Definition Sfx_DamBreakData.h:189
float64 m_sectWidth
Definition Sfx_DamBreakData.h:192
bool isUnitSectionWidth() const noexcept
type of section geometry
Definition Sfx_DamBreakData.h:125
bool m_frictionLess
Definition Sfx_DamBreakData.h:195
float64 m_S0av
Definition Sfx_DamBreakData.h:184
pairofloat64 m_domainExtent
Definition Sfx_DamBreakData.h:181
bool m_flatBed
Definition Sfx_DamBreakData.h:196
void setHudsonParams() noexcept
Hudson data.
Definition Sfx_DamBreakData.h:231
DamBreakData(eDataTypes aDiscrType=eDataTypes::emcneil)
Definition Sfx_DamBreakData.h:32
float64 getS0am() const noexcept
Definition Sfx_DamBreakData.h:73
pairofloat64 m_dambreakExtent
Definition Sfx_DamBreakData.h:182
pairofloat64 domainExtent() const noexcept
spatial domain ectent
Definition Sfx_DamBreakData.h:110
float64 m_Xmin
Definition Sfx_DamBreakData.h:190
float64 getCFL() const noexcept
Courant-Friedrich-Levy number.
Definition Sfx_DamBreakData.h:79
Definition HydUtils.h:15