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::ConformalRicciScalar<DataVector>,
73 : gr::Tags::TraceExtrinsicCurvature<DataType>,
74 : ::Tags::dt<gr::Tags::TraceExtrinsicCurvature<DataType>>,
75 : ::Tags::deriv<gr::Tags::TraceExtrinsicCurvature<DataType>,
76 : tmpl::size_t<3>, Frame::Inertial>,
77 : ::Tags::deriv<Tags::ConformalFactorMinusOne<DataType>, tmpl::size_t<3>,
78 : Frame::Inertial>,
79 : ::Tags::deriv<Tags::LapseTimesConformalFactorMinusOne<DataType>,
80 : tmpl::size_t<3>, Frame::Inertial>,
81 : ::Tags::deriv<Tags::ConformalFactor<DataType>, tmpl::size_t<3>,
82 : Frame::Inertial>,
83 : ::Tags::deriv<Tags::LapseTimesConformalFactor<DataType>,
84 : tmpl::size_t<3>, Frame::Inertial>,
85 : Tags::ShiftBackground<DataType, 3, Frame::Inertial>,
86 : Tags::ShiftExcess<DataType, 3, Frame::Inertial>,
87 : ::Tags::deriv<Tags::ShiftExcess<DataType, 3, Frame::Inertial>,
88 : tmpl::size_t<3>, Frame::Inertial>,
89 : Tags::ShiftStrain<DataType, 3, Frame::Inertial>,
90 : gr::Tags::Shift<DataType, 3>,
91 : ::Tags::Flux<Tags::ConformalFactorMinusOne<DataType>, tmpl::size_t<3>,
92 : Frame::Inertial>,
93 : ::Tags::Flux<Tags::LapseTimesConformalFactorMinusOne<DataType>,
94 : tmpl::size_t<3>, Frame::Inertial>,
95 : Tags::LongitudinalShiftExcess<DataType, 3, Frame::Inertial>,
96 : Tags::LongitudinalShiftBackgroundMinusDtConformalMetric<
97 : DataVector, 3, Frame::Inertial>,
98 : Tags::LongitudinalShiftMinusDtConformalMetricSquare<DataVector>,
99 : Tags::LongitudinalShiftMinusDtConformalMetricOverLapseSquare<
100 : DataVector>,
101 : ::Tags::div<Tags::LongitudinalShiftBackgroundMinusDtConformalMetric<
102 : DataVector, 3, Frame::Inertial>>,
103 : Tags::ShiftDotDerivExtrinsicCurvatureTrace<DataVector>,
104 : gr::Tags::ExtrinsicCurvature<DataVector, 3>,
105 : gr::Tags::Conformal<gr::Tags::EnergyDensity<DataType>, 0>,
106 : gr::Tags::Conformal<gr::Tags::StressTrace<DataType>, 0>,
107 : gr::Tags::Conformal<gr::Tags::MomentumDensity<DataType, 3>, 0>,
108 : gr::Tags::Conformal<gr::Tags::EnergyDensity<DataType>, 6>,
109 : gr::Tags::Conformal<gr::Tags::StressTrace<DataType>, 6>,
110 : gr::Tags::Conformal<gr::Tags::MomentumDensity<DataType, 3>, 6>,
111 : gr::Tags::Conformal<gr::Tags::EnergyDensity<DataType>, 8>,
112 : gr::Tags::Conformal<gr::Tags::StressTrace<DataType>, 8>,
113 : gr::Tags::Conformal<gr::Tags::MomentumDensity<DataType, 3>, 8>,
114 : ::Tags::FixedSource<Tags::ConformalFactorMinusOne<DataType>>,
115 : ::Tags::FixedSource<Tags::LapseTimesConformalFactorMinusOne<DataType>>,
116 : ::Tags::FixedSource<Tags::ShiftExcess<DataType, 3, Frame::Inertial>>,
117 : hydro::Tags::RestMassDensity<DataType>, hydro::Tags::Pressure<DataType>,
118 : hydro::Tags::SpatialVelocity<DataType, 3>,
119 : hydro::Tags::MagneticField<DataType, 3>>;
120 : using supported_tags_one =
121 : tmpl::list<Tags::ConformalFactor<DataType>,
122 : Tags::LapseTimesConformalFactor<DataType>,
123 : gr::Tags::Lapse<DataType>,
124 : hydro::Tags::SpecificEnthalpy<DataType>,
125 : hydro::Tags::LorentzFactor<DataType>>;
126 : using supported_tags_metric =
127 : tmpl::list<Tags::ConformalMetric<DataType, 3, Frame::Inertial>,
128 : Tags::InverseConformalMetric<DataType, 3, Frame::Inertial>,
129 : gr::Tags::SpatialMetric<DataType, 3>,
130 : gr::Tags::InverseSpatialMetric<DataType, 3>>;
131 : using supported_tags = tmpl::append<supported_tags_zero, supported_tags_one,
132 : supported_tags_metric>;
133 : static_assert(
134 : std::is_same_v<
135 : tmpl::list_difference<tmpl::list<RequestedTags...>, supported_tags>,
136 : tmpl::list<>>,
137 : "Not all requested tags are supported. The static_assert lists the "
138 : "unsupported tags.");
139 : const auto make_value = [&x](auto tag_v) {
140 : using tag = std::decay_t<decltype(tag_v)>;
141 : if constexpr (tmpl::list_contains_v<supported_tags_zero, tag>) {
142 : return make_with_value<typename tag::type>(x, 0.);
143 : } else if constexpr (tmpl::list_contains_v<supported_tags_one, tag>) {
144 : return make_with_value<typename tag::type>(x, 1.);
145 : } else if constexpr (tmpl::list_contains_v<supported_tags_metric, tag>) {
146 : auto flat_metric = make_with_value<typename tag::type>(x, 0.);
147 : get<0, 0>(flat_metric) = 1.;
148 : get<1, 1>(flat_metric) = 1.;
149 : get<2, 2>(flat_metric) = 1.;
150 : return flat_metric;
151 : }
152 : };
153 : return {make_value(RequestedTags{})...};
154 : }
155 :
156 : template <typename DataType, typename... RequestedTags>
157 0 : tuples::TaggedTuple<RequestedTags...> variables(
158 : const tnsr::I<DataType, 3, Frame::Inertial>& x, const Mesh<3>& /*mesh*/,
159 : const InverseJacobian<DataVector, 3, Frame::ElementLogical,
160 : Frame::Inertial>&
161 : /*inv_jacobian*/,
162 : tmpl::list<RequestedTags...> /*meta*/) const {
163 : return variables(x, tmpl::list<RequestedTags...>{});
164 : }
165 : };
166 :
167 0 : bool operator==(const Flatness& /*lhs*/, const Flatness& /*rhs*/);
168 :
169 0 : bool operator!=(const Flatness& lhs, const Flatness& rhs);
170 :
171 : } // namespace Xcts::Solutions
|