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/StepperErrorTolerances.hpp"
14 : #include "Time/TimeStepId.hpp"
15 : #include "Time/TimeSteppers/TimeStepper.hpp"
16 : #include "Utilities/Gsl.hpp"
17 : #include "Utilities/Serialization/CharmPupable.hpp"
18 : #include "Utilities/TMPL.hpp"
19 :
20 : /// \cond
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 : bool dense_output_uses_fsal() const override;
68 :
69 1 : uint64_t number_of_substeps() const override;
70 :
71 1 : uint64_t number_of_substeps_for_error() const override;
72 :
73 1 : size_t number_of_past_steps() const override;
74 :
75 1 : TimeStepId next_time_id(const TimeStepId& current_id,
76 : const TimeDelta& time_step) const override;
77 :
78 1 : TimeStepId next_time_id_for_error(const TimeStepId& current_id,
79 : const TimeDelta& time_step) const override;
80 :
81 : private:
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 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
|