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)
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>
371 ) <<
"Reaction type not specified" <<
nl <<
nl 372 <<
"Valid Reaction types are :" <<
nl 373 << IstreamConstructorTablePtr_->sortedToc()
377 const word reactionTypeName(is);
379 typename IstreamConstructorTable::iterator cstrIter
380 = IstreamConstructorTablePtr_->find(reactionTypeName);
382 if (cstrIter == IstreamConstructorTablePtr_->end())
387 ) <<
"Unknown reaction type " 388 << reactionTypeName <<
nl <<
nl 389 <<
"Valid reaction types are :" <<
nl 390 << IstreamConstructorTablePtr_->sortedToc()
396 cstrIter()(species, thermoDatabase, is)
401 template<
class ReactionThermo>
410 const word& reactionTypeName = dict.
lookup(
"type");
412 typename dictionaryConstructorTable::iterator cstrIter
413 = dictionaryConstructorTablePtr_->find(reactionTypeName);
415 if (cstrIter == dictionaryConstructorTablePtr_->end())
418 <<
"Unknown reaction type " 419 << reactionTypeName <<
nl <<
nl 420 <<
"Valid reaction types are :" <<
nl 421 << dictionaryConstructorTablePtr_->sortedToc()
427 cstrIter()(species, thermoDatabase,
dict)
434 template<
class ReactionThermo>
439 << token::END_STATEMENT <<
nl;
443 template<
class ReactionThermo>
455 template<
class ReactionThermo>
468 template<
class ReactionThermo>
480 template<
class ReactionThermo>
487 template<
class ReactionThermo>
491 return NullObjectRef<speciesTable>();
495 template<
class ReactionThermo>
500 return NullObjectRef<List<specieCoeffs>>();
504 template<
class ReactionThermo>
509 return NullObjectRef<List<specieCoeffs>>();
bool eof() const
Return true if end of input seen.
string str() const
Return the string.
#define forAll(list, i)
Loop across all elements in list.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
virtual const List< specieCoeffs > & grhs() const
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.
errorManipArg< error, int > exit(error &err, const int errNo=1)
A list of keyword definitions, which are a keyword followed by any number of values (e...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
bool empty() const
Return true if the UList is empty (ie, size() is zero)
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
const word dictName() const
Return the local dictionary name (final part of scoped name)
A token holds items read from Istream.
bool good() const
Return true if next operation might succeed.
void putBack(const token &)
Put back token.
void reactionStrRight(OStringStream &reaction) const
Return string representation of the right of the reaction.
Class to hold the specie index and its coefficients in the.
Simple extension of ReactionThermo to handle reaction kinetics in addition to the equilibrium thermod...
virtual scalar kf(const scalar p, const scalar T, const scalarField &c) const
Forward rate constant.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects...
A class for handling words, derived from string.
void reactionStrLeft(OStringStream &reaction) const
Return string representation of the left of the reaction.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
virtual void write(Ostream &) const
Write.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
DynamicList< T, SizeInc, SizeMult, SizeDiv > & shrink()
Shrink the allocated space to the number of elements used.
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.
Ostream & writeKeyword(const keyType &)
Write the keyword followed by an appropriate indentation.
word name(const complex &)
Return a string representation of a complex.
virtual const List< specieCoeffs > & glhs() const
T remove()
Remove and return the top element.
Reaction(const speciesTable &species, const List< specieCoeffs > &lhs, const List< specieCoeffs > &rhs, const HashPtrTable< ReactionThermo > &thermoDatabase)
Construct from components.
void setLRhs(Istream &, const speciesTable &, List< specieCoeffs > &lhs, List< specieCoeffs > &rhs)
Construct the left- and right-hand-side reaction coefficients.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
A wordList with hashed indices for faster lookup by name.
InfoProxy< token > info() const
Return info proxy.
Info<< "Creating reaction model\n"<< endl;autoPtr< combustionModels::psiCombustionModel > reaction(combustionModels::psiCombustionModel::New(mesh))
Input from memory buffer stream.
const word & wordToken() const
dimensioned< scalar > mag(const dimensioned< Type > &)
bool contains(const word &) const
Does the list contain the specified name.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
bool isPunctuation() const
T & last()
Return the last element of the list.
void clear()
Clear the addressed list, i.e. set the size to zero.
const speciesTable & species() const
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
A class for handling character strings derived from std::string.
Output to memory buffer stream.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
virtual const speciesTable & gasSpecies() const