OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

hRhoMixtureThermo.C

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 2009-2009 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 \*---------------------------------------------------------------------------*/
00026 
00027 #include "hRhoMixtureThermo.H"
00028 #include "fvMesh.H"
00029 #include "fixedValueFvPatchFields.H"
00030 
00031 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
00032 
00033 template<class MixtureType>
00034 void Foam::hRhoMixtureThermo<MixtureType>::calculate()
00035 {
00036     const scalarField& hCells = h_.internalField();
00037     const scalarField& pCells = p_.internalField();
00038 
00039     scalarField& TCells = T_.internalField();
00040     scalarField& psiCells = psi_.internalField();
00041     scalarField& rhoCells = rho_.internalField();
00042     scalarField& muCells = mu_.internalField();
00043     scalarField& alphaCells = alpha_.internalField();
00044 
00045     forAll(TCells, celli)
00046     {
00047         const typename MixtureType::thermoType& mixture =
00048             this->cellMixture(celli);
00049 
00050         TCells[celli] = mixture.TH(hCells[celli], TCells[celli]);
00051         psiCells[celli] = mixture.psi(pCells[celli], TCells[celli]);
00052         rhoCells[celli] = mixture.rho(pCells[celli], TCells[celli]);
00053 
00054         muCells[celli] = mixture.mu(TCells[celli]);
00055         alphaCells[celli] = mixture.alpha(TCells[celli]);
00056     }
00057 
00058     forAll(T_.boundaryField(), patchi)
00059     {
00060         fvPatchScalarField& pp = p_.boundaryField()[patchi];
00061         fvPatchScalarField& pT = T_.boundaryField()[patchi];
00062         fvPatchScalarField& ppsi = psi_.boundaryField()[patchi];
00063         fvPatchScalarField& prho = rho_.boundaryField()[patchi];
00064 
00065         fvPatchScalarField& ph = h_.boundaryField()[patchi];
00066 
00067         fvPatchScalarField& pmu_ = mu_.boundaryField()[patchi];
00068         fvPatchScalarField& palpha_ = alpha_.boundaryField()[patchi];
00069 
00070         if (pT.fixesValue())
00071         {
00072             forAll(pT, facei)
00073             {
00074                 const typename MixtureType::thermoType& mixture =
00075                     this->patchFaceMixture(patchi, facei);
00076 
00077                 ph[facei] = mixture.H(pT[facei]);
00078 
00079                 ppsi[facei] = mixture.psi(pp[facei], pT[facei]);
00080                 prho[facei] = mixture.rho(pp[facei], pT[facei]);
00081                 pmu_[facei] = mixture.mu(pT[facei]);
00082                 palpha_[facei] = mixture.alpha(pT[facei]);
00083             }
00084         }
00085         else
00086         {
00087             forAll(pT, facei)
00088             {
00089                 const typename MixtureType::thermoType& mixture =
00090                     this->patchFaceMixture(patchi, facei);
00091 
00092                 pT[facei] = mixture.TH(ph[facei], pT[facei]);
00093 
00094                 ppsi[facei] = mixture.psi(pp[facei], pT[facei]);
00095                 prho[facei] = mixture.rho(pp[facei], pT[facei]);
00096                 pmu_[facei] = mixture.mu(pT[facei]);
00097                 palpha_[facei] = mixture.alpha(pT[facei]);
00098             }
00099         }
00100     }
00101 }
00102 
00103 
00104 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00105 
00106 template<class MixtureType>
00107 Foam::hRhoMixtureThermo<MixtureType>::hRhoMixtureThermo(const fvMesh& mesh)
00108 :
00109     hReactionThermo(mesh),
00110     MixtureType(*this, mesh)
00111 {
00112     scalarField& hCells = h_.internalField();
00113     const scalarField& TCells = T_.internalField();
00114 
00115     forAll(hCells, celli)
00116     {
00117         hCells[celli] = this->cellMixture(celli).H(TCells[celli]);
00118     }
00119 
00120     forAll(h_.boundaryField(), patchi)
00121     {
00122         h_.boundaryField()[patchi] == h(T_.boundaryField()[patchi], patchi);
00123     }
00124 
00125     hBoundaryCorrection(h_);
00126 
00127     calculate();
00128 }
00129 
00130 
00131 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
00132 
00133 template<class MixtureType>
00134 Foam::hRhoMixtureThermo<MixtureType>::~hRhoMixtureThermo()
00135 {}
00136 
00137 
00138 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00139 
00140 template<class MixtureType>
00141 void Foam::hRhoMixtureThermo<MixtureType>::correct()
00142 {
00143     if (debug)
00144     {
00145         Info<< "entering hRhoMixtureThermo<MixtureType>::correct()" << endl;
00146     }
00147 
00148     calculate();
00149 
00150     if (debug)
00151     {
00152         Info<< "exiting hRhoMixtureThermo<MixtureType>::correct()" << endl;
00153     }
00154 }
00155 
00156 
00157 template<class MixtureType>
00158 Foam::tmp<Foam::volScalarField>
00159 Foam::hRhoMixtureThermo<MixtureType>::hs() const
00160 {
00161     const fvMesh& mesh = T_.mesh();
00162 
00163     tmp<volScalarField> ths
00164     (
00165         new volScalarField
00166         (
00167             IOobject
00168             (
00169                 "hs",
00170                 mesh.time().timeName(),
00171                 mesh,
00172                 IOobject::NO_READ,
00173                 IOobject::NO_WRITE
00174             ),
00175             mesh,
00176             h_.dimensions()
00177         )
00178     );
00179 
00180     volScalarField& hsf = ths();
00181     scalarField& hsCells = hsf.internalField();
00182     const scalarField& TCells = T_.internalField();
00183 
00184     forAll(TCells, celli)
00185     {
00186         hsCells[celli] = this->cellMixture(celli).Hs(TCells[celli]);
00187     }
00188 
00189     forAll(T_.boundaryField(), patchi)
00190     {
00191         scalarField& hsp = hsf.boundaryField()[patchi];
00192         const scalarField& Tp = T_.boundaryField()[patchi];
00193 
00194         forAll(Tp, facei)
00195         {
00196             hsp[facei] = this->patchFaceMixture(patchi, facei).Hs(Tp[facei]);
00197         }
00198     }
00199 
00200     return ths;
00201 }
00202 
00203 
00204 template<class MixtureType>
00205 Foam::tmp<Foam::volScalarField>
00206 Foam::hRhoMixtureThermo<MixtureType>::hc() const
00207 {
00208     const fvMesh& mesh = T_.mesh();
00209 
00210     tmp<volScalarField> thc
00211     (
00212         new volScalarField
00213         (
00214             IOobject
00215             (
00216                 "hc",
00217                 mesh.time().timeName(),
00218                 mesh,
00219                 IOobject::NO_READ,
00220                 IOobject::NO_WRITE
00221             ),
00222             mesh,
00223             h_.dimensions()
00224         )
00225     );
00226 
00227     volScalarField& hcf = thc();
00228     scalarField& hcCells = hcf.internalField();
00229 
00230     forAll(hcCells, celli)
00231     {
00232         hcCells[celli] = this->cellMixture(celli).Hc();
00233     }
00234 
00235     forAll(hcf.boundaryField(), patchi)
00236     {
00237         scalarField& hcp = hcf.boundaryField()[patchi];
00238 
00239         forAll(hcp, facei)
00240         {
00241             hcp[facei] = this->patchFaceMixture(patchi, facei).Hc();
00242         }
00243     }
00244 
00245     return thc;
00246 }
00247 
00248 
00249 template<class MixtureType>
00250 Foam::tmp<Foam::scalarField>
00251 Foam::hRhoMixtureThermo<MixtureType>::h
00252 (
00253     const scalarField& T,
00254     const labelList& cells
00255 ) const
00256 {
00257     tmp<scalarField> th(new scalarField(T.size()));
00258     scalarField& h = th();
00259 
00260     forAll(T, celli)
00261     {
00262         h[celli] = this->cellMixture(cells[celli]).H(T[celli]);
00263     }
00264 
00265     return th;
00266 }
00267 
00268 
00269 template<class MixtureType>
00270 Foam::tmp<Foam::scalarField>
00271 Foam::hRhoMixtureThermo<MixtureType>::h
00272 (
00273     const scalarField& T,
00274     const label patchi
00275 ) const
00276 {
00277     tmp<scalarField> th(new scalarField(T.size()));
00278     scalarField& h = th();
00279 
00280     forAll(T, facei)
00281     {
00282         h[facei] = this->patchFaceMixture(patchi, facei).H(T[facei]);
00283     }
00284 
00285     return th;
00286 }
00287 
00288 
00289 template<class MixtureType>
00290 Foam::tmp<Foam::scalarField>
00291 Foam::hRhoMixtureThermo<MixtureType>::Cp
00292 (
00293     const scalarField& T,
00294     const label patchi
00295 ) const
00296 {
00297     tmp<scalarField> tCp(new scalarField(T.size()));
00298 
00299     scalarField& cp = tCp();
00300 
00301     forAll(T, facei)
00302     {
00303         cp[facei] = this->patchFaceMixture(patchi, facei).Cp(T[facei]);
00304     }
00305 
00306     return tCp;
00307 }
00308 
00309 
00310 template<class MixtureType>
00311 Foam::tmp<Foam::volScalarField>
00312 Foam::hRhoMixtureThermo<MixtureType>::Cp() const
00313 {
00314     const fvMesh& mesh = T_.mesh();
00315 
00316     tmp<volScalarField> tCp
00317     (
00318         new volScalarField
00319         (
00320             IOobject
00321             (
00322                 "Cp",
00323                 mesh.time().timeName(),
00324                 mesh,
00325                 IOobject::NO_READ,
00326                 IOobject::NO_WRITE
00327             ),
00328             mesh,
00329             dimensionSet(0, 2, -2, -1, 0)
00330         )
00331     );
00332 
00333     volScalarField& cp = tCp();
00334 
00335     scalarField& cpCells = cp.internalField();
00336     const scalarField& TCells = T_.internalField();
00337 
00338     forAll(TCells, celli)
00339     {
00340         cpCells[celli] = this->cellMixture(celli).Cp(TCells[celli]);
00341     }
00342 
00343     forAll(T_.boundaryField(), patchi)
00344     {
00345         cp.boundaryField()[patchi] = Cp(T_.boundaryField()[patchi], patchi);
00346     }
00347 
00348     return tCp;
00349 }
00350 
00351 
00352 template<class MixtureType>
00353 bool Foam::hRhoMixtureThermo<MixtureType>::read()
00354 {
00355     if (hReactionThermo::read())
00356     {
00357         MixtureType::read(*this);
00358         return true;
00359     }
00360     else
00361     {
00362         return false;
00363     }
00364 }
00365 
00366 
00367 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd