Rosenbrock34.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 | Copyright (C) 2013-2015 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::Rosenbrock34
26 
27 Description
28  L-stable embedded Rosenbrock ODE solver of order (3)4.
29 
30  \verbatim
31  "Solving Ordinary Differential Equations II: Stiff
32  and Differential-Algebraic Problems, second edition",
33  Hairer, E.,
34  Nørsett, S.,
35  Wanner, G.,
36  Springer-Verlag, Berlin. 1996.
37  \endverbatim
38 
39  The default constants are from:
40  \verbatim
41  "Implementation of Rosenbrock Methods"
42  Shampine, L. F.,
43  ACM Transactions on Mathematical Software, vol. 8, 1982, pp. 93–113.
44  \endverbatim
45  with which the scheme is more accurate than with the L-Stable coefficients
46  for small step-size but less stable for large step-size.
47 
48  The L-Stable scheme constants are provided commented-out in Rosenbrock34.C
49 
50 SourceFiles
51  Rosenbrock34.C
52 
53 \*---------------------------------------------------------------------------*/
54 
55 #ifndef Rosenbrock34_H
56 #define Rosenbrock34_H
57 
58 #include "ODESolver.H"
59 #include "adaptiveSolver.H"
60 
61 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
62 
63 namespace Foam
64 {
65 
66 /*---------------------------------------------------------------------------*\
67  Class Rosenbrock34 Declaration
68 \*---------------------------------------------------------------------------*/
69 
70 class Rosenbrock34
71 :
72  public ODESolver,
73  public adaptiveSolver
74 {
75  // Private data
76 
77  mutable scalarField k1_;
78  mutable scalarField k2_;
79  mutable scalarField k3_;
80  mutable scalarField k4_;
81  mutable scalarField err_;
82  mutable scalarField dydx_;
83  mutable scalarField dfdx_;
84  mutable scalarSquareMatrix dfdy_;
85  mutable scalarSquareMatrix a_;
86  mutable labelList pivotIndices_;
87 
88  static const scalar
89  a21, a31, a32,
90  c21, c31, c32,
91  c41, c42, c43,
92  b1, b2, b3, b4,
93  e1, e2, e3, e4,
94  gamma,
95  c2, c3,
96  d1, d2, d3, d4;
97 
98 
99 public:
100 
101  //- Runtime type information
102  TypeName("Rosenbrock34");
103 
104 
105  // Constructors
106 
107  //- Construct from ODE
108  Rosenbrock34(const ODESystem& ode, const dictionary& dict);
109 
110 
111  // Member Functions
112 
113  //- Inherit solve from ODESolver
114  using ODESolver::solve;
115 
116  //- Solve a single step dx and return the error
117  scalar solve
118  (
119  const scalar x0,
120  const scalarField& y0,
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  void solve
128  (
129  scalar& x,
130  scalarField& y,
131  scalar& dxTry
132  ) const;
133 };
134 
135 
136 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
137 
138 } // End namespace Foam
139 
140 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
141 
142 #endif
143 
144 // ************************************************************************* //
dictionary dict
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:137
dimensionedScalar y0(const dimensionedScalar &ds)
An ODE solver for chemistry.
Definition: ode.H:50
scalar y
virtual void solve(scalar &x, scalarField &y, scalar &dxTry) const
Solve the ODE system as far as possible upto dxTry.
Definition: ODESolver.H:178
TypeName("Rosenbrock34")
Runtime type information.
Rosenbrock34(const ODESystem &ode, const dictionary &dict)
Construct from ODE.
Definition: Rosenbrock34.C:108
Abstract base-class for ODE system solvers.
Definition: ODESolver.H:50
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: Rosenbrock34.C:128
L-stable embedded Rosenbrock ODE solver of order (3)4.
Definition: Rosenbrock34.H:69
Namespace for OpenFOAM.