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/Burgers/BoundaryCorrections/BoundaryCorrection.hpp"
12 #include "Evolution/Systems/Burgers/Tags.hpp"
13 #include "NumericalAlgorithms/DiscontinuousGalerkin/Formulation.hpp"
14 #include "Options/Options.hpp"
16 #include "Utilities/TMPL.hpp"
17 
18 /// \cond
19 class DataVector;
20 namespace gsl {
21 template <typename T>
22 class not_null;
23 } // namespace gsl
24 namespace PUP {
25 class er;
26 } // namespace PUP
27 /// \endcond
28 
30 /*!
31  * \brief A Rusanov/local Lax-Friedrichs Riemann solver
32  *
33  * Let \f$U\f$ be the evolved variable, \f$F^i\f$ the flux, and \f$n_i\f$ be
34  * the outward directed unit normal to the interface. Denoting \f$F := n_i
35  * F^i\f$, the %Rusanov boundary correction is
36  *
37  * \f{align*}
38  * G_\text{Rusanov} = \frac{F_\text{int} - F_\text{ext}}{2} -
39  * \frac{\text{max}\left(|U_\text{int}|, |U_\text{ext}|\right)}{2}
40  * \left(U_\text{ext} - U_\text{int}\right),
41  * \f}
42  *
43  * where "int" and "ext" stand for interior and exterior. The minus sign in
44  * front of the \f$F_{\text{ext}}\f$ is necessary because the outward directed
45  * normal of the neighboring element has the opposite sign, i.e.
46  * \f$n_i^{\text{ext}}=-n_i^{\text{int}}\f$.
47  *
48  * \note In the strong form the `dg_boundary_terms` function returns
49  * \f$G - F_\text{int}\f$
50  */
51 class Rusanov final : public BoundaryCorrection {
52  private:
53  struct AbsCharSpeed : db::SimpleTag {
54  using type = Scalar<DataVector>;
55  };
56 
57  public:
58  using options = tmpl::list<>;
59  static constexpr Options::String help = {
60  "Computes the Rusanov or local Lax-Friedrichs boundary correction term "
61  "for the Burgers system."};
62 
63  Rusanov() = default;
64  Rusanov(const Rusanov&) = default;
65  Rusanov& operator=(const Rusanov&) = default;
66  Rusanov(Rusanov&&) = default;
67  Rusanov& operator=(Rusanov&&) = default;
68  ~Rusanov() override = default;
69 
70  /// \cond
71  explicit Rusanov(CkMigrateMessage* msg) noexcept;
72  using PUP::able::register_constructor;
74  /// \endcond
75  void pup(PUP::er& p) override; // NOLINT
76 
77  std::unique_ptr<BoundaryCorrection> get_clone() const noexcept override;
78 
79  using dg_package_field_tags =
80  tmpl::list<Tags::U, ::Tags::NormalDotFlux<Tags::U>, AbsCharSpeed>;
81  using dg_package_data_temporary_tags = tmpl::list<>;
82  using dg_package_data_volume_tags = tmpl::list<>;
83 
84  static double dg_package_data(
85  gsl::not_null<Scalar<DataVector>*> packaged_u,
86  gsl::not_null<Scalar<DataVector>*> packaged_normal_dot_flux,
87  gsl::not_null<Scalar<DataVector>*> packaged_abs_char_speed,
88  const Scalar<DataVector>& u,
89  const tnsr::I<DataVector, 1, Frame::Inertial>& flux_u,
90  const tnsr::i<DataVector, 1, Frame::Inertial>& normal_covector,
91  const std::optional<tnsr::I<DataVector, 1, Frame::Inertial>>&
92  mesh_velocity,
94  normal_dot_mesh_velocity) noexcept;
95 
96  static void dg_boundary_terms(
97  gsl::not_null<Scalar<DataVector>*> boundary_correction_u,
98  const Scalar<DataVector>& u_int,
99  const Scalar<DataVector>& normal_dot_flux_u_int,
100  const Scalar<DataVector>& abs_char_speed_int,
101  const Scalar<DataVector>& u_ext,
102  const Scalar<DataVector>& normal_dot_flux_u_ext,
103  const Scalar<DataVector>& abs_char_speed_ext,
104  dg::Formulation dg_formulation) noexcept;
105 };
106 } // namespace Burgers::BoundaryCorrections
CharmPupable.hpp
Options.hpp
db::SimpleTag
Mark a struct as a simple tag by inheriting from this.
Definition: Tag.hpp:36
WRAPPED_PUPable_decl_template
#define WRAPPED_PUPable_decl_template(className)
Mark derived classes as serializable.
Definition: CharmPupable.hpp:22
Burgers::BoundaryCorrections::Rusanov
A Rusanov/local Lax-Friedrichs Riemann solver.
Definition: Rusanov.hpp:51
DataVector
Stores a collection of function values.
Definition: DataVector.hpp:46
Burgers::BoundaryCorrections::BoundaryCorrection
The base class used to create boundary corrections from input files and store them in the global cach...
Definition: BoundaryCorrection.hpp:23
memory
Scalar
Tensor< T, Symmetry<>, index_list<> > Scalar
Definition: TypeAliases.hpp:21
Burgers::BoundaryCorrections
Boundary corrections/numerical fluxes.
Definition: BoundaryCorrection.hpp:13
TypeAliases.hpp
Options::String
const char *const String
The string used in option structs.
Definition: Options.hpp:32
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.
Definition: ReadSpecPiecewisePolynomial.hpp:11
TMPL.hpp
gsl::not_null
Require a pointer to not be a nullptr
Definition: ReadSpecPiecewisePolynomial.hpp:13