1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
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 "hPsiThermo.H"
29 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
31 template<class MixtureType>
32 void Foam::hPsiThermo<MixtureType>::calculate()
34 const scalarField& hCells = h_.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_.TH(hCells[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& ph = h_.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 ph[facei] = mixture_.H(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_.TH(ph[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::hPsiThermo<MixtureType>::hPsiThermo(const fvMesh& mesh, const objectRegistry& obj)
102 basicPsiThermo(mesh, obj),
103 MixtureType(*this, mesh, obj),
110 mesh.time().timeName(),
116 dimensionSet(0, 2, -2, 0, 0),
117 this->hBoundaryTypes()
120 scalarField& hCells = h_.internalField();
121 const scalarField& TCells = this->T_.internalField();
123 forAll(hCells, celli)
125 hCells[celli] = this->cellMixture(celli).H(TCells[celli]);
128 forAll(h_.boundaryField(), patchi)
130 h_.boundaryField()[patchi] ==
131 h(this->T_.boundaryField()[patchi], patchi);
134 hBoundaryCorrection(h_);
138 // Switch on saving old time
139 this->psi_.oldTime();
143 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
145 template<class MixtureType>
146 Foam::hPsiThermo<MixtureType>::~hPsiThermo()
150 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
152 template<class MixtureType>
153 void Foam::hPsiThermo<MixtureType>::correct()
157 Info<< "entering hPsiThermo<MixtureType>::correct()" << endl;
160 // force the saving of the old-time values
161 this->psi_.oldTime();
167 Info<< "exiting hPsiThermo<MixtureType>::correct()" << endl;
172 template<class MixtureType>
173 Foam::tmp<Foam::scalarField> Foam::hPsiThermo<MixtureType>::h
175 const scalarField& T,
176 const labelList& cells
179 tmp<scalarField> th(new scalarField(T.size()));
180 scalarField& h = th();
184 h[celli] = this->cellMixture(cells[celli]).H(T[celli]);
191 template<class MixtureType>
192 Foam::tmp<Foam::scalarField> Foam::hPsiThermo<MixtureType>::h
194 const scalarField& T,
198 tmp<scalarField> th(new scalarField(T.size()));
199 scalarField& h = th();
203 h[facei] = this->patchFaceMixture(patchi, facei).H(T[facei]);
210 template<class MixtureType>
211 Foam::tmp<Foam::scalarField> Foam::hPsiThermo<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::scalarField> Foam::hPsiThermo<MixtureType>::Cp
232 const scalarField& T,
233 const labelList& cells
236 tmp<scalarField> tCp(new scalarField(T.size()));
237 scalarField& cp = tCp();
241 cp[celli] = this->cellMixture(cells[celli]).Cp(T[celli]);
248 template<class MixtureType>
249 Foam::tmp<Foam::volScalarField> Foam::hPsiThermo<MixtureType>::Cp() const
251 const fvMesh& mesh = this->T_.mesh();
253 tmp<volScalarField> tCp
260 mesh.time().timeName(),
266 dimensionSet(0, 2, -2, -1, 0)
270 volScalarField& cp = tCp();
272 forAll(this->T_, celli)
274 cp[celli] = this->cellMixture(celli).Cp(this->T_[celli]);
277 forAll(this->T_.boundaryField(), patchi)
279 const fvPatchScalarField& pT = this->T_.boundaryField()[patchi];
280 fvPatchScalarField& pCp = cp.boundaryField()[patchi];
284 pCp[facei] = this->patchFaceMixture(patchi, facei).Cp(pT[facei]);
292 template<class MixtureType>
293 Foam::tmp<Foam::scalarField> Foam::hPsiThermo<MixtureType>::Cv
295 const scalarField& T,
299 tmp<scalarField> tCv(new scalarField(T.size()));
300 scalarField& cv = tCv();
304 cv[facei] = this->patchFaceMixture(patchi, facei).Cv(T[facei]);
311 template<class MixtureType>
312 Foam::tmp<Foam::volScalarField> Foam::hPsiThermo<MixtureType>::Cv() const
314 const fvMesh& mesh = this->T_.mesh();
316 tmp<volScalarField> tCv
323 mesh.time().timeName(),
329 dimensionSet(0, 2, -2, -1, 0)
333 volScalarField& cv = tCv();
335 forAll(this->T_, celli)
337 cv[celli] = this->cellMixture(celli).Cv(this->T_[celli]);
340 forAll(this->T_.boundaryField(), patchi)
342 cv.boundaryField()[patchi] =
343 Cv(this->T_.boundaryField()[patchi], patchi);
350 template<class MixtureType>
351 bool Foam::hPsiThermo<MixtureType>::read()
353 if (basicPsiThermo::read())
355 MixtureType::read(*this);
365 // ************************************************************************* //