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-2017 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  const dictionary& dict
68 )
69 :
70  Reaction<ReactionThermo>(species, thermoDatabase, dict),
71  pyrolisisGases_(dict.parent().parent().lookup("gaseousSpecies")),
72  glhs_(),
73  grhs_()
74 {
75  this->setLRhs
76  (
77  IStringStream(dict.lookup("reaction"))(),
78  pyrolisisGases_,
79  glhs_,
80  grhs_
81  );
82 }
83 
84 
85 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
86 
87 template<class ReactionThermo>
90 {
91  return glhs_;
92 }
93 
94 
95 template<class ReactionThermo>
98 {
99  return grhs_;
100 }
101 
102 
103 template<class ReactionThermo>
105 gasSpecies() const
106 {
107  return pyrolisisGases_;
108 }
109 
110 
111 template<class ReactionThermo>
113 {
115  os.writeKeyword("reaction") << solidReactionStr(reaction)
116  << token::END_STATEMENT << nl;
117 }
118 
119 
120 template<class ReactionThermo>
122 (
123  OStringStream& reaction
124 ) const
125 {
126  this->reactionStrLeft(reaction);
127  if (glhs().size() > 0)
128  {
129  reaction << " + ";
130  solidReactionStrLeft(reaction);
131  }
132  reaction << " = ";
133  this->reactionStrRight(reaction);
134  if (grhs().size() > 0)
135  {
136  reaction << " + ";
137  solidReactionStrRight(reaction);
138  }
139  return reaction.str();
140 
141 }
142 
143 
144 template<class ReactionThermo>
146 (
147  OStringStream& reaction
148 ) const
149 {
150  for (label i = 0; i < glhs().size(); ++i)
151  {
152  if (i > 0)
153  {
154  reaction << " + ";
155  }
156  if (mag(glhs()[i].stoichCoeff - 1) > SMALL)
157  {
158  reaction << glhs()[i].stoichCoeff;
159  }
160  reaction << gasSpecies()[glhs()[i].index];
161  if (mag(glhs()[i].exponent - glhs()[i].stoichCoeff) > SMALL)
162  {
163  reaction << "^" << glhs()[i].exponent;
164  }
165  }
166 }
167 
168 
169 template<class ReactionThermo>
171 (
172  OStringStream& reaction
173 ) const
174 {
175 
176  for (label i = 0; i < grhs().size(); ++i)
177  {
178  if (i > 0)
179  {
180  reaction << " + ";
181  }
182  if (mag(grhs()[i].stoichCoeff - 1) > SMALL)
183  {
184  reaction << grhs()[i].stoichCoeff;
185  }
186  reaction << gasSpecies()[grhs()[i].index];
187  if (mag(grhs()[i].exponent - grhs()[i].stoichCoeff) > SMALL)
188  {
189  reaction << "^" << grhs()[i].exponent;
190  }
191  }
192 }
193 
194 // ************************************************************************* //
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
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:60
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:163
virtual const List< specieCoeffs > & grhs() const
Definition: solidReaction.C:97
A HashTable specialization for hashing pointers.
Definition: HashPtrTable.H:50
Simple extension of ReactionThermo to handle reaction kinetics in addition to the equilibrium thermod...
Definition: Reaction.H:53
const dictionary & parent() const
Return the parent dictionary.
Definition: dictionary.H:260
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
virtual const List< specieCoeffs > & glhs() const
Definition: solidReaction.C:89
virtual void write(Ostream &) const
Write.
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\"<< endl;autoPtr< combustionModels::psiCombustionModel > reaction(combustionModels::psiCombustionModel::New(mesh))
Input from memory buffer stream.
Definition: IStringStream.H:49
string str() const
Return the string.
dimensioned< scalar > mag(const dimensioned< Type > &)
A class for handling character strings derived from std::string.
Definition: string.H:74
Output to memory buffer stream.
Definition: OStringStream.H:49
virtual const speciesTable & gasSpecies() const
Access to gas specie list.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:576