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