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