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