31 template<
class ThermoType>
51 forAll(curSpecieComposition, j)
54 curSpecieComposition[j];
55 if (curElement.
name() ==
"C")
57 sC_[i] = curElement.
nAtoms();
59 else if (curElement.
name() ==
"H")
61 sH_[i] = curElement.
nAtoms();
63 else if (curElement.
name() ==
"O")
65 sO_[i] = curElement.
nAtoms();
67 else if (curElement.
name() ==
"N")
69 sN_[i] = curElement.
nAtoms();
73 Info<<
"element not considered"<<
endl;
79 sortPart_ = this->
coeffsDict_.template lookup<scalar>(
"sortPart");
86 template<
class ThermoType>
93 template<
class ThermoType>
126 scalar CFlux(0.0), HFlux(0.0), OFlux(0.0), NFlux(0.0);
132 forAll(this->chemistry_.reactions(), i)
137 scalar omegaf, omegar;
138 R.omega(
p,
T,
c1, li, omegaf, omegar);
140 scalar fr =
mag(omegaf) +
mag(omegar);
141 scalar NCi(0.0),NHi(0.0),NOi(0.0),NNi(0.0);
144 label curIndex =
R.lhs()[
s].index;
145 scalar stoicCoeff =
R.lhs()[
s].stoichCoeff;
146 NCi += sC_[curIndex]*stoicCoeff;
147 NHi += sH_[curIndex]*stoicCoeff;
148 NOi += sO_[curIndex]*stoicCoeff;
149 NNi += sN_[curIndex]*stoicCoeff;
161 scalar Acoeff =
R.lhs()[Ai].stoichCoeff;
166 scalar Bcoeff =
R.rhs()[Bi].stoichCoeff;
168 if (rABPos(
B,
A)==-1)
173 rABPos(
A,
B) = NbrABInit[
A]++;
174 otherS = rABPos(
A,
B);
176 rABOtherSpec(
A, otherS) =
B;
180 CFluxAB(
A, otherS) +=
181 fr*Acoeff*sC_[
A]*Bcoeff*sC_[
B]/NCi;
185 HFluxAB(
A, otherS) +=
186 fr*Acoeff*sH_[
A]*Bcoeff*sH_[
B]/NHi;
190 OFluxAB(
A, otherS) +=
191 fr*Acoeff*sO_[
A]*Bcoeff*sO_[
B]/NOi;
195 NFluxAB(
A, otherS) +=
196 fr*Acoeff*sN_[
A]*Bcoeff*sN_[
B]/NNi;
206 CFluxAB(
B, otherS) +=
207 fr*Acoeff*sC_[
A]*Bcoeff*sC_[
B]/NCi;
211 HFluxAB(
B, otherS) +=
212 fr*Acoeff*sH_[
A]*Bcoeff*sH_[
B]/NHi;
216 OFluxAB(
B, otherS) +=
217 fr*Acoeff*sO_[
A]*Bcoeff*sO_[
B]/NOi;
221 NFluxAB(
B, otherS) +=
222 fr*Acoeff*sN_[
A]*Bcoeff*sN_[
B]/NNi;
227 CFlux += fr*Acoeff*sC_[
A]*Bcoeff*sC_[
B]/NCi;
231 HFlux += fr*Acoeff*sH_[
A]*Bcoeff*sH_[
B]/NHi;
235 OFlux += fr*Acoeff*sO_[
A]*Bcoeff*sO_[
B]/NOi;
239 NFlux += fr*Acoeff*sN_[
A]*Bcoeff*sN_[
B]/NNi;
249 this->activeSpecies_[i] =
false;
260 for (
int j=0; j<NbrABInit[
A]; j++)
262 label pairIndex = nP++;
263 pairsFlux[pairIndex] = 0.0;
265 pairsFlux[pairIndex] += CFluxAB(
A, j);
266 source[pairIndex] =
A;
276 scalar threshold((1-this->tolerance())*CFlux);
278 label nbToSort(
static_cast<label> (nbPairs*sortPart_));
279 nbToSort =
max(nbToSort,1);
281 bool cumRespected(
false);
284 if (startPoint >= nbPairs)
287 <<
"startPoint outside number of pairs without reaching"
292 label nbi =
min(nbToSort, nbPairs-startPoint);
295 for (
int i=0; i<nbi; i++)
297 cumFlux += pairsFlux[idx[startPoint+i]];
298 if (!this->activeSpecies_[source[idx[startPoint+i]]])
300 this->activeSpecies_[source[idx[startPoint+i]]] =
true;
302 if (!this->activeSpecies_[sink[idx[startPoint+i]]])
304 this->activeSpecies_[sink[idx[startPoint+i]]] =
true;
306 if (cumFlux >= threshold)
312 startPoint += nbToSort;
324 for (
int j=0; j<NbrABInit[
A]; j++)
326 label pairIndex = nP++;
327 pairsFlux[pairIndex] = 0.0;
329 pairsFlux[pairIndex] += HFluxAB(
A, j);
330 source[pairIndex] =
A;
336 scalar threshold((1-this->tolerance())*HFlux);
338 label nbToSort(
static_cast<label> (nbPairs*sortPart_));
339 nbToSort =
max(nbToSort,1);
341 bool cumRespected(
false);
344 if (startPoint >= nbPairs)
347 <<
"startPoint outside number of pairs without reaching"
352 label nbi =
min(nbToSort, nbPairs-startPoint);
355 for (
int i=0; i<nbi; i++)
357 cumFlux += pairsFlux[idx[startPoint+i]];
359 if (!this->activeSpecies_[source[idx[startPoint+i]]])
361 this->activeSpecies_[source[idx[startPoint+i]]] =
true;
363 if (!this->activeSpecies_[sink[idx[startPoint+i]]])
365 this->activeSpecies_[sink[idx[startPoint+i]]] =
true;
367 if (cumFlux >= threshold)
373 startPoint += nbToSort;
385 for (
int j=0; j<NbrABInit[
A]; j++)
387 label pairIndex = nP++;
388 pairsFlux[pairIndex] = 0.0;
390 pairsFlux[pairIndex] += OFluxAB(
A, j);
391 source[pairIndex] =
A;
396 scalar threshold((1-this->tolerance())*OFlux);
398 label nbToSort(
static_cast<label> (nbPairs*sortPart_));
399 nbToSort =
max(nbToSort,1);
401 bool cumRespected(
false);
404 if (startPoint >= nbPairs)
407 <<
"startPoint outside number of pairs without reaching"
412 label nbi =
min(nbToSort, nbPairs-startPoint);
415 for (
int i=0; i<nbi; i++)
417 cumFlux += pairsFlux[idx[startPoint+i]];
419 if (!this->activeSpecies_[source[idx[startPoint+i]]])
421 this->activeSpecies_[source[idx[startPoint+i]]] =
true;
423 if (!this->activeSpecies_[sink[idx[startPoint+i]]])
425 this->activeSpecies_[sink[idx[startPoint+i]]] =
true;
427 if (cumFlux >= threshold)
433 startPoint += nbToSort;
445 for (
int j=0; j<NbrABInit[
A]; j++)
447 label pairIndex = nP++;
448 pairsFlux[pairIndex] = 0.0;
450 pairsFlux[pairIndex] += NFluxAB(
A, j);
451 source[pairIndex] =
A;
456 scalar threshold((1-this->tolerance())*NFlux);
458 label nbToSort(
static_cast<label> (nbPairs*sortPart_));
459 nbToSort =
max(nbToSort,1);
461 bool cumRespected(
false);
464 if (startPoint >= nbPairs)
467 <<
"startPoint outside number of pairs without reaching"
472 label nbi =
min(nbToSort, nbPairs-startPoint);
475 for (
int i=0; i<nbi; i++)
477 cumFlux += pairsFlux[idx[startPoint+i]];
479 if (!this->activeSpecies_[source[idx[startPoint+i]]])
481 this->activeSpecies_[source[idx[startPoint+i]]] =
true;
483 if (!this->activeSpecies_[sink[idx[startPoint+i]]])
485 this->activeSpecies_[sink[idx[startPoint+i]]] =
true;
487 if (cumFlux >= threshold)
493 startPoint += nbToSort;
static const Foam::dimensionedScalar A("A", Foam::dimPressure, 611.21)
static const Foam::dimensionedScalar B("B", Foam::dimless, 18.678)
#define forAll(list, i)
Loop across all elements in list.
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Simple extension of ThermoType to handle reaction kinetics in addition to the equilibrium thermodynam...
A templated 2D rectangular m x n matrix of objects of <Type>.
A list that is sorted upon construction or when explicitly requested with the sort() method.
const labelList & indices() const
Return the list of sorted indices. Updated every sort.
void partialSort(int M, int start)
Partial sort the list (if changed after construction time)
Extends base chemistry model by adding a thermo package, and ODE functions. Introduces chemistry equa...
An abstract class for methods of chemical mechanism reduction.
void initReduceMechanism()
Protected Member Functions.
const dictionary coeffsDict_
Dictionary that store the algorithm data.
label nSpecie()
Return the number of species.
void endReduceMechanism(List< label > &ctos, DynamicList< label > &stoc)
End reduction of the mechanism.
virtual ~EFA()
Destructor.
EFA(const IOdictionary &dict, chemistryModel< ThermoType > &chemistry)
Construct from components.
virtual void reduceMechanism(const scalar p, const scalar T, const scalarField &c, List< label > &ctos, DynamicList< label > &stoc, const label li)
Reduce the mechanism.
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
label nAtoms() const
Return the number of atoms of this element in the specie.
const word & name() const
Return the name of the element.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
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.name(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
const dimensionedScalar c1
First radiation constant: default SI units: [W/m^2].
const dimensionedScalar c
Speed of light in a vacuum.
errorManipArg< error, int > exit(error &err, const int errNo=1)
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Ostream & endl(Ostream &os)
Add newline and flush stream.
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
dimensioned< scalar > mag(const dimensioned< Type > &)
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
static scalar R(const scalar a, const scalar x)
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
basicChemistryModel & chemistry