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 -------------------------------------------------------------------------------
11 License
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 
27 Class
28  Foam::RKCK45
29 
30 Group
31  grpODESolvers
32 
33 Description
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 
49 SourceFiles
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 
62 namespace Foam
63 {
64 
65 /*---------------------------------------------------------------------------*\
66  Class RKCK45 Declaration
67 \*---------------------------------------------------------------------------*/
68 
69 class 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 
96 public:
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,
127  scalarField& y
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 // ************************************************************************* //
Foam::ODESolver
Abstract base-class for ODE system solvers.
Definition: ODESolver.H:56
Foam::RKCK45::resize
virtual bool resize()
Resize the ODE solver.
Definition: RKCK45.C:93
adaptiveSolver.H
Foam::Field< scalar >
Foam::RKCK45::RKCK45
RKCK45(const ODESystem &ode, const dictionary &dict)
Construct from ODESystem.
Definition: RKCK45.C:77
Foam::RKCK45
4/5th Order Cash-Karp Runge-Kutta ODE solver.
Definition: RKCK45.H:68
Foam::y0
dimensionedScalar y0(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:281
Foam::ode
An ODE solver for chemistry.
Definition: ode.H:52
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
ODESolver.H
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::RKCK45::TypeName
TypeName("RKCK45")
Runtime type information.
Foam::RKCK45::~RKCK45
virtual ~RKCK45()=default
Destructor.
Foam::ODESystem
Abstract base class for the systems of ordinary differential equations.
Definition: ODESystem.H:49
Foam::ODESolver::solve
virtual void solve(scalar &x, scalarField &y, scalar &dxTry) const
Solve the ODE system as far as possible up to dxTry.
Definition: ODESolver.C:117
x
x
Definition: LISASMDCalcMethod2.H:52
Foam::RKCK45::solve
virtual 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:115
Foam::adaptiveSolver
Definition: adaptiveSolver.H:53
y
scalar y
Definition: LISASMDCalcMethod1.H:14