Hllc.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
6 #include <cstddef>
7 #include <string>
8 
9 #include "DataStructures/DataBox/Tag.hpp"
11 #include "Domain/FaceNormal.hpp"
12 #include "Evolution/Systems/NewtonianEuler/Characteristics.hpp"
13 #include "Evolution/Systems/NewtonianEuler/TagsDeclarations.hpp"
14 #include "Options/Options.hpp"
15 #include "Utilities/Gsl.hpp"
16 #include "Utilities/TMPL.hpp"
17 
18 /// \cond
19 namespace PUP {
20 class er;
21 } // namespace PUP
22 
23 namespace Tags {
24 template <typename>
25 struct NormalDotFlux;
26 template <typename>
27 struct Normalized;
28 } // namespace Tags
29 
30 class DataVector;
31 template <typename>
32 class Variables;
33 /// \endcond
34 
35 namespace NewtonianEuler {
36 namespace NumericalFluxes {
37 
38 /*!
39  * \brief Compute the HLLC numerical flux
40  *
41  * Class implementing the HLLC flux for the Newtonian Euler equations,
42  * originally introduced by E. F. Toro, M. Spruce and W. Speares \cite Toro1994.
43  * Let \f$F^k = [F^k(\rho), F^k(S^i), F^k(e)]^T\f$ be the fluxes of
44  * the conservative quantities \f$U = [\rho, S^i, e]^T\f$
45  * (see NewtonianEuler::ComputeFluxes). Denoting \f$v_n = n_k v^k\f$ and
46  * \f$F = n_kF^k\f$, where \f$v^k\f$ is the velocity and
47  * \f$n_k\f$ is the interface unit normal, the HLLC flux is
48  *
49  * \f{align*}
50  * G_\text{HLLC} =
51  * \begin{cases}
52  * F_\text{int}, & S_\text{min} > 0, \\
53  * G_{*\text{int}}, & S_\text{min} \leq 0\quad\text{and}\quad S_* > 0, \\
54  * G_{*\text{ext}}, & S_* \leq 0\quad\text{and}\quad S_\text{max} > 0, \\
55  * F_\text{ext}, & S_\text{max} \leq 0,
56  * \end{cases}
57  * \f}
58  *
59  * where
60  *
61  * \f{align*}
62  * G_{*\text{int}} &= \frac{S_*\left(F_\text{int}
63  * - S_\text{min}U_\text{int}\right)
64  * - S_\text{min} p_{*\text{int}}D_*}{S_* - S_\text{min}},\\
65  * G_{*\text{ext}} &= \frac{S_*\left(F_\text{ext}
66  * - S_\text{max}U_\text{ext}\right)
67  * - S_\text{max} p_{*\text{ext}}D_*}{S_* - S_\text{max}},
68  * \f}
69  *
70  * with
71  *
72  * \f{align*}
73  * p_{*\text{int}} &\equiv p_\text{int} + \rho_\text{int}
74  * \left[(v_n)_\text{int} - S_\text{min}\right]
75  * \left[(v_n)_\text{int} - S_*\right], \\
76  * p_{*\text{ext}} &\equiv p_\text{ext} + \rho_\text{ext}
77  * \left[(v_n)_\text{ext} - S_\text{max}\right]
78  * \left[(v_n)_\text{ext} - S_*\right], \\
79  * S_* &\equiv \frac{p_\text{int} + F(\rho)_\text{int}\left[(v_n)_\text{int}
80  * - S_\text{min}\right] - p_\text{ext}
81  * - F(\rho)_\text{ext}\left[(v_n)_\text{ext} -
82  * S_\text{max}\right]}{F(\rho)_\text{int} - \rho_\text{int}S_\text{min}
83  * - F(\rho)_\text{ext} + \rho_\text{ext}S_\text{max}},\\
84  * D_* &\equiv \left[\begin{array}{c}
85  * 0\\ n^i\\ S_*
86  * \end{array}\right],
87  * \f}
88  *
89  * and \f$S_\text{min}\f$ and \f$S_\text{max}\f$ are estimates of the minimum
90  * and maximum signal speeds bounding the ingoing and outgoing
91  * wavespeeds that arise when solving the Riemann problem. One requires
92  * \f$S_\text{min} \leq S_* \leq S_\text{max}\f$. As estimates, we use
93  *
94  * \f{align*}
95  * S_\text{min} &=
96  * \text{min}\left(\{\lambda_\text{int}\},\{\lambda_\text{ext}\}, 0\right)\\
97  * S_\text{max} &=
98  * \text{max}\left(\{\lambda_\text{int}\},\{\lambda_\text{ext}\}, 0\right),
99  * \f}
100  *
101  * where \f$\{\lambda\}\f$ is the set of all the characteristic speeds along a
102  * given normal. This way, the definition of \f$G_\text{HLLC}\f$ simplifies to
103  *
104  * \f{align*}
105  * G_\text{HLLC} =
106  * \begin{cases}
107  * \dfrac{S_*\left(F_\text{int} - S_\text{min}U_\text{int}\right)
108  * - S_\text{min} p_{*\text{int}}D_*}{S_* - S_\text{min}}, & S_* > 0, \\
109  * \dfrac{S_*\left(F_\text{ext} - S_\text{max}U_\text{ext}\right)
110  * - S_\text{max} p_{*\text{ext}}D_*}{S_* - S_\text{max}}, & S_* \leq 0. \\
111  * \end{cases}
112  * \f}
113  *
114  * \warning The HLLC flux implemented here does not incorporate any cure for
115  * the Carbuncle phenomenon or other shock instabilities reported in the
116  * literature. Prefer using another numerical flux in more than 1-d.
117  */
118 template <size_t Dim, typename Frame>
119 struct Hllc {
121 
122  /// Estimate for one of the signal speeds
124  using type = Scalar<DataVector>;
125  };
126 
127  /// Estimate for the other signal speed
129  using type = Scalar<DataVector>;
130  };
131 
132  /// The normal component of the velocity
134  using type = Scalar<DataVector>;
135  };
136 
137  using options = tmpl::list<>;
138  static constexpr OptionString help = {
139  "Compute the HLLC flux for the Newtonian Euler system."};
140 
141  // clang-tidy: non-const reference
142  void pup(PUP::er& /*p*/) noexcept {} // NOLINT
143 
144  using package_tags = tmpl::list<
152 
153  using argument_tags = tmpl::list<
154  ::Tags::NormalDotFlux<Tags::MassDensityCons>,
155  ::Tags::NormalDotFlux<Tags::MomentumDensity<Dim, Frame>>,
156  ::Tags::NormalDotFlux<Tags::EnergyDensity>, Tags::MassDensityCons,
157  Tags::MomentumDensity<Dim, Frame>, Tags::EnergyDensity,
158  Tags::Velocity<DataVector, Dim, Frame>, Tags::Pressure<DataVector>,
160  ::Tags::Normalized<domain::Tags::UnnormalizedFaceNormal<Dim, Frame>>>;
161 
162  void package_data(
163  gsl::not_null<Variables<package_tags>*> packaged_data,
164  const Scalar<DataVector>& normal_dot_flux_mass_density,
165  const tnsr::I<DataVector, Dim, Frame>& normal_dot_flux_momentum_density,
166  const Scalar<DataVector>& normal_dot_flux_energy_density,
167  const Scalar<DataVector>& mass_density,
168  const tnsr::I<DataVector, Dim, Frame>& momentum_density,
169  const Scalar<DataVector>& energy_density,
170  const tnsr::I<DataVector, Dim, Frame>& velocity,
171  const Scalar<DataVector>& pressure,
172  const db::const_item_type<char_speeds_tag>& characteristic_speeds,
173  const tnsr::i<DataVector, Dim, Frame>& interface_unit_normal) const
174  noexcept;
175 
176  void operator()(
177  gsl::not_null<Scalar<DataVector>*> normal_dot_numerical_flux_mass_density,
178  gsl::not_null<tnsr::I<DataVector, Dim, Frame>*>
179  normal_dot_numerical_flux_momentum_density,
181  normal_dot_numerical_flux_energy_density,
182  const Scalar<DataVector>& normal_dot_flux_mass_density_int,
183  const tnsr::I<DataVector, Dim, Frame>&
184  normal_dot_flux_momentum_density_int,
185  const Scalar<DataVector>& normal_dot_flux_energy_density_int,
186  const Scalar<DataVector>& mass_density_int,
187  const tnsr::I<DataVector, Dim, Frame>& momentum_density_int,
188  const Scalar<DataVector>& energy_density_int,
189  const Scalar<DataVector>& pressure_int,
190  const tnsr::i<DataVector, Dim, Frame>& interface_unit_normal,
191  const Scalar<DataVector>& normal_velocity_int,
192  const Scalar<DataVector>& largest_ingoing_speed_int,
193  const Scalar<DataVector>& largest_outgoing_speed_int,
194  const Scalar<DataVector>& minus_normal_dot_flux_mass_density_ext,
195  const tnsr::I<DataVector, Dim, Frame>&
196  minus_normal_dot_flux_momentum_density_ext,
197  const Scalar<DataVector>& minus_normal_dot_flux_energy_density_ext,
198  const Scalar<DataVector>& mass_density_ext,
199  const tnsr::I<DataVector, Dim, Frame>& momentum_density_ext,
200  const Scalar<DataVector>& energy_density_ext,
201  const Scalar<DataVector>& pressure_ext,
202  const tnsr::i<DataVector, Dim, Frame>& minus_interface_unit_normal,
203  const Scalar<DataVector>& minus_normal_velocity_ext,
204  // names are inverted w.r.t interior data. See package_data()
205  const Scalar<DataVector>& minus_largest_outgoing_speed_ext,
206  const Scalar<DataVector>& minus_largest_ingoing_speed_ext) const noexcept;
207 };
208 
209 } // namespace NumericalFluxes
210 } // namespace NewtonianEuler
Prefix indicating a boundary unit normal vector dotted into the flux.
Definition: Prefixes.hpp:124
The momentum density of the fluid.
Definition: Tags.hpp:43
Definition: Strahlkorper.hpp:14
The normalized (co)vector represented by Tag.
Definition: Magnitude.hpp:121
Estimate for one of the signal speeds.
Definition: Hllc.hpp:123
Estimate for the other signal speed.
Definition: Hllc.hpp:128
The macroscopic or flow velocity of the fluid.
Definition: Tags.hpp:57
Defines classes and functions for making classes creatable from input files.
Tags for the DataBox inherit from this type.
Definition: Tag.hpp:23
const char *const OptionString
The string used in option structs.
Definition: Options.hpp:30
The energy density of the fluid.
Definition: Tags.hpp:51
Definition: DataBoxTag.hpp:27
The fluid pressure.
Definition: Tags.hpp:72
Defines a list of useful type aliases for tensors.
Declares function unnormalized_face_normal.
Definition: Characteristics.hpp:120
Compute the HLLC numerical flux.
Definition: Hllc.hpp:119
Stores a collection of function values.
Definition: DataVector.hpp:42
Wraps the template metaprogramming library used (brigand)
Defines functions and classes from the GSL.
Tensor< T, Symmetry<>, index_list<> > Scalar
Scalar type.
Definition: TypeAliases.hpp:21
The mass density of the fluid (as a conservative variable).
Definition: Tags.hpp:37
The normal component of the velocity.
Definition: Hllc.hpp:133
Require a pointer to not be a nullptr
Definition: Gsl.hpp:182
Items related to evolving the Newtonian Euler system.
Definition: EvolveNewtonianEulerFwd.hpp:8