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