Loading...
Searching...
No Matches
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\*---------------------------------------------------------------------------*/
29#include "solidReaction.H"
30#include "DynamicList.H"
31
32// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
33
34template<class ReactionThermo>
36(
38 const speciesTable& pyrolisisGases,
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 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 );
114
115
116// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
117
118template<class ReactionThermo>
122 return glhs_;
123}
124
125
126template<class ReactionThermo>
129{
130 return grhs_;
131}
132
133
134template<class ReactionThermo>
137{
138 return pyrolisisGases_;
139}
140
141
142template<class ReactionThermo>
144{
146 os.writeEntry("reaction", solidReactionStr(reaction));
147}
148
149
150template<class ReactionThermo>
151Foam::string Foam::solidReaction<ReactionThermo>::solidReactionStr
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
175template<class ReactionThermo>
176void Foam::solidReaction<ReactionThermo>::solidReactionStrLeft
177(
179) const
180{
181 Reaction<ReactionThermo>::reactionStr(reaction, gasSpecies(), glhs());
182}
183
184
185template<class ReactionThermo>
186void Foam::solidReaction<ReactionThermo>::solidReactionStrRight
187(
189) const
190{
191 Reaction<ReactionThermo>::reactionStr(reaction, gasSpecies(), grhs());
192}
193
194
195// ************************************************************************* //
An ISstream with internal List storage. Always UNCOMPRESSED.
virtual void rewind() override
Rewind the stream, clearing any old errors.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition List.H:72
Output to string buffer, using a OSstream. Always UNCOMPRESSED.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition Ostream.H:59
Simple extension of ReactionThermo to handle reaction kinetics in addition to the equilibrium thermod...
Definition Reaction.H:69
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
Reaction(const speciesTable &species, const List< specieCoeffs > &lhs, const List< specieCoeffs > &rhs, const ReactionTable< ReactionThermo > &thermoDatabase, bool initReactionThermo=true)
Construct from components.
Definition Reaction.C:150
const speciesTable & species() const noexcept
Access to specie list.
Definition Reaction.H:313
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
label push_uniq(const word &val)
Append an element if not already in the list.
Lookup type of boundary radiation properties.
Definition lookup.H:60
Read solid reactions of the type S1 = S2 + G1.
solidReaction(const Reaction< ReactionThermo > &reaction, const speciesTable &pyrolisisGases, const List< specieCoeffs > &glhs, const List< specieCoeffs > &grhs)
Construct from components.
virtual const List< specieCoeffs > & glhs() const
virtual void write(Ostream &os) const
Write.
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:76
A class for handling words, derived from Foam::string.
Definition word.H:66
OBJstream os(runTime.globalPath()/outputName)
CombustionModel< rhoReactionThermo > & reaction
hashedWordList speciesTable
A table of species as a hashedWordList.
HashPtrTable< ThermoType > ReactionTable
Definition Reaction.H:52
dictionary dict