33 template<
class ThermoType>
38 template<
class ThermoType>
49 for (
label k=0; k<nCols-1; k++)
52 for (
label i=k; i<nCols; i++)
62 for (
label i=k; i<nCols; i++)
67 for (
label i=k; i<nCols; i++)
75 for (
label j=k+1; j<nCols; j++)
78 for (
label i=k; i<nCols; i++)
80 sum +=
R(i, k)*
R(i, j);
82 scalar tau = sum/c[
k];
83 for (
label i=k; i<nCols; i++)
85 R(i, j) -= tau*
R(i, k);
91 d[nCols-1] =
R(nCols-1, nCols-1);
94 for (
label i=0; i<nCols; i++)
97 for (
label j=0; j<i; j++)
105 template<
class ThermoType>
117 for (k=n-1; k>=0; k--)
130 for (
label i=k-1; i>=0; i--)
132 rotate(R, i, w[i],-w[i+1], n);
137 else if (
mag(w[i]) >
mag(w[i+1]))
139 w[i] =
mag(w[i])*
sqrt(1.0 +
sqr(w[i+1]/w[i]));
143 w[i] =
mag(w[i+1])*
sqrt(1.0 +
sqr(w[i]/w[i+1]));
149 R(0, i) += w[0]*v[i];
154 rotate(R, i,
R(i, i), -
R(i+1, i), n);
159 template<
class ThermoType>
169 scalar
c, fact,
s, w,
y;
173 s = (b >= 0 ? 1 : -1);
199 template<
class ThermoType>
207 const scalar& tolerance,
208 const label& completeSpaceSize,
213 chemistry_(chemistry),
217 scaleFactor_(scaleFactor),
219 completeSpaceSize_(completeSpaceSize),
221 nActiveSpecies_(chemistry.
mechRed()->NsSimp()),
222 simplifiedToCompleteIndex_(nActiveSpecies_),
223 timeTag_(chemistry_.timeSteps()),
224 lastTimeUsed_(chemistry_.timeSteps()),
230 completeToSimplifiedIndex_(completeSpaceSize - 3)
232 tolerance_ = tolerance;
234 iddeltaT_ = completeSpaceSize - 1;
235 scaleFactor_[iddeltaT_] *= phi_[iddeltaT_] / tolerance_;
237 idT_ = completeSpaceSize - 3;
238 idp_ = completeSpaceSize - 2;
240 bool isMechRedActive = chemistry_.mechRed()->active();
243 for (
label i=0; i<completeSpaceSize-3; i++)
245 completeToSimplifiedIndex_[i] =
248 for (
label i=0; i<nActiveSpecies_; i++)
250 simplifiedToCompleteIndex_[i] =
255 const label reduOrCompDim =
256 isMechRedActive ? nActiveSpecies_ + 3 : completeSpaceSize;
265 for (
label i=0; i<reduOrCompDim; i++)
267 D[i] =
max(S[i], 0.5);
276 for (
label i=0; i<reduOrCompDim; i++)
278 for (
label j=0; j<reduOrCompDim; j++)
284 compi = simplifiedToCompleteIndex(i);
291 Atilde(i, j) /= (tolerance*scaleFactor[compi]);
300 qrDecompose(reduOrCompDim, LT_);
304 template<
class ThermoType>
331 idT_ = completeSpaceSize() - 3;
332 idp_ = completeSpaceSize() - 2;
333 iddeltaT_ = completeSpaceSize() - 1;
339 template<
class ThermoType>
343 bool isMechRedActive = chemistry_.mechRed()->active();
346 isMechRedActive ? nActiveSpecies_ : completeSpaceSize() - 3;
351 for (
label i=0; i<completeSpaceSize()-3; i++)
361 ||(isMechRedActive && completeToSimplifiedIndex_[i] != -1)
364 label si=(isMechRedActive) ? completeToSimplifiedIndex_[i] : i;
366 for (
label j=si; j<dim; j++)
368 label sj=(isMechRedActive) ? simplifiedToCompleteIndex_[j] : j;
369 temp += LT_(si, j)*dphi[sj];
372 temp += LT_(si, dim)*dphi[idT_];
373 temp += LT_(si, dim+1)*dphi[idp_];
374 temp += LT_(si, dim+2)*dphi[iddeltaT_];
378 temp = dphi[i]/(tolerance_*scaleFactor_[i]);
381 epsTemp +=
sqr(temp);
383 if (printProportion_)
393 LT_(dim, dim)*dphi[idT_]
394 +LT_(dim, dim+1)*dphi[idp_]
395 +LT_(dim, dim+2)*dphi[iddeltaT_]
402 LT_(dim+1, dim+1)*dphi[idp_]
403 +LT_(dim+1, dim+2)*dphi[iddeltaT_]
406 epsTemp +=
sqr(LT_[dim+2][dim+2]*dphi[iddeltaT_]);
408 if (printProportion_)
412 LT_(dim, dim)*dphi[idT_]
413 + LT_(dim, dim+1)*dphi[idp_]
417 sqr(LT_(dim+1, dim+1)*dphi[idp_]);
420 sqr(LT_[dim+2][dim+2]*dphi[iddeltaT_]);
423 if (
sqrt(epsTemp) > 1 + tolerance_)
425 if (printProportion_)
429 for (
label i=0; i<completeSpaceSize(); i++)
438 if (maxIndex >= completeSpaceSize() - 3)
440 if (maxIndex == idT_)
444 else if (maxIndex == idp_)
448 else if (maxIndex == iddeltaT_)
455 propName = chemistry_.Y()[maxIndex].member();
457 Info<<
"Direction maximum impact to error in ellipsoid: " 459 Info<<
"Proportion to the total error on the retrieve: " 460 << max/(epsTemp+small) << endl;
471 template<
class ThermoType>
483 bool isMechRedActive = chemistry_.mechRed()->active();
487 isMechRedActive ? nActiveSpecies_ : completeSpaceSize() - 2;
491 for (
label i=0; i<completeSpaceSize()-3; i++)
496 label si = completeToSimplifiedIndex_[i];
501 for (
label j=0; j<dim; j++)
503 label sj=simplifiedToCompleteIndex_[j];
504 dRl += Avar(si, j)*dphi[sj];
506 dRl += Avar(si, nActiveSpecies_)*dphi[idT_];
507 dRl += Avar(si, nActiveSpecies_+1)*dphi[idp_];
508 dRl += Avar(si, nActiveSpecies_+2)*dphi[iddeltaT_];
517 for (
label j=0; j<completeSpaceSize(); j++)
519 dRl += Avar(i, j)*dphi[j];
522 eps2 +=
sqr((dR[i]-dRl)/scaleFactorV[i]);
526 if (eps2 > tolerance())
538 template<
class ThermoType>
542 label initNActiveSpecies(nActiveSpecies_);
543 bool isMechRedActive = chemistry_.mechRed()->active();
547 label activeAdded(0);
552 for (
label i=0; i<completeSpaceSize()-3; i++)
558 completeToSimplifiedIndex_[i] == -1
559 && chemistry_.completeToSimplifiedIndex()[i]!=-1
569 completeToSimplifiedIndex_[i] != -1
570 && chemistry_.completeToSimplifiedIndex()[i] == -1
581 completeToSimplifiedIndex_[i] == -1
582 && chemistry_.completeToSimplifiedIndex()[i] == -1
592 if (activeAdded > maxNumNewDim_)
598 nActiveSpecies_ += dimToAdd.
size();
599 simplifiedToCompleteIndex_.setSize(nActiveSpecies_);
602 label si = nActiveSpecies_ - dimToAdd.
size() + i;
604 simplifiedToCompleteIndex_[si] = dimToAdd[i];
605 completeToSimplifiedIndex_[dimToAdd[i]] = si;
614 if (nActiveSpecies_ > initNActiveSpecies)
622 for (
label i=0; i<initNActiveSpecies; i++)
624 for (
label j=0; j<initNActiveSpecies; j++)
626 LT_(i, j) = LTvar(i, j);
627 A_(i, j) = Avar(i, j);
632 for (
label i=0; i<initNActiveSpecies; i++)
634 for (
label j=1; j>=0; j--)
636 LT_(i, nActiveSpecies_+j)=LTvar(i, initNActiveSpecies+j);
637 A_(i, nActiveSpecies_+j)=Avar(i, initNActiveSpecies+j);
638 LT_(nActiveSpecies_+j, i)=LTvar(initNActiveSpecies+j, i);
639 A_(nActiveSpecies_+j, i)=Avar(initNActiveSpecies+j, i);
643 LT_(nActiveSpecies_, nActiveSpecies_)=
644 LTvar(initNActiveSpecies, initNActiveSpecies);
645 A_(nActiveSpecies_, nActiveSpecies_)=
646 Avar(initNActiveSpecies, initNActiveSpecies);
647 LT_(nActiveSpecies_+1, nActiveSpecies_+1)=
648 LTvar(initNActiveSpecies+1, initNActiveSpecies+1);
649 A_(nActiveSpecies_+1, nActiveSpecies_+1)=
650 Avar(initNActiveSpecies+1, initNActiveSpecies+1);
651 LT_(nActiveSpecies_+2, nActiveSpecies_+2)=
652 LTvar(initNActiveSpecies+2, initNActiveSpecies+2);
653 A_(nActiveSpecies_+2, nActiveSpecies_+2)=
654 Avar(initNActiveSpecies+2, initNActiveSpecies+2);
656 for (
label i=initNActiveSpecies; i<nActiveSpecies_;i++)
660 /(tolerance_*scaleFactor_[simplifiedToCompleteIndex_[i]]);
667 isMechRedActive ? nActiveSpecies_ + 3 : completeSpaceSize();
671 scalar normPhiTilde = 0;
674 for (
label i=0; i<dim; i++)
676 for (
label j=i; j<dim-3; j++)
681 sj = simplifiedToCompleteIndex_[j];
683 phiTilde[i] += LT_(i, j)*dphi[sj];
686 phiTilde[i] += LT_(i, dim-3)*dphi[idT_];
687 phiTilde[i] += LT_(i, dim-3+1)*dphi[idp_];
688 phiTilde[i] += LT_(i, dim-3+2)*dphi[iddeltaT_];
690 normPhiTilde +=
sqr(phiTilde[i]);
693 scalar invSqrNormPhiTilde = 1.0/normPhiTilde;
694 normPhiTilde =
sqrt(normPhiTilde);
697 scalar gamma = (1/normPhiTilde - 1)*invSqrNormPhiTilde;
701 for (
label i=0; i<dim; i++)
703 for (
label j=0; j<=i;j++)
705 v[i] += phiTilde[j]*LT_(j, i);
709 qrUpdate(LT_,dim, u, v);
716 template<
class ThermoType>
719 this->numRetrieve_++;
723 template<
class ThermoType>
726 this->numRetrieve_ = 0;
730 template<
class ThermoType>
737 template<
class ThermoType>
743 if (i < nActiveSpecies_)
745 return simplifiedToCompleteIndex_[i];
747 else if (i == nActiveSpecies_)
749 return completeSpaceSize_ - 3;
751 else if (i == nActiveSpecies_ + 1)
753 return completeSpaceSize_ - 2;
755 else if (i == nActiveSpecies_ + 2)
757 return completeSpaceSize_ - 1;
dimensionedScalar sign(const dimensionedScalar &ds)
Extends standardChemistryModel by adding the TDAC method.
#define forAll(list, i)
Loop across all elements in list.
void multiply(FieldField< Field, Type > &f, const FieldField< Field, Type > &f1, const FieldField< Field, scalar > &f2)
const scalar & tolerance()
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
const scalarSquareMatrix & A() const
const scalarSquareMatrix & LT() const
List< label > & simplifiedToCompleteIndex()
A list of keyword definitions, which are a keyword followed by any number of values (e...
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
const scalarRectangularMatrix & U() const
Return U.
Form T() const
Return the transpose of the matrix.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
void size(const label)
Override size to be inconsistent with allocated storage.
bool checkSolution(const scalarField &phiq, const scalarField &Rphiq)
If phiq is not in the EOA, then the mapping is computed.
const dimensionedScalar b
Wien displacement law constant: default SI units: [m K].
dimensionedScalar sqrt(const dimensionedScalar &ds)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Leaf of the binary tree. The chemPoint stores the composition 'phi', the mapping of this composition ...
Field< label > & completeToSimplifiedIndex()
List< label > & completeToSimplifiedIndex()
label k
Boltzmann constant.
const dimensionedScalar c
Speed of light in a vacuum.
chemPointISAT(TDACChemistryModel< ThermoType > &chemistry, const scalarField &phi, const scalarField &Rphi, const scalarSquareMatrix &A, const scalarField &scaleFactor, const scalar &tolerance, const label &completeSpaceSize, const dictionary &coeffsDict, binaryNode< ThermoType > *node=nullptr)
Construct from components.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
autoPtr< chemistryReductionMethod< ThermoType > > & mechRed()
DynamicList< label > & simplifiedToCompleteIndex()
const dimensionedScalar sigma
Stefan-Boltzmann constant: default SI units: [W/m^2/K^4].
binaryNode< ThermoType > *& node()
const scalarDiagonalMatrix & S() const
Return the singular values.
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
A class for handling words, derived from string.
const scalarField & scaleFactor()
tmp< fvMatrix< Type > > S(const Pair< tmp< volScalarField::Internal >> &, const GeometricField< Type, fvPatchField, volMesh > &)
TDACChemistryModel< ThermoType > & chemistry()
Access to the TDACChemistryModel.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
bool grow(const scalarField &phiq)
More details about the minimum-volume ellipsoid covering an.
Singular value decomposition of a rectangular matrix.
const scalarField & phi() const
volScalarField scalarField(fieldObject, mesh)
const scalarField & Rphi() const
const scalarRectangularMatrix & V() const
Return the square matrix V.
void resetNumRetrieve()
Resets the number of retrieves at each time step.
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
#define R(A, B, C, D, E, F, K, M)
void increaseNLifeTime()
Increases the "counter" of the chP life.
label & completeSpaceSize()
void increaseNumRetrieve()
Increases the number of retrieves the chempoint has generated.
bool inEOA(const scalarField &phiq)
To RETRIEVE the mapping from the stored chemPoint phi, the query.
dimensioned< scalar > mag(const dimensioned< Type > &)
SquareMatrix< scalar > scalarSquareMatrix