Line data Source code
1 0 : // Distributed under the MIT License.
2 : // See LICENSE.txt for details.
3 :
4 : #pragma once
5 :
6 : #include <limits>
7 : #include <memory>
8 : #include <ostream>
9 :
10 : #include "DataStructures/DataBox/Prefixes.hpp"
11 : #include "DataStructures/Tensor/Tensor.hpp"
12 : #include "Elliptic/Systems/Xcts/Tags.hpp"
13 : #include "NumericalAlgorithms/LinearOperators/Divergence.hpp"
14 : #include "NumericalAlgorithms/LinearOperators/PartialDerivatives.hpp"
15 : #include "Options/String.hpp"
16 : #include "PointwiseFunctions/GeneralRelativity/Tags.hpp"
17 : #include "PointwiseFunctions/GeneralRelativity/Tags/Conformal.hpp"
18 : #include "PointwiseFunctions/Hydro/Tags.hpp"
19 : #include "PointwiseFunctions/InitialDataUtilities/AnalyticSolution.hpp"
20 : #include "Utilities/Gsl.hpp"
21 : #include "Utilities/Serialization/CharmPupable.hpp"
22 : #include "Utilities/TMPL.hpp"
23 : #include "Utilities/TaggedTuple.hpp"
24 :
25 : /// \cond
26 : namespace PUP {
27 : class er;
28 : } // namespace PUP
29 : /// \endcond
30 :
31 : namespace Xcts::Solutions {
32 :
33 : /// Flat spacetime in general relativity. Useful as initial guess.
34 1 : class Flatness : public elliptic::analytic_data::AnalyticSolution {
35 : public:
36 0 : using options = tmpl::list<>;
37 0 : static constexpr Options::String help{
38 : "Flat spacetime, useful as initial guess."};
39 :
40 0 : Flatness() = default;
41 0 : Flatness(const Flatness&) = default;
42 0 : Flatness& operator=(const Flatness&) = default;
43 0 : Flatness(Flatness&&) = default;
44 0 : Flatness& operator=(Flatness&&) = default;
45 0 : ~Flatness() = default;
46 0 : std::unique_ptr<elliptic::analytic_data::AnalyticSolution> get_clone()
47 : const override {
48 : return std::make_unique<Flatness>(*this);
49 : }
50 :
51 : /// \cond
52 : explicit Flatness(CkMigrateMessage* m)
53 : : elliptic::analytic_data::AnalyticSolution(m) {}
54 : using PUP::able::register_constructor;
55 : WRAPPED_PUPable_decl_template(Flatness);
56 : /// \endcond
57 :
58 : template <typename DataType, typename... RequestedTags>
59 0 : tuples::TaggedTuple<RequestedTags...> variables(
60 : const tnsr::I<DataType, 3, Frame::Inertial>& x,
61 : tmpl::list<RequestedTags...> /*meta*/) const {
62 : using supported_tags_zero = tmpl::list<
63 : Tags::ConformalFactorMinusOne<DataType>,
64 : Tags::LapseTimesConformalFactorMinusOne<DataType>,
65 : ::Tags::deriv<Tags::ConformalMetric<DataType, 3, Frame::Inertial>,
66 : tmpl::size_t<3>, Frame::Inertial>,
67 : ::Tags::deriv<gr::Tags::SpatialMetric<DataType, 3>, tmpl::size_t<3>,
68 : Frame::Inertial>,
69 : Tags::ConformalChristoffelFirstKind<DataType, 3, Frame::Inertial>,
70 : Tags::ConformalChristoffelSecondKind<DataType, 3, Frame::Inertial>,
71 : Tags::ConformalChristoffelContracted<DataType, 3, Frame::Inertial>,
72 : Tags::ConformalRicciTensor<DataVector, 3, Frame::Inertial>,
73 : Tags::ConformalRicciScalar<DataVector>,
74 : gr::Tags::TraceExtrinsicCurvature<DataType>,
75 : ::Tags::dt<gr::Tags::TraceExtrinsicCurvature<DataType>>,
76 : ::Tags::deriv<gr::Tags::TraceExtrinsicCurvature<DataType>,
77 : tmpl::size_t<3>, Frame::Inertial>,
78 : ::Tags::deriv<Tags::ConformalFactorMinusOne<DataType>, tmpl::size_t<3>,
79 : Frame::Inertial>,
80 : ::Tags::deriv<Tags::LapseTimesConformalFactorMinusOne<DataType>,
81 : tmpl::size_t<3>, Frame::Inertial>,
82 : ::Tags::deriv<Tags::ConformalFactor<DataType>, tmpl::size_t<3>,
83 : Frame::Inertial>,
84 : ::Tags::deriv<Tags::LapseTimesConformalFactor<DataType>,
85 : tmpl::size_t<3>, Frame::Inertial>,
86 : Tags::ShiftBackground<DataType, 3, Frame::Inertial>,
87 : ::Tags::deriv<Tags::ShiftBackground<DataType, 3, Frame::Inertial>,
88 : tmpl::size_t<3>, Frame::Inertial>,
89 : Tags::ShiftExcess<DataType, 3, Frame::Inertial>,
90 : ::Tags::deriv<Tags::ShiftExcess<DataType, 3, Frame::Inertial>,
91 : tmpl::size_t<3>, Frame::Inertial>,
92 : Tags::ShiftStrain<DataType, 3, Frame::Inertial>,
93 : gr::Tags::Shift<DataType, 3>,
94 : ::Tags::Flux<Tags::ConformalFactorMinusOne<DataType>, tmpl::size_t<3>,
95 : Frame::Inertial>,
96 : ::Tags::Flux<Tags::LapseTimesConformalFactorMinusOne<DataType>,
97 : tmpl::size_t<3>, Frame::Inertial>,
98 : Tags::LongitudinalShiftExcess<DataType, 3, Frame::Inertial>,
99 : Tags::LongitudinalShiftBackgroundMinusDtConformalMetric<
100 : DataVector, 3, Frame::Inertial>,
101 : Tags::LongitudinalShiftMinusDtConformalMetricSquare<DataVector>,
102 : Tags::LongitudinalShiftMinusDtConformalMetricOverLapseSquare<
103 : DataVector>,
104 : ::Tags::div<Tags::LongitudinalShiftBackgroundMinusDtConformalMetric<
105 : DataVector, 3, Frame::Inertial>>,
106 : Tags::ShiftDotDerivExtrinsicCurvatureTrace<DataVector>,
107 : gr::Tags::ExtrinsicCurvature<DataVector, 3>,
108 : gr::Tags::Conformal<gr::Tags::EnergyDensity<DataType>, 0>,
109 : gr::Tags::Conformal<gr::Tags::StressTrace<DataType>, 0>,
110 : gr::Tags::Conformal<gr::Tags::MomentumDensity<DataType, 3>, 0>,
111 : gr::Tags::Conformal<gr::Tags::EnergyDensity<DataType>, 6>,
112 : gr::Tags::Conformal<gr::Tags::StressTrace<DataType>, 6>,
113 : gr::Tags::Conformal<gr::Tags::MomentumDensity<DataType, 3>, 6>,
114 : gr::Tags::Conformal<gr::Tags::EnergyDensity<DataType>, 8>,
115 : gr::Tags::Conformal<gr::Tags::StressTrace<DataType>, 8>,
116 : gr::Tags::Conformal<gr::Tags::MomentumDensity<DataType, 3>, 8>,
117 : ::Tags::FixedSource<Tags::ConformalFactorMinusOne<DataType>>,
118 : ::Tags::FixedSource<Tags::LapseTimesConformalFactorMinusOne<DataType>>,
119 : ::Tags::FixedSource<Tags::ShiftExcess<DataType, 3, Frame::Inertial>>,
120 : hydro::Tags::RestMassDensity<DataType>, hydro::Tags::Pressure<DataType>,
121 : hydro::Tags::SpatialVelocity<DataType, 3>,
122 : hydro::Tags::MagneticField<DataType, 3>>;
123 : using supported_tags_one =
124 : tmpl::list<Tags::ConformalFactor<DataType>,
125 : Tags::LapseTimesConformalFactor<DataType>,
126 : gr::Tags::Lapse<DataType>,
127 : hydro::Tags::SpecificEnthalpy<DataType>,
128 : hydro::Tags::LorentzFactor<DataType>>;
129 : using supported_tags_metric =
130 : tmpl::list<Tags::ConformalMetric<DataType, 3, Frame::Inertial>,
131 : Tags::InverseConformalMetric<DataType, 3, Frame::Inertial>,
132 : gr::Tags::SpatialMetric<DataType, 3>,
133 : gr::Tags::InverseSpatialMetric<DataType, 3>>;
134 : using supported_tags = tmpl::append<supported_tags_zero, supported_tags_one,
135 : supported_tags_metric>;
136 : static_assert(
137 : std::is_same_v<
138 : tmpl::list_difference<tmpl::list<RequestedTags...>, supported_tags>,
139 : tmpl::list<>>,
140 : "Not all requested tags are supported. The static_assert lists the "
141 : "unsupported tags.");
142 : const auto make_value = [&x](auto tag_v) {
143 : using tag = std::decay_t<decltype(tag_v)>;
144 : if constexpr (tmpl::list_contains_v<supported_tags_zero, tag>) {
145 : return make_with_value<typename tag::type>(x, 0.);
146 : } else if constexpr (tmpl::list_contains_v<supported_tags_one, tag>) {
147 : return make_with_value<typename tag::type>(x, 1.);
148 : } else if constexpr (tmpl::list_contains_v<supported_tags_metric, tag>) {
149 : auto flat_metric = make_with_value<typename tag::type>(x, 0.);
150 : get<0, 0>(flat_metric) = 1.;
151 : get<1, 1>(flat_metric) = 1.;
152 : get<2, 2>(flat_metric) = 1.;
153 : return flat_metric;
154 : }
155 : };
156 : return {make_value(RequestedTags{})...};
157 : }
158 :
159 : template <typename DataType, typename... RequestedTags>
160 0 : tuples::TaggedTuple<RequestedTags...> variables(
161 : const tnsr::I<DataType, 3, Frame::Inertial>& x, const Mesh<3>& /*mesh*/,
162 : const InverseJacobian<DataVector, 3, Frame::ElementLogical,
163 : Frame::Inertial>&
164 : /*inv_jacobian*/,
165 : tmpl::list<RequestedTags...> /*meta*/) const {
166 : return variables(x, tmpl::list<RequestedTags...>{});
167 : }
168 : };
169 :
170 0 : bool operator==(const Flatness& /*lhs*/, const Flatness& /*rhs*/);
171 :
172 0 : bool operator!=(const Flatness& lhs, const Flatness& rhs);
173 :
174 : } // namespace Xcts::Solutions
|