LimitLorentzFactor.hpp
1 // 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/Options.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  */
39  public:
40  /// Do not apply the Lorentz factor cap above this density
42  using type = double;
43  static type lower_bound() noexcept { return 0.0; }
44  static constexpr OptionString 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.
50  using type = double;
51  static type lower_bound() noexcept { return 1.0; }
52  static constexpr OptionString help = {"Largest Lorentz factor allowed."};
53  };
54 
55  using options = tmpl::list<MaxDensityCutoff, LorentzFactorCap>;
56  static constexpr OptionString help = {
57  "Limit the maximum Lorentz factor to LorentzFactorCap in regions where "
58  "the\n"
59  "density is below MaxDensityCutoff. The Lorentz factor is set to\n"
60  "LorentzFactorCap and the spatial velocity is adjusted accordingly."};
61 
62  LimitLorentzFactor(double max_density_cutoff,
63  double lorentz_factor_cap) noexcept;
64 
65  LimitLorentzFactor() = default;
66  LimitLorentzFactor(const LimitLorentzFactor& /*rhs*/) = default;
67  LimitLorentzFactor& operator=(const LimitLorentzFactor& /*rhs*/) = default;
68  LimitLorentzFactor(LimitLorentzFactor&& /*rhs*/) noexcept = default;
69  LimitLorentzFactor& operator=(LimitLorentzFactor&& /*rhs*/) noexcept =
70  default;
71  ~LimitLorentzFactor() = default;
72 
73  // NOLINTNEXTLINE(google-runtime-references)
74  void pup(PUP::er& p) noexcept;
75 
76  using return_tags = tmpl::list<hydro::Tags::LorentzFactor<DataVector>,
78 
79  using argument_tags = tmpl::list<hydro::Tags::RestMassDensity<DataVector>>;
80 
81  void operator()(
82  gsl::not_null<tnsr::I<DataVector, 3, Frame::Inertial>*> spatial_velocity,
83  gsl::not_null<Scalar<DataVector>*> lorentz_factor,
84  const Scalar<DataVector>& rest_mass_density) const noexcept;
85 
86  private:
87  friend bool operator==(const LimitLorentzFactor& lhs,
88  const LimitLorentzFactor& rhs) noexcept;
89 
90  double max_density_cuttoff_;
91  double lorentz_factor_cap_;
92 };
93 
94 bool operator!=(const LimitLorentzFactor& lhs,
95  const LimitLorentzFactor& rhs) noexcept;
96 } // namespace VariableFixing
Definition: Strahlkorper.hpp:14
The spatial velocity .
Definition: Tags.hpp:144
Limit the maximum Lorentz factor to LorentzFactorCap in regions where the density is below MaxDensity...
Definition: LimitLorentzFactor.hpp:38
Defines classes and functions for making classes creatable from input files.
const char *const OptionString
The string used in option structs.
Definition: Options.hpp:26
Contains all variable fixers.
Definition: FixConservatives.cpp:55
Defines a list of useful type aliases for tensors.
Stores a collection of function values.
Definition: DataVector.hpp:46
Wraps the template metaprogramming library used (brigand)
Defines functions and classes from the GSL.
Largest Lorentz factor allowed. If a larger one is found, normalize velocity to have the Lorentz fact...
Definition: LimitLorentzFactor.hpp:49
Do not apply the Lorentz factor cap above this density.
Definition: LimitLorentzFactor.hpp:41
Tensor< T, Symmetry<>, index_list<> > Scalar
Scalar type.
Definition: TypeAliases.hpp:21
Require a pointer to not be a nullptr
Definition: ConservativeFromPrimitive.hpp:12