DamBreak++ Wave Simulator 0.3
DamBreak++ Simulation Framework
Loading...
Searching...
No Matches
dbpp_TimeStepCondition.hpp
Go to the documentation of this file.
1#pragma once
2
3// C++20 includes
4#include <ranges>
5#include <optional>
6// STL include
7#include <algorithm>
8// numeric include
9#include <valarray>
10//
11#include "include/Sfx_UniversalConstants.h "//gravity
12#include "include/Sfx_DefineTypes.h" //float64
13// VS19 include
15
16#undef min
17
18namespace dbpp
19{
27 std::optional<float64> TimeStepCondition( std::ranges::view auto aU1,
28 std::ranges::view auto aU2, bool isSectionUnitWidth=true)
29 {
30 namespace rng = std::ranges;
31
32 assert(rng::size(aU1) == rng::size(aU2));
33
34 // NOTE 'dx' is hard coded
35// DamBreakData w_dbData(Simulation::instance()->getDBdata());
36 //w_dbData.initMcNeil1D();
37
38 // const auto B = w_dbData.getWidth();
39 // const auto dx = w_dbData.dX();
40
41
42 // only suporting section of unit width in this release
43 if (!isSectionUnitWidth) return std::nullopt;
44
45 // IMPORTANT
46 // first node is tie not considered j=1
47 // Calcul des valeurs des variables d'état
48 // for (auto j = 1; j < aU1.size(); j++)
49 // {
50 // IMPORTANT-
51 // this algorithm assume far left node is tied (physical boundary condition)
52 std::valarray<rng::range_value_t<decltype(aU1)>> w_U1(aU1.data(),aU1.size());
53 std::valarray<rng::range_value_t<decltype(aU1)>> w_U2(aU2.data(),aU2.size());
54
55 // FIX THAT!!!
56 // debug purpose
57 //const auto B = 1.; w_dbData.getWidth();
58 constexpr auto dx = 0.01; //w_dbData.dX();
59 // Sfx::DamBreakData aDamBreakData{ Sfx::SimulationMgr::getSingleton().getDBdataType() };
60 // Analyse des conditions de stabilité numérique
61 auto V = w_U2 / w_U1;
62 auto c = std::sqrt(Sfx::cGravity<float64>*w_U1); // / HydroUtils::T(B)); // T à calculer
63 auto dtc = dx / (std::abs(V) + c);
64 // return min value
65 return dtc.min();
66 }
67}// End of namespace
Definition DamBreakProb.h:15
std::optional< float64 > TimeStepCondition(std::ranges::view auto aU1, std::ranges::view auto aU2, bool isSectionUnitWidth=true)
Time step criteria stability (assume far left node is tie by b.c.).
Definition dbpp_TimeStepCondition.hpp:27