Kerr.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
6 #include <cstddef>
7 #include <pup.h>
8 
9 #include "DataStructures/CachedTempBuffer.hpp"
12 #include "Elliptic/Systems/Xcts/Tags.hpp"
15 #include "Options/Options.hpp"
17 #include "PointwiseFunctions/AnalyticSolutions/GeneralRelativity/KerrSchild.hpp"
18 #include "PointwiseFunctions/AnalyticSolutions/Xcts/AnalyticSolution.hpp"
19 #include "PointwiseFunctions/AnalyticSolutions/Xcts/CommonVariables.hpp"
20 #include "PointwiseFunctions/GeneralRelativity/Tags.hpp"
21 #include "Utilities/Gsl.hpp"
22 #include "Utilities/TMPL.hpp"
23 #include "Utilities/TaggedTuple.hpp"
24 
25 namespace Xcts::Solutions {
26 namespace detail {
27 
28 template <typename DataType>
29 struct KerrVariables;
30 
31 template <typename DataType>
32 using KerrVariablesCache = cached_temp_buffer_from_typelist<
33  KerrVariables<DataType>,
35  common_tags<DataType>,
36  Tags::ConformalMetric<DataType, 3, Frame::Inertial>,
38  tmpl::size_t<3>, Frame::Inertial>,
41  Tags::ConformalFactor<DataType>,
44  gr::Tags::Lapse<DataType>, Tags::LapseTimesConformalFactor<DataType>,
46  tmpl::size_t<3>, Frame::Inertial>,
47  Tags::ShiftBackground<DataType, 3, Frame::Inertial>,
48  Tags::LongitudinalShiftBackgroundMinusDtConformalMetric<
49  DataType, 3, Frame::Inertial>,
50  Tags::ShiftExcess<DataType, 3, Frame::Inertial>,
51  Tags::ShiftStrain<DataType, 3, Frame::Inertial>,
52  Tags::Conformal<gr::Tags::EnergyDensity<DataType>, 0>,
53  Tags::Conformal<gr::Tags::StressTrace<DataType>, 0>,
54  Tags::Conformal<gr::Tags::MomentumDensity<3, Frame::Inertial, DataType>,
55  0>>>;
56 
57 template <typename DataType>
58 struct KerrVariables : CommonVariables<DataType, KerrVariablesCache<DataType>> {
59  static constexpr size_t Dim = 3;
60  using Cache = KerrVariablesCache<DataType>;
61  using CommonVariables<DataType, KerrVariablesCache<DataType>>::operator();
62 
63  const tnsr::I<DataType, Dim>& x;
65 
66  void operator()(
67  gsl::not_null<tnsr::ii<DataType, Dim>*> conformal_metric,
69  Tags::ConformalMetric<DataType, Dim, Frame::Inertial> /*meta*/)
70  const noexcept;
71  void operator()(
72  gsl::not_null<tnsr::II<DataType, Dim>*> inv_conformal_metric,
74  Tags::InverseConformalMetric<DataType, Dim, Frame::Inertial> /*meta*/)
75  const noexcept;
76  void operator()(
77  gsl::not_null<tnsr::ijj<DataType, Dim>*> deriv_conformal_metric,
79  ::Tags::deriv<Tags::ConformalMetric<DataType, Dim, Frame::Inertial>,
80  tmpl::size_t<Dim>, Frame::Inertial> /*meta*/)
81  const noexcept;
82  void operator()(
83  gsl::not_null<Scalar<DataType>*> trace_extrinsic_curvature,
84  gsl::not_null<Cache*> cache,
85  gr::Tags::TraceExtrinsicCurvature<DataType> /*meta*/) const noexcept;
86  void operator()(
87  gsl::not_null<Scalar<DataType>*> dt_trace_extrinsic_curvature,
88  gsl::not_null<Cache*> cache,
89  ::Tags::dt<gr::Tags::TraceExtrinsicCurvature<DataType>> /*meta*/)
90  const noexcept;
91  void operator()(gsl::not_null<Scalar<DataType>*> conformal_factor,
92  gsl::not_null<Cache*> cache,
93  Tags::ConformalFactor<DataType> /*meta*/) const noexcept;
94  void operator()(
95  gsl::not_null<tnsr::i<DataType, Dim>*> conformal_factor_gradient,
96  gsl::not_null<Cache*> cache,
97  ::Tags::deriv<Xcts::Tags::ConformalFactor<DataType>, tmpl::size_t<Dim>,
98  Frame::Inertial> /*meta*/) const noexcept;
99  void operator()(gsl::not_null<Scalar<DataType>*> lapse,
100  gsl::not_null<Cache*> cache,
101  gr::Tags::Lapse<DataType> /*meta*/) const noexcept;
102  void operator()(
103  gsl::not_null<Scalar<DataType>*> lapse_times_conformal_factor,
104  gsl::not_null<Cache*> cache,
105  Tags::LapseTimesConformalFactor<DataType> /*meta*/) const noexcept;
106  void operator()(gsl::not_null<tnsr::i<DataType, Dim>*>
107  lapse_times_conformal_factor_gradient,
108  gsl::not_null<Cache*> cache,
109  ::Tags::deriv<Tags::LapseTimesConformalFactor<DataType>,
110  tmpl::size_t<Dim>, Frame::Inertial> /*meta*/)
111  const noexcept;
112  void operator()(
113  gsl::not_null<tnsr::I<DataType, Dim>*> shift_background,
114  gsl::not_null<Cache*> cache,
115  Tags::ShiftBackground<DataType, Dim, Frame::Inertial> /*meta*/)
116  const noexcept;
117  void operator()(gsl::not_null<tnsr::II<DataType, Dim, Frame::Inertial>*>
118  longitudinal_shift_background_minus_dt_conformal_metric,
119  gsl::not_null<Cache*> cache,
120  Tags::LongitudinalShiftBackgroundMinusDtConformalMetric<
121  DataType, Dim, Frame::Inertial> /*meta*/) const noexcept;
122  void operator()(gsl::not_null<tnsr::I<DataType, Dim>*> shift_excess,
123  gsl::not_null<Cache*> cache,
124  Tags::ShiftExcess<DataType, Dim, Frame::Inertial> /*meta*/)
125  const noexcept;
126  void operator()(gsl::not_null<tnsr::ii<DataType, Dim>*> shift_strain,
127  gsl::not_null<Cache*> cache,
128  Tags::ShiftStrain<DataType, Dim, Frame::Inertial> /*meta*/)
129  const noexcept;
130  void operator()(gsl::not_null<Scalar<DataType>*> energy_density,
131  gsl::not_null<Cache*> cache,
132  Tags::Conformal<gr::Tags::EnergyDensity<DataType>,
133  0> /*meta*/) const noexcept;
134  void operator()(gsl::not_null<Scalar<DataType>*> stress_trace,
135  gsl::not_null<Cache*> cache,
136  Tags::Conformal<gr::Tags::StressTrace<DataType>, 0> /*meta*/)
137  const noexcept;
138  void operator()(
139  gsl::not_null<tnsr::I<DataType, Dim>*> momentum_density,
140  gsl::not_null<Cache*> cache,
141  Tags::Conformal<gr::Tags::MomentumDensity<Dim, Frame::Inertial, DataType>,
142  0> /*meta*/) const noexcept;
143 };
144 
145 } // namespace detail
146 
147 // The following implements the registration and factory-creation mechanism
148 
149 /// \cond
150 template <typename Registrars>
151 struct Kerr;
152 
153 namespace Registrars {
154 struct Kerr {
155  template <typename Registrars>
156  using f = Solutions::Kerr<Registrars>;
157 };
158 } // namespace Registrars
159 /// \endcond
160 
161 /*!
162  * \brief Kerr spacetime in general relativity
163  *
164  * This class implements the Kerr solution to the XCTS equations. It is
165  * currently implemented in Kerr-Schild coordinates only and derives most
166  * quantities from the `gr::Solution::KerrSchild` class. It poses a
167  * non-conformally-flat problem to the XCTS equations.
168  *
169  * The conformal factor in this solution is set to \f$\psi=1\f$, so the
170  * conformal background-metric is the spatial Kerr metric. It is possible to
171  * choose a different \f$\psi\f$ so the solution is non-trivial in this
172  * variable, though that is probably only useful for testing and currently not
173  * implemented. It should be noted, however, that the combination of
174  * \f$\psi=1\f$ and apparent-horizon boundary conditions poses a hard problem to
175  * the nonlinear solver when starting at a flat initial guess. This is because
176  * the strongly-nonlinear boundary-conditions couple the variables in such a way
177  * that the solution is initially corrected away from \f$\psi=1\f$ and is then
178  * unable to recover. A conformal-factor profile such as \f$\psi=1 +
179  * \frac{M}{2r}\f$ (resembling isotropic coordinates) resolves this issue. In
180  * production solves this is not an issue because we choose a much better
181  * initial guess than flatness, such as a superposition of Kerr solutions for
182  * black-hole binary initial data.
183  */
184 template <typename Registrars = tmpl::list<Solutions::Registrars::Kerr>>
185 class Kerr : public AnalyticSolution<Registrars>,
187  public:
188  using KerrSchild::KerrSchild;
189  using PUP::able::register_constructor;
191 
192  template <typename DataType, typename... RequestedTags>
193  tuples::TaggedTuple<RequestedTags...> variables(
194  const tnsr::I<DataType, 3, Frame::Inertial>& x,
195  tmpl::list<RequestedTags...> /*meta*/) const noexcept {
196  using VarsComputer = detail::KerrVariables<DataType>;
197  typename VarsComputer::Cache cache{
198  get_size(*x.begin()),
199  VarsComputer{
200  {{std::nullopt, std::nullopt}},
201  x,
203  return {cache.get_var(RequestedTags{})...};
204  }
205 
206  template <typename DataType, typename... RequestedTags>
207  tuples::TaggedTuple<RequestedTags...> variables(
208  const tnsr::I<DataType, 3, Frame::Inertial>& x, const Mesh<3>& mesh,
209  const InverseJacobian<DataVector, 3, Frame::Logical, Frame::Inertial>&
210  inv_jacobian,
211  tmpl::list<RequestedTags...> /*meta*/) const noexcept {
212  using VarsComputer = detail::KerrVariables<DataType>;
213  typename VarsComputer::Cache cache{
214  get_size(*x.begin()),
215  VarsComputer{
216  {{mesh, inv_jacobian}},
217  x,
219  return {cache.get_var(RequestedTags{})...};
220  }
221 
222  void pup(PUP::er& p) noexcept override {
223  gr::Solutions::KerrSchild::pup(p);
225  }
226 };
227 
228 /// \cond
229 template <typename Registrars>
230 PUP::able::PUP_ID Kerr<Registrars>::my_PUP_ID = 0; // NOLINT
231 /// \endcond
232 
233 } // namespace Xcts::Solutions
gr::Tags::TraceExtrinsicCurvature
Definition: Tags.hpp:120
Xcts
Items related to solving the Extended Conformal Thin Sandwich (XCTS) decomposition of the Einstein co...
Definition: Flatness.hpp:22
gr::Solutions::KerrSchild
Kerr black hole in Kerr-Schild coordinates.
Definition: KerrSchild.hpp:215
CharmPupable.hpp
Frame::Inertial
Definition: IndexType.hpp:44
Divergence.hpp
Options.hpp
gr::Solutions::KerrSchild::IntermediateVars
Definition: KerrSchild.hpp:496
get_size
decltype(auto) get_size(const T &t, SizeFunction size=GetContainerSize{}) noexcept
Retrieve the size of t if t.size() is a valid expression, otherwise if T is fundamental or a std::com...
Definition: ContainerHelpers.hpp:145
domain::push_back
CoordinateMap< SourceFrame, TargetFrame, Maps..., NewMap > push_back(CoordinateMap< SourceFrame, TargetFrame, Maps... > old_map, NewMap new_map) noexcept
Creates a CoordinateMap by appending the new map to the end of the old maps.
gr::lapse
Scalar< DataType > lapse(const tnsr::I< DataType, SpatialDim, Frame > &shift, const tnsr::aa< DataType, SpatialDim, Frame > &spacetime_metric) noexcept
Compute lapse from shift and spacetime metric.
Xcts::Solutions::Kerr
Kerr spacetime in general relativity.
Definition: Kerr.hpp:185
WRAPPED_PUPable_decl_template
#define WRAPPED_PUPable_decl_template(className)
Mark derived classes as serializable.
Definition: CharmPupable.hpp:22
cstddef
Xcts::Solutions::AnalyticSolution
Base class for analytic solutions of the XCTS equations.
Definition: AnalyticSolution.hpp:34
tuples::TaggedTuple
An associative container that is indexed by structs.
Definition: TaggedTuple.hpp:271
Mesh
Holds the number of grid points, basis, and quadrature in each direction of the computational grid.
Definition: Mesh.hpp:49
tnsr
Type aliases to construct common Tensors.
Definition: TypeAliases.hpp:31
Tags::dt
Prefix indicating a time derivative.
Definition: Prefixes.hpp:29
ActionTesting::cache
Parallel::GlobalCache< Metavariables > & cache(MockRuntimeSystem< Metavariables > &runner, const ArrayIndex &array_index) noexcept
Returns the GlobalCache of Component with index array_index.
Definition: MockRuntimeSystemFreeFunctions.hpp:382
Scalar
Tensor< T, Symmetry<>, index_list<> > Scalar
Definition: TypeAliases.hpp:21
Gsl.hpp
Frame
Definition: IndexType.hpp:36
gr
Definition: GaugeWave.hpp:28
Tensor.hpp
Tags::deriv
Prefix indicating spatial derivatives.
Definition: PartialDerivatives.hpp:52
PartialDerivatives.hpp
Xcts::Solutions
Analytic solutions of the XCTS equations.
Definition: AnalyticSolution.hpp:18
Prefixes.hpp
gsl
Implementations from the Guideline Support Library.
Definition: ReadSpecPiecewisePolynomial.hpp:11
gr::Tags::Lapse
Definition: Tags.hpp:52
TMPL.hpp
gsl::not_null
Require a pointer to not be a nullptr
Definition: ReadSpecPiecewisePolynomial.hpp:13