Line data Source code
1 0 : // Distributed under the MIT License.
2 : // See LICENSE.txt for details.
3 :
4 : #pragma once
5 :
6 : #include <limits>
7 :
8 : #include "Options/Options.hpp"
9 : #include "Options/String.hpp"
10 : #include "Time/StepChoosers/StepChooser.hpp"
11 : #include "Time/TimeStepRequest.hpp"
12 : #include "Utilities/Serialization/CharmPupable.hpp"
13 : #include "Utilities/TMPL.hpp"
14 :
15 : /// \cond
16 : namespace PUP {
17 : class er;
18 : } // namespace PUP
19 : /// \endcond
20 :
21 : namespace StepChoosers {
22 :
23 : /// Limits the step size to a constant.
24 1 : class Maximum : public StepChooser<StepChooserUse::Slab>,
25 : public StepChooser<StepChooserUse::LtsStep> {
26 : public:
27 : /// \cond
28 : Maximum() = default;
29 : explicit Maximum(CkMigrateMessage* /*unused*/) {}
30 : using PUP::able::register_constructor;
31 : WRAPPED_PUPable_decl_template(Maximum); // NOLINT
32 : /// \endcond
33 :
34 0 : static constexpr Options::String help{"Limits the step size to a constant."};
35 :
36 0 : explicit Maximum(double value);
37 :
38 0 : using argument_tags = tmpl::list<>;
39 :
40 0 : TimeStepRequest operator()(double last_step) const;
41 :
42 1 : bool uses_local_data() const override;
43 1 : bool can_be_delayed() const override;
44 1 : bool must_set_step_size() const override;
45 :
46 : // NOLINTNEXTLINE(google-runtime-references)
47 0 : void pup(PUP::er& p) override;
48 :
49 : private:
50 0 : double value_ = std::numeric_limits<double>::signaling_NaN();
51 : };
52 : } // namespace StepChoosers
53 :
54 : template <>
55 0 : struct Options::create_from_yaml<StepChoosers::Maximum> {
56 : template <typename Metavariables>
57 0 : static StepChoosers::Maximum create(const Options::Option& options) {
58 : return create<void>(options);
59 : }
60 : };
61 :
62 : template <>
63 0 : StepChoosers::Maximum
64 : Options::create_from_yaml<StepChoosers::Maximum>::create<void>(
65 : const Options::Option& options);
|