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 : 12 : /// \cond 13 : namespace EquationsOfState { 14 : template <bool, size_t> 15 : class EquationOfState; 16 : } // namespace EquationsOfState 17 : namespace grmhd::ValenciaDivClean { 18 : class PrimitiveFromConservativeOptions; 19 : } // namespace grmhd::ValenciaDivClean 20 : /// \endcond 21 : 22 : namespace grmhd::ValenciaDivClean::PrimitiveRecoverySchemes { 23 : 24 : struct PrimitiveRecoveryData; 25 : 26 : /*! 27 : * \brief Compute the primitive variables from the conservative variables using 28 : * the scheme of \cite Galeazzi2013mia. 29 : * 30 : * In the notation of the Kastaun paper, `tau` is \f$D q\f$, 31 : * `momentum_density_squared` is \f$r^2 D^2\f$, 32 : * `rest_mass_density_times_lorentz_factor` is \f$D\f$. 33 : * Furthermore, the algorithm iterates over \f$z\f$, which is the Lorentz factor 34 : * times the absolute magnetitude of the velocity. 35 : * 36 : * In terms of the conservative variables (in our notation): 37 : * \f{align*} 38 : * q = & \frac{{\tilde \tau}}{{\tilde D}} \\ 39 : * r^2 = & \frac{\gamma^{kl} {\tilde S}_k {\tilde S}_l}{{\tilde D}^2} \\ 40 : * \f} 41 : * 42 : * where the conserved variables \f${\tilde D}\f$, \f${\tilde S}_i\f$ and 43 : * \f${\tilde \tau}\f$ are a generalized mass-energy 44 : * density, momentum density and specific internal energy density, 45 : * and \f$\gamma\f$ and \f$\gamma^{kl}\f$ are the determinant and inverse 46 : * of the spatial metric \f$\gamma_{kl}\f$. 47 : * 48 : * \note This scheme does not use the initial guess for the pressure. 49 : */ 50 1 : class KastaunEtAlHydro { 51 : public: 52 : template <bool EnforcePhysicality, typename EosType> 53 0 : static std::optional<PrimitiveRecoveryData> apply( 54 : double initial_guess_pressure, double tau, 55 : double momentum_density_squared, 56 : double momentum_density_dot_magnetic_field, double magnetic_field_squared, 57 : double rest_mass_density_times_lorentz_factor, double electron_fraction, 58 : const EosType& equation_of_state, 59 : const grmhd::ValenciaDivClean::PrimitiveFromConservativeOptions& 60 : primitive_from_conservative_options); 61 : 62 0 : static const std::string name() { return "KastaunEtAlHydro"; } 63 : 64 : private: 65 0 : static constexpr size_t max_iterations_ = 100; 66 0 : static constexpr double absolute_tolerance_ = 67 : 10.0 * std::numeric_limits<double>::epsilon(); 68 0 : static constexpr double relative_tolerance_ = 69 : 10.0 * std::numeric_limits<double>::epsilon(); 70 : }; 71 : } // namespace grmhd::ValenciaDivClean::PrimitiveRecoverySchemes