FixToAtmosphere.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
6 #include <cstddef>
7 #include <limits>
8 
10 #include "Options/Options.hpp"
11 #include "PointwiseFunctions/Hydro/EquationsOfState/EquationOfState.hpp"
12 #include "PointwiseFunctions/Hydro/TagsDeclarations.hpp" // IWYU pragma: keep
13 #include "Utilities/Gsl.hpp"
14 #include "Utilities/TMPL.hpp"
15 
16 /// \cond
17 class DataVector;
18 
19 namespace PUP {
20 class er;
21 } // namespace PUP
22 /// \endcond
23 
24 // IWYU pragma: no_forward_declare EquationsOfState::EquationOfState
25 // IWYU pragma: no_forward_declare Tensor
26 // IWYU pragma: no_forward_declare hydro::Tags::EquationOfStateBase
27 // IWYU pragma: no_forward_declare hydro::Tags::SpatialVelocity
28 // IWYU pragma: no_forward_declare hydro::Tags::LorentzFactor
29 // IWYU pragma: no_forward_declare hydro::Tags::Pressure
30 // IWYU pragma: no_forward_declare hydro::Tags::RestMassDensity
31 // IWYU pragma: no_forward_declare hydro::Tags::SpecificEnthalpy
32 // IWYU pragma: no_forward_declare hydro::Tags::SpecificInternalEnergy
33 
34 namespace VariableFixing {
35 
36 /// \ingroup VariableFixingGroup
37 /// \brief Fix the primitive variables to an atmosphere in low density regions
38 ///
39 /// If the rest mass density is below \f$\rho_{\textrm{cutoff}}\f$
40 /// (DensityCutoff), it is set to \f$\rho_{\textrm{atm}}\f$
41 /// (DensityOfAtmosphere), and the pressure, specific internal energy (for
42 /// one-dimensional equations of state), and specific enthalpy are adjusted to
43 /// satisfy the equation of state. For a two-dimensional equation of state, the
44 /// specific internal energy is set to zero. In addition, the spatial velocity
45 /// is set to zero, and the Lorentz factor is set to one.
46 template <size_t ThermodynamicDim>
48  public:
49  /// \brief Rest mass density of the atmosphere
51  using type = double;
52  static type lower_bound() noexcept { return 0.0; }
53  static constexpr OptionString help = {"Density of atmosphere"};
54  };
55  /// \brief Rest mass density at which to impose the atmosphere. Should be
56  /// greater than or equal to the density of the atmosphere.
57  struct DensityCutoff {
58  using type = double;
59  static type lower_bound() noexcept { return 0.0; }
60  static constexpr OptionString help = {
61  "Density to impose atmosphere at. Must be >= rho_atm"};
62  };
63 
64  using options = tmpl::list<DensityOfAtmosphere, DensityCutoff>;
65  static constexpr OptionString help = {
66  "If the rest mass density is below DensityCutoff, it is set\n"
67  "to DensityOfAtmosphere, and the pressure, specific internal energy\n"
68  "(for one-dimensional equations of state), and specific enthalpy are\n"
69  "adjusted to satisfy the equation of state. For a two-dimensional\n"
70  "equation of state, the specific internal energy is set to zero.\n"
71  "In addition, the spatial velocity is set to zero, and the Lorentz\n"
72  "factor is set to one.\n"};
73 
74  FixToAtmosphere(double density_of_atmosphere, double density_cutoff,
75  const OptionContext& context = {});
76 
77  FixToAtmosphere() = default;
78  FixToAtmosphere(const FixToAtmosphere& /*rhs*/) = default;
79  FixToAtmosphere& operator=(const FixToAtmosphere& /*rhs*/) = default;
80  FixToAtmosphere(FixToAtmosphere&& /*rhs*/) noexcept = default;
81  FixToAtmosphere& operator=(FixToAtmosphere&& /*rhs*/) noexcept = default;
82  ~FixToAtmosphere() = default;
83 
84  // NOLINTNEXTLINE(google-runtime-references)
85  void pup(PUP::er& p) noexcept;
86 
87  using return_tags =
88  tmpl::list<hydro::Tags::RestMassDensity<DataVector>,
94  using argument_tags = tmpl::list<hydro::Tags::EquationOfStateBase>;
95 
96  void operator()(
97  gsl::not_null<Scalar<DataVector>*> rest_mass_density,
98  gsl::not_null<Scalar<DataVector>*> specific_internal_energy,
99  gsl::not_null<tnsr::I<DataVector, 3, Frame::Inertial>*> spatial_velocity,
100  gsl::not_null<Scalar<DataVector>*> lorentz_factor,
104  equation_of_state) const noexcept;
105 
106  private:
107  template <size_t LocalThermodynamicDim>
108  // NOLINTNEXTLINE(readability-redundant-declaration)
109  friend bool operator==(
111  const FixToAtmosphere<LocalThermodynamicDim>& rhs) noexcept;
112 
113  double density_of_atmosphere_{std::numeric_limits<double>::signaling_NaN()};
114  double density_cutoff_{std::numeric_limits<double>::signaling_NaN()};
115 };
116 
117 template <size_t ThermodynamicDim>
118 bool operator!=(const FixToAtmosphere<ThermodynamicDim>& lhs,
119  const FixToAtmosphere<ThermodynamicDim>& rhs) noexcept;
120 
121 } // namespace VariableFixing
Definition: Strahlkorper.hpp:14
The spatial velocity .
Definition: Tags.hpp:144
Fix the primitive variables to an atmosphere in low density regions.
Definition: FixToAtmosphere.hpp:47
The fluid pressure .
Definition: Tags.hpp:123
The specific internal energy .
Definition: Tags.hpp:176
Base class for equations of state depending on whether or not the system is relativistic, and the number of independent thermodynamic variables (ThermodynamicDim) needed to determine the pressure.
Definition: EquationOfState.hpp:63
T signaling_NaN(T... args)
Defines classes and functions for making classes creatable from input files.
Scalar< DataType > specific_enthalpy(const Scalar< DataType > &rest_mass_density, const Scalar< DataType > &specific_internal_energy, const Scalar< DataType > &pressure) noexcept
Computes the relativistic specific enthalpy as: where is the specific internal energy...
const char *const OptionString
The string used in option structs.
Definition: Options.hpp:26
Contains all variable fixers.
Definition: FixConservatives.cpp:55
The Lorentz factor .
Definition: Tags.hpp:64
Defines a list of useful type aliases for tensors.
Rest mass density at which to impose the atmosphere. Should be greater than or equal to the density o...
Definition: FixToAtmosphere.hpp:57
Stores a collection of function values.
Definition: DataVector.hpp:46
Information about the nested operations being performed by the parser, for use in printing errors...
Definition: Options.hpp:35
Wraps the template metaprogramming library used (brigand)
Defines functions and classes from the GSL.
Rest mass density of the atmosphere.
Definition: FixToAtmosphere.hpp:50
The specific enthalpy .
Definition: Tags.hpp:169
Tensor< T, Symmetry<>, index_list<> > Scalar
Scalar type.
Definition: TypeAliases.hpp:21
Require a pointer to not be a nullptr
Definition: ConservativeFromPrimitive.hpp:12