1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2009-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 "hRhoMixtureThermo.H"
29 #include "fixedValueFvPatchFields.H"
31 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
33 template<class MixtureType>
34 void Foam::hRhoMixtureThermo<MixtureType>::calculate()
36 const scalarField& hCells = h_.internalField();
37 const scalarField& pCells = p_.internalField();
39 scalarField& TCells = T_.internalField();
40 scalarField& psiCells = psi_.internalField();
41 scalarField& rhoCells = rho_.internalField();
42 scalarField& muCells = mu_.internalField();
43 scalarField& alphaCells = alpha_.internalField();
47 const typename MixtureType::thermoType& mixture =
48 this->cellMixture(celli);
50 TCells[celli] = mixture.TH(hCells[celli], TCells[celli]);
51 psiCells[celli] = mixture.psi(pCells[celli], TCells[celli]);
52 rhoCells[celli] = mixture.rho(pCells[celli], TCells[celli]);
54 muCells[celli] = mixture.mu(TCells[celli]);
55 alphaCells[celli] = mixture.alpha(TCells[celli]);
58 forAll(T_.boundaryField(), patchi)
60 fvPatchScalarField& pp = p_.boundaryField()[patchi];
61 fvPatchScalarField& pT = T_.boundaryField()[patchi];
62 fvPatchScalarField& ppsi = psi_.boundaryField()[patchi];
63 fvPatchScalarField& prho = rho_.boundaryField()[patchi];
65 fvPatchScalarField& ph = h_.boundaryField()[patchi];
67 fvPatchScalarField& pmu_ = mu_.boundaryField()[patchi];
68 fvPatchScalarField& palpha_ = alpha_.boundaryField()[patchi];
74 const typename MixtureType::thermoType& mixture =
75 this->patchFaceMixture(patchi, facei);
77 ph[facei] = mixture.H(pT[facei]);
79 ppsi[facei] = mixture.psi(pp[facei], pT[facei]);
80 prho[facei] = mixture.rho(pp[facei], pT[facei]);
81 pmu_[facei] = mixture.mu(pT[facei]);
82 palpha_[facei] = mixture.alpha(pT[facei]);
89 const typename MixtureType::thermoType& mixture =
90 this->patchFaceMixture(patchi, facei);
92 pT[facei] = mixture.TH(ph[facei], pT[facei]);
94 ppsi[facei] = mixture.psi(pp[facei], pT[facei]);
95 prho[facei] = mixture.rho(pp[facei], pT[facei]);
96 pmu_[facei] = mixture.mu(pT[facei]);
97 palpha_[facei] = mixture.alpha(pT[facei]);
104 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
106 template<class MixtureType>
107 Foam::hRhoMixtureThermo<MixtureType>::hRhoMixtureThermo(const fvMesh& mesh)
109 hReactionThermo(mesh),
110 MixtureType(*this, mesh)
112 scalarField& hCells = h_.internalField();
113 const scalarField& TCells = T_.internalField();
115 forAll(hCells, celli)
117 hCells[celli] = this->cellMixture(celli).H(TCells[celli]);
120 forAll(h_.boundaryField(), patchi)
122 h_.boundaryField()[patchi] == h(T_.boundaryField()[patchi], patchi);
125 hBoundaryCorrection(h_);
131 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
133 template<class MixtureType>
134 Foam::hRhoMixtureThermo<MixtureType>::~hRhoMixtureThermo()
138 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
140 template<class MixtureType>
141 void Foam::hRhoMixtureThermo<MixtureType>::correct()
145 Info<< "entering hRhoMixtureThermo<MixtureType>::correct()" << endl;
152 Info<< "exiting hRhoMixtureThermo<MixtureType>::correct()" << endl;
157 template<class MixtureType>
158 Foam::tmp<Foam::volScalarField>
159 Foam::hRhoMixtureThermo<MixtureType>::hc() const
161 const fvMesh& mesh = T_.mesh();
163 tmp<volScalarField> thc
170 mesh.time().timeName(),
180 volScalarField& hcf = thc();
181 scalarField& hcCells = hcf.internalField();
183 forAll(hcCells, celli)
185 hcCells[celli] = this->cellMixture(celli).Hc();
188 forAll(hcf.boundaryField(), patchi)
190 scalarField& hcp = hcf.boundaryField()[patchi];
194 hcp[facei] = this->patchFaceMixture(patchi, facei).Hc();
202 template<class MixtureType>
203 Foam::tmp<Foam::scalarField>
204 Foam::hRhoMixtureThermo<MixtureType>::h
206 const scalarField& T,
207 const labelList& cells
210 tmp<scalarField> th(new scalarField(T.size()));
211 scalarField& h = th();
215 h[celli] = this->cellMixture(cells[celli]).H(T[celli]);
222 template<class MixtureType>
223 Foam::tmp<Foam::scalarField>
224 Foam::hRhoMixtureThermo<MixtureType>::h
226 const scalarField& T,
230 tmp<scalarField> th(new scalarField(T.size()));
231 scalarField& h = th();
235 h[facei] = this->patchFaceMixture(patchi, facei).H(T[facei]);
242 template<class MixtureType>
243 Foam::tmp<Foam::scalarField>
244 Foam::hRhoMixtureThermo<MixtureType>::Cp
246 const scalarField& T,
250 tmp<scalarField> tCp(new scalarField(T.size()));
252 scalarField& cp = tCp();
256 cp[facei] = this->patchFaceMixture(patchi, facei).Cp(T[facei]);
263 template<class MixtureType>
264 Foam::tmp<Foam::volScalarField>
265 Foam::hRhoMixtureThermo<MixtureType>::Cp() const
267 const fvMesh& mesh = T_.mesh();
269 tmp<volScalarField> tCp
276 mesh.time().timeName(),
282 dimensionSet(0, 2, -2, -1, 0)
286 volScalarField& cp = tCp();
288 scalarField& cpCells = cp.internalField();
289 const scalarField& TCells = T_.internalField();
291 forAll(TCells, celli)
293 cpCells[celli] = this->cellMixture(celli).Cp(TCells[celli]);
296 forAll(T_.boundaryField(), patchi)
298 cp.boundaryField()[patchi] = Cp(T_.boundaryField()[patchi], patchi);
305 template<class MixtureType>
306 bool Foam::hRhoMixtureThermo<MixtureType>::read()
308 if (hReactionThermo::read())
310 MixtureType::read(*this);
320 // ************************************************************************* //