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-------------------------------------------------------------------------------
11License
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
34template<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
50template<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
64template<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.appendUniq(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
115template<class ReactionThermo>
118{
119 return glhs_;
120}
121
122
123template<class ReactionThermo>
126{
127 return grhs_;
128}
129
130
131template<class ReactionThermo>
133gasSpecies() const
134{
135 return pyrolisisGases_;
136}
137
138
139template<class ReactionThermo>
141{
143 os.writeEntry("reaction", solidReactionStr(reaction));
144}
145
146
147template<class ReactionThermo>
149(
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
172template<class ReactionThermo>
174(
175 OStringStream& reaction
176) const
177{
178 Reaction<ReactionThermo>::reactionStr(reaction, gasSpecies(), glhs());
179}
180
181
182template<class ReactionThermo>
184(
185 OStringStream& reaction
186) const
187{
188 Reaction<ReactionThermo>::reactionStr(reaction, gasSpecies(), grhs());
189}
190
191
192// ************************************************************************* //
Input from string buffer, using a ISstream. Always UNCOMPRESSED.
Definition: StringStream.H:112
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: List.H:77
Output to string buffer, using a OSstream. Always UNCOMPRESSED.
Definition: StringStream.H:231
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
Ostream & writeEntry(const keyType &key, const T &value)
Write a keyword/value entry.
Definition: Ostream.H:239
Simple extension of ReactionThermo to handle reaction kinetics in addition to the equilibrium thermod...
Definition: Reaction.H:73
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:248
const speciesTable & species() const noexcept
Access to specie list.
Definition: Reaction.H:270
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
string getString(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Same as get< string >(const word&, keyType::option)
Definition: dictionary.H:1548
virtual bool write()
Write the output fields.
A wordList with hashed named lookup, which can be faster in some situations than using the normal lis...
label appendUniq(const word &val)
Append an element if not already in the list.
Lookup type of boundary radiation properties.
Definition: lookup.H:66
Read solid reactions of the type S1 = S2 + G1.
Definition: solidReaction.H:64
virtual const List< specieCoeffs > & glhs() const
virtual const List< specieCoeffs > & grhs() const
Access to gas components of the reaction.
virtual const speciesTable & gasSpecies() const
Access to gas specie list.
A class for handling character strings derived from std::string.
Definition: string.H:79
A class for handling words, derived from Foam::string.
Definition: word.H:68
OBJstream os(runTime.globalPath()/outputName)
CombustionModel< rhoReactionThermo > & reaction
dictionary dict