Schwarzschild.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
6 #include <ostream>
7 
10 #include "Elliptic/Systems/Xcts/Tags.hpp"
12 #include "Options/Options.hpp"
13 #include "PointwiseFunctions/GeneralRelativity/Tags.hpp"
14 #include "Utilities/TMPL.hpp"
15 #include "Utilities/TaggedTuple.hpp"
16 
17 /// \cond
18 namespace PUP {
19 class er;
20 } // namespace PUP
21 /// \endcond
22 
23 namespace Xcts::Solutions {
24 
25 /// Various coordinate systems in which to express the Schwarzschild solution
27  /*!
28  * \brief Isotropic Schwarzschild coordinates
29  *
30  * These arise from the canonical Schwarzschild coordinates by the radial
31  * transformation
32  *
33  * \f{equation}
34  * r = \bar{r}\left(1+\frac{M}{2\bar{r}}\right)^2
35  * \f}
36  *
37  * (Eq. (1.61) in \cite BaumgarteShapiro) where \f$r\f$ is the canonical
38  * Schwarzschild radius, also referred to as "areal" radius because it is
39  * defined such that spheres with constant \f$r\f$ have the area \f$4\pi
40  * r^2\f$, and \f$\bar{r}\f$ is the "isotropic" radius. In the isotropic
41  * radius the Schwarzschild spatial metric is conformally flat:
42  *
43  * \f{equation}
44  * \gamma_{ij}=\psi^4\eta_{ij} \quad \text{with conformal factor} \quad
45  * \psi=1+\frac{M}{2\bar{r}}
46  * \f}
47  *
48  * (Table 2.1 in \cite BaumgarteShapiro). Its lapse transforms to
49  *
50  * \f{equation}
51  * \alpha=\frac{1-M/(2\bar{r})}{1+M/(2\bar{r})}
52  * \f}
53  *
54  * and the shift vanishes (\f$\beta^i=0\f$) as it does in areal Schwarzschild
55  * coordinates. The solution also remains maximally sliced, i.e. \f$K=0\f$.
56  *
57  * The Schwarzschild horizon in these coordinates is at
58  * \f$\bar{r}=\frac{M}{2}\f$ due to the radial transformation from \f$r=2M\f$.
59  */
60  Isotropic,
61 };
62 
63 std::ostream& operator<<(std::ostream& os,
64  SchwarzschildCoordinates coords) noexcept;
65 
66 /*!
67  * \brief Schwarzschild spacetime in general relativity
68  *
69  * This class implements the Schwarzschild solution with mass parameter
70  * \f$M\f$ in various coordinate systems. See the entries of the
71  * `Xcts::Solutions::SchwarzschildCoordinates` enum for the available coordinate
72  * systems and for the solution variables in the respective coordinates.
73  */
74 template <SchwarzschildCoordinates Coords>
76  private:
77  struct Mass {
78  using type = double;
79  static constexpr Options::String help = "Mass parameter M";
80  };
81 
82  public:
83  using options = tmpl::list<Mass>;
84  static constexpr Options::String help{
85  "Schwarzschild spacetime in general relativity"};
86 
87  Schwarzschild() = default;
88  Schwarzschild(const Schwarzschild&) noexcept = delete;
89  Schwarzschild& operator=(const Schwarzschild&) noexcept = delete;
90  Schwarzschild(Schwarzschild&&) noexcept = default;
91  Schwarzschild& operator=(Schwarzschild&&) noexcept = default;
92  ~Schwarzschild() noexcept = default;
93 
94  explicit Schwarzschild(double mass) noexcept;
95 
96  /// The mass parameter \f$M\f$.
97  double mass() const noexcept;
98 
99  /// The radius of the Schwarzschild horizon in the given coordinates.
100  double radius_at_horizon() const noexcept;
101 
102  // @{
103  /// Retrieve variable at coordinates `x`
104  template <typename DataType>
105  auto variables(const tnsr::I<DataType, 3, Frame::Inertial>& x,
106  tmpl::list<Xcts::Tags::ConformalMetric<
107  DataType, 3, Frame::Inertial>> /*meta*/) const noexcept
110 
111  template <typename DataType>
112  auto variables(
113  const tnsr::I<DataType, 3, Frame::Inertial>& x,
114  tmpl::list<gr::Tags::TraceExtrinsicCurvature<DataType>> /*meta*/) const
115  noexcept
117 
118  template <typename DataType>
119  auto variables(
120  const tnsr::I<DataType, 3, Frame::Inertial>& x,
122  tmpl::size_t<3>, Frame::Inertial>> /*meta*/)
123  const noexcept -> tuples::TaggedTuple<
125  tmpl::size_t<3>, Frame::Inertial>>;
126 
127  template <typename DataType>
128  auto variables(
129  const tnsr::I<DataType, 3, Frame::Inertial>& x,
130  tmpl::list<Xcts::Tags::ConformalFactor<DataType>> /*meta*/) const noexcept
132 
133  template <typename DataType>
134  auto variables(
135  const tnsr::I<DataType, 3, Frame::Inertial>& x,
137  tmpl::size_t<3>, Frame::Inertial>> /*meta*/)
138  const noexcept -> tuples::TaggedTuple<
140  Frame::Inertial>>;
141 
142  template <typename DataType>
143  auto variables(
144  const tnsr::I<DataType, 3, Frame::Inertial>& x,
146  const noexcept
148 
149  template <typename DataType>
150  auto variables(
151  const tnsr::I<DataType, 3, Frame::Inertial>& x,
153  tmpl::size_t<3>, Frame::Inertial>> /*meta*/)
154  const noexcept -> tuples::TaggedTuple<
156  tmpl::size_t<3>, Frame::Inertial>>;
157 
158  template <typename DataType>
159  auto variables(const tnsr::I<DataType, 3, Frame::Inertial>& x,
160  tmpl::list<Xcts::Tags::ShiftBackground<
161  DataType, 3, Frame::Inertial>> /*meta*/) const noexcept
164 
165  template <typename DataType>
166  auto variables(
167  const tnsr::I<DataType, 3, Frame::Inertial>& x,
168  tmpl::list<
170  noexcept -> tuples::TaggedTuple<
172 
173  template <typename DataType>
174  auto variables(
175  const tnsr::I<DataType, 3, Frame::Inertial>& x,
176  tmpl::list<
178  noexcept -> tuples::TaggedTuple<
180 
181  template <typename DataType>
182  auto variables(const tnsr::I<DataType, 3, Frame::Inertial>& x,
183  tmpl::list<::Tags::FixedSource<
184  Xcts::Tags::ConformalFactor<DataType>>> /*meta*/) const
185  noexcept -> tuples::TaggedTuple<
187 
188  template <typename DataType>
189  auto variables(const tnsr::I<DataType, 3, Frame::Inertial>& x,
190  tmpl::list<::Tags::FixedSource<
192  const noexcept -> tuples::TaggedTuple<
194 
195  template <typename DataType>
196  auto variables(const tnsr::I<DataType, 3, Frame::Inertial>& x,
198  DataType, 3, Frame::Inertial>>> /*meta*/) const noexcept
201 
202  template <typename DataType>
203  auto variables(const tnsr::I<DataType, 3, Frame::Inertial>& x,
204  tmpl::list<gr::Tags::EnergyDensity<DataType>> /*meta*/) const
206 
207  template <typename DataType>
208  auto variables(const tnsr::I<DataType, 3, Frame::Inertial>& x,
209  tmpl::list<gr::Tags::StressTrace<DataType>> /*meta*/) const
211 
212  template <typename DataType>
213  auto variables(const tnsr::I<DataType, 3, Frame::Inertial>& x,
215  DataType>> /*meta*/) const
216  noexcept -> tuples::TaggedTuple<
218  // @}
219 
220  /// Retrieve a collection of variables at coordinates `x`
221  template <typename DataType, typename... Tags>
223  const tnsr::I<DataType, 3, Frame::Inertial>& x,
224  tmpl::list<Tags...> /*meta*/) const noexcept {
225  static_assert(sizeof...(Tags) > 1, "The requested tag is not implemented.");
226  return {tuples::get<Tags>(variables(x, tmpl::list<Tags>{}))...};
227  }
228 
229  void pup(PUP::er& p) noexcept { // NOLINT
230  p | mass_;
231  }
232 
233  private:
234  double mass_;
235 };
236 
237 template <SchwarzschildCoordinates Coords>
238 SPECTRE_ALWAYS_INLINE bool operator==(
239  const Schwarzschild<Coords>& lhs,
240  const Schwarzschild<Coords>& rhs) noexcept {
241  return lhs.mass() == rhs.mass();
242 }
243 
244 template <SchwarzschildCoordinates Coords>
246  const Schwarzschild<Coords>& lhs,
247  const Schwarzschild<Coords>& rhs) noexcept {
248  return not(lhs == rhs);
249 }
250 
251 } // namespace Xcts::Solutions
gr::Tags::TraceExtrinsicCurvature
Definition: Tags.hpp:114
Xcts::Solutions::Schwarzschild::variables
auto variables(const tnsr::I< DataType, 3, Frame::Inertial > &x, tmpl::list< Xcts::Tags::ConformalMetric< DataType, 3, Frame::Inertial >>) const noexcept -> tuples::TaggedTuple< Xcts::Tags::ConformalMetric< DataType, 3, Frame::Inertial >>
Retrieve variable at coordinates x
Xcts::Solutions::Schwarzschild::radius_at_horizon
double radius_at_horizon() const noexcept
The radius of the Schwarzschild horizon in the given coordinates.
Frame::Inertial
Definition: IndexType.hpp:44
Xcts::Tags::Conformal
The quantity Tag scaled by the Xcts::Tags::ConformalFactor to the given Power
Definition: Tags.hpp:35
std::rel_ops::operator!=
T operator!=(T... args)
Options.hpp
Xcts::Tags::LapseTimesConformalFactor
The product of lapse and conformal factor .
Definition: Tags.hpp:58
gr::Tags::EnergyDensity
The energy density , where denotes the normal to the spatial hypersurface.
Definition: Tags.hpp:132
Xcts::Tags::ConformalFactor
The conformal factor that rescales the spatial metric .
Definition: Tags.hpp:26
Tags::FixedSource
Prefix indicating a source term that is independent of dynamic variables.
Definition: Prefixes.hpp:75
SPECTRE_ALWAYS_INLINE
#define SPECTRE_ALWAYS_INLINE
Definition: ForceInline.hpp:16
std::ostream
Xcts::Tags::ShiftStrain
The symmetric "strain" of the shift vector .
Definition: Tags.hpp:120
Xcts::Solutions::SchwarzschildCoordinates
SchwarzschildCoordinates
Various coordinate systems in which to express the Schwarzschild solution.
Definition: Schwarzschild.hpp:26
Xcts::Tags::ShiftExcess
The dynamic part of the shift .
Definition: Tags.hpp:88
Xcts::Solutions::Schwarzschild::variables
tuples::TaggedTuple< Tags... > variables(const tnsr::I< DataType, 3, Frame::Inertial > &x, tmpl::list< Tags... >) const noexcept
Retrieve a collection of variables at coordinates x
Definition: Schwarzschild.hpp:222
tuples::TaggedTuple
An associative container that is indexed by structs.
Definition: TaggedTuple.hpp:271
Xcts::Tags::ShiftBackground
The constant part of the shift .
Definition: Tags.hpp:69
Xcts::Solutions::SchwarzschildCoordinates::Isotropic
@ Isotropic
Isotropic Schwarzschild coordinates.
gr::Tags::MomentumDensity
The spatial momentum density , where denotes the normal to the spatial hypersurface.
Definition: Tags.hpp:150
Options::String
const char *const String
The string used in option structs.
Definition: Options.hpp:32
Tensor.hpp
Tags::deriv
Prefix indicating spatial derivatives.
Definition: PartialDerivatives.hpp:52
Xcts::Solutions::Schwarzschild::mass
double mass() const noexcept
The mass parameter .
PartialDerivatives.hpp
Xcts::Solutions
Analytic solutions to the XCTS equations.
Definition: ConstantDensityStar.hpp:25
ostream
Prefixes.hpp
gr::Tags::StressTrace
The trace of the spatial stress-energy tensor .
Definition: Tags.hpp:141
TMPL.hpp
Xcts::Solutions::Schwarzschild
Schwarzschild spacetime in general relativity.
Definition: Schwarzschild.hpp:75