1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
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
13 the Free Software Foundation, either version 3 of the License, or
14 (at your 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, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "hPsiMixtureThermo.H"
28 #include "fixedValueFvPatchFields.H"
30 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
32 template<class MixtureType>
33 void Foam::hPsiMixtureThermo<MixtureType>::calculate()
35 const scalarField& hCells = h_.internalField();
36 const scalarField& pCells = p_.internalField();
38 scalarField& TCells = T_.internalField();
39 scalarField& psiCells = psi_.internalField();
40 scalarField& muCells = mu_.internalField();
41 scalarField& alphaCells = alpha_.internalField();
45 const typename MixtureType::thermoType& mixture =
46 this->cellMixture(celli);
48 TCells[celli] = mixture.TH(hCells[celli], TCells[celli]);
49 psiCells[celli] = mixture.psi(pCells[celli], TCells[celli]);
51 muCells[celli] = mixture.mu(TCells[celli]);
52 alphaCells[celli] = mixture.alpha(TCells[celli]);
55 forAll(T_.boundaryField(), patchi)
57 fvPatchScalarField& pp = p_.boundaryField()[patchi];
58 fvPatchScalarField& pT = T_.boundaryField()[patchi];
59 fvPatchScalarField& ppsi = psi_.boundaryField()[patchi];
61 fvPatchScalarField& ph = h_.boundaryField()[patchi];
63 fvPatchScalarField& pmu_ = mu_.boundaryField()[patchi];
64 fvPatchScalarField& palpha_ = alpha_.boundaryField()[patchi];
70 const typename MixtureType::thermoType& mixture =
71 this->patchFaceMixture(patchi, facei);
73 ph[facei] = mixture.H(pT[facei]);
75 ppsi[facei] = mixture.psi(pp[facei], pT[facei]);
76 pmu_[facei] = mixture.mu(pT[facei]);
77 palpha_[facei] = mixture.alpha(pT[facei]);
84 const typename MixtureType::thermoType& mixture =
85 this->patchFaceMixture(patchi, facei);
87 pT[facei] = mixture.TH(ph[facei], pT[facei]);
89 ppsi[facei] = mixture.psi(pp[facei], pT[facei]);
90 pmu_[facei] = mixture.mu(pT[facei]);
91 palpha_[facei] = mixture.alpha(pT[facei]);
98 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
100 template<class MixtureType>
101 Foam::hPsiMixtureThermo<MixtureType>::hPsiMixtureThermo(const fvMesh& mesh)
103 hCombustionThermo(mesh),
104 MixtureType(*this, mesh)
106 scalarField& hCells = h_.internalField();
107 const scalarField& TCells = T_.internalField();
109 forAll(hCells, celli)
111 hCells[celli] = this->cellMixture(celli).H(TCells[celli]);
114 forAll(h_.boundaryField(), patchi)
116 h_.boundaryField()[patchi] == h(T_.boundaryField()[patchi], patchi);
119 hBoundaryCorrection(h_);
123 // Switch on saving old time
128 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
130 template<class MixtureType>
131 Foam::hPsiMixtureThermo<MixtureType>::~hPsiMixtureThermo()
135 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
137 template<class MixtureType>
138 void Foam::hPsiMixtureThermo<MixtureType>::correct()
142 Info<< "entering hPsiMixtureThermo<MixtureType>::correct()" << endl;
145 // force the saving of the old-time values
152 Info<< "exiting hPsiMixtureThermo<MixtureType>::correct()" << endl;
157 template<class MixtureType>
158 Foam::tmp<Foam::volScalarField>
159 Foam::hPsiMixtureThermo<MixtureType>::hc() const
161 const fvMesh& mesh = T_.mesh();
163 tmp<volScalarField> thc
170 mesh.time().timeName(),
180 volScalarField& hcf = thc();
181 scalarField& hcCells = hcf.internalField();
183 forAll(hcCells, celli)
185 hcCells[celli] = this->cellMixture(celli).Hc();
188 forAll(hcf.boundaryField(), patchi)
190 scalarField& hcp = hcf.boundaryField()[patchi];
194 hcp[facei] = this->patchFaceMixture(patchi, facei).Hc();
202 template<class MixtureType>
203 Foam::tmp<Foam::scalarField>
204 Foam::hPsiMixtureThermo<MixtureType>::h
206 const scalarField& T,
207 const labelList& cells
210 tmp<scalarField> th(new scalarField(T.size()));
211 scalarField& h = th();
215 h[celli] = this->cellMixture(cells[celli]).H(T[celli]);
222 template<class MixtureType>
223 Foam::tmp<Foam::scalarField>
224 Foam::hPsiMixtureThermo<MixtureType>::h
226 const scalarField& T,
230 tmp<scalarField> th(new scalarField(T.size()));
231 scalarField& h = th();
235 h[facei] = this->patchFaceMixture(patchi, facei).H(T[facei]);
242 template<class MixtureType>
243 Foam::tmp<Foam::scalarField>
244 Foam::hPsiMixtureThermo<MixtureType>::Cp
246 const scalarField& T,
250 tmp<scalarField> tCp(new scalarField(T.size()));
252 scalarField& cp = tCp();
256 cp[facei] = this->patchFaceMixture(patchi, facei).Cp(T[facei]);
263 template<class MixtureType>
264 Foam::tmp<Foam::volScalarField>
265 Foam::hPsiMixtureThermo<MixtureType>::Cp() const
267 const fvMesh& mesh = T_.mesh();
269 tmp<volScalarField> tCp
276 mesh.time().timeName(),
282 dimEnergy/dimMass/dimTemperature
286 volScalarField& cp = tCp();
288 scalarField& cpCells = cp.internalField();
289 const scalarField& TCells = T_.internalField();
291 forAll(TCells, celli)
293 cpCells[celli] = this->cellMixture(celli).Cp(TCells[celli]);
296 forAll(T_.boundaryField(), patchi)
298 cp.boundaryField()[patchi] = Cp(T_.boundaryField()[patchi], patchi);
305 template<class MixtureType>
306 bool Foam::hPsiMixtureThermo<MixtureType>::read()
308 if (hCombustionThermo::read())
310 MixtureType::read(*this);
320 // ************************************************************************* //