Line data Source code
1 0 : // Distributed under the MIT License.
2 : // See LICENSE.txt for details.
3 :
4 : #pragma once
5 :
6 : #include <cstddef>
7 : #include <vector>
8 :
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 : template <size_t VolumeDim>
17 : class Element;
18 : namespace domain {
19 : namespace Tags {
20 : template <size_t VolumeDim>
21 : struct Element;
22 : } // namespace Tags
23 : } // namespace domain
24 : namespace PUP {
25 : class er;
26 : } // namespace PUP
27 : /// \endcond
28 :
29 1 : namespace StepChoosers {
30 : /// Sets a goal specified per-block.
31 : /// \note This StepChooser is for debugging.
32 : template <size_t Dim>
33 1 : class ByBlock : public StepChooser<StepChooserUse::Slab>,
34 : public StepChooser<StepChooserUse::LtsStep> {
35 : public:
36 : /// \cond
37 : ByBlock() = default;
38 : explicit ByBlock(CkMigrateMessage* /*unused*/) {}
39 : using PUP::able::register_constructor;
40 : WRAPPED_PUPable_decl_template(ByBlock); // NOLINT
41 : /// \endcond
42 :
43 0 : struct Sizes {
44 0 : using type = std::vector<double>;
45 0 : static constexpr Options::String help{
46 : "Step sizes, indexed by block number"};
47 : };
48 :
49 0 : static constexpr Options::String help{"Sets a goal specified per-block."};
50 0 : using options = tmpl::list<Sizes>;
51 :
52 0 : explicit ByBlock(std::vector<double> sizes);
53 :
54 0 : using argument_tags = tmpl::list<domain::Tags::Element<Dim>>;
55 :
56 0 : TimeStepRequest operator()(const Element<Dim>& element,
57 : double last_step) const;
58 :
59 1 : bool uses_local_data() const override;
60 1 : bool can_be_delayed() const override;
61 1 : bool must_set_step_size() const override;
62 :
63 : // NOLINTNEXTLINE(google-runtime-references)
64 0 : void pup(PUP::er& p) override;
65 :
66 : private:
67 0 : std::vector<double> sizes_;
68 : };
69 : } // namespace StepChoosers
|