DamBreak++ Wave Simulator 0.3
DamBreak++ Simulation Framework
Loading...
Searching...
No Matches
HydUtils.h
Go to the documentation of this file.
1
2#pragma once
3
4// STL functions objetcs
5#include <functional>
6
7// SfxBase library
8#include "include/Sfx_DefineTypes.h"
9
10// NOTE
11// this code is not used anymore, need to do some clean-up and this file shopuld be parft of the clean-up.
12// duplicate code (many version in different files)
13
14namespace Sfx
15{
16 //
17 // Prototypes header
18 //
19
20 //float64 T( float64 B);
21 //float64 A( float64 B, float64 Y);
22 //float64 P( float64 A, float64 B);
23 //float64 R( float64 A, float64 B);
24#if 0
32 constexpr float64 Evaluation_H_fonction_A(float64 A, float64 Z, float64 B = 1.)
33 {
34 return (A/B + Z);
35 }
36
44 constexpr float64 Evaluation_A_fonction_H(float64 H, float64 Z, float64 B = 1.)
45 {
46 return (H - Z) * B;
47 }
48#endif //0
49
54 inline constexpr float64 computeVelocity(float64 aU1, float64 aU2)
55 {
56 return aU2 / aU1;
57 }
58
62 inline constexpr float64 WettedPerimeter( float64 aArea, float64 aWidth = 1.)
63 {
64 return (2. * aArea) / aWidth + aWidth;
65 }
66
70 inline constexpr float64 HydRadius( float64 aArea, float64 aWidth = 1.)
71 {
72 //WettedPerimeter wWP;
73
74 return (aArea / WettedPerimeter(aArea));
75 }
76 inline constexpr float64 WettedArea(float64 aDepth, float64 aWidth = 1.)
77 {
78 return aWidth * aDepth;
79 }
80 inline constexpr float64 SectionWidth(float64 aWidth = 1.)
81 {
82 return aWidth;
83 }
84#if 0
85 struct computeVelocity //: std::binary_function<float64, float64, float64> deprecated
86 {
93 constexpr float64 operator() ( const float64 aU1,
94 const float64 aU2) const
95 {
96 return aU2/aU1;
97 }
98 };
99
100 // Design Note:
101 // ------------
102 // Function object (functors) that perform calculation
103 // cross-section ( wetted area, hydraulic radius, width
104 // at free surface,
105 //
106 // To be used with iterator while going through a list
107 // of sections.
108 //
109 // Compute width of the section
110 // process_iterator<list::iterator, Width()> wProc_it_run;
111 //
112 // "Model of" applicative template mechanism
113 //
114
115 // _____________________________________________________
116 //
117 // struct WettedPerimeter : public std::binary_function<float64,float64,float64>
118 // result_type operator() ( const first_argument_type aArea,
119 // const second_argument_type aWidth) const
120 // use of std::bind2nd to set width = 1.
121 //
122
127 class WettedPerimeter {
128
129 public:
130
131 constexpr float64 operator () ( const float64 aArea, const float64 aWidth = 1.) const
132 {
133 // Fonction spécifique à un canal rectangulaire de largeur B
134 // Périmètre établi en fonction d'une superficie d'écoulement A
135
136 // float64 Resultat;
137
138 // Resultat = 2.*A/B + B;
139
140 // return (Resultat);
141
142 return (2.*aArea)/aWidth + aWidth;
143 }
144 };
145
146 // ____________________________________________________
147 //
148 // struct HydRadius : public std::binary_function<float64,float64,float64>
149 // result_type operator() ( const first_argument_type aArea,
150 // const second_argument_type aWidth) const
151 // use of std::bind2nd to set width = 1.
152
153
158 class HydRadius {
159
160 public:
161
162 constexpr float64 operator () ( const float64 aArea, const float64 aWidth = 1.) const
163 {
164 // Fonction spécifique à un canal rectangulaire de largeur B
165 // Périmètre établi en fonction d'une superficie d'écoulement A
166
167 // float64 Resultat;
168
169 // Resultat = A/P(A, B);
170
171 // return (Resultat);
172 WettedPerimeter wWP;
173
174 return (aArea/wWP( aArea));
175 }
176 };
177
178 // use of std::bind2nd to set width = 1.
179 //
180 class WettedArea {
181
182 public:
183
184 constexpr float64 operator () ( const float64 aDepth, const float64 aWidth = 1.) const
185 {
186 // float64 Resultat;
187
188 // Resultat = B * Y;
189
190 // return (Resultat);
191
192 return aWidth*aDepth;
193 }
194
195 // In a future version ?????
196 // float64 operator () ( const float64 aY, const Section aSection) const
197 // {
198 // }
199 };
200
201 // _____________________________________________________
202 //
203 class SectionWidth {
204
205 public:
206
207 constexpr float64 operator () ( float64 aWidth = 1.) const
208 {
209 return aWidth;
210 }
211
212 // In future version, given a section, compute is width at free surface level
213 // By default the width is set to 1
214 // float64 operator () ( Section aSection = 1.) const
215 // {
216 // return aB;
217 // }
218
219 };
220
221 // see EMcNeilUtils
222
223 double P(double A, double B)
224 {
225 double Resultat;
226
227 Resultat = 2. * A / B + B;
228
229 return (Resultat);
230 }
231
232 double R(double A, double B)
233 {
234 double Resultat;
235
236 Resultat = A / P(A, B);
237
238 return (Resultat);
239 }
240
241
242 double A(double B, double Y)
243 {
244 double Resultat;
245
246 Resultat = B * Y;
247
248 return (Resultat);
249 }
250
251 double T(double B)
252 {
253 double Resultat;
254
255 Resultat = B;
256
257 return (Resultat);
258 }
259
260
261 // shall return std::optional<double>
262 template<typename Range>
263 auto StVenant1D_Incomplete_Flux( Range& aU1, Range& aU2)
264 {
265 static_assert(0 != std::size(aU1));
266 static_assert(std::is_same_v<std::size(aU1), std::size(aU2)>);
267 if constexpr ( !std::is_same_v<std::size(aU1), std::size(aU2)>)
268 {
269 return -1.;
270 }
271 else
272 {
273 return (aU2 * aU2) / aU1;
274 }
275 //static_assert(std::extent_v<decltype(aU1[0],0)> == 10.);
276 //static_assert(std::extent_v<decltype(aU1[99],0)> == 1.);
277 //static_assert( std::size(aU1) == std::size(decltype(aU2)), "Incomplete Flux range empty");
278 //static_assert( !std::size(aU1) && !std::size(aU2) , "Incomplete Flux range empty");
279
280 //return (aU2 * aU2) / aU1;
281
282 // Fonction de calcul de F2 incomplet (excluant le terme de pression hydrostatique)
283
284// float64 F2;
285
286// F2 = U2 * U2 / U1;
287
288// return (F2);
289 }
290#endif // 0
291} // End of namespace
Definition HydUtils.h:15
constexpr float64 SectionWidth(float64 aWidth=1.)
Definition HydUtils.h:80
constexpr float64 HydRadius(float64 aArea, float64 aWidth=1.)
Function specific to a rectangular channel of width B Perimeter established according to a flow area ...
Definition HydUtils.h:70
constexpr float64 computeVelocity(float64 aU1, float64 aU2)
"Model of" binary function (STL function objects).
Definition HydUtils.h:54
constexpr float64 WettedArea(float64 aDepth, float64 aWidth=1.)
Definition HydUtils.h:76
constexpr float64 WettedPerimeter(float64 aArea, float64 aWidth=1.)
Function object (callable) that perform calculation cross-section ( wetted area, hydraulic radius,...
Definition HydUtils.h:62
auto StVenant1D_Incomplete_Flux(Range &aU1, Range &aU2)
Definition Sfx_MathFunctions.hpp:330
@ A
Definition dbpp_Enumerations.h:16
double float64
Definition dbpp_LDeltaOperator.h:12