RKCK45.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-2015 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::RKCK45
26 
27 Description
28  4/5th Order Cash-Karp Runge-Kutta ODE solver.
29 
30  References:
31  \verbatim
32  "A variable order Runge-Kutta method for initial value problems
33  with rapidly varying right-hand sides"
34  Cash, J.R.,
35  Karp, A.H.
36  ACM Transactions on Mathematical Software, vol. 16, 1990, pp. 201–222.
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 SourceFiles
47  RKCK45.C
48 
49 \*---------------------------------------------------------------------------*/
50 
51 #ifndef RKCK45_H
52 #define RKCK45_H
53 
54 #include "ODESolver.H"
55 #include "adaptiveSolver.H"
56 
57 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
58 
59 namespace Foam
60 {
61 
62 /*---------------------------------------------------------------------------*\
63  Class RKCK45 Declaration
64 \*---------------------------------------------------------------------------*/
65 
66 class RKCK45
67 :
68  public ODESolver,
69  public adaptiveSolver
70 {
71  // Private data
72 
73  //- RKCK Constants
74  static const scalar
75  c2, c3, c4, c5, c6,
76  a21, a31, a32, a41, a42, a43, a51, a52, a53, a54,
77  a61, a62, a63, a64, a65,
78  b1, b3, b4, b6,
79  e1, e3, e4, e5, e6;
80 
81  // Temporary fields
82  mutable scalarField yTemp_;
83  mutable scalarField k2_;
84  mutable scalarField k3_;
85  mutable scalarField k4_;
86  mutable scalarField k5_;
87  mutable scalarField k6_;
88 
89  //- Error-estimate field
90  mutable scalarField err_;
91 
92 
93 public:
94 
95  //- Runtime type information
96  TypeName("RKCK45");
97 
98 
99  // Constructors
100 
101  //- Construct from ODE
102  RKCK45(const ODESystem& ode, const dictionary& dict);
103 
104 
105  // Member Functions
106 
107  //- Inherit solve from ODESolver
108  using ODESolver::solve;
109 
110  //- Solve a single step dx and return the error
111  scalar solve
112  (
113  const scalar x0,
114  const scalarField& y0,
115  const scalarField& dydx0,
116  const scalar dx,
117  scalarField& y
118  ) const;
119 
120  //- Solve the ODE system and the update the state
121  void solve
122  (
123  scalar& x,
124  scalarField& y,
125  scalar& dxTry
126  ) const;
127 };
128 
129 
130 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
131 
132 } // End namespace Foam
133 
134 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
135 
136 #endif
137 
138 // ************************************************************************* //
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
4/5th Order Cash-Karp Runge-Kutta ODE solver.
Definition: RKCK45.H:65
dimensionedScalar y0(const dimensionedScalar &ds)
An ODE solver for chemistry.
Definition: ode.H:50
scalar y
RKCK45(const ODESystem &ode, const dictionary &dict)
Construct from ODE.
Definition: RKCK45.C:74
TypeName("RKCK45")
Runtime type information.
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: RKCK45.C:91
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.