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_;
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,
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 // ************************************************************************* //
Foam::Rosenbrock34::gamma
static const scalar gamma
Definition: Rosenbrock34.H:93
Foam::ODESolver
Abstract base-class for ODE system solvers.
Definition: ODESolver.H:50
Foam::Rosenbrock34::dfdx_
scalarField dfdx_
Definition: Rosenbrock34.H:82
Foam::Rosenbrock34::c31
static const scalar c31
Definition: Rosenbrock34.H:89
Foam::Rosenbrock34::c21
static const scalar c21
Definition: Rosenbrock34.H:89
Foam::Rosenbrock34::a21
static const scalar a21
Definition: Rosenbrock34.H:88
Foam::Rosenbrock34::k4_
scalarField k4_
Definition: Rosenbrock34.H:79
Foam::Rosenbrock34::dfdy_
scalarSquareMatrix dfdy_
Definition: Rosenbrock34.H:83
Foam::Rosenbrock34::b2
static const scalar b2
Definition: Rosenbrock34.H:91
Foam::Rosenbrock34::TypeName
TypeName("Rosenbrock34")
Runtime type information.
Foam::Rosenbrock34::e3
static const scalar e3
Definition: Rosenbrock34.H:92
Foam::Rosenbrock34::k2_
scalarField k2_
Definition: Rosenbrock34.H:77
adaptiveSolver.H
Foam::Rosenbrock34::a31
static const scalar a31
Definition: Rosenbrock34.H:88
Foam::Field
Pre-declare SubField and related Field type.
Definition: Field.H:57
Foam::Rosenbrock34::d2
static const scalar d2
Definition: Rosenbrock34.H:95
Foam::Rosenbrock34::a32
static const scalar a32
Definition: Rosenbrock34.H:88
Foam::Rosenbrock34::e2
static const scalar e2
Definition: Rosenbrock34.H:92
Foam::Rosenbrock34::k3_
scalarField k3_
Definition: Rosenbrock34.H:78
Foam::Rosenbrock34::c42
static const scalar c42
Definition: Rosenbrock34.H:90
Foam::y0
dimensionedScalar y0(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:272
Foam::Rosenbrock34::Rosenbrock34
Rosenbrock34(const ODESystem &ode, const dictionary &dict)
Construct from ODE.
Definition: Rosenbrock34.C:108
Foam::Rosenbrock34
L-stable embedded Rosenbrock ODE solver of order (3)4.
Definition: Rosenbrock34.H:69
Foam::Rosenbrock34::e1
static const scalar e1
Definition: Rosenbrock34.H:92
Foam::ode
An ODE solver for chemistry.
Definition: ode.H:50
Foam::Rosenbrock34::solve
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
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::Rosenbrock34::c32
static const scalar c32
Definition: Rosenbrock34.H:89
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
ODESolver.H
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::Rosenbrock34::c41
static const scalar c41
Definition: Rosenbrock34.H:90
Foam::Rosenbrock34::d1
static const scalar d1
Definition: Rosenbrock34.H:95
Foam::SquareMatrix< scalar >
Foam::Rosenbrock34::d3
static const scalar d3
Definition: Rosenbrock34.H:95
Foam::ODESystem
Abstract base class for the systems of ordinary differential equations.
Definition: ODESystem.H:46
Foam::Rosenbrock34::e4
static const scalar e4
Definition: Rosenbrock34.H:92
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
Foam::ODESolver::solve
virtual void solve(scalar &x, scalarField &y, scalar &dxTry) const
Solve the ODE system as far as possible upto dxTry.
Definition: ODESolver.H:178
Foam::Rosenbrock34::pivotIndices_
labelList pivotIndices_
Definition: Rosenbrock34.H:85
Foam::Rosenbrock34::d4
static const scalar d4
Definition: Rosenbrock34.H:95
Foam::Rosenbrock34::b4
static const scalar b4
Definition: Rosenbrock34.H:91
Foam::Rosenbrock34::c2
static const scalar c2
Definition: Rosenbrock34.H:94
Foam::Rosenbrock34::dydx_
scalarField dydx_
Definition: Rosenbrock34.H:81
x
x
Definition: LISASMDCalcMethod2.H:52
Foam::Rosenbrock34::b3
static const scalar b3
Definition: Rosenbrock34.H:91
Foam::Rosenbrock34::k1_
scalarField k1_
Definition: Rosenbrock34.H:76
Foam::Rosenbrock34::a_
scalarSquareMatrix a_
Definition: Rosenbrock34.H:84
Foam::Rosenbrock34::err_
scalarField err_
Definition: Rosenbrock34.H:80
Foam::adaptiveSolver
Definition: adaptiveSolver.H:47
Foam::Rosenbrock34::c3
static const scalar c3
Definition: Rosenbrock34.H:94
y
scalar y
Definition: LISASMDCalcMethod1.H:14
Foam::Rosenbrock34::c43
static const scalar c43
Definition: Rosenbrock34.H:90
Foam::Rosenbrock34::b1
static const scalar b1
Definition: Rosenbrock34.H:91