1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
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 "ePsiThermo.H"
29 #include "fixedValueFvPatchFields.H"
31 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
33 template<class MixtureType>
34 void Foam::ePsiThermo<MixtureType>::calculate()
36 const scalarField& eCells = e_.internalField();
37 const scalarField& pCells = this->p_.internalField();
39 scalarField& TCells = this->T_.internalField();
40 scalarField& psiCells = this->psi_.internalField();
41 scalarField& muCells = this->mu_.internalField();
42 scalarField& alphaCells = this->alpha_.internalField();
46 const typename MixtureType::thermoType& mixture_ =
47 this->cellMixture(celli);
49 TCells[celli] = mixture_.TE(eCells[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(this->T_.boundaryField(), patchi)
58 fvPatchScalarField& pp = this->p_.boundaryField()[patchi];
59 fvPatchScalarField& pT = this->T_.boundaryField()[patchi];
60 fvPatchScalarField& ppsi = this->psi_.boundaryField()[patchi];
62 fvPatchScalarField& pe = e_.boundaryField()[patchi];
64 fvPatchScalarField& pmu = this->mu_.boundaryField()[patchi];
65 fvPatchScalarField& palpha = this->alpha_.boundaryField()[patchi];
71 const typename MixtureType::thermoType& mixture_ =
72 this->patchFaceMixture(patchi, facei);
74 pe[facei] = mixture_.E(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_.TE(pe[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::ePsiThermo<MixtureType>::ePsiThermo(const fvMesh& mesh)
104 basicPsiThermo(mesh),
105 MixtureType(*this, mesh),
112 mesh.time().timeName(),
118 dimensionSet(0, 2, -2, 0, 0),
119 this->eBoundaryTypes()
122 scalarField& eCells = e_.internalField();
123 const scalarField& TCells = this->T_.internalField();
125 forAll(eCells, celli)
127 eCells[celli] = this->cellMixture(celli).E(TCells[celli]);
130 forAll(e_.boundaryField(), patchi)
132 e_.boundaryField()[patchi] ==
133 e(this->T_.boundaryField()[patchi], patchi);
136 this->eBoundaryCorrection(e_);
140 // Switch on saving old time
141 this->psi_.oldTime();
145 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
147 template<class MixtureType>
148 Foam::ePsiThermo<MixtureType>::~ePsiThermo()
152 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
154 template<class MixtureType>
155 void Foam::ePsiThermo<MixtureType>::correct()
159 Info<< "entering ePsiThermo<MixtureType>::correct()" << endl;
162 // force the saving of the old-time values
163 this->psi_.oldTime();
169 Info<< "exiting ePsiThermo<MixtureType>::correct()" << endl;
174 template<class MixtureType>
175 Foam::tmp<Foam::scalarField> Foam::ePsiThermo<MixtureType>::e
177 const scalarField& T,
178 const labelList& cells
181 tmp<scalarField> te(new scalarField(T.size()));
182 scalarField& h = te();
186 h[celli] = this->cellMixture(cells[celli]).E(T[celli]);
193 template<class MixtureType>
194 Foam::tmp<Foam::scalarField> Foam::ePsiThermo<MixtureType>::e
196 const scalarField& T,
200 tmp<scalarField> te(new scalarField(T.size()));
201 scalarField& h = te();
205 h[facei] = this->patchFaceMixture(patchi, facei).E(T[facei]);
212 template<class MixtureType>
213 Foam::tmp<Foam::scalarField> Foam::ePsiThermo<MixtureType>::Cp
215 const scalarField& T,
219 tmp<scalarField> tCp(new scalarField(T.size()));
220 scalarField& cp = tCp();
224 cp[facei] = this->patchFaceMixture(patchi, facei).Cp(T[facei]);
231 template<class MixtureType>
232 Foam::tmp<Foam::volScalarField> Foam::ePsiThermo<MixtureType>::Cp() const
234 const fvMesh& mesh = this->T_.mesh();
236 tmp<volScalarField> tCp
243 mesh.time().timeName(),
249 dimensionSet(0, 2, -2, -1, 0),
250 this->T_.boundaryField().types()
254 volScalarField& cp = tCp();
256 forAll(this->T_, celli)
258 cp[celli] = this->cellMixture(celli).Cp(this->T_[celli]);
261 forAll(this->T_.boundaryField(), patchi)
263 const fvPatchScalarField& pT = this->T_.boundaryField()[patchi];
264 fvPatchScalarField& pCp = cp.boundaryField()[patchi];
268 pCp[facei] = this->patchFaceMixture(patchi, facei).Cp(pT[facei]);
276 template<class MixtureType>
277 Foam::tmp<Foam::scalarField> Foam::ePsiThermo<MixtureType>::Cv
279 const scalarField& T,
283 tmp<scalarField> tCv(new scalarField(T.size()));
284 scalarField& cv = tCv();
288 cv[facei] = this->patchFaceMixture(patchi, facei).Cv(T[facei]);
295 template<class MixtureType>
296 Foam::tmp<Foam::volScalarField> Foam::ePsiThermo<MixtureType>::Cv() const
298 const fvMesh& mesh = this->T_.mesh();
300 tmp<volScalarField> tCv
307 mesh.time().timeName(),
313 dimensionSet(0, 2, -2, -1, 0)
317 volScalarField& cv = tCv();
319 forAll(this->T_, celli)
321 cv[celli] = this->cellMixture(celli).Cv(this->T_[celli]);
324 forAll(this->T_.boundaryField(), patchi)
326 cv.boundaryField()[patchi] =
327 Cv(this->T_.boundaryField()[patchi], patchi);
334 template<class MixtureType>
335 bool Foam::ePsiThermo<MixtureType>::read()
337 if (basicPsiThermo::read())
339 MixtureType::read(*this);
349 // ************************************************************************* //