RKDP45.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2013-2016 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::RKDP45
26 
27 Description
28  4/5th Order Dormand–Prince Runge-Kutta ODE solver.
29 
30  References:
31  \verbatim
32  "A family of embedded Runge-Kutta formulae"
33  Dormand, J. R.,
34  Prince, P. J.,
35  Journal of Computational and Applied Mathematics,
36  6 (1), 1980: pp. 19-26.
37 
38  "Solving Ordinary Differential Equations I: Nonstiff Problems,
39  second edition",
40  Hairer, E.,
41  Nørsett, S.,
42  Wanner, G.,
43  Springer-Verlag, Berlin. 1993, ISBN 3-540-56670-8.
44  \endverbatim
45 
46 See also
47  Foam::RKF45
48  Foam::RKCK45
49 
50 SourceFiles
51  RKDP45.C
52 
53 \*---------------------------------------------------------------------------*/
54 
55 #ifndef RKDP45_H
56 #define RKDP45_H
57 
58 #include "ODESolver.H"
59 #include "adaptiveSolver.H"
60 
61 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
62 
63 namespace Foam
64 {
65 
66 /*---------------------------------------------------------------------------*\
67  Class RKDP45 Declaration
68 \*---------------------------------------------------------------------------*/
69 
70 class RKDP45
71 :
72  public ODESolver,
73  public adaptiveSolver
74 {
75  // Private data
76 
77  //- RKDP Constants
78  static const scalar
79  c2, c3, c4, c5,
80  a21, a31, a32, a41, a42, a43, a51, a52, a53, a54,
81  a61, a62, a63, a64, a65,
82  b1, b3, b4, b5, b6,
83  e1, e3, e4, e5, e6, e7;
84 
85  // Temporary fields
86  mutable scalarField yTemp_;
87  mutable scalarField k2_;
88  mutable scalarField k3_;
89  mutable scalarField k4_;
90  mutable scalarField k5_;
91  mutable scalarField k6_;
92 
93  //- Error-estimate field
94  mutable scalarField err_;
95 
96 
97 public:
98 
99  //- Runtime type information
100  TypeName("RKDP45");
101 
102 
103  // Constructors
104 
105  //- Construct from ODE
106  RKDP45(const ODESystem& ode, const dictionary& dict);
107 
108 
109  // Member Functions
110 
111  //- Inherit solve from ODESolver
112  using ODESolver::solve;
113 
114  //- Solve a single step dx and return the error
115  scalar solve
116  (
117  const scalar x0,
118  const scalarField& y0,
119  const scalarField& dydx0,
120  const scalar dx,
121  scalarField& y
122  ) const;
123 
124  //- Solve the ODE system and the update the state
125  void solve
126  (
127  scalar& x,
128  scalarField& y,
129  scalar& dxTry
130  ) const;
131 };
132 
133 
134 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
135 
136 } // End namespace Foam
137 
138 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
139 
140 #endif
141 
142 // ************************************************************************* //
dictionary dict
Abstract base class for the systems of ordinary differential equations.
Definition: ODESystem.H:46
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
dimensionedScalar y0(const dimensionedScalar &ds)
An ODE solver for chemistry.
Definition: ode.H:50
4/5th Order Dormand–Prince Runge-Kutta ODE solver.
Definition: RKDP45.H:69
scalar y
scalar solve(const scalar x0, const scalarField &y0, const scalarField &dydx0, const scalar dx, scalarField &y) const
Solve a single step dx and return the error.
Definition: RKDP45.C:96
TypeName("RKDP45")
Runtime type information.
RKDP45(const ODESystem &ode, const dictionary &dict)
Construct from ODE.
Definition: RKDP45.C:79
virtual void solve(scalar &x, scalarField &y, scalar &dxTry) const
Solve the ODE system as far as possible upto dxTry.
Definition: ODESolver.H:178
Abstract base-class for ODE system solvers.
Definition: ODESolver.H:50
Namespace for OpenFOAM.