1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend 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 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. 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
104 const objectRegistry& obj
107 hCombustionThermo(mesh, obj),
108 MixtureType(*this, mesh, obj)
110 scalarField& hCells = h_.internalField();
111 const scalarField& TCells = T_.internalField();
113 forAll(hCells, celli)
115 hCells[celli] = this->cellMixture(celli).H(TCells[celli]);
118 forAll(h_.boundaryField(), patchi)
120 h_.boundaryField()[patchi] == h(T_.boundaryField()[patchi], patchi);
123 hBoundaryCorrection(h_);
127 // Switch on saving old time
132 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
134 template<class MixtureType>
135 Foam::hPsiMixtureThermo<MixtureType>::~hPsiMixtureThermo()
139 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
141 template<class MixtureType>
142 void Foam::hPsiMixtureThermo<MixtureType>::correct()
146 Info<< "entering hPsiMixtureThermo<MixtureType>::correct()" << endl;
149 // force the saving of the old-time values
156 Info<< "exiting hPsiMixtureThermo<MixtureType>::correct()" << endl;
161 template<class MixtureType>
162 Foam::tmp<Foam::volScalarField>
163 Foam::hPsiMixtureThermo<MixtureType>::hc() const
165 const fvMesh& mesh = T_.mesh();
167 tmp<volScalarField> thc
174 mesh.time().timeName(),
184 volScalarField& hcf = thc();
185 scalarField& hcCells = hcf.internalField();
187 forAll(hcCells, celli)
189 hcCells[celli] = this->cellMixture(celli).Hc();
192 forAll(hcf.boundaryField(), patchi)
194 scalarField& hcp = hcf.boundaryField()[patchi];
198 hcp[facei] = this->patchFaceMixture(patchi, facei).Hc();
206 template<class MixtureType>
207 Foam::tmp<Foam::scalarField>
208 Foam::hPsiMixtureThermo<MixtureType>::h
210 const scalarField& T,
211 const labelList& cells
214 tmp<scalarField> th(new scalarField(T.size()));
215 scalarField& h = th();
219 h[celli] = this->cellMixture(cells[celli]).H(T[celli]);
226 template<class MixtureType>
227 Foam::tmp<Foam::scalarField>
228 Foam::hPsiMixtureThermo<MixtureType>::h
230 const scalarField& T,
234 tmp<scalarField> th(new scalarField(T.size()));
235 scalarField& h = th();
239 h[facei] = this->patchFaceMixture(patchi, facei).H(T[facei]);
246 template<class MixtureType>
247 Foam::tmp<Foam::scalarField>
248 Foam::hPsiMixtureThermo<MixtureType>::Cp
250 const scalarField& T,
254 tmp<scalarField> tCp(new scalarField(T.size()));
256 scalarField& cp = tCp();
260 cp[facei] = this->patchFaceMixture(patchi, facei).Cp(T[facei]);
267 template<class MixtureType>
268 Foam::tmp<Foam::scalarField>
269 Foam::hPsiMixtureThermo<MixtureType>::Cp
271 const scalarField& T,
272 const labelList& cells
275 tmp<scalarField> tCp(new scalarField(T.size()));
276 scalarField& cp = tCp();
280 cp[celli] = this->cellMixture(cells[celli]).Cp(T[celli]);
287 template<class MixtureType>
288 Foam::tmp<Foam::volScalarField>
289 Foam::hPsiMixtureThermo<MixtureType>::Cp() const
291 const fvMesh& mesh = T_.mesh();
293 tmp<volScalarField> tCp
300 mesh.time().timeName(),
306 dimensionSet(0, 2, -2, -1, 0)
310 volScalarField& cp = tCp();
312 scalarField& cpCells = cp.internalField();
313 const scalarField& TCells = T_.internalField();
315 forAll(TCells, celli)
317 cpCells[celli] = this->cellMixture(celli).Cp(TCells[celli]);
320 forAll(T_.boundaryField(), patchi)
322 cp.boundaryField()[patchi] = Cp(T_.boundaryField()[patchi], patchi);
329 template<class MixtureType>
330 bool Foam::hPsiMixtureThermo<MixtureType>::read()
332 if (hCombustionThermo::read())
334 MixtureType::read(*this);
344 // ************************************************************************* //