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 #include "hPsiMixtureThermo.H"
00028 #include "fvMesh.H"
00029 #include "fixedValueFvPatchFields.H"
00030
00031
00032
00033 template<class MixtureType>
00034 void Foam::hPsiMixtureThermo<MixtureType>::calculate()
00035 {
00036 const scalarField& hCells = h_.internalField();
00037 const scalarField& pCells = p_.internalField();
00038
00039 scalarField& TCells = T_.internalField();
00040 scalarField& psiCells = psi_.internalField();
00041 scalarField& muCells = mu_.internalField();
00042 scalarField& alphaCells = alpha_.internalField();
00043
00044 forAll(TCells, celli)
00045 {
00046 const typename MixtureType::thermoType& mixture =
00047 this->cellMixture(celli);
00048
00049 TCells[celli] = mixture.TH(hCells[celli], TCells[celli]);
00050 psiCells[celli] = mixture.psi(pCells[celli], TCells[celli]);
00051
00052 muCells[celli] = mixture.mu(TCells[celli]);
00053 alphaCells[celli] = mixture.alpha(TCells[celli]);
00054 }
00055
00056 forAll(T_.boundaryField(), patchi)
00057 {
00058 fvPatchScalarField& pp = p_.boundaryField()[patchi];
00059 fvPatchScalarField& pT = T_.boundaryField()[patchi];
00060 fvPatchScalarField& ppsi = psi_.boundaryField()[patchi];
00061
00062 fvPatchScalarField& ph = h_.boundaryField()[patchi];
00063
00064 fvPatchScalarField& pmu_ = mu_.boundaryField()[patchi];
00065 fvPatchScalarField& palpha_ = alpha_.boundaryField()[patchi];
00066
00067 if (pT.fixesValue())
00068 {
00069 forAll(pT, facei)
00070 {
00071 const typename MixtureType::thermoType& mixture =
00072 this->patchFaceMixture(patchi, facei);
00073
00074 ph[facei] = mixture.H(pT[facei]);
00075
00076 ppsi[facei] = mixture.psi(pp[facei], pT[facei]);
00077 pmu_[facei] = mixture.mu(pT[facei]);
00078 palpha_[facei] = mixture.alpha(pT[facei]);
00079 }
00080 }
00081 else
00082 {
00083 forAll(pT, facei)
00084 {
00085 const typename MixtureType::thermoType& mixture =
00086 this->patchFaceMixture(patchi, facei);
00087
00088 pT[facei] = mixture.TH(ph[facei], pT[facei]);
00089
00090 ppsi[facei] = mixture.psi(pp[facei], pT[facei]);
00091 pmu_[facei] = mixture.mu(pT[facei]);
00092 palpha_[facei] = mixture.alpha(pT[facei]);
00093 }
00094 }
00095 }
00096 }
00097
00098
00099
00100
00101 template<class MixtureType>
00102 Foam::hPsiMixtureThermo<MixtureType>::hPsiMixtureThermo(const fvMesh& mesh)
00103 :
00104 hCombustionThermo(mesh),
00105 MixtureType(*this, mesh)
00106 {
00107 scalarField& hCells = h_.internalField();
00108 const scalarField& TCells = T_.internalField();
00109
00110 forAll(hCells, celli)
00111 {
00112 hCells[celli] = this->cellMixture(celli).H(TCells[celli]);
00113 }
00114
00115 forAll(h_.boundaryField(), patchi)
00116 {
00117 h_.boundaryField()[patchi] == h(T_.boundaryField()[patchi], patchi);
00118 }
00119
00120 hBoundaryCorrection(h_);
00121
00122 calculate();
00123
00124
00125 psi_.oldTime();
00126 }
00127
00128
00129
00130
00131 template<class MixtureType>
00132 Foam::hPsiMixtureThermo<MixtureType>::~hPsiMixtureThermo()
00133 {}
00134
00135
00136
00137
00138 template<class MixtureType>
00139 void Foam::hPsiMixtureThermo<MixtureType>::correct()
00140 {
00141 if (debug)
00142 {
00143 Info<< "entering hPsiMixtureThermo<MixtureType>::correct()" << endl;
00144 }
00145
00146
00147 psi_.oldTime();
00148
00149 calculate();
00150
00151 if (debug)
00152 {
00153 Info<< "exiting hPsiMixtureThermo<MixtureType>::correct()" << endl;
00154 }
00155 }
00156
00157
00158 template<class MixtureType>
00159 Foam::tmp<Foam::volScalarField>
00160 Foam::hPsiMixtureThermo<MixtureType>::hs() const
00161 {
00162 const fvMesh& mesh = T_.mesh();
00163
00164 tmp<volScalarField> ths
00165 (
00166 new volScalarField
00167 (
00168 IOobject
00169 (
00170 "hs",
00171 mesh.time().timeName(),
00172 mesh,
00173 IOobject::NO_READ,
00174 IOobject::NO_WRITE
00175 ),
00176 mesh,
00177 h_.dimensions()
00178 )
00179 );
00180
00181 volScalarField& hsf = ths();
00182 scalarField& hsCells = hsf.internalField();
00183 const scalarField& TCells = T_.internalField();
00184
00185 forAll(TCells, celli)
00186 {
00187 hsCells[celli] = this->cellMixture(celli).Hs(TCells[celli]);
00188 }
00189
00190 forAll(T_.boundaryField(), patchi)
00191 {
00192 scalarField& hsp = hsf.boundaryField()[patchi];
00193 const scalarField& Tp = T_.boundaryField()[patchi];
00194
00195 forAll(Tp, facei)
00196 {
00197 hsp[facei] = this->patchFaceMixture(patchi, facei).Hs(Tp[facei]);
00198 }
00199 }
00200
00201 return ths;
00202 }
00203
00204
00205 template<class MixtureType>
00206 Foam::tmp<Foam::volScalarField>
00207 Foam::hPsiMixtureThermo<MixtureType>::hc() const
00208 {
00209 const fvMesh& mesh = T_.mesh();
00210
00211 tmp<volScalarField> thc
00212 (
00213 new volScalarField
00214 (
00215 IOobject
00216 (
00217 "hc",
00218 mesh.time().timeName(),
00219 mesh,
00220 IOobject::NO_READ,
00221 IOobject::NO_WRITE
00222 ),
00223 mesh,
00224 h_.dimensions()
00225 )
00226 );
00227
00228 volScalarField& hcf = thc();
00229 scalarField& hcCells = hcf.internalField();
00230
00231 forAll(hcCells, celli)
00232 {
00233 hcCells[celli] = this->cellMixture(celli).Hc();
00234 }
00235
00236 forAll(hcf.boundaryField(), patchi)
00237 {
00238 scalarField& hcp = hcf.boundaryField()[patchi];
00239
00240 forAll(hcp, facei)
00241 {
00242 hcp[facei] = this->patchFaceMixture(patchi, facei).Hc();
00243 }
00244 }
00245
00246 return thc;
00247 }
00248
00249
00250 template<class MixtureType>
00251 Foam::tmp<Foam::scalarField>
00252 Foam::hPsiMixtureThermo<MixtureType>::h
00253 (
00254 const scalarField& T,
00255 const labelList& cells
00256 ) const
00257 {
00258 tmp<scalarField> th(new scalarField(T.size()));
00259 scalarField& h = th();
00260
00261 forAll(T, celli)
00262 {
00263 h[celli] = this->cellMixture(cells[celli]).H(T[celli]);
00264 }
00265
00266 return th;
00267 }
00268
00269
00270 template<class MixtureType>
00271 Foam::tmp<Foam::scalarField>
00272 Foam::hPsiMixtureThermo<MixtureType>::h
00273 (
00274 const scalarField& T,
00275 const label patchi
00276 ) const
00277 {
00278 tmp<scalarField> th(new scalarField(T.size()));
00279 scalarField& h = th();
00280
00281 forAll(T, facei)
00282 {
00283 h[facei] = this->patchFaceMixture(patchi, facei).H(T[facei]);
00284 }
00285
00286 return th;
00287 }
00288
00289
00290 template<class MixtureType>
00291 Foam::tmp<Foam::scalarField>
00292 Foam::hPsiMixtureThermo<MixtureType>::Cp
00293 (
00294 const scalarField& T,
00295 const label patchi
00296 ) const
00297 {
00298 tmp<scalarField> tCp(new scalarField(T.size()));
00299
00300 scalarField& cp = tCp();
00301
00302 forAll(T, facei)
00303 {
00304 cp[facei] = this->patchFaceMixture(patchi, facei).Cp(T[facei]);
00305 }
00306
00307 return tCp;
00308 }
00309
00310
00311 template<class MixtureType>
00312 Foam::tmp<Foam::volScalarField>
00313 Foam::hPsiMixtureThermo<MixtureType>::Cp() const
00314 {
00315 const fvMesh& mesh = T_.mesh();
00316
00317 tmp<volScalarField> tCp
00318 (
00319 new volScalarField
00320 (
00321 IOobject
00322 (
00323 "Cp",
00324 mesh.time().timeName(),
00325 mesh,
00326 IOobject::NO_READ,
00327 IOobject::NO_WRITE
00328 ),
00329 mesh,
00330 dimensionSet(0, 2, -2, -1, 0)
00331 )
00332 );
00333
00334 volScalarField& cp = tCp();
00335
00336 scalarField& cpCells = cp.internalField();
00337 const scalarField& TCells = T_.internalField();
00338
00339 forAll(TCells, celli)
00340 {
00341 cpCells[celli] = this->cellMixture(celli).Cp(TCells[celli]);
00342 }
00343
00344 forAll(T_.boundaryField(), patchi)
00345 {
00346 cp.boundaryField()[patchi] = Cp(T_.boundaryField()[patchi], patchi);
00347 }
00348
00349 return tCp;
00350 }
00351
00352
00353 template<class MixtureType>
00354 bool Foam::hPsiMixtureThermo<MixtureType>::read()
00355 {
00356 if (hCombustionThermo::read())
00357 {
00358 MixtureType::read(*this);
00359 return true;
00360 }
00361 else
00362 {
00363 return false;
00364 }
00365 }
00366
00367
00368