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-2015 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 ODE
79  Euler(const ODESystem& ode, const dictionary& dict);
80 
81 
82  // Member Functions
83 
84  //- Inherit solve from ODESolver
85  using ODESolver::solve;
86 
87  //- Solve a single step dx and return the error
88  scalar solve
89  (
90  const scalar x0,
91  const scalarField& y0,
92  const scalarField& dydx0,
93  const scalar dx,
94  scalarField& y
95  ) const;
96 
97  //- Solve the ODE system and the update the state
98  void solve
99  (
100  scalar& x,
101  scalarField& y,
102  scalar& dxTry
103  ) const;
104 };
105 
106 
107 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
108 
109 } // End namespace Foam
110 
111 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
112 
113 #endif
114 
115 // ************************************************************************* //
virtual void solve(scalar &x, scalarField &y, scalar &dxTry) const
Solve the ODE system as far as possible upto dxTry.
Definition: ODESolver.H:178
Euler(const word &phiName, const dictionary &dict)
Construct from components.
Definition: Euler.C:32
dimensionedScalar y0(const dimensionedScalar &ds)
Namespace for OpenFOAM.
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:51
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
dictionary dict
TypeName("Euler")
Runtime type information.
scalar y