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 "hsPsiMixtureThermo.H"
28 #include "fixedValueFvPatchFields.H"
30 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
32 template<class MixtureType>
33 Foam::hsPsiMixtureThermo<MixtureType>::hsPsiMixtureThermo
36 const objectRegistry& obj
39 hsCombustionThermo(mesh, obj),
40 MixtureType(*this, mesh, obj)
42 scalarField& hCells = hs_.internalField();
43 const scalarField& TCells = T_.internalField();
47 hCells[celli] = this->cellMixture(celli).Hs(TCells[celli]);
50 forAll(hs_.boundaryField(), patchi)
52 hs_.boundaryField()[patchi] == hs(T_.boundaryField()[patchi], patchi);
55 hBoundaryCorrection(hs_);
58 psi_.oldTime(); // Switch on saving old time
62 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
64 template<class MixtureType>
65 Foam::hsPsiMixtureThermo<MixtureType>::~hsPsiMixtureThermo()
69 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
71 template<class MixtureType>
72 void Foam::hsPsiMixtureThermo<MixtureType>::calculate()
74 const scalarField& hsCells = hs_.internalField();
75 const scalarField& pCells = p_.internalField();
77 scalarField& TCells = T_.internalField();
78 scalarField& psiCells = psi_.internalField();
79 scalarField& muCells = mu_.internalField();
80 scalarField& alphaCells = alpha_.internalField();
84 const typename MixtureType::thermoType& mixture_ =
85 this->cellMixture(celli);
87 TCells[celli] = mixture_.THs(hsCells[celli], TCells[celli]);
88 psiCells[celli] = mixture_.psi(pCells[celli], TCells[celli]);
90 muCells[celli] = mixture_.mu(TCells[celli]);
91 alphaCells[celli] = mixture_.alpha(TCells[celli]);
94 forAll(T_.boundaryField(), patchi)
96 fvPatchScalarField& pp = p_.boundaryField()[patchi];
97 fvPatchScalarField& pT = T_.boundaryField()[patchi];
98 fvPatchScalarField& ppsi = psi_.boundaryField()[patchi];
100 fvPatchScalarField& phs = hs_.boundaryField()[patchi];
102 fvPatchScalarField& pmu_ = mu_.boundaryField()[patchi];
103 fvPatchScalarField& palpha_ = alpha_.boundaryField()[patchi];
109 const typename MixtureType::thermoType& mixture_ =
110 this->patchFaceMixture(patchi, facei);
112 phs[facei] = mixture_.Hs(pT[facei]);
114 ppsi[facei] = mixture_.psi(pp[facei], pT[facei]);
115 pmu_[facei] = mixture_.mu(pT[facei]);
116 palpha_[facei] = mixture_.alpha(pT[facei]);
123 const typename MixtureType::thermoType& mixture_ =
124 this->patchFaceMixture(patchi, facei);
126 pT[facei] = mixture_.THs(phs[facei], pT[facei]);
128 ppsi[facei] = mixture_.psi(pp[facei], pT[facei]);
129 pmu_[facei] = mixture_.mu(pT[facei]);
130 palpha_[facei] = mixture_.alpha(pT[facei]);
137 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
139 template<class MixtureType>
140 void Foam::hsPsiMixtureThermo<MixtureType>::correct()
144 Info<< "entering hMixtureThermo<MixtureType>::correct()" << endl;
147 // force the saving of the old-time values
154 Info<< "exiting hMixtureThermo<MixtureType>::correct()" << endl;
158 template<class MixtureType>
159 Foam::tmp<Foam::volScalarField>
160 Foam::hsPsiMixtureThermo<MixtureType>::hc() const
162 const fvMesh& mesh = T_.mesh();
164 tmp<volScalarField> thc
171 mesh.time().timeName(),
181 volScalarField& hcf = thc();
182 scalarField& hcCells = hcf.internalField();
184 forAll(hcCells, celli)
186 hcCells[celli] = this->cellMixture(celli).Hc();
189 forAll(hcf.boundaryField(), patchi)
191 scalarField& hcp = hcf.boundaryField()[patchi];
195 hcp[facei] = this->patchFaceMixture(patchi, facei).Hc();
203 template<class MixtureType>
204 Foam::tmp<Foam::scalarField>
205 Foam::hsPsiMixtureThermo<MixtureType>::hs
207 const scalarField& T,
208 const labelList& cells
211 tmp<scalarField> ths(new scalarField(T.size()));
212 scalarField& hs = ths();
216 hs[celli] = this->cellMixture(cells[celli]).Hs(T[celli]);
223 template<class MixtureType>
224 Foam::tmp<Foam::scalarField>
225 Foam::hsPsiMixtureThermo<MixtureType>::hs
227 const scalarField& T,
231 tmp<scalarField> ths(new scalarField(T.size()));
232 scalarField& hs = ths();
236 hs[facei] = this->patchFaceMixture(patchi, facei).Hs(T[facei]);
243 template<class MixtureType>
244 Foam::tmp<Foam::scalarField>
245 Foam::hsPsiMixtureThermo<MixtureType>::Cp
247 const scalarField& T,
251 tmp<scalarField> tCp(new scalarField(T.size()));
253 scalarField& cp = tCp();
257 cp[facei] = this->patchFaceMixture(patchi, facei).Cp(T[facei]);
264 template<class MixtureType>
265 Foam::tmp<Foam::scalarField>
266 Foam::hsPsiMixtureThermo<MixtureType>::Cp
268 const scalarField& T,
269 const labelList& cells
272 tmp<scalarField> tCp(new scalarField(T.size()));
273 scalarField& cp = tCp();
277 cp[celli] = this->cellMixture(cells[celli]).Cp(T[celli]);
284 template<class MixtureType>
285 Foam::tmp<Foam::volScalarField>
286 Foam::hsPsiMixtureThermo<MixtureType>::Cp() const
288 const fvMesh& mesh = T_.mesh();
290 tmp<volScalarField> tCp
297 mesh.time().timeName(),
303 dimEnergy/dimMass/dimTemperature
307 volScalarField& cp = tCp();
309 scalarField& cpCells = cp.internalField();
310 const scalarField& TCells = T_.internalField();
312 forAll(TCells, celli)
314 cpCells[celli] = this->cellMixture(celli).Cp(TCells[celli]);
317 forAll(T_.boundaryField(), patchi)
319 cp.boundaryField()[patchi] = Cp(T_.boundaryField()[patchi], patchi);
326 template<class MixtureType>
327 bool Foam::hsPsiMixtureThermo<MixtureType>::read()
329 if (hsCombustionThermo::read())
331 MixtureType::read(*this);
341 // ************************************************************************* //