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

hRhoThermo.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) 1991-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 "hRhoThermo.H"
00028 
00029 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
00030 
00031 template<class MixtureType>
00032 void Foam::hRhoThermo<MixtureType>::calculate()
00033 {
00034     const scalarField& hCells = this->h_.internalField();
00035     const scalarField& pCells = this->p_.internalField();
00036 
00037     scalarField& TCells = this->T_.internalField();
00038     scalarField& psiCells = this->psi_.internalField();
00039     scalarField& rhoCells = this->rho_.internalField();
00040     scalarField& muCells = this->mu_.internalField();
00041     scalarField& alphaCells = this->alpha_.internalField();
00042 
00043     forAll(TCells, celli)
00044     {
00045         const typename MixtureType::thermoType& mixture_ =
00046             this->cellMixture(celli);
00047 
00048         TCells[celli] = mixture_.TH(hCells[celli], TCells[celli]);
00049         psiCells[celli] = mixture_.psi(pCells[celli], TCells[celli]);
00050         rhoCells[celli] = mixture_.rho(pCells[celli], TCells[celli]);
00051 
00052         muCells[celli] = mixture_.mu(TCells[celli]);
00053         alphaCells[celli] = mixture_.alpha(TCells[celli]);
00054     }
00055 
00056     forAll(this->T_.boundaryField(), patchi)
00057     {
00058         fvPatchScalarField& pp = this->p_.boundaryField()[patchi];
00059         fvPatchScalarField& pT = this->T_.boundaryField()[patchi];
00060         fvPatchScalarField& ppsi = this->psi_.boundaryField()[patchi];
00061         fvPatchScalarField& prho = this->rho_.boundaryField()[patchi];
00062 
00063         fvPatchScalarField& ph = this->h_.boundaryField()[patchi];
00064 
00065         fvPatchScalarField& pmu = this->mu_.boundaryField()[patchi];
00066         fvPatchScalarField& palpha = this->alpha_.boundaryField()[patchi];
00067 
00068         if (pT.fixesValue())
00069         {
00070             forAll(pT, facei)
00071             {
00072                 const typename MixtureType::thermoType& mixture_ =
00073                     this->patchFaceMixture(patchi, facei);
00074 
00075                 ph[facei] = mixture_.H(pT[facei]);
00076 
00077                 ppsi[facei] = mixture_.psi(pp[facei], pT[facei]);
00078                 prho[facei] = mixture_.rho(pp[facei], pT[facei]);
00079                 pmu[facei] = mixture_.mu(pT[facei]);
00080                 palpha[facei] = mixture_.alpha(pT[facei]);
00081             }
00082         }
00083         else
00084         {
00085             forAll(pT, facei)
00086             {
00087                 const typename MixtureType::thermoType& mixture_ =
00088                     this->patchFaceMixture(patchi, facei);
00089 
00090                 pT[facei] = mixture_.TH(ph[facei], pT[facei]);
00091 
00092                 ppsi[facei] = mixture_.psi(pp[facei], pT[facei]);
00093                 prho[facei] = mixture_.rho(pp[facei], pT[facei]);
00094                 pmu[facei] = mixture_.mu(pT[facei]);
00095                 palpha[facei] = mixture_.alpha(pT[facei]);
00096             }
00097         }
00098     }
00099 }
00100 
00101 
00102 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00103 
00104 template<class MixtureType>
00105 Foam::hRhoThermo<MixtureType>::hRhoThermo(const fvMesh& mesh)
00106 :
00107     basicRhoThermo(mesh),
00108     MixtureType(*this, mesh),
00109 
00110     h_
00111     (
00112         IOobject
00113         (
00114             "h",
00115             mesh.time().timeName(),
00116             mesh,
00117             IOobject::NO_READ,
00118             IOobject::NO_WRITE
00119         ),
00120         mesh,
00121         dimensionSet(0, 2, -2, 0, 0),
00122         this->hBoundaryTypes()
00123     )
00124 {
00125     scalarField& hCells = h_.internalField();
00126     const scalarField& TCells = this->T_.internalField();
00127 
00128     forAll(hCells, celli)
00129     {
00130         hCells[celli] = this->cellMixture(celli).H(TCells[celli]);
00131     }
00132 
00133     forAll(h_.boundaryField(), patchi)
00134     {
00135         h_.boundaryField()[patchi] ==
00136             h(this->T_.boundaryField()[patchi], patchi);
00137     }
00138 
00139     hBoundaryCorrection(h_);
00140 
00141     calculate();
00142 }
00143 
00144 
00145 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
00146 
00147 template<class MixtureType>
00148 Foam::hRhoThermo<MixtureType>::~hRhoThermo()
00149 {}
00150 
00151 
00152 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00153 
00154 template<class MixtureType>
00155 void Foam::hRhoThermo<MixtureType>::correct()
00156 {
00157     if (debug)
00158     {
00159         Info<< "entering hRhoThermo<MixtureType>::correct()" << endl;
00160     }
00161 
00162     calculate();
00163 
00164     if (debug)
00165     {
00166         Info<< "exiting hRhoThermo<MixtureType>::correct()" << endl;
00167     }
00168 }
00169 
00170 
00171 template<class MixtureType>
00172 Foam::tmp<Foam::scalarField> Foam::hRhoThermo<MixtureType>::h
00173 (
00174     const scalarField& T,
00175     const labelList& cells
00176 ) const
00177 {
00178     tmp<scalarField> th(new scalarField(T.size()));
00179     scalarField& h = th();
00180 
00181     forAll(T, celli)
00182     {
00183         h[celli] = this->cellMixture(cells[celli]).H(T[celli]);
00184     }
00185 
00186     return th;
00187 }
00188 
00189 
00190 template<class MixtureType>
00191 Foam::tmp<Foam::scalarField> Foam::hRhoThermo<MixtureType>::h
00192 (
00193     const scalarField& T,
00194     const label patchi
00195 ) const
00196 {
00197     tmp<scalarField> th(new scalarField(T.size()));
00198     scalarField& h = th();
00199 
00200     forAll(T, facei)
00201     {
00202         h[facei] = this->patchFaceMixture(patchi, facei).H(T[facei]);
00203     }
00204 
00205     return th;
00206 }
00207 
00208 
00209 template<class MixtureType>
00210 Foam::tmp<Foam::scalarField> Foam::hRhoThermo<MixtureType>::Cp
00211 (
00212     const scalarField& T,
00213     const label patchi
00214 ) const
00215 {
00216     tmp<scalarField> tCp(new scalarField(T.size()));
00217     scalarField& cp = tCp();
00218 
00219     forAll(T, facei)
00220     {
00221         cp[facei] = this->patchFaceMixture(patchi, facei).Cp(T[facei]);
00222     }
00223 
00224     return tCp;
00225 }
00226 
00227 
00228 template<class MixtureType>
00229 Foam::tmp<Foam::volScalarField> Foam::hRhoThermo<MixtureType>::Cp() const
00230 {
00231     const fvMesh& mesh = this->T_.mesh();
00232 
00233     tmp<volScalarField> tCp
00234     (
00235         new volScalarField
00236         (
00237             IOobject
00238             (
00239                 "Cp",
00240                 mesh.time().timeName(),
00241                 mesh,
00242                 IOobject::NO_READ,
00243                 IOobject::NO_WRITE
00244             ),
00245             mesh,
00246             dimensionSet(0, 2, -2, -1, 0),
00247             this->T_.boundaryField().types()
00248         )
00249     );
00250 
00251     volScalarField& cp = tCp();
00252 
00253     forAll(this->T_, celli)
00254     {
00255         cp[celli] = this->cellMixture(celli).Cp(this->T_[celli]);
00256     }
00257 
00258     forAll(this->T_.boundaryField(), patchi)
00259     {
00260         const fvPatchScalarField& pT = this->T_.boundaryField()[patchi];
00261         fvPatchScalarField& pCp = cp.boundaryField()[patchi];
00262 
00263         forAll(pT, facei)
00264         {
00265             pCp[facei] = this->patchFaceMixture(patchi, facei).Cp(pT[facei]);
00266         }
00267     }
00268 
00269     return tCp;
00270 }
00271 
00272 
00273 template<class MixtureType>
00274 Foam::tmp<Foam::scalarField> Foam::hRhoThermo<MixtureType>::Cv
00275 (
00276     const scalarField& T,
00277     const label patchi
00278 ) const
00279 {
00280     tmp<scalarField> tCv(new scalarField(T.size()));
00281     scalarField& cv = tCv();
00282 
00283     forAll(T, facei)
00284     {
00285         cv[facei] = this->patchFaceMixture(patchi, facei).Cv(T[facei]);
00286     }
00287 
00288     return tCv;
00289 }
00290 
00291 
00292 template<class MixtureType>
00293 Foam::tmp<Foam::volScalarField> Foam::hRhoThermo<MixtureType>::Cv() const
00294 {
00295     const fvMesh& mesh = this->T_.mesh();
00296 
00297     tmp<volScalarField> tCv
00298     (
00299         new volScalarField
00300         (
00301             IOobject
00302             (
00303                 "Cv",
00304                 mesh.time().timeName(),
00305                 mesh,
00306                 IOobject::NO_READ,
00307                 IOobject::NO_WRITE
00308             ),
00309             mesh,
00310             dimensionSet(0, 2, -2, -1, 0)
00311         )
00312     );
00313 
00314     volScalarField& cv = tCv();
00315 
00316     forAll(this->T_, celli)
00317     {
00318         cv[celli] = this->cellMixture(celli).Cv(this->T_[celli]);
00319     }
00320 
00321     forAll(this->T_.boundaryField(), patchi)
00322     {
00323         cv.boundaryField()[patchi] =
00324             Cv(this->T_.boundaryField()[patchi], patchi);
00325     }
00326 
00327     return tCv;
00328 }
00329 
00330 
00331 template<class MixtureType>
00332 bool Foam::hRhoThermo<MixtureType>::read()
00333 {
00334     if (basicRhoThermo::read())
00335     {
00336         MixtureType::read(*this);
00337         return true;
00338     }
00339     else
00340     {
00341         return false;
00342     }
00343 }
00344 
00345 
00346 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd