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:
@ -151,7 +151,7 @@ Foam::scalar Foam::ODEChemistryModel<CompType, ThermoType>::omega
|
||||
) const
|
||||
{
|
||||
scalarField c2(nSpecie_, 0.0);
|
||||
for (label i=0; i<nSpecie_; i++)
|
||||
for (label i = 0; i < nSpecie_; i++)
|
||||
{
|
||||
c2[i] = max(0.0, c[i]);
|
||||
}
|
||||
@ -169,7 +169,7 @@ Foam::scalar Foam::ODEChemistryModel<CompType, ThermoType>::omega
|
||||
lRef = R.lhs()[slRef].index;
|
||||
|
||||
pf = kf;
|
||||
for (label s=1; s<Nl; s++)
|
||||
for (label s = 1; s < Nl; s++)
|
||||
{
|
||||
const label si = R.lhs()[s].index;
|
||||
|
||||
@ -212,7 +212,7 @@ Foam::scalar Foam::ODEChemistryModel<CompType, ThermoType>::omega
|
||||
|
||||
// find the matrix element and element position for the rhs
|
||||
pr = kr;
|
||||
for (label s=1; s<Nr; s++)
|
||||
for (label s = 1; s < Nr; s++)
|
||||
{
|
||||
const label si = R.rhs()[s].index;
|
||||
if (c[si] < c[rRef])
|
||||
@ -270,7 +270,7 @@ void Foam::ODEChemistryModel<CompType, ThermoType>::derivatives
|
||||
// dT/dt = ...
|
||||
scalar rho = 0.0;
|
||||
scalar cSum = 0.0;
|
||||
for (label i=0; i<nSpecie_; i++)
|
||||
for (label i = 0; i < nSpecie_; i++)
|
||||
{
|
||||
const scalar W = specieThermo_[i].W();
|
||||
cSum += c[i];
|
||||
@ -287,7 +287,7 @@ void Foam::ODEChemistryModel<CompType, ThermoType>::derivatives
|
||||
cp /= mw;
|
||||
|
||||
scalar dT = 0.0;
|
||||
for (label i=0; i<nSpecie_; i++)
|
||||
for (label i = 0; i < nSpecie_; i++)
|
||||
{
|
||||
const scalar hi = specieThermo_[i].h(T);
|
||||
dT += hi*dcdt[i];
|
||||
@ -552,6 +552,7 @@ Foam::ODEChemistryModel<CompType, ThermoType>::Sh() const
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
if (this->chemistry_)
|
||||
{
|
||||
scalarField& Sh = tSh();
|
||||
@ -560,7 +561,7 @@ Foam::ODEChemistryModel<CompType, ThermoType>::Sh() const
|
||||
{
|
||||
forAll(Sh, cellI)
|
||||
{
|
||||
scalar hi = specieThermo_[i].Hc();
|
||||
const scalar hi = specieThermo_[i].Hc();
|
||||
Sh[cellI] -= hi*RR_[i][cellI];
|
||||
}
|
||||
}
|
||||
@ -734,7 +735,7 @@ Foam::scalar Foam::ODEChemistryModel<CompType, ThermoType>::solve
|
||||
t += dt;
|
||||
|
||||
// update the temperature
|
||||
scalar cTot = sum(c);
|
||||
const scalar cTot = sum(c);
|
||||
ThermoType mixture(0.0*specieThermo_[0]);
|
||||
for (label i=0; i<nSpecie_; i++)
|
||||
{
|
||||
|
||||
@ -39,7 +39,7 @@ Foam::EulerImplicit<CompType, ThermoType>::EulerImplicit
|
||||
chemistrySolver<CompType, ThermoType>(model, modelName),
|
||||
coeffsDict_(model.subDict(modelName + "Coeffs")),
|
||||
cTauChem_(readScalar(coeffsDict_.lookup("cTauChem"))),
|
||||
equil_(coeffsDict_.lookup("equilibriumRateLimiter"))
|
||||
eqRateLimiter_(coeffsDict_.lookup("equilibriumRateLimiter"))
|
||||
{}
|
||||
|
||||
|
||||
@ -65,12 +65,12 @@ Foam::scalar Foam::EulerImplicit<CompType, ThermoType>::solve
|
||||
const label nSpecie = this->model_.nSpecie();
|
||||
simpleMatrix<scalar> RR(nSpecie, 0, 0);
|
||||
|
||||
for (label i=0; i<nSpecie; i++)
|
||||
for (label i = 0; i < nSpecie; i++)
|
||||
{
|
||||
c[i] = max(0.0, c[i]);
|
||||
}
|
||||
|
||||
for (label i=0; i<nSpecie; i++)
|
||||
for (label i = 0; i < nSpecie; i++)
|
||||
{
|
||||
RR.source()[i] = c[i]/dt;
|
||||
}
|
||||
@ -88,9 +88,9 @@ Foam::scalar Foam::EulerImplicit<CompType, ThermoType>::solve
|
||||
);
|
||||
|
||||
scalar corr = 1.0;
|
||||
if (equil_)
|
||||
if (eqRateLimiter_)
|
||||
{
|
||||
if (omegai<0.0)
|
||||
if (omegai < 0.0)
|
||||
{
|
||||
corr = 1.0/(1.0 + pr*dt);
|
||||
}
|
||||
@ -100,31 +100,31 @@ Foam::scalar Foam::EulerImplicit<CompType, ThermoType>::solve
|
||||
}
|
||||
}
|
||||
|
||||
forAll(R.lhs(), s)
|
||||
forAll(R.lhs(), specieI)
|
||||
{
|
||||
label si = R.lhs()[s].index;
|
||||
scalar sl = R.lhs()[s].stoichCoeff;
|
||||
RR[si][rRef] -= sl*pr*corr;
|
||||
RR[si][lRef] += sl*pf*corr;
|
||||
const label id = R.lhs()[specieI].index;
|
||||
const scalar sc = R.lhs()[specieI].stoichCoeff;
|
||||
RR[id][rRef] -= sc*pr*corr;
|
||||
RR[id][lRef] += sc*pf*corr;
|
||||
}
|
||||
|
||||
forAll(R.rhs(), s)
|
||||
forAll(R.rhs(), specieI)
|
||||
{
|
||||
label si = R.rhs()[s].index;
|
||||
scalar sr = R.rhs()[s].stoichCoeff;
|
||||
RR[si][lRef] -= sr*pf*corr;
|
||||
RR[si][rRef] += sr*pr*corr;
|
||||
const label id = R.rhs()[specieI].index;
|
||||
const scalar sc = R.rhs()[specieI].stoichCoeff;
|
||||
RR[id][lRef] -= sc*pf*corr;
|
||||
RR[id][rRef] += sc*pr*corr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (label i=0; i<nSpecie; i++)
|
||||
for (label i = 0; i < nSpecie; i++)
|
||||
{
|
||||
RR[i][i] += 1.0/dt;
|
||||
}
|
||||
|
||||
c = RR.LUsolve();
|
||||
for (label i=0; i<nSpecie; i++)
|
||||
for (label i = 0; i < nSpecie; i++)
|
||||
{
|
||||
c[i] = max(0.0, c[i]);
|
||||
}
|
||||
@ -134,7 +134,7 @@ Foam::scalar Foam::EulerImplicit<CompType, ThermoType>::solve
|
||||
const label nEqns = this->model_.nEqns();
|
||||
scalarField c1(nEqns, 0.0);
|
||||
|
||||
for (label i=0; i<nSpecie; i++)
|
||||
for (label i = 0; i < nSpecie; i++)
|
||||
{
|
||||
c1[i] = c[i];
|
||||
}
|
||||
@ -144,9 +144,9 @@ Foam::scalar Foam::EulerImplicit<CompType, ThermoType>::solve
|
||||
scalarField dcdt(nEqns, 0.0);
|
||||
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++)
|
||||
{
|
||||
scalar d = dcdt[i];
|
||||
if (d < -SMALL)
|
||||
|
||||
@ -57,12 +57,17 @@ class EulerImplicit
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Coefficients dictionary
|
||||
dictionary coeffsDict_;
|
||||
|
||||
|
||||
// Model constants
|
||||
|
||||
//- Chemistry timescale
|
||||
scalar cTauChem_;
|
||||
Switch equil_;
|
||||
|
||||
//- Equilibrium rate limiter flag (on/off)
|
||||
Switch eqRateLimiter_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
@ -38,7 +38,7 @@ Foam::sequential<CompType, ThermoType>::sequential
|
||||
chemistrySolver<CompType, ThermoType>(model, modelName),
|
||||
coeffsDict_(model.subDict(modelName + "Coeffs")),
|
||||
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];
|
||||
|
||||
scalar om0 = this->model_.omega
|
||||
scalar omega = this->model_.omega
|
||||
(
|
||||
R, c, T, p, pf, cf, lRef, pb, cb, rRef
|
||||
);
|
||||
|
||||
scalar omeg = 0.0;
|
||||
if (!equil_)
|
||||
if (eqRateLimiter_)
|
||||
{
|
||||
omeg = om0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (om0<0.0)
|
||||
if (omega < 0.0)
|
||||
{
|
||||
omeg = om0/(1.0 + pb*dt);
|
||||
omega /= 1.0 + pb*dt;
|
||||
}
|
||||
else
|
||||
{
|
||||
omeg = om0/(1.0 + pf*dt);
|
||||
omega /= 1.0 + pf*dt;
|
||||
}
|
||||
}
|
||||
tChemInv = max(tChemInv, mag(omeg));
|
||||
|
||||
tChemInv = max(tChemInv, mag(omega));
|
||||
|
||||
|
||||
// update species
|
||||
forAll(R.lhs(), s)
|
||||
forAll(R.lhs(), specieI)
|
||||
{
|
||||
label si = R.lhs()[s].index;
|
||||
scalar sl = R.lhs()[s].stoichCoeff;
|
||||
c[si] -= dt*sl*omeg;
|
||||
c[si] = max(0.0, c[si]);
|
||||
const label id = R.lhs()[specieI].index;
|
||||
const scalar sc = R.lhs()[specieI].stoichCoeff;
|
||||
c[id] -= dt*sc*omega;
|
||||
c[id] = max(0.0, c[id]);
|
||||
}
|
||||
|
||||
forAll(R.rhs(), s)
|
||||
forAll(R.rhs(), specieI)
|
||||
{
|
||||
label si = R.rhs()[s].index;
|
||||
scalar sr = R.rhs()[s].stoichCoeff;
|
||||
c[si] += dt*sr*omeg;
|
||||
c[si] = max(0.0, c[si]);
|
||||
const label id = R.rhs()[specieI].index;
|
||||
const scalar sc = R.rhs()[specieI].stoichCoeff;
|
||||
c[id] += dt*sc*omega;
|
||||
c[id] = max(0.0, c[id]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -59,12 +59,17 @@ class sequential
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Coefficients dictionary
|
||||
dictionary coeffsDict_;
|
||||
|
||||
|
||||
// Model constants
|
||||
|
||||
//- Chemistry time scale
|
||||
scalar cTauChem_;
|
||||
Switch equil_;
|
||||
|
||||
//- Equilibrium rate limiter flag (on/off)
|
||||
Switch eqRateLimiter_;
|
||||
|
||||
|
||||
public:
|
||||
@ -75,7 +80,6 @@ public:
|
||||
|
||||
// Constructors
|
||||
|
||||
|
||||
//- Construct from components
|
||||
sequential
|
||||
(
|
||||
|
||||
Reference in New Issue
Block a user