Flatness.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
6 #include <limits>
7 #include <ostream>
8 
11 #include "Elliptic/Systems/Xcts/Tags.hpp"
14 #include "Options/Options.hpp"
16 #include "PointwiseFunctions/AnalyticSolutions/Xcts/AnalyticSolution.hpp"
17 #include "PointwiseFunctions/GeneralRelativity/Tags.hpp"
18 #include "Utilities/Gsl.hpp"
19 #include "Utilities/TMPL.hpp"
20 #include "Utilities/TaggedTuple.hpp"
21 
22 /// \cond
23 namespace PUP {
24 class er;
25 } // namespace PUP
26 /// \endcond
27 
28 namespace Xcts::Solutions {
29 
30 /// \cond
31 template <typename Registrars>
32 struct Flatness;
33 
34 namespace Registrars {
35 struct Flatness {
36  template <typename Registrars>
37  using f = Solutions::Flatness<Registrars>;
38 };
39 } // namespace Registrars
40 /// \endcond
41 
42 /// Flat spacetime in general relativity. Useful as initial guess.
43 template <typename Registrars = tmpl::list<Solutions::Registrars::Flatness>>
44 class Flatness : public AnalyticSolution<Registrars> {
45  private:
47 
48  public:
49  using options = tmpl::list<>;
50  static constexpr Options::String help{
51  "Flat spacetime, useful as initial guess."};
52 
53  Flatness() = default;
54  Flatness(const Flatness&) noexcept = default;
55  Flatness& operator=(const Flatness&) noexcept = default;
56  Flatness(Flatness&&) noexcept = default;
57  Flatness& operator=(Flatness&&) noexcept = default;
58  ~Flatness() noexcept = default;
59 
60  /// \cond
61  explicit Flatness(CkMigrateMessage* m) noexcept : Base(m) {}
62  using PUP::able::register_constructor;
64  /// \endcond
65 
66  template <typename DataType, typename... RequestedTags>
67  tuples::TaggedTuple<RequestedTags...> variables(
68  const tnsr::I<DataType, 3, Frame::Inertial>& x,
69  tmpl::list<RequestedTags...> /*meta*/) const noexcept {
70  using supported_tags_zero = tmpl::list<
72  tmpl::size_t<3>, Frame::Inertial>,
80  tmpl::size_t<3>, Frame::Inertial>,
84  tmpl::size_t<3>, Frame::Inertial>,
92  DataVector>,
99  0>,
103  6>,
107  8>,
111  using supported_tags_one =
112  tmpl::list<Tags::ConformalFactor<DataType>,
114  using supported_tags_metric =
115  tmpl::list<Tags::ConformalMetric<DataType, 3, Frame::Inertial>,
117  using supported_tags = tmpl::append<supported_tags_zero, supported_tags_one,
118  supported_tags_metric>;
119  static_assert(
120  std::is_same_v<
121  tmpl::list_difference<tmpl::list<RequestedTags...>, supported_tags>,
122  tmpl::list<>>,
123  "Not all requested tags are supported. The static_assert lists the "
124  "unsupported tags.");
125  const auto make_value = [&x](auto tag_v) noexcept {
126  using tag = std::decay_t<decltype(tag_v)>;
127  if constexpr (tmpl::list_contains_v<supported_tags_zero, tag>) {
128  return make_with_value<typename tag::type>(x, 0.);
129  } else if constexpr (tmpl::list_contains_v<supported_tags_one, tag>) {
130  return make_with_value<typename tag::type>(x, 1.);
131  } else if constexpr (tmpl::list_contains_v<supported_tags_metric, tag>) {
132  auto flat_metric = make_with_value<typename tag::type>(x, 0.);
133  get<0, 0>(flat_metric) = 1.;
134  get<1, 1>(flat_metric) = 1.;
135  get<2, 2>(flat_metric) = 1.;
136  return flat_metric;
137  }
138  };
139  return {make_value(RequestedTags{})...};
140  }
141 
142  template <typename DataType, typename... RequestedTags>
143  tuples::TaggedTuple<RequestedTags...> variables(
144  const tnsr::I<DataType, 3, Frame::Inertial>& x, const Mesh<3>& /*mesh*/,
145  const InverseJacobian<DataVector, 3, Frame::Logical, Frame::Inertial>&
146  /*inv_jacobian*/,
147  tmpl::list<RequestedTags...> /*meta*/) const noexcept {
148  return variables(x, tmpl::list<RequestedTags...>{});
149  }
150 };
151 
152 template <typename Registrars>
153 bool operator==(const Flatness<Registrars>& /*lhs*/,
154  const Flatness<Registrars>& /*rhs*/) noexcept {
155  return true;
156 }
157 
158 template <typename Registrars>
159 bool operator!=(const Flatness<Registrars>& lhs,
160  const Flatness<Registrars>& rhs) noexcept {
161  return not(lhs == rhs);
162 }
163 
164 /// \cond
165 template <typename Registrars>
166 PUP::able::PUP_ID Flatness<Registrars>::my_PUP_ID = 0; // NOLINT
167 /// \endcond
168 
169 } // namespace Xcts::Solutions
gr::Tags::TraceExtrinsicCurvature
Definition: Tags.hpp:120
CharmPupable.hpp
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:30
Divergence.hpp
Options.hpp
Xcts::Tags::ConformalChristoffelSecondKind
The Christoffel symbols of the second kind related to the conformal metric .
Definition: Tags.hpp:212
Xcts::Tags::LapseTimesConformalFactor
The product of lapse and conformal factor .
Definition: Tags.hpp:63
Xcts::Solutions::Flatness
Flat spacetime in general relativity. Useful as initial guess.
Definition: Flatness.hpp:44
Xcts::Tags::ConformalChristoffelContracted
The Christoffel symbols of the second kind (related to the conformal metric ) contracted in their fir...
Definition: Tags.hpp:222
Tags::FixedSource
Prefix indicating a source term that is independent of dynamic variables.
Definition: Prefixes.hpp:75
Xcts::Tags::LongitudinalShiftMinusDtConformalMetricOverLapseSquare
The conformal longitudinal operator applied to the shift vector minus the time derivative of the conf...
Definition: Tags.hpp:181
Tags::div
Prefix indicating the divergence.
Definition: Divergence.hpp:44
WRAPPED_PUPable_decl_template
#define WRAPPED_PUPable_decl_template(className)
Mark derived classes as serializable.
Definition: CharmPupable.hpp:22
Xcts::Tags::ShiftStrain
The symmetric "strain" of the shift vector .
Definition: Tags.hpp:125
Xcts::Solutions::AnalyticSolution
Base class for analytic solutions of the XCTS equations.
Definition: AnalyticSolution.hpp:34
Xcts::Tags::ShiftExcess
The dynamic part of the shift .
Definition: Tags.hpp:93
tuples::TaggedTuple
An associative container that is indexed by structs.
Definition: TaggedTuple.hpp:271
DataVector
Stores a collection of function values.
Definition: DataVector.hpp:46
std::decay_t
Xcts::Tags::ShiftBackground
The constant part of the shift .
Definition: Tags.hpp:74
Mesh
Holds the number of grid points, basis, and quadrature in each direction of the computational grid.
Definition: Mesh.hpp:49
Tags::dt
Prefix indicating a time derivative.
Definition: Prefixes.hpp:29
limits
Gsl.hpp
Xcts::Tags::ConformalChristoffelFirstKind
The Christoffel symbols of the first kind related to the conformal metric .
Definition: Tags.hpp:203
Options::String
const char *const String
The string used in option structs.
Definition: Options.hpp:32
Xcts::Tags::LongitudinalShiftMinusDtConformalMetricSquare
The conformal longitudinal operator applied to the shift vector minus the time derivative of the conf...
Definition: Tags.hpp:169
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
ostream
Xcts::Tags::LongitudinalShiftBackgroundMinusDtConformalMetric
The conformal longitudinal operator applied to the background shift vector minus the time derivative ...
Definition: Tags.hpp:158
Prefixes.hpp
brigand::list_difference
fold< Sequence2, Sequence1, lazy::remove< _state, _element > > list_difference
Obtain the elements of Sequence1 that are not in Sequence2.
Definition: TMPL.hpp:625
Xcts::Tags::ShiftDotDerivExtrinsicCurvatureTrace
The shift vector contracted with the gradient of the trace of the extrinsic curvature: .
Definition: Tags.hpp:194
TMPL.hpp
Xcts::Tags::ConformalRicciScalar
The Ricci scalar related to the conformal metric .
Definition: Tags.hpp:240