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

sxs-collaboration / spectre / 4166255778

pending completion
4166255778

push

github

GitHub
Merge pull request #1224 from nilsvu/jet

104 of 104 new or added lines in 2 files covered. (100.0%)

63434 of 66125 relevant lines covered (95.93%)

406544.0 hits per line

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

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

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

6
#include <cmath>
7
#include <ostream>
8
#include <pup.h>
9

10
#include "DataStructures/DataBox/DataBoxTag.hpp"
11
#include "DataStructures/DataVector.hpp"
12
#include "DataStructures/Tensor/EagerMath/DotProduct.hpp"
13
#include "Parallel/PupStlCpp11.hpp"
14
#include "PointwiseFunctions/Hydro/LorentzFactor.hpp"
15
#include "PointwiseFunctions/Hydro/SpecificEnthalpy.hpp"
16
#include "PointwiseFunctions/Hydro/Tags.hpp"
17
#include "Utilities/ConstantExpressions.hpp"
18
#include "Utilities/ContainerHelpers.hpp"
19
#include "Utilities/GenerateInstantiations.hpp"
20
#include "Utilities/Gsl.hpp"
21
#include "Utilities/MakeWithValue.hpp"
22
#include "Utilities/Math.hpp"
23

24
namespace {
25
template <typename DataType>
26
Scalar<DataType> compute_piecewise(const tnsr::I<DataType, 3>& x,
162✔
27
                                   const double inlet_radius,
28
                                   const double ambient_value,
29
                                   const double jet_value) {
30
  auto result = make_with_value<Scalar<DataType>>(x, ambient_value);
81✔
31
  for (size_t i = 0; i < get_size(get(result)); ++i) {
1,944✔
32
    if (get_element(get<0>(x), i) <= 0. and
972✔
33
        abs(get_element(get<1>(x), i)) <= inlet_radius) {
×
34
      get_element(get(result), i) = jet_value;
×
35
    }
36
  }
37
  return result;
162✔
38
}
39

40
template <typename DataType>
41
tnsr::I<DataType, 3> compute_piecewise_vector(
36✔
42
    const tnsr::I<DataType, 3>& x, const double inlet_radius,
43
    const std::array<double, 3>& ambient_value,
44
    const std::array<double, 3>& jet_value) {
45
  auto result = make_with_value<tnsr::I<DataType, 3>>(x, 0.);
36✔
46
  for (size_t i = 0; i < get_size(get<0>(result)); ++i) {
432✔
47
    if (get_element(get<0>(x), i) <= 0. and
216✔
48
        abs(get_element(get<1>(x), i)) <= inlet_radius) {
×
49
      get_element(get<0>(result), i) = jet_value[0];
×
50
      get_element(get<1>(result), i) = jet_value[1];
×
51
      get_element(get<2>(result), i) = jet_value[2];
×
52
    } else {
53
      get_element(get<0>(result), i) = ambient_value[0];
216✔
54
      get_element(get<1>(result), i) = ambient_value[1];
234✔
55
      get_element(get<2>(result), i) = ambient_value[2];
324✔
56
    }
57
  }
58
  return result;
36✔
59
}
60
}  // namespace
61

