FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

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