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 (
35  const Reaction<ReactionThermo>& reaction,
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 :
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 (
140  OStringStream& reaction
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 (
164  OStringStream& reaction
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 (
189  OStringStream& reaction
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 // ************************************************************************* //
string str() const
Return the string.
dictionary dict
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
virtual void write(Ostream &) const
Write.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
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
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:76
Simple extension of ReactionThermo to handle reaction kinetics in addition to the equilibrium thermod...
Definition: Reaction.H:53
virtual const List< specieCoeffs > & grhs() const
solidReaction(const Reaction< ReactionThermo > &reaction, const speciesTable &pyrolisisGases, const List< specieCoeffs > &glhs, const List< specieCoeffs > &grhs)
Construct from components.
Definition: solidReaction.C:34
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
static const char nl
Definition: Ostream.H:262
Ostream & writeKeyword(const keyType &)
Write the keyword followed by an appropriate indentation.
Definition: Ostream.C:54
Read solid reactions of the type S1 = S2 + G1.
Definition: solidReaction.H:49
A wordList with hashed indices for faster lookup by name.
Info<< "Creating reaction model\n"<< endl;autoPtr< combustionModels::psiCombustionModel > reaction(combustionModels::psiCombustionModel::New(mesh))
Input from memory buffer stream.
Definition: IStringStream.H:49
virtual const List< specieCoeffs > & glhs() const
dimensioned< scalar > mag(const dimensioned< Type > &)
const dictionary & parent() const
Return the parent dictionary.
Definition: dictionary.H:251
virtual const speciesTable & gasSpecies() const
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:366
A class for handling character strings derived from std::string.
Definition: string.H:74
Output to memory buffer stream.
Definition: OStringStream.H:49
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:451