chemistryModel: Refactored interface to chemistry reduction

in preparation for un-templating ISAT
This commit is contained in:
Henry Weller
2022-01-18 22:06:04 +00:00
parent 427307c190
commit a3f7c38835
12 changed files with 107 additions and 88 deletions

View File

@ -867,7 +867,14 @@ Foam::scalar Foam::chemistryModel<ThermoType>::solve
Rphiq[Rphiq.size()-2] = p; Rphiq[Rphiq.size()-2] = p;
Rphiq[Rphiq.size()-1] = deltaT[celli]; Rphiq[Rphiq.size()-1] = deltaT[celli];
tabulation_.add(phiq, Rphiq, celli, rho0, deltaT[celli]); tabulation_.add
(
phiq,
Rphiq,
mechRed_.nActiveSpecies(),
celli,
deltaT[celli]
);
} }
// When operations are done and if mechanism reduction is active, // When operations are done and if mechanism reduction is active,

View File

@ -330,9 +330,8 @@ public:
// Mechanism reduction access functions // Mechanism reduction access functions
//- Return access to the mechanism reduction method //- Return true if mechanism reduction is active
// Needed by ISAT inline bool reduction() const;
inline const chemistryReductionMethod<ThermoType>& mechRed() const;
//- Allow the reduction method to reset the number of species //- Allow the reduction method to reset the number of species
inline void setNSpecie(const label newNs); inline void setNSpecie(const label newNs);

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2016-2021 OpenFOAM Foundation \\ / A nd | Copyright (C) 2016-2022 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -119,10 +119,9 @@ Foam::chemistryModel<ThermoType>::Y() const
template<class ThermoType> template<class ThermoType>
inline const Foam::chemistryReductionMethod<ThermoType>& inline bool Foam::chemistryModel<ThermoType>::reduction() const
Foam::chemistryModel<ThermoType>::mechRed() const
{ {
return mechRed_; return mechRedActive_;
} }

View File

