SolidReaction.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2018 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 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
30 
31 template<class ReactionThermo>
33 (
34  const Reaction<ReactionThermo>& reaction,
35  const speciesTable& pyrolisisGases,
36  const List<specieCoeffs>& glhs,
37  const List<specieCoeffs>& grhs
38 )
39 :
41  pyrolisisGases_(pyrolisisGases),
42  glhs_(glhs),
43  grhs_(grhs)
44 {}
45 
46 
47 template<class ReactionThermo>
49 (
51  const speciesTable& pyrolisisGases
52 )
53 :
55  pyrolisisGases_(pyrolisisGases),
56  glhs_(r.glhs_),
57  grhs_(r.grhs_)
58 {}
59 
60 
61 template<class ReactionThermo>
63 (
64  const speciesTable& species,
65  const HashPtrTable<ReactionThermo>& thermoDatabase,
66  const dictionary& dict
67 )
68 :
69  Reaction<ReactionThermo>(species, thermoDatabase, dict),
70  pyrolisisGases_(dict.parent().parent().lookup("gaseousSpecies")),
71  glhs_(),
72  grhs_()
73 {
74  this->setLRhs
75  (
76  IStringStream(dict.lookup("reaction"))(),
77  pyrolisisGases_,
78  glhs_,
79  grhs_
80  );
81 }
82 
83 
84 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
85 
86 template<class ReactionThermo>
89 {
90  return glhs_;
91 }
92 
93 
94 template<class ReactionThermo>
97 {
98  return grhs_;
99 }
100 
101 
102 template<class ReactionThermo>
104 gasSpecies() const
105 {
106  return pyrolisisGases_;
107 }
108 
109 
110 template<class ReactionThermo>
112 {
114  os.writeKeyword("reaction") << solidReactionStr(reaction)
115  << token::END_STATEMENT << nl;
116 }
117 
118 
119 template<class ReactionThermo>
121 (
122  OStringStream& reaction
123 ) const
124 {
125  this->reactionStrLeft(reaction);
126  if (glhs().size() > 0)
127  {
128  reaction << " + ";
129  solidReactionStrLeft(reaction);
130  }
131  reaction << " = ";
132  this->reactionStrRight(reaction);
133  if (grhs().size() > 0)
134  {
135  reaction << " + ";
136  solidReactionStrRight(reaction);
137  }
138  return reaction.str();
139 
140 }
141 
142 
143 template<class ReactionThermo>
145 (
146  OStringStream& reaction
147 ) const
148 {
149  for (label i = 0; i < glhs().size(); ++i)
150  {
151  if (i > 0)
152  {
153  reaction << " + ";
154  }
155  if (mag(glhs()[i].stoichCoeff - 1) > small)
156  {
157  reaction << glhs()[i].stoichCoeff;
158  }
159  reaction << gasSpecies()[glhs()[i].index];
160  if (mag(glhs()[i].exponent - glhs()[i].stoichCoeff) > small)
161  {
162  reaction << "^" << glhs()[i].exponent;
163  }
164  }
165 }
166 
167 
168 template<class ReactionThermo>
170 (
171  OStringStream& reaction
172 ) const
173 {
174 
175  for (label i = 0; i < grhs().size(); ++i)
176  {
177  if (i > 0)
178  {
179  reaction << " + ";
180  }
181  if (mag(grhs()[i].stoichCoeff - 1) > small)
182  {
183  reaction << grhs()[i].stoichCoeff;
184  }
185  reaction << gasSpecies()[grhs()[i].index];
186  if (mag(grhs()[i].exponent - grhs()[i].stoichCoeff) > small)
187  {
188  reaction << "^" << grhs()[i].exponent;
189  }
190  }
191 }
192 
193 // ************************************************************************* //
dictionary dict
virtual const speciesTable & gasSpecies() const
Access to gas specie 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.
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
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:55
virtual const List< specieCoeffs > & glhs() const
Access to the gas components of the right hand side.
Definition: SolidReaction.C:88
virtual const List< specieCoeffs > & grhs() const
Access to the gas components of the left hand side.
Definition: SolidReaction.C:96
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:33
CombustionModel< rhoReactionThermo > & reaction
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:265
Ostream & writeKeyword(const keyType &)
Write the keyword followed by an appropriate indentation.
Definition: Ostream.C:54
virtual void write(Ostream &) const
Write.
A wordList with hashed indices for faster lookup by name.
Input from memory buffer stream.
Definition: IStringStream.H:49
string str() const
Return the string.
Read solid reactions of the type S1 = S2 + G1.
Definition: SolidReaction.H:49
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
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:576