31 template<
class ReactionThermo>
36 template<
class ReactionThermo>
42 for (
label i = 0; i < lhs_.size(); ++i)
48 if (
mag(lhs_[i].stoichCoeff - 1) > SMALL)
50 reaction << lhs_[i].stoichCoeff;
52 reaction << species_[lhs_[i].index];
53 if (
mag(lhs_[i].exponent - lhs_[i].stoichCoeff) > SMALL)
55 reaction <<
"^" << lhs_[i].exponent;
61 template<
class ReactionThermo>
67 for (
label i = 0; i < rhs_.size(); ++i)
73 if (
mag(rhs_[i].stoichCoeff - 1) > SMALL)
75 reaction << rhs_[i].stoichCoeff;
77 reaction << species_[rhs_[i].index];
78 if (
mag(rhs_[i].exponent - rhs_[i].stoichCoeff) > SMALL)
80 reaction <<
"^" << rhs_[i].exponent;
88 template<
class ReactionThermo>
91 return nUnNamedReactions++;
95 template<
class ReactionThermo>
101 reactionStrLeft(reaction);
103 reactionStrRight(reaction);
104 return reaction.
str();
108 template<
class ReactionThermo>
116 ReactionThermo::thermoType::operator=
118 rhs_[0].stoichCoeff*(*thermoDatabase[species_[rhs_[0].index]])
121 for (
label i=1; i<rhs_.size(); ++i)
125 rhs_[i].stoichCoeff*(*thermoDatabase[species_[rhs_[i].index]])
134 lhs_[i].stoichCoeff*(*thermoDatabase[species_[lhs_[i].index]])
143 template<
class ReactionThermo>
152 ReactionThermo::thermoType(*thermoDatabase[species[0]]),
153 name_(
"un-named-reaction-" +
Foam::name(getNewReactionID())),
158 setThermo(thermoDatabase);
162 template<
class ReactionThermo>
169 ReactionThermo::thermoType(r),
170 name_(r.
name() +
"Copy"),
177 template<
class ReactionThermo>
195 exponent = stoichCoeff;
201 size_t i = specieName.find(
'^');
205 string exponentStr = specieName
208 specieName.size() - i - 1
210 exponent = atof(exponentStr.c_str());
211 specieName = specieName(0, i);
216 index = species[specieName];
226 <<
"Expected a word but found " << t.
info()
232 template<
class ReactionThermo>
247 if (dlrhs.
last().index != -1)
255 else if (t == token::ASSIGN)
285 else if (t == token::ASSIGN)
309 FatalIOErrorIn(
"Reaction<ReactionThermo>::setLRhs(Istream& is)", is)
310 <<
"Cannot continue reading reaction data from stream" 315 template<
class ReactionThermo>
323 ReactionThermo::thermoType(*thermoDatabase[species[0]]),
324 name_(
"un-named-reaction" +
Foam::name(getNewReactionID())),
327 setLRhs(is, species, lhs_, rhs_);
328 setThermo(thermoDatabase);
332 template<
class ReactionThermo>
340 ReactionThermo::thermoType(*thermoDatabase[species[0]]),
351 setThermo(thermoDatabase);
357 template<
class ReactionThermo>
370 "Reaction<ReactionThermo>::New(const speciesTable&, " 371 " const HashPtrTable<ReactionThermo>&, Istream&)",
373 ) <<
"Reaction type not specified" <<
nl <<
nl 374 <<
"Valid Reaction types are :" <<
nl 375 << IstreamConstructorTablePtr_->sortedToc()
379 const word reactionTypeName(is);
381 typename IstreamConstructorTable::iterator cstrIter
382 = IstreamConstructorTablePtr_->find(reactionTypeName);
384 if (cstrIter == IstreamConstructorTablePtr_->end())
388 "Reaction<ReactionThermo>::New(const speciesTable&, " 389 " const HashPtrTable<ReactionThermo>&, Istream&)",
391 ) <<
"Unknown reaction type " 392 << reactionTypeName <<
nl <<
nl 393 <<
"Valid reaction types are :" <<
nl 394 << IstreamConstructorTablePtr_->sortedToc()
400 cstrIter()(species, thermoDatabase, is)
405 template<
class ReactionThermo>
414 const word& reactionTypeName = dict.
lookup(
"type");
416 typename dictionaryConstructorTable::iterator cstrIter
417 = dictionaryConstructorTablePtr_->find(reactionTypeName);
419 if (cstrIter == dictionaryConstructorTablePtr_->end())
423 "Reaction<ReactionThermo>::New" 425 "const speciesTable&, " 426 "const HashPtrTable<ReactionThermo>&, " 429 ) <<
"Unknown reaction type " 430 << reactionTypeName <<
nl <<
nl 431 <<
"Valid reaction types are :" <<
nl 432 << dictionaryConstructorTablePtr_->sortedToc()
438 cstrIter()(species, thermoDatabase,
dict)
445 template<
class ReactionThermo>
450 << token::END_STATEMENT <<
nl;
454 template<
class ReactionThermo>
466 template<
class ReactionThermo>
479 template<
class ReactionThermo>
491 template<
class ReactionThermo>
498 template<
class ReactionThermo>
503 "const speciesTable& gasSpecies() const" 506 return NullObjectRef<speciesTable>();
510 template<
class ReactionThermo>
516 "inline const List<typename Reaction<ReactionThermo>::specieCoeffs>&" 517 "Reaction<ReactionThermo>::glhs()" 519 return NullObjectRef<List<specieCoeffs> >();
523 template<
class ReactionThermo>
529 "inline const List<typename Reaction<ReactionThermo>::specieCoeffs>&" 530 "Reaction<ReactionThermo>::grhs()" 532 return NullObjectRef<List<specieCoeffs> >();
Input from memory buffer stream.
virtual const List< specieCoeffs > & grhs() const
const speciesTable & species() const
dimensioned< scalar > mag(const dimensioned< Type > &)
word name(const complex &)
Return a string representation of a complex.
bool empty() const
Return true if the UList is empty (ie, size() is zero).
virtual scalar kf(const scalar p, const scalar T, const scalarField &c) const
Forward rate constant.
T & last()
Return the last element of the list.
void reactionStrLeft(OStringStream &reaction) const
Return string representation of the left of the reaction.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
virtual const speciesTable & gasSpecies() const
string str() const
Return the string.
void clear()
Clear the addressed list, i.e. set the size to zero.
A class for handling words, derived from string.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
A class for handling character strings derived from std::string.
bool isPunctuation() const
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
errorManipArg< error, int > exit(error &err, const int errNo=1)
T remove()
Remove and return the top element.
A list of keyword definitions, which are a keyword followed by any number of values (e...
const word & wordToken() const
bool eof() const
Return true if end of input seen.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
virtual const List< specieCoeffs > & glhs() const
void putBack(const token &)
Put back token.
InfoProxy< token > info() const
Return info proxy.
virtual scalar kr(const scalar kfwd, const scalar p, const scalar T, const scalarField &c) const
Reverse rate constant from the given forward rate constant.
bool good() const
Return true if next operation might succeed.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & shrink()
Shrink the allocated space to the number of elements used.
Output to memory buffer stream.
A token holds items read from Istream.
void setLRhs(Istream &, const speciesTable &, List< specieCoeffs > &lhs, List< specieCoeffs > &rhs)
Construct the left- and right-hand-side reaction coefficients.
Ostream & writeKeyword(const keyType &)
Write the keyword followed by an appropriate indentation.
void reactionStrRight(OStringStream &reaction) const
Return string representation of the right of the reaction.
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
Simple extension of ReactionThermo to handle reaction kinetics in addition to the equilibrium thermod...
virtual void write(Ostream &) const
Write.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects...
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Class to hold the specie index and its coefficients in the.
Info<< "Creating reaction model\n"<< endl;autoPtr< combustionModels::psiCombustionModel > reaction(combustionModels::psiCombustionModel::New(mesh))
A wordList with hashed indices for faster lookup by name.
static autoPtr< Reaction< ReactionThermo > > New(const speciesTable &species, const HashPtrTable< ReactionThermo > &thermoDatabase, Istream &is)
Return a pointer to new patchField created on freestore from input.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
const word dictName() const
Return the local dictionary name (final part of scoped name)
bool contains(const word &) const
Does the list contain the specified name.
Reaction(const speciesTable &species, const List< specieCoeffs > &lhs, const List< specieCoeffs > &rhs, const HashPtrTable< ReactionThermo > &thermoDatabase)
Construct from components.
#define notImplemented(functionName)
Issue a FatalErrorIn for a function not currently implemented.
#define FatalIOErrorIn(functionName, ios)
Report an error message using Foam::FatalIOError.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...