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 "ePsiThermo.H"
28 #include "fixedValueFvPatchFields.H"
30 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
32 template<class MixtureType>
33 void Foam::ePsiThermo<MixtureType>::calculate()
35 const scalarField& eCells = e_.internalField();
36 const scalarField& pCells = this->p_.internalField();
38 scalarField& TCells = this->T_.internalField();
39 scalarField& psiCells = this->psi_.internalField();
40 scalarField& muCells = this->mu_.internalField();
41 scalarField& alphaCells = this->alpha_.internalField();
45 const typename MixtureType::thermoType& mixture_ =
46 this->cellMixture(celli);
48 TCells[celli] = mixture_.TE(eCells[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(this->T_.boundaryField(), patchi)
57 fvPatchScalarField& pp = this->p_.boundaryField()[patchi];
58 fvPatchScalarField& pT = this->T_.boundaryField()[patchi];
59 fvPatchScalarField& ppsi = this->psi_.boundaryField()[patchi];
61 fvPatchScalarField& pe = e_.boundaryField()[patchi];
63 fvPatchScalarField& pmu = this->mu_.boundaryField()[patchi];
64 fvPatchScalarField& palpha = this->alpha_.boundaryField()[patchi];
70 const typename MixtureType::thermoType& mixture_ =
71 this->patchFaceMixture(patchi, facei);
73 pe[facei] = mixture_.E(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_.TE(pe[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::ePsiThermo<MixtureType>::ePsiThermo(const fvMesh& mesh)
103 basicPsiThermo(mesh),
104 MixtureType(*this, mesh),
111 mesh.time().timeName(),
118 this->eBoundaryTypes()
121 scalarField& eCells = e_.internalField();
122 const scalarField& TCells = this->T_.internalField();
124 forAll(eCells, celli)
126 eCells[celli] = this->cellMixture(celli).E(TCells[celli]);
129 forAll(e_.boundaryField(), patchi)
131 e_.boundaryField()[patchi] ==
132 e(this->T_.boundaryField()[patchi], patchi);
135 this->eBoundaryCorrection(e_);
139 // Switch on saving old time
140 this->psi_.oldTime();
144 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
146 template<class MixtureType>
147 Foam::ePsiThermo<MixtureType>::~ePsiThermo()
151 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
153 template<class MixtureType>
154 void Foam::ePsiThermo<MixtureType>::correct()
158 Info<< "entering ePsiThermo<MixtureType>::correct()" << endl;
161 // force the saving of the old-time values
162 this->psi_.oldTime();
168 Info<< "exiting ePsiThermo<MixtureType>::correct()" << endl;
173 template<class MixtureType>
174 Foam::tmp<Foam::scalarField> Foam::ePsiThermo<MixtureType>::e
176 const scalarField& T,
177 const labelList& cells
180 tmp<scalarField> te(new scalarField(T.size()));
181 scalarField& h = te();
185 h[celli] = this->cellMixture(cells[celli]).E(T[celli]);
192 template<class MixtureType>
193 Foam::tmp<Foam::scalarField> Foam::ePsiThermo<MixtureType>::e
195 const scalarField& T,
199 tmp<scalarField> te(new scalarField(T.size()));
200 scalarField& h = te();
204 h[facei] = this->patchFaceMixture(patchi, facei).E(T[facei]);
211 template<class MixtureType>
212 Foam::tmp<Foam::scalarField> Foam::ePsiThermo<MixtureType>::Cp
214 const scalarField& T,
218 tmp<scalarField> tCp(new scalarField(T.size()));
219 scalarField& cp = tCp();
223 cp[facei] = this->patchFaceMixture(patchi, facei).Cp(T[facei]);
230 template<class MixtureType>
231 Foam::tmp<Foam::volScalarField> Foam::ePsiThermo<MixtureType>::Cp() const
233 const fvMesh& mesh = this->T_.mesh();
235 tmp<volScalarField> tCp
242 mesh.time().timeName(),
248 dimEnergy/dimMass/dimTemperature
252 volScalarField& cp = tCp();
254 forAll(this->T_, celli)
256 cp[celli] = this->cellMixture(celli).Cp(this->T_[celli]);
259 forAll(this->T_.boundaryField(), patchi)
261 const fvPatchScalarField& pT = this->T_.boundaryField()[patchi];
262 fvPatchScalarField& pCp = cp.boundaryField()[patchi];
266 pCp[facei] = this->patchFaceMixture(patchi, facei).Cp(pT[facei]);
274 template<class MixtureType>
275 Foam::tmp<Foam::scalarField> Foam::ePsiThermo<MixtureType>::Cv
277 const scalarField& T,
281 tmp<scalarField> tCv(new scalarField(T.size()));
282 scalarField& cv = tCv();
286 cv[facei] = this->patchFaceMixture(patchi, facei).Cv(T[facei]);
293 template<class MixtureType>
294 Foam::tmp<Foam::volScalarField> Foam::ePsiThermo<MixtureType>::Cv() const
296 const fvMesh& mesh = this->T_.mesh();
298 tmp<volScalarField> tCv
305 mesh.time().timeName(),
311 dimEnergy/dimMass/dimTemperature
315 volScalarField& cv = tCv();
317 forAll(this->T_, celli)
319 cv[celli] = this->cellMixture(celli).Cv(this->T_[celli]);
322 forAll(this->T_.boundaryField(), patchi)
324 cv.boundaryField()[patchi] =
325 Cv(this->T_.boundaryField()[patchi], patchi);
332 template<class MixtureType>
333 bool Foam::ePsiThermo<MixtureType>::read()
335 if (basicPsiThermo::read())
337 MixtureType::read(*this);
347 // ************************************************************************* //