Hll.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 An HLL (Harten-Lax-van Leer) 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 HLL boundary correction is \cite Harten1983
36  *
37  * \f{align*}
38  * G_\text{HLL} = \frac{\lambda_\text{max} F_\text{int} +
39  * \lambda_\text{min} F_\text{ext}}{\lambda_\text{max} - \lambda_\text{min}}
40  * - \frac{\lambda_\text{min}\lambda_\text{max}}{\lambda_\text{max} -
41  * \lambda_\text{min}} \left(U_\text{int} - U_\text{ext}\right)
42  * \f}
43  *
44  * where "int" and "ext" stand for interior and exterior, and \cite Davis1988
45  *
46  * \f{align*}
47  * \lambda_\text{min} &= \text{min}\left(U_\text{int},-U_\text{ext}, 0\right) \\
48  * \lambda_\text{max} &= \text{max}\left(U_\text{int},-U_\text{ext}, 0\right),
49  * \f}
50  *
51  * The positive sign in front of the \f$F_{\text{ext}}\f$ in \f$G_\text{HLL}\f$
52  * and the minus signs in front of the \f$U_\text{ext}\f$ terms in
53  * \f$\lambda_\text{min}\f$ and \f$\lambda_\text{max}\f$ terms are necessary
54  * because the outward directed normal of the neighboring element has the
55  * opposite sign, i.e. \f$n_i^{\text{ext}}=-n_i^{\text{int}}\f$. Note that for
56  * either \f$\lambda_\text{min} = 0\f$ or \f$\lambda_\text{max} = 0\f$ (i.e. all
57  * characteristics move in the same direction) the HLL boundary correction
58  * reduces to pure upwinding.
59  *
60  * \note
61  * - In the strong form the `dg_boundary_terms` function returns
62  * \f$G - F_\text{int}\f$
63  * - Some references use \f$S\f$ instead of \f$\lambda\f$ for the
64  * signal/characteristic speeds
65  */
66 class Hll final : public BoundaryCorrection {
67  private:
68  struct CharSpeed : db::SimpleTag {
69  using type = Scalar<DataVector>;
70  };
71 
72  public:
73  using options = tmpl::list<>;
74  static constexpr Options::String help = {
75  "Computes the HLL boundary correction term for the Burgers system."};
76 
77  Hll() = default;
78  Hll(const Hll&) = default;
79  Hll& operator=(const Hll&) = default;
80  Hll(Hll&&) = default;
81  Hll& operator=(Hll&&) = default;
82  ~Hll() override = default;
83 
84  /// \cond
85  explicit Hll(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> get_clone() const noexcept override;
92 
93  using dg_package_field_tags =
94  tmpl::list<Tags::U, ::Tags::NormalDotFlux<Tags::U>, CharSpeed>;
95  using dg_package_data_temporary_tags = tmpl::list<>;
96  using dg_package_data_volume_tags = tmpl::list<>;
97 
98  static double dg_package_data(
99  gsl::not_null<Scalar<DataVector>*> packaged_u,
100  gsl::not_null<Scalar<DataVector>*> packaged_normal_dot_flux,
101  gsl::not_null<Scalar<DataVector>*> packaged_char_speed,
102  const Scalar<DataVector>& u,
103  const tnsr::I<DataVector, 1, Frame::Inertial>& flux_u,
104  const tnsr::i<DataVector, 1, Frame::Inertial>& normal_covector,
105  const std::optional<tnsr::I<DataVector, 1, Frame::Inertial>>&
106  mesh_velocity,
108  normal_dot_mesh_velocity) noexcept;
109 
110  static void dg_boundary_terms(
111  gsl::not_null<Scalar<DataVector>*> boundary_correction_u,
112  const Scalar<DataVector>& u_int,
113  const Scalar<DataVector>& normal_dot_flux_u_int,
114  const Scalar<DataVector>& abs_char_speed_int,
115  const Scalar<DataVector>& u_ext,
116  const Scalar<DataVector>& normal_dot_flux_u_ext,
117  const Scalar<DataVector>& abs_char_speed_ext,
118  dg::Formulation dg_formulation) noexcept;
119 };
120 } // namespace Burgers::BoundaryCorrections
CharmPupable.hpp
Burgers::BoundaryCorrections::Hll
An HLL (Harten-Lax-van Leer) Riemann solver.
Definition: Hll.hpp:66
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
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