• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

sxs-collaboration / spectre / 4225779574

pending completion
4225779574

push

github

GitHub
Merge pull request #4712 from nilsvu/xcts_wrap_hydro

108 of 108 new or added lines in 3 files covered. (100.0%)

63785 of 66497 relevant lines covered (95.92%)

502061.27 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

97.56
/src/PointwiseFunctions/AnalyticSolutions/Xcts/WrappedGr.cpp
1
// Distributed under the MIT License.
2
// See LICENSE.txt for details.
3

4
#include "PointwiseFunctions/AnalyticSolutions/Xcts/WrappedGr.hpp"
5

6
#include <algorithm>
7
#include <cstddef>
8

9
#include "DataStructures/DataBox/Prefixes.hpp"
10
#include "DataStructures/DataVector.hpp"
11
#include "DataStructures/Tensor/Tensor.hpp"
12
#include "Elliptic/Systems/Xcts/Tags.hpp"
13
#include "NumericalAlgorithms/LinearOperators/PartialDerivatives.hpp"
14
#include "Options/Options.hpp"
15
#include "PointwiseFunctions/AnalyticData/GrMhd/CcsnCollapse.hpp"
16
#include "PointwiseFunctions/AnalyticData/GrMhd/MagnetizedTovStar.hpp"
17
#include "PointwiseFunctions/AnalyticSolutions/GeneralRelativity/HarmonicSchwarzschild.hpp"
18
#include "PointwiseFunctions/AnalyticSolutions/GeneralRelativity/KerrSchild.hpp"
19
#include "PointwiseFunctions/AnalyticSolutions/GeneralRelativity/SphericalKerrSchild.hpp"
20
#include "PointwiseFunctions/AnalyticSolutions/RelativisticEuler/RotatingStar.hpp"
21
#include "PointwiseFunctions/AnalyticSolutions/Xcts/CommonVariables.tpp"
22
#include "PointwiseFunctions/Elasticity/Strain.hpp"
23
#include "PointwiseFunctions/GeneralRelativity/IndexManipulation.hpp"
24
#include "PointwiseFunctions/GeneralRelativity/Tags.hpp"
25
#include "PointwiseFunctions/GeneralRelativity/Tags/Conformal.hpp"
26
#include "PointwiseFunctions/Hydro/ComovingMagneticField.hpp"
27
#include "PointwiseFunctions/Hydro/StressEnergy.hpp"
28
#include "PointwiseFunctions/Xcts/LongitudinalOperator.hpp"
29
#include "Utilities/ConstantExpressions.hpp"
30
#include "Utilities/GenerateInstantiations.hpp"
31
#include "Utilities/Gsl.hpp"
32

