DamBreak++ Wave Simulator 0.3
DamBreak++ Simulation Framework
Loading...
Searching...
No Matches
DamBreakSim.h
Go to the documentation of this file.
1
2#pragma once
3
4// File stream
5#include <fstream>
6#include <filesystem> //C++17 new feature
7// STL container
8#include <valarray>
9#include <vector>
10// VS19 include
12// SfxBase19 includes
13#include "include/Sfx_TimePrm.h"
14#include "include/Sfx_Utility.h"
15#include "include/Sfx_Simulator.h"
16// May 2015 include
17//#include "../May_VS2015/DamBreakData.h"
19// VS2019 includes
21
22#define SFX_DEBUG 0 // deprecated, set in the visual studio preprocessor
23
24// IMPORTANT (Nov 24)
25// this cause an error "error C2872: 'byte': ambiguous symbol" see comment below
26// The issue is that, since using namespace std imports the entire std namespace into the top-level one,
27// it is like defining stuff there, including the new byte type from C++17, then Windows headers also define byte so
28// byte is ambiguous because of the name collision. In general, you should not define anythng before including headers as it may cause such issues.
29//using namespace std; don't do that in a header file like thsi, included by other files it mess everything
30
37class DamBreakSim : public Sfx::Simulator,
38 public std::enable_shared_from_this<DamBreakSim>
39{
40 public:
45 {
46 SINE = 0,
47 STEP = 1
48 };
49 public:
54
56 ~DamBreakSim() = default;
57
62 DamBreakSim(const DamBreakSim & aOther) = delete;
63
69 DamBreakSim& operator= (const DamBreakSim & aOther) = delete;
70
71 //
72 // Simulator interface (base class)
73 //
74
76 void run() override final;
77
79 bool init() override final;
80
82 void unInitialize() override final {/*nothing to do*/ }
83
85 void dump( const std::filesystem::path& aFilePath /*const char* aFilename*/);
86
88 // void setH( float64 aValue);
89 const DBSArrayType getH() const noexcept { return mH;}
90
92 void setPhi1( float64 aValue) { mPhi1 = aValue;}
93 void setPhi0( float64 aValue) { mPhi0 = aValue;}
94
99 const float64 getPhi1() const { return mPhi1; }
104 const float64 getPhi0() const { return mPhi0; }
105
106 // ---------------REFACTORING--------------------------------
107 // All these methods shall be managed by the Simulation Manager
108 //
109
115 inline float64 getCFL() const { return mCFL;}
116 void setCFL( float64 aOther) { mCFL = aOther;}
121 float64 getCurrentTime() const { return mTime;}
126 float64 getTimeStep() { return m_Tip.Delta();}
131 uint32 currentIteration() { return m_Tip.getTimeStepNo();}
136 std::string getMethodName() { return mMethodName;}
141 void setMethodName( const std::string& aMethodName)
142 {
143 if( !mMethodName.empty())
144 {
145 mMethodName.clear();
146 mMethodName = aMethodName;
147 }
148 }
149
153 void setWorkingDir( std::filesystem::path aProjectPath) { m_currWrkDir = aProjectPath; }
158 bool isFlatBedTopography() const { return true; }
159
160 //eInitialWaveProfile getWaveInitialProfile() { return m_initialWaveProfile; }
175 std::shared_ptr<DamBreakSim> getDamBreakSim() { return shared_from_this(); }
176 private:
177
184 float64 mDx;
185
186 // StateVariables m_CurrentState; /**< state variables*/
188 int32 mReadpar;
189 // int32 mConditionArret;
190 // uint32 mNbIterations; //
192 // bool mUseFixedTimeStep; //
193 // float32 mMaxTimeStep; //
194 // float32 mLastTime; //
195 Sfx::SfxTimePrm m_Tip;
196
197 // flag for ???
200 // bool mUseGravity; /**< */
202
203 float64 mCFL;
204
205 // Time parameters
206 float64 mTime;
207
208 // Section width set to unity
209 float64 B;
210
211 float64 mL;
212 // int32 N; /**< number of grid points */
213// float64 uMax; /**< maximum wave amplitude */
214 float64 mDt;
215 //float64 CFLRatio; /**< Courant-Friedrichs-Lewy ratio tau/h */
216 float64 mS0am;
217 float64 mS0av;
218 float64 mPhi1;
219 float64 mPhi0;
220
221// enum {SINE, STEP}; /**< initial solution profile */
222 // int32 initialWaveform; /**< sine function, step, etc. */
224 std::ofstream mFileRes;
225 //const char* mStVenantOut;
226 std::string mStVenantOut;
227 //const char* mMethodName;
228 std::string mMethodName;
229 std::filesystem::path m_currWrkDir;
230 // Compute the time step for numerical stability
231 // float64 calculateDt();
232 // Physical boundary condition
233 void ImposePhysCnd();
234 // Save intermediate result in a file
235 void saveResult();
237 // list of cross-section
239 public:
244 void profilecmp( float64 aTime);
245
246 private:
252// void plotCurve( char* aOutFileName, const char* aInFileName = nullptr) const;
253
257 //void (*CalculFF)( ArrayType & aFF1, ArrayType & aFF2,
258 // const ArrayType & aU1, const ArrayType & aU2);
259
260 //using CalculFF = void (*)( DBSArrayType& aFF1, DBSArrayType& aFF2,
261 // const DBSArrayType& aU1, const DBSArrayType& aU2);
262
263 // Pointer 2 function
265};
void(*)(DBSArrayType &aFF1, DBSArrayType &aFF2, const DBSArrayType &aU1, const DBSArrayType &aU2) CalculFF
PointerToFunction(numerical flux computation)
Definition SimulationConfig.h:32
std::valarray< float64 > DBSArrayType
Definition SimulationConfig.h:22
bool isFlatBedTopography() const
Cross-section flow topography.
Definition DamBreakSim.h:158
void dump(const std::filesystem::path &aFilePath)
Save data in a file for visualizing.
Definition DamBreakSim.cpp:354
bool mSimRunning
Definition DamBreakSim.h:198
float64 mDt
Definition DamBreakSim.h:214
void setCFL(float64 aOther)
Definition DamBreakSim.h:116
int32 mNbIterMax
Definition DamBreakSim.h:191
DBSArrayType mH
Definition DamBreakSim.h:180
DamBreakSim & operator=(const DamBreakSim &aOther)=delete
assigning not allowed
std::string getMethodName()
Numerical scheme for the current simulation.
Definition DamBreakSim.h:136
DBSArrayType mU2
Definition DamBreakSim.h:179
float64 B
Definition DamBreakSim.h:209
eInitialWaveProfile
Definition DamBreakSim.h:45
@ STEP
Definition DamBreakSim.h:47
@ SINE
Definition DamBreakSim.h:46
DBSArrayType mX
Definition DamBreakSim.h:181
DBSArrayType mN
Definition DamBreakSim.h:183
float64 mCFL
Definition DamBreakSim.h:203
bool mUseFriction
Definition DamBreakSim.h:199
const DBSArrayType getH() const noexcept
Set/get water level height.
Definition DamBreakSim.h:89
bool mUseCompare
Definition DamBreakSim.h:201
void ImposePhysCnd()
Definition DamBreakSim.cpp:515
float64 mL
Definition DamBreakSim.h:211
float64 mTime
Definition DamBreakSim.h:206
DBSArrayType mZ
Definition DamBreakSim.h:182
DBSArrayType mU1
Definition DamBreakSim.h:178
float64 mDx
Definition DamBreakSim.h:184
std::string mStVenantOut
Definition DamBreakSim.h:226
Sfx::DamBreakData m_dbData
Definition DamBreakSim.h:236
int32 mNbSections
Definition DamBreakSim.h:187
void saveResult()
Definition DamBreakSim.cpp:380
eInitialWaveProfile m_initialWaveProfile
Definition DamBreakSim.h:223
std::filesystem::path m_currWrkDir
Definition DamBreakSim.h:229
void setMethodName(const std::string &aMethodName)
set method name of numerical scheme
Definition DamBreakSim.h:141
CalculFF m_calculFF
Display the result as a graph (post-script format) for visualization.
Definition DamBreakSim.h:264
const float64 getPhi0() const
Constant value in the initial setting of the Dam-Break problem.
Definition DamBreakSim.h:104
std::ofstream mFileRes
Definition DamBreakSim.h:224
float64 getTimeStep()
return time stepping
Definition DamBreakSim.h:126
float64 mS0am
Definition DamBreakSim.h:216
void setInitialCnd(eInitialWaveProfile aType)
Set/Get Initial profile.
Definition DamBreakSim.h:165
void unInitialize() override final
clean-upof the simulator
Definition DamBreakSim.h:82
uint32 currentIteration()
Current iteration of the simulation.
Definition DamBreakSim.h:131
float64 mPhi1
Definition DamBreakSim.h:218
float64 getCurrentTime() const
Returns the current time of the simulation.
Definition DamBreakSim.h:121
DamBreakSim(const DamBreakSim &aOther)=delete
copying not allowed
void setWorkingDir(std::filesystem::path aProjectPath)
Working directory (store result of simulation and ...)
Definition DamBreakSim.h:153
void run() override final
Definition DamBreakSim.cpp:102
std::string mMethodName
Definition DamBreakSim.h:228
DamBreakSim()
Default ctor.
Definition DamBreakSim.cpp:46
void setPhi0(float64 aValue)
Definition DamBreakSim.h:93
Sfx::SfxTimePrm m_Tip
Definition DamBreakSim.h:195
const float64 getPhi1() const
Constant value in the initial setting of the Dam-Break problem.
Definition DamBreakSim.h:99
int32 mReadpar
Definition DamBreakSim.h:188
void profilecmp(float64 aTime)
Plot profile of the water depth (exact/computed) at a given time.
Definition DamBreakSim.cpp:598
dbpp::ListSectionsFlow m_listDamBreak
Definition DamBreakSim.h:238
float64 mPhi0
Definition DamBreakSim.h:219
~DamBreakSim()=default
Force destructor to be virtual.
bool init() override final
Some initialization of the simulator.
Definition DamBreakSim.cpp:420
float64 getCFL() const
Courant-Friedrich-Levy number of the simulation.
Definition DamBreakSim.h:115
void setPhi1(float64 aValue)
Initial values (water level) imposed on the left and right side of DAM.
Definition DamBreakSim.h:92
std::shared_ptr< DamBreakSim > getDamBreakSim()
share the ownership of 'this' with all existing std::shared_ptr that refer to *this.
Definition DamBreakSim.h:175
eInitialWaveProfile getInitialType() const
Initial wave profile.
Definition DamBreakSim.h:170
float64 mS0av
Definition DamBreakSim.h:217
Hold data for validation. Two type: EMcneil, Hudson (DamBreak config)
Definition Sfx_DamBreakData.h:17
List of cross-section flow (itereable)
Definition dbpp_ListSectionsFlow.h:15