1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 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 "hPsiMixtureThermo.H"
29 #include "fixedValueFvPatchFields.H"
31 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
33 template<class MixtureType>
34 void Foam::hPsiMixtureThermo<MixtureType>::calculate()
36 const scalarField& hCells = h_.internalField();
37 const scalarField& pCells = p_.internalField();
39 scalarField& TCells = T_.internalField();
40 scalarField& psiCells = psi_.internalField();
41 scalarField& muCells = mu_.internalField();
42 scalarField& alphaCells = alpha_.internalField();
46 const typename MixtureType::thermoType& mixture =
47 this->cellMixture(celli);
49 TCells[celli] = mixture.TH(hCells[celli], TCells[celli]);
50 psiCells[celli] = mixture.psi(pCells[celli], TCells[celli]);
52 muCells[celli] = mixture.mu(TCells[celli]);
53 alphaCells[celli] = mixture.alpha(TCells[celli]);
56 forAll(T_.boundaryField(), patchi)
58 fvPatchScalarField& pp = p_.boundaryField()[patchi];
59 fvPatchScalarField& pT = T_.boundaryField()[patchi];
60 fvPatchScalarField& ppsi = psi_.boundaryField()[patchi];
62 fvPatchScalarField& ph = h_.boundaryField()[patchi];
64 fvPatchScalarField& pmu_ = mu_.boundaryField()[patchi];
65 fvPatchScalarField& palpha_ = alpha_.boundaryField()[patchi];
71 const typename MixtureType::thermoType& mixture =
72 this->patchFaceMixture(patchi, facei);
74 ph[facei] = mixture.H(pT[facei]);
76 ppsi[facei] = mixture.psi(pp[facei], pT[facei]);
77 pmu_[facei] = mixture.mu(pT[facei]);
78 palpha_[facei] = mixture.alpha(pT[facei]);
85 const typename MixtureType::thermoType& mixture =
86 this->patchFaceMixture(patchi, facei);
88 pT[facei] = mixture.TH(ph[facei], pT[facei]);
90 ppsi[facei] = mixture.psi(pp[facei], pT[facei]);
91 pmu_[facei] = mixture.mu(pT[facei]);
92 palpha_[facei] = mixture.alpha(pT[facei]);
99 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
101 template<class MixtureType>
102 Foam::hPsiMixtureThermo<MixtureType>::hPsiMixtureThermo(const fvMesh& mesh)
104 hCombustionThermo(mesh),
105 MixtureType(*this, mesh)
107 scalarField& hCells = h_.internalField();
108 const scalarField& TCells = T_.internalField();
110 forAll(hCells, celli)
112 hCells[celli] = this->cellMixture(celli).H(TCells[celli]);
115 forAll(h_.boundaryField(), patchi)
117 h_.boundaryField()[patchi] == h(T_.boundaryField()[patchi], patchi);
120 hBoundaryCorrection(h_);
124 // Switch on saving old time
129 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
131 template<class MixtureType>
132 Foam::hPsiMixtureThermo<MixtureType>::~hPsiMixtureThermo()
136 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
138 template<class MixtureType>
139 void Foam::hPsiMixtureThermo<MixtureType>::correct()
143 Info<< "entering hPsiMixtureThermo<MixtureType>::correct()" << endl;
146 // force the saving of the old-time values
153 Info<< "exiting hPsiMixtureThermo<MixtureType>::correct()" << endl;
158 template<class MixtureType>
159 Foam::tmp<Foam::volScalarField>
160 Foam::hPsiMixtureThermo<MixtureType>::hs() const
162 const fvMesh& mesh = T_.mesh();
164 tmp<volScalarField> ths
171 mesh.time().timeName(),
181 volScalarField& hsf = ths();
182 scalarField& hsCells = hsf.internalField();
183 const scalarField& TCells = T_.internalField();
185 forAll(TCells, celli)
187 hsCells[celli] = this->cellMixture(celli).Hs(TCells[celli]);
190 forAll(T_.boundaryField(), patchi)
192 scalarField& hsp = hsf.boundaryField()[patchi];
193 const scalarField& Tp = T_.boundaryField()[patchi];
197 hsp[facei] = this->patchFaceMixture(patchi, facei).Hs(Tp[facei]);
205 template<class MixtureType>
206 Foam::tmp<Foam::volScalarField>
207 Foam::hPsiMixtureThermo<MixtureType>::hc() const
209 const fvMesh& mesh = T_.mesh();
211 tmp<volScalarField> thc
218 mesh.time().timeName(),
228 volScalarField& hcf = thc();
229 scalarField& hcCells = hcf.internalField();
231 forAll(hcCells, celli)
233 hcCells[celli] = this->cellMixture(celli).Hc();
236 forAll(hcf.boundaryField(), patchi)
238 scalarField& hcp = hcf.boundaryField()[patchi];
242 hcp[facei] = this->patchFaceMixture(patchi, facei).Hc();
250 template<class MixtureType>
251 Foam::tmp<Foam::scalarField>
252 Foam::hPsiMixtureThermo<MixtureType>::h
254 const scalarField& T,
255 const labelList& cells
258 tmp<scalarField> th(new scalarField(T.size()));
259 scalarField& h = th();
263 h[celli] = this->cellMixture(cells[celli]).H(T[celli]);
270 template<class MixtureType>
271 Foam::tmp<Foam::scalarField>
272 Foam::hPsiMixtureThermo<MixtureType>::h
274 const scalarField& T,
278 tmp<scalarField> th(new scalarField(T.size()));
279 scalarField& h = th();
283 h[facei] = this->patchFaceMixture(patchi, facei).H(T[facei]);
290 template<class MixtureType>
291 Foam::tmp<Foam::scalarField>
292 Foam::hPsiMixtureThermo<MixtureType>::Cp
294 const scalarField& T,
298 tmp<scalarField> tCp(new scalarField(T.size()));
300 scalarField& cp = tCp();
304 cp[facei] = this->patchFaceMixture(patchi, facei).Cp(T[facei]);
311 template<class MixtureType>
312 Foam::tmp<Foam::volScalarField>
313 Foam::hPsiMixtureThermo<MixtureType>::Cp() const
315 const fvMesh& mesh = T_.mesh();
317 tmp<volScalarField> tCp
324 mesh.time().timeName(),
330 dimensionSet(0, 2, -2, -1, 0)
334 volScalarField& cp = tCp();
336 scalarField& cpCells = cp.internalField();
337 const scalarField& TCells = T_.internalField();
339 forAll(TCells, celli)
341 cpCells[celli] = this->cellMixture(celli).Cp(TCells[celli]);
344 forAll(T_.boundaryField(), patchi)
346 cp.boundaryField()[patchi] = Cp(T_.boundaryField()[patchi], patchi);
353 template<class MixtureType>
354 bool Foam::hPsiMixtureThermo<MixtureType>::read()
356 if (hCombustionThermo::read())
358 MixtureType::read(*this);
368 // ************************************************************************* //