Home
Downloads
Documentation
Installation
User Guide
man-pages
API Documentation
README
Release Notes
Changes
License
Support
SourceForge Project
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
src
thermophysicalModels
specie
reaction
Reactions_
Reaction
Reaction.H
Go to the documentation of this file.
1
/*---------------------------------------------------------------------------*\
2
========= |
3
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4
\\ / O peration |
5
\\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
6
\\/ M anipulation |
7
-------------------------------------------------------------------------------
8
License
9
This file is part of OpenFOAM.
10
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.
15
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
19
for more details.
20
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/>.
23
24
Class
25
Foam::Reaction
26
27
Description
28
Simple extension of ReactionThermo to handle reaction kinetics in addition
29
to the equilibrium thermodynamics already handled.
30
31
SourceFiles
32
ReactionI.H
33
Reaction.C
34
35
\*---------------------------------------------------------------------------*/
36
37
#ifndef Reaction_H
38
#define Reaction_H
39
40
#include <
specie/speciesTable.H
>
41
#include <
OpenFOAM/HashPtrTable.H
>
42
#include <
OpenFOAM/scalarField.H
>
43
#include <
OpenFOAM/typeInfo.H
>
44
#include <
OpenFOAM/runTimeSelectionTables.H
>
45
46
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47
48
namespace
Foam
49
{
50
51
// Forward declaration of friend functions and operators
52
53
template
<
class
ReactionThermo>
54
class
Reaction;
55
56
template
<
class
ReactionThermo>
57
inline
Ostream& operator<<(Ostream&, const Reaction<ReactionThermo>&);
58
59
60
/*---------------------------------------------------------------------------*\
61
Class Reaction Declaration
62
\*---------------------------------------------------------------------------*/
63
64
template
<
class
ReactionThermo>
65
class
Reaction
66
:
67
public
ReactionThermo
68
{
69
70
public
:
71
72
// Public data types
73
74
//- Class to hold the specie index and its coefficients in the
75
// reaction rate expression
76
struct
specieCoeffs
77
{
78
label
index
;
79
scalar
stoichCoeff
;
80
scalar
exponent
;
81
82
specieCoeffs
()
83
:
84
index
(-1),
85
stoichCoeff
(0),
86
exponent
(1)
87
{}
88
89
specieCoeffs
(
const
speciesTable
& species,
Istream
& is);
90
91
bool
operator==
(
const
specieCoeffs
& sc)
const
92
{
93
return
index
== sc.
index
;
94
}
95
96
bool
operator!=
(
const
specieCoeffs
& sc)
const
97
{
98
return
index
!= sc.
index
;
99
}
100
101
friend
Ostream
&
operator<<
(
Ostream
& os,
const
specieCoeffs
& sc)
102
{
103
os << sc.
index
<<
token::SPACE
104
<< sc.
stoichCoeff
<<
token::SPACE
105
<< sc.
exponent
;
106
return
os;
107
}
108
};
109
110
111
private
:
112
113
// Private data
114
115
//- List of specie names present in reaction system
116
const
speciesTable
& species_;
117
118
//- Specie info for the left-hand-side of the reaction
119
List<specieCoeffs>
lhs_;
120
121
//- Specie info for the right-hand-side of the reaction
122
List<specieCoeffs>
rhs_;
123
124
125
// Private member functions
126
127
void
setLRhs(
Istream
&);
128
void
setThermo(
const
HashPtrTable<ReactionThermo>
& thermoDatabase);
129
130
//- Disallow default bitwise assignment
131
void
operator=(
const
Reaction<ReactionThermo>
&);
132
133
134
public
:
135
136
//- Runtime type information
137
TypeName
(
"Reaction"
);
138
139
140
// Declare run-time constructor selection tables
141
142
declareRunTimeSelectionTable
143
(
144
autoPtr
,
145
Reaction
,
146
Istream
,
147
(
148
const
speciesTable
& species,
149
const
HashPtrTable<ReactionThermo>
& thermoDatabase,
150
Istream
& is
151
),
152
(species, thermoDatabase, is)
153
);
154
155
156
// Public classes
157
158
//- Class used for the read-construction of PtrLists of reaction
159
class
iNew
160
{
161
const
speciesTable
& species_;
162
const
HashPtrTable<ReactionThermo>
& thermoDatabase_;
163
164
public
:
165
166
iNew
167
(
168
const
speciesTable
& species,
169
const
HashPtrTable<ReactionThermo>
& thermoDatabase
170
)
171
:
172
species_(species),
173
thermoDatabase_(thermoDatabase)
174
{}
175
176
autoPtr<Reaction>
operator()
(
Istream
& is)
const
177
{
178
return
autoPtr<Reaction>
179
(
180
Reaction::New
(species_, thermoDatabase_, is)
181
);
182
}
183
};
184
185
186
// Constructors
187
188
//- Construct from components
189
Reaction
190
(
191
const
speciesTable
& species,
192
const
List<specieCoeffs>
&
lhs
,
193
const
List<specieCoeffs>
&
rhs
,
194
const
HashPtrTable<ReactionThermo>
& thermoDatabase
195
);
196
197
//- Construct as copy given new speciesTable
198
Reaction
(
const
Reaction<ReactionThermo>
&,
const
speciesTable
& species);
199
200
//- Construct from Istream
201
Reaction
202
(
203
const
speciesTable
& species,
204
const
HashPtrTable<ReactionThermo>
& thermoDatabase,
205
Istream
& is
206
);
207
208
//- Construct and return a clone
209
virtual
autoPtr<Reaction<ReactionThermo>
>
clone
()
const
210
{
211
return
autoPtr<Reaction<ReactionThermo>
>
212
(
213
new
Reaction<ReactionThermo>
(*this)
214
);
215
}
216
217
//- Construct and return a clone with new speciesTable
218
virtual
autoPtr<Reaction<ReactionThermo>
>
clone
219
(
220
const
speciesTable
& species
221
)
const
222
{
223
return
autoPtr<Reaction<ReactionThermo>
>
224
(
225
new
Reaction<ReactionThermo>
(*
this
, species)
226
);
227
}
228
229
230
// Selectors
231
232
//- Return a pointer to a new patchField created on freestore from input
233
static
autoPtr<Reaction<ReactionThermo>
>
New
234
(
235
const
speciesTable
& species,
236
const
HashPtrTable<ReactionThermo>
& thermoDatabase,
237
Istream
&
238
);
239
240
241
// Destructor
242
243
virtual
~Reaction
()
244
{}
245
246
247
// Member Functions
248
249
// Access
250
251
inline
const
List<specieCoeffs>
&
lhs
()
const
;
252
inline
const
List<specieCoeffs>
&
rhs
()
const
;
253
254
255
// Reaction rate coefficients
256
257
//- Forward rate constant
258
virtual
scalar
kf
259
(
260
const
scalar
T
,
261
const
scalar
p
,
262
const
scalarField
& c
263
)
const
;
264
265
//- Reverse rate constant from the given forward rate constant
266
virtual
scalar
kr
267
(
268
const
scalar kfwd,
269
const
scalar
T
,
270
const
scalar
p
,
271
const
scalarField
& c
272
)
const
;
273
274
//- Reverse rate constant.
275
// Note this evaluates the forward rate constant and divides by the
276
// equilibrium constant
277
virtual
scalar
kr
278
(
279
const
scalar
T
,
280
const
scalar
p
,
281
const
scalarField
& c
282
)
const
;
283
284
285
//- Write
286
virtual
void
write
(
Ostream
&)
const
;
287
288
289
// Ostream Operator
290
291
friend
Ostream
& operator<< <ReactionThermo>
292
(
293
Ostream
&,
294
const
Reaction<ReactionThermo>
&
295
);
296
};
297
298
299
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
300
301
}
// End namespace Foam
302
303
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
304
305
#include <
specie/ReactionI.H
>
306
307
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
308
309
#ifdef NoRepository
310
# include <
specie/Reaction.C
>
311
#endif
312
313
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
314
315
#endif
316
317
// ************************ vim: set sw=4 sts=4 et: ************************ //