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 "hhuMixtureThermo.H"
00028 #include "fvMesh.H"
00029 #include "fixedValueFvPatchFields.H"
00030
00031
00032
00033 template<class MixtureType>
00034 Foam::hhuMixtureThermo<MixtureType>::hhuMixtureThermo(const fvMesh& mesh)
00035 :
00036 hhuCombustionThermo(mesh),
00037 MixtureType(*this, mesh)
00038 {
00039 scalarField& hCells = h_.internalField();
00040 scalarField& huCells = hu_.internalField();
00041 const scalarField& TCells = T_.internalField();
00042 const scalarField& TuCells = Tu_.internalField();
00043
00044 forAll(hCells, celli)
00045 {
00046 hCells[celli] = this->cellMixture(celli).H(TCells[celli]);
00047 huCells[celli] = this->cellReactants(celli).H(TuCells[celli]);
00048 }
00049
00050 forAll(h_.boundaryField(), patchi)
00051 {
00052 h_.boundaryField()[patchi] == h(T_.boundaryField()[patchi], patchi);
00053
00054 fvPatchScalarField& phu = hu_.boundaryField()[patchi];
00055 const fvPatchScalarField& pTu = Tu_.boundaryField()[patchi];
00056
00057 forAll(phu, facei)
00058 {
00059 phu[facei] = this->patchFaceReactants(patchi, facei).H(pTu[facei]);
00060 }
00061 }
00062
00063 hBoundaryCorrection(h_);
00064 huBoundaryCorrection(hu_);
00065
00066 calculate();
00067 psi_.oldTime();
00068 }
00069
00070
00071
00072
00073 template<class MixtureType>
00074 Foam::hhuMixtureThermo<MixtureType>::~hhuMixtureThermo()
00075 {}
00076
00077
00078
00079
00080 template<class MixtureType>
00081 void Foam::hhuMixtureThermo<MixtureType>::calculate()
00082 {
00083 const scalarField& hCells = h_.internalField();
00084 const scalarField& huCells = hu_.internalField();
00085 const scalarField& pCells = p_.internalField();
00086
00087 scalarField& TCells = T_.internalField();
00088 scalarField& TuCells = Tu_.internalField();
00089 scalarField& psiCells = psi_.internalField();
00090 scalarField& muCells = mu_.internalField();
00091 scalarField& alphaCells = alpha_.internalField();
00092
00093 forAll(TCells, celli)
00094 {
00095 const typename MixtureType::thermoType& mixture_ =
00096 this->cellMixture(celli);
00097
00098 TCells[celli] = mixture_.TH(hCells[celli], TCells[celli]);
00099 psiCells[celli] = mixture_.psi(pCells[celli], TCells[celli]);
00100
00101 muCells[celli] = mixture_.mu(TCells[celli]);
00102 alphaCells[celli] = mixture_.alpha(TCells[celli]);
00103
00104 TuCells[celli] =
00105 this->cellReactants(celli).TH(huCells[celli], TuCells[celli]);
00106 }
00107
00108 forAll(T_.boundaryField(), patchi)
00109 {
00110 fvPatchScalarField& pp = p_.boundaryField()[patchi];
00111 fvPatchScalarField& pT = T_.boundaryField()[patchi];
00112 fvPatchScalarField& pTu = Tu_.boundaryField()[patchi];
00113 fvPatchScalarField& ppsi = psi_.boundaryField()[patchi];
00114
00115 fvPatchScalarField& ph = h_.boundaryField()[patchi];
00116 fvPatchScalarField& phu = hu_.boundaryField()[patchi];
00117
00118 fvPatchScalarField& pmu_ = mu_.boundaryField()[patchi];
00119 fvPatchScalarField& palpha_ = alpha_.boundaryField()[patchi];
00120
00121 if (pT.fixesValue())
00122 {
00123 forAll(pT, facei)
00124 {
00125 const typename MixtureType::thermoType& mixture_ =
00126 this->patchFaceMixture(patchi, facei);
00127
00128 ph[facei] = mixture_.H(pT[facei]);
00129
00130 ppsi[facei] = mixture_.psi(pp[facei], pT[facei]);
00131 pmu_[facei] = mixture_.mu(pT[facei]);
00132 palpha_[facei] = mixture_.alpha(pT[facei]);
00133 }
00134 }
00135 else
00136 {
00137 forAll(pT, facei)
00138 {
00139 const typename MixtureType::thermoType& mixture_ =
00140 this->patchFaceMixture(patchi, facei);
00141
00142 pT[facei] = mixture_.TH(ph[facei], pT[facei]);
00143
00144 ppsi[facei] = mixture_.psi(pp[facei], pT[facei]);
00145 pmu_[facei] = mixture_.mu(pT[facei]);
00146 palpha_[facei] = mixture_.alpha(pT[facei]);
00147
00148 pTu[facei] =
00149 this->patchFaceReactants(patchi, facei)
00150 .TH(phu[facei], pTu[facei]);
00151 }
00152 }
00153 }
00154 }
00155
00156
00157 template<class MixtureType>
00158 void Foam::hhuMixtureThermo<MixtureType>::correct()
00159 {
00160 if (debug)
00161 {
00162 Info<< "entering hhuMixtureThermo<MixtureType>::correct()" << endl;
00163 }
00164
00165
00166 psi_.oldTime();
00167
00168 calculate();
00169
00170 if (debug)
00171 {
00172 Info<< "exiting hhuMixtureThermo<MixtureType>::correct()" << endl;
00173 }
00174 }
00175
00176
00177 template<class MixtureType>
00178 Foam::tmp<Foam::volScalarField>
00179 Foam::hhuMixtureThermo<MixtureType>::hs() const
00180 {
00181 const fvMesh& mesh = T_.mesh();
00182
00183 tmp<volScalarField> ths
00184 (
00185 new volScalarField
00186 (
00187 IOobject
00188 (
00189 "hs",
00190 mesh.time().timeName(),
00191 mesh,
00192 IOobject::NO_READ,
00193 IOobject::NO_WRITE
00194 ),
00195 mesh,
00196 h_.dimensions()
00197 )
00198 );
00199
00200 volScalarField& hsf = ths();
00201
00202 scalarField& hsCells = hsf.internalField();
00203 const scalarField& TCells = T_.internalField();
00204
00205 forAll(TCells, celli)
00206 {
00207 hsCells[celli] = this->cellMixture(celli).Hs(TCells[celli]);
00208 }
00209
00210 forAll(T_.boundaryField(), patchi)
00211 {
00212 scalarField& hsp = hsf.boundaryField()[patchi];
00213 const scalarField& Tp = T_.boundaryField()[patchi];
00214
00215 forAll(Tp, facei)
00216 {
00217 hsp[facei] = this->patchFaceMixture(patchi, facei).Hs(Tp[facei]);
00218 }
00219 }
00220
00221 return ths;
00222 }
00223
00224
00225 template<class MixtureType>
00226 Foam::tmp<Foam::volScalarField>
00227 Foam::hhuMixtureThermo<MixtureType>::hc() const
00228 {
00229 const fvMesh& mesh = T_.mesh();
00230
00231 tmp<volScalarField> thc
00232 (
00233 new volScalarField
00234 (
00235 IOobject
00236 (
00237 "hc",
00238 mesh.time().timeName(),
00239 mesh,
00240 IOobject::NO_READ,
00241 IOobject::NO_WRITE
00242 ),
00243 mesh,
00244 h_.dimensions()
00245 )
00246 );
00247
00248 volScalarField& hcf = thc();
00249 scalarField& hcCells = hcf.internalField();
00250
00251 forAll(hcCells, celli)
00252 {
00253 hcCells[celli] = this->cellMixture(celli).Hc();
00254 }
00255
00256 forAll(hcf.boundaryField(), patchi)
00257 {
00258 scalarField& hcp = hcf.boundaryField()[patchi];
00259
00260 forAll(hcp, facei)
00261 {
00262 hcp[facei] = this->patchFaceMixture(patchi, facei).Hc();
00263 }
00264 }
00265
00266 return thc;
00267 }
00268
00269
00270 template<class MixtureType>
00271 Foam::tmp<Foam::scalarField> Foam::hhuMixtureThermo<MixtureType>::h
00272 (
00273 const scalarField& T,
00274 const labelList& cells
00275 ) const
00276 {
00277 tmp<scalarField> th(new scalarField(T.size()));
00278 scalarField& h = th();
00279
00280 forAll(T, celli)
00281 {
00282 h[celli] = this->cellMixture(cells[celli]).H(T[celli]);
00283 }
00284
00285 return th;
00286 }
00287
00288
00289 template<class MixtureType>
00290 Foam::tmp<Foam::scalarField> Foam::hhuMixtureThermo<MixtureType>::h
00291 (
00292 const scalarField& T,
00293 const label patchi
00294 ) const
00295 {
00296 tmp<scalarField> th(new scalarField(T.size()));
00297 scalarField& h = th();
00298
00299 forAll(T, facei)
00300 {
00301 h[facei] = this->patchFaceMixture(patchi, facei).H(T[facei]);
00302 }
00303
00304 return th;
00305 }
00306
00307
00308 template<class MixtureType>
00309 Foam::tmp<Foam::scalarField> Foam::hhuMixtureThermo<MixtureType>::Cp
00310 (
00311 const scalarField& T,
00312 const label patchi
00313 ) const
00314 {
00315 tmp<scalarField> tCp(new scalarField(T.size()));
00316
00317 scalarField& cp = tCp();
00318
00319 forAll(T, facei)
00320 {
00321 cp[facei] = this->patchFaceMixture(patchi, facei).Cp(T[facei]);
00322 }
00323
00324 return tCp;
00325 }
00326
00327
00328 template<class MixtureType>
00329 Foam::tmp<Foam::volScalarField>
00330 Foam::hhuMixtureThermo<MixtureType>::Cp() const
00331 {
00332 const fvMesh& mesh = T_.mesh();
00333
00334 tmp<volScalarField> tCp
00335 (
00336 new volScalarField
00337 (
00338 IOobject
00339 (
00340 "Cp",
00341 mesh.time().timeName(),
00342 mesh,
00343 IOobject::NO_READ,
00344 IOobject::NO_WRITE
00345 ),
00346 mesh,
00347 dimensionSet(0, 2, -2, -1, 0)
00348 )
00349 );
00350
00351 volScalarField& cp = tCp();
00352 scalarField& cpCells = cp.internalField();
00353 const scalarField& TCells = T_.internalField();
00354
00355 forAll(TCells, celli)
00356 {
00357 cpCells[celli] = this->cellMixture(celli).Cp(TCells[celli]);
00358 }
00359
00360 forAll(T_.boundaryField(), patchi)
00361 {
00362 cp.boundaryField()[patchi] = Cp(T_.boundaryField()[patchi], patchi);
00363 }
00364
00365 return tCp;
00366 }
00367
00368
00369 template<class MixtureType>
00370 Foam::tmp<Foam::scalarField>
00371 Foam::hhuMixtureThermo<MixtureType>::hu
00372 (
00373 const scalarField& Tu,
00374 const labelList& cells
00375 ) const
00376 {
00377 tmp<scalarField> thu(new scalarField(Tu.size()));
00378 scalarField& hu = thu();
00379
00380 forAll(Tu, celli)
00381 {
00382 hu[celli] = this->cellReactants(cells[celli]).H(Tu[celli]);
00383 }
00384
00385 return thu;
00386 }
00387
00388
00389 template<class MixtureType>
00390 Foam::tmp<Foam::scalarField>
00391 Foam::hhuMixtureThermo<MixtureType>::hu
00392 (
00393 const scalarField& Tu,
00394 const label patchi
00395 ) const
00396 {
00397 tmp<scalarField> thu(new scalarField(Tu.size()));
00398 scalarField& hu = thu();
00399
00400 forAll(Tu, facei)
00401 {
00402 hu[facei] = this->patchFaceReactants(patchi, facei).H(Tu[facei]);
00403 }
00404
00405 return thu;
00406 }
00407
00408
00409 template<class MixtureType>
00410 Foam::tmp<Foam::volScalarField>
00411 Foam::hhuMixtureThermo<MixtureType>::Tb() const
00412 {
00413 tmp<volScalarField> tTb
00414 (
00415 new volScalarField
00416 (
00417 IOobject
00418 (
00419 "Tb",
00420 T_.time().timeName(),
00421 T_.db(),
00422 IOobject::NO_READ,
00423 IOobject::NO_WRITE
00424 ),
00425 T_
00426 )
00427 );
00428
00429 volScalarField& Tb_ = tTb();
00430 scalarField& TbCells = Tb_.internalField();
00431 const scalarField& TCells = T_.internalField();
00432 const scalarField& hCells = h_.internalField();
00433
00434 forAll(TbCells, celli)
00435 {
00436 TbCells[celli] =
00437 this->cellProducts(celli).TH(hCells[celli], TCells[celli]);
00438 }
00439
00440 forAll(Tb_.boundaryField(), patchi)
00441 {
00442 fvPatchScalarField& pTb = Tb_.boundaryField()[patchi];
00443
00444 const fvPatchScalarField& ph = h_.boundaryField()[patchi];
00445 const fvPatchScalarField& pT = T_.boundaryField()[patchi];
00446
00447 forAll(pTb, facei)
00448 {
00449 pTb[facei] =
00450 this->patchFaceProducts(patchi, facei)
00451 .TH(ph[facei], pT[facei]);
00452 }
00453 }
00454
00455 return tTb;
00456 }
00457
00458
00459 template<class MixtureType>
00460 Foam::tmp<Foam::volScalarField>
00461 Foam::hhuMixtureThermo<MixtureType>::psiu() const
00462 {
00463 tmp<volScalarField> tpsiu
00464 (
00465 new volScalarField
00466 (
00467 IOobject
00468 (
00469 "psiu",
00470 psi_.time().timeName(),
00471 psi_.db(),
00472 IOobject::NO_READ,
00473 IOobject::NO_WRITE
00474 ),
00475 psi_.mesh(),
00476 psi_.dimensions()
00477 )
00478 );
00479
00480 volScalarField& psiu = tpsiu();
00481 scalarField& psiuCells = psiu.internalField();
00482 const scalarField& TuCells = Tu_.internalField();
00483 const scalarField& pCells = p_.internalField();
00484
00485 forAll(psiuCells, celli)
00486 {
00487 psiuCells[celli] =
00488 this->cellReactants(celli).psi(pCells[celli], TuCells[celli]);
00489 }
00490
00491 forAll(psiu.boundaryField(), patchi)
00492 {
00493 fvPatchScalarField& ppsiu = psiu.boundaryField()[patchi];
00494
00495 const fvPatchScalarField& pp = p_.boundaryField()[patchi];
00496 const fvPatchScalarField& pTu = Tu_.boundaryField()[patchi];
00497
00498 forAll(ppsiu, facei)
00499 {
00500 ppsiu[facei] =
00501 this->
00502 patchFaceReactants(patchi, facei).psi(pp[facei], pTu[facei]);
00503 }
00504 }
00505
00506 return tpsiu;
00507 }
00508
00509
00510 template<class MixtureType>
00511 Foam::tmp<Foam::volScalarField>
00512 Foam::hhuMixtureThermo<MixtureType>::psib() const
00513 {
00514 tmp<volScalarField> tpsib
00515 (
00516 new volScalarField
00517 (
00518 IOobject
00519 (
00520 "psib",
00521 psi_.time().timeName(),
00522 psi_.db(),
00523 IOobject::NO_READ,
00524 IOobject::NO_WRITE
00525 ),
00526 psi_.mesh(),
00527 psi_.dimensions()
00528 )
00529 );
00530
00531 volScalarField& psib = tpsib();
00532 scalarField& psibCells = psib.internalField();
00533 volScalarField Tb_ = Tb();
00534 const scalarField& TbCells = Tb_.internalField();
00535 const scalarField& pCells = p_.internalField();
00536
00537 forAll(psibCells, celli)
00538 {
00539 psibCells[celli] =
00540 this->cellReactants(celli).psi(pCells[celli], TbCells[celli]);
00541 }
00542
00543 forAll(psib.boundaryField(), patchi)
00544 {
00545 fvPatchScalarField& ppsib = psib.boundaryField()[patchi];
00546
00547 const fvPatchScalarField& pp = p_.boundaryField()[patchi];
00548 const fvPatchScalarField& pTb = Tb_.boundaryField()[patchi];
00549
00550 forAll(ppsib, facei)
00551 {
00552 ppsib[facei] =
00553 this->patchFaceReactants
00554 (patchi, facei).psi(pp[facei], pTb[facei]);
00555 }
00556 }
00557
00558 return tpsib;
00559 }
00560
00561
00562 template<class MixtureType>
00563 Foam::tmp<Foam::volScalarField>
00564 Foam::hhuMixtureThermo<MixtureType>::muu() const
00565 {
00566 tmp<volScalarField> tmuu
00567 (
00568 new volScalarField
00569 (
00570 IOobject
00571 (
00572 "muu",
00573 T_.time().timeName(),
00574 T_.db(),
00575 IOobject::NO_READ,
00576 IOobject::NO_WRITE
00577 ),
00578 T_.mesh(),
00579 dimensionSet(1, -1, -1, 0, 0)
00580 )
00581 );
00582
00583 volScalarField& muu_ = tmuu();
00584 scalarField& muuCells = muu_.internalField();
00585 const scalarField& TuCells = Tu_.internalField();
00586
00587 forAll(muuCells, celli)
00588 {
00589 muuCells[celli] = this->cellReactants(celli).mu(TuCells[celli]);
00590 }
00591
00592 forAll(muu_.boundaryField(), patchi)
00593 {
00594 fvPatchScalarField& pMuu = muu_.boundaryField()[patchi];
00595 const fvPatchScalarField& pTu = Tu_.boundaryField()[patchi];
00596
00597 forAll(pMuu, facei)
00598 {
00599 pMuu[facei] =
00600 this->patchFaceReactants(patchi, facei).mu(pTu[facei]);
00601 }
00602 }
00603
00604 return tmuu;
00605 }
00606
00607
00608 template<class MixtureType>
00609 Foam::tmp<Foam::volScalarField>
00610 Foam::hhuMixtureThermo<MixtureType>::mub() const
00611 {
00612 tmp<volScalarField> tmub
00613 (
00614 new volScalarField
00615 (
00616 IOobject
00617 (
00618 "mub",
00619 T_.time().timeName(),
00620 T_.db(),
00621 IOobject::NO_READ,
00622 IOobject::NO_WRITE
00623 ),
00624 T_.mesh(),
00625 dimensionSet(1, -1, -1, 0, 0)
00626 )
00627 );
00628
00629 volScalarField& mub_ = tmub();
00630 scalarField& mubCells = mub_.internalField();
00631 volScalarField Tb_ = Tb();
00632 const scalarField& TbCells = Tb_.internalField();
00633
00634 forAll(mubCells, celli)
00635 {
00636 mubCells[celli] = this->cellProducts(celli).mu(TbCells[celli]);
00637 }
00638
00639 forAll(mub_.boundaryField(), patchi)
00640 {
00641 fvPatchScalarField& pMub = mub_.boundaryField()[patchi];
00642 const fvPatchScalarField& pTb = Tb_.boundaryField()[patchi];
00643
00644 forAll(pMub, facei)
00645 {
00646 pMub[facei] =
00647 this->patchFaceProducts(patchi, facei).mu(pTb[facei]);
00648 }
00649 }
00650
00651 return tmub;
00652 }
00653
00654
00655 template<class MixtureType>
00656 bool Foam::hhuMixtureThermo<MixtureType>::read()
00657 {
00658 if (hhuCombustionThermo::read())
00659 {
00660 MixtureType::read(*this);
00661 return true;
00662 }
00663 else
00664 {
00665 return false;
00666 }
00667 }
00668
00669
00670