1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 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, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
29 Simple extension of ReactionThermo to handle reaction kinetics in addition
30 to the equilibrium thermodynamics already handled.
36 \*---------------------------------------------------------------------------*/
41 #include "speciesTable.H"
42 #include "HashPtrTable.H"
43 #include "scalarField.H"
45 #include "runTimeSelectionTables.H"
47 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
52 // Forward declaration of friend functions and operators
54 template<class ReactionThermo>
57 template<class ReactionThermo>
58 inline Ostream& operator<<(Ostream&, const Reaction<ReactionThermo>&);
61 /*---------------------------------------------------------------------------*\
62 Class Reaction Declaration
63 \*---------------------------------------------------------------------------*/
65 template<class ReactionThermo>
75 //- Class to hold the specie index and its coefficients in the
76 // reaction rate expression
90 specieCoeffs(const speciesTable& species, Istream& is);
92 bool operator==(const specieCoeffs& sc) const
94 return index == sc.index;
97 bool operator!=(const specieCoeffs& sc) const
99 return index != sc.index;
102 friend Ostream& operator<<(Ostream& os, const specieCoeffs& sc)
104 os << sc.index << token::SPACE
105 << sc.stoichCoeff << token::SPACE
116 //- List of specie names present in reaction system
117 const speciesTable& species_;
119 //- Specie info for the left-hand-side of the reaction
120 List<specieCoeffs> lhs_;
122 //- Specie info for the right-hand-side of the reaction
123 List<specieCoeffs> rhs_;
126 // Private member functions
128 void setLRhs(Istream&);
129 void setThermo(const HashPtrTable<ReactionThermo>& thermoDatabase);
131 //- Disallow default bitwise assignment
132 void operator=(const Reaction<ReactionThermo>&);
137 //- Runtime type information
138 TypeName("Reaction");
141 // Declare run-time constructor selection tables
143 declareRunTimeSelectionTable
149 const speciesTable& species,
150 const HashPtrTable<ReactionThermo>& thermoDatabase,
153 (species, thermoDatabase, is)
159 //- Class used for the read-construction of PtrLists of reaction
162 const speciesTable& species_;
163 const HashPtrTable<ReactionThermo>& thermoDatabase_;
169 const speciesTable& species,
170 const HashPtrTable<ReactionThermo>& thermoDatabase
174 thermoDatabase_(thermoDatabase)
177 autoPtr<Reaction> operator()(Istream& is) const
179 return autoPtr<Reaction>
181 Reaction::New(species_, thermoDatabase_, is)
189 //- Construct from components
192 const speciesTable& species,
193 const List<specieCoeffs>& lhs,
194 const List<specieCoeffs>& rhs,
195 const HashPtrTable<ReactionThermo>& thermoDatabase
198 //- Construct as copy given new speciesTable
199 Reaction(const Reaction<ReactionThermo>&, const speciesTable& species);
201 //- Construct from Istream
204 const speciesTable& species,
205 const HashPtrTable<ReactionThermo>& thermoDatabase,
209 //- Construct and return a clone
210 virtual autoPtr<Reaction<ReactionThermo> > clone() const
212 return autoPtr<Reaction<ReactionThermo> >
214 new Reaction<ReactionThermo>(*this)
218 //- Construct and return a clone with new speciesTable
219 virtual autoPtr<Reaction<ReactionThermo> > clone
221 const speciesTable& species
224 return autoPtr<Reaction<ReactionThermo> >
226 new Reaction<ReactionThermo>(*this, species)
233 //- Return a pointer to a new patchField created on freestore from input
234 static autoPtr<Reaction<ReactionThermo> > New
236 const speciesTable& species,
237 const HashPtrTable<ReactionThermo>& thermoDatabase,
252 inline const List<specieCoeffs>& lhs() const;
253 inline const List<specieCoeffs>& rhs() const;
256 // Reaction rate coefficients
258 //- Forward rate constant
266 //- Reverse rate constant from the given forward rate constant
275 //- Reverse rate constant.
276 // Note this evaluates the forward rate constant and divides by the
277 // equilibrium constant
287 virtual void write(Ostream&) const;
292 friend Ostream& operator<< <ReactionThermo>
295 const Reaction<ReactionThermo>&
300 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
302 } // End namespace Foam
304 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
306 #include "ReactionI.H"
308 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
311 # include "Reaction.C"
314 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
318 // ************************************************************************* //