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 | 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 \*---------------------------------------------------------------------------*/
28 
29 #include "Euler.H"
31 
32 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36  defineTypeNameAndDebug(Euler, 0);
37  addToRunTimeSelectionTable(ODESolver, Euler, dictionary);
38 }
39 
40 
41 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
42 
44 :
45  ODESolver(ode, dict),
47  err_(n_)
48 {}
49 
50 
51 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
52 
54 {
55  if (ODESolver::resize())
56  {
58 
59  resizeField(err_);
60 
61  return true;
62  }
63 
64  return false;
65 }
66 
67 
68 Foam::scalar Foam::Euler::solve
69 (
70  const scalar x0,
71  const scalarField& y0,
72  const scalarField& dydx0,
73  const scalar dx,
74  scalarField& y
75 ) const
76 {
77  // Calculate error estimate from the change in state:
78  forAll(err_, i)
79  {
80  err_[i] = dx*dydx0[i];
81  }
82 
83  // Update the state
84  forAll(y, i)
85  {
86  y[i] = y0[i] + err_[i];
87  }
88 
89  return normalizeError(y0, y, err_);
90 }
91 
92 
94 (
95  scalar& x,
96  scalarField& y,
97  scalar& dxTry
98 ) const
99 {
100  adaptiveSolver::solve(odes_, x, y, dxTry);
101 }
102 
103 
104 // ************************************************************************* //
Foam::addToRunTimeSelectionTable
addToRunTimeSelectionTable(decompositionMethod, kahipDecomp, dictionary)
Foam::ODESolver
Abstract base-class for ODE system solvers.
Definition: ODESolver.H:56
Euler.H
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
Foam::Euler::resize
virtual bool resize()
Resize the ODE solver.
Definition: Euler.C:53
Foam::adaptiveSolver::solve
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.
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
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
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::adaptiveSolver::resize
bool resize(const label n)
Resize the ODE solver.
Definition: adaptiveSolver.C:52
x
x
Definition: LISASMDCalcMethod2.H:52
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
Foam::ODESolver::resize
virtual bool resize()=0
Resize the ODE solver.
Definition: ODESolver.C:92
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