added access to basicSpecieMixture and turbulenceModel to access required fields

This commit is contained in:
ignis 2018-01-27 00:55:23 +09:00
parent 620b23cf01
commit 7884c49a4d
7 changed files with 142 additions and 292 deletions

View file

@ -23,11 +23,42 @@ License
\*---------------------------------------------------------------------------*/
#include "fvmLaplacian.H"
#include "fvmDiv.H"
#include "linear.H"
#include "MossBrookesSoot.H"
#include "reactingMixture.H"
#include "fvm.H"
#include "basicSpecieMixture.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
template<class CombThermoType, class ThermoType>
const Foam::basicSpecieMixture&
Foam::radiation::MossBrookesSoot<CombThermoType, ThermoType>::checkThermo
(
const fluidThermo& thermo
)
{
if (isA<basicSpecieMixture>(thermo))
{
return dynamic_cast<const basicSpecieMixture& >
(
thermo
);
}
else
{
FatalErrorInFunction
<< "Inconsistent thermo package for " << thermo.type()
<< "Please select a thermo package based on "
<< "basicSpecieMixture" << exit(FatalError);
return dynamic_cast<const basicSpecieMixture& >
(
thermo
);
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
@ -91,6 +122,7 @@ Foam::radiation::MossBrookesSoot<CombThermoType, ThermoType>::MossBrookesSoot
),
coeffsDict_(dict.subOrEmptyDict(modelType + "Coeffs")),
thermo_(mesh.lookupObject<fluidThermo>(basicThermo::dictName)),
mixture_(checkThermo(thermo_)),
Snet_
(
IOobject
@ -236,8 +268,7 @@ Foam::radiation::MossBrookesSoot<CombThermoType, ThermoType>::MossBrookesSoot
Boltzmann(readScalar(coeffsDict_.lookup("BoltzmannConst"))),
radiationActive_(readBool(coeffsDict_.lookup("Radiationeffect"))),
cliqueNuc(readScalar(coeffsDict_.lookup("NucExpCorrectConstant"))),
cliqueMassGrow(readScalar(coeffsDict_.lookup("MassGrowCorrectConstant"))),
chemistryPtr_(CombThermoType::New(mesh))
cliqueMassGrow(readScalar(coeffsDict_.lookup("MassGrowCorrectConstant")))
{
}
@ -252,50 +283,6 @@ Foam::radiation::MossBrookesSoot<CombThermoType, ThermoType>::~MossBrookesSoot()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class CombThermoType, class ThermoType>
Foam::tmp<Foam::volVectorField>
Foam::radiation::MossBrookesSoot<CombThermoType, ThermoType>::U() const
{
return Foam::tmp<Foam::volVectorField>(NULL);
}
template<class CombThermoType, class ThermoType>
Foam::tmp<Foam::volScalarField>
Foam::radiation::MossBrookesSoot<CombThermoType, ThermoType>::nut() const
{
return Foam::tmp<Foam::volScalarField>(NULL);
}
template<class CombThermoType, class ThermoType>
Foam::tmp<Foam::volScalarField>
Foam::radiation::MossBrookesSoot<CombThermoType, ThermoType>::XPrec() const
{
word precSpecie(coeffsDict_.lookup("Precursor"));
const word *precspecie;
precspecie = &precSpecie;
return Foam::tmp<Foam::volScalarField>(NULL);
}
template<class CombThermoType, class ThermoType>
Foam::tmp<Foam::volScalarField>
Foam::radiation::MossBrookesSoot<CombThermoType, ThermoType>::XSgs() const
{
word sgsSpecie(coeffsDict_.lookup("SurfaceGrowSpecie"));
const word *sgsspecie;
sgsspecie = &sgsSpecie;
return Foam::tmp<Foam::volScalarField>(NULL);
}
template<class CombThermoType, class ThermoType>
Foam::tmp<Foam::volScalarField>
Foam::radiation::MossBrookesSoot<CombThermoType, ThermoType>::XOxid() const
{
word oxSpecie(coeffsDict_.lookup("SootOxidizerSpecie"));
const word *oxspecie;
oxspecie = &oxSpecie;
return Foam::tmp<Foam::volScalarField>(NULL);
}
template<class CombThermoType, class ThermoType>
Foam::tmp<Foam::volScalarField>
Foam::radiation::MossBrookesSoot<CombThermoType, ThermoType>::a(const label bandI) const
@ -354,43 +341,30 @@ void Foam::radiation::MossBrookesSoot<CombThermoType, ThermoType>::correct()
const volScalarField rho_ = thermo_.rho();
const volVectorField U_ = U();
const volScalarField &nut_ = turbulence().nut();
const volScalarField nut_ = nut();
const surfaceScalarField phi_
(
IOobject
(
"phi_for_soot",
mesh().time().timeName(),
mesh(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
linearInterpolate(rho_*U_) & mesh().Sf()
);
const surfaceScalarField phi_ (turbulence().phi());
fvScalarMatrix SootEqn
(
fvm::div(phi_, soot_)
- fvm::laplacian((rho_*nut_/PrtSoot), soot_)
==
- fvm::laplacian((rho_*nut_/PrtSoot), soot_)
==
Snet_
);
fvScalarMatrix NucConcEqn
(
fvm::div(phi_, NucConc_)
- fvm::laplacian((rho_*nut_/PrtSoot), NucConc_)
==
NSnet_
);
SootEqn.relax();
SootEqn.solve();
fvScalarMatrix NucConcEqn
(
fvm::div(phi_, NucConc_)
- fvm::laplacian((rho_*nut_/PrtSoot), NucConc_)
==
NSnet_
);
NucConcEqn.relax();
NucConcEqn.solve();
@ -433,52 +407,17 @@ void Foam::radiation::MossBrookesSoot<CombThermoType, ThermoType>::calcSource()
const volScalarField T_ = thermo_.T();
const volScalarField p_ = thermo_.p();
const volScalarField XPrec_ = XPrec();
const scalar precI = mixture_.species()[coeffsDict_.lookup("Precursor")];
const scalar growI = mixture_.species()[coeffsDict_.lookup("SurfaceGrowSpecie")];
const scalar oxidI = mixture_.species()[coeffsDict_.lookup("SootOxidizerSpecie")];
const volScalarField XSgs_ = XSgs();
const volScalarField &Yprec_ = mixture_.Y(precI);
const volScalarField &Ygrow_ = mixture_.Y(growI);
const volScalarField &Yoxid_ = mixture_.Y(oxidI);
const volScalarField XOxid_ = XOxid();
scalar ErrorIndex_p = 0;
scalar ErrorIndex_rho = 0;
scalar ErrorIndex_T = 0;
scalar ErrorIndex_precursor = 0;
scalar ErrorIndex_oxidizer = 0;
forAll(rho_, celli)
{
if (p_[celli] < 0) {
ErrorIndex_p = 1;
}
if (rho_[celli] < 0) {
ErrorIndex_rho = 1;
}
if (T_[celli] < 0) {
ErrorIndex_T = 1;
}
if (XPrec_[celli] < 0) {
ErrorIndex_precursor = 1;
}
if (XOxid_[celli] < 0) {
ErrorIndex_oxidizer = 1;
}
}
if (ErrorIndex_p == 1){
Info<<"Warning! Improper pressure field value has been fed into the soot calculation!"<<endl;
}
if (ErrorIndex_rho == 1){
Info<<"Warning! Improper rho field value has been fed into the soot calculation!"<<endl;
}
if (ErrorIndex_T == 1){
Info<<"Warning! Improper T field value has been fed into the soot calculation!"<<endl;
}
if (ErrorIndex_precursor == 1){
Info<<"Warning! Improper soot precursor mole fraction field value has been fed into the soot calculation!"<<endl;
}
if (ErrorIndex_oxidizer == 1){
Info<<"Warning! Improper soot oxidizer mole fraction field value has been fed into the soot calculation!"<<endl;
}
const volScalarField XPrec_(mixture_.W()*Yprec_/mixture_.W(precI));
const volScalarField XSgs_ (mixture_.W()*Ygrow_/mixture_.W(growI));
const volScalarField XOxid_(mixture_.W()*Yoxid_/mixture_.W(oxidI));
forAll(rho_, celli)
{

View file

@ -69,9 +69,7 @@ SourceFiles
#include "HashTable.H"
#include "fluidThermo.H"
#include "Reaction.H"
#include "autoPtr.H"
#include "psiChemistryModel.H"
#include "basicSpecieMixture.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -91,6 +89,15 @@ class MossBrookesSoot
{
// Static functions
//- Check mixture in thermo
static const basicSpecieMixture& checkThermo
(
const fluidThermo&
);
// Private data
//- Soot mass fraction
@ -111,6 +118,9 @@ class MossBrookesSoot
//- Thermo package
const fluidThermo& thermo_;
//- Composition
const basicSpecieMixture& mixture_;
//- Net rate of soot generation
volScalarField Snet_;
@ -202,26 +212,8 @@ protected:
// Protected data
//- Pointer to chemistry model
autoPtr<CombThermoType> chemistryPtr_;
// Protected Member Functions
//- Return velocity field U
tmp<volVectorField> U() const;
//- Return nut
tmp<volScalarField> nut() const;
//- Return mole fraction of soot precursor
tmp<volScalarField> XPrec() const;
//- Return mole fraction of soot surface growth specie
tmp<volScalarField> XSgs() const;
//- Return mole fraction of soot oxidation specie
tmp<volScalarField> XOxid() const;
public:
//- Runtime type information

View file

@ -23,11 +23,41 @@ License
\*---------------------------------------------------------------------------*/
#include "fvmLaplacian.H"
#include "fvmDiv.H"
#include "linear.H"
#include "khanGreeveSoot.H"
#include "reactingMixture.H"
#include "fvm.H"
#include "basicSpecieMixture.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
template<class CombThermoType, class ThermoType>
const Foam::basicSpecieMixture&
Foam::radiation::khanGreeveSoot<CombThermoType, ThermoType>::checkThermo
(
const fluidThermo& thermo
)
{
if (isA<basicSpecieMixture>(thermo))
{
return dynamic_cast<const basicSpecieMixture& >
(
thermo
);
}
else
{
FatalErrorInFunction
<< "Inconsistent thermo package for " << thermo.type()
<< "Please select a thermo package based on "
<< "basicSpecieMixture" << exit(FatalError);
return dynamic_cast<const basicSpecieMixture& >
(
thermo
);
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
@ -68,6 +98,7 @@ Foam::radiation::khanGreeveSoot<CombThermoType, ThermoType>::khanGreeveSoot
),
coeffsDict_(dict.subOrEmptyDict(modelType + "Coeffs")),
thermo_(mesh.lookupObject<fluidThermo>(basicThermo::dictName)),
mixture_(checkThermo(thermo_)),
Snet_
(
IOobject
@ -156,8 +187,7 @@ Foam::radiation::khanGreeveSoot<CombThermoType, ThermoType>::khanGreeveSoot
),
eqvMax(readScalar(coeffsDict_.lookup("EquivalenceRatioMax"))),
eqvMin(readScalar(coeffsDict_.lookup("EquivalenceRatioMin"))),
radiationActive_(readBool(coeffsDict_.lookup("Radiationeffect"))),
chemistryPtr_(CombThermoType::New(mesh))
radiationActive_(readBool(coeffsDict_.lookup("Radiationeffect")))
{
}
@ -173,64 +203,6 @@ Foam::radiation::khanGreeveSoot<CombThermoType, ThermoType>::~khanGreeveSoot()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class CombThermoType, class ThermoType>
Foam::tmp<Foam::volScalarField>
Foam::radiation::khanGreeveSoot<CombThermoType, ThermoType>::Yox() const
{
word oxidSpecie(coeffsDict_.lookup("Oxidizer"));
const word *oxidspecie;
oxidspecie = &oxidSpecie;
return Foam::tmp<Foam::volScalarField>(NULL);
}
template<class CombThermoType, class ThermoType>
Foam::tmp<Foam::volScalarField>
Foam::radiation::khanGreeveSoot<CombThermoType, ThermoType>::Yfuel() const
{
word fuelSpecie(coeffsDict_.lookup("Fuel"));
const word *fuelspecie;
fuelspecie = &fuelSpecie;
return Foam::tmp<Foam::volScalarField>(NULL);
}
template<class CombThermoType, class ThermoType>
Foam::tmp<Foam::volScalarField>
Foam::radiation::khanGreeveSoot<CombThermoType, ThermoType>::Xfuel() const
{
word fuelSpecie(coeffsDict_.lookup("Fuel"));
const word *fuelspecie;
fuelspecie = &fuelSpecie;
return Foam::tmp<Foam::volScalarField>(NULL);
}
template<class CombThermoType, class ThermoType>
Foam::tmp<Foam::volScalarField>
Foam::radiation::khanGreeveSoot<CombThermoType, ThermoType>::epsilon() const
{
return Foam::tmp<Foam::volScalarField>(NULL);
}
template<class CombThermoType, class ThermoType>
Foam::tmp<Foam::volScalarField>
Foam::radiation::khanGreeveSoot<CombThermoType, ThermoType>::k() const
{
return Foam::tmp<Foam::volScalarField>(NULL);
}
template<class CombThermoType, class ThermoType>
Foam::tmp<Foam::volVectorField>
Foam::radiation::khanGreeveSoot<CombThermoType, ThermoType>::U() const
{
return Foam::tmp<Foam::volVectorField>(NULL);
}
template<class CombThermoType, class ThermoType>
Foam::tmp<Foam::volScalarField>
Foam::radiation::khanGreeveSoot<CombThermoType, ThermoType>::nut() const
{
return Foam::tmp<Foam::volScalarField>(NULL);
}
template<class CombThermoType, class ThermoType>
Foam::tmp<Foam::volScalarField>
Foam::radiation::khanGreeveSoot<CombThermoType, ThermoType>::a(const label bandI) const
@ -269,6 +241,7 @@ Foam::radiation::khanGreeveSoot<CombThermoType, ThermoType>::a(const label bandI
return tas;
}
template<class CombThermoType, class ThermoType>
Foam::tmp<Foam::volScalarField>
Foam::radiation::khanGreeveSoot<CombThermoType, ThermoType>::e(const label bandI) const
@ -277,36 +250,25 @@ Foam::radiation::khanGreeveSoot<CombThermoType, ThermoType>::e(const label bandI
return a(bandI);
}
template<class CombThermoType, class ThermoType>
void Foam::radiation::khanGreeveSoot<CombThermoType, ThermoType>::correct()
{
calcSource();
const volScalarField rho_ = thermo_.rho();
const volScalarField &rho_ = thermo_.rho();
const volVectorField U_ = U();
const volScalarField &nut_ = turbulence().nut();
const volScalarField nut_ = nut();
const surfaceScalarField phi_
(
IOobject
(
"phi_for_soot",
mesh().time().timeName(),
mesh(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
linearInterpolate(rho_*U_) & mesh().Sf()
);
const surfaceScalarField phi_ (turbulence().phi());
fvScalarMatrix SootEqn
(
fvm::div(phi_, soot_)
- fvm::laplacian((rho_*nut_/PrtSoot), soot_)
==
fvm::ddt(rho_, soot_)
+ fvm::div(phi_, soot_)
- fvm::laplacian((rho_*nut_/PrtSoot), soot_)
==
Snet_
);
@ -334,15 +296,19 @@ void Foam::radiation::khanGreeveSoot<CombThermoType, ThermoType>::calcSource()
const volScalarField T_ = thermo_.T();
const volScalarField p_ = thermo_.p();
const volScalarField Yox_ = Yox();
const scalar oxI = mixture_.species()[coeffsDict_.lookup("Oxidizer")];
const volScalarField Yfuel_ = Yfuel();
const scalar fuelI = mixture_.species()[coeffsDict_.lookup("Fuel")];
const volScalarField Xfuel_ = Xfuel();
const volScalarField &Yox_ = mixture_.Y(oxI);
const volScalarField epsilon_ = epsilon();
const volScalarField &Yfuel_ = mixture_.Y(fuelI);
const volScalarField k_ = k();
const volScalarField Xfuel_(mixture_.W()*Yfuel_/mixture_.W(fuelI));
const volScalarField &epsilon_ = turbulence().epsilon();
const volScalarField &k_ = turbulence().k();
forAll(rho_, celli)
{

View file

@ -64,9 +64,7 @@ SourceFiles
#include "HashTable.H"
#include "fluidThermo.H"
#include "Reaction.H"
#include "autoPtr.H"
#include "psiChemistryModel.H"
#include "basicSpecieMixture.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -86,6 +84,15 @@ class khanGreeveSoot
{
// Static functions
//- Check mixture in thermo
static const basicSpecieMixture& checkThermo
(
const fluidThermo&
);
// Private data
//- Soot mass fraction
@ -100,6 +107,9 @@ class khanGreeveSoot
//- Thermo package
const fluidThermo& thermo_;
//- Composition
const basicSpecieMixture& mixture_;
//- Net rate of soot generation
volScalarField Snet_;
@ -151,36 +161,6 @@ class khanGreeveSoot
//- Soot radiative effect on/off flag
bool radiationActive_;
protected:
// Protected data
//- Pointer to chemistry model
autoPtr<CombThermoType> chemistryPtr_;
// Protected Member Functions
//- Return the oxidizer mass fraction
tmp<volScalarField> Yox() const;
//- Return the fuel mass fraction
tmp<volScalarField> Yfuel() const;
//- Return the mole fraction of the fuel
tmp<volScalarField> Xfuel() const;
//- Return the epsilon
tmp<volScalarField> epsilon() const;
//- Return the k
tmp<volScalarField> k() const;
//- Return the velocity field U
tmp<volVectorField> U() const;
//- Return the nut
tmp<volScalarField> nut() const;
public:
//- Runtime type information

View file

@ -46,7 +46,8 @@ Foam::radiation::sootModel::sootModel
)
:
dict_(dict),
mesh_(mesh)
mesh_(mesh),
turbulence_(mesh.lookupObject<compressibleTurbulenceModel>(turbulenceModel::propertiesName))
{}

View file

@ -66,7 +66,7 @@ protected:
const fvMesh& mesh_;
//- Reference to the turbulence model
compressibleTurbulenceModel* turbulencePtr_;
const compressibleTurbulenceModel &turbulence_;
public:
@ -164,12 +164,6 @@ public:
//- Return access to turbulence
inline const compressibleTurbulenceModel& turbulence() const;
//- Set turbulence
inline void setTurbulence
(
compressibleTurbulenceModel& turbModel
);
};

View file

@ -30,29 +30,7 @@ License
inline const Foam::compressibleTurbulenceModel&
Foam::radiation::sootModel::turbulence() const
{
if (turbulencePtr_)
{
return *turbulencePtr_;
}
else
{
FatalErrorInFunction
<< "turbulencePtr_ is empty. Please use "
<< "sootModel::setTurbulence "
<< "(compressibleTurbulenceModel& )"
<< abort(FatalError);
return *turbulencePtr_;
}
}
inline void Foam::radiation::sootModel::setTurbulence
(
compressibleTurbulenceModel& turbModel
)
{
turbulencePtr_ = &turbModel;
return turbulence_;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //