solidReaction.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "solidReaction.H"
27 #include "DynamicList.H"
28 
29 
30 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
31 
32 template<class ReactionThermo>
34 (
36  const speciesTable& pyrolisisGases,
37  const List<specieCoeffs>& glhs,
38  const List<specieCoeffs>& grhs
39 )
40 :
42  pyrolisisGases_(pyrolisisGases),
43  glhs_(glhs),
44  grhs_(grhs)
45 {}
46 
47 
48 template<class ReactionThermo>
50 (
52  const speciesTable& pyrolisisGases
53 )
54 :
55  Reaction<ReactionThermo>(r),
56  pyrolisisGases_(pyrolisisGases),
57  glhs_(r.glhs_),
58  grhs_(r.grhs_)
59 {}
60 
61 
62 template<class ReactionThermo>
64 (
65  const speciesTable& species,
66  const HashPtrTable<ReactionThermo>& thermoDatabase,
67  Istream& is
68 )
69 :
70  Reaction<ReactionThermo>(species, thermoDatabase, is),
71  pyrolisisGases_(),
72  glhs_(),
73  grhs_()
74 {
76 }
77 
78 
79 template<class ReactionThermo>
81 (
82  const speciesTable& species,
83  const HashPtrTable<ReactionThermo>& thermoDatabase,
84  const dictionary& dict
85 )
86 :
87  Reaction<ReactionThermo>(species, thermoDatabase, dict),
88  pyrolisisGases_(dict.parent().parent().lookup("gaseousSpecies")),
89  glhs_(),
90  grhs_()
91 {
92  this->setLRhs
93  (
94  IStringStream(dict.lookup("reaction"))(),
95  pyrolisisGases_,
96  glhs_,
97  grhs_
98  );
99 }
100 
101 
102 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
103 
104 template<class ReactionThermo>
107 {
108  return glhs_;
109 }
110 
111 
112 template<class ReactionThermo>
115 {
116  return grhs_;
117 }
118 
119 
120 template<class ReactionThermo>
122 gasSpecies() const
123 {
124  return pyrolisisGases_;
125 }
126 
127 
128 template<class ReactionThermo>
130 {
132  os.writeKeyword("reaction") << solidReactionStr(reaction)
133  << token::END_STATEMENT << nl;
134 }
135 
136 
137 template<class ReactionThermo>
139 (
141 ) const
142 {
143  this->reactionStrLeft(reaction);
144  if (glhs().size() > 0)
145  {
146  reaction << " + ";
147  solidReactionStrLeft(reaction);
148  }
149  reaction << " = ";
150  this->reactionStrRight(reaction);
151  if (grhs().size() > 0)
152  {
153  reaction << " + ";
154  solidReactionStrRight(reaction);
155  }
156  return reaction.str();
157 
158 }
159 
160 
161 template<class ReactionThermo>
163 (
165 ) const
166 {
167  for (label i = 0; i < glhs().size(); ++i)
168  {
169  if (i > 0)
170  {
171  reaction << " + ";
172  }
173  if (mag(glhs()[i].stoichCoeff - 1) > SMALL)
174  {
175  reaction << glhs()[i].stoichCoeff;
176  }
177  reaction << gasSpecies()[glhs()[i].index];
178  if (mag(glhs()[i].exponent - glhs()[i].stoichCoeff) > SMALL)
179  {
180  reaction << "^" << glhs()[i].exponent;
181  }
182  }
183 }
184 
185 
186 template<class ReactionThermo>
188 (
190 ) const
191 {
192 
193  for (label i = 0; i < grhs().size(); ++i)
194  {
195  if (i > 0)
196  {
197  reaction << " + ";
198  }
199  if (mag(grhs()[i].stoichCoeff - 1) > SMALL)
200  {
201  reaction << grhs()[i].stoichCoeff;
202  }
203  reaction << gasSpecies()[grhs()[i].index];
204  if (mag(grhs()[i].exponent - grhs()[i].stoichCoeff) > SMALL)
205  {
206  reaction << "^" << grhs()[i].exponent;
207  }
208  }
209 }
210 
211 // ************************************************************************* //
Foam::token::END_STATEMENT
@ END_STATEMENT
Definition: token.H:99
Foam::dictionary::lookup
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:449
Foam::string
A class for handling character strings derived from std::string.
Definition: string.H:74
Foam::solidReaction::solidReactionStrLeft
void solidReactionStrLeft(OStringStream &) const
Return string representation of the left of the reaction.
Definition: solidReaction.C:163
Foam::mag
dimensioned< scalar > mag(const dimensioned< Type > &)
Foam::solidReaction::write
virtual void write(Ostream &) const
Write.
Definition: solidReaction.C:129
Foam::solidReaction::grhs
virtual const List< specieCoeffs > & grhs() const
Definition: solidReaction.C:114
solidReaction.H
NotImplemented
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:365
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
Foam::hashedWordList
A wordList with hashed indices for faster lookup by name.
Definition: hashedWordList.H:57
Foam::speciesTable
hashedWordList speciesTable
A table of species as a hashedWordList.
Definition: speciesTable.H:41
Foam::nl
static const char nl
Definition: Ostream.H:260
Foam::dictionary::parent
const dictionary & parent() const
Return the parent dictionary.
Definition: dictionary.H:251
Foam::solidReaction::solidReactionStr
string solidReactionStr(OStringStream &) const
Return string representation of reaction.
Definition: solidReaction.C:139
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
Foam::IStringStream
Input from memory buffer stream.
Definition: IStringStream.H:49
Foam::solidReaction::gasSpecies
virtual const speciesTable & gasSpecies() const
Definition: solidReaction.C:122
reaction
Info<< "Creating reaction model\n"<< endl;autoPtr< combustionModels::psiCombustionModel > reaction(combustionModels::psiCombustionModel::New(mesh))
Foam::HashPtrTable< ReactionThermo >
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
Foam::OStringStream
Output to memory buffer stream.
Definition: OStringStream.H:49
Foam::solidReaction::solidReaction
solidReaction(const Reaction< ReactionThermo > &reaction, const speciesTable &pyrolisisGases, const List< specieCoeffs > &glhs, const List< specieCoeffs > &grhs)
Construct from components.
Definition: solidReaction.C:34
Foam::Ostream::writeKeyword
Ostream & writeKeyword(const keyType &)
Write the keyword followed by an appropriate indentation.
Definition: Ostream.C:59
Foam::solidReaction::glhs
virtual const List< specieCoeffs > & glhs() const
Definition: solidReaction.C:106
Foam::solidReaction
Read solid reactions of the type S1 = S2 + G1.
Definition: solidReaction.H:49
DynamicList.H
Foam::List::size
void size(const label)
Override size to be inconsistent with allocated storage.
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53
Foam::Reaction
Simple extension of ReactionThermo to handle reaction kinetics in addition to the equilibrium thermod...
Definition: Reaction.H:53
Foam::solidReaction::solidReactionStrRight
void solidReactionStrRight(OStringStream &) const
Return string representation of the right of the reaction.
Definition: solidReaction.C:188