Rusanov.hpp
1 // Distributed under the MIT License.
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 A Rusanov/local Lax-Friedrichs Riemann solver
35  *
36  * Let \f$U\f$ be the state vector of evolved variables, \f$F^i\f$ the
37  * corresponding fluxes, and \f$n_i\f$ be the outward directed unit normal to
38  * the interface. Denoting \f$F := n_i F^i\f$, the %Rusanov boundary correction
39  * is
40  *
41  * \f{align*}
42  * G_\text{Rusanov} = \frac{F_\text{int} - F_\text{ext}}{2} -
43  * \frac{\text{max}\left(\{|\lambda_\text{int}|\},
44  * \{|\lambda_\text{ext}|\}\right)}{2} \left(U_\text{ext} - U_\text{int}\right),
45  * \f}
46  *
47  * where "int" and "ext" stand for interior and exterior, and
48  * \f$\{|\lambda|\}\f$ is the set of characteristic/signal speeds. The minus
49  * sign in front of the \f$F_{\text{ext}}\f$ is necessary because the outward
50  * directed normal of the neighboring element has the opposite sign, i.e.
51  * \f$n_i^{\text{ext}}=-n_i^{\text{int}}\f$. The characteristic/signal speeds
52  * are given by:
53  *
54  * \f{align*}
55  * \lambda_{\pm}&=v^i n_i \pm c_s, \\
56  * \lambda_v&=v^i n_i
57  * \f}
58  *
59  * where \f$v^i\f$ is the spatial velocity and \f$c_s\f$ the sound speed.
60  *
61  * \note In the strong form the `dg_boundary_terms` function returns
62  * \f$G - F_\text{int}\f$
63  */
64 template <size_t Dim>
65 class Rusanov final : public BoundaryCorrection<Dim> {
66  private:
67  struct AbsCharSpeed : db::SimpleTag {
68  using type = Scalar<DataVector>;
69  };
70 
71  public:
72  using options = tmpl::list<>;
73  static constexpr Options::String help = {
74  "Computes the Rusanov or local Lax-Friedrichs boundary correction term "
75  "for the Newtonian Euler/hydrodynamics system."};
76 
77  Rusanov() = default;
78  Rusanov(const Rusanov&) = default;
79  Rusanov& operator=(const Rusanov&) = default;
80  Rusanov(Rusanov&&) = default;
81  Rusanov& operator=(Rusanov&&) = default;
82  ~Rusanov() override = default;
83 
84  /// \cond
85  explicit Rusanov(CkMigrateMessage* msg) noexcept;
86  using PUP::able::register_constructor;
88  /// \endcond
89  void pup(PUP::er& p) override; // NOLINT
90 
91  std::unique_ptr<BoundaryCorrection<Dim>> get_clone() const noexcept override;
92 
93  using dg_package_field_tags =
94  tmpl::list<Tags::MassDensityCons, Tags::MomentumDensity<Dim>,
99  using dg_package_data_temporary_tags = tmpl::list<>;
100  using dg_package_data_primitive_tags =
101  tmpl::list<NewtonianEuler::Tags::Velocity<DataVector, Dim>,
103  using dg_package_data_volume_tags =
104  tmpl::list<hydro::Tags::EquationOfStateBase>;
105 
106  template <size_t ThermodynamicDim>
107  double dg_package_data(
108  gsl::not_null<Scalar<DataVector>*> packaged_mass_density,
109  gsl::not_null<tnsr::I<DataVector, Dim, Frame::Inertial>*>
110  packaged_momentum_density,
111  gsl::not_null<Scalar<DataVector>*> packaged_energy_density,
112  gsl::not_null<Scalar<DataVector>*> packaged_normal_dot_flux_mass_density,
113  gsl::not_null<tnsr::I<DataVector, Dim, Frame::Inertial>*>
114  packaged_normal_dot_flux_momentum_density,
116  packaged_normal_dot_flux_energy_density,
117  gsl::not_null<Scalar<DataVector>*> packaged_abs_char_speed,
118 
119  const Scalar<DataVector>& mass_density,
120  const tnsr::I<DataVector, Dim, Frame::Inertial>& momentum_density,
121  const Scalar<DataVector>& energy_density,
122 
123  const tnsr::I<DataVector, Dim, Frame::Inertial>& flux_mass_density,
124  const tnsr::IJ<DataVector, Dim, Frame::Inertial>& flux_momentum_density,
125  const tnsr::I<DataVector, Dim, Frame::Inertial>& flux_energy_density,
126 
127  const tnsr::I<DataVector, Dim, Frame::Inertial>& velocity,
128  const Scalar<DataVector>& specific_internal_energy,
129 
130  const tnsr::i<DataVector, Dim, Frame::Inertial>& normal_covector,
131  const std::optional<tnsr::I<DataVector, Dim, Frame::Inertial>>&
132  /*mesh_velocity*/,
133  const std::optional<Scalar<DataVector>>& normal_dot_mesh_velocity,
135  equation_of_state) const noexcept;
136 
137  void dg_boundary_terms(
138  gsl::not_null<Scalar<DataVector>*> boundary_correction_mass_density,
139  gsl::not_null<tnsr::I<DataVector, Dim, Frame::Inertial>*>
140  boundary_correction_momentum_density,
141  gsl::not_null<Scalar<DataVector>*> boundary_correction_energy_density,
142  const Scalar<DataVector>& mass_density_int,
143  const tnsr::I<DataVector, Dim, Frame::Inertial>& momentum_density_int,
144  const Scalar<DataVector>& energy_density_int,
145  const Scalar<DataVector>& normal_dot_flux_mass_density_int,
146  const tnsr::I<DataVector, Dim, Frame::Inertial>&
147  normal_dot_flux_momentum_density_int,
148  const Scalar<DataVector>& normal_dot_flux_energy_density_int,
149  const Scalar<DataVector>& abs_char_speed_int,
150  const Scalar<DataVector>& mass_density_ext,
151  const tnsr::I<DataVector, Dim, Frame::Inertial>& momentum_density_ext,
152  const Scalar<DataVector>& energy_density_ext,
153  const Scalar<DataVector>& normal_dot_flux_mass_density_ext,
154  const tnsr::I<DataVector, Dim, Frame::Inertial>&
155  normal_dot_flux_momentum_density_ext,
156  const Scalar<DataVector>& normal_dot_flux_energy_density_ext,
157  const Scalar<DataVector>& abs_char_speed_ext,
158  dg::Formulation dg_formulation) const noexcept;
159 };
160 } // namespace Burgers::BoundaryCorrections
CharmPupable.hpp
EquationsOfState::EquationOfState
Base class for equations of state depending on whether or not the system is relativistic,...
Definition: EquationOfState.hpp:63
Options.hpp
NewtonianEuler::Tags::SpecificInternalEnergy
The specific internal energy of the fluid.
Definition: Tags.hpp:60
db::SimpleTag
Mark a struct as a simple tag by inheriting from this.
Definition: Tag.hpp:36
Tags::NormalDotFlux
Prefix indicating a boundary unit normal vector dotted into the flux.
Definition: Prefixes.hpp:96
NewtonianEuler::BoundaryCorrections
Boundary corrections/numerical fluxes.
Definition: BoundaryCorrection.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
memory
NewtonianEuler::Tags::EnergyDensity
The energy density of the fluid.
Definition: Tags.hpp:45
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:24
Gsl.hpp
TypeAliases.hpp
Options::String
const char *const String
The string used in option structs.
Definition: Options.hpp:32
optional
NewtonianEuler::BoundaryCorrections::Rusanov
A Rusanov/local Lax-Friedrichs Riemann solver.
Definition: Rusanov.hpp:65
dg::Formulation
Formulation
The DG formulation to use.
Definition: Formulation.hpp:34
std::unique_ptr
Prefixes.hpp
gsl
Implementations from the Guideline Support Library.
Definition: ReadSpecThirdOrderPiecewisePolynomial.hpp:11
TMPL.hpp
gsl::not_null
Require a pointer to not be a nullptr
Definition: ReadSpecThirdOrderPiecewisePolynomial.hpp:13