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 "hsPsiThermo.H"
28 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
30 template<class MixtureType>
31 void Foam::hsPsiThermo<MixtureType>::calculate()
33 const scalarField& hsCells = hs_.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_.THs(hsCells[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& phs = hs_.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 phs[facei] = mixture_.Hs(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_.THs(phs[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::hsPsiThermo<MixtureType>::hsPsiThermo
102 const objectRegistry& obj
105 basicPsiThermo(mesh, obj),
106 MixtureType(*this, mesh, obj),
113 mesh.time().timeName(),
120 this->hBoundaryTypes()
123 scalarField& hsCells = hs_.internalField();
124 const scalarField& TCells = this->T_.internalField();
126 forAll(hsCells, celli)
128 hsCells[celli] = this->cellMixture(celli).Hs(TCells[celli]);
131 forAll(hs_.boundaryField(), patchi)
133 hs_.boundaryField()[patchi] ==
134 hs(this->T_.boundaryField()[patchi], patchi);
137 hBoundaryCorrection(hs_);
141 // Switch on saving old time
142 this->psi_.oldTime();
146 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
148 template<class MixtureType>
149 Foam::hsPsiThermo<MixtureType>::~hsPsiThermo()
153 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
155 template<class MixtureType>
156 void Foam::hsPsiThermo<MixtureType>::correct()
160 Info<< "entering hsPsiThermo<MixtureType>::correct()" << endl;
163 // force the saving of the old-time values
164 this->psi_.oldTime();
170 Info<< "exiting hsPsiThermo<MixtureType>::correct()" << endl;
175 template<class MixtureType>
176 Foam::tmp<Foam::scalarField> Foam::hsPsiThermo<MixtureType>::hs
178 const scalarField& T,
179 const labelList& cells
182 tmp<scalarField> ths(new scalarField(T.size()));
183 scalarField& hs = ths();
187 hs[celli] = this->cellMixture(cells[celli]).Hs(T[celli]);
194 template<class MixtureType>
195 Foam::tmp<Foam::scalarField> Foam::hsPsiThermo<MixtureType>::hs
197 const scalarField& T,
201 tmp<scalarField> ths(new scalarField(T.size()));
202 scalarField& hs = ths();
206 hs[facei] = this->patchFaceMixture(patchi, facei).Hs(T[facei]);
213 template<class MixtureType>
214 Foam::tmp<Foam::scalarField> Foam::hsPsiThermo<MixtureType>::Cp
216 const scalarField& T,
220 tmp<scalarField> tCp(new scalarField(T.size()));
221 scalarField& cp = tCp();
225 cp[facei] = this->patchFaceMixture(patchi, facei).Cp(T[facei]);
232 template<class MixtureType>
233 Foam::tmp<Foam::scalarField> Foam::hsPsiThermo<MixtureType>::Cp
235 const scalarField& T,
236 const labelList& cells
239 tmp<scalarField> tCp(new scalarField(T.size()));
240 scalarField& cp = tCp();
244 cp[celli] = this->cellMixture(cells[celli]).Cp(T[celli]);
251 template<class MixtureType>
252 Foam::tmp<Foam::volScalarField> Foam::hsPsiThermo<MixtureType>::Cp() const
254 const fvMesh& mesh = this->T_.mesh();
256 tmp<volScalarField> tCp
263 mesh.time().timeName(),
269 dimensionSet(0, 2, -2, -1, 0)
273 volScalarField& cp = tCp();
275 forAll(this->T_, celli)
277 cp[celli] = this->cellMixture(celli).Cp(this->T_[celli]);
280 forAll(this->T_.boundaryField(), patchi)
282 const fvPatchScalarField& pT = this->T_.boundaryField()[patchi];
283 fvPatchScalarField& pCp = cp.boundaryField()[patchi];
287 pCp[facei] = this->patchFaceMixture(patchi, facei).Cp(pT[facei]);
295 template<class MixtureType>
296 Foam::tmp<Foam::scalarField> Foam::hsPsiThermo<MixtureType>::Cv
298 const scalarField& T,
302 tmp<scalarField> tCv(new scalarField(T.size()));
303 scalarField& cv = tCv();
307 cv[facei] = this->patchFaceMixture(patchi, facei).Cv(T[facei]);
314 template<class MixtureType>
315 Foam::tmp<Foam::volScalarField> Foam::hsPsiThermo<MixtureType>::Cv() const
317 const fvMesh& mesh = this->T_.mesh();
319 tmp<volScalarField> tCv
326 mesh.time().timeName(),
332 dimEnergy/dimMass/dimTemperature
336 volScalarField& cv = tCv();
338 forAll(this->T_, celli)
340 cv[celli] = this->cellMixture(celli).Cv(this->T_[celli]);
343 forAll(this->T_.boundaryField(), patchi)
345 cv.boundaryField()[patchi] =
346 Cv(this->T_.boundaryField()[patchi], patchi);
353 template<class MixtureType>
354 bool Foam::hsPsiThermo<MixtureType>::read()
356 if (basicPsiThermo::read())
358 MixtureType::read(*this);
368 // ************************************************************************* //