DamBreak++ Wave Simulator 0.3
DamBreak++ Simulation Framework
Loading...
Searching...
No Matches
dbpp_ListSectionsFlow.h
Go to the documentation of this file.
1#pragma once
2
3#include <vector>
4#include <map>
5#include <algorithm>
6#include "dbpp_SectionFlow.h"
7#include "include/Sfx_DefineTypes.h"
8
9namespace dbpp
10{
15 {
16 public:
20 using vec_sizetype = std::vector<SectionFlow>::size_type;
21 using vec_valtype = std::vector<SectionFlow>::value_type;
22 using vec_iter = std::vector<SectionFlow>::iterator;
23 using vec_citer = std::vector<SectionFlow>::const_iterator;
24 using vec_riter = std::reverse_iterator<vec_iter>;
25 using vec_rciter = std::reverse_iterator<vec_citer>;
26
27 // **************** STL-like Container ***************
28 vec_iter begin() { return m_listSectionsFlow.begin(); }
29 vec_iter end() { return m_listSectionsFlow.end();}
30 vec_riter rbegin() { return m_listSectionsFlow.rbegin(); }
31 vec_riter rend() { return m_listSectionsFlow.rend(); }
32 vec_citer cbegin() const { return m_listSectionsFlow.cbegin(); }
33 vec_citer cend() const { return m_listSectionsFlow.cend(); }
34 vec_rciter crbegin() const { return m_listSectionsFlow.crbegin(); }
35 vec_rciter crend() const { return m_listSectionsFlow.crend(); }
36
37 public:
38 // New ctor to take account that subject can be shared by many instances
39// make sure that we still pointing to a valid instance (DEPRECATED!!)
40 //explicit ListSectionsFlow( vec_sizetype aNbSections=100) {/*not implemented yet*/ }
45 void push_back( const SectionFlow& aSectF) { m_listSectionsFlow.push_back(aSectF); }
50 void push_back( SectionFlow&& aSectF) { m_listSectionsFlow.push_back(std::move(aSectF)); }
56 bool contains(SectionFlow aSectF2Find)
57 {
58 // use the find algorithm, of the stl ()
59 if (std::find(m_listSectionsFlow.begin(), m_listSectionsFlow.end(), aSectF2Find) != m_listSectionsFlow.end())
60 {
61 // found something
62 return true;
63 }
64 return false;
65 }
66
69 void clear() { m_listSectionsFlow.clear(); }
70
71 // Design Note: should i return a reference?
73 {
74 return m_listSectionsFlow[aIdx];
75 }
77 {
78 return m_listSectionsFlow[aIdx];
79 }
80
84 [[nodiscard]] bool isEmpty() const noexcept { return m_listSectionsFlow.empty(); }
89 vec_sizetype size() const noexcept { return m_listSectionsFlow.size(); }
93 void shrink2Fit() { m_listSectionsFlow.shrink_to_fit(); }
98 std::vector<SectionFlow> getList() const noexcept
99 {
100 return m_listSectionsFlow;
101 }
102
106 const SectionFlow& front() const { return m_listSectionsFlow.front(); }
111 const SectionFlow& back() const { return m_listSectionsFlow.back(); }
116 void reserve( vec_sizetype aSize) { m_listSectionsFlow.reserve(aSize); }
117
119 bool isFrictionLess() const
120 {
121 return (std::all_of(m_listSectionsFlow.cbegin(), m_listSectionsFlow.cend(),
122 [](const SectionFlow& aSectFlow)
123 {
124 return aSectFlow.N() == 0.;
125 }));
126 }
127
129 bool isFlatBed() const
130 {
131 return (std::all_of(m_listSectionsFlow.cbegin(), m_listSectionsFlow.cend(),
132 [](const SectionFlow& aSectFlow)
133 {
134 return aSectFlow.Z() == 0.;
135 }));
136 }
137
139 bool isUnitWidth() const
140 {
141 return (std::all_of(m_listSectionsFlow.cbegin(), m_listSectionsFlow.cend(),
142 [](const SectionFlow& aSectFlow)
143 {
144 return aSectFlow.B() == 1.;
145 }));
146 }
147
151 std::map<unsigned, float64> getSectionsManning() const
152 {
153 std::map<unsigned int, double> w_sectManningMap;
154 // Manning coefficient
155 for (const auto& w_sect : m_listSectionsFlow)
156 {
157 w_sectManningMap.insert({ w_sect.getId(), w_sect.N() });
158 }
159 return w_sectManningMap;
160 }
161
165 std::map<unsigned, float64> getSectionsBathymetry() const
166 {
167 std::map<unsigned int, double> w_sectBathymetryMap;
168 // Manning coefficient
169 for (const auto& w_sect : m_listSectionsFlow)
170 {
171 w_sectBathymetryMap.insert({ w_sect.getId(), w_sect.Z() });
172 }
173 return w_sectBathymetryMap;
174 }
175
179 std::map<unsigned, double> getSectionsWaterLevel() const
180 {
181 std::map<unsigned int, double> w_sectWaterLevelMap;
182 // Manning coefficient
183 for (const auto& w_sect : m_listSectionsFlow)
184 {
185 w_sectWaterLevelMap.insert({ w_sect.getId(), w_sect.H() });
186 }
187 return w_sectWaterLevelMap;
188 }
189 private:
190 std::vector<SectionFlow> m_listSectionsFlow;
191 };
192} // End of namespace
List of cross-section flow (itereable)
Definition dbpp_ListSectionsFlow.h:15
SectionFlow & operator[](vec_sizetype aIdx)
Definition dbpp_ListSectionsFlow.h:72
vec_citer cbegin() const
Definition dbpp_ListSectionsFlow.h:32
std::map< unsigned, float64 > getSectionsBathymetry() const
Definition dbpp_ListSectionsFlow.h:165
std::map< unsigned, double > getSectionsWaterLevel() const
Definition dbpp_ListSectionsFlow.h:179
vec_rciter crend() const
Definition dbpp_ListSectionsFlow.h:35
std::vector< SectionFlow > m_listSectionsFlow
Definition dbpp_ListSectionsFlow.h:190
void shrink2Fit()
Definition dbpp_ListSectionsFlow.h:93
vec_sizetype size() const noexcept
Definition dbpp_ListSectionsFlow.h:89
bool isFlatBed() const
Definition dbpp_ListSectionsFlow.h:129
bool contains(SectionFlow aSectF2Find)
Definition dbpp_ListSectionsFlow.h:56
std::vector< SectionFlow > getList() const noexcept
Definition dbpp_ListSectionsFlow.h:98
bool isEmpty() const noexcept
Definition dbpp_ListSectionsFlow.h:84
vec_iter begin()
Definition dbpp_ListSectionsFlow.h:28
vec_iter end()
Definition dbpp_ListSectionsFlow.h:29
vec_riter rbegin()
Definition dbpp_ListSectionsFlow.h:30
const SectionFlow & front() const
Definition dbpp_ListSectionsFlow.h:106
std::vector< SectionFlow >::size_type vec_sizetype
Aliases.
Definition dbpp_ListSectionsFlow.h:20
std::vector< SectionFlow >::value_type vec_valtype
Definition dbpp_ListSectionsFlow.h:21
void reserve(vec_sizetype aSize)
Definition dbpp_ListSectionsFlow.h:116
void clear()
Empty list.
Definition dbpp_ListSectionsFlow.h:69
vec_rciter crbegin() const
Definition dbpp_ListSectionsFlow.h:34
vec_citer cend() const
Definition dbpp_ListSectionsFlow.h:33
const SectionFlow & back() const
Definition dbpp_ListSectionsFlow.h:111
std::reverse_iterator< vec_citer > vec_rciter
Definition dbpp_ListSectionsFlow.h:25
std::vector< SectionFlow >::const_iterator vec_citer
Definition dbpp_ListSectionsFlow.h:23
std::reverse_iterator< vec_iter > vec_riter
Definition dbpp_ListSectionsFlow.h:24
void push_back(const SectionFlow &aSectF)
Definition dbpp_ListSectionsFlow.h:45
std::map< unsigned, float64 > getSectionsManning() const
Definition dbpp_ListSectionsFlow.h:151
std::vector< SectionFlow >::iterator vec_iter
Definition dbpp_ListSectionsFlow.h:22
vec_riter rend()
Definition dbpp_ListSectionsFlow.h:31
bool isUnitWidth() const
Definition dbpp_ListSectionsFlow.h:139
void push_back(SectionFlow &&aSectF)
Definition dbpp_ListSectionsFlow.h:50
bool isFrictionLess() const
Definition dbpp_ListSectionsFlow.h:119
Cross-sectional flow (2-dimensional).
Definition dbpp_SectionFlow.h:16
Definition DamBreakProb.h:15