33
namespace Xcts::Solutions {
34
namespace detail {
35

36
template <typename DataType, bool HasMhd>
37
void WrappedGrVariables<DataType, HasMhd>::operator()(
6✔
38
    const gsl::not_null<tnsr::ii<DataType, Dim>*> spatial_metric,
39
    const gsl::not_null<Cache*> /*cache*/,
40
    gr::Tags::SpatialMetric<Dim, Frame::Inertial, DataType> /*meta*/) const {
41
  *spatial_metric =
6✔
42
      get<gr::Tags::SpatialMetric<Dim, Frame::Inertial, DataType>>(gr_solution);
6✔
43
}
6✔
44

45
template <typename DataType, bool HasMhd>
46
void WrappedGrVariables<DataType, HasMhd>::operator()(
7✔
47
    const gsl::not_null<tnsr::II<DataType, Dim>*> inv_spatial_metric,
48
    const gsl::not_null<Cache*> /*cache*/,
49
    gr::Tags::InverseSpatialMetric<Dim, Frame::Inertial, DataType> /*meta*/)
50
    const {
51
  *inv_spatial_metric =
7✔
52
      get<gr::Tags::InverseSpatialMetric<Dim, Frame::Inertial, DataType>>(
7✔
53
          gr_solution);
7✔
54
}
7✔
55

56
template <typename DataType, bool HasMhd>
57
void WrappedGrVariables<DataType, HasMhd>::operator()(
7✔
58
    const gsl::not_null<tnsr::ijj<DataType, Dim>*> deriv_spatial_metric,
59
    const gsl::not_null<Cache*> /*cache*/,
60
    ::Tags::deriv<gr::Tags::SpatialMetric<Dim, Frame::Inertial, DataType>,
61
                  tmpl::size_t<Dim>, Frame::Inertial> /*meta*/) const {
62
  *deriv_spatial_metric =
7✔
63
      get<::Tags::deriv<gr::Tags::SpatialMetric<Dim, Frame::Inertial, DataType>,
64
                        tmpl::size_t<Dim>, Frame::Inertial>>(gr_solution);
7✔
65
}
7✔
66

67
template <typename DataType, bool HasMhd>
68
void WrappedGrVariables<DataType, HasMhd>::operator()(
34✔
69
    const gsl::not_null<tnsr::ii<DataType, Dim>*> conformal_metric,
70
    const gsl::not_null<Cache*> cache,
71
    Xcts::Tags::ConformalMetric<DataType, Dim, Frame::Inertial> /*meta*/)
72
    const {
73
  const auto& conformal_factor =
34✔
74
      cache->get_var(*this, Xcts::Tags::ConformalFactor<DataType>{});
75
  *conformal_metric =
34✔
76
      get<gr::Tags::SpatialMetric<Dim, Frame::Inertial, DataType>>(gr_solution);
34✔
77
  for (size_t i = 0; i < Dim; ++i) {
136✔
78
    for (size_t j = 0; j <= i; ++j) {
306✔
79
      conformal_metric->get(i, j) /= pow<4>(get(conformal_factor));
408✔
80
    }
81
  }
82
}
34✔
83

84
template <typename DataType, bool HasMhd>
85
void WrappedGrVariables<DataType, HasMhd>::operator()(
28✔
86
    const gsl::not_null<tnsr::II<DataType, Dim>*> inv_conformal_metric,
87
    const gsl::not_null<Cache*> cache,
88
    Xcts::Tags::InverseConformalMetric<DataType, Dim, Frame::Inertial> /*meta*/)
89
    const {
90
  const auto& conformal_factor =
28✔
91
      cache->get_var(*this, Xcts::Tags::ConformalFactor<DataType>{});
92
  *inv_conformal_metric =
28✔
93
      get<gr::Tags::InverseSpatialMetric<Dim, Frame::Inertial, DataType>>(
28✔
94
          gr_solution);
28✔
95
  for (size_t i = 0; i < Dim; ++i) {
112✔
96
    for (size_t j = 0; j <= i; ++j) {
252✔
97
      inv_conformal_metric->get(i, j) *= pow<4>(get(conformal_factor));
336✔
98
    }
99
  }
100
}
28✔
101

102
template <typename DataType, bool HasMhd>
103
void WrappedGrVariables<DataType, HasMhd>::operator()(
34✔
104
    const gsl::not_null<tnsr::ijj<DataType, Dim>*> deriv_conformal_metric,
105
    const gsl::not_null<Cache*> cache,
106
    ::Tags::deriv<Xcts::Tags::ConformalMetric<DataType, Dim, Frame::Inertial>,
107
                  tmpl::size_t<Dim>, Frame::Inertial> /*meta*/) const {
108
  const auto& conformal_factor =
34✔
109
      cache->get_var(*this, Xcts::Tags::ConformalFactor<DataType>{});
110
  const auto& deriv_conformal_factor = cache->get_var(
34✔
111
      *this, ::Tags::deriv<Xcts::Tags::ConformalFactor<DataType>,
112
                           tmpl::size_t<Dim>, Frame::Inertial>{});
113
  const auto& conformal_metric = cache->get_var(
34✔
114
      *this, Xcts::Tags::ConformalMetric<DataType, Dim, Frame::Inertial>{});
115
  *deriv_conformal_metric =
34✔
116
      get<::Tags::deriv<gr::Tags::SpatialMetric<Dim, Frame::Inertial, DataType>,
117
                        tmpl::size_t<Dim>, Frame::Inertial>>(gr_solution);
34✔
118
  for (size_t i = 0; i < Dim; ++i) {
136✔
119
    for (size_t j = 0; j < Dim; ++j) {
408✔
120
      for (size_t k = 0; k <= j; ++k) {
918✔
121
        deriv_conformal_metric->get(i, j, k) /= pow<4>(get(conformal_factor));
1,224✔
122
        deriv_conformal_metric->get(i, j, k) -= 4. / get(conformal_factor) *
1,836✔
123
                                                conformal_metric.get(j, k) *
1,836✔
124
                                                deriv_conformal_factor.get(i);
125
      }
126
    }
127
  }
128
}
34✔
129

130
template <typename DataType, bool HasMhd>
131
void WrappedGrVariables<DataType, HasMhd>::operator()(
26✔
132
    const gsl::not_null<Scalar<DataType>*> trace_extrinsic_curvature,
133
    const gsl::not_null<Cache*> /*cache*/,
134
    gr::Tags::TraceExtrinsicCurvature<DataType> /*meta*/) const {
135
  const auto& extrinsic_curvature =
136
      get<gr::Tags::ExtrinsicCurvature<Dim, Frame::Inertial, DataType>>(
52✔
137
          gr_solution);
26✔
138
  const auto& inv_spatial_metric =
139
      get<gr::Tags::InverseSpatialMetric<Dim, Frame::Inertial, DataType>>(
52✔
140
          gr_solution);
26✔
141
  trace(trace_extrinsic_curvature, extrinsic_curvature, inv_spatial_metric);
26✔
142
}
26✔
143

144
template <typename DataType, bool HasMhd>
145
void WrappedGrVariables<DataType, HasMhd>::operator()(
12✔
146
    const gsl::not_null<Scalar<DataType>*> dt_trace_extrinsic_curvature,
147
    const gsl::not_null<Cache*> /*cache*/,
148
    ::Tags::dt<gr::Tags::TraceExtrinsicCurvature<DataType>> /*meta*/) const {
149
  get(*dt_trace_extrinsic_curvature) = 0.;
24✔
150
}
12✔
151

152
template <typename DataType, bool HasMhd>
153
void WrappedGrVariables<DataType, HasMhd>::operator()(
50✔
154
    const gsl::not_null<Scalar<DataType>*> conformal_factor,
155
    const gsl::not_null<Cache*> /*cache*/,
156
    Xcts::Tags::ConformalFactor<DataType> /*meta*/) const {
157
  get(*conformal_factor) = 1.;
100✔
158
}
50✔
159

160
template <typename DataType, bool HasMhd>
161
void WrappedGrVariables<DataType, HasMhd>::operator()(
46✔
162
    const gsl::not_null<tnsr::i<DataType, Dim>*> conformal_factor_gradient,
163
    const gsl::not_null<Cache*> /*cache*/,
164
    ::Tags::deriv<Xcts::Tags::ConformalFactor<DataType>, tmpl::size_t<Dim>,
165
                  Frame::Inertial> /*meta*/) const {
166
  std::fill(conformal_factor_gradient->begin(),
46✔
167
            conformal_factor_gradient->end(), 0.);
46✔
168
}
46✔
169

170
template <typename DataType, bool HasMhd>
171
void WrappedGrVariables<DataType, HasMhd>::operator()(
29✔
172
    const gsl::not_null<Scalar<DataType>*> lapse,
173
    const gsl::not_null<Cache*> /*cache*/,
174
    gr::Tags::Lapse<DataType> /*meta*/) const {
175
  *lapse = get<gr::Tags::Lapse<DataType>>(gr_solution);
29✔
176
}
29✔
177

178
template <typename DataType, bool HasMhd>
179
void WrappedGrVariables<DataType, HasMhd>::operator()(
22✔
180
    const gsl::not_null<Scalar<DataType>*> lapse_times_conformal_factor,
181
    const gsl::not_null<Cache*> cache,
182
    Xcts::Tags::LapseTimesConformalFactor<DataType> /*meta*/) const {
183
  *lapse_times_conformal_factor =
22✔
184
      cache->get_var(*this, gr::Tags::Lapse<DataType>{});
185
  const auto& conformal_factor =
22✔
186
      cache->get_var(*this, Xcts::Tags::ConformalFactor<DataType>{});
187
  get(*lapse_times_conformal_factor) *= get(conformal_factor);
44✔
188
}
22✔
189

190
template <typename DataType, bool HasMhd>
191
void WrappedGrVariables<DataType, HasMhd>::operator()(
14✔
192
    const gsl::not_null<tnsr::i<DataType, Dim>*>
193
        lapse_times_conformal_factor_gradient,
194
    const gsl::not_null<Cache*> cache,
195
    ::Tags::deriv<Xcts::Tags::LapseTimesConformalFactor<DataType>,
196
                  tmpl::size_t<Dim>, Frame::Inertial> /*meta*/) const {
197
  const auto& conformal_factor =
14✔
198
      cache->get_var(*this, Xcts::Tags::ConformalFactor<DataType>{});
199
  const auto& deriv_conformal_factor = cache->get_var(
14✔
200
      *this, ::Tags::deriv<Xcts::Tags::ConformalFactor<DataType>,
201
                           tmpl::size_t<Dim>, Frame::Inertial>{});
202
  *lapse_times_conformal_factor_gradient =
14✔
203
      get<::Tags::deriv<gr::Tags::Lapse<DataType>, tmpl::size_t<Dim>,
204
                        Frame::Inertial>>(gr_solution);
14✔
205
  const auto& lapse = get<gr::Tags::Lapse<DataType>>(gr_solution);
14✔
206
  for (size_t i = 0; i < Dim; ++i) {
56✔
207
    lapse_times_conformal_factor_gradient->get(i) *= get(conformal_factor);
42✔
208
    lapse_times_conformal_factor_gradient->get(i) +=
42✔
209
        get(lapse) * deriv_conformal_factor.get(i);
126✔
210
  }
211
}
14✔
212

213
template <typename DataType, bool HasMhd>
214
void WrappedGrVariables<DataType, HasMhd>::operator()(
21✔
215
    const gsl::not_null<tnsr::I<DataType, Dim>*> shift_background,
216
    const gsl::not_null<Cache*> /*cache*/,
217
    Xcts::Tags::ShiftBackground<DataType, Dim, Frame::Inertial> /*meta*/)
218
    const {
219
  std::fill(shift_background->begin(), shift_background->end(), 0.);
21✔
220
}
21✔
221

222
template <typename DataType, bool HasMhd>
223
void WrappedGrVariables<DataType, HasMhd>::operator()(
26✔
224
    const gsl::not_null<tnsr::II<DataType, Dim, Frame::Inertial>*>
225
        longitudinal_shift_background_minus_dt_conformal_metric,
226
    const gsl::not_null<Cache*> /*cache*/,
227
    Xcts::Tags::LongitudinalShiftBackgroundMinusDtConformalMetric<
228
        DataType, Dim, Frame::Inertial> /*meta*/) const {
229
  std::fill(longitudinal_shift_background_minus_dt_conformal_metric->begin(),
26✔
230
            longitudinal_shift_background_minus_dt_conformal_metric->end(), 0.);
26✔
231
}
26✔
232

233
template <typename DataType, bool HasMhd>
234
void WrappedGrVariables<DataType, HasMhd>::operator()(
21✔
235
    const gsl::not_null<tnsr::I<DataType, Dim>*> shift_excess,
236
    const gsl::not_null<Cache*> /*cache*/,
237
    Xcts::Tags::ShiftExcess<DataType, Dim, Frame::Inertial> /*meta*/) const {
238
  *shift_excess =
21✔
239
      get<gr::Tags::Shift<Dim, Frame::Inertial, DataType>>(gr_solution);
21✔
240
}
21✔
241

242
template <typename DataType, bool HasMhd>
243
void WrappedGrVariables<DataType, HasMhd>::operator()(
26✔
244
    const gsl::not_null<tnsr::ii<DataType, Dim>*> shift_strain,
245
    const gsl::not_null<Cache*> cache,
246
    Xcts::Tags::ShiftStrain<DataType, Dim, Frame::Inertial> /*meta*/) const {
247
  const auto& shift =
248
      get<gr::Tags::Shift<Dim, Frame::Inertial, DataType>>(gr_solution);
26✔
249
  const auto& deriv_shift =
250
      get<::Tags::deriv<gr::Tags::Shift<Dim, Frame::Inertial, DataType>,
251
                        tmpl::size_t<Dim>, Frame::Inertial>>(gr_solution);
26✔
252
  const auto& conformal_metric = cache->get_var(
26✔
253
      *this, Xcts::Tags::ConformalMetric<DataType, Dim, Frame::Inertial>{});
254
  const auto& deriv_conformal_metric = cache->get_var(
26✔
255
      *this,
256
      ::Tags::deriv<Xcts::Tags::ConformalMetric<DataType, Dim, Frame::Inertial>,
257
                    tmpl::size_t<Dim>, Frame::Inertial>{});
258
  const auto& conformal_christoffel_first_kind = cache->get_var(
26✔
259
      *this, Xcts::Tags::ConformalChristoffelFirstKind<DataType, Dim,
260
                                                       Frame::Inertial>{});
261
  Elasticity::strain(shift_strain, deriv_shift, conformal_metric,
26✔
262
                     deriv_conformal_metric, conformal_christoffel_first_kind,
263
                     shift);
264
}
26✔
265

266
template <typename DataType, bool HasMhd>
267
void WrappedGrVariables<DataType, HasMhd>::operator()(
7✔
268
    const gsl::not_null<tnsr::ii<DataType, 3>*> extrinsic_curvature,
269
    const gsl::not_null<Cache*> /*cache*/,
270
    gr::Tags::ExtrinsicCurvature<3, Frame::Inertial, DataType> /*meta*/) const {
271
  *extrinsic_curvature =
7✔
272
      get<gr::Tags::ExtrinsicCurvature<Dim, Frame::Inertial, DataType>>(
7✔
273
          gr_solution);
7✔
274
}
7✔
275

276
#if defined(__GNUC__) && !defined(__clang__)
277
#pragma GCC diagnostic push
278
#pragma GCC diagnostic ignored "-Wsuggest-attribute=noreturn"
279
#endif  // defined(__GNUC__) && !defined(__clang__)
280

281
template <typename DataType, bool HasMhd>
282
void WrappedGrVariables<DataType, HasMhd>::operator()(
12✔
283
    [[maybe_unused]] const gsl::not_null<Scalar<DataType>*>
284
        magnetic_field_dot_spatial_velocity,
285
    const gsl::not_null<Cache*> /*cache*/,
286
    hydro::Tags::MagneticFieldDotSpatialVelocity<DataType> /*meta*/) const {
287
  if constexpr (HasMhd) {
288
    const auto& spatial_velocity =
289
        get<hydro::Tags::SpatialVelocity<DataType, Dim, Frame::Inertial>>(
24✔
290
            hydro_solution);
12✔
291
    const auto& magnetic_field =
292
        get<hydro::Tags::MagneticField<DataType, Dim, Frame::Inertial>>(
24✔
293
            hydro_solution);
12✔
294
    const auto& spatial_metric =
295
        get<gr::Tags::SpatialMetric<Dim, Frame::Inertial, DataType>>(
12✔
296
            gr_solution);
12✔
297
    tenex::evaluate(magnetic_field_dot_spatial_velocity,
48✔
298
                    magnetic_field(ti::I) * spatial_velocity(ti::J) *
299
                        spatial_metric(ti::i, ti::j));
300
  } else {
301
    ERROR(
×
302
        "The 'MagneticFieldDotSpatialVelocity' should not be needed in vacuum "
303
        "GR.");
304
  }
305
}
12✔
306

307
template <typename DataType, bool HasMhd>
308
void WrappedGrVariables<DataType, HasMhd>::operator()(
12✔
309
    [[maybe_unused]] const gsl::not_null<Scalar<DataType>*>
310
        comoving_magnetic_field_squared,
311
    [[maybe_unused]] const gsl::not_null<Cache*> cache,
312
    hydro::Tags::ComovingMagneticFieldSquared<DataType> /*meta*/) const {
313
  if constexpr (HasMhd) {
314
    const auto& lorentz_factor =
315
        get<hydro::Tags::LorentzFactor<DataType>>(hydro_solution);
12✔
316
    const auto& magnetic_field =
317
        get<hydro::Tags::MagneticField<DataType, Dim, Frame::Inertial>>(
24✔
318
            hydro_solution);
12✔
319
    const auto& spatial_metric =
320
        get<gr::Tags::SpatialMetric<Dim, Frame::Inertial, DataType>>(
12✔
321
            gr_solution);
12✔
322
    const auto magnetic_field_squared =
72✔
323
        tenex::evaluate(magnetic_field(ti::I) * magnetic_field(ti::J) *
×
324
                        spatial_metric(ti::i, ti::j));
325
    const auto& magnetic_field_dot_spatial_velocity = cache->get_var(
12✔
326
        *this, hydro::Tags::MagneticFieldDotSpatialVelocity<DataType>{});
327
    hydro::comoving_magnetic_field_squared(
12✔
328
        comoving_magnetic_field_squared, magnetic_field_squared,
329
        magnetic_field_dot_spatial_velocity, lorentz_factor);
330
  } else {
331
    ERROR(
×
332
        "The 'ComovingMagneticFieldSquared' should not be needed in vacuum "
333
        "GR.");
334
  }
335
}
12✔
336

337
#if defined(__GNUC__) && !defined(__clang__)
338
#pragma GCC diagnostic pop
339
#endif  // defined(__GNUC__) && !defined(__clang__)
340

341
template <typename DataType, bool HasMhd>
342
void WrappedGrVariables<DataType, HasMhd>::operator()(
24✔
343
    const gsl::not_null<Scalar<DataType>*> energy_density,
344
    [[maybe_unused]] const gsl::not_null<Cache*> cache,
345
    gr::Tags::Conformal<gr::Tags::EnergyDensity<DataType>, 0> /*meta*/) const {
346
  if constexpr (HasMhd) {
347
    const auto& rest_mass_density =
348
        get<hydro::Tags::RestMassDensity<DataType>>(hydro_solution);
12✔
349
    const auto& specific_enthalpy =
350
        get<hydro::Tags::SpecificEnthalpy<DataType>>(hydro_solution);
12✔
351
    const auto& pressure = get<hydro::Tags::Pressure<DataType>>(hydro_solution);
12✔
352
    const auto& lorentz_factor =
353
        get<hydro::Tags::LorentzFactor<DataType>>(hydro_solution);
12✔
354
    const auto& magnetic_field_dot_spatial_velocity = cache->get_var(
12✔
355
        *this, hydro::Tags::MagneticFieldDotSpatialVelocity<DataType>{});
356
    const auto& comoving_magnetic_field_squared = cache->get_var(
12✔
357
        *this, hydro::Tags::ComovingMagneticFieldSquared<DataType>{});
358
    hydro::energy_density(energy_density, rest_mass_density, specific_enthalpy,
12✔
359
                          pressure, lorentz_factor,
360
                          magnetic_field_dot_spatial_velocity,
361
                          comoving_magnetic_field_squared);
362
  } else {
363
    std::fill(energy_density->begin(), energy_density->end(), 0.);
12✔
364
  }
365
}
24✔
366

367
template <typename DataType, bool HasMhd>
368
void WrappedGrVariables<DataType, HasMhd>::operator()(
12✔
369
    const gsl::not_null<Scalar<DataType>*> stress_trace,
370
    [[maybe_unused]] const gsl::not_null<Cache*> cache,
371
    gr::Tags::Conformal<gr::Tags::StressTrace<DataType>, 0> /*meta*/) const {
372
  if constexpr (HasMhd) {
373
    const auto& rest_mass_density =
374
        get<hydro::Tags::RestMassDensity<DataType>>(hydro_solution);
6✔
375
    const auto& specific_enthalpy =
376
        get<hydro::Tags::SpecificEnthalpy<DataType>>(hydro_solution);
6✔
377
    const auto& pressure = get<hydro::Tags::Pressure<DataType>>(hydro_solution);
6✔
378
    const auto& spatial_velocity =
379
        get<hydro::Tags::SpatialVelocity<DataType, Dim, Frame::Inertial>>(
12✔
380
            hydro_solution);
6✔
381
    const auto& spatial_metric =
382
        get<gr::Tags::SpatialMetric<Dim, Frame::Inertial, DataType>>(
6✔
383
            gr_solution);
6✔
384
    const auto spatial_velocity_squared =
36✔
385
        tenex::evaluate(spatial_velocity(ti::I) * spatial_velocity(ti::J) *
×
386
                        spatial_metric(ti::i, ti::j));
387
    const auto& lorentz_factor =
388
        get<hydro::Tags::LorentzFactor<DataType>>(hydro_solution);
6✔
389
    const auto& magnetic_field_dot_spatial_velocity = cache->get_var(
6✔
390
        *this, hydro::Tags::MagneticFieldDotSpatialVelocity<DataType>{});
391
    const auto& comoving_magnetic_field_squared = cache->get_var(
6✔
392
        *this, hydro::Tags::ComovingMagneticFieldSquared<DataType>{});
393
    hydro::stress_trace(stress_trace, rest_mass_density, specific_enthalpy,
6✔
394
                        pressure, spatial_velocity_squared, lorentz_factor,
395
                        magnetic_field_dot_spatial_velocity,
396
                        comoving_magnetic_field_squared);
397
  } else {
398
    std::fill(stress_trace->begin(), stress_trace->end(), 0.);
6✔
399
  }
400
}
12✔
401

402
template <typename DataType, bool HasMhd>
403
void WrappedGrVariables<DataType, HasMhd>::operator()(
12✔
404
    const gsl::not_null<tnsr::I<DataType, Dim>*> momentum_density,
405
    [[maybe_unused]] const gsl::not_null<Cache*> cache,
406
    gr::Tags::Conformal<
407
        gr::Tags::MomentumDensity<Dim, Frame::Inertial, DataType>, 0> /*meta*/)
408
    const {
409
  if constexpr (HasMhd) {
410
    const auto& rest_mass_density =
411
        get<hydro::Tags::RestMassDensity<DataType>>(hydro_solution);
6✔
412
    const auto& specific_enthalpy =
413
        get<hydro::Tags::SpecificEnthalpy<DataType>>(hydro_solution);
6✔
414
    const auto& spatial_velocity =
415
        get<hydro::Tags::SpatialVelocity<DataType, Dim, Frame::Inertial>>(
12✔
416
            hydro_solution);
6✔
417
    const auto& lorentz_factor =
418
        get<hydro::Tags::LorentzFactor<DataType>>(hydro_solution);
6✔
419
    const auto& magnetic_field =
420
        get<hydro::Tags::MagneticField<DataType, Dim, Frame::Inertial>>(
12✔
421
            hydro_solution);
6✔
422
    const auto& magnetic_field_dot_spatial_velocity = cache->get_var(
6✔
423
        *this, hydro::Tags::MagneticFieldDotSpatialVelocity<DataType>{});
424
    const auto& comoving_magnetic_field_squared = cache->get_var(
6✔
425
        *this, hydro::Tags::ComovingMagneticFieldSquared<DataType>{});
426
    hydro::momentum_density(momentum_density, rest_mass_density,
6✔
427
                            specific_enthalpy, spatial_velocity, lorentz_factor,
428
                            magnetic_field, magnetic_field_dot_spatial_velocity,
429
                            comoving_magnetic_field_squared);
430
  } else {
431
    std::fill(momentum_density->begin(), momentum_density->end(), 0.);
6✔
432
  }
433
}
12✔
434

435
template class WrappedGrVariables<double, false>;
436
template class WrappedGrVariables<DataVector, false>;
437
template class WrappedGrVariables<double, true>;
438
template class WrappedGrVariables<DataVector, true>;
439

440
}  // namespace detail
441

442
template <typename GrSolution, bool HasMhd, typename... GrSolutionOptions>
443
PUP::able::PUP_ID
444
    WrappedGr<GrSolution, HasMhd, tmpl::list<GrSolutionOptions...>>::my_PUP_ID =
445
        0;  // NOLINT
446

447
}  // namespace Xcts::Solutions
448

