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