DamBreak++ Wave Simulator 0.3
DamBreak++ Simulation Framework
Loading...
Searching...
No Matches
dbpp_PhysicalSystem.h
Go to the documentation of this file.
1#pragma once
2
3// STL includes
4#include <map>
5#include <vector>
6// SfxBase19 includes
7#include "include/Sfx_UniversalConstants.h"
8#include "include/Sfx_StateVariables.h"
9#include "include/Sfx_Observable.h"
10// SfxBase package DamBreak++
13#include "dbpp_EMcNeilPhysBC.h"
14// BaseNumTypes library include
15#include "Sfx/Sfx_StateVectorField.h"
16
17namespace dbpp
18{
31 class PhysicalSystem : public virtual Sfx::Observable
32 {
37 {
40 };
41
42 public:
46 using pairStateVar = std::pair<Sfx::StateVariables/*A*/, Sfx::StateVariables/*Q*/>;//temporary fix
47
51 using SectionStateVar = std::map<unsigned int/*section id*/, pairStateVar /*section state var*/>;
52
56 using StateVectorPair = Sfx::StateVectorField::StateVector; // U=(A,Q)
57
61 template<typename... Params>
63 {
64 std::tuple<unsigned, Params.../*node values*/> values;
65 };
66 public:
73 virtual void add( const SectionFlow& aSectFlow2Add);
78 virtual void add( SectionFlow&& aSectFlow2Add);
79 // No don't do that, disable move semantic!! return by copy
80 // C++17 "copy elision is mandatory" no more temporary since
81 // the prvalue "materialize" to xvalue (eXpiring value)
82 SectionStateVar getStateVariables() const noexcept { return m_stateVarMap; }
92 Sfx::StateVectorField getStateVector() const;
93 // what about an iterator instead of returning the list of section flow
94 const ListSectionsFlow& getSectionList() const noexcept { return *m_listSections; }
100 std::shared_ptr<ListSectionsFlow>& getListSectionsPtr()
101 {
102 return m_listSections;
103 }
104
108 std::shared_ptr<ListSectionsFlow> getListSectionsPtr() const
109 {
110 return m_listSections;
111 }
112
115 [[nodiscard]] bool empty() const noexcept { return m_listSections->isEmpty(); }
120 ListSectionsFlow::vec_sizetype size() const noexcept { return m_listSections->size(); }
121
122 // Design Note
123 // Shall implement this method as template for container
124 // different signature or niversal reference??
125 //void update(CONT&& aCont) {...}
126
131 void update( const Sfx::StateVectorField& aStateVector);
137 void update( const std::valarray<float64>& aVarr1,
138 const std::valarray<float64>& aVarr2);
144 void update( std::valarray<float64>&& aVarr1,
145 std::valarray<float64>&& aVarr2);
150 void setRightPhysicalBnd( std::tuple<uint32, float64, float64, float64> aRightPhyBnd)
151 {
152 m_bcNodeDownstream = std::make_from_tuple<PhyBCNdlConstraint>(aRightPhyBnd);
153 }
154
159 {
160 return m_bcNodeDownstream;
161 }
162
166 void setLeftPhysicalBnd( std::tuple<uint32, float64, float64, float64> aLeftPhyBnd)
167 {
168 m_bcNodeUpstream = std::make_from_tuple<PhyBCNdlConstraint>(aLeftPhyBnd);
169 }
170
175 {
176 return m_bcNodeUpstream;
177 }
178
182 bool isSystemFictionLess() const noexcept { return true; }
187 bool useUnitWidthGeom() const noexcept { return true; }
192 bool useFlatEarth() const noexcept { return true; }
196 void PhysicalSystemBndType() const noexcept{/*half-open*/ } // left tied, right open
203 {
204 // list of unit section (nbSections is propbaly equal to 101)
205 ListSectionsFlow w_listSectF; //{ static_cast<ListSectionsFlow::vec_sizetype>(aDbdata.nbSections()) };
206 w_listSectF.reserve(aDbdata.nbSections());
207
208 // create the list of sections flow for the current simulation
209 auto sectId = 0u;
210 Sfx::DamBreakInitialCnd w_ic{ aDbdata };
211 // give return value a name to use it as an 'lvalue' (keep non-constness of return value)
212 auto&& w_xcoordBeg = w_ic.Xcoord().begin(); // return a temporary (prvalue: pure reading value)
213
214 // reference to temporay objects always extends their lifetime
215 static_assert(!std::is_same_v<decltype(w_xcoordBeg),std::ranges::dangling>); // check for dangling iterator
216 static_assert(std::is_same_v<decltype(w_xcoordBeg),std::vector<float64>::iterator&&>); // type (rvalue ref)
217 static_assert(std::is_same_v<decltype((w_xcoordBeg)), std::vector<float64>::iterator&>); // value category (lvalue ref)
218 for( auto w_sectH : w_ic.Hvalues())
219 {
220 // unit width as default and Manning coefficient is zero (default value)
221 w_listSectF.push_back(SectionFlow{ sectId,*w_xcoordBeg++,w_sectH }); // yield no dangling iterator
222 }
223
224 return w_listSectF;
225 }
226
227 // Observable interface
228
233 void attach(Sfx::Observer* aObserver) override final;
238 void detach(Sfx::Observer* aObserver) override final;
242 void notify() override final;
243 private:
244 int32 m_nbSectionsFlow = Sfx::DIM::value;
247 // Design Note
248 // not too sure yet if it should be part of the physical system (for now leave it like that)
249 // Usage: node_id,A,Q,H (values)
250 // auto w_bndLeftEnd = std::make_from_tuple<Nodal_Value>(std::make_tuple(1,2.,3.2,.4));
253 std::list<Sfx::Observer*> m_listOfObserver;
254 };
255} // End of namespace
dbpp::NodalTpl< unsigned, float64, float64, float64 > PhyBCNdlConstraint
Physics computational domain (phenomena take place: half-open as default)
Definition SimulationConfig.h:39
Hold data for validation. Two type: EMcneil, Hudson (DamBreak config)
Definition Sfx_DamBreakData.h:17
int32 nbSections() const noexcept
Definition Sfx_DamBreakData.h:85
Sole responsibility is to provide wave profile at initial start up based on DamBreakData.
Definition Sfx_DamBreakInitialCnd.h:16
std::vector< float64 > Hvalues() const
water level values
Definition Sfx_DamBreakInitialCnd.h:130
std::vector< float64 > Xcoord() const noexcept
x-coordinate
Definition Sfx_DamBreakInitialCnd.h:110
List of cross-section flow (itereable)
Definition dbpp_ListSectionsFlow.h:15
std::vector< SectionFlow >::size_type vec_sizetype
Aliases.
Definition dbpp_ListSectionsFlow.h:20
void reserve(vec_sizetype aSize)
Definition dbpp_ListSectionsFlow.h:116
void push_back(const SectionFlow &aSectF)
Definition dbpp_ListSectionsFlow.h:45
virtual void add(const SectionFlow &aSectFlow2Add)
adding a section
Definition dbpp_PhysicalSystem.cpp:34
std::shared_ptr< ListSectionsFlow > m_listSections
Definition dbpp_PhysicalSystem.h:245
ListSectionsFlow::vec_sizetype size() const noexcept
number of physical objects
Definition dbpp_PhysicalSystem.h:120
Sfx::StateVectorField::StateVector StateVectorPair
alias template state variables vector
Definition dbpp_PhysicalSystem.h:56
bool empty() const noexcept
check emptyness
Definition dbpp_PhysicalSystem.h:115
bool useFlatEarth() const noexcept
falt bed bathymetry
Definition dbpp_PhysicalSystem.h:192
SectionStateVar m_stateVarMap
Definition dbpp_PhysicalSystem.h:246
std::list< Sfx::Observer * > m_listOfObserver
Definition dbpp_PhysicalSystem.h:253
void setLeftPhysicalBnd(std::tuple< uint32, float64, float64, float64 > aLeftPhyBnd)
physical boundry left far end of global domain
Definition dbpp_PhysicalSystem.h:166
std::shared_ptr< ListSectionsFlow > getListSectionsPtr() const
list of sections
Definition dbpp_PhysicalSystem.h:108
void detach(Sfx::Observer *aObserver) override final
Remove observer from the ist.
Definition dbpp_PhysicalSystem.cpp:177
void PhysicalSystemBndType() const noexcept
type of physical boundary
Definition dbpp_PhysicalSystem.h:196
std::map< unsigned int, pairStateVar > SectionStateVar
alias template map state variables
Definition dbpp_PhysicalSystem.h:51
int32 m_nbSectionsFlow
Definition dbpp_PhysicalSystem.h:244
bool useUnitWidthGeom() const noexcept
section geometry type
Definition dbpp_PhysicalSystem.h:187
static ListSectionsFlow createSectionFlow(const Sfx::DamBreakData &aDbdata)
Create list of section flow.
Definition dbpp_PhysicalSystem.h:202
SectionStateVar & getStateVariables() noexcept
System state variables.
Definition dbpp_PhysicalSystem.h:87
PhyBCNdlConstraint getRightPhysicalBnd() const noexcept
Physical boundary.
Definition dbpp_PhysicalSystem.h:158
const ListSectionsFlow & getSectionList() const noexcept
Definition dbpp_PhysicalSystem.h:94
PhysicalSystem()
Default ctor.
Definition dbpp_PhysicalSystem.cpp:19
PhyBCNdlConstraint m_bcNodeDownstream
Definition dbpp_PhysicalSystem.h:252
PhyBCNdlConstraint m_bcNodeUpstream
Definition dbpp_PhysicalSystem.h:251
ListSectionsFlow & getSectionList() noexcept
Definition dbpp_PhysicalSystem.h:95
ePhysicalSystemType
Definition dbpp_PhysicalSystem.h:37
@ close
Definition dbpp_PhysicalSystem.h:39
@ halfOpen
Definition dbpp_PhysicalSystem.h:38
bool isSystemFictionLess() const noexcept
friction is used
Definition dbpp_PhysicalSystem.h:182
void setRightPhysicalBnd(std::tuple< uint32, float64, float64, float64 > aRightPhyBnd)
physical boundary at far end global domain
Definition dbpp_PhysicalSystem.h:150
PhyBCNdlConstraint getLeftPhysicalBnd() const noexcept
physical boundry left far end of global domain
Definition dbpp_PhysicalSystem.h:174
SectionStateVar getStateVariables() const noexcept
Definition dbpp_PhysicalSystem.h:82
std::shared_ptr< ListSectionsFlow > & getListSectionsPtr()
list of sections
Definition dbpp_PhysicalSystem.h:100
void notify() override final
notify all observers (call update())
Definition dbpp_PhysicalSystem.cpp:176
void attach(Sfx::Observer *aObserver) override final
attach the observer
Definition dbpp_PhysicalSystem.cpp:175
void update(const Sfx::StateVectorField &aStateVector)
update all sections flow and state variables
Definition dbpp_PhysicalSystem.cpp:186
std::pair< Sfx::StateVariables, Sfx::StateVariables > pairStateVar
alias template state variables
Definition dbpp_PhysicalSystem.h:46
Sfx::StateVectorField getStateVector() const
physical system state vector (scalar field)
Definition dbpp_PhysicalSystem.cpp:80
Cross-sectional flow (2-dimensional).
Definition dbpp_SectionFlow.h:16
Definition HydUtils.h:15
Definition DamBreakProb.h:15
Type to repesent the nodal constraint.
Definition dbpp_PhysicalSystem.h:63
std::tuple< unsigned, Params... > values
Definition dbpp_PhysicalSystem.h:64