1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2010-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 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 "hsPsiThermo.H"
29 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
31 template<class MixtureType>
32 void Foam::hsPsiThermo<MixtureType>::calculate()
34 const scalarField& hsCells = hs_.internalField();
35 const scalarField& pCells = this->p_.internalField();
37 scalarField& TCells = this->T_.internalField();
38 scalarField& psiCells = this->psi_.internalField();
39 scalarField& muCells = this->mu_.internalField();
40 scalarField& alphaCells = this->alpha_.internalField();
44 const typename MixtureType::thermoType& mixture_ =
45 this->cellMixture(celli);
47 TCells[celli] = mixture_.THs(hsCells[celli], TCells[celli]);
48 psiCells[celli] = mixture_.psi(pCells[celli], TCells[celli]);
50 muCells[celli] = mixture_.mu(TCells[celli]);
51 alphaCells[celli] = mixture_.alpha(TCells[celli]);
54 forAll(T_.boundaryField(), patchi)
56 fvPatchScalarField& pp = this->p_.boundaryField()[patchi];
57 fvPatchScalarField& pT = this->T_.boundaryField()[patchi];
58 fvPatchScalarField& ppsi = this->psi_.boundaryField()[patchi];
60 fvPatchScalarField& phs = hs_.boundaryField()[patchi];
62 fvPatchScalarField& pmu = this->mu_.boundaryField()[patchi];
63 fvPatchScalarField& palpha = this->alpha_.boundaryField()[patchi];
69 const typename MixtureType::thermoType& mixture_ =
70 this->patchFaceMixture(patchi, facei);
72 phs[facei] = mixture_.Hs(pT[facei]);
74 ppsi[facei] = mixture_.psi(pp[facei], pT[facei]);
75 pmu[facei] = mixture_.mu(pT[facei]);
76 palpha[facei] = mixture_.alpha(pT[facei]);
83 const typename MixtureType::thermoType& mixture_ =
84 this->patchFaceMixture(patchi, facei);
86 pT[facei] = mixture_.THs(phs[facei], pT[facei]);
88 ppsi[facei] = mixture_.psi(pp[facei], pT[facei]);
89 pmu[facei] = mixture_.mu(pT[facei]);
90 palpha[facei] = mixture_.alpha(pT[facei]);
97 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
99 template<class MixtureType>
100 Foam::hsPsiThermo<MixtureType>::hsPsiThermo(const fvMesh& mesh)
102 basicPsiThermo(mesh),
103 MixtureType(*this, mesh),
110 mesh.time().timeName(),
117 this->hBoundaryTypes()
120 scalarField& hsCells = hs_.internalField();
121 const scalarField& TCells = this->T_.internalField();
123 forAll(hsCells, celli)
125 hsCells[celli] = this->cellMixture(celli).Hs(TCells[celli]);
128 forAll(hs_.boundaryField(), patchi)
130 hs_.boundaryField()[patchi] ==
131 hs(this->T_.boundaryField()[patchi], patchi);
134 hBoundaryCorrection(hs_);
138 // Switch on saving old time
139 this->psi_.oldTime();
143 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
145 template<class MixtureType>
146 Foam::hsPsiThermo<MixtureType>::~hsPsiThermo()
150 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
152 template<class MixtureType>
153 void Foam::hsPsiThermo<MixtureType>::correct()
157 Info<< "entering hsPsiThermo<MixtureType>::correct()" << endl;
160 // force the saving of the old-time values
161 this->psi_.oldTime();
167 Info<< "exiting hsPsiThermo<MixtureType>::correct()" << endl;
172 template<class MixtureType>
173 Foam::tmp<Foam::scalarField> Foam::hsPsiThermo<MixtureType>::hs
175 const scalarField& T,
176 const labelList& cells
179 tmp<scalarField> ths(new scalarField(T.size()));
180 scalarField& hs = ths();
184 hs[celli] = this->cellMixture(cells[celli]).Hs(T[celli]);
191 template<class MixtureType>
192 Foam::tmp<Foam::scalarField> Foam::hsPsiThermo<MixtureType>::hs
194 const scalarField& T,
198 tmp<scalarField> ths(new scalarField(T.size()));
199 scalarField& hs = ths();
203 hs[facei] = this->patchFaceMixture(patchi, facei).Hs(T[facei]);
210 template<class MixtureType>
211 Foam::tmp<Foam::scalarField> Foam::hsPsiThermo<MixtureType>::Cp
213 const scalarField& T,
217 tmp<scalarField> tCp(new scalarField(T.size()));
218 scalarField& cp = tCp();
222 cp[facei] = this->patchFaceMixture(patchi, facei).Cp(T[facei]);
229 template<class MixtureType>
230 Foam::tmp<Foam::volScalarField> Foam::hsPsiThermo<MixtureType>::Cp() const
232 const fvMesh& mesh = this->T_.mesh();
234 tmp<volScalarField> tCp
241 mesh.time().timeName(),
247 dimensionSet(0, 2, -2, -1, 0)
251 volScalarField& cp = tCp();
253 forAll(this->T_, celli)
255 cp[celli] = this->cellMixture(celli).Cp(this->T_[celli]);
258 forAll(this->T_.boundaryField(), patchi)
260 const fvPatchScalarField& pT = this->T_.boundaryField()[patchi];
261 fvPatchScalarField& pCp = cp.boundaryField()[patchi];
265 pCp[facei] = this->patchFaceMixture(patchi, facei).Cp(pT[facei]);
273 template<class MixtureType>
274 Foam::tmp<Foam::scalarField> Foam::hsPsiThermo<MixtureType>::Cv
276 const scalarField& T,
280 tmp<scalarField> tCv(new scalarField(T.size()));
281 scalarField& cv = tCv();
285 cv[facei] = this->patchFaceMixture(patchi, facei).Cv(T[facei]);
292 template<class MixtureType>
293 Foam::tmp<Foam::volScalarField> Foam::hsPsiThermo<MixtureType>::Cv() const
295 const fvMesh& mesh = this->T_.mesh();
297 tmp<volScalarField> tCv
304 mesh.time().timeName(),
310 dimEnergy/dimMass/dimTemperature
314 volScalarField& cv = tCv();
316 forAll(this->T_, celli)
318 cv[celli] = this->cellMixture(celli).Cv(this->T_[celli]);
321 forAll(this->T_.boundaryField(), patchi)
323 cv.boundaryField()[patchi] =
324 Cv(this->T_.boundaryField()[patchi], patchi);
331 template<class MixtureType>
332 bool Foam::hsPsiThermo<MixtureType>::read()
334 if (basicPsiThermo::read())
336 MixtureType::read(*this);
346 // ************************************************************************* //