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

sxs-collaboration / spectre / 4235749111

pending completion
4235749111

push

github

GitHub
Merge pull request #3142 from nilsvu/reftags_args

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

63847 of 66538 relevant lines covered (95.96%)

468412.87 hits per line

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

89.36
/src/PointwiseFunctions/AnalyticData/GrMhd/RiemannProblem.cpp
1
// Distributed under the MIT License.
2
// See LICENSE.txt for details.
3

4
#include "PointwiseFunctions/AnalyticData/GrMhd/RiemannProblem.hpp"
5

6
#include <pup.h>
7

8
#include "DataStructures/DataVector.hpp"  // IWYU pragma: keep
9
#include "DataStructures/Tensor/EagerMath/DotProduct.hpp"
10
#include "DataStructures/Tensor/Tensor.hpp"  // IWYU pragma: keep
11
#include "PointwiseFunctions/Hydro/LorentzFactor.hpp"
12
#include "PointwiseFunctions/Hydro/SpecificEnthalpy.hpp"
13
#include "PointwiseFunctions/Hydro/Tags.hpp"
14
#include "Utilities/ContainerHelpers.hpp"
15
#include "Utilities/GenerateInstantiations.hpp"
16
#include "Utilities/MakeWithValue.hpp"
17
#include "Utilities/Math.hpp"  // IWYU pragma: keep
18

