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