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-2018 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 scalarField& dydx0,
108  const scalar dx,
109  scalarField& y
110  ) const;
111 
112  //- Solve the ODE system and the update the state
113  virtual void solve
114  (
115  scalar& x,
116  scalarField& y,
117  scalar& dxTry
118  ) const;
119 };
120 
121 
122 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
123 
124 } // End namespace Foam
125 
126 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
127 
128 #endif
129 
130 // ************************************************************************* //
virtual void solve(scalar &x, scalarField &y, scalar &dxTry) const
Solve the ODE system as far as possible up to dxTry.
Definition: ODESolver.C:116
dictionary dict
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:137
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
Semi-implicit Euler ODE solver of order (0)1.
Definition: EulerSI.H:61
virtual ~EulerSI()
Destructor.
Definition: EulerSI.H:89
Abstract base-class for ODE system solvers.
Definition: ODESolver.H:50
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: EulerSI.C:78
TypeName("EulerSI")
Runtime type information.
Namespace for OpenFOAM.