TestTrigger.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
7 
8 #include <pup.h>
9 #include <string>
10 
11 #include "DataStructures/DataBox/Tag.hpp"
12 #include "Evolution/EventsAndDenseTriggers/DenseTrigger.hpp"
13 #include "Options/Options.hpp"
15 #include "Utilities/TMPL.hpp"
16 
17 namespace TestHelpers::DenseTriggers {
18 class TestTrigger : public DenseTrigger {
19  public:
20  /// \cond
21  TestTrigger() = default;
22  explicit TestTrigger(CkMigrateMessage* const msg) noexcept
23  : DenseTrigger(msg) {}
24  using PUP::able::register_constructor;
26  /// \endcond
27 
28  struct IsReady {
29  using type = bool;
30  constexpr static Options::String help = "IsReady";
31  };
32 
33  struct IsTriggered {
34  using type = bool;
35  constexpr static Options::String help = "IsTriggered";
36  };
37 
38  struct NextCheck {
39  using type = double;
40  constexpr static Options::String help = "NextCheck";
41  };
42 
43  using options = tmpl::list<IsReady, IsTriggered, NextCheck>;
44  constexpr static Options::String help = "help";
45 
46  TestTrigger(const bool is_ready, const bool is_triggered,
47  const double next_check) noexcept
48  : is_ready_(is_ready),
49  is_triggered_(is_triggered),
50  next_check_(next_check) {}
51 
52  using is_triggered_argument_tags = tmpl::list<>;
53  Result is_triggered() const noexcept {
54  CHECK(is_ready_);
55  return {is_triggered_, next_check_};
56  }
57 
58  using is_ready_argument_tags = tmpl::list<>;
59  bool is_ready() const noexcept { return is_ready_; }
60 
61  // NOLINTNEXTLINE(google-runtime-references)
62  void pup(PUP::er& p) noexcept override {
63  DenseTrigger::pup(p);
64  p | is_ready_;
65  p | is_triggered_;
66  p | next_check_;
67  }
68 
69  private:
70  bool is_ready_;
71  bool is_triggered_;
72  double next_check_;
73 };
74 
75 template <typename Label>
76 class BoxTrigger : public DenseTrigger {
77  public:
78  /// \cond
79  BoxTrigger() = default;
80  explicit BoxTrigger(CkMigrateMessage* const msg) noexcept
81  : DenseTrigger(msg) {}
82  using PUP::able::register_constructor;
84  /// \endcond
85 
86  static std::string name() noexcept {
87  return "BoxTrigger<" + Options::name<Label>() + ">";
88  }
89 
90  using options = tmpl::list<>;
91  constexpr static Options::String help = "help";
92 
94  using type = bool;
95  };
96 
98  using type = double;
99  };
100 
102  using type = bool;
103  };
104 
105  using is_triggered_argument_tags =
106  tmpl::list<IsReady, IsTriggered, NextCheck>;
107  Result is_triggered(const bool is_ready, const bool is_triggered,
108  const double next_check) const noexcept {
109  CHECK(is_ready);
110  return {is_triggered, next_check};
111  }
112 
113  using is_ready_argument_tags = tmpl::list<IsReady>;
114  bool is_ready(const bool is_ready) const noexcept { return is_ready; }
115 };
116 
117 /// \cond
118 template <typename Label>
119 PUP::able::PUP_ID BoxTrigger<Label>::my_PUP_ID = 0; // NOLINT
120 /// \endcond
121 } // namespace TestHelpers::DenseTriggers
std::string
CharmPupable.hpp
TestHelpers::DenseTriggers::BoxTrigger
Definition: TestTrigger.hpp:76
Options.hpp
TestHelpers::DenseTriggers::TestTrigger
Definition: TestTrigger.hpp:18
TestingFramework.hpp
TestHelpers::DenseTriggers::BoxTrigger::IsReady
Definition: TestTrigger.hpp:101
TestHelpers::DenseTriggers::TestTrigger::IsTriggered
Definition: TestTrigger.hpp:33
db::SimpleTag
Mark a struct as a simple tag by inheriting from this.
Definition: Tag.hpp:36
DenseTrigger
Definition: DenseTrigger.hpp:27
TestHelpers::DenseTriggers::TestTrigger::IsReady
Definition: TestTrigger.hpp:28
WRAPPED_PUPable_decl_template
#define WRAPPED_PUPable_decl_template(className)
Mark derived classes as serializable.
Definition: CharmPupable.hpp:22
TestHelpers::DenseTriggers::BoxTrigger::IsTriggered
Definition: TestTrigger.hpp:93
DenseTrigger::Result
Result type for the is_triggered method.
Definition: DenseTrigger.hpp:34
Options::String
const char *const String
The string used in option structs.
Definition: Options.hpp:32
TestHelpers::DenseTriggers::BoxTrigger::NextCheck
Definition: TestTrigger.hpp:97
TestHelpers::DenseTriggers::TestTrigger::NextCheck
Definition: TestTrigger.hpp:38
TMPL.hpp
string