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>
114 typename ReactionThermo::thermoType rhsThermo
117 *(*thermoDatabase[species_[rhs_[0].index]]).W()
118 *(*thermoDatabase[species_[rhs_[0].index]])
121 for (
label i=1; i<rhs_.size(); ++i)
125 *(*thermoDatabase[species_[rhs_[i].index]]).W()
126 *(*thermoDatabase[species_[rhs_[i].index]]);
129 typename ReactionThermo::thermoType lhsThermo
132 *(*thermoDatabase[species_[lhs_[0].index]]).W()
133 *(*thermoDatabase[species_[lhs_[0].index]])
136 for (
label i=1; i<lhs_.size(); ++i)
140 *(*thermoDatabase[species_[lhs_[i].index]]).W()
141 *(*thermoDatabase[species_[lhs_[i].index]]);
144 ReactionThermo::thermoType::operator=(lhsThermo == rhsThermo);
151 template<
class ReactionThermo>
160 ReactionThermo::thermoType(*thermoDatabase[species[0]]),
161 name_(
"un-named-reaction-" +
Foam::name(getNewReactionID())),
166 setThermo(thermoDatabase);
170 template<
class ReactionThermo>
177 ReactionThermo::thermoType(r),
178 name_(r.
name() +
"Copy"),
185 template<
class ReactionThermo>
203 exponent = stoichCoeff;
209 size_t i = specieName.find(
'^');
213 string exponentStr = specieName
216 specieName.size() - i - 1
218 exponent = atof(exponentStr.c_str());
219 specieName = specieName(0, i);
224 index = species[specieName];
234 <<
"Expected a word but found " << t.
info()
240 template<
class ReactionThermo>
255 if (dlrhs.
last().index != -1)
263 else if (t == token::ASSIGN)
293 else if (t == token::ASSIGN)
318 <<
"Cannot continue reading reaction data from stream" 323 template<
class ReactionThermo>
331 ReactionThermo::thermoType(*thermoDatabase[species[0]]),
342 setThermo(thermoDatabase);
348 template<
class ReactionThermo>
357 const word& reactionTypeName = dict.
lookup(
"type");
359 typename dictionaryConstructorTable::iterator cstrIter
360 = dictionaryConstructorTablePtr_->find(reactionTypeName);
362 if (cstrIter == dictionaryConstructorTablePtr_->end())
365 <<
"Unknown reaction type " 366 << reactionTypeName <<
nl <<
nl 367 <<
"Valid reaction types are :" <<
nl 368 << dictionaryConstructorTablePtr_->sortedToc()
374 cstrIter()(species, thermoDatabase,
dict)
381 template<
class ReactionThermo>
386 << token::END_STATEMENT <<
nl;
390 template<
class ReactionThermo>
402 template<
class ReactionThermo>
415 template<
class ReactionThermo>
427 template<
class ReactionThermo>
434 template<
class ReactionThermo>
438 return NullObjectRef<speciesTable>();
442 template<
class ReactionThermo>
447 return NullObjectRef<List<specieCoeffs>>();
451 template<
class ReactionThermo>
456 return NullObjectRef<List<specieCoeffs>>();
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.
virtual scalar kf(const scalar p, const scalar T, const scalarField &c) const
Forward rate constant.
bool empty() const
Return true if the UList is empty (ie, size() is zero)
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
errorManipArg< error, int > exit(error &err, const int errNo=1)
virtual const List< specieCoeffs > & grhs() const
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.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
InfoProxy< token > info() const
Return info proxy.
const word & wordToken() const
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
A token holds items read from Istream.
virtual void write(Ostream &) const
Write.
void putBack(const token &)
Put back token.
A HashTable specialization for hashing pointers.
bool good() const
Return true if next operation might succeed.
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...
const word dictName() const
Return the local dictionary name (final part of scoped name)
const speciesTable & species() const
Access to specie list.
void reactionStrLeft(OStringStream &reaction) const
Return string representation of the left of the reaction.
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.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
virtual const List< specieCoeffs > & glhs() const
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.
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 speciesTable & gasSpecies() const
Access to gas specie list.
void reactionStrRight(OStringStream &reaction) const
Return string representation of the right of the reaction.
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.
static autoPtr< Reaction< ReactionThermo > > New(const speciesTable &species, const HashPtrTable< ReactionThermo > &thermoDatabase, const dictionary &dict)
Return a pointer to new patchField created on freestore from dict.
Info<< "Creating reaction model\"<< endl;autoPtr< combustionModels::psiCombustionModel > reaction(combustionModels::psiCombustionModel::New(mesh))
Input from memory buffer stream.
string str() const
Return the string.
dimensioned< scalar > mag(const dimensioned< Type > &)
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
bool contains(const word &) const
Does the list contain the specified name.
T & last()
Return the last element of the list.
void clear()
Clear the addressed list, i.e. set the size to zero.
#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.
bool isPunctuation() const
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.