Periodic.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
6 #include <memory>
7 #include <pup.h>
8 
9 #include "Domain/BoundaryConditions/BoundaryCondition.hpp"
10 #include "Options/Options.hpp"
12 #include "Utilities/TMPL.hpp"
13 
15 /// Mark a boundary condition as being periodic.
16 ///
17 /// Periodic boundary conditions shouldn't require any implementation outside of
18 /// a check in the domain creator using the `is_periodic()` function to
19 /// determine what boundaries are periodic. Across each matching pair of
20 /// periodic boundary conditions, the domain creator should specify that the DG
21 /// elements are neighbors of each other.
23  public:
24  MarkAsPeriodic() = default;
25  MarkAsPeriodic(MarkAsPeriodic&&) noexcept = default;
26  MarkAsPeriodic& operator=(MarkAsPeriodic&&) noexcept = default;
27  MarkAsPeriodic(const MarkAsPeriodic&) = default;
28  MarkAsPeriodic& operator=(const MarkAsPeriodic&) = default;
29  virtual ~MarkAsPeriodic() = 0;
30 };
31 
32 /*!
33  * \brief Periodic boundary conditions.
34  *
35  * To use with a specific system add:
36  *
37  * \code
38  * domain::BoundaryConditions::Periodic<your::system::BoundaryConditionBase>
39  * \endcode
40  *
41  * to the list of creatable classes.
42  *
43  * \note Not all domain creators will allow you to specify periodic boundary
44  * conditions since they may not make sense.
45  */
46 template <typename SystemBoundaryConditionBaseClass>
47 struct Periodic final : public SystemBoundaryConditionBaseClass,
48  public MarkAsPeriodic {
49  public:
50  using options = tmpl::list<>;
51  static constexpr Options::String help{
52  "Periodic boundary conditions.\n\nNote: Not all domain creators will "
53  "allow you to specify periodic boundary conditions since they may not "
54  "make sense."};
55  static std::string name() noexcept { return "Periodic"; }
56 
57  Periodic() = default;
58  Periodic(Periodic&&) noexcept = default;
59  Periodic& operator=(Periodic&&) noexcept = default;
60  Periodic(const Periodic&) = default;
61  Periodic& operator=(const Periodic&) = default;
62  ~Periodic() override = default;
63 
64  explicit Periodic(CkMigrateMessage* msg) noexcept;
65 
66  WRAPPED_PUPable_decl_base_template(
68 
69  auto get_clone() const noexcept -> std::unique_ptr<
71 
72  void pup(PUP::er& p) override;
73 };
74 
75 template <typename SystemBoundaryConditionBaseClass>
77  CkMigrateMessage* const msg) noexcept
78  : SystemBoundaryConditionBaseClass(msg) {}
79 
80 template <typename SystemBoundaryConditionBaseClass>
82 Periodic<SystemBoundaryConditionBaseClass>::get_clone() const noexcept {
83  return std::make_unique<Periodic>(*this);
84 }
85 
86 template <typename SystemBoundaryConditionBaseClass>
87 void Periodic<SystemBoundaryConditionBaseClass>::pup(PUP::er& p) {
88  BoundaryCondition::pup(p);
89 }
90 
91 /// \cond
92 template <typename SystemBoundaryConditionBaseClass>
93 // NOLINTNEXTLINE
94 PUP::able::PUP_ID Periodic<SystemBoundaryConditionBaseClass>::my_PUP_ID = 0;
95 /// \endcond
96 
97 /// Check if a boundary condition inherits from `MarkAsPeriodic`, which
98 /// constitutes as it being marked as a periodic boundary condition.
99 bool is_periodic(
100  const std::unique_ptr<BoundaryCondition>& boundary_condition) noexcept;
101 } // namespace domain::BoundaryConditions
std::string
CharmPupable.hpp
domain::BoundaryConditions::BoundaryCondition
Base class from which all system-specific base classes must inherit.
Definition: BoundaryCondition.hpp:18
Options.hpp
domain::BoundaryConditions::Periodic
Periodic boundary conditions.
Definition: Periodic.hpp:47
domain::BoundaryConditions
Domain support for applying boundary conditions
Definition: BoundaryCondition.hpp:14
memory
Options::String
const char *const String
The string used in option structs.
Definition: Options.hpp:32
domain::BoundaryConditions::MarkAsPeriodic
Mark a boundary condition as being periodic.
Definition: Periodic.hpp:22
domain::BoundaryConditions::is_periodic
bool is_periodic(const std::unique_ptr< BoundaryCondition > &boundary_condition) noexcept
Check if a boundary condition inherits from MarkAsPeriodic, which constitutes as it being marked as a...
Definition: Periodic.cpp:9
std::unique_ptr
TMPL.hpp