Hll.hpp
2 // See LICENSE.txt for details.
3
4 #pragma once
5
6 #include <memory>
7 #include <optional>
8
11 #include "Evolution/Systems/NewtonianEuler/BoundaryCorrections/BoundaryCorrection.hpp"
12 #include "Evolution/Systems/NewtonianEuler/Tags.hpp"
13 #include "NumericalAlgorithms/DiscontinuousGalerkin/Formulation.hpp"
14 #include "Options/Options.hpp"
16 #include "PointwiseFunctions/Hydro/EquationsOfState/EquationOfState.hpp"
17 #include "PointwiseFunctions/Hydro/Tags.hpp"
18 #include "Utilities/Gsl.hpp"
19 #include "Utilities/TMPL.hpp"
20
21 /// \cond
22 class DataVector;
23 namespace gsl {
24 template <typename T>
25 class not_null;
26 } // namespace gsl
27 namespace PUP {
28 class er;
29 } // namespace PUP
30 /// \endcond
31
33 /*!
34  * \brief An HLL (Harten-Lax-van Leer) Riemann solver for NewtonianEuler system
35  *
36  * Let \f$U\f$ be the evolved variable, \f$F^i\f$ the flux, and \f$n_i\f$ be the
37  * outward directed unit normal to the interface. Denoting \f$F := n_i F^i\f$,
38  * the HLL boundary correction is \cite Harten1983
39  *
40  * \f{align*}
41  * G_\text{HLL} = \frac{\lambda_\text{max} F_\text{int} +
42  * \lambda_\text{min} F_\text{ext}}{\lambda_\text{max} - \lambda_\text{min}}
43  * - \frac{\lambda_\text{min}\lambda_\text{max}}{\lambda_\text{max} -
44  * \lambda_\text{min}} \left(U_\text{int} - U_\text{ext}\right)
45  * \f}
46  *
47  * where "int" and "ext" stand for interior and exterior.
48  * \f$\lambda_\text{min}\f$ and \f$\lambda_\text{max}\f$ are defined as
49  *
50  * \f{align*}
51  * \lambda_\text{min} &=
52  * \text{min}\left(\lambda^{-}_\text{int},-\lambda^{+}_\text{ext}, 0\right) \\
53  * \lambda_\text{max} &=
54  * \text{max}\left(\lambda^{+}_\text{int},-\lambda^{-}_\text{ext}, 0\right)
55  * \f}
56  *
57  * where \f$\lambda^{+}\f$ (\f$\lambda^{-}\f$) is the largest characteristic
58  * speed in the outgoing (ingoing) direction. Note the minus signs in front of
59  * \f$\lambda^{\pm}_\text{ext}\f$, which is because an outgoing speed w.r.t. the
60  * neighboring element is an ingoing speed w.r.t. the local element, and vice
61  * versa. Similarly, the \f$F_{\text{ext}}\f$ term in \f$G_\text{HLL}\f$ has a
62  * positive sign because the outward directed normal of the neighboring element
63  * has the opposite sign, i.e. \f$n_i^{\text{ext}}=-n_i^{\text{int}}\f$.
64  *
65  * For the NewtonianEuler system, \f$\lambda^\pm\f$ are given as
66  *
67  * \f{align*}
68  * \lambda^\pm = v^in_i \pm c_s
69  * \f}
70  *
71  * where \f$v^i\f$ is the spatial velocity and \f$c_s\f$ the sound speed.
72  *
73  * \note
74  * - In the strong form the dg_boundary_terms function returns \f$G - 75 * F_\text{int}\f$
76  * - For either \f$\lambda_\text{min} = 0\f$ or \f$\lambda_\text{max} = 0\f$
77  * (i.e. all characteristics move in the same direction) the HLL boundary
78  * correction reduces to pure upwinding.
79  * - Some references use \f$S\f$ instead of \f$\lambda\f$ for the
80  * signal/characteristic speeds
81  */
82 template <size_t Dim>
83 class Hll final : public BoundaryCorrection<Dim> {
84  public:
86  using type = Scalar<DataVector>;
87  };
89  using type = Scalar<DataVector>;
90  };
91
92  using options = tmpl::list<>;
93  static constexpr Options::String help = {
94  "Computes the HLL boundary correction term for the "
95  "Newtonian Euler/hydrodynamics system."};
96
97  Hll() = default;
98  Hll(const Hll&) = default;
99  Hll& operator=(const Hll&) = default;
100  Hll(Hll&&) = default;
101  Hll& operator=(Hll&&) = default;
102  ~Hll() override = default;
103
104  /// \cond
105  explicit Hll(CkMigrateMessage* msg) noexcept;
106  using PUP::able::register_constructor;
108  /// \endcond
109  void pup(PUP::er& p) override; // NOLINT
110
111  std::unique_ptr<BoundaryCorrection<Dim>> get_clone() const noexcept override;
112
113  using dg_package_field_tags =
114  tmpl::list<Tags::MassDensityCons, Tags::MomentumDensity<Dim>,
115  Tags::EnergyDensity,
116  ::Tags::NormalDotFlux<Tags::MassDensityCons>,
117  ::Tags::NormalDotFlux<Tags::MomentumDensity<Dim>>,
118  ::Tags::NormalDotFlux<Tags::EnergyDensity>,
119  LargestOutgoingCharSpeed, LargestIngoingCharSpeed>;
120  using dg_package_data_temporary_tags = tmpl::list<>;
121  using dg_package_data_primitive_tags =
122  tmpl::list<NewtonianEuler::Tags::Velocity<DataVector, Dim>,
123  NewtonianEuler::Tags::SpecificInternalEnergy<DataVector>>;
124  using dg_package_data_volume_tags =
125  tmpl::list<hydro::Tags::EquationOfStateBase>;
126
127  template <size_t ThermodynamicDim>
128  double dg_package_data(
129  gsl::not_null<Scalar<DataVector>*> packaged_mass_density,
130  gsl::not_null<tnsr::I<DataVector, Dim, Frame::Inertial>*>
131  packaged_momentum_density,
132  gsl::not_null<Scalar<DataVector>*> packaged_energy_density,
133  gsl::not_null<Scalar<DataVector>*> packaged_normal_dot_flux_mass_density,
134  gsl::not_null<tnsr::I<DataVector, Dim, Frame::Inertial>*>
135  packaged_normal_dot_flux_momentum_density,
136  gsl::not_null<Scalar<DataVector>*>
137  packaged_normal_dot_flux_energy_density,
138  gsl::not_null<Scalar<DataVector>*> packaged_largest_outgoing_char_speed,
139  gsl::not_null<Scalar<DataVector>*> packaged_largest_ingoing_char_speed,
140
141  const Scalar<DataVector>& mass_density,
142  const tnsr::I<DataVector, Dim, Frame::Inertial>& momentum_density,
143  const Scalar<DataVector>& energy_density,
144
145  const tnsr::I<DataVector, Dim, Frame::Inertial>& flux_mass_density,
146  const tnsr::IJ<DataVector, Dim, Frame::Inertial>& flux_momentum_density,
147  const tnsr::I<DataVector, Dim, Frame::Inertial>& flux_energy_density,
148
149  const tnsr::I<DataVector, Dim, Frame::Inertial>& velocity,
150  const Scalar<DataVector>& specific_internal_energy,
151
152  const tnsr::i<DataVector, Dim, Frame::Inertial>& normal_covector,
153  const std::optional<tnsr::I<DataVector, Dim, Frame::Inertial>>&
154  /*mesh_velocity*/,
155  const std::optional<Scalar<DataVector>>& normal_dot_mesh_velocity,
156  const EquationsOfState::EquationOfState<false, ThermodynamicDim>&
157  equation_of_state) const noexcept;
158
159  void dg_boundary_terms(
160  gsl::not_null<Scalar<DataVector>*> boundary_correction_mass_density,
161  gsl::not_null<tnsr::I<DataVector, Dim, Frame::Inertial>*>
162  boundary_correction_momentum_density,
163  gsl::not_null<Scalar<DataVector>*> boundary_correction_energy_density,
164  const Scalar<DataVector>& mass_density_int,
165  const tnsr::I<DataVector, Dim, Frame::Inertial>& momentum_density_int,
166  const Scalar<DataVector>& energy_density_int,
167  const Scalar<DataVector>& normal_dot_flux_mass_density_int,
168  const tnsr::I<DataVector, Dim, Frame::Inertial>&
169  normal_dot_flux_momentum_density_int,
170  const Scalar<DataVector>& normal_dot_flux_energy_density_int,
171  const Scalar<DataVector>& largest_outgoing_char_speed_int,
172  const Scalar<DataVector>& largest_ingoing_char_speed_int,
173  const Scalar<DataVector>& mass_density_ext,
174  const tnsr::I<DataVector, Dim, Frame::Inertial>& momentum_density_ext,
175  const Scalar<DataVector>& energy_density_ext,
176  const Scalar<DataVector>& normal_dot_flux_mass_density_ext,
177  const tnsr::I<DataVector, Dim, Frame::Inertial>&
178  normal_dot_flux_momentum_density_ext,
179  const Scalar<DataVector>& normal_dot_flux_energy_density_ext,
180  const Scalar<DataVector>& largest_outgoing_char_speed_ext,
181  const Scalar<DataVector>& largest_ingoing_char_speed_ext,
182  dg::Formulation dg_formulation) const noexcept;
183 };
184 } // namespace NewtonianEuler::BoundaryCorrections
EquationsOfState
Contains all equations of state, including base class.
Definition: DarkEnergyFluid.hpp:26
CharmPupable.hpp
Options.hpp
NewtonianEuler::BoundaryCorrections::Hll
An HLL (Harten-Lax-van Leer) Riemann solver for NewtonianEuler system.
Definition: Hll.hpp:83
NewtonianEuler::BoundaryCorrections::Hll::LargestOutgoingCharSpeed
Definition: Hll.hpp:85
db::SimpleTag
Mark a struct as a simple tag by inheriting from this.
Definition: Tag.hpp:36
NewtonianEuler
Items related to evolving the Newtonian Euler system.
Definition: EvolveNewtonianEulerFwd.hpp:8
NewtonianEuler::BoundaryCorrections
Boundary corrections/numerical fluxes.
Definition: BoundaryCorrection.hpp:13
dg
Functionality related to discontinuous Galerkin schemes.
Definition: ApplyMassMatrix.hpp:13
WRAPPED_PUPable_decl_template
#define WRAPPED_PUPable_decl_template(className)
Mark derived classes as serializable.
Definition: CharmPupable.hpp:22
DataVector
Stores a collection of function values.
Definition: DataVector.hpp:46
hydro
Items related to hydrodynamic systems.
Definition: SmoothFlow.hpp:19
memory
tnsr
Type aliases to construct common Tensors.
Definition: TypeAliases.hpp:31
Scalar
Tensor< T, Symmetry<>, index_list<> > Scalar
Definition: TypeAliases.hpp:21
NewtonianEuler::BoundaryCorrections::BoundaryCorrection
The base class used to create boundary corrections from input files and store them in the global cach...
Definition: BoundaryCorrection.hpp:28
Gsl.hpp
TypeAliases.hpp
Options::String
const char *const String
The string used in option structs.
Definition: Options.hpp:32
Frame
Definition: IndexType.hpp:36
optional
dg::Formulation
Formulation
The DG formulation to use.
Definition: Formulation.hpp:34
std::unique_ptr
Prefixes.hpp
gsl
Implementations from the Guideline Support Library.