Line data Source code
1 1 : // Distributed under the MIT License. 2 : // See LICENSE.txt for details. 3 : 4 : /// \file 5 : /// Defines class DormandPrince5. 6 : 7 : #pragma once 8 : 9 : #include <cstddef> 10 : 11 : #include "Options/String.hpp" 12 : #include "Time/TimeSteppers/RungeKutta.hpp" 13 : #include "Utilities/Serialization/CharmPupable.hpp" 14 : #include "Utilities/TMPL.hpp" 15 : 16 : namespace TimeSteppers { 17 : 18 : /*! 19 : * \ingroup TimeSteppersGroup 20 : * 21 : * The standard 5th-order Dormand-Prince time stepping method, given e.g. in 22 : * Sec. 17.2 of \cite NumericalRecipes. 23 : * 24 : * \f{eqnarray}{ 25 : * \frac{du}{dt} & = & \mathcal{L}(t,u). 26 : * \f} 27 : * Given a solution \f$u(t^n)=u^n\f$, this stepper computes 28 : * \f$u(t^{n+1})=u^{n+1}\f$ using the following equations: 29 : * 30 : * \f{align}{ 31 : * k^{(1)} & = dt \mathcal{L}(t^n, u^n),\\ 32 : * k^{(i)} & = dt \mathcal{L}(t^n + c_i dt, 33 : * u^n + \sum_{j=1}^{i-1} a_{ij} k^{(j)}), 34 : * \mbox{ } 2 \leq i \leq 6,\\ 35 : * u^{n+1} & = u^n + \sum_{i=1}^{6} b_i k^{(i)}. 36 : * \f} 37 : * 38 : * Here the coefficients \f$a_{ij}\f$, \f$b_i\f$, and \f$c_i\f$ are given 39 : * in e.g. Sec. 17.2 of \cite NumericalRecipes. Note that \f$c_1 = 0\f$. 40 : * 41 : * The CFL factor/stable step size is 1.6532839463174733. 42 : */ 43 1 : class DormandPrince5 : public RungeKutta { 44 : public: 45 0 : using options = tmpl::list<>; 46 0 : static constexpr Options::String help = { 47 : "The standard Dormand-Prince 5th-order time stepper."}; 48 : 49 0 : DormandPrince5() = default; 50 0 : DormandPrince5(const DormandPrince5&) = default; 51 0 : DormandPrince5& operator=(const DormandPrince5&) = default; 52 0 : DormandPrince5(DormandPrince5&&) = default; 53 0 : DormandPrince5& operator=(DormandPrince5&&) = default; 54 0 : ~DormandPrince5() override = default; 55 : 56 1 : size_t order() const override; 57 : 58 1 : double stable_step() const override; 59 : 60 0 : WRAPPED_PUPable_decl_template(DormandPrince5); // NOLINT 61 : 62 0 : explicit DormandPrince5(CkMigrateMessage* /*unused*/) {} 63 : 64 0 : const ButcherTableau& butcher_tableau() const override; 65 : }; 66 : 67 0 : inline bool constexpr operator==(const DormandPrince5& /*lhs*/, 68 : const DormandPrince5& /*rhs*/) { 69 : return true; 70 : } 71 : 72 0 : inline bool constexpr operator!=(const DormandPrince5& /*lhs*/, 73 : const DormandPrince5& /*rhs*/) { 74 : return false; 75 : } 76 : } // namespace TimeSteppers