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  ICharStream reactionIs(dict.getString("reaction"));
85 
86  this->setLRhs
87  (
88  reactionIs,
89  pyrolisisGases_,
90  glhs_,
91  grhs_,
92  false // failUnknownSpecie = false
93  );
94 
95  speciesTable allSpecies(species);
96  for (const word& gasName : pyrolisisGases_)
97  {
98  allSpecies.push_uniq(gasName);
99  }
100  List<specieCoeffs> dummyLhs;
101  List<specieCoeffs> dummyRhs;
102 
103  // Rescan (and fail) if a species is neither gas nor solid
104  reactionIs.rewind();
105  this->setLRhs
106  (
107  reactionIs,
108  allSpecies,
109  dummyLhs,
110  dummyRhs
111  // failUnknownSpecie = true
112  );
113 }
114 
115 
116 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
117 
118 template<class ReactionThermo>
121 {
122  return glhs_;
123 }
124 
125 
126 template<class ReactionThermo>
129 {
130  return grhs_;
131 }
132 
133 
134 template<class ReactionThermo>
136 gasSpecies() const
137 {
138  return pyrolisisGases_;
139 }
140 
141 
142 template<class ReactionThermo>
144 {
146  os.writeEntry("reaction", solidReactionStr(reaction));
147 }
148 
149 
150 template<class ReactionThermo>
152 (
153  OStringStream& reaction
154 ) const
155 {
156  this->reactionStrLeft(reaction);
157  if (!glhs().empty())
158  {
159  reaction << " + ";
160  solidReactionStrLeft(reaction);
161  }
162 
163  reaction << " = ";
164 
165  this->reactionStrRight(reaction);
166  if (!grhs().empty())
167  {
168  reaction << " + ";
169  solidReactionStrRight(reaction);
170  }
171  return reaction.str();
172 }
173 
174 
175 template<class ReactionThermo>
177 (
178  OStringStream& reaction
179 ) const
180 {
181  Reaction<ReactionThermo>::reactionStr(reaction, gasSpecies(), glhs());
182 }
183 
184 
185 template<class ReactionThermo>
187 (
188  OStringStream& reaction
189 ) const
190 {
191  Reaction<ReactionThermo>::reactionStr(reaction, gasSpecies(), grhs());
192 }
193 
194 
195 // ************************************************************************* //
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...
An ISstream with internal List storage. Always UNCOMPRESSED.
Definition: ICharStream.H:241
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:208
virtual const speciesTable & gasSpecies() const
Access to gas specie list.