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

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