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 : /// Sets a constant goal. 24 1 : class Constant : public StepChooser<StepChooserUse::Slab>, 25 : public StepChooser<StepChooserUse::LtsStep> { 26 : public: 27 : /// \cond 28 : Constant() = default; 29 : explicit Constant(CkMigrateMessage* /*unused*/) {} 30 : using PUP::able::register_constructor; 31 : WRAPPED_PUPable_decl_template(Constant); // NOLINT 32 : /// \endcond 33 : 34 0 : static constexpr Options::String help{"Sets a constant goal."}; 35 : 36 0 : explicit Constant(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 : 45 : // NOLINTNEXTLINE(google-runtime-references) 46 0 : void pup(PUP::er& p) override; 47 : 48 : private: 49 0 : double value_ = std::numeric_limits<double>::signaling_NaN(); 50 : }; 51 : } // namespace StepChoosers 52 : 53 : template <> 54 0 : struct Options::create_from_yaml<StepChoosers::Constant> { 55 : template <typename Metavariables> 56 0 : static StepChoosers::Constant create(const Options::Option& options) { 57 : return create<void>(options); 58 : } 59 : }; 60 : 61 : template <> 62 0 : StepChoosers::Constant 63 : Options::create_from_yaml<StepChoosers::Constant>::create<void>( 64 : const Options::Option& options);