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