1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2008 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 \*---------------------------------------------------------------------------*/
29 #include "fixedValueFvPatchFields.H"
31 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
33 template<class MixtureType>
34 Foam::hThermo<MixtureType>::hThermo(const fvMesh& mesh)
37 MixtureType(*this, mesh),
44 mesh.time().timeName(),
50 dimensionSet(0, 2, -2, 0, 0),
54 scalarField& hCells = h_.internalField();
55 const scalarField& TCells = T_.internalField();
59 hCells[celli] = this->cellMixture(celli).H(TCells[celli]);
62 forAll(h_.boundaryField(), patchi)
64 h_.boundaryField()[patchi] == h(T_.boundaryField()[patchi], patchi);
67 hBoundaryCorrection(h_);
70 psi_.oldTime(); // Switch on saving old time
74 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
76 template<class MixtureType>
77 Foam::hThermo<MixtureType>::~hThermo()
81 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
83 template<class MixtureType>
84 void Foam::hThermo<MixtureType>::calculate()
86 const scalarField& hCells = h_.internalField();
87 const scalarField& pCells = p_.internalField();
89 scalarField& TCells = T_.internalField();
90 scalarField& psiCells = psi_.internalField();
91 scalarField& muCells = mu_.internalField();
92 scalarField& alphaCells = alpha_.internalField();
96 const typename MixtureType::thermoType& mixture_ =
97 this->cellMixture(celli);
99 TCells[celli] = mixture_.TH(hCells[celli], TCells[celli]);
100 psiCells[celli] = mixture_.psi(pCells[celli], TCells[celli]);
102 muCells[celli] = mixture_.mu(TCells[celli]);
103 alphaCells[celli] = mixture_.alpha(TCells[celli]);
106 forAll(T_.boundaryField(), patchi)
108 fvPatchScalarField& pp = p_.boundaryField()[patchi];
109 fvPatchScalarField& pT = T_.boundaryField()[patchi];
110 fvPatchScalarField& ppsi = psi_.boundaryField()[patchi];
112 fvPatchScalarField& ph = h_.boundaryField()[patchi];
114 fvPatchScalarField& pmu = mu_.boundaryField()[patchi];
115 fvPatchScalarField& palpha = alpha_.boundaryField()[patchi];
121 const typename MixtureType::thermoType& mixture_ =
122 this->patchFaceMixture(patchi, facei);
124 ph[facei] = mixture_.H(pT[facei]);
126 ppsi[facei] = mixture_.psi(pp[facei], pT[facei]);
127 pmu[facei] = mixture_.mu(pT[facei]);
128 palpha[facei] = mixture_.alpha(pT[facei]);
135 const typename MixtureType::thermoType& mixture_ =
136 this->patchFaceMixture(patchi, facei);
138 pT[facei] = mixture_.TH(ph[facei], pT[facei]);
140 ppsi[facei] = mixture_.psi(pp[facei], pT[facei]);
141 pmu[facei] = mixture_.mu(pT[facei]);
142 palpha[facei] = mixture_.alpha(pT[facei]);
149 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
151 template<class MixtureType>
152 void Foam::hThermo<MixtureType>::correct()
156 Info<< "entering hThermo<MixtureType>::correct()" << endl;
159 // force the saving of the old-time values
166 Info<< "exiting hThermo<MixtureType>::correct()" << endl;
171 template<class MixtureType>
172 Foam::tmp<Foam::scalarField> Foam::hThermo<MixtureType>::h
174 const scalarField& T,
175 const labelList& cells
178 tmp<scalarField> th(new scalarField(T.size()));
179 scalarField& h = th();
183 h[celli] = this->cellMixture(cells[celli]).H(T[celli]);
190 template<class MixtureType>
191 Foam::tmp<Foam::scalarField> Foam::hThermo<MixtureType>::h
193 const scalarField& T,
197 tmp<scalarField> th(new scalarField(T.size()));
198 scalarField& h = th();
202 h[facei] = this->patchFaceMixture(patchi, facei).H(T[facei]);
209 template<class MixtureType>
210 Foam::tmp<Foam::scalarField> Foam::hThermo<MixtureType>::Cp
212 const scalarField& T,
216 tmp<scalarField> tCp(new scalarField(T.size()));
217 scalarField& cp = tCp();
221 cp[facei] = this->patchFaceMixture(patchi, facei).Cp(T[facei]);
228 template<class MixtureType>
229 Foam::tmp<Foam::volScalarField> Foam::hThermo<MixtureType>::Cp() const
231 const fvMesh& mesh = T_.mesh();
233 tmp<volScalarField> tCp
240 mesh.time().timeName(),
246 dimensionSet(0, 2, -2, -1, 0)
250 volScalarField& cp = tCp();
254 cp[celli] = this->cellMixture(celli).Cp(T_[celli]);
257 forAll(T_.boundaryField(), patchi)
259 cp.boundaryField()[patchi] = Cp(T_.boundaryField()[patchi], patchi);
266 template<class MixtureType>
267 Foam::tmp<Foam::volScalarField> Foam::hThermo<MixtureType>::Cv() const
269 const fvMesh& mesh = T_.mesh();
271 tmp<volScalarField> tCv
278 mesh.time().timeName(),
284 dimensionSet(0, 2, -2, -1, 0),
285 T_.boundaryField().types()
289 volScalarField& cv = tCv();
293 cv[celli] = this->cellMixture(celli).Cv(T_[celli]);
296 forAll(T_.boundaryField(), patchi)
298 const fvPatchScalarField& pT = T_.boundaryField()[patchi];
299 fvPatchScalarField& pCv = cv.boundaryField()[patchi];
303 pCv[facei] = this->patchFaceMixture(patchi, facei).Cv(pT[facei]);
311 template<class MixtureType>
312 bool Foam::hThermo<MixtureType>::read()
314 if (basicThermo::read())
316 MixtureType::read(*this);
326 // ************************************************************************* //