1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend is free software: you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation, either version 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. 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
36 const objectRegistry& obj
39 hhuCombustionThermo(mesh, obj),
40 MixtureType(*this, mesh, obj)
42 scalarField& hCells = h_.internalField();
43 scalarField& huCells = hu_.internalField();
44 const scalarField& TCells = T_.internalField();
45 const scalarField& TuCells = Tu_.internalField();
49 hCells[celli] = this->cellMixture(celli).H(TCells[celli]);
50 huCells[celli] = this->cellReactants(celli).H(TuCells[celli]);
53 forAll(h_.boundaryField(), patchi)
55 h_.boundaryField()[patchi] == h(T_.boundaryField()[patchi], patchi);
57 fvPatchScalarField& phu = hu_.boundaryField()[patchi];
58 const fvPatchScalarField& pTu = Tu_.boundaryField()[patchi];
62 phu[facei] = this->patchFaceReactants(patchi, facei).H(pTu[facei]);
66 hBoundaryCorrection(h_);
67 huBoundaryCorrection(hu_);
70 psi_.oldTime(); // Switch on saving old time
74 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
76 template<class MixtureType>
77 Foam::hhuMixtureThermo<MixtureType>::~hhuMixtureThermo()
81 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
83 template<class MixtureType>
84 void Foam::hhuMixtureThermo<MixtureType>::calculate()
86 const scalarField& hCells = h_.internalField();
87 const scalarField& huCells = hu_.internalField();
88 const scalarField& pCells = p_.internalField();
90 scalarField& TCells = T_.internalField();
91 scalarField& TuCells = Tu_.internalField();
92 scalarField& psiCells = psi_.internalField();
93 scalarField& muCells = mu_.internalField();
94 scalarField& alphaCells = alpha_.internalField();
98 const typename MixtureType::thermoType& mixture_ =
99 this->cellMixture(celli);
101 TCells[celli] = mixture_.TH(hCells[celli], TCells[celli]);
102 psiCells[celli] = mixture_.psi(pCells[celli], TCells[celli]);
104 muCells[celli] = mixture_.mu(TCells[celli]);
105 alphaCells[celli] = mixture_.alpha(TCells[celli]);
108 this->cellReactants(celli).TH(huCells[celli], TuCells[celli]);
111 forAll(T_.boundaryField(), patchi)
113 fvPatchScalarField& pp = p_.boundaryField()[patchi];
114 fvPatchScalarField& pT = T_.boundaryField()[patchi];
115 fvPatchScalarField& pTu = Tu_.boundaryField()[patchi];
116 fvPatchScalarField& ppsi = psi_.boundaryField()[patchi];
118 fvPatchScalarField& ph = h_.boundaryField()[patchi];
119 fvPatchScalarField& phu = hu_.boundaryField()[patchi];
121 fvPatchScalarField& pmu_ = mu_.boundaryField()[patchi];
122 fvPatchScalarField& palpha_ = alpha_.boundaryField()[patchi];
128 const typename MixtureType::thermoType& mixture_ =
129 this->patchFaceMixture(patchi, facei);
131 ph[facei] = mixture_.H(pT[facei]);
133 ppsi[facei] = mixture_.psi(pp[facei], pT[facei]);
134 pmu_[facei] = mixture_.mu(pT[facei]);
135 palpha_[facei] = mixture_.alpha(pT[facei]);
142 const typename MixtureType::thermoType& mixture_ =
143 this->patchFaceMixture(patchi, facei);
145 pT[facei] = mixture_.TH(ph[facei], pT[facei]);
147 ppsi[facei] = mixture_.psi(pp[facei], pT[facei]);
148 pmu_[facei] = mixture_.mu(pT[facei]);
149 palpha_[facei] = mixture_.alpha(pT[facei]);
152 this->patchFaceReactants(patchi, facei)
153 .TH(phu[facei], pTu[facei]);
160 template<class MixtureType>
161 void Foam::hhuMixtureThermo<MixtureType>::correct()
165 Info<< "entering hhuMixtureThermo<MixtureType>::correct()" << endl;
168 // force the saving of the old-time values
175 Info<< "exiting hhuMixtureThermo<MixtureType>::correct()" << endl;
180 template<class MixtureType>
181 Foam::tmp<Foam::volScalarField>
182 Foam::hhuMixtureThermo<MixtureType>::hc() const
184 const fvMesh& mesh = T_.mesh();
186 tmp<volScalarField> thc
193 mesh.time().timeName(),
203 volScalarField& hcf = thc();
204 scalarField& hcCells = hcf.internalField();
206 forAll(hcCells, celli)
208 hcCells[celli] = this->cellMixture(celli).Hc();
211 forAll(hcf.boundaryField(), patchi)
213 scalarField& hcp = hcf.boundaryField()[patchi];
217 hcp[facei] = this->patchFaceMixture(patchi, facei).Hc();
225 template<class MixtureType>
226 Foam::tmp<Foam::scalarField> Foam::hhuMixtureThermo<MixtureType>::h
228 const scalarField& T,
229 const labelList& cells
232 tmp<scalarField> th(new scalarField(T.size()));
233 scalarField& h = th();
237 h[celli] = this->cellMixture(cells[celli]).H(T[celli]);
244 template<class MixtureType>
245 Foam::tmp<Foam::scalarField> Foam::hhuMixtureThermo<MixtureType>::h
247 const scalarField& T,
251 tmp<scalarField> th(new scalarField(T.size()));
252 scalarField& h = th();
256 h[facei] = this->patchFaceMixture(patchi, facei).H(T[facei]);
263 template<class MixtureType>
264 Foam::tmp<Foam::scalarField> Foam::hhuMixtureThermo<MixtureType>::Cp
266 const scalarField& T,
270 tmp<scalarField> tCp(new scalarField(T.size()));
272 scalarField& cp = tCp();
276 cp[facei] = this->patchFaceMixture(patchi, facei).Cp(T[facei]);
283 template<class MixtureType>
284 Foam::tmp<Foam::scalarField>
285 Foam::hhuMixtureThermo<MixtureType>::Cp
287 const scalarField& T,
288 const labelList& cells
291 tmp<scalarField> tCp(new scalarField(T.size()));
292 scalarField& cp = tCp();
296 cp[celli] = this->cellMixture(cells[celli]).Cp(T[celli]);
303 template<class MixtureType>
304 Foam::tmp<Foam::volScalarField>
305 Foam::hhuMixtureThermo<MixtureType>::Cp() const
307 const fvMesh& mesh = T_.mesh();
309 tmp<volScalarField> tCp
316 mesh.time().timeName(),
322 dimensionSet(0, 2, -2, -1, 0)
326 volScalarField& cp = tCp();
327 scalarField& cpCells = cp.internalField();
328 const scalarField& TCells = T_.internalField();
330 forAll(TCells, celli)
332 cpCells[celli] = this->cellMixture(celli).Cp(TCells[celli]);
335 forAll(T_.boundaryField(), patchi)
337 cp.boundaryField()[patchi] = Cp(T_.boundaryField()[patchi], patchi);
344 template<class MixtureType>
345 Foam::tmp<Foam::scalarField> Foam::hhuMixtureThermo<MixtureType>::Cv
347 const scalarField& T,
351 tmp<scalarField> tCv(new scalarField(T.size()));
353 scalarField& cv = tCv();
357 cv[facei] = this->patchFaceMixture(patchi, facei).Cv(T[facei]);
364 template<class MixtureType>
365 Foam::tmp<Foam::volScalarField> Foam::hhuMixtureThermo<MixtureType>::Cv() const
367 const fvMesh& mesh = T_.mesh();
369 tmp<volScalarField> tCv
376 mesh.time().timeName(),
382 dimensionSet(0, 2, -2, -1, 0)
386 volScalarField& cv = tCv();
390 cv[celli] = this->cellMixture(celli).Cv(T_[celli]);
393 forAll(T_.boundaryField(), patchi)
395 cv.boundaryField()[patchi] = Cv(T_.boundaryField()[patchi], patchi);
402 template<class MixtureType>
403 Foam::tmp<Foam::scalarField>
404 Foam::hhuMixtureThermo<MixtureType>::hu
406 const scalarField& Tu,
407 const labelList& cells
410 tmp<scalarField> thu(new scalarField(Tu.size()));
411 scalarField& hu = thu();
415 hu[celli] = this->cellReactants(cells[celli]).H(Tu[celli]);
422 template<class MixtureType>
423 Foam::tmp<Foam::scalarField>
424 Foam::hhuMixtureThermo<MixtureType>::hu
426 const scalarField& Tu,
430 tmp<scalarField> thu(new scalarField(Tu.size()));
431 scalarField& hu = thu();
435 hu[facei] = this->patchFaceReactants(patchi, facei).H(Tu[facei]);
442 template<class MixtureType>
443 Foam::tmp<Foam::volScalarField>
444 Foam::hhuMixtureThermo<MixtureType>::Tb() const
446 tmp<volScalarField> tTb
453 T_.time().timeName(),
462 volScalarField& Tb_ = tTb();
463 scalarField& TbCells = Tb_.internalField();
464 const scalarField& TCells = T_.internalField();
465 const scalarField& hCells = h_.internalField();
467 forAll(TbCells, celli)
470 this->cellProducts(celli).TH(hCells[celli], TCells[celli]);
473 forAll(Tb_.boundaryField(), patchi)
475 fvPatchScalarField& pTb = Tb_.boundaryField()[patchi];
477 const fvPatchScalarField& ph = h_.boundaryField()[patchi];
478 const fvPatchScalarField& pT = T_.boundaryField()[patchi];
483 this->patchFaceProducts(patchi, facei)
484 .TH(ph[facei], pT[facei]);
492 template<class MixtureType>
493 Foam::tmp<Foam::volScalarField>
494 Foam::hhuMixtureThermo<MixtureType>::psiu() const
496 tmp<volScalarField> tpsiu
503 psi_.time().timeName(),
513 volScalarField& psiu = tpsiu();
514 scalarField& psiuCells = psiu.internalField();
515 const scalarField& TuCells = Tu_.internalField();
516 const scalarField& pCells = p_.internalField();
518 forAll(psiuCells, celli)
521 this->cellReactants(celli).psi(pCells[celli], TuCells[celli]);
524 forAll(psiu.boundaryField(), patchi)
526 fvPatchScalarField& ppsiu = psiu.boundaryField()[patchi];
528 const fvPatchScalarField& pp = p_.boundaryField()[patchi];
529 const fvPatchScalarField& pTu = Tu_.boundaryField()[patchi];
535 patchFaceReactants(patchi, facei).psi(pp[facei], pTu[facei]);
543 template<class MixtureType>
544 Foam::tmp<Foam::volScalarField>
545 Foam::hhuMixtureThermo<MixtureType>::psib() const
547 tmp<volScalarField> tpsib
554 psi_.time().timeName(),
564 volScalarField& psib = tpsib();
565 scalarField& psibCells = psib.internalField();
566 volScalarField Tb_ = Tb();
567 const scalarField& TbCells = Tb_.internalField();
568 const scalarField& pCells = p_.internalField();
570 forAll(psibCells, celli)
573 this->cellReactants(celli).psi(pCells[celli], TbCells[celli]);
576 forAll(psib.boundaryField(), patchi)
578 fvPatchScalarField& ppsib = psib.boundaryField()[patchi];
580 const fvPatchScalarField& pp = p_.boundaryField()[patchi];
581 const fvPatchScalarField& pTb = Tb_.boundaryField()[patchi];
586 this->patchFaceReactants
587 (patchi, facei).psi(pp[facei], pTb[facei]);
595 template<class MixtureType>
596 Foam::tmp<Foam::volScalarField>
597 Foam::hhuMixtureThermo<MixtureType>::muu() const
599 tmp<volScalarField> tmuu
606 T_.time().timeName(),
612 dimensionSet(1, -1, -1, 0, 0)
616 volScalarField& muu_ = tmuu();
617 scalarField& muuCells = muu_.internalField();
618 const scalarField& TuCells = Tu_.internalField();
620 forAll(muuCells, celli)
622 muuCells[celli] = this->cellReactants(celli).mu(TuCells[celli]);
625 forAll(muu_.boundaryField(), patchi)
627 fvPatchScalarField& pMuu = muu_.boundaryField()[patchi];
628 const fvPatchScalarField& pTu = Tu_.boundaryField()[patchi];
633 this->patchFaceReactants(patchi, facei).mu(pTu[facei]);
641 template<class MixtureType>
642 Foam::tmp<Foam::volScalarField>
643 Foam::hhuMixtureThermo<MixtureType>::mub() const
645 tmp<volScalarField> tmub
652 T_.time().timeName(),
658 dimensionSet(1, -1, -1, 0, 0)
662 volScalarField& mub_ = tmub();
663 scalarField& mubCells = mub_.internalField();
664 volScalarField Tb_ = Tb();
665 const scalarField& TbCells = Tb_.internalField();
667 forAll(mubCells, celli)
669 mubCells[celli] = this->cellProducts(celli).mu(TbCells[celli]);
672 forAll(mub_.boundaryField(), patchi)
674 fvPatchScalarField& pMub = mub_.boundaryField()[patchi];
675 const fvPatchScalarField& pTb = Tb_.boundaryField()[patchi];
680 this->patchFaceProducts(patchi, facei).mu(pTb[facei]);
688 template<class MixtureType>
689 bool Foam::hhuMixtureThermo<MixtureType>::read()
691 if (hhuCombustionThermo::read())
693 MixtureType::read(*this);
703 // ************************************************************************* //