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 "hsPsiMixtureThermo.H"
28 #include "fixedValueFvPatchFields.H"
30 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
32 template<class MixtureType>
33 Foam::hsPsiMixtureThermo<MixtureType>::hsPsiMixtureThermo(const fvMesh& mesh)
35 hsCombustionThermo(mesh),
36 MixtureType(*this, mesh)
38 scalarField& hCells = hs_.internalField();
39 const scalarField& TCells = T_.internalField();
43 hCells[celli] = this->cellMixture(celli).Hs(TCells[celli]);
46 forAll(hs_.boundaryField(), patchi)
48 hs_.boundaryField()[patchi] == hs(T_.boundaryField()[patchi], patchi);
51 hBoundaryCorrection(hs_);
54 psi_.oldTime(); // Switch on saving old time
58 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
60 template<class MixtureType>
61 Foam::hsPsiMixtureThermo<MixtureType>::~hsPsiMixtureThermo()
65 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
67 template<class MixtureType>
68 void Foam::hsPsiMixtureThermo<MixtureType>::calculate()
70 const scalarField& hsCells = hs_.internalField();
71 const scalarField& pCells = p_.internalField();
73 scalarField& TCells = T_.internalField();
74 scalarField& psiCells = psi_.internalField();
75 scalarField& muCells = mu_.internalField();
76 scalarField& alphaCells = alpha_.internalField();
80 const typename MixtureType::thermoType& mixture_ =
81 this->cellMixture(celli);
83 TCells[celli] = mixture_.THs(hsCells[celli], TCells[celli]);
84 psiCells[celli] = mixture_.psi(pCells[celli], TCells[celli]);
86 muCells[celli] = mixture_.mu(TCells[celli]);
87 alphaCells[celli] = mixture_.alpha(TCells[celli]);
90 forAll(T_.boundaryField(), patchi)
92 fvPatchScalarField& pp = p_.boundaryField()[patchi];
93 fvPatchScalarField& pT = T_.boundaryField()[patchi];
94 fvPatchScalarField& ppsi = psi_.boundaryField()[patchi];
96 fvPatchScalarField& phs = hs_.boundaryField()[patchi];
98 fvPatchScalarField& pmu_ = mu_.boundaryField()[patchi];
99 fvPatchScalarField& palpha_ = alpha_.boundaryField()[patchi];
105 const typename MixtureType::thermoType& mixture_ =
106 this->patchFaceMixture(patchi, facei);
108 phs[facei] = mixture_.Hs(pT[facei]);
110 ppsi[facei] = mixture_.psi(pp[facei], pT[facei]);
111 pmu_[facei] = mixture_.mu(pT[facei]);
112 palpha_[facei] = mixture_.alpha(pT[facei]);
119 const typename MixtureType::thermoType& mixture_ =
120 this->patchFaceMixture(patchi, facei);
122 pT[facei] = mixture_.THs(phs[facei], pT[facei]);
124 ppsi[facei] = mixture_.psi(pp[facei], pT[facei]);
125 pmu_[facei] = mixture_.mu(pT[facei]);
126 palpha_[facei] = mixture_.alpha(pT[facei]);
133 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
135 template<class MixtureType>
136 void Foam::hsPsiMixtureThermo<MixtureType>::correct()
140 Info<< "entering hMixtureThermo<MixtureType>::correct()" << endl;
143 // force the saving of the old-time values
150 Info<< "exiting hMixtureThermo<MixtureType>::correct()" << endl;
154 template<class MixtureType>
155 Foam::tmp<Foam::volScalarField>
156 Foam::hsPsiMixtureThermo<MixtureType>::hc() const
158 const fvMesh& mesh = T_.mesh();
160 tmp<volScalarField> thc
167 mesh.time().timeName(),
177 volScalarField& hcf = thc();
178 scalarField& hcCells = hcf.internalField();
180 forAll(hcCells, celli)
182 hcCells[celli] = this->cellMixture(celli).Hc();
185 forAll(hcf.boundaryField(), patchi)
187 scalarField& hcp = hcf.boundaryField()[patchi];
191 hcp[facei] = this->patchFaceMixture(patchi, facei).Hc();
199 template<class MixtureType>
200 Foam::tmp<Foam::scalarField>
201 Foam::hsPsiMixtureThermo<MixtureType>::hs
203 const scalarField& T,
204 const labelList& cells
207 tmp<scalarField> ths(new scalarField(T.size()));
208 scalarField& hs = ths();
212 hs[celli] = this->cellMixture(cells[celli]).Hs(T[celli]);
219 template<class MixtureType>
220 Foam::tmp<Foam::scalarField>
221 Foam::hsPsiMixtureThermo<MixtureType>::hs
223 const scalarField& T,
227 tmp<scalarField> ths(new scalarField(T.size()));
228 scalarField& hs = ths();
232 hs[facei] = this->patchFaceMixture(patchi, facei).Hs(T[facei]);
239 template<class MixtureType>
240 Foam::tmp<Foam::scalarField>
241 Foam::hsPsiMixtureThermo<MixtureType>::Cp
243 const scalarField& T,
247 tmp<scalarField> tCp(new scalarField(T.size()));
249 scalarField& cp = tCp();
253 cp[facei] = this->patchFaceMixture(patchi, facei).Cp(T[facei]);
260 template<class MixtureType>
261 Foam::tmp<Foam::volScalarField>
262 Foam::hsPsiMixtureThermo<MixtureType>::Cp() const
264 const fvMesh& mesh = T_.mesh();
266 tmp<volScalarField> tCp
273 mesh.time().timeName(),
279 dimEnergy/dimMass/dimTemperature
283 volScalarField& cp = tCp();
285 scalarField& cpCells = cp.internalField();
286 const scalarField& TCells = T_.internalField();
288 forAll(TCells, celli)
290 cpCells[celli] = this->cellMixture(celli).Cp(TCells[celli]);
293 forAll(T_.boundaryField(), patchi)
295 cp.boundaryField()[patchi] = Cp(T_.boundaryField()[patchi], patchi);
302 template<class MixtureType>
303 bool Foam::hsPsiMixtureThermo<MixtureType>::read()
305 if (hsCombustionThermo::read())
307 MixtureType::read(*this);
317 // ************************************************************************* //