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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2017 OpenFOAM Foundation
9  Copyright (C) 2017 OpenCFD Ltd
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
29 #include "solidReaction.H"
30 #include "DynamicList.H"
31 
32 
33 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
34 
35 template<class ReactionThermo>
37 (
39  const speciesTable& pyrolisisGases,
40  const List<specieCoeffs>& glhs,
41  const List<specieCoeffs>& grhs
42 )
43 :
45  pyrolisisGases_(pyrolisisGases),
46  glhs_(glhs),
47  grhs_(grhs)
48 {}
49 
50 
51 template<class ReactionThermo>
53 (
55  const speciesTable& pyrolisisGases
56 )
57 :
59  pyrolisisGases_(pyrolisisGases),
60  glhs_(r.glhs_),
61  grhs_(r.grhs_)
62 {}
63 
64 
65 template<class ReactionThermo>
67 (
68  const speciesTable& species,
69  const HashPtrTable<ReactionThermo>& thermoDatabase,
70  const dictionary& dict
71 )
72 :
73  Reaction<ReactionThermo>(species, thermoDatabase, dict, false),
74  pyrolisisGases_(dict.parent().parent().lookup("gaseousSpecies")),
75  glhs_(),
76  grhs_()
77 {
78  this->setLRhs
79  (
80  IStringStream(dict.getString("reaction"))(),
81  pyrolisisGases_,
82  glhs_,
83  grhs_
84  );
85 }
86 
87 
88 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
89 
90 template<class ReactionThermo>
93 {
94  return glhs_;
95 }
96 
97 
98 template<class ReactionThermo>
101 {
102  return grhs_;
103 }
104 
105 
106 template<class ReactionThermo>
108 gasSpecies() const
109 {
110  return pyrolisisGases_;
111 }
112 
113 
114 template<class ReactionThermo>
116 {
118  os.writeEntry("reaction", solidReactionStr(reaction));
119 }
120 
121 
122 template<class ReactionThermo>
124 (
126 ) const
127 {
128  this->reactionStrLeft(reaction);
129  if (glhs().size() > 0)
130  {
131  reaction << " + ";
132  solidReactionStrLeft(reaction);
133  }
134  reaction << " = ";
135  this->reactionStrRight(reaction);
136  if (grhs().size() > 0)
137  {
138  reaction << " + ";
139  solidReactionStrRight(reaction);
140  }
141  return reaction.str();
142 
143 }
144 
145 
146 template<class ReactionThermo>
148 (
149  OStringStream& reaction
150 ) const
151 {
152  for (label i = 0; i < glhs().size(); ++i)
153  {
154  if (i > 0)
155  {
156  reaction << " + ";
157  }
158  if (mag(glhs()[i].stoichCoeff - 1) > SMALL)
159  {
160  reaction << glhs()[i].stoichCoeff;
161  }
162  reaction << gasSpecies()[glhs()[i].index];
163  if (mag(glhs()[i].exponent - glhs()[i].stoichCoeff) > SMALL)
164  {
165  reaction << "^" << glhs()[i].exponent;
166  }
167  }
168 }
169 
170 
171 template<class ReactionThermo>
173 (
174  OStringStream& reaction
175 ) const
176 {
177 
178  for (label i = 0; i < grhs().size(); ++i)
179  {
180  if (i > 0)
181  {
182  reaction << " + ";
183  }
184  if (mag(grhs()[i].stoichCoeff - 1) > SMALL)
185  {
186  reaction << grhs()[i].stoichCoeff;
187  }
188  reaction << gasSpecies()[grhs()[i].index];
189  if (mag(grhs()[i].exponent - grhs()[i].stoichCoeff) > SMALL)
190  {
191  reaction << "^" << grhs()[i].exponent;
192  }
193  }
194 }
195 
196 // ************************************************************************* //
Foam::string
A class for handling character strings derived from std::string.
Definition: string.H:73
Foam::solidReaction::write
virtual void write(Ostream &) const
Write.
Definition: solidReaction.C:115
Foam::solidReaction::grhs
virtual const List< specieCoeffs > & grhs() const
Access to gas components of the reaction.
Definition: solidReaction.C:100
solidReaction.H
Foam::hashedWordList
A wordList with hashed named lookup, which can be faster in some situations than using the normal lis...
Definition: hashedWordList.H:54
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
Foam::IStringStream
Input from string buffer, using a ISstream.
Definition: StringStream.H:111
Foam::solidReaction::gasSpecies
virtual const speciesTable & gasSpecies() const
Access to gas specie list.
Definition: solidReaction.C:108
reaction
CombustionModel< rhoReactionThermo > & reaction
Definition: setRegionFluidFields.H:3
Foam::HashPtrTable
A HashTable of pointers to objects of type <T>, with deallocation management of the pointers.
Definition: HashPtrTable.H:54
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: BitOps.H:63
Foam::OStringStream
Output to string buffer, using a OSstream.
Definition: StringStream.H:196
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:37
Foam::mag
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
Foam::solidReaction::glhs
virtual const List< specieCoeffs > & glhs() const
Definition: solidReaction.C:92
Foam::Ostream::writeEntry
Ostream & writeEntry(const keyType &key, const T &value)
Write a keyword/value entry.
Definition: Ostream.H:232
Foam::solidReaction
Read solid reactions of the type S1 = S2 + G1.
Definition: solidReaction.H:52
DynamicList.H
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::Reaction
Simple extension of ReactionThermo to handle reaction kinetics in addition to the equilibrium thermod...
Definition: Reaction.H:56