chemistryModel: General cleanup
This commit is contained in:
parent
6f338ed716
commit
dd0dddf46a
3 changed files with 36 additions and 80 deletions
|
|
@ -2,7 +2,7 @@
|
||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
|
|
@ -57,7 +57,7 @@ Foam::chemistryModel<CompType, ThermoType>::chemistryModel
|
||||||
c_(nSpecie_),
|
c_(nSpecie_),
|
||||||
dcdt_(nSpecie_)
|
dcdt_(nSpecie_)
|
||||||
{
|
{
|
||||||
// create the fields for the chemistry sources
|
// Create the fields for the chemistry sources
|
||||||
forAll(RR_, fieldi)
|
forAll(RR_, fieldi)
|
||||||
{
|
{
|
||||||
RR_.set
|
RR_.set
|
||||||
|
|
@ -148,7 +148,6 @@ Foam::scalar Foam::chemistryModel<CompType, ThermoType>::omegaI
|
||||||
label& rRef
|
label& rRef
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
|
|
||||||
const Reaction<ThermoType>& R = reactions_[index];
|
const Reaction<ThermoType>& R = reactions_[index];
|
||||||
scalar w = omega(R, c, T, p, pf, cf, lRef, pr, cr, rRef);
|
scalar w = omega(R, c, T, p, pf, cf, lRef, pr, cr, rRef);
|
||||||
return(w);
|
return(w);
|
||||||
|
|
@ -224,7 +223,7 @@ Foam::scalar Foam::chemistryModel<CompType, ThermoType>::omega
|
||||||
label srRef = 0;
|
label srRef = 0;
|
||||||
rRef = R.rhs()[srRef].index;
|
rRef = R.rhs()[srRef].index;
|
||||||
|
|
||||||
// find the matrix element and element position for the rhs
|
// Find the matrix element and element position for the rhs
|
||||||
pr = kr;
|
pr = kr;
|
||||||
for (label s = 1; s < Nr; s++)
|
for (label s = 1; s < Nr; s++)
|
||||||
{
|
{
|
||||||
|
|
@ -285,7 +284,7 @@ void Foam::chemistryModel<CompType, ThermoType>::derivatives
|
||||||
|
|
||||||
omega(c_, T, p, dcdt);
|
omega(c_, T, p, dcdt);
|
||||||
|
|
||||||
// constant pressure
|
// Constant pressure
|
||||||
// dT/dt = ...
|
// dT/dt = ...
|
||||||
scalar rho = 0.0;
|
scalar rho = 0.0;
|
||||||
scalar cSum = 0.0;
|
scalar cSum = 0.0;
|
||||||
|
|
@ -463,23 +462,6 @@ template<class CompType, class ThermoType>
|
||||||
Foam::tmp<Foam::volScalarField>
|
Foam::tmp<Foam::volScalarField>
|
||||||
Foam::chemistryModel<CompType, ThermoType>::tc() const
|
Foam::chemistryModel<CompType, ThermoType>::tc() const
|
||||||
{
|
{
|
||||||
scalar pf, cf, pr, cr;
|
|
||||||
label lRef, rRef;
|
|
||||||
|
|
||||||
const volScalarField rho
|
|
||||||
(
|
|
||||||
IOobject
|
|
||||||
(
|
|
||||||
"rho",
|
|
||||||
this->time().timeName(),
|
|
||||||
this->mesh(),
|
|
||||||
IOobject::NO_READ,
|
|
||||||
IOobject::NO_WRITE,
|
|
||||||
false
|
|
||||||
),
|
|
||||||
this->thermo().rho()
|
|
||||||
);
|
|
||||||
|
|
||||||
tmp<volScalarField> ttc
|
tmp<volScalarField> ttc
|
||||||
(
|
(
|
||||||
new volScalarField
|
new volScalarField
|
||||||
|
|
@ -500,24 +482,31 @@ Foam::chemistryModel<CompType, ThermoType>::tc() const
|
||||||
);
|
);
|
||||||
|
|
||||||
scalarField& tc = ttc.ref();
|
scalarField& tc = ttc.ref();
|
||||||
|
|
||||||
|
tmp<volScalarField> trho(this->thermo().rho());
|
||||||
|
const scalarField& rho = trho();
|
||||||
|
|
||||||
const scalarField& T = this->thermo().T();
|
const scalarField& T = this->thermo().T();
|
||||||
const scalarField& p = this->thermo().p();
|
const scalarField& p = this->thermo().p();
|
||||||
|
|
||||||
const label nReaction = reactions_.size();
|
const label nReaction = reactions_.size();
|
||||||
|
|
||||||
|
scalar pf, cf, pr, cr;
|
||||||
|
label lRef, rRef;
|
||||||
|
|
||||||
if (this->chemistry_)
|
if (this->chemistry_)
|
||||||
{
|
{
|
||||||
forAll(rho, celli)
|
forAll(rho, celli)
|
||||||
{
|
{
|
||||||
scalar rhoi = rho[celli];
|
const scalar rhoi = rho[celli];
|
||||||
scalar Ti = T[celli];
|
const scalar Ti = T[celli];
|
||||||
scalar pi = p[celli];
|
const scalar pi = p[celli];
|
||||||
|
|
||||||
scalar cSum = 0.0;
|
scalar cSum = 0.0;
|
||||||
|
|
||||||
for (label i=0; i<nSpecie_; i++)
|
for (label i=0; i<nSpecie_; i++)
|
||||||
{
|
{
|
||||||
scalar Yi = Y_[i][celli];
|
c_[i] = rhoi*Y_[i][celli]/specieThermo_[i].W();
|
||||||
c_[i] = rhoi*Yi/specieThermo_[i].W();
|
|
||||||
cSum += c_[i];
|
cSum += c_[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -529,10 +518,10 @@ Foam::chemistryModel<CompType, ThermoType>::tc() const
|
||||||
|
|
||||||
forAll(R.rhs(), s)
|
forAll(R.rhs(), s)
|
||||||
{
|
{
|
||||||
scalar sr = R.rhs()[s].stoichCoeff;
|
tc[celli] += R.rhs()[s].stoichCoeff*pf*cf;
|
||||||
tc[celli] += sr*pf*cf;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tc[celli] = nReaction*cSum/tc[celli];
|
tc[celli] = nReaction*cSum/tc[celli];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -583,14 +572,6 @@ Foam::chemistryModel<CompType, ThermoType>::Qdot() const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class CompType, class ThermoType>
|
|
||||||
Foam::label Foam::chemistryModel<CompType, ThermoType>::nEqns() const
|
|
||||||
{
|
|
||||||
// nEqns = number of species + temperature + pressure
|
|
||||||
return nSpecie_ + 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class CompType, class ThermoType>
|
template<class CompType, class ThermoType>
|
||||||
Foam::tmp<Foam::DimensionedField<Foam::scalar, Foam::volMesh>>
|
Foam::tmp<Foam::DimensionedField<Foam::scalar, Foam::volMesh>>
|
||||||
Foam::chemistryModel<CompType, ThermoType>::calculateRR
|
Foam::chemistryModel<CompType, ThermoType>::calculateRR
|
||||||
|
|
@ -602,20 +583,6 @@ Foam::chemistryModel<CompType, ThermoType>::calculateRR
|
||||||
scalar pf, cf, pr, cr;
|
scalar pf, cf, pr, cr;
|
||||||
label lRef, rRef;
|
label lRef, rRef;
|
||||||
|
|
||||||
const volScalarField rho
|
|
||||||
(
|
|
||||||
IOobject
|
|
||||||
(
|
|
||||||
"rho",
|
|
||||||
this->time().timeName(),
|
|
||||||
this->mesh(),
|
|
||||||
IOobject::NO_READ,
|
|
||||||
IOobject::NO_WRITE,
|
|
||||||
false
|
|
||||||
),
|
|
||||||
this->thermo().rho()
|
|
||||||
);
|
|
||||||
|
|
||||||
tmp<volScalarField::Internal> tRR
|
tmp<volScalarField::Internal> tRR
|
||||||
(
|
(
|
||||||
new volScalarField::Internal
|
new volScalarField::Internal
|
||||||
|
|
@ -635,6 +602,9 @@ Foam::chemistryModel<CompType, ThermoType>::calculateRR
|
||||||
|
|
||||||
volScalarField::Internal& RR = tRR.ref();
|
volScalarField::Internal& RR = tRR.ref();
|
||||||
|
|
||||||
|
tmp<volScalarField> trho(this->thermo().rho());
|
||||||
|
const scalarField& rho = trho();
|
||||||
|
|
||||||
const scalarField& T = this->thermo().T();
|
const scalarField& T = this->thermo().T();
|
||||||
const scalarField& p = this->thermo().p();
|
const scalarField& p = this->thermo().p();
|
||||||
|
|
||||||
|
|
@ -679,19 +649,8 @@ void Foam::chemistryModel<CompType, ThermoType>::calculate()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const volScalarField rho
|
tmp<volScalarField> trho(this->thermo().rho());
|
||||||
(
|
const scalarField& rho = trho();
|
||||||
IOobject
|
|
||||||
(
|
|
||||||
"rho",
|
|
||||||
this->time().timeName(),
|
|
||||||
this->mesh(),
|
|
||||||
IOobject::NO_READ,
|
|
||||||
IOobject::NO_WRITE,
|
|
||||||
false
|
|
||||||
),
|
|
||||||
this->thermo().rho()
|
|
||||||
);
|
|
||||||
|
|
||||||
const scalarField& T = this->thermo().T();
|
const scalarField& T = this->thermo().T();
|
||||||
const scalarField& p = this->thermo().p();
|
const scalarField& p = this->thermo().p();
|
||||||
|
|
@ -734,19 +693,8 @@ Foam::scalar Foam::chemistryModel<CompType, ThermoType>::solve
|
||||||
return deltaTMin;
|
return deltaTMin;
|
||||||
}
|
}
|
||||||
|
|
||||||
const volScalarField rho
|
tmp<volScalarField> trho(this->thermo().rho());
|
||||||
(
|
const scalarField& rho = trho();
|
||||||
IOobject
|
|
||||||
(
|
|
||||||
"rho",
|
|
||||||
this->time().timeName(),
|
|
||||||
this->mesh(),
|
|
||||||
IOobject::NO_READ,
|
|
||||||
IOobject::NO_WRITE,
|
|
||||||
false
|
|
||||||
),
|
|
||||||
this->thermo().rho()
|
|
||||||
);
|
|
||||||
|
|
||||||
const scalarField& T = this->thermo().T();
|
const scalarField& T = this->thermo().T();
|
||||||
const scalarField& p = this->thermo().p();
|
const scalarField& p = this->thermo().p();
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
|
|
@ -238,7 +238,7 @@ public:
|
||||||
// ODE functions (overriding abstract functions in ODE.H)
|
// ODE functions (overriding abstract functions in ODE.H)
|
||||||
|
|
||||||
//- Number of ODE's to solve
|
//- Number of ODE's to solve
|
||||||
virtual label nEqns() const;
|
inline virtual label nEqns() const;
|
||||||
|
|
||||||
virtual void derivatives
|
virtual void derivatives
|
||||||
(
|
(
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
|
|
@ -28,6 +28,14 @@ License
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class CompType, class ThermoType>
|
||||||
|
inline Foam::label Foam::chemistryModel<CompType, ThermoType>::nEqns() const
|
||||||
|
{
|
||||||
|
// nEqns = number of species + temperature + pressure
|
||||||
|
return nSpecie_ + 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class CompType, class ThermoType>
|
template<class CompType, class ThermoType>
|
||||||
inline Foam::PtrList<Foam::DimensionedField<Foam::scalar, Foam::volMesh>>&
|
inline Foam::PtrList<Foam::DimensionedField<Foam::scalar, Foam::volMesh>>&
|
||||||
Foam::chemistryModel<CompType, ThermoType>::RR()
|
Foam::chemistryModel<CompType, ThermoType>::RR()
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue