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 : 8 : #include "Options/String.hpp" 9 : #include "Time/TimeSteppers/RungeKutta.hpp" 10 : #include "Utilities/Serialization/CharmPupable.hpp" 11 : #include "Utilities/TMPL.hpp" 12 : 13 : namespace TimeSteppers { 14 : /*! 15 : * \ingroup TimeSteppersGroup 16 : * \brief A second order continuous-extension RK method that provides 2nd-order 17 : * dense output. 18 : * 19 : * \f{eqnarray}{ 20 : * \frac{du}{dt} & = & \mathcal{L}(t,u). 21 : * \f} 22 : * Given a solution \f$u(t^n)=u^n\f$, this stepper computes 23 : * \f$u(t^{n+1})=u^{n+1}\f$ using the following equations: 24 : * 25 : * \f{align}{ 26 : * k^{(i)} & = \mathcal{L}(t^n + c_i \Delta t, 27 : * u^n + \Delta t \sum_{j=1}^{i-1} a_{ij} k^{(j)}), 28 : * \mbox{ } 1 \leq i \leq s,\\ 29 : * u^{n+1}(t^n + \theta \Delta t) & = u^n + \Delta t \sum_{i=1}^{s} b_i(\theta) 30 : * k^{(i)}. \f} 31 : * 32 : * Here the coefficients \f$a_{ij}\f$, \f$b_i\f$, and \f$c_i\f$ are given 33 : * in \cite Gassner20114232. Note that \f$c_1 = 0\f$, \f$s\f$ is the number 34 : * of stages, and \f$\theta\f$ is the fraction of the step. 35 : * 36 : * The CFL factor/stable step size is 1.0. 37 : */ 38 1 : class Heun2 : public RungeKutta { 39 : public: 40 0 : using options = tmpl::list<>; 41 0 : static constexpr Options::String help = { 42 : "Heun's method, a 2nd order Runge-Kutta method."}; 43 : 44 0 : Heun2() = default; 45 0 : Heun2(const Heun2&) = default; 46 0 : Heun2& operator=(const Heun2&) = default; 47 0 : Heun2(Heun2&&) = default; 48 0 : Heun2& operator=(Heun2&&) = default; 49 0 : ~Heun2() override = default; 50 : 51 1 : size_t order() const override; 52 : 53 1 : size_t error_estimate_order() const override; 54 : 55 1 : double stable_step() const override; 56 : 57 0 : WRAPPED_PUPable_decl_template(Heun2); // NOLINT 58 : 59 0 : explicit Heun2(CkMigrateMessage* /*unused*/) {} 60 : 61 0 : const ButcherTableau& butcher_tableau() const override; 62 : }; 63 : 64 0 : inline bool constexpr operator==(const Heun2& /*lhs*/, const Heun2& /*rhs*/) { 65 : return true; 66 : } 67 : 68 0 : inline bool constexpr operator!=(const Heun2& /*lhs*/, const Heun2& /*rhs*/) { 69 : return false; 70 : } 71 : } // namespace TimeSteppers