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_;
73  mutable scalarSquareMatrix dfdy_;
74  mutable scalarSquareMatrix a_;
75  mutable labelList pivotIndices_;
76 
77  static const scalar
78  a21,
79  c21,
80  b1, b2,
81  gamma,
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 // ************************************************************************* //
virtual void solve(scalar &x, scalarField &y, scalar &dxTry) const
Solve the ODE system as far as possible upto dxTry.
Definition: ODESolver.H:178
L-stable embedded Rosenbrock ODE solver of order (1)2.
Definition: Rosenbrock12.H:60
dimensionedScalar y0(const dimensionedScalar &ds)
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
Namespace for OpenFOAM.
Abstract base class for the systems of ordinary differential equations.
Definition: ODESystem.H:46
dictionary dict
An ODE solver for chemistry.
Definition: ode.H:50
Rosenbrock12(const ODESystem &ode, const dictionary &dict)
Construct from ODE.
Definition: Rosenbrock12.C:52
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
Abstract base-class for ODE system solvers.
Definition: ODESolver.H:50
scalar y
TypeName("Rosenbrock12")
Runtime type information.