227 lines
5.8 KiB
C
227 lines
5.8 KiB
C
/*---------------------------------------------------------------------------*\
|
|
========= |
|
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
|
\\ / O peration |
|
|
\\ / A nd | Copyright (C) 2013-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 <http://www.gnu.org/licenses/>.
|
|
|
|
\*---------------------------------------------------------------------------*/
|
|
|
|
#include "EDM.H"
|
|
#include "fvmSup.H"
|
|
|
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
|
|
|
|
|
template<class Type>
|
|
Foam::combustionModels::EDM<Type>::EDM
|
|
(
|
|
const word& modelType,
|
|
const fvMesh& mesh,
|
|
const word& phaseName
|
|
)
|
|
:
|
|
Type(modelType, mesh, phaseName),
|
|
finiteRate_ (this->coeffs().lookupOrDefault("finiteRate", false)),
|
|
A_ (this->coeffs().lookupOrDefault("A", 4.0)),
|
|
B_ (this->coeffs().lookupOrDefault("B", 0.5))
|
|
{
|
|
if (finiteRate_)
|
|
{
|
|
Info<< " using Finite-rate/Eddy Dissipation Model" << endl;
|
|
}
|
|
else
|
|
{
|
|
Info<< " using Eddy Dissipation Model" << endl;
|
|
}
|
|
Info<< " A = " << A_ << endl;
|
|
Info<< " B = " << B_ << endl;
|
|
}
|
|
|
|
|
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
|
|
|
template<class Type>
|
|
Foam::combustionModels::EDM<Type>::~EDM()
|
|
{}
|
|
|
|
|
|
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
|
|
|
template<class Type>
|
|
Foam::tmp<Foam::volScalarField>
|
|
Foam::combustionModels::EDM<Type>::tc() const
|
|
{
|
|
return this->chemistryPtr_->tc();
|
|
}
|
|
|
|
|
|
template<class Type>
|
|
void Foam::combustionModels::EDM<Type>::correct()
|
|
{
|
|
if (this->active())
|
|
{
|
|
tmp<volScalarField> tk(this->turbulence().k());
|
|
const volScalarField& k = tk();
|
|
|
|
tmp<volScalarField> tepsilon(this->turbulence().epsilon());
|
|
const volScalarField& epsilon = tepsilon();
|
|
|
|
this->chemistryPtr_->edm(epsilon/k, A_, B_);
|
|
|
|
if (finiteRate_)
|
|
{
|
|
// Copy edm rate stored in chemistryPtr_->RR(i)
|
|
PtrList<DimensionedField<scalar, volMesh>> edmRates
|
|
(
|
|
this->thermo().composition().Y().size()
|
|
);
|
|
forAll(edmRates, i)
|
|
{
|
|
edmRates.set
|
|
(
|
|
i,
|
|
new DimensionedField<scalar, volMesh>
|
|
(
|
|
this->chemistryPtr_->RR(i)
|
|
)
|
|
);
|
|
}
|
|
|
|
this->chemistryPtr_->calculate();
|
|
|
|
forAll(edmRates, i)
|
|
{
|
|
DimensionedField<scalar, volMesh> &finiteRatei
|
|
(
|
|
this->chemistryPtr_->RR(i)
|
|
);
|
|
|
|
forAll(finiteRatei, celli)
|
|
{
|
|
finiteRatei[celli] = min(finiteRatei[celli], edmRates[i][celli]);
|
|
finiteRatei[celli] =
|
|
finiteRatei[celli]*edmRates[i][celli]
|
|
/ (finiteRatei[celli] + edmRates[i][celli] + SMALL);
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
template<class Type>
|
|
Foam::tmp<Foam::fvScalarMatrix>
|
|
Foam::combustionModels::EDM<Type>::R(volScalarField& Y) const
|
|
{
|
|
tmp<fvScalarMatrix> tSu(new fvScalarMatrix(Y, dimMass/dimTime));
|
|
|
|
fvScalarMatrix& Su = tSu.ref();
|
|
|
|
if (this->active())
|
|
{
|
|
const label specieI =
|
|
this->thermo().composition().species()[Y.member()];
|
|
|
|
Su += this->chemistryPtr_->RR(specieI);
|
|
}
|
|
|
|
return tSu;
|
|
}
|
|
|
|
|
|
template<class Type>
|
|
Foam::tmp<Foam::volScalarField>
|
|
Foam::combustionModels::EDM<Type>::dQ() const
|
|
{
|
|
tmp<volScalarField> tdQ
|
|
(
|
|
new volScalarField
|
|
(
|
|
IOobject
|
|
(
|
|
IOobject::groupName(typeName + ":dQ", this->phaseName_),
|
|
this->mesh().time().timeName(),
|
|
this->mesh(),
|
|
IOobject::NO_READ,
|
|
IOobject::NO_WRITE,
|
|
false
|
|
),
|
|
this->mesh(),
|
|
dimensionedScalar("dQ", dimEnergy/dimTime, 0.0)
|
|
)
|
|
);
|
|
|
|
if (this->active())
|
|
{
|
|
tdQ.ref() = this->chemistryPtr_->dQ();
|
|
}
|
|
|
|
return tdQ;
|
|
}
|
|
|
|
|
|
template<class Type>
|
|
Foam::tmp<Foam::volScalarField>
|
|
Foam::combustionModels::EDM<Type>::Sh() const
|
|
{
|
|
tmp<volScalarField> tSh
|
|
(
|
|
new volScalarField
|
|
(
|
|
IOobject
|
|
(
|
|
IOobject::groupName(typeName + ":Sh", this->phaseName_),
|
|
this->mesh().time().timeName(),
|
|
this->mesh(),
|
|
IOobject::NO_READ,
|
|
IOobject::NO_WRITE,
|
|
false
|
|
),
|
|
this->mesh(),
|
|
dimensionedScalar("zero", dimEnergy/dimTime/dimVolume, 0.0)
|
|
)
|
|
);
|
|
|
|
if (this->active())
|
|
{
|
|
tSh.ref() = this->chemistryPtr_->Sh();
|
|
}
|
|
|
|
return tSh;
|
|
}
|
|
|
|
|
|
template<class Type>
|
|
bool Foam::combustionModels::EDM<Type>::read()
|
|
{
|
|
if (Type::read())
|
|
{
|
|
this->coeffs().lookup("finiteRate") >> finiteRate_;
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
// ************************************************************************* //
|