RKF45.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 | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2013-2016 OpenFOAM Foundation
9 Copyright (C) 2019 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27Class
28 Foam::RKF45
29
30Group
31 grpODESolvers
32
33Description
34 4/5th Order Runge-Kutta-Fehlberg ODE solver
35
36 References:
37 \verbatim
38 Fehlberg, E. (1969).
39 Low-order classical Runge-Kutta formulas with stepsize control
40 and their application to some heat transfer problems.
41 NASA Technical Report 315.
42
43 Hairer, E., Nørsett, S. P., & Wanner, G. (1993).
44 Solving Ordinary Differential Equations I: Nonstiff Problems,
45 second edition.
46 Springer-Verlag, Berlin.
47 \endverbatim
48
49 This method embeds the 4-th order integration step into the 5-th order step
50 and allows to perform an adaptive step-size control using these two order
51 without the need of re-evaluation.
52
53SourceFiles
54 RKF45.C
55
56\*---------------------------------------------------------------------------*/
57
58#ifndef RKF45_H
59#define RKF45_H
60
61#include "ODESolver.H"
62#include "adaptiveSolver.H"
63
64// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
65
66namespace Foam
67{
68
69/*---------------------------------------------------------------------------*\
70 Class RKF45 Declaration
71\*---------------------------------------------------------------------------*/
73class RKF45
74:
75 public ODESolver,
76 public adaptiveSolver
77{
78 // Private data
79
80 //- RKF45 Constants
81 static const scalar
82 c2, c3, c4, c5, c6,
83 a21, a31, a32, a41, a42, a43, a51, a52, a53, a54,
84 a61, a62, a63, a64, a65,
85 b1, b3, b4, b5, b6,
86 e1, e3, e4, e5, e6;
87
88
89 // Temporary fields
90 mutable scalarField yTemp_;
91 mutable scalarField k2_;
92 mutable scalarField k3_;
93 mutable scalarField k4_;
94 mutable scalarField k5_;
95 mutable scalarField k6_;
96
97 //- Error-estimate field
98 mutable scalarField err_;
99
100
101public:
102
103 //- Runtime type information
104 TypeName("RKF45");
105
106
107 // Constructors
108
109 //- Construct from ODESystem
110 RKF45(const ODESystem& ode, const dictionary& dict);
111
112
113 //- Destructor
114 virtual ~RKF45() = default;
115
116
117 // Member Functions
118
119 //- Inherit solve from ODESolver
120 using ODESolver::solve;
121
122 //- Resize the ODE solver
123 virtual bool resize();
124
125 //- Solve a single step dx and return the error
126 virtual scalar solve
127 (
128 const scalar x0,
129 const scalarField& y0,
130 const scalarField& dydx0,
131 const scalar dx,
133 ) const;
134
135 //- Solve the ODE system and the update the state
136 virtual void solve
137 (
138 scalar& x,
139 scalarField& y,
140 scalar& dxTry
141 ) const;
142};
143
144
145// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
146
147} // End namespace Foam
148
149// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
150
151#endif
152
153// ************************************************************************* //
scalar y
Abstract base-class for ODE system solvers.
Definition: ODESolver.H:57
Abstract base class for the systems of ordinary differential equations.
Definition: ODESystem.H:50
4/5th Order Runge-Kutta-Fehlberg ODE solver
Definition: RKF45.H:76
virtual ~RKF45()=default
Destructor.
virtual bool resize()
Resize the ODE solver.
Definition: RKF45.C:94
TypeName("RKF45")
Runtime type information.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
An ODE solver for chemistry.
Definition: ode.H:55
Namespace for OpenFOAM.
dimensionedScalar y0(const dimensionedScalar &ds)
dictionary dict
CEqn solve()
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73