/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 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 .
\*---------------------------------------------------------------------------*/
#include "EulerImplicit.H"
#include "addToRunTimeSelectionTable.H"
#include "simpleMatrix.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template
Foam::EulerImplicit::EulerImplicit
(
const fvMesh& mesh,
const word& phaseName
)
:
chemistrySolver(mesh, phaseName),
coeffsDict_(this->subDict("EulerImplicitCoeffs")),
cTauChem_(readScalar(coeffsDict_.lookup("cTauChem"))),
eqRateLimiter_(coeffsDict_.lookup("equilibriumRateLimiter")),
cTp_(this->nEqns())
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template
Foam::EulerImplicit::~EulerImplicit()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template
void Foam::EulerImplicit::updateRRInReactionI
(
const label index,
const scalar pr,
const scalar pf,
const scalar corr,
const label lRef,
const label rRef,
const scalar p,
const scalar T,
simpleMatrix& RR
) const
{
const Reaction& R =
this->reactions_[index];
forAll(R.lhs(), s)
{
label si = R.lhs()[s].index;
scalar sl = R.lhs()[s].stoichCoeff;
RR[si][rRef] -= sl*pr*corr;
RR[si][lRef] += sl*pf*corr;
}
forAll(R.rhs(), s)
{
label si = R.rhs()[s].index;
scalar sr = R.rhs()[s].stoichCoeff;
RR[si][lRef] -= sr*pf*corr;
RR[si][rRef] += sr*pr*corr;
}
}
template
void Foam::EulerImplicit::solve
(
scalarField& c,
scalar& T,
scalar& p,
scalar& deltaT,
scalar& subDeltaT
) const
{
const label nSpecie = this->nSpecie();
simpleMatrix RR(nSpecie, 0, 0);
for (label i=0; ispecieThermo_[0]
);
for (label i=1; ispecieThermo_[i];
}
scalar ha = mixture.Ha(p, T);
scalar deltaTEst = min(deltaT, subDeltaT);
forAll(this->reactions(), i)
{
scalar pf, cf, pr, cr;
label lRef, rRef;
scalar omegai = this->omegaI(i, c, T, p, pf, cf, lRef, pr, cr, rRef);
scalar corr = 1.0;
if (eqRateLimiter_)
{
if (omegai < 0.0)
{
corr = 1.0/(1.0 + pr*deltaTEst);
}
else
{
corr = 1.0/(1.0 + pf*deltaTEst);
}
}
updateRRInReactionI(i, pr, pf, corr, lRef, rRef, p, T, RR);
}
// Calculate the stable/accurate time-step
scalar tMin = GREAT;
for (label i=0; ispecieThermo_[0];
for (label i=1; ispecieThermo_[i];
}
T = mixture.THa(ha, p, T);
/*
for (label i=0; i