SpECTRE Documentation Coverage Report
Current view: top level - Evolution/VariableFixing - LimitLorentzFactor.hpp Hit Total Coverage
Commit: 9a905b0737f373631c1b8e8389b8f26e67fa5313 Lines: 4 31 12.9 %
Date: 2024-03-28 09:03:18
Legend: Lines: hit not hit

          Line data    Source code
       1           0 : // Distributed under the MIT License.
       2             : // See LICENSE.txt for details.
       3             : 
       4             : #pragma once
       5             : 
       6             : #include "DataStructures/Tensor/TypeAliases.hpp"  // IWYU pragma: keep
       7             : #include "Options/String.hpp"
       8             : #include "PointwiseFunctions/Hydro/TagsDeclarations.hpp"  // IWYU pragma: keep
       9             : #include "Utilities/Gsl.hpp"
      10             : #include "Utilities/TMPL.hpp"
      11             : 
      12             : /// \cond
      13             : class DataVector;
      14             : 
      15             : namespace PUP {
      16             : class er;
      17             : }  // namespace PUP
      18             : /// \endcond
      19             : 
      20             : // IWYU pragma: no_forward_declare hydro::Tags::SpatialVelocity
      21             : // IWYU pragma: no_forward_declare hydro::Tags::LorentzFactor
      22             : // IWYU pragma: no_forward_declare hydro::Tags::RestMassDensity
      23             : // IWYU pragma: no_forward_declare Tensor
      24             : 
      25             : namespace VariableFixing {
      26             : /*!
      27             :  *\ingroup VariableFixingGroup
      28             :  * \brief Limit the maximum Lorentz factor to LorentzFactorCap in regions where
      29             :  * the density is below MaxDensityCutoff.
      30             :  *
      31             :  * The Lorentz factor is set to LorentzFactorCap and the spatial velocity is
      32             :  * adjusted according to:
      33             :  * \f{align}
      34             :  * v^i_{(\textrm{new})} = \sqrt{\left(1 - \frac{1}{W_{(\textrm{new})}^2}\right)
      35             :  * \left(1 - \frac{1}{W_{(\textrm{old})}^2}\right)^{-1}} v^i_{(\textrm{old})}
      36             :  * \f}
      37             :  */
      38           1 : class LimitLorentzFactor {
      39             :  public:
      40             :   /// Do not apply the Lorentz factor cap above this density
      41           1 :   struct MaxDensityCutoff {
      42           0 :     using type = double;
      43           0 :     static type lower_bound() { return 0.0; }
      44           0 :     static constexpr Options::String help = {
      45             :         "Do not apply the Lorentz factor cap above this density"};
      46             :   };
      47             :   /// Largest Lorentz factor allowed. If a larger one is found, normalize
      48             :   /// velocity to have the Lorentz factor be this value.
      49           1 :   struct LorentzFactorCap {
      50           0 :     using type = double;
      51           0 :     static type lower_bound() { return 1.0; }
      52           0 :     static constexpr Options::String help = {"Largest Lorentz factor allowed."};
      53             :   };
      54             :   /// Whether or not the limiting is enabled
      55           1 :   struct Enable {
      56           0 :     using type = bool;
      57           0 :     static constexpr Options::String help = {
      58             :         "If true then the limiting is applied."};
      59             :   };
      60             : 
      61           0 :   using options = tmpl::list<MaxDensityCutoff, LorentzFactorCap, Enable>;
      62           0 :   static constexpr Options::String help = {
      63             :       "Limit the maximum Lorentz factor to LorentzFactorCap in regions where "
      64             :       "the\n"
      65             :       "density is below MaxDensityCutoff. The Lorentz factor is set to\n"
      66             :       "LorentzFactorCap and the spatial velocity is adjusted accordingly."};
      67             : 
      68           0 :   LimitLorentzFactor(double max_density_cutoff, double lorentz_factor_cap,
      69             :                      bool enable);
      70             : 
      71           0 :   LimitLorentzFactor() = default;
      72           0 :   LimitLorentzFactor(const LimitLorentzFactor& /*rhs*/) = default;
      73           0 :   LimitLorentzFactor& operator=(const LimitLorentzFactor& /*rhs*/) = default;
      74           0 :   LimitLorentzFactor(LimitLorentzFactor&& /*rhs*/) = default;
      75           0 :   LimitLorentzFactor& operator=(LimitLorentzFactor&& /*rhs*/) = default;
      76           0 :   ~LimitLorentzFactor() = default;
      77             : 
      78             :   // NOLINTNEXTLINE(google-runtime-references)
      79           0 :   void pup(PUP::er& p);
      80             : 
      81           0 :   using return_tags = tmpl::list<hydro::Tags::LorentzFactor<DataVector>,
      82             :                                  hydro::Tags::SpatialVelocity<DataVector, 3>>;
      83             : 
      84           0 :   using argument_tags = tmpl::list<hydro::Tags::RestMassDensity<DataVector>>;
      85             : 
      86           0 :   void operator()(
      87             :       gsl::not_null<Scalar<DataVector>*> lorentz_factor,
      88             :       gsl::not_null<tnsr::I<DataVector, 3, Frame::Inertial>*> spatial_velocity,
      89             :       const Scalar<DataVector>& rest_mass_density) const;
      90             : 
      91             :  private:
      92           0 :   friend bool operator==(const LimitLorentzFactor& lhs,
      93             :                          const LimitLorentzFactor& rhs);
      94             : 
      95           0 :   double max_density_cuttoff_;
      96           0 :   double lorentz_factor_cap_;
      97           0 :   bool enable_;
      98             : };
      99             : 
     100           0 : bool operator!=(const LimitLorentzFactor& lhs, const LimitLorentzFactor& rhs);
     101             : }  // namespace VariableFixing

Generated by: LCOV version 1.14