@ -43,6 +43,7 @@ Foam::chemistryTabulationMethods::ISAT<ThermoType>::ISAT
coeffsDict_(chemistryProperties.subDict("tabulation")), coeffsDict_(chemistryProperties.subDict("tabulation")),
chemistry_(chemistry), chemistry_(chemistry),
log_(coeffsDict_.lookupOrDefault<Switch>("log", false)), log_(coeffsDict_.lookupOrDefault<Switch>("log", false)),
reduction_(chemistry_.reduction()),
chemisTree_(*this, coeffsDict_), chemisTree_(*this, coeffsDict_),
scaleFactor_(chemistry.nEqns() + 1, 1), scaleFactor_(chemistry.nEqns() + 1, 1),
runTime_(chemistry.time()), runTime_(chemistry.time()),
@ -198,7 +199,6 @@ void Foam::chemistryTabulationMethods::ISAT<ThermoType>::calcNewC
) )
{ {
const label nEqns = chemistry_.nEqns(); // Species, T, p const label nEqns = chemistry_.nEqns(); // Species, T, p
const bool mechRedActive = chemistry_.mechRed().active();
const List<label>& completeToSimplified = phi0->completeToSimplifiedIndex(); const List<label>& completeToSimplified = phi0->completeToSimplifiedIndex();
const scalarField dphi(phiq - phi0->phi()); const scalarField dphi(phiq - phi0->phi());
@ -213,12 +213,12 @@ void Foam::chemistryTabulationMethods::ISAT<ThermoType>::calcNewC
Rphiq = phi0->Rphi(); Rphiq = phi0->Rphi();
for (label i=0; i<nEqns + 1; i++) for (label i=0; i<nEqns + 1; i++)
{ {
if (mechRedActive) if (reduction_)
{ {
const label si = const label si =
i < nEqns - 2 i < nEqns - 2
? completeToSimplified[i] ? completeToSimplified[i]
: i - (nEqns - 2) + phi0->nActiveSpecies(); : i - (nEqns - 2) + phi0->nActive();
if (si != -1) if (si != -1)
{ {
@ -229,7 +229,7 @@ void Foam::chemistryTabulationMethods::ISAT<ThermoType>::calcNewC
const label sj = const label sj =
j < nEqns - 2 j < nEqns - 2
? completeToSimplified[j] ? completeToSimplified[j]
: j - (nEqns - 2) + phi0->nActiveSpecies(); : j - (nEqns - 2) + phi0->nActive();
if (sj != -1) if (sj != -1)
{ {
@ -490,6 +490,7 @@ Foam::label Foam::chemistryTabulationMethods::ISAT<ThermoType>::add
( (
const scalarField& phiq, const scalarField& phiq,
const scalarField& Rphiq, const scalarField& Rphiq,
const label nActive,
const label li, const label li,
const scalar deltaT const scalar deltaT
) )
@ -568,6 +569,7 @@ Foam::label Foam::chemistryTabulationMethods::ISAT<ThermoType>::add
scaleFactor(), scaleFactor(),
tolerance_, tolerance_,
scaleFactor_.size(), scaleFactor_.size(),
nActive,
nulPhi nulPhi
); );
deleteDemandDrivenData(tempList[i]); deleteDemandDrivenData(tempList[i]);
@ -592,6 +594,7 @@ Foam::label Foam::chemistryTabulationMethods::ISAT<ThermoType>::add
scaleFactor(), scaleFactor(),
tolerance_, tolerance_,
scaleFactor_.size(), scaleFactor_.size(),
nActive,
lastSearch_ // lastSearch_ may be nullptr (handled by binaryTree) lastSearch_ // lastSearch_ may be nullptr (handled by binaryTree)
); );
if (lastSearch_ != nullptr) if (lastSearch_ != nullptr)

View File

@ -68,6 +68,9 @@ class ISAT
//- Switch to select performance logging //- Switch to select performance logging
Switch log_; Switch log_;
//- Is reduction applied to the state vectors
const bool reduction_;
//- List of the stored 'points' organised in a binary tree //- List of the stored 'points' organised in a binary tree
binaryTree<ThermoType> chemisTree_; binaryTree<ThermoType> chemisTree_;
@ -232,6 +235,12 @@ public:
return true; return true;
} }
//- Return true if reduction is applied to the state variables
bool reduction() const
{
return reduction_;
}
const chemistryModel<ThermoType>& chemistry() const chemistryModel<ThermoType>& chemistry()
{ {
return chemistry_; return chemistry_;
@ -271,6 +280,7 @@ public:
( (
const scalarField& phiq, const scalarField& phiq,
const scalarField& Rphiq, const scalarField& Rphiq,
const label nActive,
const label li, const label li,
const scalar deltaT const scalar deltaT
); );

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2016-2021 OpenFOAM Foundation \\ / A nd | Copyright (C) 2016-2022 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -70,7 +70,7 @@ void Foam::binaryNode<ThermoType>::calcV
{ {
// LT is the transpose of the L matrix // LT is the transpose of the L matrix
scalarSquareMatrix& LT = elementLeft->LT(); scalarSquareMatrix& LT = elementLeft->LT();
bool mechReductionActive = elementLeft->chemistry().mechRed().active(); const bool reduction = elementLeft->table().reduction();
// Difference of composition in the full species domain // Difference of composition in the full species domain
scalarField phiDif(elementRight->phi() - elementLeft->phi()); scalarField phiDif(elementRight->phi() - elementLeft->phi());
@ -82,7 +82,7 @@ void Foam::binaryNode<ThermoType>::calcV
{ {
label si = i; label si = i;
bool outOfIndexI = true; bool outOfIndexI = true;
if (mechReductionActive) if (reduction)
{ {
if (i<elementLeft->completeSpaceSize() - 3) if (i<elementLeft->completeSpaceSize() - 3)
{ {
@ -93,17 +93,18 @@ void Foam::binaryNode<ThermoType>::calcV
{ {
outOfIndexI = false; outOfIndexI = false;
const label dif = i - (elementLeft->completeSpaceSize() - 3); const label dif = i - (elementLeft->completeSpaceSize() - 3);
si = elementLeft->nActiveSpecies() + dif; si = elementLeft->nActive() + dif;
} }
} }
if (!mechReductionActive || (mechReductionActive && !(outOfIndexI))) if (!reduction || (reduction && !(outOfIndexI)))
{ {
v[i] = 0; v[i] = 0;
for (label j=0; j<elementLeft->completeSpaceSize(); j++) for (label j=0; j<elementLeft->completeSpaceSize(); j++)
{ {
label sj = j; label sj = j;
bool outOfIndexJ = true; bool outOfIndexJ = true;
if (mechReductionActive)
if (reduction)
{ {
if (j < elementLeft->completeSpaceSize() - 3) if (j < elementLeft->completeSpaceSize() - 3)
{ {
@ -115,14 +116,11 @@ void Foam::binaryNode<ThermoType>::calcV
outOfIndexJ = false; outOfIndexJ = false;
const label dif = const label dif =
j - (elementLeft->completeSpaceSize() - 3); j - (elementLeft->completeSpaceSize() - 3);
sj = elementLeft->nActiveSpecies() + dif; sj = elementLeft->nActive() + dif;
} }
} }
if
( if (!reduction ||(reduction && !(outOfIndexJ)))
!mechReductionActive
||(mechReductionActive && !(outOfIndexJ))
)
{ {
// Since L is a lower triangular matrix k=0->min(i, j) // Since L is a lower triangular matrix k=0->min(i, j)
for (label k=0; k<=min(si, sj); k++) for (label k=0; k<=min(si, sj); k++)

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2016-2021 OpenFOAM Foundation \\ / A nd | Copyright (C) 2016-2022 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -382,6 +382,7 @@ void Foam::binaryTree<ThermoType>::insertNewLeaf
const scalarField& scaleFactor, const scalarField& scaleFactor,
const scalar& epsTol, const scalar& epsTol,
const label nCols, const label nCols,
const label nActive,
chP*& phi0 chP*& phi0
) )
{ {
@ -401,6 +402,7 @@ void Foam::binaryTree<ThermoType>::insertNewLeaf
scaleFactor, scaleFactor,
epsTol, epsTol,
nCols, nCols,
nActive,
coeffsDict_, coeffsDict_,
root_ root_
); );
@ -428,6 +430,7 @@ void Foam::binaryTree<ThermoType>::insertNewLeaf
scaleFactor, scaleFactor,
epsTol, epsTol,
nCols, nCols,
nActive,
coeffsDict_ coeffsDict_
); );
// insert new node on the parent node in the position of the // insert new node on the parent node in the position of the

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2016-2021 OpenFOAM Foundation \\ / A nd | Copyright (C) 2016-2022 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -188,6 +188,7 @@ public:
const scalarField& scaleFactor, const scalarField& scaleFactor,
const scalar& epsTol, const scalar& epsTol,
const label nCols, const label nCols,
const label nActive,
chP*& phi0 chP*& phi0
); );

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2016-2021 OpenFOAM Foundation \\ / A nd | Copyright (C) 2016-2022 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -204,8 +204,9 @@ Foam::chemPointISAT<ThermoType>::chemPointISAT
const scalarField& Rphi, const scalarField& Rphi,
const scalarSquareMatrix& A, const scalarSquareMatrix& A,
const scalarField& scaleFactor, const scalarField& scaleFactor,
const scalar& tolerance, const scalar tolerance,
const label& completeSpaceSize, const label completeSpaceSize,
const label nActive,
const dictionary& coeffsDict, const dictionary& coeffsDict,
binaryNode<ThermoType>* node binaryNode<ThermoType>* node
) )
@ -218,8 +219,8 @@ Foam::chemPointISAT<ThermoType>::chemPointISAT
node_(node), node_(node),
completeSpaceSize_(completeSpaceSize), completeSpaceSize_(completeSpaceSize),
nGrowth_(0), nGrowth_(0),
nActiveSpecies_(table_.chemistry().mechRed().nActiveSpecies()), nActive_(nActive),
simplifiedToCompleteIndex_(nActiveSpecies_), simplifiedToCompleteIndex_(nActive_),
timeTag_(table.timeSteps()), timeTag_(table.timeSteps()),
lastTimeUsed_(table.timeSteps()), lastTimeUsed_(table.timeSteps()),
toRemove_(false), toRemove_(false),
@ -237,21 +238,20 @@ Foam::chemPointISAT<ThermoType>::chemPointISAT
idT_ = completeSpaceSize - 3; idT_ = completeSpaceSize - 3;
idp_ = completeSpaceSize - 2; idp_ = completeSpaceSize - 2;
const bool mechRedActive = table_.chemistry().mechRed().active(); if (table_.reduction())
if (mechRedActive)
{ {
for (label i=0; i<completeSpaceSize-3; i++) for (label i=0; i<completeSpaceSize-3; i++)
{ {
completeToSimplifiedIndex_[i] = table_.chemistry().cTos(i); completeToSimplifiedIndex_[i] = table_.chemistry().cTos(i);
} }
for (label i=0; i<nActiveSpecies_; i++) for (label i=0; i<nActive_; i++)
{ {
simplifiedToCompleteIndex_[i] = table_.chemistry().sToc(i); simplifiedToCompleteIndex_[i] = table_.chemistry().sToc(i);
} }
} }
const label reduOrCompDim = const label reduOrCompDim =
mechRedActive ? nActiveSpecies_ + 3 : completeSpaceSize; table_.reduction() ? nActive_ + 3 : completeSpaceSize;
// SVD decomposition A = U*D*V^T // SVD decomposition A = U*D*V^T
SVD svdA(A); SVD svdA(A);
@ -277,7 +277,7 @@ Foam::chemPointISAT<ThermoType>::chemPointISAT
{ {
label compi = i; label compi = i;
if (mechRedActive) if (table_.reduction())
{ {
compi = simplifiedToCompleteIndex(i); compi = simplifiedToCompleteIndex(i);
} }
@ -314,7 +314,7 @@ Foam::chemPointISAT<ThermoType>::chemPointISAT
node_(p.node()), node_(p.node()),
completeSpaceSize_(p.completeSpaceSize()), completeSpaceSize_(p.completeSpaceSize()),
nGrowth_(p.nGrowth()), nGrowth_(p.nGrowth()),
nActiveSpecies_(p.nActiveSpecies()), nActive_(p.nActive()),
simplifiedToCompleteIndex_(p.simplifiedToCompleteIndex()), simplifiedToCompleteIndex_(p.simplifiedToCompleteIndex()),
timeTag_(p.timeTag()), timeTag_(p.timeTag()),
lastTimeUsed_(p.lastTimeUsed()), lastTimeUsed_(p.lastTimeUsed()),
@ -338,10 +338,9 @@ template<class ThermoType>
bool Foam::chemPointISAT<ThermoType>::inEOA(const scalarField& phiq) bool Foam::chemPointISAT<ThermoType>::inEOA(const scalarField& phiq)
{ {
const scalarField dphi(phiq - phi()); const scalarField dphi(phiq - phi());
const bool mechRedActive = table_.chemistry().mechRed().active();
const label dim = const label dim =
mechRedActive ? nActiveSpecies_ : completeSpaceSize() - 3; table_.reduction() ? nActive_ : completeSpaceSize() - 3;
scalar epsTemp = 0; scalar epsTemp = 0;
List<scalar> propEps(completeSpaceSize(), scalar(0)); List<scalar> propEps(completeSpaceSize(), scalar(0));
@ -355,19 +354,19 @@ bool Foam::chemPointISAT<ThermoType>::inEOA(const scalarField& phiq)
// inactive species), just multiply the diagonal element and dphi // inactive species), just multiply the diagonal element and dphi
if if
( (
!(mechRedActive) !(table_.reduction())
||(mechRedActive && completeToSimplifiedIndex_[i] != -1) ||(table_.reduction() && completeToSimplifiedIndex_[i] != -1)
) )
{ {
const label si = const label si =
mechRedActive table_.reduction()
? completeToSimplifiedIndex_[i] ? completeToSimplifiedIndex_[i]
: i; : i;
for (label j=si; j<dim; j++)// LT is upper triangular for (label j=si; j<dim; j++)// LT is upper triangular
{ {
const label sj = const label sj =
mechRedActive table_.reduction()
? simplifiedToCompleteIndex_[j] ? simplifiedToCompleteIndex_[j]
: j; : j;
@ -487,18 +486,17 @@ bool Foam::chemPointISAT<ThermoType>::checkSolution
const scalarField dphi(phiq - phi()); const scalarField dphi(phiq - phi());
const scalarField& scaleFactorV(scaleFactor()); const scalarField& scaleFactorV(scaleFactor());
const scalarSquareMatrix& Avar(A()); const scalarSquareMatrix& Avar(A());
const bool mechRedActive = table_.chemistry().mechRed().active();
scalar dRl = 0; scalar dRl = 0;
const label dim = const label dim =
mechRedActive ? nActiveSpecies_ : completeSpaceSize() - 2; table_.reduction() ? nActive_ : completeSpaceSize() - 2;
// Since we build only the solution for the species, T and p are not // Since we build only the solution for the species, T and p are not
// included // included
for (label i=0; i<completeSpaceSize()-3; i++) for (label i=0; i<completeSpaceSize()-3; i++)
{ {
dRl = 0; dRl = 0;
if (mechRedActive) if (table_.reduction())
{ {
const label si = completeToSimplifiedIndex_[i]; const label si = completeToSimplifiedIndex_[i];
@ -510,9 +508,9 @@ bool Foam::chemPointISAT<ThermoType>::checkSolution
const label sj = simplifiedToCompleteIndex_[j]; const label sj = simplifiedToCompleteIndex_[j];
dRl += Avar(si, j)*dphi[sj]; dRl += Avar(si, j)*dphi[sj];
} }
dRl += Avar(si, nActiveSpecies_)*dphi[idT_]; dRl += Avar(si, nActive_)*dphi[idT_];
dRl += Avar(si, nActiveSpecies_+1)*dphi[idp_]; dRl += Avar(si, nActive_+1)*dphi[idp_];
dRl += Avar(si, nActiveSpecies_+2)*dphi[iddeltaT_]; dRl += Avar(si, nActive_+2)*dphi[iddeltaT_];
} }
else else
{ {
@ -546,10 +544,9 @@ template<class ThermoType>
bool Foam::chemPointISAT<ThermoType>::grow(const scalarField& phiq) bool Foam::chemPointISAT<ThermoType>::grow(const scalarField& phiq)
{ {
const scalarField dphi(phiq - phi()); const scalarField dphi(phiq - phi());
const label initNActiveSpecies(nActiveSpecies_); const label initNActiveSpecies(nActive_);
const bool mechRedActive = table_.chemistry().mechRed().active();
if (mechRedActive) if (table_.reduction())
{ {
label activeAdded(0); label activeAdded(0);
DynamicList<label> dimToAdd(0); DynamicList<label> dimToAdd(0);
@ -602,11 +599,11 @@ bool Foam::chemPointISAT<ThermoType>::grow(const scalarField& phiq)
} }
// the number of added dimension to the current chemPoint // the number of added dimension to the current chemPoint
nActiveSpecies_ += dimToAdd.size(); nActive_ += dimToAdd.size();
simplifiedToCompleteIndex_.setSize(nActiveSpecies_); simplifiedToCompleteIndex_.setSize(nActive_);
forAll(dimToAdd, i) forAll(dimToAdd, i)
{ {
label si = nActiveSpecies_ - dimToAdd.size() + i; label si = nActive_ - dimToAdd.size() + i;
// add the new active species // add the new active species
simplifiedToCompleteIndex_[si] = dimToAdd[i]; simplifiedToCompleteIndex_[si] = dimToAdd[i];
completeToSimplifiedIndex_[dimToAdd[i]] = si; completeToSimplifiedIndex_[dimToAdd[i]] = si;
@ -618,12 +615,12 @@ bool Foam::chemPointISAT<ThermoType>::grow(const scalarField& phiq)
// (change the diagonal position) // (change the diagonal position)
//-set all element of the new lines and columns to zero except diagonal //-set all element of the new lines and columns to zero except diagonal
// (=1/(tolerance*scaleFactor)) // (=1/(tolerance*scaleFactor))
if (nActiveSpecies_ > initNActiveSpecies) if (nActive_ > initNActiveSpecies)
{ {
const scalarSquareMatrix LTvar = LT_; // take a copy of LT_ const scalarSquareMatrix LTvar = LT_; // take a copy of LT_
const scalarSquareMatrix Avar = A_; // take a copy of A_ const scalarSquareMatrix Avar = A_; // take a copy of A_
LT_ = scalarSquareMatrix(nActiveSpecies_+3, Zero); LT_ = scalarSquareMatrix(nActive_+3, Zero);
A_ = scalarSquareMatrix(nActiveSpecies_+3, Zero); A_ = scalarSquareMatrix(nActive_+3, Zero);
// write the initial active species // write the initial active species
for (label i=0; i<initNActiveSpecies; i++) for (label i=0; i<initNActiveSpecies; i++)
@ -640,27 +637,27 @@ bool Foam::chemPointISAT<ThermoType>::grow(const scalarField& phiq)
{ {
for (label j=1; j>=0; j--) for (label j=1; j>=0; j--)
{ {
LT_(i, nActiveSpecies_+j)=LTvar(i, initNActiveSpecies+j); LT_(i, nActive_+j)=LTvar(i, initNActiveSpecies+j);
A_(i, nActiveSpecies_+j)=Avar(i, initNActiveSpecies+j); A_(i, nActive_+j)=Avar(i, initNActiveSpecies+j);
LT_(nActiveSpecies_+j, i)=LTvar(initNActiveSpecies+j, i); LT_(nActive_+j, i)=LTvar(initNActiveSpecies+j, i);
A_(nActiveSpecies_+j, i)=Avar(initNActiveSpecies+j, i); A_(nActive_+j, i)=Avar(initNActiveSpecies+j, i);
} }
} }
// end with the diagonal elements for temperature and pressure // end with the diagonal elements for temperature and pressure
LT_(nActiveSpecies_, nActiveSpecies_)= LT_(nActive_, nActive_)=
LTvar(initNActiveSpecies, initNActiveSpecies); LTvar(initNActiveSpecies, initNActiveSpecies);
A_(nActiveSpecies_, nActiveSpecies_)= A_(nActive_, nActive_)=
Avar(initNActiveSpecies, initNActiveSpecies); Avar(initNActiveSpecies, initNActiveSpecies);
LT_(nActiveSpecies_+1, nActiveSpecies_+1)= LT_(nActive_+1, nActive_+1)=
LTvar(initNActiveSpecies+1, initNActiveSpecies+1); LTvar(initNActiveSpecies+1, initNActiveSpecies+1);
A_(nActiveSpecies_+1, nActiveSpecies_+1)= A_(nActive_+1, nActive_+1)=
Avar(initNActiveSpecies+1, initNActiveSpecies+1); Avar(initNActiveSpecies+1, initNActiveSpecies+1);
LT_(nActiveSpecies_+2, nActiveSpecies_+2)= LT_(nActive_+2, nActive_+2)=
LTvar(initNActiveSpecies+2, initNActiveSpecies+2); LTvar(initNActiveSpecies+2, initNActiveSpecies+2);
A_(nActiveSpecies_+2, nActiveSpecies_+2)= A_(nActive_+2, nActive_+2)=
Avar(initNActiveSpecies+2, initNActiveSpecies+2); Avar(initNActiveSpecies+2, initNActiveSpecies+2);
for (label i=initNActiveSpecies; i<nActiveSpecies_;i++) for (label i=initNActiveSpecies; i<nActive_;i++)
{ {
LT_(i, i)= LT_(i, i)=
1.0 1.0
@ -671,7 +668,7 @@ bool Foam::chemPointISAT<ThermoType>::grow(const scalarField& phiq)
} }
const label dim = const label dim =
mechRedActive ? nActiveSpecies_ + 3 : completeSpaceSize(); table_.reduction() ? nActive_ + 3 : completeSpaceSize();
// beginning of grow algorithm // beginning of grow algorithm
scalarField phiTilde(dim, 0); scalarField phiTilde(dim, 0);
@ -683,7 +680,7 @@ bool Foam::chemPointISAT<ThermoType>::grow(const scalarField& phiq)
for (label j=i; j<dim-3; j++)// LT is upper triangular for (label j=i; j<dim-3; j++)// LT is upper triangular
{ {
const label sj = const label sj =
mechRedActive table_.reduction()
? simplifiedToCompleteIndex_[j] ? simplifiedToCompleteIndex_[j]
: j; : j;
@ -747,19 +744,19 @@ Foam::label Foam::chemPointISAT<ThermoType>::simplifiedToCompleteIndex
const label i const label i
) )
{ {
if (i < nActiveSpecies_) if (i < nActive_)
{ {
return simplifiedToCompleteIndex_[i]; return simplifiedToCompleteIndex_[i];
} }
else if (i == nActiveSpecies_) else if (i == nActive_)
{ {
return completeSpaceSize_ - 3; return completeSpaceSize_ - 3;
} }
else if (i == nActiveSpecies_ + 1) else if (i == nActive_ + 1)
{ {
return completeSpaceSize_ - 2; return completeSpaceSize_ - 2;
} }
else if (i == nActiveSpecies_ + 2) else if (i == nActive_ + 2)
{ {
return completeSpaceSize_ - 1; return completeSpaceSize_ - 1;
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2016-2021 OpenFOAM Foundation \\ / A nd | Copyright (C) 2016-2022 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -184,7 +184,7 @@ class chemPointISAT
static scalar tolerance_; static scalar tolerance_;
//- Number of active species stored in the chemPoint //- Number of active species stored in the chemPoint
label nActiveSpecies_; label nActive_;
//- Vectors that store the index conversion between the simplified //- Vectors that store the index conversion between the simplified
// and the complete chemical mechanism // and the complete chemical mechanism
@ -256,8 +256,9 @@ public:
const scalarField& Rphi, const scalarField& Rphi,
const scalarSquareMatrix& A, const scalarSquareMatrix& A,
const scalarField& scaleFactor, const scalarField& scaleFactor,
const scalar& tolerance, const scalar tolerance,
const label& completeSpaceSize, const label completeSpaceSize,
const label nActive,
const dictionary& coeffsDict, const dictionary& coeffsDict,
binaryNode<ThermoType>* node = nullptr binaryNode<ThermoType>* node = nullptr
); );
@ -275,13 +276,13 @@ public:
// Member Functions // Member Functions
//- Access to the chemistryModel //- Access to the ISAT table
inline const chemistryModel<ThermoType>& chemistry() inline const chemistryTabulationMethods::ISAT<ThermoType>& table() const
{ {
return table_.chemistry(); return table_;
} }
inline label nGrowth() inline label nGrowth() const
{ {
return nGrowth_; return nGrowth_;
} }
@ -301,12 +302,12 @@ public:
return Rphi_; return Rphi_;
} }
inline const scalarField& scaleFactor() inline const scalarField& scaleFactor() const
{ {
return scaleFactor_; return scaleFactor_;
} }
inline const scalar& tolerance() inline const scalar& tolerance() const
{ {
return tolerance_; return tolerance_;
} }
@ -341,9 +342,9 @@ public:
return LT_; return LT_;
} }
inline label nActiveSpecies() inline label nActive()
{ {
return nActiveSpecies_; return nActive_;
} }
inline List<label>& completeToSimplifiedIndex() inline List<label>& completeToSimplifiedIndex()

View File

@ -56,7 +56,6 @@ class chemistryModel;
template<class ThermoType> template<class ThermoType>
class chemistryTabulationMethod class chemistryTabulationMethod
{ {
public: public:
//- Runtime type information //- Runtime type information
@ -123,6 +122,7 @@ public:
( (
const scalarField& phiQ, const scalarField& phiQ,
const scalarField& RphiQ, const scalarField& RphiQ,
const label nActive,
const label li, const label li,
const scalar deltaT const scalar deltaT
) = 0; ) = 0;

View File

@ -103,6 +103,7 @@ public:
( (
const scalarField& phiq, const scalarField& phiq,
const scalarField& Rphiq, const scalarField& Rphiq,
const label nActive,
const label li, const label li,
const scalar deltaT const scalar deltaT
) )