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/GrMhd/ValenciaDivClean/BoundaryCorrections/BoundaryCorrection.hpp"
12 #include "Evolution/Systems/GrMhd/ValenciaDivClean/Tags.hpp"
13 #include "NumericalAlgorithms/DiscontinuousGalerkin/Formulation.hpp"
14 #include "Options/Options.hpp"
16 #include "PointwiseFunctions/GeneralRelativity/Tags.hpp"
17 #include "Utilities/Gsl.hpp"
18 #include "Utilities/TMPL.hpp"
19 
20 /// \cond
21 class DataVector;
22 namespace gsl {
23 template <typename T>
24 class not_null;
25 } // namespace gsl
26 namespace PUP {
27 class er;
28 } // namespace PUP
29 /// \endcond
30 
32 /*!
33  * \brief An HLL Riemann solver
34  *
35  * Let \f$U\f$ be the evolved variable, \f$F^i\f$ the flux, and \f$n_i\f$ be the
36  * outward directed unit normal to the interface. Denoting \f$F := n_i F^i\f$,
37  * the HLL boundary correction is \cite Harten1983
38  *
39  * \f{align*}
40  * G_\text{HLL} = \frac{\lambda_\text{max} F_\text{int} +
41  * \lambda_\text{min} F_\text{ext}}{\lambda_\text{max} - \lambda_\text{min}}
42  * - \frac{\lambda_\text{min}\lambda_\text{max}}{\lambda_\text{max} -
43  * \lambda_\text{min}} \left(U_\text{int} - U_\text{ext}\right)
44  * \f}
45  *
46  * where "int" and "ext" stand for interior and exterior.
47  * \f$\lambda_\text{min}\f$ and \f$\lambda_\text{max}\f$ are defined as
48  *
49  * \f{align*}
50  * \lambda_\text{min} &=
51  * \text{min}\left(\lambda^{-}_\text{int},-\lambda^{+}_\text{ext}, 0\right) \\
52  * \lambda_\text{max} &=
53  * \text{max}\left(\lambda^{+}_\text{int},-\lambda^{-}_\text{ext}, 0\right)
54  * \f}
55  *
56  * where \f$\lambda^{+}\f$ (\f$\lambda^{-}\f$) is the largest characteristic
57  * speed in the outgoing (ingoing) direction. Note the minus signs in front of
58  * \f$\lambda^{\pm}_\text{ext}\f$, which is because an outgoing speed w.r.t. the
59  * neighboring element is an ingoing speed w.r.t. the local element, and vice
60  * versa. Similarly, the \f$F_{\text{ext}}\f$ term in \f$G_\text{HLL}\f$ has a
61  * positive sign because the outward directed normal of the neighboring element
62  * has the opposite sign, i.e. \f$n_i^{\text{ext}}=-n_i^{\text{int}}\f$.
63  *
64  * The characteristic/signal speeds are given in the documentation for
65  * `grmhd::ValenciaDivClean::characteristic_speeds()`. Since the fluid is
66  * travelling slower than the speed of light, the speeds we are interested in
67  * are
68  *
69  * \f{align*}{
70  * \lambda^{\pm}&=\pm\alpha-\beta^i n_i,
71  * \f}
72  *
73  * which correspond to the divergence cleaning field.
74  *
75  * \note
76  * - In the strong form the `dg_boundary_terms` function returns
77  * \f$G - F_\text{int}\f$
78  * - For either \f$\lambda_\text{min} = 0\f$ or \f$\lambda_\text{max} = 0\f$
79  * (i.e. all characteristics move in the same direction) the HLL boundary
80  * correction reduces to pure upwinding.
81  * - Some references use \f$S\f$ instead of \f$\lambda\f$ for the
82  * signal/characteristic speeds
83  * - It may be possible to use the slower speeds for the magnetic field and
84  * fluid part of the system in order to make the flux less dissipative for
85  * those variables.
86  */
87 class Hll final : public BoundaryCorrection {
88  public:
90  using type = Scalar<DataVector>;
91  };
93  using type = Scalar<DataVector>;
94  };
95 
96  using options = tmpl::list<>;
97  static constexpr Options::String help = {
98  "Computes the HLL boundary correction term for the GRMHD system."};
99 
100  Hll() = default;
101  Hll(const Hll&) = default;
102  Hll& operator=(const Hll&) = default;
103  Hll(Hll&&) = default;
104  Hll& operator=(Hll&&) = default;
105  ~Hll() override = default;
106 
107  /// \cond
108  explicit Hll(CkMigrateMessage* /*unused*/) noexcept;
109  using PUP::able::register_constructor;
111  /// \endcond
112  void pup(PUP::er& p) override; // NOLINT
113 
114  std::unique_ptr<BoundaryCorrection> get_clone() const noexcept override;
115 
116  using dg_package_field_tags =
117  tmpl::list<Tags::TildeD, Tags::TildeTau, Tags::TildeS<Frame::Inertial>,
118  Tags::TildeB<Frame::Inertial>, Tags::TildePhi,
119  ::Tags::NormalDotFlux<Tags::TildeD>,
120  ::Tags::NormalDotFlux<Tags::TildeTau>,
121  ::Tags::NormalDotFlux<Tags::TildeS<Frame::Inertial>>,
122  ::Tags::NormalDotFlux<Tags::TildeB<Frame::Inertial>>,
123  ::Tags::NormalDotFlux<Tags::TildePhi>,
124  LargestOutgoingCharSpeed, LargestIngoingCharSpeed>;
125  using dg_package_data_temporary_tags =
126  tmpl::list<gr::Tags::Lapse<DataVector>,
127  gr::Tags::Shift<3, Frame::Inertial, DataVector>>;
128  using dg_package_data_primitive_tags = tmpl::list<>;
129  using dg_package_data_volume_tags = tmpl::list<>;
130 
131  static double dg_package_data(
132  gsl::not_null<Scalar<DataVector>*> packaged_tilde_d,
133  gsl::not_null<Scalar<DataVector>*> packaged_tilde_tau,
134  gsl::not_null<tnsr::i<DataVector, 3, Frame::Inertial>*> packaged_tilde_s,
135  gsl::not_null<tnsr::I<DataVector, 3, Frame::Inertial>*> packaged_tilde_b,
136  gsl::not_null<Scalar<DataVector>*> packaged_tilde_phi,
137  gsl::not_null<Scalar<DataVector>*> packaged_normal_dot_flux_tilde_d,
138  gsl::not_null<Scalar<DataVector>*> packaged_normal_dot_flux_tilde_tau,
139  gsl::not_null<tnsr::i<DataVector, 3, Frame::Inertial>*>
140  packaged_normal_dot_flux_tilde_s,
141  gsl::not_null<tnsr::I<DataVector, 3, Frame::Inertial>*>
142  packaged_normal_dot_flux_tilde_b,
143  gsl::not_null<Scalar<DataVector>*> packaged_normal_dot_flux_tilde_phi,
144  gsl::not_null<Scalar<DataVector>*> packaged_largest_outgoing_char_speed,
145  gsl::not_null<Scalar<DataVector>*> packaged_largest_ingoing_char_speed,
146 
147  const Scalar<DataVector>& tilde_d, const Scalar<DataVector>& tilde_tau,
148  const tnsr::i<DataVector, 3, Frame::Inertial>& tilde_s,
149  const tnsr::I<DataVector, 3, Frame::Inertial>& tilde_b,
150  const Scalar<DataVector>& tilde_phi,
151 
152  const tnsr::I<DataVector, 3, Frame::Inertial>& flux_tilde_d,
153  const tnsr::I<DataVector, 3, Frame::Inertial>& flux_tilde_tau,
154  const tnsr::Ij<DataVector, 3, Frame::Inertial>& flux_tilde_s,
155  const tnsr::IJ<DataVector, 3, Frame::Inertial>& flux_tilde_b,
156  const tnsr::I<DataVector, 3, Frame::Inertial>& flux_tilde_phi,
157 
158  const Scalar<DataVector>& lapse,
159  const tnsr::I<DataVector, 3, Frame::Inertial>& shift,
160 
161  const tnsr::i<DataVector, 3, Frame::Inertial>& normal_covector,
162  const tnsr::I<DataVector, 3, Frame::Inertial>& normal_vector,
163  const std::optional<tnsr::I<DataVector, 3, Frame::Inertial>>&
164  /*mesh_velocity*/,
165  const std::optional<Scalar<DataVector>>&
166  normal_dot_mesh_velocity) noexcept;
167 
168  static void dg_boundary_terms(
169  gsl::not_null<Scalar<DataVector>*> boundary_correction_tilde_d,
170  gsl::not_null<Scalar<DataVector>*> boundary_correction_tilde_tau,
171  gsl::not_null<tnsr::i<DataVector, 3, Frame::Inertial>*>
172  boundary_correction_tilde_s,
173  gsl::not_null<tnsr::I<DataVector, 3, Frame::Inertial>*>
174  boundary_correction_tilde_b,
175  gsl::not_null<Scalar<DataVector>*> boundary_correction_tilde_phi,
176  const Scalar<DataVector>& tilde_d_int,
177  const Scalar<DataVector>& tilde_tau_int,
178  const tnsr::i<DataVector, 3, Frame::Inertial>& tilde_s_int,
179  const tnsr::I<DataVector, 3, Frame::Inertial>& tilde_b_int,
180  const Scalar<DataVector>& tilde_phi_int,
181  const Scalar<DataVector>& normal_dot_flux_tilde_d_int,
182  const Scalar<DataVector>& normal_dot_flux_tilde_tau_int,
183  const tnsr::i<DataVector, 3, Frame::Inertial>&
184  normal_dot_flux_tilde_s_int,
185  const tnsr::I<DataVector, 3, Frame::Inertial>&
186  normal_dot_flux_tilde_b_int,
187  const Scalar<DataVector>& normal_dot_flux_tilde_phi_int,
188  const Scalar<DataVector>& largest_outgoing_char_speed_int,
189  const Scalar<DataVector>& largest_ingoing_char_speed_int,
190  const Scalar<DataVector>& tilde_d_ext,
191  const Scalar<DataVector>& tilde_tau_ext,
192  const tnsr::i<DataVector, 3, Frame::Inertial>& tilde_s_ext,
193  const tnsr::I<DataVector, 3, Frame::Inertial>& tilde_b_ext,
194  const Scalar<DataVector>& tilde_phi_ext,
195  const Scalar<DataVector>& normal_dot_flux_tilde_d_ext,
196  const Scalar<DataVector>& normal_dot_flux_tilde_tau_ext,
197  const tnsr::i<DataVector, 3, Frame::Inertial>&
198  normal_dot_flux_tilde_s_ext,
199  const tnsr::I<DataVector, 3, Frame::Inertial>&
200  normal_dot_flux_tilde_b_ext,
201  const Scalar<DataVector>& normal_dot_flux_tilde_phi_ext,
202  const Scalar<DataVector>& largest_outgoing_char_speed_ext,
203  const Scalar<DataVector>& largest_ingoing_char_speed_ext,
204  dg::Formulation dg_formulation) noexcept;
205 };
206 } // namespace grmhd::ValenciaDivClean::BoundaryCorrections
CharmPupable.hpp
Options.hpp
db::SimpleTag
Mark a struct as a simple tag by inheriting from this.
Definition: Tag.hpp:36
dg
Functionality related to discontinuous Galerkin schemes.
Definition: ApplyMassMatrix.hpp:13
gr::lapse
Scalar< DataType > lapse(const tnsr::I< DataType, SpatialDim, Frame > &shift, const tnsr::aa< DataType, SpatialDim, Frame > &spacetime_metric) noexcept
Compute lapse from shift and spacetime metric.
grmhd::ValenciaDivClean::BoundaryCorrections::Hll::LargestIngoingCharSpeed
Definition: Hll.hpp:92
WRAPPED_PUPable_decl_template
#define WRAPPED_PUPable_decl_template(className)
Mark derived classes as serializable.
Definition: CharmPupable.hpp:22
grmhd::ValenciaDivClean::BoundaryCorrections::Hll
An HLL Riemann solver.
Definition: Hll.hpp:87
DataVector
Stores a collection of function values.
Definition: DataVector.hpp:46
memory
tnsr
Type aliases to construct common Tensors.
Definition: TypeAliases.hpp:31
gr::shift
tnsr::I< DataType, SpatialDim, Frame > shift(const tnsr::aa< DataType, SpatialDim, Frame > &spacetime_metric, const tnsr::II< DataType, SpatialDim, Frame > &inverse_spatial_metric) noexcept
Compute shift from spacetime metric and inverse spatial metric.
grmhd::ValenciaDivClean::BoundaryCorrections
Boundary corrections/numerical fluxes.
Definition: BoundaryCorrection.hpp:14
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
Frame
Definition: IndexType.hpp:36
gr
Definition: GaugeWave.hpp:28
grmhd::ValenciaDivClean::BoundaryCorrections::Hll::LargestOutgoingCharSpeed
Definition: Hll.hpp:89
optional
dg::Formulation
Formulation
The DG formulation to use.
Definition: Formulation.hpp:34
std::unique_ptr
Prefixes.hpp
grmhd::ValenciaDivClean::BoundaryCorrections::BoundaryCorrection
The base class used to make boundary corrections factory createable so they can be specified in the i...
Definition: BoundaryCorrection.hpp:24
gsl
Implementations from the Guideline Support Library.
Definition: ReadSpecPiecewisePolynomial.hpp:11
TMPL.hpp