RKDP45.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::RKDP45
26 
27 Description
28  4/5th Order Dormand–Prince Runge-Kutta ODE solver.
29 
30  References:
31  \verbatim
32  Dormand, J. R., & Prince, P. J. (1980).
33  A family of embedded Runge-Kutta formulae.
34  Journal of computational and applied mathematics, 6(1), 19-26.
35 
36  Hairer, E., Nørsett, S. P., & Wanner, G. (1993).
37  Solving Ordinary Differential Equations I: Nonstiff Problems,
38  second edition.
39  Springer-Verlag, Berlin.
40  \endverbatim
41 
42 See also
43  Foam::RKF45
44  Foam::RKCK45
45 
46 SourceFiles
47  RKDP45.C
48 
49 \*---------------------------------------------------------------------------*/
50 
51 #ifndef RKDP45_H
52 #define RKDP45_H
53 
54 #include "ODESolver.H"
55 #include "adaptiveSolver.H"
56 
57 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
58 
59 namespace Foam
60 {
61 
62 /*---------------------------------------------------------------------------*\
63  Class RKDP45 Declaration
64 \*---------------------------------------------------------------------------*/
65 
66 class RKDP45
67 :
68  public ODESolver,
69  public adaptiveSolver
70 {
71  // Private Data
72 
73  //- RKDP Constants
74  static const scalar
75  c2, c3, c4, c5,
76  a21, a31, a32, a41, a42, a43, a51, a52, a53, a54,
77  a61, a62, a63, a64, a65,
78  b1, b3, b4, b5, b6,
79  e1, e3, e4, e5, e6, e7;
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("RKDP45");
97 
98 
99  // Constructors
100 
101  //- Construct from ODESystem
102  RKDP45(const ODESystem& ode, const dictionary& dict);
103 
104 
105  //- Destructor
106  virtual ~RKDP45()
107  {}
108 
109 
110  // Member Functions
111 
112  //- Inherit solve from ODESolver
113  using ODESolver::solve;
114 
115  //- Resize the ODE solver
116  virtual bool resize();
117 
118  //- Solve a single step dx and return the error
119  virtual scalar solve
120  (
121  const scalar x0,
122  const scalarField& y0,
123  const label li,
124  const scalarField& dydx0,
125  const scalar dx,
126  scalarField& y
127  ) const;
128 
129  //- Solve the ODE system and the update the state
130  virtual void solve
131  (
132  scalar& x,
133  scalarField& y,
134  const label li,
135  scalar& dxTry
136  ) const;
137 };
138 
139 
140 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
141 
142 } // End namespace Foam
143 
144 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
145 
146 #endif
147 
148 // ************************************************************************* //
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
dimensionedScalar y0(const dimensionedScalar &ds)
An ODE solver for chemistry.
Definition: ode.H:50
virtual bool resize()
Resize the ODE solver.
Definition: RKDP45.C:95
4/5th Order Dormand–Prince Runge-Kutta ODE solver.
Definition: RKDP45.H:65
scalar y
TypeName("RKDP45")
Runtime type information.
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: RKDP45.C:119
RKDP45(const ODESystem &ode, const dictionary &dict)
Construct from ODESystem.
Definition: RKDP45.C:79
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 ~RKDP45()
Destructor.
Definition: RKDP45.H:105
Namespace for OpenFOAM.