19
namespace grmhd::AnalyticData {
20

21
RiemannProblem::RiemannProblem(
7✔
22
    const double adiabatic_index, const double left_rest_mass_density,
23
    const double right_rest_mass_density, const double left_pressure,
24
    const double right_pressure,
25
    const std::array<double, 3>& left_spatial_velocity,
26
    const std::array<double, 3>& right_spatial_velocity,
27
    const std::array<double, 3>& left_magnetic_field,
28
    const std::array<double, 3>& right_magnetic_field, const double lapse,
29
    const double shift)
7✔
30
    : equation_of_state_(adiabatic_index),
31
      adiabatic_index_(adiabatic_index),
32
      left_rest_mass_density_(left_rest_mass_density),
33
      right_rest_mass_density_(right_rest_mass_density),
34
      left_pressure_(left_pressure),
35
      right_pressure_(right_pressure),
36
      left_spatial_velocity_(left_spatial_velocity),
37
      right_spatial_velocity_(right_spatial_velocity),
38
      left_magnetic_field_(left_magnetic_field),
39
      right_magnetic_field_(right_magnetic_field),
40
      lapse_(lapse),
41
      shift_(shift) {}
7✔
42

43
std::unique_ptr<evolution::initial_data::InitialData>
44
RiemannProblem::get_clone() const {
1✔
45
  return std::make_unique<RiemannProblem>(*this);
1✔
46
}
47

48
RiemannProblem::RiemannProblem(CkMigrateMessage* msg) : InitialData(msg) {}
1✔
49

50
void RiemannProblem::pup(PUP::er& p) {
6✔
51
  InitialData::pup(p);
6✔
52
  p | equation_of_state_;
6✔
53
  p | background_spacetime_;
6✔
54
  p | adiabatic_index_;
6✔
55
  p | left_rest_mass_density_;
6✔
56
  p | right_rest_mass_density_;
6✔
57
  p | left_pressure_;
6✔
58
  p | right_pressure_;
6✔
59
  p | left_spatial_velocity_;
6✔
60
  p | right_spatial_velocity_;
6✔
61
  p | left_magnetic_field_;
6✔
62
  p | right_magnetic_field_;
6✔
63
  p | lapse_;
6✔
64
  p | shift_;
6✔
65
}
6✔
66

67
template <typename DataType>
68
tuples::TaggedTuple<hydro::Tags::RestMassDensity<DataType>>
69
RiemannProblem::variables(
112✔
70
    const tnsr::I<DataType, 3>& x,
71
    tmpl::list<hydro::Tags::RestMassDensity<DataType>> /*meta*/) const {
72
  auto mass_density = make_with_value<Scalar<DataType>>(x, 0.0);
168✔
73
  for (size_t i = 0; i < get_size(get<0>(x)); ++i) {
1,344✔
74
    if (get_element(get<0>(x), i) <= discontinuity_location_) {
672✔
75
      get_element(get(mass_density), i) = left_rest_mass_density_;
144✔
76
    } else {
77
      get_element(get(mass_density), i) = right_rest_mass_density_;
864✔
78
    }
79
  }
80
  return mass_density;
168✔
81
}
82

83
template <typename DataType>
84
tuples::TaggedTuple<hydro::Tags::ElectronFraction<DataType>>
85
RiemannProblem::variables(
86
    const tnsr::I<DataType, 3>& x,
87
    tmpl::list<hydro::Tags::ElectronFraction<DataType>> /*meta*/) const {
88

89
    return {make_with_value<Scalar<DataType>>(x, 0.1)};
90
}
91

92
template <typename DataType>
93
tuples::TaggedTuple<hydro::Tags::SpatialVelocity<DataType, 3>>
94
RiemannProblem::variables(
56✔
95
    const tnsr::I<DataType, 3>& x,
96
    tmpl::list<hydro::Tags::SpatialVelocity<DataType, 3>> /*meta*/) const {
97
  auto spatial_velocity =
28✔
98
      make_with_value<tnsr::I<DataType, 3, Frame::Inertial>>(x, 0.0);
56✔
99
  for (size_t i = 0; i < get_size(get<0>(x)); ++i) {
672✔
100
    if (get_element(get<0>(x), i) <= discontinuity_location_) {
336✔
101
      get_element(get<0>(spatial_velocity), i) = left_spatial_velocity_[0];
48✔
102
      get_element(get<1>(spatial_velocity), i) = left_spatial_velocity_[1];
48✔
103
      get_element(get<2>(spatial_velocity), i) = left_spatial_velocity_[2];
72✔
104
    } else {
105
      get_element(get<0>(spatial_velocity), i) = right_spatial_velocity_[0];
288✔
106
      get_element(get<1>(spatial_velocity), i) = right_spatial_velocity_[1];
288✔
107
      get_element(get<2>(spatial_velocity), i) = right_spatial_velocity_[2];
432✔
108
    }
109
  }
110
  return spatial_velocity;
112✔
111
}
112

113
template <typename DataType>
114
tuples::TaggedTuple<hydro::Tags::SpecificInternalEnergy<DataType>>
115
RiemannProblem::variables(
56✔
116
    const tnsr::I<DataType, 3>& x,
117
    tmpl::list<hydro::Tags::SpecificInternalEnergy<DataType>> /*meta*/) const {
118
  return equation_of_state_.specific_internal_energy_from_density_and_pressure(
119
      get<hydro::Tags::RestMassDensity<DataType>>(
56✔
120
          variables(x, tmpl::list<hydro::Tags::RestMassDensity<DataType>>{})),
121
      get<hydro::Tags::Pressure<DataType>>(
84✔
122
          variables(x, tmpl::list<hydro::Tags::Pressure<DataType>>{})));
140✔
123
}
124

125
template <typename DataType>
126
tuples::TaggedTuple<hydro::Tags::Pressure<DataType>> RiemannProblem::variables(
112✔
127
    const tnsr::I<DataType, 3>& x,
128
    tmpl::list<hydro::Tags::Pressure<DataType>> /*meta*/) const {
129
  auto pressure = make_with_value<Scalar<DataType>>(x, 0.0);
168✔
130
  for (size_t i = 0; i < get_size(get<0>(x)); ++i) {
1,344✔
131
    if (get_element(get<0>(x), i) <= discontinuity_location_) {
672✔
132
      get_element(get(pressure), i) = left_pressure_;
144✔
133
    } else {
134
      get_element(get(pressure), i) = right_pressure_;
864✔
135
    }
136
  }
137
  return pressure;
168✔
138
}
139

140
template <typename DataType>
141
tuples::TaggedTuple<hydro::Tags::MagneticField<DataType, 3>>
142
RiemannProblem::variables(
16✔
143
    const tnsr::I<DataType, 3>& x,
144
    tmpl::list<hydro::Tags::MagneticField<DataType, 3>> /*meta*/) const {
145
  auto magnetic_field =
8✔
146
      make_with_value<tnsr::I<DataType, 3, Frame::Inertial>>(x, 0.0);
16✔
147
  for (size_t i = 0; i < get_size(get<0>(x)); ++i) {
192✔
148
    if (get_element(get<0>(x), i) <= discontinuity_location_) {
96✔
149
      get_element(get<0>(magnetic_field), i) = left_magnetic_field_[0];
×
150
      get_element(get<1>(magnetic_field), i) = left_magnetic_field_[1];
×
151
      get_element(get<2>(magnetic_field), i) = left_magnetic_field_[2];
×
152
    } else {
153
      get_element(get<0>(magnetic_field), i) = right_magnetic_field_[0];
96✔
154
      get_element(get<1>(magnetic_field), i) = right_magnetic_field_[1];
96✔
155
      get_element(get<2>(magnetic_field), i) = right_magnetic_field_[2];
144✔
156
    }
157
  }
158
  return magnetic_field;
32✔
159
}
160

161
template <typename DataType>
162
tuples::TaggedTuple<hydro::Tags::DivergenceCleaningField<DataType>>
163
RiemannProblem::variables(
16✔
164
    const tnsr::I<DataType, 3>& x,
165
    tmpl::list<hydro::Tags::DivergenceCleaningField<DataType>> /*meta*/) const {
166
  return {make_with_value<Scalar<DataType>>(x, 0.0)};
32✔
167
}
168

169
template <typename DataType>
170
tuples::TaggedTuple<hydro::Tags::LorentzFactor<DataType>>
171
RiemannProblem::variables(
28✔
172
    const tnsr::I<DataType, 3>& x,
173
    tmpl::list<hydro::Tags::LorentzFactor<DataType>> /*meta*/) const {
174
  const auto spatial_velocity = get<hydro::Tags::SpatialVelocity<DataType, 3>>(
28✔
175
      variables(x, tmpl::list<hydro::Tags::SpatialVelocity<DataType, 3>>{}));
176
  return {
177
      hydro::lorentz_factor(dot_product(spatial_velocity, spatial_velocity))};
42✔
178
}
179

180
template <typename DataType>
181
tuples::TaggedTuple<hydro::Tags::SpecificEnthalpy<DataType>>
182
RiemannProblem::variables(
28✔
183
    const tnsr::I<DataType, 3>& x,
184
    tmpl::list<hydro::Tags::SpecificEnthalpy<DataType>> /*meta*/) const {
185
  return hydro::relativistic_specific_enthalpy(
×
186
      get<hydro::Tags::RestMassDensity<DataType>>(
28✔
187
          variables(x, tmpl::list<hydro::Tags::RestMassDensity<DataType>>{})),
188
      get<hydro::Tags::SpecificInternalEnergy<DataType>>(variables(
42✔
189
          x, tmpl::list<hydro::Tags::SpecificInternalEnergy<DataType>>{})),
190
      get<hydro::Tags::Pressure<DataType>>(
42✔
191
          variables(x, tmpl::list<hydro::Tags::Pressure<DataType>>{})));
42✔
192
}
193

194
template <typename DataType>
195
tuples::TaggedTuple<gr::Tags::Lapse<DataType>> RiemannProblem::variables(
×
196
    const tnsr::I<DataType, 3>& x,
197
    tmpl::list<gr::Tags::Lapse<DataType>> /*meta*/) const {
198
  return {make_with_value<Scalar<DataType>>(x, lapse_)};
×
199
}
200

201
template <typename DataType>
202
tuples::TaggedTuple<gr::Tags::Shift<3, Frame::Inertial, DataType>>
203
RiemannProblem::variables(
×
204
    const tnsr::I<DataType, 3>& x,
205
    tmpl::list<gr::Tags::Shift<3, Frame::Inertial, DataType>> /*meta*/) const {
206
  auto shift = make_with_value<tnsr::I<DataType, 3, Frame::Inertial>>(x, 0.0);
×
207
  get<0>(shift) = shift_;
×
208
  return {std::move(shift)};
×
209
}
210

211
PUP::able::PUP_ID RiemannProblem::my_PUP_ID = 0;
212

213
bool operator==(const RiemannProblem& lhs, const RiemannProblem& rhs) {
5✔
214
  return lhs.adiabatic_index_ == rhs.adiabatic_index_ and
10✔
215
         lhs.left_rest_mass_density_ == rhs.left_rest_mass_density_ and
5✔
216
         lhs.right_rest_mass_density_ == rhs.right_rest_mass_density_ and
5✔
217
         lhs.left_pressure_ == rhs.left_pressure_ and
5✔
218
         lhs.right_pressure_ == rhs.right_pressure_ and
5✔
219
         lhs.left_spatial_velocity_ == rhs.left_spatial_velocity_ and
5✔
220
         lhs.right_spatial_velocity_ == rhs.right_spatial_velocity_ and
5✔
221
         lhs.left_magnetic_field_ == rhs.left_magnetic_field_ and
5✔
222
         lhs.right_magnetic_field_ == rhs.right_magnetic_field_ and
5✔
223
         lhs.lapse_ == rhs.lapse_ and lhs.shift_ == rhs.shift_;
10✔
224
}
225

226
bool operator!=(const RiemannProblem& lhs, const RiemannProblem& rhs) {
1✔
227
  return not(lhs == rhs);
1✔
228
}
229

230
#define DTYPE(data) BOOST_PP_TUPLE_ELEM(0, data)
231
#define TAG(data) BOOST_PP_TUPLE_ELEM(1, data)
232

233
#define INSTANTIATE_SCALARS(_, data)                                           \
234
  template tuples::TaggedTuple<TAG(data) < DTYPE(data)>>                       \
235
      RiemannProblem::variables(const tnsr::I<DTYPE(data), 3>& x,              \
236
                                tmpl::list<TAG(data) < DTYPE(data)>> /*meta*/) \
237
          const;
238

239
GENERATE_INSTANTIATIONS(INSTANTIATE_SCALARS, (double, DataVector),
240
                        (hydro::Tags::RestMassDensity,
241
                         hydro::Tags::SpecificInternalEnergy,
242
                         hydro::Tags::Pressure,
243
                         hydro::Tags::DivergenceCleaningField,
244
                         hydro::Tags::LorentzFactor,
245
                         hydro::Tags::SpecificEnthalpy, gr::Tags::Lapse))
246

247
#define INSTANTIATE_VECTORS(_, data)                        \
248
  template tuples::TaggedTuple<TAG(data) < DTYPE(data), 3>> \
249
      RiemannProblem::variables(                            \
250
          const tnsr::I<DTYPE(data), 3>& x,                 \
251
          tmpl::list<TAG(data) < DTYPE(data), 3>> /*meta*/) const;
252

253
GENERATE_INSTANTIATIONS(INSTANTIATE_VECTORS, (double, DataVector),
254
                        (hydro::Tags::SpatialVelocity,
255
                         hydro::Tags::MagneticField))
256

257
#undef DTYPE
258
#undef TAG
259
#undef INSTANTIATE_SCALARS
260
#undef INSTANTIATE_VECTORS
261

262
// The GR tags have a different template parameter ordering than the rest of the
263
// code, so need to instantiate separately.
264
template tuples::TaggedTuple<gr::Tags::Shift<3, Frame::Inertial, double>>
265
RiemannProblem::variables(
266
    const tnsr::I<double, 3>& x,
267
    tmpl::list<gr::Tags::Shift<3, Frame::Inertial, double>> /*meta*/) const;
268
template tuples::TaggedTuple<gr::Tags::Shift<3, Frame::Inertial, DataVector>>
269
RiemannProblem::variables(
270
    const tnsr::I<DataVector, 3>& x,
271
    tmpl::list<gr::Tags::Shift<3, Frame::Inertial, DataVector>> /*meta*/) const;
272
}  // namespace grmhd::AnalyticData
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

© 2025 Coveralls, Inc