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