1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 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, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include "hhuMixtureThermo.H"
29 #include "fixedValueFvPatchFields.H"
31 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
33 template<class MixtureType>
34 Foam::hhuMixtureThermo<MixtureType>::hhuMixtureThermo(const fvMesh& mesh)
36 hhuCombustionThermo(mesh),
37 MixtureType(*this, mesh)
39 scalarField& hCells = h_.internalField();
40 scalarField& huCells = hu_.internalField();
41 const scalarField& TCells = T_.internalField();
42 const scalarField& TuCells = Tu_.internalField();
46 hCells[celli] = this->cellMixture(celli).H(TCells[celli]);
47 huCells[celli] = this->cellReactants(celli).H(TuCells[celli]);
50 forAll(h_.boundaryField(), patchi)
52 h_.boundaryField()[patchi] == h(T_.boundaryField()[patchi], patchi);
54 fvPatchScalarField& phu = hu_.boundaryField()[patchi];
55 const fvPatchScalarField& pTu = Tu_.boundaryField()[patchi];
59 phu[facei] = this->patchFaceReactants(patchi, facei).H(pTu[facei]);
63 hBoundaryCorrection(h_);
64 huBoundaryCorrection(hu_);
67 psi_.oldTime(); // Switch on saving old time
71 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
73 template<class MixtureType>
74 Foam::hhuMixtureThermo<MixtureType>::~hhuMixtureThermo()
78 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
80 template<class MixtureType>
81 void Foam::hhuMixtureThermo<MixtureType>::calculate()
83 const scalarField& hCells = h_.internalField();
84 const scalarField& huCells = hu_.internalField();
85 const scalarField& pCells = p_.internalField();
87 scalarField& TCells = T_.internalField();
88 scalarField& TuCells = Tu_.internalField();
89 scalarField& psiCells = psi_.internalField();
90 scalarField& muCells = mu_.internalField();
91 scalarField& alphaCells = alpha_.internalField();
95 const typename MixtureType::thermoType& mixture_ =
96 this->cellMixture(celli);
98 TCells[celli] = mixture_.TH(hCells[celli], TCells[celli]);
99 psiCells[celli] = mixture_.psi(pCells[celli], TCells[celli]);
101 muCells[celli] = mixture_.mu(TCells[celli]);
102 alphaCells[celli] = mixture_.alpha(TCells[celli]);
105 this->cellReactants(celli).TH(huCells[celli], TuCells[celli]);
108 forAll(T_.boundaryField(), patchi)
110 fvPatchScalarField& pp = p_.boundaryField()[patchi];
111 fvPatchScalarField& pT = T_.boundaryField()[patchi];
112 fvPatchScalarField& pTu = Tu_.boundaryField()[patchi];
113 fvPatchScalarField& ppsi = psi_.boundaryField()[patchi];
115 fvPatchScalarField& ph = h_.boundaryField()[patchi];
116 fvPatchScalarField& phu = hu_.boundaryField()[patchi];
118 fvPatchScalarField& pmu_ = mu_.boundaryField()[patchi];
119 fvPatchScalarField& palpha_ = alpha_.boundaryField()[patchi];
125 const typename MixtureType::thermoType& mixture_ =
126 this->patchFaceMixture(patchi, facei);
128 ph[facei] = mixture_.H(pT[facei]);
130 ppsi[facei] = mixture_.psi(pp[facei], pT[facei]);
131 pmu_[facei] = mixture_.mu(pT[facei]);
132 palpha_[facei] = mixture_.alpha(pT[facei]);
139 const typename MixtureType::thermoType& mixture_ =
140 this->patchFaceMixture(patchi, facei);
142 pT[facei] = mixture_.TH(ph[facei], pT[facei]);
144 ppsi[facei] = mixture_.psi(pp[facei], pT[facei]);
145 pmu_[facei] = mixture_.mu(pT[facei]);
146 palpha_[facei] = mixture_.alpha(pT[facei]);
149 this->patchFaceReactants(patchi, facei)
150 .TH(phu[facei], pTu[facei]);
157 template<class MixtureType>
158 void Foam::hhuMixtureThermo<MixtureType>::correct()
162 Info<< "entering hhuMixtureThermo<MixtureType>::correct()" << endl;
165 // force the saving of the old-time values
172 Info<< "exiting hhuMixtureThermo<MixtureType>::correct()" << endl;
177 template<class MixtureType>
178 Foam::tmp<Foam::volScalarField>
179 Foam::hhuMixtureThermo<MixtureType>::hc() const
181 const fvMesh& mesh = T_.mesh();
183 tmp<volScalarField> thc
190 mesh.time().timeName(),
200 volScalarField& hcf = thc();
201 scalarField& hcCells = hcf.internalField();
203 forAll(hcCells, celli)
205 hcCells[celli] = this->cellMixture(celli).Hc();
208 forAll(hcf.boundaryField(), patchi)
210 scalarField& hcp = hcf.boundaryField()[patchi];
214 hcp[facei] = this->patchFaceMixture(patchi, facei).Hc();
222 template<class MixtureType>
223 Foam::tmp<Foam::scalarField> Foam::hhuMixtureThermo<MixtureType>::h
225 const scalarField& T,
226 const labelList& cells
229 tmp<scalarField> th(new scalarField(T.size()));
230 scalarField& h = th();
234 h[celli] = this->cellMixture(cells[celli]).H(T[celli]);
241 template<class MixtureType>
242 Foam::tmp<Foam::scalarField> Foam::hhuMixtureThermo<MixtureType>::h
244 const scalarField& T,
248 tmp<scalarField> th(new scalarField(T.size()));
249 scalarField& h = th();
253 h[facei] = this->patchFaceMixture(patchi, facei).H(T[facei]);
260 template<class MixtureType>
261 Foam::tmp<Foam::scalarField> Foam::hhuMixtureThermo<MixtureType>::Cp
263 const scalarField& T,
267 tmp<scalarField> tCp(new scalarField(T.size()));
269 scalarField& cp = tCp();
273 cp[facei] = this->patchFaceMixture(patchi, facei).Cp(T[facei]);
280 template<class MixtureType>
281 Foam::tmp<Foam::volScalarField>
282 Foam::hhuMixtureThermo<MixtureType>::Cp() const
284 const fvMesh& mesh = T_.mesh();
286 tmp<volScalarField> tCp
293 mesh.time().timeName(),
299 dimensionSet(0, 2, -2, -1, 0)
303 volScalarField& cp = tCp();
304 scalarField& cpCells = cp.internalField();
305 const scalarField& TCells = T_.internalField();
307 forAll(TCells, celli)
309 cpCells[celli] = this->cellMixture(celli).Cp(TCells[celli]);
312 forAll(T_.boundaryField(), patchi)
314 cp.boundaryField()[patchi] = Cp(T_.boundaryField()[patchi], patchi);
321 template<class MixtureType>
322 Foam::tmp<Foam::scalarField>
323 Foam::hhuMixtureThermo<MixtureType>::hu
325 const scalarField& Tu,
326 const labelList& cells
329 tmp<scalarField> thu(new scalarField(Tu.size()));
330 scalarField& hu = thu();
334 hu[celli] = this->cellReactants(cells[celli]).H(Tu[celli]);
341 template<class MixtureType>
342 Foam::tmp<Foam::scalarField>
343 Foam::hhuMixtureThermo<MixtureType>::hu
345 const scalarField& Tu,
349 tmp<scalarField> thu(new scalarField(Tu.size()));
350 scalarField& hu = thu();
354 hu[facei] = this->patchFaceReactants(patchi, facei).H(Tu[facei]);
361 template<class MixtureType>
362 Foam::tmp<Foam::volScalarField>
363 Foam::hhuMixtureThermo<MixtureType>::Tb() const
365 tmp<volScalarField> tTb
372 T_.time().timeName(),
381 volScalarField& Tb_ = tTb();
382 scalarField& TbCells = Tb_.internalField();
383 const scalarField& TCells = T_.internalField();
384 const scalarField& hCells = h_.internalField();
386 forAll(TbCells, celli)
389 this->cellProducts(celli).TH(hCells[celli], TCells[celli]);
392 forAll(Tb_.boundaryField(), patchi)
394 fvPatchScalarField& pTb = Tb_.boundaryField()[patchi];
396 const fvPatchScalarField& ph = h_.boundaryField()[patchi];
397 const fvPatchScalarField& pT = T_.boundaryField()[patchi];
402 this->patchFaceProducts(patchi, facei)
403 .TH(ph[facei], pT[facei]);
411 template<class MixtureType>
412 Foam::tmp<Foam::volScalarField>
413 Foam::hhuMixtureThermo<MixtureType>::psiu() const
415 tmp<volScalarField> tpsiu
422 psi_.time().timeName(),
432 volScalarField& psiu = tpsiu();
433 scalarField& psiuCells = psiu.internalField();
434 const scalarField& TuCells = Tu_.internalField();
435 const scalarField& pCells = p_.internalField();
437 forAll(psiuCells, celli)
440 this->cellReactants(celli).psi(pCells[celli], TuCells[celli]);
443 forAll(psiu.boundaryField(), patchi)
445 fvPatchScalarField& ppsiu = psiu.boundaryField()[patchi];
447 const fvPatchScalarField& pp = p_.boundaryField()[patchi];
448 const fvPatchScalarField& pTu = Tu_.boundaryField()[patchi];
454 patchFaceReactants(patchi, facei).psi(pp[facei], pTu[facei]);
462 template<class MixtureType>
463 Foam::tmp<Foam::volScalarField>
464 Foam::hhuMixtureThermo<MixtureType>::psib() const
466 tmp<volScalarField> tpsib
473 psi_.time().timeName(),
483 volScalarField& psib = tpsib();
484 scalarField& psibCells = psib.internalField();
485 volScalarField Tb_ = Tb();
486 const scalarField& TbCells = Tb_.internalField();
487 const scalarField& pCells = p_.internalField();
489 forAll(psibCells, celli)
492 this->cellReactants(celli).psi(pCells[celli], TbCells[celli]);
495 forAll(psib.boundaryField(), patchi)
497 fvPatchScalarField& ppsib = psib.boundaryField()[patchi];
499 const fvPatchScalarField& pp = p_.boundaryField()[patchi];
500 const fvPatchScalarField& pTb = Tb_.boundaryField()[patchi];
505 this->patchFaceReactants
506 (patchi, facei).psi(pp[facei], pTb[facei]);
514 template<class MixtureType>
515 Foam::tmp<Foam::volScalarField>
516 Foam::hhuMixtureThermo<MixtureType>::muu() const
518 tmp<volScalarField> tmuu
525 T_.time().timeName(),
531 dimensionSet(1, -1, -1, 0, 0)
535 volScalarField& muu_ = tmuu();
536 scalarField& muuCells = muu_.internalField();
537 const scalarField& TuCells = Tu_.internalField();
539 forAll(muuCells, celli)
541 muuCells[celli] = this->cellReactants(celli).mu(TuCells[celli]);
544 forAll(muu_.boundaryField(), patchi)
546 fvPatchScalarField& pMuu = muu_.boundaryField()[patchi];
547 const fvPatchScalarField& pTu = Tu_.boundaryField()[patchi];
552 this->patchFaceReactants(patchi, facei).mu(pTu[facei]);
560 template<class MixtureType>
561 Foam::tmp<Foam::volScalarField>
562 Foam::hhuMixtureThermo<MixtureType>::mub() const
564 tmp<volScalarField> tmub
571 T_.time().timeName(),
577 dimensionSet(1, -1, -1, 0, 0)
581 volScalarField& mub_ = tmub();
582 scalarField& mubCells = mub_.internalField();
583 volScalarField Tb_ = Tb();
584 const scalarField& TbCells = Tb_.internalField();
586 forAll(mubCells, celli)
588 mubCells[celli] = this->cellProducts(celli).mu(TbCells[celli]);
591 forAll(mub_.boundaryField(), patchi)
593 fvPatchScalarField& pMub = mub_.boundaryField()[patchi];
594 const fvPatchScalarField& pTb = Tb_.boundaryField()[patchi];
599 this->patchFaceProducts(patchi, facei).mu(pTb[facei]);
607 template<class MixtureType>
608 bool Foam::hhuMixtureThermo<MixtureType>::read()
610 if (hhuCombustionThermo::read())
612 MixtureType::read(*this);
622 // ************************************************************************* //