Rosenbrock12.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::Rosenbrock12
26 
27 Description
28  L-stable embedded Rosenbrock ODE solver of order (1)2.
29 
30  References:
31  \verbatim
32  "A second-order Rosenbrock method applied to
33  photochemical dispersion problems",
34  J. G. Verwer,
35  E. J. Spee,
36  J. G. Blom,
37  W. Hundsdorfer,
38  Siam Journal on Scientific Computing 01/1999; 20(4):1456-1480.
39  \endverbatim
40 
41 SourceFiles
42  Rosenbrock12.C
43 
44 \*---------------------------------------------------------------------------*/
45 
46 #ifndef Rosenbrock12_H
47 #define Rosenbrock12_H
48 
49 #include "ODESolver.H"
50 #include "adaptiveSolver.H"
51 
52 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
53 
54 namespace Foam
55 {
56 
57 /*---------------------------------------------------------------------------*\
58  Class Rosenbrock12 Declaration
59 \*---------------------------------------------------------------------------*/
60 
61 class Rosenbrock12
62 :
63  public ODESolver,
64  public adaptiveSolver
65 {
66  // Private data
67 
68  mutable scalarField k1_;
69  mutable scalarField k2_;
70  mutable scalarField err_;
71  mutable scalarField dydx_;
72  mutable scalarField dfdx_;
75  mutable labelList pivotIndices_;
76 
77  static const scalar
78  a21,
79  c21,
80  b1, b2,
82  c2,
83  e1, e2,
84  d1, d2;
85 
86 
87 public:
88 
89  //- Runtime type information
90  TypeName("Rosenbrock12");
91 
92 
93  // Constructors
94 
95  //- Construct from ODE
96  Rosenbrock12(const ODESystem& ode, const dictionary& dict);
97 
98 
99  // Member Functions
100 
101  //- Inherit solve from ODESolver
102  using ODESolver::solve;
103 
104  //- Solve a single step dx and return the error
105  scalar solve
106  (
107  const scalar x0,
108  const scalarField& y0,
109  const scalarField& dydx0,
110  const scalar dx,
111  scalarField& y
112  ) const;
113 
114  //- Solve the ODE system and the update the state
115  void solve
116  (
117  scalar& x,
118  scalarField& y,
119  scalar& dxTry
120  ) const;
121 };
122 
123 
124 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
125 
126 } // End namespace Foam
127 
128 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
129 
130 #endif
131 
132 // ************************************************************************* //
Foam::Rosenbrock12::TypeName
TypeName("Rosenbrock12")
Runtime type information.
Foam::Rosenbrock12
L-stable embedded Rosenbrock ODE solver of order (1)2.
Definition: Rosenbrock12.H:60
Foam::Rosenbrock12::c21
static const scalar c21
Definition: Rosenbrock12.H:78
Foam::Rosenbrock12::dydx_
scalarField dydx_
Definition: Rosenbrock12.H:70
Foam::Rosenbrock12::b1
static const scalar b1
Definition: Rosenbrock12.H:79
Foam::Rosenbrock12::k2_
scalarField k2_
Definition: Rosenbrock12.H:68
Foam::Rosenbrock12::c2
static const scalar c2
Definition: Rosenbrock12.H:81
Foam::ODESolver
Abstract base-class for ODE system solvers.
Definition: ODESolver.H:50
Foam::Rosenbrock12::a21
static const scalar a21
Definition: Rosenbrock12.H:77
Foam::Rosenbrock12::Rosenbrock12
Rosenbrock12(const ODESystem &ode, const dictionary &dict)
Construct from ODE.
Definition: Rosenbrock12.C:52
Foam::Rosenbrock12::k1_
scalarField k1_
Definition: Rosenbrock12.H:67
adaptiveSolver.H
Foam::Field
Pre-declare SubField and related Field type.
Definition: Field.H:57
Foam::Rosenbrock12::a_
scalarSquareMatrix a_
Definition: Rosenbrock12.H:73
Foam::y0
dimensionedScalar y0(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:272
Foam::ode
An ODE solver for chemistry.
Definition: ode.H:50
dict
dictionary dict
Definition: searchingEngine.H:14
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::Rosenbrock12::e1
static const scalar e1
Definition: Rosenbrock12.H:82
Foam::Rosenbrock12::err_
scalarField err_
Definition: Rosenbrock12.H:69
Foam::SquareMatrix< scalar >
Foam::Rosenbrock12::d1
static const scalar d1
Definition: Rosenbrock12.H:83
Foam::ODESystem
Abstract base class for the systems of ordinary differential equations.
Definition: ODESystem.H:46
Foam::Rosenbrock12::e2
static const scalar e2
Definition: Rosenbrock12.H:82
Foam::Rosenbrock12::d2
static const scalar d2
Definition: Rosenbrock12.H:83
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::Rosenbrock12::gamma
static const scalar gamma
Definition: Rosenbrock12.H:80
x
x
Definition: LISASMDCalcMethod2.H:52
Foam::Rosenbrock12::dfdx_
scalarField dfdx_
Definition: Rosenbrock12.H:71
Foam::Rosenbrock12::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: Rosenbrock12.C:70
Foam::Rosenbrock12::pivotIndices_
labelList pivotIndices_
Definition: Rosenbrock12.H:74
Foam::Rosenbrock12::b2
static const scalar b2
Definition: Rosenbrock12.H:79
Foam::Rosenbrock12::dfdy_
scalarSquareMatrix dfdy_
Definition: Rosenbrock12.H:72
Foam::adaptiveSolver
Definition: adaptiveSolver.H:47
y
scalar y
Definition: LISASMDCalcMethod1.H:14