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"
13 #include "Options/Options.hpp"
15 #include "PointwiseFunctions/AnalyticSolutions/Xcts/AnalyticSolution.hpp"
16 #include "PointwiseFunctions/GeneralRelativity/Tags.hpp"
17 #include "Utilities/Gsl.hpp"
18 #include "Utilities/TMPL.hpp"
19 #include "Utilities/TaggedTuple.hpp"
20 
21 /// \cond
22 namespace PUP {
23 class er;
24 } // namespace PUP
25 /// \endcond
26 
27 namespace Xcts::Solutions {
28 
29 /// \cond
30 template <typename Registrars>
31 struct Flatness;
32 
33 namespace Registrars {
34 struct Flatness {
35  template <typename Registrars>
36  using f = Solutions::Flatness<Registrars>;
37 };
38 } // namespace Registrars
39 /// \endcond
40 
41 /// Flat spacetime in general relativity. Useful as initial guess.
42 template <typename Registrars = tmpl::list<Solutions::Registrars::Flatness>>
43 class Flatness : public AnalyticSolution<Registrars> {
44  private:
46 
47  public:
48  using options = tmpl::list<>;
49  static constexpr Options::String help{
50  "Flat spacetime, useful as initial guess."};
51 
52  Flatness() = default;
53  Flatness(const Flatness&) noexcept = default;
54  Flatness& operator=(const Flatness&) noexcept = default;
55  Flatness(Flatness&&) noexcept = default;
56  Flatness& operator=(Flatness&&) noexcept = default;
57  ~Flatness() noexcept = default;
58 
59  /// \cond
60  explicit Flatness(CkMigrateMessage* m) noexcept : Base(m) {}
61  using PUP::able::register_constructor;
63  /// \endcond
64 
65  template <typename DataType, typename... RequestedTags>
66  tuples::TaggedTuple<RequestedTags...> variables(
67  const tnsr::I<DataType, 3, Frame::Inertial>& x,
68  tmpl::list<RequestedTags...> /*meta*/) const noexcept {
69  using supported_tags_zero = tmpl::list<
71  tmpl::size_t<3>, Frame::Inertial>,
78  tmpl::size_t<3>, Frame::Inertial>,
82  tmpl::size_t<3>, Frame::Inertial>,
91  using supported_tags_one =
92  tmpl::list<Tags::ConformalFactor<DataType>,
94  using supported_tags_metric =
95  tmpl::list<Tags::ConformalMetric<DataType, 3, Frame::Inertial>,
97  using supported_tags = tmpl::append<supported_tags_zero, supported_tags_one,
98  supported_tags_metric>;
99  static_assert(
100  std::is_same_v<
101  tmpl::list_difference<tmpl::list<RequestedTags...>, supported_tags>,
102  tmpl::list<>>,
103  "Not all requested tags are supported. The static_assert lists the "
104  "unsupported tags.");
105  const auto make_value = [&x](auto tag_v) noexcept {
106  using tag = std::decay_t<decltype(tag_v)>;
107  if constexpr (tmpl::list_contains_v<supported_tags_zero, tag>) {
108  return make_with_value<typename tag::type>(x, 0.);
109  } else if constexpr (tmpl::list_contains_v<supported_tags_one, tag>) {
110  return make_with_value<typename tag::type>(x, 1.);
111  } else if constexpr (tmpl::list_contains_v<supported_tags_metric, tag>) {
112  auto flat_metric = make_with_value<typename tag::type>(x, 0.);
113  get<0, 0>(flat_metric) = 1.;
114  get<1, 1>(flat_metric) = 1.;
115  get<2, 2>(flat_metric) = 1.;
116  return flat_metric;
117  }
118  };
119  return {make_value(RequestedTags{})...};
120  }
121 };
122 
123 template <typename Registrars>
124 bool operator==(const Flatness<Registrars>& /*lhs*/,
125  const Flatness<Registrars>& /*rhs*/) noexcept {
126  return true;
127 }
128 
129 template <typename Registrars>
130 bool operator!=(const Flatness<Registrars>& lhs,
131  const Flatness<Registrars>& rhs) noexcept {
132  return not(lhs == rhs);
133 }
134 
135 /// \cond
136 template <typename Registrars>
137 PUP::able::PUP_ID Flatness<Registrars>::my_PUP_ID = 0; // NOLINT
138 /// \endcond
139 
140 } // 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
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:43
Xcts::Tags::ConformalChristoffelContracted
The Christoffel symbols of the second kind (related to the conformal metric ) contracted in their fir...
Definition: Tags.hpp:222
gr::Tags::EnergyDensity
The energy density , where denotes the normal to the spatial hypersurface.
Definition: Tags.hpp:138
Tags::FixedSource
Prefix indicating a source term that is independent of dynamic variables.
Definition: Prefixes.hpp:75
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
std::decay_t
Xcts::Tags::ShiftBackground
The constant part of the shift .
Definition: Tags.hpp:74
Tags::dt
Prefix indicating a time derivative.
Definition: Prefixes.hpp:29
limits
gr::Tags::MomentumDensity
The spatial momentum density , where denotes the normal to the spatial hypersurface.
Definition: Tags.hpp:156
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
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
Prefixes.hpp
gr::Tags::StressTrace
The trace of the spatial stress-energy tensor .
Definition: Tags.hpp:147
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:589
TMPL.hpp