9 #include "DataStructures/CachedTempBuffer.hpp"
11 #include "DataStructures/DataVector.hpp"
13 #include "Elliptic/Systems/Xcts/Tags.hpp"
18 #include "PointwiseFunctions/AnalyticSolutions/Xcts/AnalyticSolution.hpp"
19 #include "PointwiseFunctions/AnalyticSolutions/Xcts/CommonVariables.hpp"
20 #include "PointwiseFunctions/GeneralRelativity/Tags.hpp"
21 #include "Utilities/ContainerHelpers.hpp"
24 #include "Utilities/TaggedTuple.hpp"
79 template <
typename Metavariables>
82 return create<void>(options);
95 struct SchwarzschildImpl {
101 struct CoordinateSystem {
102 static std::string name() noexcept {
return "Coordinates"; }
105 "The coordinate system used to describe the solution";
108 using options = tmpl::list<Mass, CoordinateSystem>;
110 "Schwarzschild spacetime in general relativity"};
112 SchwarzschildImpl() =
default;
113 SchwarzschildImpl(
const SchwarzschildImpl&) noexcept =
default;
114 SchwarzschildImpl& operator=(
const SchwarzschildImpl&) noexcept =
default;
115 SchwarzschildImpl(SchwarzschildImpl&&) noexcept = default;
116 SchwarzschildImpl& operator=(SchwarzschildImpl&&) noexcept = default;
117 ~SchwarzschildImpl() noexcept = default;
119 explicit SchwarzschildImpl(
123 double mass() const noexcept;
128 double radius_at_horizon() const noexcept;
131 void pup(PUP::er& p) noexcept;
138 bool operator==(
const SchwarzschildImpl& lhs,
139 const SchwarzschildImpl& rhs) noexcept;
142 const SchwarzschildImpl& rhs) noexcept;
144 template <
typename DataType>
145 struct SchwarzschildVariables;
147 template <
typename DataType>
148 using SchwarzschildVariablesCache = cached_temp_buffer_from_typelist<
149 SchwarzschildVariables<DataType>,
151 common_tags<DataType>,
152 Tags::ConformalMetric<DataType, 3, Frame::Inertial>,
153 Tags::InverseConformalMetric<DataType, 3, Frame::Inertial>,
158 Tags::ConformalFactor<DataType>,
164 Tags::ShiftBackground<DataType, 3, Frame::Inertial>,
165 Tags::LongitudinalShiftBackgroundMinusDtConformalMetric<
167 Tags::ShiftExcess<DataType, 3, Frame::Inertial>,
168 Tags::ShiftStrain<DataType, 3, Frame::Inertial>,
172 template <
typename DataType>
173 struct SchwarzschildVariables
174 : CommonVariables<DataType, SchwarzschildVariablesCache<DataType>> {
175 static constexpr
size_t Dim = 3;
176 using Cache = SchwarzschildVariablesCache<DataType>;
177 using CommonVariables<DataType,
178 SchwarzschildVariablesCache<DataType>>::operator();
180 const tnsr::I<DataType, 3>& x;
184 void operator()(
gsl::not_null<tnsr::ii<DataType, 3>*> conformal_metric,
186 Tags::ConformalMetric<DataType, 3, Frame::Inertial> )
191 Tags::InverseConformalMetric<DataType, 3, Frame::Inertial> )
194 gsl::not_null<tnsr::ijj<DataType, 3>*> deriv_conformal_metric,
196 ::
Tags::deriv<Tags::ConformalMetric<DataType, 3, Frame::Inertial>,
199 gsl::not_null<
Scalar<DataType>*> trace_extrinsic_curvature,
201 gr::Tags::TraceExtrinsicCurvature<DataType> ) const noexcept;
203 gsl::not_null<
tnsr::i<DataType, 3>*> trace_extrinsic_curvature_gradient,
205 ::Tags::deriv<
gr::Tags::TraceExtrinsicCurvature<DataType>,
206 tmpl::
size_t<3>,
Frame::Inertial> ) const noexcept;
208 gsl::not_null<
Scalar<DataType>*> dt_trace_extrinsic_curvature,
210 ::Tags::dt<
gr::Tags::TraceExtrinsicCurvature<DataType>> )
212 void operator()(
gsl::not_null<
Scalar<DataType>*> conformal_factor,
214 Tags::ConformalFactor<DataType> ) const noexcept;
216 gsl::not_null<
tnsr::i<DataType, 3>*> conformal_factor_gradient,
218 ::Tags::deriv<
Xcts::Tags::ConformalFactor<DataType>, tmpl::
size_t<3>,
219 Frame::Inertial> ) const noexcept;
222 gr::Tags::Lapse<DataType> ) const noexcept;
224 gsl::not_null<
Scalar<DataType>*> lapse_times_conformal_factor,
226 Tags::LapseTimesConformalFactor<DataType> ) const noexcept;
228 gsl::not_null<
tnsr::i<DataType, 3>*>
229 lapse_times_conformal_factor_gradient,
231 ::Tags::deriv<Tags::LapseTimesConformalFactor<DataType>, tmpl::
size_t<3>,
232 Frame::Inertial> ) const noexcept;
233 void operator()(
gsl::not_null<
tnsr::I<DataType, 3>*> shift_background,
235 Tags::ShiftBackground<DataType, 3,
Frame::Inertial> )
237 void operator()(
gsl::not_null<
tnsr::II<DataType, 3,
Frame::Inertial>*>
238 longitudinal_shift_background_minus_dt_conformal_metric,
240 Tags::LongitudinalShiftBackgroundMinusDtConformalMetric<
241 DataType, 3,
Frame::Inertial> ) const noexcept;
243 gsl::not_null<
tnsr::I<DataType, 3>*> shift_excess,
245 Tags::ShiftExcess<DataType, 3,
Frame::Inertial> ) const noexcept;
247 gsl::not_null<
tnsr::ii<DataType, 3>*> shift_strain,
249 Tags::ShiftStrain<DataType, 3,
Frame::Inertial> ) const noexcept;
250 void operator()(
gsl::not_null<
Scalar<DataType>*> energy_density,
252 gr::Tags::EnergyDensity<DataType> ) const noexcept;
253 void operator()(
gsl::not_null<
Scalar<DataType>*> stress_trace,
255 gr::Tags::StressTrace<DataType> ) const noexcept;
256 void operator()(
gsl::not_null<
tnsr::I<DataType, 3>*> momentum_density,
258 gr::Tags::MomentumDensity<3,
Frame::Inertial,
259 DataType> ) const noexcept;
267 template <typename Registrars>
268 struct Schwarzschild;
270 namespace Registrars {
271 struct Schwarzschild {
272 template <
typename Registrars>
273 using f = Solutions::Schwarzschild<Registrars>;
286 template <
typename Registrars =
287 tmpl::list<Solutions::Registrars::Schwarzschild>>
289 public detail::SchwarzschildImpl {
301 using SchwarzschildImpl::SchwarzschildImpl;
305 using PUP::able::register_constructor;
309 template <
typename DataType,
typename... RequestedTags>
311 const tnsr::I<DataType, 3, Frame::Inertial>& x,
312 tmpl::list<RequestedTags...> )
const noexcept {
313 using VarsComputer = detail::SchwarzschildVariables<DataType>;
314 typename VarsComputer::Cache
cache{
317 {{std::nullopt, std::nullopt}}, x, mass_, coordinate_system_}};
318 return {
cache.get_var(RequestedTags{})...};
321 template <
typename... RequestedTags>
323 const tnsr::I<DataVector, 3, Frame::Inertial>& x,
const Mesh<3>& mesh,
324 const InverseJacobian<DataVector, 3, Frame::Logical, Frame::Inertial>&
326 tmpl::list<RequestedTags...> )
const noexcept {
327 using VarsComputer = detail::SchwarzschildVariables<DataVector>;
328 typename VarsComputer::Cache
cache{
330 VarsComputer{{{mesh, inv_jacobian}}, x, mass_, coordinate_system_}};
331 return {
cache.get_var(RequestedTags{})...};
334 void pup(PUP::er& p) noexcept
override {
336 detail::SchwarzschildImpl::pup(p);
341 template <
typename Registrars>