Line data Source code
1 0 : // Distributed under the MIT License.
2 : // See LICENSE.txt for details.
3 :
4 : #pragma once
5 :
6 : #include <memory>
7 :
8 : #include "Options/String.hpp"
9 : #include "Time/StepChoosers/StepChooser.hpp"
10 : #include "Time/TimeSequence.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 : namespace Tags {
20 : struct Time;
21 : } // namespace Tags
22 : /// \endcond
23 :
24 : namespace StepChoosers {
25 : /// Suggests step sizes to place steps at specific times.
26 : ///
27 : /// The suggestion provided depends on the current time, so it should
28 : /// be applied immediately, rather than delayed several slabs.
29 1 : class StepToTimes : public StepChooser<StepChooserUse::Slab> {
30 : public:
31 : /// \cond
32 : StepToTimes() = default;
33 : explicit StepToTimes(CkMigrateMessage* /*unused*/) {}
34 : using PUP::able::register_constructor;
35 : WRAPPED_PUPable_decl_template(StepToTimes); // NOLINT
36 : /// \endcond
37 :
38 0 : struct Times {
39 0 : using type = std::unique_ptr<TimeSequence<double>>;
40 0 : static constexpr Options::String help{"Times to force steps at"};
41 : };
42 :
43 0 : static constexpr Options::String help =
44 : "Suggests step sizes to place steps at specific times.\n"
45 : "\n"
46 : "The suggestion provided depends on the current time, so it should\n"
47 : "be applied immediately, rather than delayed several slabs.";
48 0 : using options = tmpl::list<Times>;
49 :
50 0 : explicit StepToTimes(std::unique_ptr<TimeSequence<double>> times);
51 :
52 0 : using argument_tags = tmpl::list<::Tags::Time>;
53 :
54 0 : TimeStepRequest operator()(double now, double last_step) const;
55 :
56 1 : bool uses_local_data() const override;
57 1 : bool can_be_delayed() const override;
58 1 : bool must_set_step_size() const override;
59 :
60 : // NOLINTNEXTLINE(google-runtime-references)
61 0 : void pup(PUP::er& p) override;
62 :
63 : private:
64 0 : std::unique_ptr<TimeSequence<double>> times_;
65 : };
66 : } // namespace StepChoosers
|