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 "hsRhoThermo.H"
29 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
31 template<class MixtureType>
32 void Foam::hsRhoThermo<MixtureType>::calculate()
34 const scalarField& hsCells = this->hs_.internalField();
35 const scalarField& pCells = this->p_.internalField();
37 scalarField& TCells = this->T_.internalField();
38 scalarField& psiCells = this->psi_.internalField();
39 scalarField& rhoCells = this->rho_.internalField();
40 scalarField& muCells = this->mu_.internalField();
41 scalarField& alphaCells = this->alpha_.internalField();
45 const typename MixtureType::thermoType& mixture_ =
46 this->cellMixture(celli);
48 TCells[celli] = mixture_.THs(hsCells[celli], TCells[celli]);
49 psiCells[celli] = mixture_.psi(pCells[celli], TCells[celli]);
50 rhoCells[celli] = mixture_.rho(pCells[celli], TCells[celli]);
52 muCells[celli] = mixture_.mu(TCells[celli]);
53 alphaCells[celli] = mixture_.alpha(TCells[celli]);
56 forAll(this->T_.boundaryField(), patchi)
58 fvPatchScalarField& pp = this->p_.boundaryField()[patchi];
59 fvPatchScalarField& pT = this->T_.boundaryField()[patchi];
60 fvPatchScalarField& ppsi = this->psi_.boundaryField()[patchi];
61 fvPatchScalarField& prho = this->rho_.boundaryField()[patchi];
63 fvPatchScalarField& phs = this->hs_.boundaryField()[patchi];
65 fvPatchScalarField& pmu = this->mu_.boundaryField()[patchi];
66 fvPatchScalarField& palpha = this->alpha_.boundaryField()[patchi];
72 const typename MixtureType::thermoType& mixture_ =
73 this->patchFaceMixture(patchi, facei);
75 phs[facei] = mixture_.Hs(pT[facei]);
77 ppsi[facei] = mixture_.psi(pp[facei], pT[facei]);
78 prho[facei] = mixture_.rho(pp[facei], pT[facei]);
79 pmu[facei] = mixture_.mu(pT[facei]);
80 palpha[facei] = mixture_.alpha(pT[facei]);
87 const typename MixtureType::thermoType& mixture_ =
88 this->patchFaceMixture(patchi, facei);
90 pT[facei] = mixture_.THs(phs[facei], pT[facei]);
92 ppsi[facei] = mixture_.psi(pp[facei], pT[facei]);
93 prho[facei] = mixture_.rho(pp[facei], pT[facei]);
94 pmu[facei] = mixture_.mu(pT[facei]);
95 palpha[facei] = mixture_.alpha(pT[facei]);
102 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
104 template<class MixtureType>
105 Foam::hsRhoThermo<MixtureType>::hsRhoThermo(const fvMesh& mesh)
107 basicRhoThermo(mesh),
108 MixtureType(*this, mesh),
115 mesh.time().timeName(),
122 this->hBoundaryTypes()
125 scalarField& hsCells = hs_.internalField();
126 const scalarField& TCells = this->T_.internalField();
128 forAll(hsCells, celli)
130 hsCells[celli] = this->cellMixture(celli).Hs(TCells[celli]);
133 forAll(hs_.boundaryField(), patchi)
135 hs_.boundaryField()[patchi] ==
136 hs(this->T_.boundaryField()[patchi], patchi);
139 hBoundaryCorrection(hs_);
145 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
147 template<class MixtureType>
148 Foam::hsRhoThermo<MixtureType>::~hsRhoThermo()
152 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
154 template<class MixtureType>
155 void Foam::hsRhoThermo<MixtureType>::correct()
159 Info<< "entering hsRhoThermo<MixtureType>::correct()" << endl;
166 Info<< "exiting hsRhoThermo<MixtureType>::correct()" << endl;
171 template<class MixtureType>
172 Foam::tmp<Foam::scalarField> Foam::hsRhoThermo<MixtureType>::hs
174 const scalarField& T,
175 const labelList& cells
178 tmp<scalarField> ths(new scalarField(T.size()));
179 scalarField& hs = ths();
183 hs[celli] = this->cellMixture(cells[celli]).Hs(T[celli]);
190 template<class MixtureType>
191 Foam::tmp<Foam::scalarField> Foam::hsRhoThermo<MixtureType>::hs
193 const scalarField& T,
197 tmp<scalarField> ths(new scalarField(T.size()));
198 scalarField& hs = ths();
202 hs[facei] = this->patchFaceMixture(patchi, facei).Hs(T[facei]);
209 template<class MixtureType>
210 Foam::tmp<Foam::scalarField> Foam::hsRhoThermo<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::hsRhoThermo<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::hsRhoThermo<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::hsRhoThermo<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::hsRhoThermo<MixtureType>::read()
333 if (basicRhoThermo::read())
335 MixtureType::read(*this);
345 // ************************************************************************* //