1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software: you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by
13 the Free Software Foundation, either version 3 of the License, or
14 (at your option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "solidReaction.H"
27 #include "DynamicList.H"
29 /* * * * * * * * * * * * * * * private static data * * * * * * * * * * * * * */
33 defineTypeNameAndDebug(solidReaction, 0);
34 defineRunTimeSelectionTable(solidReaction, Istream);
37 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
39 Foam::solidReaction::solidReaction
41 const speciesTable& componets,
42 const speciesTable& pyrolisisGases,
43 const List<label>& slhs,
44 const List<label>& srhs,
45 const List<label>& grhs
48 components_(componets),
49 pyrolisisGases_(pyrolisisGases),
56 Foam::solidReaction::solidReaction
58 const solidReaction& r,
59 const speciesTable& componets,
60 const speciesTable& pyrolisisGases
63 components_(componets),
64 pyrolisisGases_(pyrolisisGases),
71 Foam::solidReaction::solidReaction
73 const speciesTable& components,
75 const speciesTable& pyrolisisGases
78 components_(components),
79 pyrolisisGases_(pyrolisisGases)
85 Foam::label Foam::solidReaction::componentIndex
95 word componentName = t.wordToken();
97 size_t i = componentName.find('=');
101 string exponentStr = componentName
104 componentName.size() - i - 1
106 componentName = componentName(0, i);
108 if (components_.contains(componentName))
111 return (components_[componentName]);
113 else if (pyrolisisGases_.contains(componentName))
116 return (pyrolisisGases_[componentName]);
122 "solidReaction::componentIndex(bool&, Istream& is)",
125 << "Cannot find component" << componentName
126 << "in tables :" << pyrolisisGases_ << " or "
128 << exit(FatalIOError);
135 FatalIOErrorIn("solidReaction::componentIndex(bool&, Istream& is)", is)
136 << "Expected a word but found " << t.info()
137 << exit(FatalIOError);
143 void Foam::solidReaction::setLRhs(Istream& is)
145 DynamicList<label> dlsrhs;
152 index = componentIndex(isGas, is);
156 dlsrhs.append(index);
160 if (t.isPunctuation())
166 grhs_ = dlsrhs.shrink();
173 srhs_ = dlsrhs.shrink();
174 dlsrhs.clear(); //is.putBack(t);
178 else if (t == token::ASSIGN)
182 Info << "Pyrolysis Gases should appear on lhs of the"
187 slhs_ = dlsrhs.shrink();
193 grhs_ = dlsrhs.shrink();
199 srhs_ = dlsrhs.shrink();
206 grhs_ = dlsrhs.shrink();
212 srhs_ = dlsrhs.shrink();
219 FatalIOErrorIn("solidReaction::lsrhs(Istream& is)", is)
220 << "Cannot find component in tables"
221 << exit(FatalIOError);
225 FatalIOErrorIn("solidReaction::lsrhs(Istream& is)", is)
226 << "Cannot continue reading reaction data from stream"
227 << exit(FatalIOError);
231 // * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
233 Foam::autoPtr<Foam::solidReaction> Foam::solidReaction::New
235 const speciesTable& species,
237 const speciesTable& pyrolisisGases
244 "solidReaction::New(const speciesTable& species,"
245 " const HashPtrTable& thermoDatabase, Istream&)",
247 ) << "solidReaction type not specified" << nl << nl
248 << "Valid solidReaction types are :" << endl
249 << IstreamConstructorTablePtr_->sortedToc()
250 << exit(FatalIOError);
253 const word reactionTypeName(is);
255 IstreamConstructorTable::iterator cstrIter
256 = IstreamConstructorTablePtr_->find(reactionTypeName);
258 if (cstrIter == IstreamConstructorTablePtr_->end())
262 "solidReaction::New(const speciesTable& species,"
263 " const HashPtrTable& thermoDatabase, Istream&)",
265 ) << "Unknown reaction type "
266 << reactionTypeName << nl << nl
267 << "Valid reaction types are :" << endl
268 << IstreamConstructorTablePtr_->sortedToc()
269 << exit(FatalIOError);
272 return autoPtr<solidReaction>
274 cstrIter()(species, is, pyrolisisGases)
279 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
281 void Foam::solidReaction::write(Ostream& os) const
283 os << type() << nl << " ";
287 os << components_[slhs_[i]];
294 os << components_[srhs_[i]];
301 os << pyrolisisGases_[grhs_[i]];
308 Foam::scalar Foam::solidReaction::kf
319 Foam::scalar Foam::solidReaction::nReact() const
325 // ************************************************************************* //