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

hsPsiMixtureThermo.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 "hsPsiMixtureThermo.H"
00027 #include <finiteVolume/fvMesh.H>
00028 #include <finiteVolume/fixedValueFvPatchFields.H>
00029 
00030 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00031 
00032 template<class MixtureType>
00033 Foam::hsPsiMixtureThermo<MixtureType>::hsPsiMixtureThermo(const fvMesh& mesh)
00034 :
00035     hsCombustionThermo(mesh),
00036     MixtureType(*this, mesh)
00037 {
00038     scalarField& hCells = hs_.internalField();
00039     const scalarField& TCells = T_.internalField();
00040 
00041     forAll(hCells, celli)
00042     {
00043         hCells[celli] = this->cellMixture(celli).Hs(TCells[celli]);
00044     }
00045 
00046     forAll(hs_.boundaryField(), patchi)
00047     {
00048         hs_.boundaryField()[patchi] == hs(T_.boundaryField()[patchi], patchi);
00049     }
00050 
00051     hBoundaryCorrection(hs_);
00052 
00053     calculate();
00054     psi_.oldTime();   // Switch on saving old time
00055 }
00056 
00057 
00058 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
00059 
00060 template<class MixtureType>
00061 Foam::hsPsiMixtureThermo<MixtureType>::~hsPsiMixtureThermo()
00062 {}
00063 
00064 
00065 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
00066 
00067 template<class MixtureType>
00068 void Foam::hsPsiMixtureThermo<MixtureType>::calculate()
00069 {
00070     const scalarField& hsCells = hs_.internalField();
00071     const scalarField& pCells = p_.internalField();
00072 
00073     scalarField& TCells = T_.internalField();
00074     scalarField& psiCells = psi_.internalField();
00075     scalarField& muCells = mu_.internalField();
00076     scalarField& alphaCells = alpha_.internalField();
00077 
00078     forAll(TCells, celli)
00079     {
00080         const typename MixtureType::thermoType& mixture_ =
00081             this->cellMixture(celli);
00082 
00083         TCells[celli] = mixture_.THs(hsCells[celli], TCells[celli]);
00084         psiCells[celli] = mixture_.psi(pCells[celli], TCells[celli]);
00085 
00086         muCells[celli] = mixture_.mu(TCells[celli]);
00087         alphaCells[celli] = mixture_.alpha(TCells[celli]);
00088     }
00089 
00090     forAll(T_.boundaryField(), patchi)
00091     {
00092         fvPatchScalarField& pp = p_.boundaryField()[patchi];
00093         fvPatchScalarField& pT = T_.boundaryField()[patchi];
00094         fvPatchScalarField& ppsi = psi_.boundaryField()[patchi];
00095 
00096         fvPatchScalarField& phs = hs_.boundaryField()[patchi];
00097 
00098         fvPatchScalarField& pmu_ = mu_.boundaryField()[patchi];
00099         fvPatchScalarField& palpha_ = alpha_.boundaryField()[patchi];
00100 
00101         if (pT.fixesValue())
00102         {
00103             forAll(pT, facei)
00104             {
00105                 const typename MixtureType::thermoType& mixture_ =
00106                     this->patchFaceMixture(patchi, facei);
00107 
00108                 phs[facei] = mixture_.Hs(pT[facei]);
00109 
00110                 ppsi[facei] = mixture_.psi(pp[facei], pT[facei]);
00111                 pmu_[facei] = mixture_.mu(pT[facei]);
00112                 palpha_[facei] = mixture_.alpha(pT[facei]);
00113             }
00114         }
00115         else
00116         {
00117             forAll(pT, facei)
00118             {
00119                 const typename MixtureType::thermoType& mixture_ =
00120                     this->patchFaceMixture(patchi, facei);
00121 
00122                 pT[facei] = mixture_.THs(phs[facei], pT[facei]);
00123 
00124                 ppsi[facei] = mixture_.psi(pp[facei], pT[facei]);
00125                 pmu_[facei] = mixture_.mu(pT[facei]);
00126                 palpha_[facei] = mixture_.alpha(pT[facei]);
00127             }
00128         }
00129     }
00130 }
00131 
00132 
00133 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00134 
00135 template<class MixtureType>
00136 void Foam::hsPsiMixtureThermo<MixtureType>::correct()
00137 {
00138     if (debug)
00139     {
00140         Info<< "entering hMixtureThermo<MixtureType>::correct()" << endl;
00141     }
00142 
00143     // force the saving of the old-time values
00144     psi_.oldTime();
00145 
00146     calculate();
00147 
00148     if (debug)
00149     {
00150         Info<< "exiting hMixtureThermo<MixtureType>::correct()" << endl;
00151     }
00152 }
00153 
00154 template<class MixtureType>
00155 Foam::tmp<Foam::volScalarField>
00156 Foam::hsPsiMixtureThermo<MixtureType>::hc() const
00157 {
00158     const fvMesh& mesh = T_.mesh();
00159 
00160     tmp<volScalarField> thc
00161     (
00162         new volScalarField
00163         (
00164             IOobject
00165             (
00166                 "hc",
00167                 mesh.time().timeName(),
00168                 mesh,
00169                 IOobject::NO_READ,
00170                 IOobject::NO_WRITE
00171             ),
00172             mesh,
00173             hs_.dimensions()
00174         )
00175     );
00176 
00177     volScalarField& hcf = thc();
00178     scalarField& hcCells = hcf.internalField();
00179 
00180     forAll(hcCells, celli)
00181     {
00182         hcCells[celli] = this->cellMixture(celli).Hc();
00183     }
00184 
00185     forAll(hcf.boundaryField(), patchi)
00186     {
00187         scalarField& hcp = hcf.boundaryField()[patchi];
00188 
00189         forAll(hcp, facei)
00190         {
00191             hcp[facei] = this->patchFaceMixture(patchi, facei).Hc();
00192         }
00193     }
00194 
00195     return thc;
00196 }
00197 
00198 
00199 template<class MixtureType>
00200 Foam::tmp<Foam::scalarField>
00201 Foam::hsPsiMixtureThermo<MixtureType>::hs
00202 (
00203     const scalarField& T,
00204     const labelList& cells
00205 ) const
00206 {
00207     tmp<scalarField> ths(new scalarField(T.size()));
00208     scalarField& hs = ths();
00209 
00210     forAll(T, celli)
00211     {
00212         hs[celli] = this->cellMixture(cells[celli]).Hs(T[celli]);
00213     }
00214 
00215     return ths;
00216 }
00217 
00218 
00219 template<class MixtureType>
00220 Foam::tmp<Foam::scalarField>
00221 Foam::hsPsiMixtureThermo<MixtureType>::hs
00222 (
00223     const scalarField& T,
00224     const label patchi
00225 ) const
00226 {
00227     tmp<scalarField> ths(new scalarField(T.size()));
00228     scalarField& hs = ths();
00229 
00230     forAll(T, facei)
00231     {
00232         hs[facei] = this->patchFaceMixture(patchi, facei).Hs(T[facei]);
00233     }
00234 
00235     return ths;
00236 }
00237 
00238 
00239 template<class MixtureType>
00240 Foam::tmp<Foam::scalarField>
00241 Foam::hsPsiMixtureThermo<MixtureType>::Cp
00242 (
00243     const scalarField& T,
00244     const label patchi
00245 ) const
00246 {
00247     tmp<scalarField> tCp(new scalarField(T.size()));
00248 
00249     scalarField& cp = tCp();
00250 
00251     forAll(T, facei)
00252     {
00253         cp[facei] = this->patchFaceMixture(patchi, facei).Cp(T[facei]);
00254     }
00255 
00256     return tCp;
00257 }
00258 
00259 
00260 template<class MixtureType>
00261 Foam::tmp<Foam::volScalarField>
00262 Foam::hsPsiMixtureThermo<MixtureType>::Cp() const
00263 {
00264     const fvMesh& mesh = T_.mesh();
00265 
00266     tmp<volScalarField> tCp
00267     (
00268         new volScalarField
00269         (
00270             IOobject
00271             (
00272                 "Cp",
00273                 mesh.time().timeName(),
00274                 mesh,
00275                 IOobject::NO_READ,
00276                 IOobject::NO_WRITE
00277             ),
00278             mesh,
00279             dimEnergy/dimMass/dimTemperature
00280         )
00281     );
00282 
00283     volScalarField& cp = tCp();
00284 
00285     scalarField& cpCells = cp.internalField();
00286     const scalarField& TCells = T_.internalField();
00287 
00288     forAll(TCells, celli)
00289     {
00290         cpCells[celli] = this->cellMixture(celli).Cp(TCells[celli]);
00291     }
00292 
00293     forAll(T_.boundaryField(), patchi)
00294     {
00295         cp.boundaryField()[patchi] = Cp(T_.boundaryField()[patchi], patchi);
00296     }
00297 
00298     return tCp;
00299 }
00300 
00301 
00302 template<class MixtureType>
00303 bool Foam::hsPsiMixtureThermo<MixtureType>::read()
00304 {
00305     if (hsCombustionThermo::read())
00306     {
00307         MixtureType::read(*this);
00308         return true;
00309     }
00310     else
00311     {
00312         return false;
00313     }
00314 }
00315 
00316 
00317 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines