Finite Volume Solver  prototype
A framework to build finite volume solvers for the AG Klein at the Freie Universität Berlin.
perfect_gas/MusclHancockCharactersticMethod.hpp
Go to the documentation of this file.
1 // Copyright (c) 2020 Maikel Nadolski
2 //
3 // Permission is hereby granted, free of charge, to any person obtaining a copy
4 // of this software and associated documentation files (the "Software"), to deal
5 // in the Software without restriction, including without limitation the rights
6 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 // copies of the Software, and to permit persons to whom the Software is
8 // furnished to do so, subject to the following conditions:
9 //
10 // The above copyright notice and this permission notice shall be included in
11 // all copies or substantial portions of the Software.
12 //
13 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 // SOFTWARE.
20 
21 #ifndef FUB_EQUATIONS_PERFECT_GAS_MIX_MUSCL_HANCOCK_CHAR_HPP
22 #define FUB_EQUATIONS_PERFECT_GAS_MIX_MUSCL_HANCOCK_CHAR_HPP
23 
30 
31 namespace fub {
32 namespace perfect_gas {
33 
35  double minus{};
36  double zero{};
37  double plus{};
38 };
39 
41  double v{};
42  double w{};
43 };
44 
51 };
52 
53 struct Primitives {
54  double density{};
56  double pressure{};
57 
59  : density{q.density},
60  velocity(q.momentum / q.density), pressure{q.pressure} {}
61 
63  : density{q.density}, velocity{q.momentum[0] / q.density,
64  q.momentum[1] / q.density, 0},
65  pressure{q.pressure} {}
66 
68  : density{q.density},
69  pressure{q.pressure} {
70  velocity[0] = q.momentum[0] / q.density;
71  velocity[1] = 0.0;
72  velocity[2] = 0.0;
73  }
74 };
75 
77  Array1d density{Array1d::Zero()};
78  Array3d velocity{Array3d::Zero()};
79  Array1d pressure{Array1d::Zero()};
80 
82  : density{q.density}, pressure{q.pressure} {
83  for (int d = 0; d < 3; ++d) {
84  velocity.row(d) = q.momentum.row(d) / q.density;
85  }
86  }
87 
89  : density{q.density}, pressure{q.pressure} {
90  for (int d = 0; d < 2; ++d) {
91  velocity.row(d) = q.momentum.row(d) / q.density;
92  }
93  }
94 
96  : density{q.density}, pressure{q.pressure} {
97  for (int d = 0; d < 1; ++d) {
98  velocity.row(d) = q.momentum.row(d) / q.density;
99  }
100  }
101 };
102 
103 /// \ingroup FluxMethod
104 ///
105 /// This is a variation of the Muscl Hancock Method where the reconstruction at
106 /// the half time level is based on the primitive variables (p, u, T, Y) instead
107 /// of on conservative variables.
108 template <int Rank>
110 public:
116 
118  : equation_(equation), limiter_(VanLeer()), array_limiter_(VanLeer()) {}
119 
120  template <typename Limiter>
121  MusclHancockCharacteristic(const PerfectGas<Rank>& equation, Limiter&& limiter)
122  : equation_(equation), limiter_(std::forward<Limiter>(limiter)), array_limiter_(std::forward<Limiter>(limiter)) {}
123 
124  [[nodiscard]] static constexpr int GetStencilWidth() noexcept { return 2; }
125 
126  /// Returns a stable time step estimate based on HLL signal velocities.
127  [[nodiscard]] double ComputeStableDt(span<const Complete, 4> states,
128  double dx, Direction dir) noexcept;
129 
130  /// Returns an array of stable time step estimates based on HLL signal
131  /// velocities.
133  Array1d face_fraction,
134  span<const Array1d, 4> volume_fraction,
135  double dx, Direction dir) noexcept;
136 
138  double dx, Direction dir) noexcept;
139 
141  Duration dt, double dx, Direction dir);
142 
145  double dx, Direction dir);
146 
147  void ComputeNumericFlux(ConservativeArray& flux, Array1d face_fractions,
149  span<const Array1d, 4> volume_fractions, Duration dt,
150  double dx, Direction dir);
151 
152  [[nodiscard]] const Equation& GetEquation() const noexcept {
153  return equation_;
154  }
155  [[nodiscard]] Equation& GetEquation() noexcept { return equation_; }
156 
157 private:
159  std::array<Complete, 2> reconstruction_{Complete(equation_),
164  std::function<double(double, double)> limiter_;
165 
166  std::array<CompleteArray, 2> reconstruction_array_{CompleteArray(equation_),
172 
173  // HllMethod<PerfectGas<Rank>, EinfeldtSignalVelocities<PerfectGas<Rank>>> hllem_{equation_};
175  // GodunovMethod<PerfectGas<Rank>> hllem_{equation_};
176 };
177 
178 /// \ingroup FluxMethod
179 template <int Rank>
182 
183 extern template class MusclHancockCharacteristic<1>;
184 extern template class MusclHancockCharacteristic<2>;
185 extern template class MusclHancockCharacteristic<3>;
186 } // namespace perfect_gas
187 
191 
192 } // namespace fub
193 
194 #endif
This class applies a base flux nethod on a view of states.
Definition: flux_method/FluxMethod.hpp:57
This is a variation of the Muscl Hancock Method where the reconstruction at the half time level is ba...
Definition: perfect_gas/MusclHancockCharactersticMethod.hpp:109
MusclHancockCharacteristic(const PerfectGas< Rank > &equation, Limiter &&limiter)
Definition: perfect_gas/MusclHancockCharactersticMethod.hpp:121
std::array< CompleteArray, 2 > reconstruction_array_
Definition: perfect_gas/MusclHancockCharactersticMethod.hpp:166
Primitives diffs_
Definition: perfect_gas/MusclHancockCharactersticMethod.hpp:161
std::array< Complete, 2 > reconstruction_
Definition: perfect_gas/MusclHancockCharactersticMethod.hpp:159
void ComputeNumericFlux(ConservativeArray &flux, Array1d face_fractions, span< const CompleteArray, 4 > stencil, span< const Array1d, 4 > volume_fractions, Duration dt, double dx, Direction dir)
void ComputeNumericFlux(Conservative &flux, span< const Complete, 4 > stencil, Duration dt, double dx, Direction dir)
Equation & GetEquation() noexcept
Definition: perfect_gas/MusclHancockCharactersticMethod.hpp:155
const Equation & GetEquation() const noexcept
Definition: perfect_gas/MusclHancockCharactersticMethod.hpp:152
Array1d ComputeStableDt(span< const CompleteArray, 4 > states, Array1d face_fraction, span< const Array1d, 4 > volume_fraction, double dx, Direction dir) noexcept
Returns an array of stable time step estimates based on HLL signal velocities.
std::function< double(double, double)> limiter_
Definition: perfect_gas/MusclHancockCharactersticMethod.hpp:164
HllemMethod< PerfectGas< Rank > > hllem_
Definition: perfect_gas/MusclHancockCharactersticMethod.hpp:174
void ComputeNumericFlux(ConservativeArray &flux, span< const CompleteArray, 4 > stencil, Duration dt, double dx, Direction dir)
CharacteristicsArray amplitudes_array_
Definition: perfect_gas/MusclHancockCharactersticMethod.hpp:169
std::function< Array1d(Array1d, Array1d)> array_limiter_
Definition: perfect_gas/MusclHancockCharactersticMethod.hpp:171
CharacteristicsArray slopes_array_
Definition: perfect_gas/MusclHancockCharactersticMethod.hpp:170
MusclHancockCharacteristic(const PerfectGas< Rank > &equation)
Definition: perfect_gas/MusclHancockCharactersticMethod.hpp:117
static constexpr int GetStencilWidth() noexcept
Definition: perfect_gas/MusclHancockCharactersticMethod.hpp:124
Characteristics amplitudes_
Definition: perfect_gas/MusclHancockCharactersticMethod.hpp:162
PerfectGas< Rank > equation_
Definition: perfect_gas/MusclHancockCharactersticMethod.hpp:158
Array1d ComputeStableDt(span< const CompleteArray, 4 > states, double dx, Direction dir) noexcept
double ComputeStableDt(span< const Complete, 4 > states, double dx, Direction dir) noexcept
Returns a stable time step estimate based on HLL signal velocities.
::fub::Complete< Equation > Complete
Definition: perfect_gas/MusclHancockCharactersticMethod.hpp:112
Characteristics slopes_
Definition: perfect_gas/MusclHancockCharactersticMethod.hpp:163
PrimitivesArray diffs_array_
Definition: perfect_gas/MusclHancockCharactersticMethod.hpp:168
::fub::CompleteArray< Equation > CompleteArray
Definition: perfect_gas/MusclHancockCharactersticMethod.hpp:114
A span is a view over a contiguous sequence of objects, the storage of which is owned by some other o...
Definition: span.hpp:81
The fub namespace.
Definition: AnyBoundaryCondition.hpp:31
Array< double, 3 > Array3d
Definition: Eigen.hpp:56
std::conditional_t< N==1||M==1, Eigen::Array< T, N, M >, Eigen::Array< T, N, M, Eigen::RowMajor > > Array
Definition: Eigen.hpp:50
std::chrono::duration< double > Duration
Definition: Duration.hpp:31
Array< double, 1 > Array1d
Definition: Eigen.hpp:53
Direction
This is a type safe type to denote a dimensional split direction.
Definition: Direction.hpp:30
Definition: StateArray.hpp:178
This type has a constructor which takes an equation and might allocate any dynamically sized member v...
Definition: State.hpp:335
Definition: PerfectGas.hpp:164
Definition: flux_method/MusclHancockMethod.hpp:137
Definition: perfect_gas/MusclHancockCharactersticMethod.hpp:34
double zero
Definition: perfect_gas/MusclHancockCharactersticMethod.hpp:36
double minus
Definition: perfect_gas/MusclHancockCharactersticMethod.hpp:35
double plus
Definition: perfect_gas/MusclHancockCharactersticMethod.hpp:37
Definition: perfect_gas/MusclHancockCharactersticMethod.hpp:45
Array1d v
Definition: perfect_gas/MusclHancockCharactersticMethod.hpp:49
Array1d minus
Definition: perfect_gas/MusclHancockCharactersticMethod.hpp:46
Array1d w
Definition: perfect_gas/MusclHancockCharactersticMethod.hpp:50
Array1d plus
Definition: perfect_gas/MusclHancockCharactersticMethod.hpp:48
Array1d zero
Definition: perfect_gas/MusclHancockCharactersticMethod.hpp:47
Definition: perfect_gas/MusclHancockCharactersticMethod.hpp:40
double w
Definition: perfect_gas/MusclHancockCharactersticMethod.hpp:42
double v
Definition: perfect_gas/MusclHancockCharactersticMethod.hpp:41
Definition: perfect_gas/MusclHancockCharactersticMethod.hpp:76
PrimitivesArray(const CompleteArray< PerfectGas< 2 >> &q)
Definition: perfect_gas/MusclHancockCharactersticMethod.hpp:88
PrimitivesArray(const CompleteArray< PerfectGas< 3 >> &q)
Definition: perfect_gas/MusclHancockCharactersticMethod.hpp:81
PrimitivesArray(const CompleteArray< PerfectGas< 1 >> &q)
Definition: perfect_gas/MusclHancockCharactersticMethod.hpp:95
Array1d pressure
Definition: perfect_gas/MusclHancockCharactersticMethod.hpp:79
Array1d density
Definition: perfect_gas/MusclHancockCharactersticMethod.hpp:77
Array3d velocity
Definition: perfect_gas/MusclHancockCharactersticMethod.hpp:78
Definition: perfect_gas/MusclHancockCharactersticMethod.hpp:53
Array< double, 3, 1 > velocity
Definition: perfect_gas/MusclHancockCharactersticMethod.hpp:55
double density
Definition: perfect_gas/MusclHancockCharactersticMethod.hpp:54
Primitives(const Complete< PerfectGas< 3 >> &q)
Definition: perfect_gas/MusclHancockCharactersticMethod.hpp:58
Primitives(const Complete< PerfectGas< 1 >> &q)
Definition: perfect_gas/MusclHancockCharactersticMethod.hpp:67
double pressure
Definition: perfect_gas/MusclHancockCharactersticMethod.hpp:56
Primitives(const Complete< PerfectGas< 2 >> &q)
Definition: perfect_gas/MusclHancockCharactersticMethod.hpp:62