Increase.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
6 #include <cmath>
7 #include <limits>
8 #include <pup.h>
9 
10 #include "Options/Options.hpp"
12 #include "Time/StepChoosers/StepChooser.hpp" // IWYU pragma: keep
13 #include "Time/Time.hpp"
14 #include "Utilities/Registration.hpp"
15 #include "Utilities/TMPL.hpp"
16 
17 /// \cond
18 namespace Parallel {
19 template <typename Metavariables>
20 class ConstGlobalCache;
21 } // namespace Parallel
22 namespace Tags {
23 struct TimeStep;
24 } // namespace Tags
25 /// \endcond
26 
27 namespace StepChoosers {
28 template <typename StepChooserRegistrars>
29 class Increase;
30 
31 namespace Registrars {
33 } // namespace Registrars
34 
35 /// Suggests increasing the step size by a constant ratio.
36 template <typename StepChooserRegistrars = tmpl::list<Registrars::Increase>>
37 class Increase : public StepChooser<StepChooserRegistrars> {
38  public:
39  /// \cond
40  Increase() = default;
41  explicit Increase(CkMigrateMessage* /*unused*/) noexcept {}
42  using PUP::able::register_constructor;
44  /// \endcond
45 
46  struct Factor {
47  using type = double;
48  static constexpr OptionString help{"Factor to increase by"};
49  static type lower_bound() noexcept { return 1.0; }
50  };
51 
52  static constexpr OptionString help{"Suggests a constant factor increase."};
53  using options = tmpl::list<Factor>;
54 
55  explicit Increase(const double factor) noexcept : factor_(factor) {}
56 
57  using argument_tags = tmpl::list<Tags::TimeStep>;
58 
59  template <typename Metavariables>
60  double operator()(const TimeDelta& current_step,
62  const noexcept {
63  return std::abs(current_step.value()) * factor_;
64  }
65 
66  // NOLINTNEXTLINE(google-runtime-references)
67  void pup(PUP::er& p) noexcept override { p | factor_; }
68 
69  private:
71 };
72 
73 /// \cond
74 template <typename StepChooserRegistrars>
75 PUP::able::PUP_ID Increase<StepChooserRegistrars>::my_PUP_ID = 0; // NOLINT
76 /// \endcond
77 } // namespace StepChoosers
T signaling_NaN(T... args)
Defines classes and functions for making classes creatable from input files.
Defines macros to allow serialization of abstract template base classes.
Contains functions that forward to Charm++ parallel functions.
Definition: Abort.hpp:13
#define WRAPPED_PUPable_decl_template(className)
Mark derived classes as serializable.
Definition: CharmPupable.hpp:22
Defines Time and TimeDelta.
StepChoosers suggest upper bounds on step sizes. Concrete StepChoosers should define operator() retur...
Definition: StepChooser.hpp:45
const char *const OptionString
The string used in option structs.
Definition: Options.hpp:26
Represents an interval of time within a single slab.
Definition: Time.hpp:108
A template for defining a registrar.
Definition: Registration.hpp:42
Definition: DataBoxTag.hpp:29
A Charm++ chare that caches constant data once per Charm++ node.
Definition: ConstGlobalCache.hpp:76
Definition: Increase.hpp:46
Wraps the template metaprogramming library used (brigand)
Suggests increasing the step size by a constant ratio.
Definition: Increase.hpp:29
double value() const noexcept
Approximate numerical length of the interval.
Definition: Time.hpp:131
Holds all the StepChoosers.
Definition: Cfl.hpp:25