62
namespace grmhd::AnalyticData {
63

64
SlabJet::SlabJet(double adiabatic_index, double ambient_density,
6✔
65
                 double ambient_pressure, double ambient_electron_fraction,
66
                 double jet_density, double jet_pressure,
67
                 double jet_electron_fraction,
68
                 std::array<double, 3> jet_velocity, double inlet_radius,
69
                 std::array<double, 3> magnetic_field)
6✔
70
    : equation_of_state_(adiabatic_index),
71
      ambient_density_(ambient_density),
72
      ambient_pressure_(ambient_pressure),
73
      ambient_electron_fraction_(ambient_electron_fraction),
74
      jet_density_(jet_density),
75
      jet_pressure_(jet_pressure),
76
      jet_electron_fraction_(jet_electron_fraction),
77
      jet_velocity_(jet_velocity),
78
      inlet_radius_(inlet_radius),
79
      magnetic_field_(magnetic_field) {}
6✔
80

81
std::unique_ptr<evolution::initial_data::InitialData> SlabJet::get_clone()
2✔
82
    const {
83
  return std::make_unique<SlabJet>(*this);
2✔
84
}
85

86
SlabJet::SlabJet(CkMigrateMessage* msg) : InitialData(msg) {}
2✔
87

88
void SlabJet::pup(PUP::er& p) {
6✔
89
  InitialData::pup(p);
6✔
90
  p | equation_of_state_;
6✔
91
  p | background_spacetime_;
6✔
92
  p | ambient_density_;
6✔
93
  p | ambient_pressure_;
6✔
94
  p | ambient_electron_fraction_;
6✔
95
  p | jet_density_;
6✔
96
  p | jet_pressure_;
6✔
97
  p | jet_electron_fraction_;
6✔
98
  p | jet_velocity_;
6✔
99
  p | inlet_radius_;
6✔
100
  p | magnetic_field_;
6✔
101
}
6✔
102

103
template <typename DataType>
104
tuples::TaggedTuple<hydro::Tags::RestMassDensity<DataType>> SlabJet::variables(
72✔
105
    const tnsr::I<DataType, 3>& x,
106
    tmpl::list<hydro::Tags::RestMassDensity<DataType>> /*meta*/) const {
107
  return compute_piecewise(x, inlet_radius_, ambient_density_, jet_density_);
72✔
108
}
109

110
template <typename DataType>
111
tuples::TaggedTuple<hydro::Tags::ElectronFraction<DataType>> SlabJet::variables(
18✔
112
    const tnsr::I<DataType, 3>& x,
113
    tmpl::list<hydro::Tags::ElectronFraction<DataType>> /*meta*/) const {
114
  return compute_piecewise(x, inlet_radius_, ambient_electron_fraction_,
27✔
115
                           jet_electron_fraction_);
18✔
116
}
117

118
template <typename DataType>
119
tuples::TaggedTuple<hydro::Tags::SpatialVelocity<DataType, 3>>
120
SlabJet::variables(
36✔
121
    const tnsr::I<DataType, 3>& x,
122
    tmpl::list<hydro::Tags::SpatialVelocity<DataType, 3>> /*meta*/) const {
123
  return compute_piecewise_vector(
18✔
124
      x, inlet_radius_, std::array<double, 3>{{0., 0., 0.}}, jet_velocity_);
54✔
125
}
126

127
template <typename DataType>
128
tuples::TaggedTuple<hydro::Tags::SpecificInternalEnergy<DataType>>
129
SlabJet::variables(
36✔
130
    const tnsr::I<DataType, 3>& x,
131
    tmpl::list<hydro::Tags::SpecificInternalEnergy<DataType>> /*meta*/) const {
132
  using density_tag = hydro::Tags::RestMassDensity<DataType>;
133
  using pressure_tag = hydro::Tags::Pressure<DataType>;
134
  const auto data = variables(x, tmpl::list<density_tag, pressure_tag>{});
36✔
135
  return equation_of_state_.specific_internal_energy_from_density_and_pressure(
136
      get<density_tag>(data), get<pressure_tag>(data));
54✔
137
}
138

139
template <typename DataType>
140
tuples::TaggedTuple<hydro::Tags::Pressure<DataType>> SlabJet::variables(
72✔
141
    const tnsr::I<DataType, 3>& x,
142
    tmpl::list<hydro::Tags::Pressure<DataType>> /*meta*/) const {
143
  return compute_piecewise(x, inlet_radius_, ambient_pressure_, jet_pressure_);
72✔
144
}
145

146
template <typename DataType>
147
tuples::TaggedTuple<hydro::Tags::MagneticField<DataType, 3>> SlabJet::variables(
18✔
148
    const tnsr::I<DataType, 3>& x,
149
    tmpl::list<hydro::Tags::MagneticField<DataType, 3>> /*meta*/) const {
150
  auto magnetic_field = make_with_value<tnsr::I<DataType, 3>>(x, 0.);
27✔
151
  get<0>(magnetic_field) = magnetic_field_[0];
27✔
152
  get<1>(magnetic_field) = magnetic_field_[1];
27✔
153
  get<2>(magnetic_field) = magnetic_field_[2];
27✔
154
  return {std::move(magnetic_field)};
36✔
155
}
156

157
template <typename DataType>
158
tuples::TaggedTuple<hydro::Tags::DivergenceCleaningField<DataType>>
159
SlabJet::variables(
18✔
160
    const tnsr::I<DataType, 3>& x,
161
    tmpl::list<hydro::Tags::DivergenceCleaningField<DataType>> /*meta*/) const {
162
  return {make_with_value<Scalar<DataType>>(x, 0.)};
36✔
163
}
164

165
template <typename DataType>
166
tuples::TaggedTuple<hydro::Tags::LorentzFactor<DataType>> SlabJet::variables(
18✔
167
    const tnsr::I<DataType, 3>& x,
168
    tmpl::list<hydro::Tags::LorentzFactor<DataType>> /*meta*/) const {
169
  const auto spatial_velocity = get<hydro::Tags::SpatialVelocity<DataType, 3>>(
18✔
170
      variables(x, tmpl::list<hydro::Tags::SpatialVelocity<DataType, 3>>{}));
171
  return {
172
      hydro::lorentz_factor(dot_product(spatial_velocity, spatial_velocity))};
27✔
173
}
174

175
template <typename DataType>
176
tuples::TaggedTuple<hydro::Tags::SpecificEnthalpy<DataType>> SlabJet::variables(
18✔
177
    const tnsr::I<DataType, 3>& x,
178
    tmpl::list<hydro::Tags::SpecificEnthalpy<DataType>> /*meta*/) const {
179
  using density_tag = hydro::Tags::RestMassDensity<DataType>;
180
  using energy_tag = hydro::Tags::SpecificInternalEnergy<DataType>;
181
  using pressure_tag = hydro::Tags::Pressure<DataType>;
182
  const auto data =
18✔
183
      variables(x, tmpl::list<density_tag, energy_tag, pressure_tag>{});
184
  return hydro::relativistic_specific_enthalpy(
×
185
      get<density_tag>(data), get<energy_tag>(data), get<pressure_tag>(data));
27✔
186
}
187

188
PUP::able::PUP_ID SlabJet::my_PUP_ID = 0;
189

190
bool operator==(const SlabJet& lhs, const SlabJet& rhs) {
8✔
191
  return lhs.equation_of_state_ == rhs.equation_of_state_ and
8✔
192
         lhs.ambient_density_ == rhs.ambient_density_ and
8✔
193
         lhs.ambient_pressure_ == rhs.ambient_pressure_ and
8✔
194
         lhs.ambient_electron_fraction_ == rhs.ambient_electron_fraction_ and
8✔
195
         lhs.jet_density_ == rhs.jet_density_ and
8✔
196
         lhs.jet_pressure_ == rhs.jet_pressure_ and
8✔
197
         lhs.jet_electron_fraction_ == rhs.jet_electron_fraction_ and
8✔
198
         lhs.jet_velocity_ == rhs.jet_velocity_ and
8✔
199
         lhs.inlet_radius_ == rhs.inlet_radius_ and
24✔
200
         lhs.magnetic_field_ == rhs.magnetic_field_;
16✔
201
}
202

203
bool operator!=(const SlabJet& lhs, const SlabJet& rhs) {
2✔
204
  return not(lhs == rhs);
2✔
205
}
206

207
#define DTYPE(data) BOOST_PP_TUPLE_ELEM(0, data)
208
#define TAG(data) BOOST_PP_TUPLE_ELEM(1, data)
209

210
#define INSTANTIATE_SCALARS(_, data)                        \
211
  template tuples::TaggedTuple < TAG(data) < DTYPE(data) >> \
212
      SlabJet::variables(const tnsr::I<DTYPE(data), 3>&,    \
213
                         tmpl::list < TAG(data) < DTYPE(data) >>) const;
214

215
GENERATE_INSTANTIATIONS(
216
    INSTANTIATE_SCALARS, (double, DataVector),
217
    (hydro::Tags::RestMassDensity, hydro::Tags::ElectronFraction,
218
     hydro::Tags::SpecificInternalEnergy, hydro::Tags::Pressure,
219
     hydro::Tags::DivergenceCleaningField, hydro::Tags::LorentzFactor,
220
     hydro::Tags::SpecificEnthalpy))
221

222
#define INSTANTIATE_VECTORS(_, data)                                   \
223
  template tuples::TaggedTuple < TAG(data) < DTYPE(data),              \
224
      3 >> SlabJet::variables(const tnsr::I<DTYPE(data), 3>&,          \
225
                              tmpl::list < TAG(data) < DTYPE(data), 3, \
226
                              Frame::Inertial >>) const;
227

228
GENERATE_INSTANTIATIONS(INSTANTIATE_VECTORS, (double, DataVector),
229
                        (hydro::Tags::SpatialVelocity,
230
                         hydro::Tags::MagneticField))
231

232
#undef DTYPE
233
#undef TAG
234
#undef INSTANTIATE_SCALARS
235
#undef INSTANTIATE_VECTORS
236
}  // 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