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