00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #ifndef Reaction_H
00039 #define Reaction_H
00040
00041 #include "speciesTable.H"
00042 #include "HashPtrTable.H"
00043 #include "scalarField.H"
00044 #include "typeInfo.H"
00045 #include "runTimeSelectionTables.H"
00046
00047
00048
00049 namespace Foam
00050 {
00051
00052
00053
00054 template<class ReactionThermo>
00055 class Reaction;
00056
00057 template<class ReactionThermo>
00058 inline Ostream& operator<<(Ostream&, const Reaction<ReactionThermo>&);
00059
00060
00061
00062
00063
00064
00065 template<class ReactionThermo>
00066 class Reaction
00067 :
00068 public ReactionThermo
00069 {
00070
00071 public:
00072
00073
00074
00075
00076
00077 struct specieCoeffs
00078 {
00079 label index;
00080 scalar stoichCoeff;
00081 scalar exponent;
00082
00083 specieCoeffs()
00084 {}
00085
00086 specieCoeffs(const speciesTable& species, Istream& is);
00087
00088 bool operator==(const specieCoeffs& sc) const
00089 {
00090 return index == sc.index;
00091 }
00092
00093 bool operator!=(const specieCoeffs& sc) const
00094 {
00095 return index != sc.index;
00096 }
00097
00098 friend Ostream& operator<<(Ostream& os, const specieCoeffs& sc)
00099 {
00100 os << sc.index << token::SPACE
00101 << sc.stoichCoeff << token::SPACE
00102 << sc.exponent;
00103 return os;
00104 }
00105 };
00106
00107
00108 private:
00109
00110
00111
00112
00113 const speciesTable& species_;
00114
00115
00116 List<specieCoeffs> lhs_;
00117
00118
00119 List<specieCoeffs> rhs_;
00120
00121
00122
00123
00124 void setLRhs(Istream&);
00125 void setThermo(const HashPtrTable<ReactionThermo>& thermoDatabase);
00126
00127
00128 void operator=(const Reaction<ReactionThermo>&);
00129
00130
00131 public:
00132
00133
00134 TypeName("Reaction");
00135
00136
00137
00138
00139 declareRunTimeSelectionTable
00140 (
00141 autoPtr,
00142 Reaction,
00143 Istream,
00144 (
00145 const speciesTable& species,
00146 const HashPtrTable<ReactionThermo>& thermoDatabase,
00147 Istream& is
00148 ),
00149 (species, thermoDatabase, is)
00150 );
00151
00152
00153
00154
00155
00156 class iNew
00157 {
00158 const speciesTable& species_;
00159 const HashPtrTable<ReactionThermo>& thermoDatabase_;
00160
00161 public:
00162
00163 iNew
00164 (
00165 const speciesTable& species,
00166 const HashPtrTable<ReactionThermo>& thermoDatabase
00167 )
00168 :
00169 species_(species),
00170 thermoDatabase_(thermoDatabase)
00171 {}
00172
00173 autoPtr<Reaction> operator()(Istream& is) const
00174 {
00175 return autoPtr<Reaction>
00176 (
00177 Reaction::New(species_, thermoDatabase_, is)
00178 );
00179 }
00180 };
00181
00182
00183
00184
00185
00186 Reaction
00187 (
00188 const speciesTable& species,
00189 const List<specieCoeffs>& lhs,
00190 const List<specieCoeffs>& rhs,
00191 const HashPtrTable<ReactionThermo>& thermoDatabase
00192 );
00193
00194
00195 Reaction(const Reaction<ReactionThermo>&, const speciesTable& species);
00196
00197
00198 Reaction
00199 (
00200 const speciesTable& species,
00201 const HashPtrTable<ReactionThermo>& thermoDatabase,
00202 Istream& is
00203 );
00204
00205
00206 virtual autoPtr<Reaction<ReactionThermo> > clone() const
00207 {
00208 return autoPtr<Reaction<ReactionThermo> >
00209 (
00210 new Reaction<ReactionThermo>(*this)
00211 );
00212 }
00213
00214
00215 virtual autoPtr<Reaction<ReactionThermo> > clone
00216 (
00217 const speciesTable& species
00218 ) const
00219 {
00220 return autoPtr<Reaction<ReactionThermo> >
00221 (
00222 new Reaction<ReactionThermo>(*this, species)
00223 );
00224 }
00225
00226
00227
00228
00229
00230 static autoPtr<Reaction<ReactionThermo> > New
00231 (
00232 const speciesTable& species,
00233 const HashPtrTable<ReactionThermo>& thermoDatabase,
00234 Istream&
00235 );
00236
00237
00238
00239
00240 virtual ~Reaction()
00241 {}
00242
00243
00244
00245
00246
00247
00248 inline const List<specieCoeffs>& lhs() const;
00249 inline const List<specieCoeffs>& rhs() const;
00250
00251
00252
00253
00254
00255 virtual scalar kf
00256 (
00257 const scalar T,
00258 const scalar p,
00259 const scalarField& c
00260 ) const;
00261
00262
00263 virtual scalar kr
00264 (
00265 const scalar kfwd,
00266 const scalar T,
00267 const scalar p,
00268 const scalarField& c
00269 ) const;
00270
00271
00272
00273
00274 virtual scalar kr
00275 (
00276 const scalar T,
00277 const scalar p,
00278 const scalarField& c
00279 ) const;
00280
00281
00282
00283 virtual void write(Ostream&) const;
00284
00285
00286
00287
00288 friend Ostream& operator<< <ReactionThermo>
00289 (
00290 Ostream&,
00291 const Reaction<ReactionThermo>&
00292 );
00293 };
00294
00295
00296
00297
00298 }
00299
00300
00301
00302 #include "ReactionI.H"
00303
00304
00305
00306 #ifdef NoRepository
00307 # include "Reaction.C"
00308 #endif
00309
00310
00311
00312 #endif
00313
00314