DamBreak++ Wave Simulator 0.3
DamBreak++ Simulation Framework
Loading...
Searching...
No Matches
dbpp_FluxAlgorithmFunctions.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <valarray>
4
5#include "include/Sfx_UniversalConstants.h"
6
7namespace dbpp
8{
21 template<typename T, typename ArrayType = std::valarray<T>>
22 void hllFluxAlgorithm( ArrayType& aFF1, ArrayType& aFF2, // return
23 const ArrayType& aU1, const ArrayType& aU2, // in
24 ArrayType&& dU1, ArrayType&& dU2) noexcept // (forward reference)
25 {
26 std::cout << "Debugging purpose\n";
27
28 static_assert(std::is_same_v<decltype(ArrayType), const std::valarray<double, 3>&>);
29 static_assert(std::size(aU1) == std::size(aU2), "Numerical array must be same size");
30
31 // return global domain faces
32 //auto w_glbFaces = createGlobalFaces();
33
34 for( auto i = 0; i < std::size(aU1) - 1; ++i)
35 {
36 // U1 variable
37 const auto w_U1L = aU1[i] + dU1[i];
38 const auto w_U1R = aU1[i + 1] - dU1[i + 1];
39
40 // U2 variable
41 const auto w_U2L = aU2[i] + dU2[i];
42 const auto w_U2R = aU2[i + 1] + dU2[i + 1];
43 /* StateVector UL{ U1[i] + dU1[i], U2[i] + dU2[i] };
44 StateVector UR{ U1[i + 1] - dU1[i + 1], U2[i + 1] - dU2[i + 1] };*/
45 // std::cout << "StateVector not supported yet\n";
46 // compute physical flux
47 // aFF1[i]=1.22;
48 // aFF2[i]=0/23;
49 }
50 }
51
60 template< typename ArrayType,
61 auto NbSections = Sfx::EMCNEILNbSections::value>
62 void hllFluxAlgorithm(ArrayType& aFF1, ArrayType& aFF2, // face flux
63 const ArrayType& aU1, const ArrayType& aU2) noexcept // ?? not sure
64 {
65 // C++20 range concept and compile-time if (if with initialization and follow by condition C++17)
66 if constexpr( range_t<ArrayType> numrng; !std::ranges::range<decltype(numrng)>) // condition if it is a range
67 {
68 static_assert(std::size(ArrayType) == NbSections);
69 std::cout << "numrng is not a range with exact value\n";
70 }
71
72 // std::ranges::distance(); just check
73 using sect_sizet = decltype(NbSections);
74 using arr_valuetype = typename ArrayType::value_type;
75
76 // distance
77 auto rngFF1Dist = std::ranges::distance(aFF1);
78
79 // aU over global domain (include ghost node)
80 // static_assert( std::size(aFF1) == NbSections - 1); //<< "Face Flux and global U array incompatible";
81 // static_assert( std::size(aFF2) == NbSections - 1); //<< "Face Flux and global U array incompatible";
82 static_assert(std::is_same_v<double, ArrayType::value_type>); //<< "";
83
84#if 0
85 // slope limiter stencil:
86 // Do some reconstruction of state variables at cell face (MUSCLreconstr)
87 ArrayType dU1{ aU1.size() }; // gradient over cell
88 std::adjacent_difference(std::begin(aU1), std::end(aU1), std::begin(dU1));
89 dU1[0] = 0.; // force to zero
90 ArrayType dU2{ aU2.size() }; // gradient over cell
91 std::adjacent_difference(std::begin(aU2), std::end(aU2), std::begin(dU2));
92 dU2[0] = 0.; // force to zero (adjacent_difference leave first element as is)
93
94 // Design Note
95 // we need to use range view for this slope limiter because
96 // compare adjacent value with stencil [i,i+1]
97 // [0,N[ and ]0,N]
98 // slope limiter
99 MinMod w_minModSLopeLimiter{};
100 std::adjacent_difference(dU1.cbegin(), dU1.cend(), dU2.cbegin(), dU1.begin(), w_minModSLopeLimiter);
101
102 // ... not sure about this one
103 std::vector<arr_valuetype> w_dU1(std::begin(dU1), std::end(dU1));
104 w_dU1.push_back(0.);
105
106 // limiter function gradient sharp profile
107 // remove first element ( boost range ]begin(),end()])
108
109 std::vector<typename ArrayType::value_type> w_dU2(std::begin(dU2), std::end(dU2));
110 w_dU2.push_back(0.);
111 // limiter function gradient sharp profile
112 // remove first element ( boost range ]begin(),end()])
113
114#endif // 0
115
116 // loop on cell faces
117 /* auto UL = 0.;
118 auto UR = 0.;
119
120 auto w_glbFaces = createGlobalFaces();
121
122 for( auto i = 0; i < w_glbFaces.length(); ++i)
123 {
124 StateVector UL{ U1[i] + dU1[i], U2[i] + dU2[i] };
125 StateVector UR{ U1[i+1] - dU1[i+1], U2[i+1] - dU2[i+1] };*/
126
127 // compute physical flux
128 }
129} // End of namespace
Definition DamBreakProb.h:15
void hllFluxAlgorithm(ArrayType &aFF1, ArrayType &aFF2, const ArrayType &aU1, const ArrayType &aU2, ArrayType &&dU1, ArrayType &&dU2) noexcept
Compute numerical flux according to HLL algorithm ()
Definition dbpp_FluxAlgorithmFunctions.hpp:22