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 "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
105 const objectRegistry& obj
108 hCombustionThermo(mesh, obj),
109 MixtureType(*this, mesh, obj)
111 scalarField& hCells = h_.internalField();
112 const scalarField& TCells = T_.internalField();
114 forAll(hCells, celli)
116 hCells[celli] = this->cellMixture(celli).H(TCells[celli]);
119 forAll(h_.boundaryField(), patchi)
121 h_.boundaryField()[patchi] == h(T_.boundaryField()[patchi], patchi);
124 hBoundaryCorrection(h_);
128 // Switch on saving old time
133 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
135 template<class MixtureType>
136 Foam::hPsiMixtureThermo<MixtureType>::~hPsiMixtureThermo()
140 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
142 template<class MixtureType>
143 void Foam::hPsiMixtureThermo<MixtureType>::correct()
147 Info<< "entering hPsiMixtureThermo<MixtureType>::correct()" << endl;
150 // force the saving of the old-time values
157 Info<< "exiting hPsiMixtureThermo<MixtureType>::correct()" << endl;
162 template<class MixtureType>
163 Foam::tmp<Foam::volScalarField>
164 Foam::hPsiMixtureThermo<MixtureType>::hc() const
166 const fvMesh& mesh = T_.mesh();
168 tmp<volScalarField> thc
175 mesh.time().timeName(),
185 volScalarField& hcf = thc();
186 scalarField& hcCells = hcf.internalField();
188 forAll(hcCells, celli)
190 hcCells[celli] = this->cellMixture(celli).Hc();
193 forAll(hcf.boundaryField(), patchi)
195 scalarField& hcp = hcf.boundaryField()[patchi];
199 hcp[facei] = this->patchFaceMixture(patchi, facei).Hc();
207 template<class MixtureType>
208 Foam::tmp<Foam::scalarField>
209 Foam::hPsiMixtureThermo<MixtureType>::h
211 const scalarField& T,
212 const labelList& cells
215 tmp<scalarField> th(new scalarField(T.size()));
216 scalarField& h = th();
220 h[celli] = this->cellMixture(cells[celli]).H(T[celli]);
227 template<class MixtureType>
228 Foam::tmp<Foam::scalarField>
229 Foam::hPsiMixtureThermo<MixtureType>::h
231 const scalarField& T,
235 tmp<scalarField> th(new scalarField(T.size()));
236 scalarField& h = th();
240 h[facei] = this->patchFaceMixture(patchi, facei).H(T[facei]);
247 template<class MixtureType>
248 Foam::tmp<Foam::scalarField>
249 Foam::hPsiMixtureThermo<MixtureType>::Cp
251 const scalarField& T,
255 tmp<scalarField> tCp(new scalarField(T.size()));
257 scalarField& cp = tCp();
261 cp[facei] = this->patchFaceMixture(patchi, facei).Cp(T[facei]);
268 template<class MixtureType>
269 Foam::tmp<Foam::volScalarField>
270 Foam::hPsiMixtureThermo<MixtureType>::Cp() const
272 const fvMesh& mesh = T_.mesh();
274 tmp<volScalarField> tCp
281 mesh.time().timeName(),
287 dimensionSet(0, 2, -2, -1, 0)
291 volScalarField& cp = tCp();
293 scalarField& cpCells = cp.internalField();
294 const scalarField& TCells = T_.internalField();
296 forAll(TCells, celli)
298 cpCells[celli] = this->cellMixture(celli).Cp(TCells[celli]);
301 forAll(T_.boundaryField(), patchi)
303 cp.boundaryField()[patchi] = Cp(T_.boundaryField()[patchi], patchi);
310 template<class MixtureType>
311 bool Foam::hPsiMixtureThermo<MixtureType>::read()
313 if (hCombustionThermo::read())
315 MixtureType::read(*this);
325 // ************************************************************************* //