EulerSI.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-2019 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::EulerSI
26 
27 Description
28  Semi-implicit Euler ODE solver of order (0)1.
29 
30  The method calculates the new state from:
31  \f[
32  y_{n+1} = y_n
33  + \delta_x\left[I - \delta_x\frac{\partial f}{\partial y}\right]^{-1}
34  \cdot \left[f(y_n) + \delta_x\frac{\partial f}{\partial x}\right]
35  \f]
36  The error is estimated directly from the change in the solution,
37  i.e. the difference between the 0th and 1st order solutions:
38  \f[
39  err_{n+1} = y_{n+1} - y_n
40  \f]
41 
42 SourceFiles
43  EulerSI.C
44 
45 \*---------------------------------------------------------------------------*/
46 
47 #ifndef EulerSI_H
48 #define EulerSI_H
49 
50 #include "ODESolver.H"
51 #include "adaptiveSolver.H"
52 
53 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
54 
55 namespace Foam
56 {
57 
58 /*---------------------------------------------------------------------------*\
59  Class EulerSI Declaration
60 \*---------------------------------------------------------------------------*/
61 
62 class EulerSI
63 :
64  public ODESolver,
65  public adaptiveSolver
66 {
67  // Private Data
68 
69  mutable scalarField err_;
70  mutable scalarField dydx_;
71  mutable scalarField dfdx_;
72  mutable scalarSquareMatrix dfdy_;
73  mutable scalarSquareMatrix a_;
74  mutable labelList pivotIndices_;
75 
76 
77 public:
78 
79  //- Runtime type information
80  TypeName("EulerSI");
81 
82 
83  // Constructors
84 
85  //- Construct from ODESystem
86  EulerSI(const ODESystem& ode, const dictionary& dict);
87 
88 
89  //- Destructor
90  virtual ~EulerSI()
91  {}
92 
93 
94  // Member Functions
95 
96  //- Inherit solve from ODESolver
97  using ODESolver::solve;
98 
99  //- Resize the ODE solver
100  virtual bool resize();
101 
102  //- Solve a single step dx and return the error
103  virtual scalar solve
104  (
105  const scalar x0,
106  const scalarField& y0,
107  const label li,
108  const scalarField& dydx0,
109  const scalar dx,
110  scalarField& y
111  ) const;
112 
113  //- Solve the ODE system and the update the state
114  virtual void solve
115  (
116  scalar& x,
117  scalarField& y,
118  const label li,
119  scalar& dxTry
120  ) const;
121 };
122 
123 
124 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
125 
126 } // End namespace Foam
127 
128 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
129 
130 #endif
131 
132 // ************************************************************************* //
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
EulerSI(const ODESystem &ode, const dictionary &dict)
Construct from ODESystem.
Definition: EulerSI.C:40
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
virtual bool resize()
Resize the ODE solver.
Definition: EulerSI.C:55
dimensionedScalar y0(const dimensionedScalar &ds)
An ODE solver for chemistry.
Definition: ode.H:50
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: EulerSI.C:78
Semi-implicit Euler ODE solver of order (0)1.
Definition: EulerSI.H:61
virtual ~EulerSI()
Destructor.
Definition: EulerSI.H:89
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
TypeName("EulerSI")
Runtime type information.
Namespace for OpenFOAM.