BoundaryCondition.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
6 #include <cstddef>
7 #include <memory>
8 #include <pup.h>
9 #include <string>
10 
11 #include "Domain/BoundaryConditions/BoundaryCondition.hpp"
12 #include "Domain/BoundaryConditions/None.hpp"
13 #include "Domain/BoundaryConditions/Periodic.hpp"
15 #include "Options/Options.hpp"
17 #include "Utilities/TMPL.hpp"
18 
19 /// \ingroup TestingFrameworkGroup
20 /// \brief Helpers for boundary conditions
22 /// \cond
23 template <size_t Dim>
25 /// \endcond
26 
27 /// \brief A system-specific boundary condition base class.
28 ///
29 /// To be used in conjunction with `SystemWithBoundaryConditions`
30 template <size_t Dim>
33  public:
34  using creatable_classes = tmpl::list<
38 
39  BoundaryConditionBase() = default;
40  BoundaryConditionBase(BoundaryConditionBase&&) noexcept = default;
41  BoundaryConditionBase& operator=(BoundaryConditionBase&&) noexcept = default;
43  BoundaryConditionBase& operator=(const BoundaryConditionBase&) = default;
44  ~BoundaryConditionBase() override = default;
45 
46  explicit BoundaryConditionBase(CkMigrateMessage* msg) noexcept;
47 
48  void pup(PUP::er& p) override;
49 
50  static constexpr Options::String help = {"Boundary conditions for tests."};
51 };
52 
53 /// \brief Concrete boundary condition
54 template <size_t Dim>
55 class TestBoundaryCondition final : public BoundaryConditionBase<Dim> {
56  public:
57  TestBoundaryCondition() = default;
58  explicit TestBoundaryCondition(Direction<Dim> direction, size_t block_id = 0);
59  TestBoundaryCondition(const std::string& direction, size_t block_id);
60  TestBoundaryCondition(TestBoundaryCondition&&) noexcept = default;
61  TestBoundaryCondition& operator=(TestBoundaryCondition&&) noexcept = default;
63  TestBoundaryCondition& operator=(const TestBoundaryCondition&) = default;
64  ~TestBoundaryCondition() override = default;
65  explicit TestBoundaryCondition(CkMigrateMessage* const msg) noexcept;
66 
68  using type = std::string;
69  static std::string name() noexcept { return "Direction"; }
70  static constexpr Options::String help =
71  "The direction the boundary condition operates in.";
72  };
74  using type = size_t;
75  static std::string name() noexcept { return "BlockId"; }
76  static constexpr Options::String help =
77  "The id of the block the boundary condition operates in.";
78  };
79 
80  using options = tmpl::list<DirectionOptionTag, BlockIdOptionTag>;
81 
82  static constexpr Options::String help = {"Boundary condition for testing."};
83 
84  WRAPPED_PUPable_decl_base_template(
87 
88  const Direction<Dim>& direction() const noexcept { return direction_; }
89  size_t block_id() const noexcept { return block_id_; }
90 
91  auto get_clone() const noexcept -> std::unique_ptr<
92  ::domain::BoundaryConditions::BoundaryCondition> override;
93 
94  void pup(PUP::er& p) override;
95 
96  private:
97  Direction<Dim> direction_{};
98  size_t block_id_{0};
99 };
100 
101 template <size_t Dim>
102 bool operator==(const TestBoundaryCondition<Dim>& lhs,
103  const TestBoundaryCondition<Dim>& rhs) noexcept;
104 
105 template <size_t Dim>
106 bool operator!=(const TestBoundaryCondition<Dim>& lhs,
107  const TestBoundaryCondition<Dim>& rhs) noexcept;
108 
109 template <size_t Dim>
110 using TestPeriodicBoundaryCondition =
112 
113 template <size_t Dim>
114 using TestNoneBoundaryCondition =
116 
117 /// Empty system that has boundary conditions
118 template <size_t Dim>
121 };
122 
123 /// Empty system that doesn't have boundary conditions
124 template <size_t Dim>
126 
127 /// Metavariables with a system that has boundary conditions
128 template <size_t Dim>
131 };
132 
133 /// Metavariables with a system that doesn't have boundary conditions
134 template <size_t Dim>
137 };
138 
139 void register_derived_with_charm() noexcept;
140 } // namespace TestHelpers::domain::BoundaryConditions
std::string
CharmPupable.hpp
domain::BoundaryConditions::BoundaryCondition
Base class from which all system-specific base classes must inherit.
Definition: BoundaryCondition.hpp:18
std::rel_ops::operator!=
T operator!=(T... args)
Options.hpp
domain::BoundaryConditions::Periodic
Periodic boundary conditions.
Definition: Periodic.hpp:47
TestHelpers::domain::BoundaryConditions::TestBoundaryCondition
Concrete boundary condition.
Definition: BoundaryCondition.hpp:55
Direction< Dim >
TestHelpers::domain::BoundaryConditions::TestBoundaryCondition::BlockIdOptionTag
Definition: BoundaryCondition.hpp:73
TestHelpers::domain::BoundaryConditions::MetavariablesWithBoundaryConditions
Metavariables with a system that has boundary conditions.
Definition: BoundaryCondition.hpp:129
TestHelpers::domain::BoundaryConditions::BoundaryConditionBase
A system-specific boundary condition base class.
Definition: BoundaryCondition.hpp:31
TestHelpers::domain::BoundaryConditions::SystemWithBoundaryConditions
Empty system that has boundary conditions.
Definition: BoundaryCondition.hpp:119
TestHelpers::domain::BoundaryConditions::MetavariablesWithoutBoundaryConditions
Metavariables with a system that doesn't have boundary conditions.
Definition: BoundaryCondition.hpp:135
cstddef
TestHelpers::domain::BoundaryConditions::TestBoundaryCondition::DirectionOptionTag
Definition: BoundaryCondition.hpp:67
domain::BoundaryConditions::None
None boundary conditions.
Definition: None.hpp:50
TestHelpers::domain::BoundaryConditions
Helpers for boundary conditions.
Definition: BoundaryCondition.hpp:21
memory
TestHelpers::domain::BoundaryConditions::SystemWithoutBoundaryConditions
Empty system that doesn't have boundary conditions.
Definition: BoundaryCondition.hpp:125
Options::String
const char *const String
The string used in option structs.
Definition: Options.hpp:32
Direction.hpp
TMPL.hpp
string