Files
OpenFOAM-12/src/ODE/ODESolvers/Euler/Euler.C
Henry Weller 2d0f459ea5 chemistryModel, reactions, ODESolver: Added "li" argument to all functions which evaluate the reaction rate
In chemistryModel "li" is set to the current cell index but for other reacting
systems it should be set to the current index of the element for which the
reaction system is being evaluated.

In the ODESolver "li" is the current index of the element for which the ODE
system is being solved if there is a list of related systems being solved,
otherwise it can be set to 0.
2019-07-31 15:40:04 +01:00

106 lines
2.6 KiB
C

/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2013-2019 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "Euler.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(Euler, 0);
addToRunTimeSelectionTable(ODESolver, Euler, dictionary);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::Euler::Euler(const ODESystem& ode, const dictionary& dict)
:
ODESolver(ode, dict),
adaptiveSolver(ode, dict),
err_(n_)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::Euler::resize()
{
if (ODESolver::resize())
{
adaptiveSolver::resize(n_);
resizeField(err_);
return true;
}
else
{
return false;
}
}
Foam::scalar Foam::Euler::solve
(
const scalar x0,
const scalarField& y0,
const label li,
const scalarField& dydx0,
const scalar dx,
scalarField& y
) const
{
// Calculate error estimate from the change in state:
forAll(err_, i)
{
err_[i] = dx*dydx0[i];
}
// Update the state
forAll(y, i)
{
y[i] = y0[i] + err_[i];
}
return normalizeError(y0, y, err_);
}
void Foam::Euler::solve
(
scalar& x,
scalarField& y,
const label li,
scalar& dxTry
) const
{
adaptiveSolver::solve(odes_, x, y, li, dxTry);
}
// ************************************************************************* //