DamBreak++ Wave Simulator 0.3
DamBreak++ Simulation Framework
Loading...
Searching...
No Matches
Sfx_SimulationMgr.h
Go to the documentation of this file.
1
2#pragma once
3
4// C++ include
5#include <string>
6// STL associative container
7#include <map>
8// SfxBase19 library includes
9#include "include/Sfx_Singleton.hpp" // Singleton implementation
11// Elligno includes
12#include "DamBreakSim.h" // Dam Break Simulator
13// VS19 includes
14#include "../../Nov_VS2019/PhysicsAlgorithm/Testvs19_ListSectionsFlow.hpp"
17
18namespace Sfx
19{
23 using mapFluxSchemeName = std::map<std::string, CalculFF>;
24
30 class SimulationMgr : public SfxSingleton<SimulationMgr>
31 {
32 protected:
40 ~SimulationMgr() = default;
45 SimulationMgr(const SimulationMgr& aOther) = delete;
50 SimulationMgr& operator= (const SimulationMgr& aOther) = delete;
51 public:
55 enum class eInitialWaveProfile {
58 };
59
62 enum class eRiverBedType
63 {
64 FLATBED = 0,
65 ONESTEP = 1,
66 HYDJUMP = 2,
67 RANDOM = 3
68 };
69
77
82 template<typename> friend class SfxSingleton;
86 void updateTime() {/*not implemented*/ }
90 void setStartTime(float64 aStartTime) noexcept { m_startTime = aStartTime; }
95 void setStopTime( float64 aStopTime) noexcept { m_stopTime = aStopTime; }
100 void setNumTimeStep(uint32 aNumTimeStep) noexcept { m_NumTimeStep = aNumTimeStep; }
105 float64 getStartTime() const noexcept { return m_startTime; }
110 float64 getStopTime() const noexcept { return m_stopTime; }
115 float64 getTime() noexcept { return m_startTime += getTimeStep(); }
120 void setTimeStep(const float64 aTimeStep) noexcept { m_TimeStep = aTimeStep; }
125 float64 getTimeStep() noexcept { return m_TimeStep; }
130 bool useFixedTimeStep() noexcept { return m_UseFixedTimeStep; }
131
132 // Pause the simulation
133// void paused();
134// bool isPaused();
140 bool onStart();
146 void registerSimulator( std::shared_ptr<Sfx::Simulator> aSim) { m_DamSim = aSim;}
151 void setTolerance( float32 aTolerance) { m_Tol = aTolerance;}
156 float32 getTolerance() { return m_Tol;}
157 // Returns the current time of the simulation (temporary fix)
158 //float64 getCurrentTime() const { return m_DamSim->getCurrentTime();}
164 std::shared_ptr<Sfx::Simulator> getSimulator() const { return m_DamSim;} // temporary fix, will be removed
169 void setNujicAlphaCoeff(float64 aAlphaCoeff) { m_alphaCoeff = aAlphaCoeff;}
174 float64 getNujicAlphaCoeff() const { return m_alphaCoeff; }
179 inline float64 getCFL() const noexcept { return m_CFL;}
184 void setCFL( const float64 aCFL) noexcept { m_CFL = aCFL;}
189 bool useFriction() const noexcept { return m_useFriction; }
194 void setUseFriction(bool aUseFriction) noexcept { m_useFriction = aUseFriction; }
199 bool useFlatBed() const noexcept { return m_useFlatBed; }
204 void setUseFlatBed(bool aUseFlatBed) noexcept { m_useFlatBed = aUseFlatBed; }
209 bool isUnitWidth() const noexcept { return m_isUnitWidth; }
214 void setManningCoeff(float64 aNcoeff) noexcept { m_frictionValue = aNcoeff; }
219 float64 getManningCoeff() const noexcept { return m_frictionValue; }
220
221 void setUseSourceTerms(bool aUseSrcTerms) noexcept { m_useSourceTerms = aUseSrcTerms; }
222 bool getUseSourceTerms() const noexcept { return m_useSourceTerms; }
223 bool usePressure() const noexcept { return m_usePressure; }
224 void setUsePressure(bool aUsePressure) noexcept { m_usePressure = aUsePressure; }
225 void setUseReconstruction(bool aUseReconstr) noexcept { m_useReconstruction = aUseReconstr; }
226 bool useReconstruction() const noexcept { return m_useReconstruction; }
231 bool isRunning() const noexcept { return m_simRunning; }
236 void setRunning(bool aIsRunning = true) { m_simRunning = aIsRunning; }
240 void startSimulation() noexcept { m_simRunning = true; }
244 void stopSimulation() noexcept { m_simRunning = false; }
249 void setNbIterationsMax(uint32 aNumOfIterMax) noexcept { m_NbIterMax = aNumOfIterMax; }
254 uint32 getNbIterationsMax() const noexcept { return m_NbIterMax; }
258 void incrIteration() noexcept { ++m_NbIterations; }
263 uint32 getNbIterations() const noexcept { return m_NbIterations; }
268 void setNbIterations(uint32 aNumOfIterations) noexcept { m_NbIterations = aNumOfIterations; }
272 void saveScenario() {/*not implemented yet*/ }
277 void loadSections( std::string_view aFileName = "SectionIni.txt") {/*not implemented yet*/ }
283 {
284 // when loading simulation set parameters from reading file
285 m_dbDataType = aType;
286 }
287
291 float64 getPhi0() const noexcept { return m_phi0; }
296 float64 getPhi1() const noexcept { return m_phi1; }
301 void setPhi1(float64 aPhi1) noexcept { m_phi1 = aPhi1; }
306 void setPhi0(float64 aPhi0) noexcept { m_phi0 = aPhi0; }
307
308 // default set to E. McNeil data type
310
311 // that's what we need in many places (temporary fix, this class will be re-factored)
312 // depemnds on array type, need to fix that
313 std::string getDBdataTypeStr() const noexcept
314 {
316 {
317 return std::string{ "d=1 [0,1] [0:99]" };
318 }
319 else
320 {
321 return std::string{ "d=1 [0,1000] [0:99]" };
322 }
323 }
324
328 std::string getAlgorithmName() const { return m_MethodName;}
329 void setMethodName( const std::string& aMethodName) { m_MethodName = aMethodName;}
334 std::string getPtrFluxAlgorithmName() const noexcept { return m_methodName; }
339 void setPtrFluxAlgorithmName(const std::string& aMethodName) { m_methodName = aMethodName; }
345 CalculFF getPtr2FAlgorithm( const std::string& aMethodName);
360 const std::vector<float64>& getBottom() const { return std::vector<double>(101);/*m_Z*/; }
365 //const std::vector<float64>& getManning() const { return std::vector<double>(101); /*m_N*/; }
369 // void readParams();
373 void setupEnvironment();
377 void printParamOfRun() const;
382 void setNbSections(uint32 aNbSections) noexcept { m_NbSections = aNbSections; }
387 uint32 getNbSections() const noexcept {return m_NbSections;}
392 void setSectionType(dbpp::SectionFlow::eSectionType aSectype) noexcept { m_sectionType = aSectype; }
402 void setDomainExtent(std::pair<float64, float64> aDomainExt) noexcept { m_domainExtent = aDomainExt; }
407 std::pair<float64, float64> getDomainExtent() const noexcept { return m_domainExtent; }
412 void setBottomType( const eRiverBedType aBottomType) noexcept { m_bottomType = aBottomType; }
417 eRiverBedType getBottomType() const noexcept { return m_bottomType; }
422 void setFrictionValue(float64 aFrictionType) noexcept { m_frictionValue = aFrictionType; }
427 float64 getFrictionValue() const noexcept { return m_frictionValue; }
432 void setBCType( const ePhysicalBCType aBCType) noexcept { m_physBCType = aBCType; }
433 ePhysicalBCType getBCType() const noexcept { return m_physBCType; }
450 { m_dbSystem = aDbSys; }
451
455 std::vector<float64> getWaterDepth() const { return m_dbSystem->getH(); }
456 private :
457 std::shared_ptr<Sfx::Simulator> m_DamSim;
460 // Initial profile type
461 //enum eInitialType{SINE, STEP}; initial solution profile
462 // eInitialWaveProfile m_InitialWaveform; /**< */ // sine function, step, etc.
463 float32 m_Tol;
464 float64 m_CFL;
465 float64 m_phi0;
466 float64 m_phi1;
467 // sint32 m_ReadPar; /**< Flag for reading the parameters from a file*/
469 // uint32 m_NumIterations;
471 float64 m_TimeStep;
480 float64 m_startTime;
481 float64 m_stopTime;
483 float64 m_LastTime;
485 float64 m_alphaCoeff;
486 std::string m_MethodName;
487 std::string m_StVenantOut;
488 std::map<std::string, CalculFF> m_ptr2FuncAlgo;
489 // ListofSectionsFlow m_listsectionFlow{ nullptr };
491 bool m_useFlatBed; // flag (default value is true)
492 bool m_isUnitWidth; // section of unit width (default value is true)
493 // default value is trues
494 // bool m_useFinalreport;
495 // ...
497 // measurement on the physical system
498 // bool m_performMeasurement;
499
500 // number of physical measurement on the physical system
501 //int32 m_numberOfMeasurement;
502
503 // Name of the current method
504 std::string m_methodName;
509 std::pair<float64,float64> m_domainExtent;
510 std::pair<float64,float64> m_dambreakExtent;
515 // void LoadData( std::string_view aFileName);
516 };
517} //End of namespace
void(*)(DBSArrayType &aFF1, DBSArrayType &aFF2, const DBSArrayType &aU1, const DBSArrayType &aU2) CalculFF
PointerToFunction(numerical flux computation)
Definition SimulationConfig.h:32
eDataTypes
Definition Sfx_DamBreakData.h:24
@ hudson
Definition Sfx_DamBreakData.h:26
bool getUseSourceTerms() const noexcept
Definition Sfx_SimulationMgr.h:222
dbpp::SectionFlow::eSectionType getSectionType() const noexcept
Getter.
Definition Sfx_SimulationMgr.h:397
bool m_useReconstruction
Definition Sfx_SimulationMgr.h:476
uint32 m_StateVarCount
Definition Sfx_SimulationMgr.h:472
SimulationMgr(const SimulationMgr &aOther)=delete
copy not allowed
void incrIteration() noexcept
increment the number of iteration
Definition Sfx_SimulationMgr.h:258
bool usePressure() const noexcept
Definition Sfx_SimulationMgr.h:223
void setNumTimeStep(uint32 aNumTimeStep) noexcept
Set the number of time-step.
Definition Sfx_SimulationMgr.h:100
void setFrictionValue(float64 aFrictionType) noexcept
Set section flow friction value.
Definition Sfx_SimulationMgr.h:422
std::string m_methodName
Definition Sfx_SimulationMgr.h:504
std::string getDBdataTypeStr() const noexcept
Definition Sfx_SimulationMgr.h:313
void setUseSourceTerms(bool aUseSrcTerms) noexcept
Definition Sfx_SimulationMgr.h:221
void setNbIterationsMax(uint32 aNumOfIterMax) noexcept
Definition Sfx_SimulationMgr.h:249
bool useFriction() const noexcept
Friction flag ON?OFF.
Definition Sfx_SimulationMgr.h:189
void setDomainExtent(std::pair< float64, float64 > aDomainExt) noexcept
Set computational domain extent.
Definition Sfx_SimulationMgr.h:402
float64 getManningCoeff() const noexcept
Manning coefficient.
Definition Sfx_SimulationMgr.h:219
std::shared_ptr< Sfx::Simulator > getSimulator() const
Returns simulator instance.
Definition Sfx_SimulationMgr.h:164
void setCFL(const float64 aCFL) noexcept
Set CFL number.
Definition Sfx_SimulationMgr.h:184
float64 m_MaxTimeStep
Definition Sfx_SimulationMgr.h:482
std::shared_ptr< Sfx::Simulator > m_DamSim
Definition Sfx_SimulationMgr.h:457
bool m_simRunning
Definition Sfx_SimulationMgr.h:496
eRiverBedType getBottomType() const noexcept
Getter.
Definition Sfx_SimulationMgr.h:417
SimulationMgr & operator=(const SimulationMgr &aOther)=delete
assignment not allowed
float64 getPhi1() const noexcept
Dam Break problem initial water depth downstream.
Definition Sfx_SimulationMgr.h:296
std::pair< float64, float64 > getDomainExtent() const noexcept
Getter.
Definition Sfx_SimulationMgr.h:407
float64 getTime() noexcept
Getter.
Definition Sfx_SimulationMgr.h:115
float64 m_phi1
Definition Sfx_SimulationMgr.h:466
eFrictionType
Definition Sfx_SimulationMgr.h:72
@ FrictionValue
Definition Sfx_SimulationMgr.h:72
@ NoFriction
Definition Sfx_SimulationMgr.h:72
eInitialWaveProfile
Initial wave profile.
Definition Sfx_SimulationMgr.h:55
@ STEP
Definition Sfx_SimulationMgr.h:57
@ SINE
Definition Sfx_SimulationMgr.h:56
void printParamOfRun() const
Print the parameters of run for this simulation.
Definition Sfx_SimulationMgr.cxx:151
float32 m_Tol
Definition Sfx_SimulationMgr.h:463
bool useReconstruction() const noexcept
Definition Sfx_SimulationMgr.h:226
bool m_UseFixedTimeStep
Definition Sfx_SimulationMgr.h:479
void registerSimulator(std::shared_ptr< Sfx::Simulator > aSim)
Set instance of simulator.
Definition Sfx_SimulationMgr.h:146
void setNujicAlphaCoeff(float64 aAlphaCoeff)
Coefficient used in the numerical flux algorithm (Nujic)
Definition Sfx_SimulationMgr.h:169
void setUseReconstruction(bool aUseReconstr) noexcept
Definition Sfx_SimulationMgr.h:225
std::string getAlgorithmName() const
Flux Numerical algorithm name for the current simulation.
Definition Sfx_SimulationMgr.h:328
float64 getNujicAlphaCoeff() const
Nujic coefficent use in Numerical flux calculation.
Definition Sfx_SimulationMgr.h:174
float64 m_CFL
Definition Sfx_SimulationMgr.h:464
float64 getPhi0() const noexcept
Dam Break problem initial water depth upstream.
Definition Sfx_SimulationMgr.h:291
void setBottomType(const eRiverBedType aBottomType) noexcept
River bed type.
Definition Sfx_SimulationMgr.h:412
bool useFixedTimeStep() noexcept
Fix/variable time step.
Definition Sfx_SimulationMgr.h:130
std::vector< float64 > getWaterDepth() const
Getter.
Definition Sfx_SimulationMgr.h:455
void setManningCoeff(float64 aNcoeff) noexcept
Manning coefficient.
Definition Sfx_SimulationMgr.h:214
void setDBdataType(DamBreakData::eDataTypes aType) noexcept
Setter.
Definition Sfx_SimulationMgr.h:282
void setSectionType(dbpp::SectionFlow::eSectionType aSectype) noexcept
Setter.
Definition Sfx_SimulationMgr.h:392
void setPhi0(float64 aPhi0) noexcept
Setter.
Definition Sfx_SimulationMgr.h:306
SimulationMgr()
Default ctor (protected denied access)
Definition Sfx_SimulationMgr.cxx:72
std::pair< float64, float64 > m_dambreakExtent
Definition Sfx_SimulationMgr.h:510
uint32 getNbSections() const noexcept
Getter.
Definition Sfx_SimulationMgr.h:387
void startSimulation() noexcept
Start simulation.
Definition Sfx_SimulationMgr.h:240
float64 m_phi0
Definition Sfx_SimulationMgr.h:465
eRiverBedType m_bottomType
Definition Sfx_SimulationMgr.h:507
ePhysicalBCType getBCType() const noexcept
Definition Sfx_SimulationMgr.h:433
float64 getCFL() const noexcept
Courant-Friedrich-Levy number of the simulation.
Definition Sfx_SimulationMgr.h:179
uint32 m_NbSections
Definition Sfx_SimulationMgr.h:470
DamBreakData::eDataTypes getDBdataType() const noexcept
Definition Sfx_SimulationMgr.h:309
float64 m_frictionValue
Definition Sfx_SimulationMgr.h:484
CalculFF getPtr2FAlgorithm(const std::string &aMethodName)
Ptr-2-function convective flux algorithm.
Definition Sfx_SimulationMgr.cxx:136
bool isRunning() const noexcept
Simulation status.
Definition Sfx_SimulationMgr.h:231
const Testvs19::DamBreakSystem * m_dbSystem
Definition Sfx_SimulationMgr.h:490
bool m_useSourceTerms
Definition Sfx_SimulationMgr.h:475
std::string m_StVenantOut
Definition Sfx_SimulationMgr.h:487
float64 getFrictionValue() const noexcept
Global friction value.
Definition Sfx_SimulationMgr.h:427
~SimulationMgr()=default
Destructor ctor (protected denied access)
void registerDamBreakSystem(const Testvs19::DamBreakSystem *aDbSys)
DamBreak physical system.
Definition Sfx_SimulationMgr.h:449
ePhysicalBCType
Physical boundary condition.
Definition Sfx_SimulationMgr.h:76
@ EllignoBC
Definition Sfx_SimulationMgr.h:76
@ EMcNeilBC
Definition Sfx_SimulationMgr.h:76
float64 getTimeStep() noexcept
Time stepping.
Definition Sfx_SimulationMgr.h:125
friend class SfxSingleton
Access to private member.
Definition Sfx_SimulationMgr.h:82
void setTimeStep(const float64 aTimeStep) noexcept
Setter.
Definition Sfx_SimulationMgr.h:120
float64 getStartTime() const noexcept
Getter.
Definition Sfx_SimulationMgr.h:105
mapFluxSchemeName getMapSchemeName() const
Getter.
Definition Sfx_SimulationMgr.h:355
void setUseFlatBed(bool aUseFlatBed) noexcept
Set flat bed flag ON/OFF.
Definition Sfx_SimulationMgr.h:204
const std::vector< float64 > & getBottom() const
flat bed only supported for now (debug purpose)
Definition Sfx_SimulationMgr.h:360
eInitialWaveProfile getInitialWaveForm() const noexcept
initial wave profile
Definition Sfx_SimulationMgr.h:443
float64 getStopTime() const noexcept
Getter.
Definition Sfx_SimulationMgr.h:110
uint32 getNbIterations() const noexcept
Getter.
Definition Sfx_SimulationMgr.h:263
float32 getTolerance()
Getter.
Definition Sfx_SimulationMgr.h:156
bool m_useFriction
Definition Sfx_SimulationMgr.h:473
eRiverBedType
Bottom topography type.
Definition Sfx_SimulationMgr.h:63
@ RANDOM
Definition Sfx_SimulationMgr.h:67
@ ONESTEP
Definition Sfx_SimulationMgr.h:65
@ HYDJUMP
Definition Sfx_SimulationMgr.h:66
@ FLATBED
Definition Sfx_SimulationMgr.h:64
bool isUnitWidth() const noexcept
Definition Sfx_SimulationMgr.h:209
float64 m_alphaCoeff
Definition Sfx_SimulationMgr.h:485
int32 m_NbIterations
Definition Sfx_SimulationMgr.h:477
void setInitialWaveForm(eInitialWaveProfile aType) noexcept
Set/Get Initial profile.
Definition Sfx_SimulationMgr.h:438
bool onStart()
Entry point.
Definition Sfx_SimulationMgr.cxx:116
uint32 getNbIterationsMax() const noexcept
Geter.
Definition Sfx_SimulationMgr.h:254
void setTolerance(float32 aTolerance)
solution accuracy tolerance factor
Definition Sfx_SimulationMgr.h:151
bool m_usePressure
Definition Sfx_SimulationMgr.h:474
std::pair< float64, float64 > m_domainExtent
Definition Sfx_SimulationMgr.h:509
void setNbIterations(uint32 aNumOfIterations) noexcept
Set number iterations.
Definition Sfx_SimulationMgr.h:268
void saveScenario()
parameters used to perform (reproduce) the simulation
Definition Sfx_SimulationMgr.h:272
uint32 m_NumTimeStep
Definition Sfx_SimulationMgr.h:468
void setPhi1(float64 aPhi1) noexcept
Setter.
Definition Sfx_SimulationMgr.h:301
DamBreakData::eDataTypes m_dbDataType
Definition Sfx_SimulationMgr.h:459
dbpp::SectionFlow::eSectionType m_sectionType
Definition Sfx_SimulationMgr.h:508
void setUsePressure(bool aUsePressure) noexcept
Definition Sfx_SimulationMgr.h:224
int32 m_NbIterMax
Definition Sfx_SimulationMgr.h:478
bool m_isUnitWidth
Definition Sfx_SimulationMgr.h:492
void setUseFriction(bool aUseFriction) noexcept
Set friction flag ON/OFF.
Definition Sfx_SimulationMgr.h:194
std::string getPtrFluxAlgorithmName() const noexcept
Numerical algorithm for the current simulation (ptr-2-function)
Definition Sfx_SimulationMgr.h:334
std::map< std::string, CalculFF > m_ptr2FuncAlgo
Definition Sfx_SimulationMgr.h:488
float64 m_TimeStep
Definition Sfx_SimulationMgr.h:471
eInitialWaveProfile m_InitialWaveform
Definition Sfx_SimulationMgr.h:505
void setNbSections(uint32 aNbSections) noexcept
Setter.
Definition Sfx_SimulationMgr.h:382
float64 m_stopTime
Definition Sfx_SimulationMgr.h:481
ePhysicalBCType m_physBCType
Definition Sfx_SimulationMgr.h:506
void loadSections(std::string_view aFileName="SectionIni.txt")
load section from input file
Definition Sfx_SimulationMgr.h:277
void setStartTime(float64 aStartTime) noexcept
Use this method to specify the time at the start of the simulation.
Definition Sfx_SimulationMgr.h:90
void stopSimulation() noexcept
Stop simulation.
Definition Sfx_SimulationMgr.h:244
void setupEnvironment()
Manning coefficient.
Definition Sfx_SimulationMgr.cxx:258
void updateTime()
Use this method to set the time during any point during the simulation.
Definition Sfx_SimulationMgr.h:86
void setPtrFluxAlgorithmName(const std::string &aMethodName)
Pointer-to-function name.
Definition Sfx_SimulationMgr.h:339
void setBCType(const ePhysicalBCType aBCType) noexcept
Physical boundary type.
Definition Sfx_SimulationMgr.h:432
void setRunning(bool aIsRunning=true)
Set simulation status.
Definition Sfx_SimulationMgr.h:236
CalculFF m_Algorithm
Definition Sfx_SimulationMgr.h:458
float64 m_LastTime
Definition Sfx_SimulationMgr.h:483
bool useFlatBed() const noexcept
Flat bed flag ON/OFF.
Definition Sfx_SimulationMgr.h:199
std::string m_MethodName
Definition Sfx_SimulationMgr.h:486
bool m_useFlatBed
Definition Sfx_SimulationMgr.h:491
CalculFF currentAlgorithm() const
Numerical flux algorithm.
Definition Sfx_SimulationMgr.h:350
void setStopTime(float64 aStopTime) noexcept
simulation stop time
Definition Sfx_SimulationMgr.h:95
float64 m_startTime
Definition Sfx_SimulationMgr.h:480
void setMethodName(const std::string &aMethodName)
Definition Sfx_SimulationMgr.h:329
Physical system under study (physical object)
Definition Testvs19_DamBreakSystem.h:31
eSectionType
Section flow geometry.
Definition dbpp_SectionFlow.h:21
Definition HydUtils.h:15
std::map< std::string, CalculFF > mapFluxSchemeName
Alias (map name and function)
Definition Sfx_SimulationMgr.h:23