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