31 template<
class ThermoType>
48 chemistry.
mixture().specieComposition(i);
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;
77 if (this->coeffsDict_.found(
"sortPart"))
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);
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)
170 label otherS = rABPos(A, B);
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;
203 label otherS = rABPos(B, A);
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;
258 for (
int A=0; A<this->
nSpecie() ; A++)
260 for (
int j=0; j<NbrABInit[A]; j++)
262 label pairIndex = nP++;
263 pairsFlux[pairIndex] = 0.0;
264 label B = rABOtherSpec(A, j);
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;
322 for (
int A=0; A<this->
nSpecie() ; A++)
324 for (
int j=0; j<NbrABInit[A]; j++)
326 label pairIndex = nP++;
327 pairsFlux[pairIndex] = 0.0;
328 label B = rABOtherSpec(A, j);
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;
383 for (
int A=0; A<this->
nSpecie() ; A++)
385 for (
int j=0; j<NbrABInit[A]; j++)
387 label pairIndex = nP++;
388 pairsFlux[pairIndex] = 0.0;
389 label B = rABOtherSpec(A, j);
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;
443 for (
int A=0; A<this->
nSpecie() ; A++)
445 for (
int j=0; j<NbrABInit[A]; j++)
447 label pairIndex = nP++;
448 pairsFlux[pairIndex] = 0.0;
449 label B = rABOtherSpec(A, j);
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;
#define forAll(list, i)
Loop across all elements in list.
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
scalar omega(const scalar p, const scalar T, const scalarField &c, const label li, scalar &omegaf, scalar &omegar) const
Net reaction rate.
errorManipArg< error, int > exit(error &err, const int errNo=1)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
virtual void reduceMechanism(const scalar p, const scalar T, const scalarField &c, List< label > &ctos, DynamicList< label > &stoc, const label li)
Reduce the mechanism.
Ostream & endl(Ostream &os)
Add newline and flush stream.
A list that is sorted upon construction or when explicitly requested with the sort() method...
const List< specieCoeffs > & lhs() const
Return the components of the left hand side.
Simple extension of ReactionThermo to handle reaction kinetics in addition to the equilibrium thermod...
const labelList & indices() const
Return the list of sorted indices. Updated every sort.
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
const dimensionedScalar c1
First radiation constant: default SI units: [W/m^2].
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 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects...
const word & name() const
Return the name of the element.
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
label nAtoms() const
Return the number of atoms of this element in the specie.
A templated 2D rectangular m x n matrix of objects of <Type>.
basicChemistryModel & chemistry
const multiComponentMixture< ThermoType > & mixture() const
Return reference to the mixture.
Extends base chemistry model by adding a thermo package, and ODE functions. Introduces chemistry equa...
const List< specieCoeffs > & rhs() const
Return the components of the right hand side.
virtual ~EFA()
Destructor.
#define R(A, B, C, D, E, F, K, M)
dimensioned< scalar > mag(const dimensioned< Type > &)
void partialSort(int M, int start)
Partial sort the list (if changed after construction time)
An abstract class for methods of chemical mechanism reduction.
EFA(const IOdictionary &dict, chemistryModel< ThermoType > &chemistry)
Construct from components.