DamBreak++ Wave Simulator 0.3
DamBreak++ Simulation Framework
Loading...
Searching...
No Matches
Testvs19_Wave1DSimulator.h
Go to the documentation of this file.
1
2#pragma once
3
4// C/C++ includes
5#include <stdio.h>
6//#include <string.h>
7#include <string>
8#include <tuple>
9#include <utility>
10#include <filesystem>
11// stl include
12#include <list>
13// numeric include
14#include <valarray>
15// SfxBase19 library includes
16#include "include/Sfx_DefineTypes.h"
17#include "include/Sfx_Simulator.h"
18#include "include/Sfx_Observer.h"
19
20// forward declarations
21namespace Sfx { class WaveFunc; }
22namespace dbpp {
23 class DamBreakProblem;
24 class ListSectionsFlow;
25}
26
27namespace Testvs19
28{
29 // Reference
30 // "How To Export C++ Classes From a DLL", Alex Blekhman, 13 nov 2012
31 // Code Project web site
32 //
33 // Very important to read and understand this article, because it's breath and butter
34 // of COM approach (create a factory that return pointer to base abstract type).
35 // Wave1DSimulator is nothing else than a POM/COM which is not exported. Actually it
36 // implements an interface (pure abstract class) like jb_ClassDll
37
38
42 class Wave1DSimulator : public Sfx::Simulator,
43 public virtual Sfx::Observer,
44 public std::enable_shared_from_this<Wave1DSimulator>
45 {
47 using WaveFuncPtr = std::shared_ptr<Sfx::WaveFunc>;
49 using ListSectPtr = std::shared_ptr<dbpp::ListSectionsFlow>;
50 public:
54 enum class eIC
55 {
57 Hudson = 1
58 };
59
62 enum class eSimulationState
63 {
67 };
68 public:
74 Wave1DSimulator( int aNbIterationsMax=50, double aCFL=0.6);
79 Wave1DSimulator( const Wave1DSimulator& aOther) = delete;
85 Wave1DSimulator&operator= (const Wave1DSimulator& aOther) = delete;
89 void run() override final;
94 bool init() override final;
98 void unInitialize() override final {/*nothing to do*/ }
102 virtual void timeLoop();
107 void setActiveAlgortihm( std::string aAlgoName) noexcept { m_activeAlgo = aAlgoName;}
112 std::string getactiveAlgorithm() const noexcept { return m_activeAlgo;}
117 void setValidationDir( const std::filesystem::path& aValidationDir) noexcept
118 {m_validationDir = aValidationDir;}
119
123 std::filesystem::path getValidationDir() const noexcept { return m_validationDir;}
128 void setSaveResult2File( bool saveResult) noexcept { m_saveResult2File=saveResult;}
133 bool isSaveResult2File() const noexcept { return m_saveResult2File;}
138 void setIterationNumberMax( unsigned aNumMaxIter) noexcept {m_NumberIterationsMax=aNumMaxIter;}
143 uint32 getNumberIterationsMax() const noexcept { return m_NumberIterationsMax;}
148 void setCFL( float64 aCFl) noexcept {m_CFL=aCFl;}
153 float64 getCFL() const noexcept {return m_CFL;}
158 void setPhi1(float64 aPhi1) noexcept {m_Phi1=aPhi1;}
163 float64 getPhi1() const noexcept {return m_Phi1;}
168 void setPhi0( float64 aPhi0) noexcept {m_Phi0=aPhi0;}
173 float64 getPhi0() const noexcept{return m_Phi0;}
174 // not usre about this one
175 float64 getFinalTime() const { return m_finalTime;}
176 // not sure still needed (???)
177 void update() override final;
182 void solveProblem( const dbpp::DamBreakProblem& aDBprob);
187 std::valarray<float64> getH() const noexcept
188 {
189 return std::valarray<float64>(m_waveDepthProfile.data(), m_waveDepthProfile.size());
190 }
191
195 std::shared_ptr<Wave1DSimulator> sharedPtrTo() { return shared_from_this(); }
196 private:
197 WaveFuncPtr m_H{nullptr};
198 WaveFuncPtr m_I{ nullptr };
200 std::vector<float64> m_waveDepthProfile;
201 float64 m_CFL; // deprecated
202 std::string m_activeAlgo;
203 std::filesystem::path m_validationDir;
206 float64 m_Phi1; // deprecated
207 float64 m_Phi0; // deprecated
208 float64 m_finalTime;
210 };
211} // End of namespace
Wave1DSimulator(int aNbIterationsMax=50, double aCFL=0.6)
float64 getPhi1() const noexcept
dambreak parameters (wave profile values)
Definition Testvs19_Wave1DSimulator.h:163
std::shared_ptr< dbpp::ListSectionsFlow > ListSectPtr
Definition Testvs19_Wave1DSimulator.h:49
Wave1DSimulator & operator=(const Wave1DSimulator &aOther)=delete
not allowed to assignment
uint32 getNumberIterationsMax() const noexcept
number of iterations for this simulation
Definition Testvs19_Wave1DSimulator.h:143
float64 m_CFL
Definition Testvs19_Wave1DSimulator.h:201
eSimulationState
Definition Testvs19_Wave1DSimulator.h:63
@ running
Definition Testvs19_Wave1DSimulator.h:64
@ pause
Definition Testvs19_Wave1DSimulator.h:65
@ stop
Definition Testvs19_Wave1DSimulator.h:66
float64 m_Phi0
Definition Testvs19_Wave1DSimulator.h:207
Wave1DSimulator(const Wave1DSimulator &aOther)=delete
not allowed to copy
void setPhi1(float64 aPhi1) noexcept
dambreak parameters (wave profile values)
Definition Testvs19_Wave1DSimulator.h:158
std::valarray< float64 > getH() const noexcept
water depth at global nodal point
Definition Testvs19_Wave1DSimulator.h:187
bool init() override final
Initialization of the simulator.
Definition Testvs19_Wave1DSimulator.cpp:115
void setCFL(float64 aCFl) noexcept
Courant-Friedrich-Levy Number (stability criteria)
Definition Testvs19_Wave1DSimulator.h:148
float64 getCFL() const noexcept
Courant-Friedrich-Levy Number (stability criteria)
Definition Testvs19_Wave1DSimulator.h:153
WaveFuncPtr m_H
Definition Testvs19_Wave1DSimulator.h:197
std::filesystem::path m_validationDir
Definition Testvs19_Wave1DSimulator.h:203
unsigned int m_NumberIterationsMax
Definition Testvs19_Wave1DSimulator.h:205
void setSaveResult2File(bool saveResult) noexcept
flag to set if data is to be saved to file
Definition Testvs19_Wave1DSimulator.h:128
virtual void timeLoop()
Simulation time loop.
Definition Testvs19_Wave1DSimulator.cpp:414
void setValidationDir(const std::filesystem::path &aValidationDir) noexcept
directory to store data
Definition Testvs19_Wave1DSimulator.h:117
std::string getactiveAlgorithm() const noexcept
name of numerical flux algorithm
Definition Testvs19_Wave1DSimulator.h:112
float64 m_Phi1
Definition Testvs19_Wave1DSimulator.h:206
float64 getPhi0() const noexcept
dambreak parameters (wave profile values)
Definition Testvs19_Wave1DSimulator.h:173
void solveProblem(const dbpp::DamBreakProblem &aDBprob)
Solve Dam Break problem.
Definition Testvs19_Wave1DSimulator.cpp:198
void setPhi0(float64 aPhi0) noexcept
dambreak parameters (wave profile values)
Definition Testvs19_Wave1DSimulator.h:168
std::string m_activeAlgo
Definition Testvs19_Wave1DSimulator.h:202
ListSectPtr m_ListSectFlow
Definition Testvs19_Wave1DSimulator.h:199
void setIterationNumberMax(unsigned aNumMaxIter) noexcept
number of iterations for this simulation
Definition Testvs19_Wave1DSimulator.h:138
float64 getFinalTime() const
Definition Testvs19_Wave1DSimulator.h:175
WaveFuncPtr m_I
Definition Testvs19_Wave1DSimulator.h:198
eIC
Definition Testvs19_Wave1DSimulator.h:55
@ Hudson
Definition Testvs19_Wave1DSimulator.h:57
@ EMcNeil
Definition Testvs19_Wave1DSimulator.h:56
bool isSaveResult2File() const noexcept
Save result to file.
Definition Testvs19_Wave1DSimulator.h:133
void update() override final
Definition Testvs19_Wave1DSimulator.cpp:177
std::vector< float64 > m_waveDepthProfile
Definition Testvs19_Wave1DSimulator.h:200
std::shared_ptr< Wave1DSimulator > sharedPtrTo()
share the ownership of 'this' with all existing std::shared_ptr that refer to *this.
Definition Testvs19_Wave1DSimulator.h:195
bool m_saveResult2File
Definition Testvs19_Wave1DSimulator.h:204
void run() override final
Main loop of the simulation.
Definition Testvs19_Wave1DSimulator.cpp:217
std::shared_ptr< Sfx::WaveFunc > WaveFuncPtr
Definition Testvs19_Wave1DSimulator.h:47
float64 m_finalTime
Definition Testvs19_Wave1DSimulator.h:208
void unInitialize() override final
clean-upof the simulator
Definition Testvs19_Wave1DSimulator.h:98
eIC m_IC
Definition Testvs19_Wave1DSimulator.h:209
void setActiveAlgortihm(std::string aAlgoName) noexcept
name of numerical flux algorithm
Definition Testvs19_Wave1DSimulator.h:107
std::filesystem::path getValidationDir() const noexcept
folder to save data
Definition Testvs19_Wave1DSimulator.h:123
The DAM-BREAK Problem class is a model of a well-posed problem.
Definition DamBreakProb.h:37
List of cross-section flow (itereable)
Definition dbpp_ListSectionsFlow.h:15
Definition HydUtils.h:15
Definition Testvs19_BaseRhsPhysicsAlgorithm.cpp:19
Definition DamBreakProb.h:15