mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
STYLE: code clean-up/restructure
This commit is contained in:
@ -552,6 +552,7 @@ Foam::ODEChemistryModel<CompType, ThermoType>::Sh() const
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
if (this->chemistry_)
|
if (this->chemistry_)
|
||||||
{
|
{
|
||||||
scalarField& Sh = tSh();
|
scalarField& Sh = tSh();
|
||||||
@ -560,7 +561,7 @@ Foam::ODEChemistryModel<CompType, ThermoType>::Sh() const
|
|||||||
{
|
{
|
||||||
forAll(Sh, cellI)
|
forAll(Sh, cellI)
|
||||||
{
|
{
|
||||||
scalar hi = specieThermo_[i].Hc();
|
const scalar hi = specieThermo_[i].Hc();
|
||||||
Sh[cellI] -= hi*RR_[i][cellI];
|
Sh[cellI] -= hi*RR_[i][cellI];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -734,7 +735,7 @@ Foam::scalar Foam::ODEChemistryModel<CompType, ThermoType>::solve
|
|||||||
t += dt;
|
t += dt;
|
||||||
|
|
||||||
// update the temperature
|
// update the temperature
|
||||||
scalar cTot = sum(c);
|
const scalar cTot = sum(c);
|
||||||
ThermoType mixture(0.0*specieThermo_[0]);
|
ThermoType mixture(0.0*specieThermo_[0]);
|
||||||
for (label i=0; i<nSpecie_; i++)
|
for (label i=0; i<nSpecie_; i++)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -39,7 +39,7 @@ Foam::EulerImplicit<CompType, ThermoType>::EulerImplicit
|
|||||||
chemistrySolver<CompType, ThermoType>(model, modelName),
|
chemistrySolver<CompType, ThermoType>(model, modelName),
|
||||||
coeffsDict_(model.subDict(modelName + "Coeffs")),
|
coeffsDict_(model.subDict(modelName + "Coeffs")),
|
||||||
cTauChem_(readScalar(coeffsDict_.lookup("cTauChem"))),
|
cTauChem_(readScalar(coeffsDict_.lookup("cTauChem"))),
|
||||||
equil_(coeffsDict_.lookup("equilibriumRateLimiter"))
|
eqRateLimiter_(coeffsDict_.lookup("equilibriumRateLimiter"))
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
@ -88,7 +88,7 @@ Foam::scalar Foam::EulerImplicit<CompType, ThermoType>::solve
|
|||||||
);
|
);
|
||||||
|
|
||||||
scalar corr = 1.0;
|
scalar corr = 1.0;
|
||||||
if (equil_)
|
if (eqRateLimiter_)
|
||||||
{
|
{
|
||||||
if (omegai < 0.0)
|
if (omegai < 0.0)
|
||||||
{
|
{
|
||||||
@ -100,20 +100,20 @@ Foam::scalar Foam::EulerImplicit<CompType, ThermoType>::solve
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
forAll(R.lhs(), s)
|
forAll(R.lhs(), specieI)
|
||||||
{
|
{
|
||||||
label si = R.lhs()[s].index;
|
const label id = R.lhs()[specieI].index;
|
||||||
scalar sl = R.lhs()[s].stoichCoeff;
|
const scalar sc = R.lhs()[specieI].stoichCoeff;
|
||||||
RR[si][rRef] -= sl*pr*corr;
|
RR[id][rRef] -= sc*pr*corr;
|
||||||
RR[si][lRef] += sl*pf*corr;
|
RR[id][lRef] += sc*pf*corr;
|
||||||
}
|
}
|
||||||
|
|
||||||
forAll(R.rhs(), s)
|
forAll(R.rhs(), specieI)
|
||||||
{
|
{
|
||||||
label si = R.rhs()[s].index;
|
const label id = R.rhs()[specieI].index;
|
||||||
scalar sr = R.rhs()[s].stoichCoeff;
|
const scalar sc = R.rhs()[specieI].stoichCoeff;
|
||||||
RR[si][lRef] -= sr*pf*corr;
|
RR[id][lRef] -= sc*pf*corr;
|
||||||
RR[si][rRef] += sr*pr*corr;
|
RR[id][rRef] += sc*pr*corr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -144,7 +144,7 @@ Foam::scalar Foam::EulerImplicit<CompType, ThermoType>::solve
|
|||||||
scalarField dcdt(nEqns, 0.0);
|
scalarField dcdt(nEqns, 0.0);
|
||||||
this->model_.derivatives(0.0, c1, dcdt);
|
this->model_.derivatives(0.0, c1, dcdt);
|
||||||
|
|
||||||
scalar sumC = sum(c);
|
const scalar sumC = sum(c);
|
||||||
|
|
||||||
for (label i = 0; i < nSpecie; i++)
|
for (label i = 0; i < nSpecie; i++)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -57,12 +57,17 @@ class EulerImplicit
|
|||||||
{
|
{
|
||||||
// Private data
|
// Private data
|
||||||
|
|
||||||
|
//- Coefficients dictionary
|
||||||
dictionary coeffsDict_;
|
dictionary coeffsDict_;
|
||||||
|
|
||||||
|
|
||||||
// Model constants
|
// Model constants
|
||||||
|
|
||||||
|
//- Chemistry timescale
|
||||||
scalar cTauChem_;
|
scalar cTauChem_;
|
||||||
Switch equil_;
|
|
||||||
|
//- Equilibrium rate limiter flag (on/off)
|
||||||
|
Switch eqRateLimiter_;
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|||||||
@ -38,7 +38,7 @@ Foam::sequential<CompType, ThermoType>::sequential
|
|||||||
chemistrySolver<CompType, ThermoType>(model, modelName),
|
chemistrySolver<CompType, ThermoType>(model, modelName),
|
||||||
coeffsDict_(model.subDict(modelName + "Coeffs")),
|
coeffsDict_(model.subDict(modelName + "Coeffs")),
|
||||||
cTauChem_(readScalar(coeffsDict_.lookup("cTauChem"))),
|
cTauChem_(readScalar(coeffsDict_.lookup("cTauChem"))),
|
||||||
equil_(coeffsDict_.lookup("equilibriumRateLimiter"))
|
eqRateLimiter_(coeffsDict_.lookup("equilibriumRateLimiter"))
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
@ -70,45 +70,41 @@ Foam::scalar Foam::sequential<CompType, ThermoType>::solve
|
|||||||
{
|
{
|
||||||
const Reaction<ThermoType>& R = this->model_.reactions()[i];
|
const Reaction<ThermoType>& R = this->model_.reactions()[i];
|
||||||
|
|
||||||
scalar om0 = this->model_.omega
|
scalar omega = this->model_.omega
|
||||||
(
|
(
|
||||||
R, c, T, p, pf, cf, lRef, pb, cb, rRef
|
R, c, T, p, pf, cf, lRef, pb, cb, rRef
|
||||||
);
|
);
|
||||||
|
|
||||||
scalar omeg = 0.0;
|
if (eqRateLimiter_)
|
||||||
if (!equil_)
|
|
||||||
{
|
{
|
||||||
omeg = om0;
|
if (omega < 0.0)
|
||||||
|
{
|
||||||
|
omega /= 1.0 + pb*dt;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (om0<0.0)
|
omega /= 1.0 + pf*dt;
|
||||||
{
|
|
||||||
omeg = om0/(1.0 + pb*dt);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
omeg = om0/(1.0 + pf*dt);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tChemInv = max(tChemInv, mag(omeg));
|
|
||||||
|
tChemInv = max(tChemInv, mag(omega));
|
||||||
|
|
||||||
|
|
||||||
// update species
|
// update species
|
||||||
forAll(R.lhs(), s)
|
forAll(R.lhs(), specieI)
|
||||||
{
|
{
|
||||||
label si = R.lhs()[s].index;
|
const label id = R.lhs()[specieI].index;
|
||||||
scalar sl = R.lhs()[s].stoichCoeff;
|
const scalar sc = R.lhs()[specieI].stoichCoeff;
|
||||||
c[si] -= dt*sl*omeg;
|
c[id] -= dt*sc*omega;
|
||||||
c[si] = max(0.0, c[si]);
|
c[id] = max(0.0, c[id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
forAll(R.rhs(), s)
|
forAll(R.rhs(), specieI)
|
||||||
{
|
{
|
||||||
label si = R.rhs()[s].index;
|
const label id = R.rhs()[specieI].index;
|
||||||
scalar sr = R.rhs()[s].stoichCoeff;
|
const scalar sc = R.rhs()[specieI].stoichCoeff;
|
||||||
c[si] += dt*sr*omeg;
|
c[id] += dt*sc*omega;
|
||||||
c[si] = max(0.0, c[si]);
|
c[id] = max(0.0, c[id]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -59,12 +59,17 @@ class sequential
|
|||||||
{
|
{
|
||||||
// Private data
|
// Private data
|
||||||
|
|
||||||
|
//- Coefficients dictionary
|
||||||
dictionary coeffsDict_;
|
dictionary coeffsDict_;
|
||||||
|
|
||||||
|
|
||||||
// Model constants
|
// Model constants
|
||||||
|
|
||||||
|
//- Chemistry time scale
|
||||||
scalar cTauChem_;
|
scalar cTauChem_;
|
||||||
Switch equil_;
|
|
||||||
|
//- Equilibrium rate limiter flag (on/off)
|
||||||
|
Switch eqRateLimiter_;
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -75,7 +80,6 @@ public:
|
|||||||
|
|
||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
|
|
||||||
//- Construct from components
|
//- Construct from components
|
||||||
sequential
|
sequential
|
||||||
(
|
(
|
||||||
|
|||||||
Reference in New Issue
Block a user