1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2010 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
13 the Free Software Foundation, either version 3 of the License, or
14 (at your 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, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "hhuMixtureThermo.H"
28 #include "fixedValueFvPatchFields.H"
30 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
32 template<class MixtureType>
33 Foam::hhuMixtureThermo<MixtureType>::hhuMixtureThermo(const fvMesh& mesh)
35 hhuCombustionThermo(mesh),
36 MixtureType(*this, mesh)
38 scalarField& hCells = h_.internalField();
39 scalarField& huCells = hu_.internalField();
40 const scalarField& TCells = T_.internalField();
41 const scalarField& TuCells = Tu_.internalField();
45 hCells[celli] = this->cellMixture(celli).H(TCells[celli]);
46 huCells[celli] = this->cellReactants(celli).H(TuCells[celli]);
49 forAll(h_.boundaryField(), patchi)
51 h_.boundaryField()[patchi] == h(T_.boundaryField()[patchi], patchi);
53 fvPatchScalarField& phu = hu_.boundaryField()[patchi];
54 const fvPatchScalarField& pTu = Tu_.boundaryField()[patchi];
58 phu[facei] = this->patchFaceReactants(patchi, facei).H(pTu[facei]);
62 hBoundaryCorrection(h_);
63 huBoundaryCorrection(hu_);
66 psi_.oldTime(); // Switch on saving old time
70 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
72 template<class MixtureType>
73 Foam::hhuMixtureThermo<MixtureType>::~hhuMixtureThermo()
77 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
79 template<class MixtureType>
80 void Foam::hhuMixtureThermo<MixtureType>::calculate()
82 const scalarField& hCells = h_.internalField();
83 const scalarField& huCells = hu_.internalField();
84 const scalarField& pCells = p_.internalField();
86 scalarField& TCells = T_.internalField();
87 scalarField& TuCells = Tu_.internalField();
88 scalarField& psiCells = psi_.internalField();
89 scalarField& muCells = mu_.internalField();
90 scalarField& alphaCells = alpha_.internalField();
94 const typename MixtureType::thermoType& mixture_ =
95 this->cellMixture(celli);
97 TCells[celli] = mixture_.TH(hCells[celli], TCells[celli]);
98 psiCells[celli] = mixture_.psi(pCells[celli], TCells[celli]);
100 muCells[celli] = mixture_.mu(TCells[celli]);
101 alphaCells[celli] = mixture_.alpha(TCells[celli]);
104 this->cellReactants(celli).TH(huCells[celli], TuCells[celli]);
107 forAll(T_.boundaryField(), patchi)
109 fvPatchScalarField& pp = p_.boundaryField()[patchi];
110 fvPatchScalarField& pT = T_.boundaryField()[patchi];
111 fvPatchScalarField& pTu = Tu_.boundaryField()[patchi];
112 fvPatchScalarField& ppsi = psi_.boundaryField()[patchi];
114 fvPatchScalarField& ph = h_.boundaryField()[patchi];
115 fvPatchScalarField& phu = hu_.boundaryField()[patchi];
117 fvPatchScalarField& pmu_ = mu_.boundaryField()[patchi];
118 fvPatchScalarField& palpha_ = alpha_.boundaryField()[patchi];
124 const typename MixtureType::thermoType& mixture_ =
125 this->patchFaceMixture(patchi, facei);
127 ph[facei] = mixture_.H(pT[facei]);
129 ppsi[facei] = mixture_.psi(pp[facei], pT[facei]);
130 pmu_[facei] = mixture_.mu(pT[facei]);
131 palpha_[facei] = mixture_.alpha(pT[facei]);
138 const typename MixtureType::thermoType& mixture_ =
139 this->patchFaceMixture(patchi, facei);
141 pT[facei] = mixture_.TH(ph[facei], pT[facei]);
143 ppsi[facei] = mixture_.psi(pp[facei], pT[facei]);
144 pmu_[facei] = mixture_.mu(pT[facei]);
145 palpha_[facei] = mixture_.alpha(pT[facei]);
148 this->patchFaceReactants(patchi, facei)
149 .TH(phu[facei], pTu[facei]);
156 template<class MixtureType>
157 void Foam::hhuMixtureThermo<MixtureType>::correct()
161 Info<< "entering hhuMixtureThermo<MixtureType>::correct()" << endl;
164 // force the saving of the old-time values
171 Info<< "exiting hhuMixtureThermo<MixtureType>::correct()" << endl;
176 template<class MixtureType>
177 Foam::tmp<Foam::volScalarField>
178 Foam::hhuMixtureThermo<MixtureType>::hc() const
180 const fvMesh& mesh = T_.mesh();
182 tmp<volScalarField> thc
189 mesh.time().timeName(),
199 volScalarField& hcf = thc();
200 scalarField& hcCells = hcf.internalField();
202 forAll(hcCells, celli)
204 hcCells[celli] = this->cellMixture(celli).Hc();
207 forAll(hcf.boundaryField(), patchi)
209 scalarField& hcp = hcf.boundaryField()[patchi];
213 hcp[facei] = this->patchFaceMixture(patchi, facei).Hc();
221 template<class MixtureType>
222 Foam::tmp<Foam::scalarField> Foam::hhuMixtureThermo<MixtureType>::h
224 const scalarField& T,
225 const labelList& cells
228 tmp<scalarField> th(new scalarField(T.size()));
229 scalarField& h = th();
233 h[celli] = this->cellMixture(cells[celli]).H(T[celli]);
240 template<class MixtureType>
241 Foam::tmp<Foam::scalarField> Foam::hhuMixtureThermo<MixtureType>::h
243 const scalarField& T,
247 tmp<scalarField> th(new scalarField(T.size()));
248 scalarField& h = th();
252 h[facei] = this->patchFaceMixture(patchi, facei).H(T[facei]);
259 template<class MixtureType>
260 Foam::tmp<Foam::scalarField> Foam::hhuMixtureThermo<MixtureType>::Cp
262 const scalarField& T,
266 tmp<scalarField> tCp(new scalarField(T.size()));
268 scalarField& cp = tCp();
272 cp[facei] = this->patchFaceMixture(patchi, facei).Cp(T[facei]);
279 template<class MixtureType>
280 Foam::tmp<Foam::volScalarField>
281 Foam::hhuMixtureThermo<MixtureType>::Cp() const
283 const fvMesh& mesh = T_.mesh();
285 tmp<volScalarField> tCp
292 mesh.time().timeName(),
298 dimensionSet(0, 2, -2, -1, 0)
302 volScalarField& cp = tCp();
303 scalarField& cpCells = cp.internalField();
304 const scalarField& TCells = T_.internalField();
306 forAll(TCells, celli)
308 cpCells[celli] = this->cellMixture(celli).Cp(TCells[celli]);
311 forAll(T_.boundaryField(), patchi)
313 cp.boundaryField()[patchi] = Cp(T_.boundaryField()[patchi], patchi);
320 template<class MixtureType>
321 Foam::tmp<Foam::scalarField>
322 Foam::hhuMixtureThermo<MixtureType>::hu
324 const scalarField& Tu,
325 const labelList& cells
328 tmp<scalarField> thu(new scalarField(Tu.size()));
329 scalarField& hu = thu();
333 hu[celli] = this->cellReactants(cells[celli]).H(Tu[celli]);
340 template<class MixtureType>
341 Foam::tmp<Foam::scalarField>
342 Foam::hhuMixtureThermo<MixtureType>::hu
344 const scalarField& Tu,
348 tmp<scalarField> thu(new scalarField(Tu.size()));
349 scalarField& hu = thu();
353 hu[facei] = this->patchFaceReactants(patchi, facei).H(Tu[facei]);
360 template<class MixtureType>
361 Foam::tmp<Foam::volScalarField>
362 Foam::hhuMixtureThermo<MixtureType>::Tb() const
364 tmp<volScalarField> tTb
371 T_.time().timeName(),
380 volScalarField& Tb_ = tTb();
381 scalarField& TbCells = Tb_.internalField();
382 const scalarField& TCells = T_.internalField();
383 const scalarField& hCells = h_.internalField();
385 forAll(TbCells, celli)
388 this->cellProducts(celli).TH(hCells[celli], TCells[celli]);
391 forAll(Tb_.boundaryField(), patchi)
393 fvPatchScalarField& pTb = Tb_.boundaryField()[patchi];
395 const fvPatchScalarField& ph = h_.boundaryField()[patchi];
396 const fvPatchScalarField& pT = T_.boundaryField()[patchi];
401 this->patchFaceProducts(patchi, facei)
402 .TH(ph[facei], pT[facei]);
410 template<class MixtureType>
411 Foam::tmp<Foam::volScalarField>
412 Foam::hhuMixtureThermo<MixtureType>::psiu() const
414 tmp<volScalarField> tpsiu
421 psi_.time().timeName(),
431 volScalarField& psiu = tpsiu();
432 scalarField& psiuCells = psiu.internalField();
433 const scalarField& TuCells = Tu_.internalField();
434 const scalarField& pCells = p_.internalField();
436 forAll(psiuCells, celli)
439 this->cellReactants(celli).psi(pCells[celli], TuCells[celli]);
442 forAll(psiu.boundaryField(), patchi)
444 fvPatchScalarField& ppsiu = psiu.boundaryField()[patchi];
446 const fvPatchScalarField& pp = p_.boundaryField()[patchi];
447 const fvPatchScalarField& pTu = Tu_.boundaryField()[patchi];
453 patchFaceReactants(patchi, facei).psi(pp[facei], pTu[facei]);
461 template<class MixtureType>
462 Foam::tmp<Foam::volScalarField>
463 Foam::hhuMixtureThermo<MixtureType>::psib() const
465 tmp<volScalarField> tpsib
472 psi_.time().timeName(),
482 volScalarField& psib = tpsib();
483 scalarField& psibCells = psib.internalField();
484 volScalarField Tb_ = Tb();
485 const scalarField& TbCells = Tb_.internalField();
486 const scalarField& pCells = p_.internalField();
488 forAll(psibCells, celli)
491 this->cellReactants(celli).psi(pCells[celli], TbCells[celli]);
494 forAll(psib.boundaryField(), patchi)
496 fvPatchScalarField& ppsib = psib.boundaryField()[patchi];
498 const fvPatchScalarField& pp = p_.boundaryField()[patchi];
499 const fvPatchScalarField& pTb = Tb_.boundaryField()[patchi];
504 this->patchFaceReactants
505 (patchi, facei).psi(pp[facei], pTb[facei]);
513 template<class MixtureType>
514 Foam::tmp<Foam::volScalarField>
515 Foam::hhuMixtureThermo<MixtureType>::muu() const
517 tmp<volScalarField> tmuu
524 T_.time().timeName(),
530 dimensionSet(1, -1, -1, 0, 0)
534 volScalarField& muu_ = tmuu();
535 scalarField& muuCells = muu_.internalField();
536 const scalarField& TuCells = Tu_.internalField();
538 forAll(muuCells, celli)
540 muuCells[celli] = this->cellReactants(celli).mu(TuCells[celli]);
543 forAll(muu_.boundaryField(), patchi)
545 fvPatchScalarField& pMuu = muu_.boundaryField()[patchi];
546 const fvPatchScalarField& pTu = Tu_.boundaryField()[patchi];
551 this->patchFaceReactants(patchi, facei).mu(pTu[facei]);
559 template<class MixtureType>
560 Foam::tmp<Foam::volScalarField>
561 Foam::hhuMixtureThermo<MixtureType>::mub() const
563 tmp<volScalarField> tmub
570 T_.time().timeName(),
576 dimensionSet(1, -1, -1, 0, 0)
580 volScalarField& mub_ = tmub();
581 scalarField& mubCells = mub_.internalField();
582 volScalarField Tb_ = Tb();
583 const scalarField& TbCells = Tb_.internalField();
585 forAll(mubCells, celli)
587 mubCells[celli] = this->cellProducts(celli).mu(TbCells[celli]);
590 forAll(mub_.boundaryField(), patchi)
592 fvPatchScalarField& pMub = mub_.boundaryField()[patchi];
593 const fvPatchScalarField& pTb = Tb_.boundaryField()[patchi];
598 this->patchFaceProducts(patchi, facei).mu(pTb[facei]);
606 template<class MixtureType>
607 bool Foam::hhuMixtureThermo<MixtureType>::read()
609 if (hhuCombustionThermo::read())
611 MixtureType::read(*this);
621 // ************************************************************************* //