Line data Source code
1 0 : // Distributed under the MIT License.
2 : // See LICENSE.txt for details.
3 :
4 : #pragma once
5 :
6 : #include <cstddef>
7 : #include <limits>
8 : #include <optional>
9 : #include <string>
10 :
11 : #include "Evolution/Systems/GrMhd/ValenciaDivClean/PrimitiveRecoveryData.hpp"
12 :
13 : /// \cond
14 : namespace EquationsOfState {
15 : template <bool, size_t>
16 : class EquationOfState;
17 : } // namespace EquationsOfState
18 : namespace grmhd::ValenciaDivClean {
19 : class PrimitiveFromConservativeOptions;
20 : } // namespace grmhd::ValenciaDivClean
21 : /// \endcond
22 :
23 1 : namespace grmhd::ValenciaDivClean::PrimitiveRecoverySchemes {
24 :
25 : /*!
26 : * \brief Compute the primitive variables from the conservative variables using
27 : * the scheme of \cite Kastaun2020uxr.
28 : *
29 : * In the notation of the Kastaun paper, `tau` is \f$D q)\f$,
30 : * `momentum_density_squared` is \f$r^2 D^2\f$,
31 : * `momentum_density_dot_magnetic_field` is \f$t D^{\frac{3}{2}}\f$,
32 : * `magnetic_field_squared` is \f$s D\f$, and
33 : * `rest_mass_density_times_lorentz_factor` is \f$D\f$.
34 : * Furthermore, the returned `PrimitiveRecoveryData.rho_h_w_squared` is \f$x
35 : * D\f$.
36 : *
37 : * In terms of the conservative variables (in our notation):
38 : * \f{align*}
39 : * q = & \frac{{\tilde \tau}}{{\tilde D}} \\
40 : * r = & \frac{\gamma^{kl} {\tilde S}_k {\tilde S}_l}{{\tilde D}^2} \\
41 : * t^2 = & \frac{({\tilde B}^k {\tilde S}_k)^2}{{\tilde D}^3 \sqrt{\gamma}} \\
42 : * s = & \frac{\gamma_{kl} {\tilde B}^k {\tilde B}^l}{{\tilde D}\sqrt{\gamma}}
43 : * \f}
44 : *
45 : * where the conserved variables \f${\tilde D}\f$, \f${\tilde S}_i\f$,
46 : * \f${\tilde \tau}\f$, and \f${\tilde B}^i\f$ are a generalized mass-energy
47 : * density, momentum density, specific internal energy density, and magnetic
48 : * field, and \f$\gamma\f$ and \f$\gamma^{kl}\f$ are the determinant and inverse
49 : * of the spatial metric \f$\gamma_{kl}\f$.
50 : *
51 : * \note This scheme does not use the initial guess for the pressure.
52 : */
53 1 : class KastaunEtAl {
54 : public:
55 : template <bool EnforcePhysicality, typename EosType>
56 0 : static std::optional<PrimitiveRecoveryData> apply(
57 : double initial_guess_pressure, double tau,
58 : double momentum_density_squared,
59 : double momentum_density_dot_magnetic_field, double magnetic_field_squared,
60 : double rest_mass_density_times_lorentz_factor, double electron_fraction,
61 : const EosType& equation_of_state,
62 : const grmhd::ValenciaDivClean::PrimitiveFromConservativeOptions&
63 : primitive_from_conservative_options);
64 :
65 0 : static const std::string name() { return "KastaunEtAl"; }
66 :
67 : private:
68 0 : static constexpr size_t max_iterations_ = 100;
69 0 : static constexpr double absolute_tolerance_ =
70 : 10.0 * std::numeric_limits<double>::epsilon();
71 0 : static constexpr double relative_tolerance_ =
72 : 10.0 * std::numeric_limits<double>::epsilon();
73 : };
74 : } // namespace grmhd::ValenciaDivClean::PrimitiveRecoverySchemes
|