449
// Instantiate implementations for common variables
450
template class Xcts::Solutions::CommonVariables<
451
    double,
452
    typename Xcts::Solutions::detail::WrappedGrVariables<double, false>::Cache>;
453
template class Xcts::Solutions::CommonVariables<
454
    DataVector, typename Xcts::Solutions::detail::WrappedGrVariables<
455
                    DataVector, false>::Cache>;
456
template class Xcts::AnalyticData::CommonVariables<
457
    double,
458
    typename Xcts::Solutions::detail::WrappedGrVariables<double, false>::Cache>;
459
template class Xcts::AnalyticData::CommonVariables<
460
    DataVector, typename Xcts::Solutions::detail::WrappedGrVariables<
461
                    DataVector, false>::Cache>;
462

463
#define STYPE(data) BOOST_PP_TUPLE_ELEM(0, data)
464

465
#define INSTANTIATE_GR(_, data) \
466
  template class Xcts::Solutions::WrappedGr<STYPE(data), false>;
467
#define INSTANTIATE_GRMHD(_, data) \
468
  template class Xcts::Solutions::WrappedGr<STYPE(data), true>;
469

470
GENERATE_INSTANTIATIONS(INSTANTIATE_GR, (gr::Solutions::KerrSchild,
471
                                         gr::Solutions::SphericalKerrSchild,
472
                                         gr::Solutions::HarmonicSchwarzschild))
473
GENERATE_INSTANTIATIONS(INSTANTIATE_GRMHD,
474
                        (grmhd::AnalyticData::CcsnCollapse,
475
                         grmhd::AnalyticData::MagnetizedTovStar,
476
                         RelativisticEuler::Solutions::RotatingStar))
477

478
#undef STYPE
479
#undef INSTANTIATE_GR
480
#undef INSTANTIATE_GRMHD
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc