1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
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 "hPsiThermo.H"
28 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
30 template<class MixtureType>
31 void Foam::hPsiThermo<MixtureType>::calculate()
33 const scalarField& hCells = h_.internalField();
34 const scalarField& pCells = this->p_.internalField();
36 scalarField& TCells = this->T_.internalField();
37 scalarField& psiCells = this->psi_.internalField();
38 scalarField& muCells = this->mu_.internalField();
39 scalarField& alphaCells = this->alpha_.internalField();
43 const typename MixtureType::thermoType& mixture_ =
44 this->cellMixture(celli);
46 TCells[celli] = mixture_.TH(hCells[celli], TCells[celli]);
47 psiCells[celli] = mixture_.psi(pCells[celli], TCells[celli]);
49 muCells[celli] = mixture_.mu(TCells[celli]);
50 alphaCells[celli] = mixture_.alpha(TCells[celli]);
53 forAll(T_.boundaryField(), patchi)
55 fvPatchScalarField& pp = this->p_.boundaryField()[patchi];
56 fvPatchScalarField& pT = this->T_.boundaryField()[patchi];
57 fvPatchScalarField& ppsi = this->psi_.boundaryField()[patchi];
59 fvPatchScalarField& ph = h_.boundaryField()[patchi];
61 fvPatchScalarField& pmu = this->mu_.boundaryField()[patchi];
62 fvPatchScalarField& palpha = this->alpha_.boundaryField()[patchi];
68 const typename MixtureType::thermoType& mixture_ =
69 this->patchFaceMixture(patchi, facei);
71 ph[facei] = mixture_.H(pT[facei]);
73 ppsi[facei] = mixture_.psi(pp[facei], pT[facei]);
74 pmu[facei] = mixture_.mu(pT[facei]);
75 palpha[facei] = mixture_.alpha(pT[facei]);
82 const typename MixtureType::thermoType& mixture_ =
83 this->patchFaceMixture(patchi, facei);
85 pT[facei] = mixture_.TH(ph[facei], pT[facei]);
87 ppsi[facei] = mixture_.psi(pp[facei], pT[facei]);
88 pmu[facei] = mixture_.mu(pT[facei]);
89 palpha[facei] = mixture_.alpha(pT[facei]);
96 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
98 template<class MixtureType>
99 Foam::hPsiThermo<MixtureType>::hPsiThermo(const fvMesh& mesh)
101 basicPsiThermo(mesh),
102 MixtureType(*this, mesh),
109 mesh.time().timeName(),
116 this->hBoundaryTypes()
119 scalarField& hCells = h_.internalField();
120 const scalarField& TCells = this->T_.internalField();
122 forAll(hCells, celli)
124 hCells[celli] = this->cellMixture(celli).H(TCells[celli]);
127 forAll(h_.boundaryField(), patchi)
129 h_.boundaryField()[patchi] ==
130 h(this->T_.boundaryField()[patchi], patchi);
133 hBoundaryCorrection(h_);
137 // Switch on saving old time
138 this->psi_.oldTime();
142 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
144 template<class MixtureType>
145 Foam::hPsiThermo<MixtureType>::~hPsiThermo()
149 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
151 template<class MixtureType>
152 void Foam::hPsiThermo<MixtureType>::correct()
156 Info<< "entering hPsiThermo<MixtureType>::correct()" << endl;
159 // force the saving of the old-time values
160 this->psi_.oldTime();
166 Info<< "exiting hPsiThermo<MixtureType>::correct()" << endl;
171 template<class MixtureType>
172 Foam::tmp<Foam::scalarField> Foam::hPsiThermo<MixtureType>::h
174 const scalarField& T,
175 const labelList& cells
178 tmp<scalarField> th(new scalarField(T.size()));
179 scalarField& h = th();
183 h[celli] = this->cellMixture(cells[celli]).H(T[celli]);
190 template<class MixtureType>
191 Foam::tmp<Foam::scalarField> Foam::hPsiThermo<MixtureType>::h
193 const scalarField& T,
197 tmp<scalarField> th(new scalarField(T.size()));
198 scalarField& h = th();
202 h[facei] = this->patchFaceMixture(patchi, facei).H(T[facei]);
209 template<class MixtureType>
210 Foam::tmp<Foam::scalarField> Foam::hPsiThermo<MixtureType>::Cp
212 const scalarField& T,
216 tmp<scalarField> tCp(new scalarField(T.size()));
217 scalarField& cp = tCp();
221 cp[facei] = this->patchFaceMixture(patchi, facei).Cp(T[facei]);
228 template<class MixtureType>
229 Foam::tmp<Foam::volScalarField> Foam::hPsiThermo<MixtureType>::Cp() const
231 const fvMesh& mesh = this->T_.mesh();
233 tmp<volScalarField> tCp
240 mesh.time().timeName(),
246 dimEnergy/dimMass/dimTemperature
250 volScalarField& cp = tCp();
252 forAll(this->T_, celli)
254 cp[celli] = this->cellMixture(celli).Cp(this->T_[celli]);
257 forAll(this->T_.boundaryField(), patchi)
259 const fvPatchScalarField& pT = this->T_.boundaryField()[patchi];
260 fvPatchScalarField& pCp = cp.boundaryField()[patchi];
264 pCp[facei] = this->patchFaceMixture(patchi, facei).Cp(pT[facei]);
272 template<class MixtureType>
273 Foam::tmp<Foam::scalarField> Foam::hPsiThermo<MixtureType>::Cv
275 const scalarField& T,
279 tmp<scalarField> tCv(new scalarField(T.size()));
280 scalarField& cv = tCv();
284 cv[facei] = this->patchFaceMixture(patchi, facei).Cv(T[facei]);
291 template<class MixtureType>
292 Foam::tmp<Foam::volScalarField> Foam::hPsiThermo<MixtureType>::Cv() const
294 const fvMesh& mesh = this->T_.mesh();
296 tmp<volScalarField> tCv
303 mesh.time().timeName(),
309 dimEnergy/dimMass/dimTemperature
313 volScalarField& cv = tCv();
315 forAll(this->T_, celli)
317 cv[celli] = this->cellMixture(celli).Cv(this->T_[celli]);
320 forAll(this->T_.boundaryField(), patchi)
322 cv.boundaryField()[patchi] =
323 Cv(this->T_.boundaryField()[patchi], patchi);
330 template<class MixtureType>
331 bool Foam::hPsiThermo<MixtureType>::read()
333 if (basicPsiThermo::read())
335 MixtureType::read(*this);
345 // ************************************************************************* //