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

sxs-collaboration / spectre / 4245608534

pending completion
4245608534

push

github

GitHub
Merge pull request #4745 from knelli2/time_dep_dep

13 of 13 new or added lines in 4 files covered. (100.0%)

63923 of 66629 relevant lines covered (95.94%)

427287.21 hits per line

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

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

4
#include "PointwiseFunctions/AnalyticData/GrMhd/InitialMagneticFields/Poloidal.hpp"
5

6
#include <memory>
7

8
#include "DataStructures/Tensor/Tensor.hpp"
9
#include "PointwiseFunctions/AnalyticData/GrMhd/InitialMagneticFields/InitialMagneticField.hpp"
10
#include "PointwiseFunctions/Hydro/Tags.hpp"
11
#include "Utilities/ContainerHelpers.hpp"
12
#include "Utilities/GenerateInstantiations.hpp"
13

14
namespace grmhd::AnalyticData::InitialMagneticFields {
15

16
std::unique_ptr<InitialMagneticField> Poloidal::get_clone() const {
1✔
17
  return std::make_unique<Poloidal>(*this);
1✔
18
}
19

20
Poloidal::Poloidal(CkMigrateMessage* msg) : InitialMagneticField(msg) {}
1✔
21

22
void Poloidal::pup(PUP::er& p) {
9✔
23
  InitialMagneticField::pup(p);
9✔
24
  p | pressure_exponent_;
9✔
25
  p | cutoff_pressure_;
9✔
26
  p | vector_potential_amplitude_;
9✔
27
}
9✔
28

29
// NOLINTNEXTLINE
30
PUP::able::PUP_ID Poloidal::my_PUP_ID = 0;
31

32
Poloidal::Poloidal(const size_t pressure_exponent, const double cutoff_pressure,
10✔
33
                   const double vector_potential_amplitude)
10✔
34
    : pressure_exponent_(pressure_exponent),
35
      cutoff_pressure_(cutoff_pressure),
36
      vector_potential_amplitude_(vector_potential_amplitude) {}
10✔
37

38
template <typename DataType>
39
tuples::TaggedTuple<hydro::Tags::MagneticField<DataType, 3>>
40
Poloidal::variables(const tnsr::I<DataType, 3>& coords,
3✔
41
                    const Scalar<DataType>& pressure,
42
                    const Scalar<DataType>& sqrt_det_spatial_metric,
43
                    const tnsr::i<DataType, 3>& dcoords_pressure) const {
44
  auto magnetic_field = make_with_value<tnsr::I<DataType, 3>>(coords, 0.0);
8✔
45
  const size_t num_pts = get_size(get(pressure));
3✔
46

47
  for (size_t i = 0; i < num_pts; ++i) {
254✔
48
    const double pressure_i = get_element(get(pressure), i);
251✔
49
    if (pressure_i < cutoff_pressure_) {
251✔
50
      get_element(magnetic_field.get(0), i) = 0.0;
×
51
      get_element(magnetic_field.get(1), i) = 0.0;
×
52
      get_element(magnetic_field.get(2), i) = 0.0;
×
53
      continue;
×
54
    }
55

56
    // (p - p_c)^{n_s}
57
    const double pressure_term =
58
        pow(pressure_i - cutoff_pressure_, pressure_exponent_);
251✔
59
    // n_s * (p - p_c)^{n_s-1}
60
    const double n_times_pressure_to_n_minus_1 =
251✔
61
        pressure_exponent_ * pow(pressure_i - cutoff_pressure_,
251✔
62
                                 static_cast<int>(pressure_exponent_) - 1);
251✔
63

64
    const double x = get_element(coords.get(0), i);
251✔
65
    const double y = get_element(coords.get(1), i);
251✔
66

67
    const auto& dp_dx = get_element(dcoords_pressure.get(0), i);
251✔
68
    const auto& dp_dy = get_element(dcoords_pressure.get(1), i);
251✔
69
    const auto& dp_dz = get_element(dcoords_pressure.get(2), i);
251✔
70

71
    // Assign Bx, By, Bz
72
    get_element(magnetic_field.get(0), i) =
251✔
73
        -n_times_pressure_to_n_minus_1 * x * dp_dz;
251✔
74
    get_element(magnetic_field.get(1), i) =
251✔
75
        -n_times_pressure_to_n_minus_1 * y * dp_dz;
251✔
76
    get_element(magnetic_field.get(2), i) =
502✔
77
        2.0 * pressure_term +
251✔
78
        n_times_pressure_to_n_minus_1 * (x * dp_dx + y * dp_dy);
251✔
79
  }
80

81
  for (size_t d = 0; d < 3; ++d) {
12✔
82
    magnetic_field.get(d) *=
9✔
83
        vector_potential_amplitude_ / get(sqrt_det_spatial_metric);
18✔
84
  }
85

86
  return {std::move(magnetic_field)};
6✔
87
}
88

89
bool operator==(const Poloidal& lhs, const Poloidal& rhs) {
9✔
90
  return lhs.pressure_exponent_ == rhs.pressure_exponent_ and
17✔
91
         lhs.cutoff_pressure_ == rhs.cutoff_pressure_ and
16✔
92
         lhs.vector_potential_amplitude_ == rhs.vector_potential_amplitude_;
16✔
93
}
94

95
bool operator!=(const Poloidal& lhs, const Poloidal& rhs) {
4✔
96
  return not(lhs == rhs);
4✔
97
}
98

99
#define DTYPE(data) BOOST_PP_TUPLE_ELEM(0, data)
100

101
#define INSTANTIATE(_, data)                                               \
102
  template tuples::TaggedTuple<hydro::Tags::MagneticField<DTYPE(data), 3>> \
103
  Poloidal::variables<DTYPE(data)>(                                        \
104
      const tnsr::I<DTYPE(data), 3>& coords,                               \
105
      const Scalar<DTYPE(data)>& pressure,                                 \
106
      const Scalar<DTYPE(data)>& sqrt_det_spatial_metric,                  \
107
      const tnsr::i<DTYPE(data), 3>& dcoords_pressure) const;
108

109
GENERATE_INSTANTIATIONS(INSTANTIATE, (double, DataVector))
110

111
#undef INSTANTIATE
112
#undef DTYPE
113

114
}  // namespace grmhd::AnalyticData::InitialMagneticFields
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