Euler.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-2016 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 scalarField& dydx0,
101  const scalar dx,
102  scalarField& y
103  ) const;
104 
105  //- Solve the ODE system and the update the state
106  virtual void solve
107  (
108  scalar& x,
109  scalarField& y,
110  scalar& dxTry
111  ) const;
112 };
113 
114 
115 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
116 
117 } // End namespace Foam
118 
119 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
120 
121 #endif
122 
123 // ************************************************************************* //
virtual void solve(scalar &x, scalarField &y, scalar &dxTry) const
Solve the ODE system as far as possible upto dxTry.
Definition: ODESolver.C:116
dictionary dict
virtual ~Euler()
Destructor.
Definition: Euler.C:51
dimensionedScalar y0(const dimensionedScalar &ds)
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: Euler.C:68
scalar y
TypeName("Euler")
Runtime type information.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
friend class ODESystem
Definition: ODESolver.H:95
virtual bool resize()
Resize the ODE solver.
Definition: Euler.C:50
Euler(const word &phiName, const dictionary &dict)
Construct from components.
Definition: Euler.C:32
Namespace for OpenFOAM.