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-2021 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 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
33 
34 template<class ReactionThermo>
36 (
38  const speciesTable& pyrolisisGases,
39  const List<specieCoeffs>& glhs,
40  const List<specieCoeffs>& grhs
41 )
42 :
44  pyrolisisGases_(pyrolisisGases),
45  glhs_(glhs),
46  grhs_(grhs)
47 {}
48 
49 
50 template<class ReactionThermo>
52 (
54  const speciesTable& pyrolisisGases
55 )
56 :
58  pyrolisisGases_(pyrolisisGases),
59  glhs_(r.glhs_),
60  grhs_(r.grhs_)
61 {}
62 
63 
64 template<class ReactionThermo>
66 (
67  const speciesTable& species,
68  const ReactionTable<ReactionThermo>& thermoDatabase,
69  const dictionary& dict
70 )
71 :
72  Reaction<ReactionThermo>(species, thermoDatabase, dict, false),
73  pyrolisisGases_(dict.parent().parent().lookup("gaseousSpecies")),
74  glhs_(),
75  grhs_()
76 {
77  this->setLRhs
78  (
79  IStringStream(dict.getString("reaction"))(),
80  pyrolisisGases_,
81  glhs_,
82  grhs_
83  );
84 }
85 
86 
87 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
88 
89 template<class ReactionThermo>
92 {
93  return glhs_;
94 }
95 
96 
97 template<class ReactionThermo>
100 {
101  return grhs_;
102 }
103 
104 
105 template<class ReactionThermo>
107 gasSpecies() const
108 {
109  return pyrolisisGases_;
110 }
111 
112 
113 template<class ReactionThermo>
115 {
117  os.writeEntry("reaction", solidReactionStr(reaction));
118 }
119 
120 
121 template<class ReactionThermo>
123 (
125 ) const
126 {
127  this->reactionStrLeft(reaction);
128  if (glhs().size() > 0)
129  {
130  reaction << " + ";
131  solidReactionStrLeft(reaction);
132  }
133  reaction << " = ";
134  this->reactionStrRight(reaction);
135  if (grhs().size() > 0)
136  {
137  reaction << " + ";
138  solidReactionStrRight(reaction);
139  }
140  return reaction.str();
141 
142 }
143 
144 
145 template<class ReactionThermo>
147 (
148  OStringStream& reaction
149 ) const
150 {
151  for (label i = 0; i < glhs().size(); ++i)
152  {
153  if (i > 0)
154  {
155  reaction << " + ";
156  }
157  if (mag(glhs()[i].stoichCoeff - 1) > SMALL)
158  {
159  reaction << glhs()[i].stoichCoeff;
160  }
161  reaction << gasSpecies()[glhs()[i].index];
162  if (mag(glhs()[i].exponent - glhs()[i].stoichCoeff) > SMALL)
163  {
164  reaction << "^" << glhs()[i].exponent;
165  }
166  }
167 }
168 
169 
170 template<class ReactionThermo>
172 (
173  OStringStream& reaction
174 ) const
175 {
176 
177  for (label i = 0; i < grhs().size(); ++i)
178  {
179  if (i > 0)
180  {
181  reaction << " + ";
182  }
183  if (mag(grhs()[i].stoichCoeff - 1) > SMALL)
184  {
185  reaction << grhs()[i].stoichCoeff;
186  }
187  reaction << gasSpecies()[grhs()[i].index];
188  if (mag(grhs()[i].exponent - grhs()[i].stoichCoeff) > SMALL)
189  {
190  reaction << "^" << grhs()[i].exponent;
191  }
192  }
193 }
194 
195 // ************************************************************************* //
Foam::string
A class for handling character strings derived from std::string.
Definition: string.H:76
Foam::solidReaction::grhs
virtual const List< specieCoeffs > & grhs() const
Access to gas components of the reaction.
Definition: solidReaction.C:99
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
Foam::solidReaction::write
virtual void write(Ostream &os) const
Write.
Definition: solidReaction.C:114
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:123
os
OBJstream os(runTime.globalPath()/outputName)
Foam::IStringStream
Input from string buffer, using a ISstream. Always UNCOMPRESSED.
Definition: StringStream.H:108
Foam::solidReaction::gasSpecies
virtual const speciesTable & gasSpecies() const
Access to gas specie list.
Definition: solidReaction.C:107
reaction
CombustionModel< rhoReactionThermo > & reaction
Definition: setRegionFluidFields.H:3
Foam::HashPtrTable< ThermoType >
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. Always UNCOMPRESSED.
Definition: StringStream.H:227
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:36
Foam::mag
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
Foam::solidReaction::glhs
virtual const List< specieCoeffs > & glhs() const
Definition: solidReaction.C:91
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:59