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 <cstdint> 8 : #include <optional> 9 : 10 : #include "DataStructures/TaggedVariant.hpp" 11 : #include "Options/String.hpp" 12 : #include "Time/StepperErrorEstimate.hpp" 13 : #include "Time/TimeStepId.hpp" 14 : #include "Time/TimeSteppers/TimeStepper.hpp" 15 : #include "Utilities/Gsl.hpp" 16 : #include "Utilities/Serialization/CharmPupable.hpp" 17 : #include "Utilities/TMPL.hpp" 18 : 19 : /// \cond 20 : struct StepperErrorTolerances; 21 : class TimeDelta; 22 : namespace TimeSteppers { 23 : template <typename T> 24 : class ConstUntypedHistory; 25 : template <typename T> 26 : class MutableUntypedHistory; 27 : } // namespace TimeSteppers 28 : /// \endcond 29 : 30 : namespace TimeSteppers { 31 : 32 : /// \ingroup TimeSteppersGroup 33 : /// 34 : /// A "strong stability-preserving" 3rd-order Runge-Kutta 35 : /// time-stepper, as described in \cite HesthavenWarburton section 36 : /// 5.7. 37 : /// 38 : /// The CFL factor/stable step size is 1.25637266330916. 39 : /// 40 : /// \note The time stepper is only strong-stability-preserving for 41 : /// time steps not exceeding 1.0, i.e., slightly less than 0.8 times 42 : /// the stable step. 43 1 : class Rk3HesthavenSsp : public TimeStepper { 44 : public: 45 0 : using options = tmpl::list<>; 46 0 : static constexpr Options::String help = { 47 : "A third-order strong stability-preserving Runge-Kutta time-stepper."}; 48 : 49 0 : Rk3HesthavenSsp() = default; 50 0 : Rk3HesthavenSsp(const Rk3HesthavenSsp&) = default; 51 0 : Rk3HesthavenSsp& operator=(const Rk3HesthavenSsp&) = default; 52 0 : Rk3HesthavenSsp(Rk3HesthavenSsp&&) = default; 53 0 : Rk3HesthavenSsp& operator=(Rk3HesthavenSsp&&) = default; 54 0 : ~Rk3HesthavenSsp() override = default; 55 : 56 0 : WRAPPED_PUPable_decl_template(Rk3HesthavenSsp); // NOLINT 57 : 58 0 : explicit Rk3HesthavenSsp(CkMigrateMessage* /*unused*/) {} 59 : 60 1 : variants::TaggedVariant<Tags::FixedOrder, Tags::VariableOrder> order() 61 : const override; 62 : 63 1 : double stable_step() const override; 64 : 65 1 : bool monotonic() const override; 66 : 67 1 : uint64_t number_of_substeps() const override; 68 : 69 1 : uint64_t number_of_substeps_for_error() const override; 70 : 71 1 : size_t number_of_past_steps() const override; 72 : 73 1 : TimeStepId next_time_id(const TimeStepId& current_id, 74 : const TimeDelta& time_step) const override; 75 : 76 1 : TimeStepId next_time_id_for_error(const TimeStepId& current_id, 77 : const TimeDelta& time_step) const override; 78 : 79 : private: 80 : template <typename T> 81 0 : void update_u_impl(gsl::not_null<T*> u, const ConstUntypedHistory<T>& history, 82 : const TimeDelta& time_step) const; 83 : 84 : template <typename T> 85 0 : std::optional<StepperErrorEstimate> update_u_impl( 86 : gsl::not_null<T*> u, const ConstUntypedHistory<T>& history, 87 : const TimeDelta& time_step, 88 : const std::optional<StepperErrorTolerances>& tolerances) const; 89 : 90 : template <typename T> 91 0 : void clean_history_impl(const MutableUntypedHistory<T>& history) const; 92 : 93 : template <typename T> 94 0 : bool dense_update_u_impl(gsl::not_null<T*> u, 95 : const ConstUntypedHistory<T>& history, 96 : double time) const; 97 : 98 : template <typename T> 99 0 : bool can_change_step_size_impl(const TimeStepId& time_id, 100 : const ConstUntypedHistory<T>& history) const; 101 : 102 : TIME_STEPPER_DECLARE_OVERLOADS 103 : }; 104 : 105 0 : inline bool constexpr operator==(const Rk3HesthavenSsp& /*lhs*/, 106 : const Rk3HesthavenSsp& /*rhs*/) { 107 : return true; 108 : } 109 : 110 0 : inline bool constexpr operator!=(const Rk3HesthavenSsp& /*lhs*/, 111 : const Rk3HesthavenSsp& /*rhs*/) { 112 : return false; 113 : } 114 : } // namespace TimeSteppers