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