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