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