seulex.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 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::seulex
26 
27 Description
28  An extrapolation-algorithm, based on the linearly implicit Euler method
29  with step size control and order selection.
30 
31  The implementation is based on the SEULEX algorithm in
32  \verbatim
33  "Solving Ordinary Differential Equations II: Stiff
34  and Differential-Algebraic Problems, second edition",
35  Hairer, E.,
36  Nørsett, S.,
37  Wanner, G.,
38  Springer-Verlag, Berlin. 1996.
39  \endverbatim
40 
41 SourceFiles
42  seulex.C
43 
44 \*---------------------------------------------------------------------------*/
45 
46 #ifndef seulex_H
47 #define seulex_H
48 
49 #include "ODESolver.H"
50 #include "scalarMatrices.H"
51 #include "labelField.H"
52 
53 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
54 
55 namespace Foam
56 {
57 
58 /*---------------------------------------------------------------------------*\
59  Class seulex Declaration
60 \*---------------------------------------------------------------------------*/
61 
62 class seulex
63 :
64  public ODESolver
65 {
66  // Private data
67 
68  // Static constants
69 
70  static const label kMaxx_ = 12;
71  static const label iMaxx_ = kMaxx_ + 1;
72 
73  static const scalar
74  stepFactor1_, stepFactor2_, stepFactor3_,
75  stepFactor4_, stepFactor5_,
76  kFactor1_, kFactor2_;
77 
78  // Evaluated constants
79 
80  scalar jacRedo_;
81  labelField nSeq_;
82  scalarField cpu_;
83  scalarSquareMatrix coeff_;
84 
85  // Temporary storage
86  // held to avoid dynamic memory allocation between calls
87  // and to transfer internal values between functions
88 
89  mutable scalar theta_;
90  mutable label kTarg_;
91  mutable scalarRectangularMatrix table_;
92 
93  mutable scalarField dfdx_;
94  mutable scalarSquareMatrix dfdy_;
95  mutable scalarSquareMatrix a_;
96  mutable labelList pivotIndices_;
97 
98  // Fields space for "solve" function
99  mutable scalarField dxOpt_, temp_;
100  mutable scalarField y0_, ySequence_, scale_;
101 
102  // Fields used in "seul" function
103  mutable scalarField dy_, yTemp_, dydx_;
104 
105 
106  // Private Member Functions
107 
108  //- Computes the j-th line of the extrapolation table
109  bool seul
110  (
111  const scalar x0,
112  const scalarField& y0,
113  const scalar dxTot,
114  const label k,
115  scalarField& y,
116  const scalarField& scale
117  ) const;
118 
119  //- Polynomial extrpolation
120  void extrapolate
121  (
122  const label k,
124  scalarField& y
125  ) const;
126 
127 
128 public:
129 
130  //- Runtime type information
131  TypeName("seulex");
132 
133 
134  // Constructors
135 
136  //- Construct from ODE
137  seulex(const ODESystem& ode, const dictionary& dict);
138 
139 
140  // Member Functions
141 
142  //- Solve the ODE system and the update the state
143  void solve
144  (
145  scalar& x,
146  scalarField& y,
147  stepState& step
148  ) const;
149 };
150 
151 
152 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
153 
154 } // End namespace Foam
155 
156 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
157 
158 #endif
159 
160 // ************************************************************************* //
dictionary dict
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
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:137
dimensionedScalar y0(const dimensionedScalar &ds)
label k
Boltzmann constant.
An ODE solver for chemistry.
Definition: ode.H:50
scalar y
An extrapolation-algorithm, based on the linearly implicit Euler method with step size control and or...
Definition: seulex.H:61
TypeName("seulex")
Runtime type information.
void solve(scalar &x, scalarField &y, stepState &step) const
Solve the ODE system and the update the state.
Definition: seulex.C:215
Abstract base-class for ODE system solvers.
Definition: ODESolver.H:50
seulex(const ODESystem &ode, const dictionary &dict)
Construct from ODE.
Definition: seulex.C:50
Namespace for OpenFOAM.