Euler.C
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 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 \*---------------------------------------------------------------------------*/
25 
26 #include "Euler.H"
28 
29 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
30 
31 namespace Foam
32 {
33  defineTypeNameAndDebug(Euler, 0);
34  addToRunTimeSelectionTable(ODESolver, Euler, dictionary);
35 }
36 
37 
38 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
39 
41 :
42  ODESolver(ode, dict),
43  adaptiveSolver(ode, dict),
44  err_(n_)
45 {}
46 
47 
48 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
49 
50 Foam::scalar Foam::Euler::solve
51 (
52  const scalar x0,
53  const scalarField& y0,
54  const scalarField& dydx0,
55  const scalar dx,
56  scalarField& y
57 ) const
58 {
59  // Calculate error estimate from the change in state:
60  forAll(err_, i)
61  {
62  err_[i] = dx*dydx0[i];
63  }
64 
65  // Update the state
66  forAll(y, i)
67  {
68  y[i] = y0[i] + err_[i];
69  }
70 
71  return normalizeError(y0, y, err_);
72 }
73 
74 
76 (
77  scalar& x,
78  scalarField& y,
79  scalar& dxTry
80 ) const
81 {
82  adaptiveSolver::solve(odes_, x, y, dxTry);
83 }
84 
85 
86 // ************************************************************************* //
Euler(const word &phiName, const dictionary &dict)
Construct from components.
Definition: Euler.C:32
virtual scalar solve(const scalar x0, const scalarField &y0, const scalarField &dydx0, const scalar dx, scalarField &y) const =0
Solve a single step dx and return the error.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
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
Abstract base class for the systems of ordinary differential equations.
Definition: ODESystem.H:46
dictionary dict
An ODE solver for chemistry.
Definition: ode.H:50
#define forAll(list, i)
Definition: UList.H:421
const ODESystem & odes_
Reference to ODESystem.
Definition: ODESolver.H:58
Macros for easy insertion into run-time selection tables.
Abstract base-class for ODE system solvers.
Definition: ODESolver.H:50
scalar normalizeError(const scalarField &y0, const scalarField &y, const scalarField &err) const
Return the nomalized scalar error.
Definition: ODESolver.C:67
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
defineTypeNameAndDebug(combustionModel, 0)