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-2022 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 :
43  Reaction<ReactionThermo>(reaction),
44  pyrolisisGases_(pyrolisisGases),
45  glhs_(glhs),
46  grhs_(grhs)
47 {}
48 
49 
50 template<class ReactionThermo>
52 (
54  const speciesTable& pyrolisisGases
55 )
56 :
57  Reaction<ReactionThermo>(r),
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>
73  (
74  species,
75  thermoDatabase,
76  dict,
77  false, // initReactionThermo = false
78  false // failUnknownSpecie = false
79  ),
80  pyrolisisGases_(dict.parent().parent().lookup("gaseousSpecies")),
81  glhs_(),
82  grhs_()
83 {
84  this->setLRhs
85  (
86  IStringStream(dict.getString("reaction"))(),
87  pyrolisisGases_,
88  glhs_,
89  grhs_,
90  false // failUnknownSpecie = false
91  );
92 
93  speciesTable allSpecies(species);
94  for (const word& gasName : pyrolisisGases_)
95  {
96  allSpecies.push_uniq(gasName);
97  }
98  List<specieCoeffs> dummyLhs;
99  List<specieCoeffs> dummyRhs;
100 
101  // Rescan (and fail) if a species is neither gas nor solid
102  this->setLRhs
103  (
104  IStringStream(dict.getString("reaction"))(),
105  allSpecies,
106  dummyLhs,
107  dummyRhs
108  // failUnknownSpecie = true
109  );
110 }
111 
112 
113 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
114 
115 template<class ReactionThermo>
118 {
119  return glhs_;
120 }
121 
122 
123 template<class ReactionThermo>
126 {
127  return grhs_;
128 }
129 
130 
131 template<class ReactionThermo>
133 gasSpecies() const
134 {
135  return pyrolisisGases_;
136 }
137 
138 
139 template<class ReactionThermo>
141 {
143  os.writeEntry("reaction", solidReactionStr(reaction));
144 }
145 
146 
147 template<class ReactionThermo>
149 (
150  OStringStream& reaction
151 ) const
152 {
153  this->reactionStrLeft(reaction);
154  if (!glhs().empty())
155  {
156  reaction << " + ";
157  solidReactionStrLeft(reaction);
158  }
159 
160  reaction << " = ";
161 
162  this->reactionStrRight(reaction);
163  if (!grhs().empty())
164  {
165  reaction << " + ";
166  solidReactionStrRight(reaction);
167  }
168  return reaction.str();
169 }
170 
171 
172 template<class ReactionThermo>
174 (
175  OStringStream& reaction
176 ) const
177 {
178  Reaction<ReactionThermo>::reactionStr(reaction, gasSpecies(), glhs());
179 }
180 
181 
182 template<class ReactionThermo>
184 (
185  OStringStream& reaction
186 ) const
187 {
188  Reaction<ReactionThermo>::reactionStr(reaction, gasSpecies(), grhs());
189 }
190 
191 
192 // ************************************************************************* //
dictionary dict
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: BitOps.H:56
const speciesTable & species() const noexcept
Access to specie list.
Definition: Reaction.H:313
Ostream & writeEntry(const keyType &key, const T &value)
Write a keyword/value entry.
Definition: Ostream.H:321
virtual const List< specieCoeffs > & grhs() const
Access to gas components of the reaction.
Lookup type of boundary radiation properties.
Definition: lookup.H:57
Simple extension of ReactionThermo to handle reaction kinetics in addition to the equilibrium thermod...
Definition: Reaction.H:55
A class for handling words, derived from Foam::string.
Definition: word.H:63
solidReaction(const Reaction< ReactionThermo > &reaction, const speciesTable &pyrolisisGases, const List< specieCoeffs > &glhs, const List< specieCoeffs > &grhs)
Construct from components.
Definition: solidReaction.C:29
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
virtual const List< specieCoeffs > & glhs() const
OBJstream os(runTime.globalPath()/outputName)
virtual void write(Ostream &os) const
Write.
Read solid reactions of the type S1 = S2 + G1.
Definition: solidReaction.H:47
void setLRhs(Istream &, const speciesTable &, List< specieCoeffs > &lhs, List< specieCoeffs > &rhs, bool failUnknownSpecie=true)
Construct the left- and right-hand-side reaction coefficients.
Definition: Reaction.C:241
CombustionModel< rhoReactionThermo > & reaction
A wordList with hashed named lookup, which can be faster in some situations than using the normal lis...
Input from string buffer, using a ISstream. Always UNCOMPRESSED.
Definition: StringStream.H:120
A class for handling character strings derived from std::string.
Definition: string.H:72
Output to string buffer, using a OSstream. Always UNCOMPRESSED.
Definition: StringStream.H:256
virtual const speciesTable & gasSpecies() const
Access to gas specie list.