RKCK45.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2013-2019 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  Cash, J. R., & Karp, A. H. (1990).
33  A variable order Runge-Kutta method for initial value problems
34  with rapidly varying right-hand sides.
35  ACM Transactions on Mathematical Software (TOMS), 16(3), 201-222.
36 
37  Hairer, E., Nørsett, S. P., & Wanner, G. (1993).
38  Solving Ordinary Differential Equations I: Nonstiff Problems,
39  second edition.
40  Springer-Verlag, Berlin.
41  \endverbatim
42 
43 SourceFiles
44  RKCK45.C
45 
46 \*---------------------------------------------------------------------------*/
47 
48 #ifndef RKCK45_H
49 #define RKCK45_H
50 
51 #include "ODESolver.H"
52 #include "adaptiveSolver.H"
53 
54 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
55 
56 namespace Foam
57 {
58 
59 /*---------------------------------------------------------------------------*\
60  Class RKCK45 Declaration
61 \*---------------------------------------------------------------------------*/
62 
63 class RKCK45
64 :
65  public ODESolver,
66  public adaptiveSolver
67 {
68  // Private Data
69 
70  //- RKCK Constants
71  static const scalar
72  c2, c3, c4, c5, c6,
73  a21, a31, a32, a41, a42, a43, a51, a52, a53, a54,
74  a61, a62, a63, a64, a65,
75  b1, b3, b4, b6,
76  e1, e3, e4, e5, e6;
77 
78  // Temporary fields
79  mutable scalarField yTemp_;
80  mutable scalarField k2_;
81  mutable scalarField k3_;
82  mutable scalarField k4_;
83  mutable scalarField k5_;
84  mutable scalarField k6_;
85 
86  //- Error-estimate field
87  mutable scalarField err_;
88 
89 
90 public:
91 
92  //- Runtime type information
93  TypeName("RKCK45");
94 
95 
96  // Constructors
97 
98  //- Construct from ODESystem
99  RKCK45(const ODESystem& ode, const dictionary& dict);
100 
101 
102  //- Destructor
103  virtual ~RKCK45()
104  {}
105 
106 
107  // Member Functions
108 
109  //- Inherit solve from ODESolver
110  using ODESolver::solve;
111 
112  //- Resize the ODE solver
113  virtual bool resize();
114 
115  //- Solve a single step dx and return the error
116  virtual scalar solve
117  (
118  const scalar x0,
119  const scalarField& y0,
120  const label li,
121  const scalarField& dydx0,
122  const scalar dx,
123  scalarField& y
124  ) const;
125 
126  //- Solve the ODE system and the update the state
127  virtual void solve
128  (
129  scalar& x,
130  scalarField& y,
131  const label li,
132  scalar& dxTry
133  ) const;
134 };
135 
136 
137 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
138 
139 } // End namespace Foam
140 
141 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
142 
143 #endif
144 
145 // ************************************************************************* //
dictionary dict
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
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:156
virtual ~RKCK45()
Destructor.
Definition: RKCK45.H:102
4/5th Order Cash-Karp Runge-Kutta ODE solver.
Definition: RKCK45.H:62
virtual bool resize()
Resize the ODE solver.
Definition: RKCK45.C:90
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 ODESystem.
Definition: RKCK45.C:74
TypeName("RKCK45")
Runtime type information.
virtual void solve(scalar &x, scalarField &y, const label li, scalar &dxTry) const
Solve the ODE system from the current state xStart, y.
Definition: ODESolver.C:116
Abstract base-class for ODE system solvers.
Definition: ODESolver.H:50
virtual scalar solve(const scalar x0, const scalarField &y0, const label li, const scalarField &dydx0, const scalar dx, scalarField &y) const
Solve a single step dx and return the error.
Definition: RKCK45.C:114
Namespace for OpenFOAM.