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

sxs-collaboration / spectre / 4159437668

pending completion
4159437668

push

github

GitHub
Merge pull request #4719 from nikwit/add-abbuting-direction-per-element

12 of 12 new or added lines in 1 file covered. (100.0%)

63326 of 66021 relevant lines covered (95.92%)

406640.27 hits per line

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

97.06
/src/Domain/Structure/ExcisionSphere.cpp
1
// Distributed under the MIT License.
2
// See LICENSE.txt for details.
3

4
#include "Domain/Structure/ExcisionSphere.hpp"
5

6
#include <cstddef>
7
#include <optional>
8
#include <ostream>
9
#include <pup.h>  // IWYU pragma: keep
10
#include <pup_stl.h>
11
#include <unordered_map>
12

13
#include "Domain/Structure/Direction.hpp"
14
#include "Domain/Structure/ElementId.hpp"
15
#include "Utilities/ConstantExpressions.hpp"
16
#include "Utilities/ErrorHandling/Assert.hpp"
17
#include "Utilities/GenerateInstantiations.hpp"
18
#include "Utilities/StdHelpers.hpp"  // IWYU pragma: keep
19

20
template <size_t VolumeDim>
21
ExcisionSphere<VolumeDim>::ExcisionSphere(
434✔
22
    const double radius, const tnsr::I<double, VolumeDim, Frame::Grid> center,
23
    std::unordered_map<size_t, Direction<VolumeDim>> abutting_directions)
24
    : radius_(radius),
25
      center_(center),
26
      abutting_directions_(std::move(abutting_directions)) {
435✔
27
  ASSERT(radius_ > 0.0,
435✔
28
         "The ExcisionSphere must have a radius greater than zero.");
29
}
433✔
30

31
template <size_t VolumeDim>
32
std::optional<Direction<VolumeDim>>
33
ExcisionSphere<VolumeDim>::abutting_direction(
1,314✔
34
    const ElementId<VolumeDim>& element_id) const {
35
  const size_t block_id = element_id.block_id();
1,314✔
36
  if (abutting_directions_.count(block_id)) {
1,314✔
37
    const auto& direction = abutting_directions_.at(block_id);
876✔
38
    const auto& segment_id = element_id.segment_id(direction.dimension());
876✔
39
    const size_t abutting_index =
876✔
40
        direction.side() == Side::Lower
876✔
41
            ? 0
876✔
42
            : two_to_the(segment_id.refinement_level()) - 1;
×
43
    if (segment_id.index() == abutting_index) {
876✔
44
      return direction;
252✔
45
    }
46
  }
47
  return std::nullopt;
1,062✔
48
}
49

50
template <size_t VolumeDim>
51
void ExcisionSphere<VolumeDim>::pup(PUP::er& p) {
977✔
52
  size_t version = 0;
977✔
53
  p | version;
977✔
54
  // Remember to increment the version number when making changes to this
55
  // function. Retain support for unpacking data written by previous versions
56
  // whenever possible.
57
  if (version >= 0) {
58
    p | radius_;
977✔
59
    p | center_;
977✔
60
    p | abutting_directions_;
977✔
61
  }
62
}
977✔
63

64
template <size_t VolumeDim>
65
bool operator==(const ExcisionSphere<VolumeDim>& lhs,
234✔
66
                const ExcisionSphere<VolumeDim>& rhs) {
67
  return lhs.radius() == rhs.radius() and lhs.center() == rhs.center() and
462✔
68
         lhs.abutting_directions() == rhs.abutting_directions();
462✔
69
}
70

71
template <size_t VolumeDim>
72
bool operator!=(const ExcisionSphere<VolumeDim>& lhs,
6✔
73
                const ExcisionSphere<VolumeDim>& rhs) {
74
  return not(lhs == rhs);
6✔
75
}
76

77
template <size_t VolumeDim>
78
std::ostream& operator<<(std::ostream& os,
3✔
79
                         const ExcisionSphere<VolumeDim>& sphere) {
80
  os << "ExcisionSphere:\n";
3✔
81
  os << "  Radius: " << sphere.radius() << "\n";
3✔
82
  os << "  Center: " << sphere.center() << "\n";
3✔
83
  os << "  Abutting directions: " << sphere.abutting_directions() << "\n";
3✔
84
  return os;
3✔
85
}
86

87
#define GET_DIM(data) BOOST_PP_TUPLE_ELEM(0, data)
88

89
#define INSTANTIATION(r, data)                                    \
90
  template class ExcisionSphere<GET_DIM(data)>;                   \
91
  template bool operator==(const ExcisionSphere<GET_DIM(data)>&,  \
92
                           const ExcisionSphere<GET_DIM(data)>&); \
93
  template bool operator!=(const ExcisionSphere<GET_DIM(data)>&,  \
94
                           const ExcisionSphere<GET_DIM(data)>&); \
95
  template std::ostream& operator<<(std::ostream&,                \
96
                                    const ExcisionSphere<GET_DIM(data)>&);
97

98
GENERATE_INSTANTIATIONS(INSTANTIATION, (1, 2, 3))
99

100
#undef GET_DIM
101
#undef INSTANTIATION
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