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

threePhaseMixture.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-2011 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     Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
00024 
00025 \*---------------------------------------------------------------------------*/
00026 
00027 #include "threePhaseMixture.H"
00028 #include <OpenFOAM/addToRunTimeSelectionTable.H>
00029 #include <finiteVolume/surfaceFields.H>
00030 #include <finiteVolume/fvc.H>
00031 
00032 // * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * * //
00033 
00034 //- Calculate and return the laminar viscosity
00035 void Foam::threePhaseMixture::calcNu()
00036 {
00037     nuModel1_->correct();
00038     nuModel2_->correct();
00039     nuModel3_->correct();
00040 
00041     // Average kinematic viscosity calculated from dynamic viscosity
00042     nu_ = mu()/(alpha1_*rho1_ + alpha2_*rho2_ + alpha3_*rho3_);
00043 }
00044 
00045 
00046 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00047 
00048 Foam::threePhaseMixture::threePhaseMixture
00049 (
00050     const volVectorField& U,
00051     const surfaceScalarField& phi
00052 )
00053 :
00054     transportModel(U, phi),
00055 
00056     phase1Name_("phase1"),
00057     phase2Name_("phase2"),
00058     phase3Name_("phase3"),
00059 
00060     nuModel1_
00061     (
00062         viscosityModel::New
00063         (
00064             "nu1",
00065             subDict(phase1Name_),
00066             U,
00067             phi
00068         )
00069     ),
00070     nuModel2_
00071     (
00072         viscosityModel::New
00073         (
00074             "nu2",
00075             subDict(phase2Name_),
00076             U,
00077             phi
00078         )
00079     ),
00080     nuModel3_
00081     (
00082         viscosityModel::New
00083         (
00084             "nu3",
00085             subDict(phase3Name_),
00086             U,
00087             phi
00088         )
00089     ),
00090 
00091     rho1_(nuModel1_->viscosityProperties().lookup("rho")),
00092     rho2_(nuModel2_->viscosityProperties().lookup("rho")),
00093     rho3_(nuModel3_->viscosityProperties().lookup("rho")),
00094 
00095     U_(U),
00096     phi_(phi),
00097 
00098     alpha1_(U_.db().lookupObject<const volScalarField> ("alpha1")),
00099     alpha2_(U_.db().lookupObject<const volScalarField> ("alpha2")),
00100     alpha3_(U_.db().lookupObject<const volScalarField> ("alpha3")),
00101 
00102     nu_
00103     (
00104         IOobject
00105         (
00106             "nu",
00107             U_.time().timeName(),
00108             U_.db()
00109         ),
00110         U_.mesh(),
00111         dimensionedScalar("nu", dimensionSet(0, 2, -1, 0, 0), 0),
00112         calculatedFvPatchScalarField::typeName
00113     )
00114 {
00115     calcNu();
00116 }
00117 
00118 
00119 // * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * * //
00120 
00121 Foam::tmp<Foam::volScalarField> Foam::threePhaseMixture::mu() const
00122 {
00123     return tmp<volScalarField>
00124     (
00125         new volScalarField
00126         (
00127             "mu",
00128             alpha1_*rho1_*nuModel1_->nu()
00129           + alpha2_*rho2_*nuModel2_->nu()
00130           + alpha3_*rho3_*nuModel3_->nu()
00131         )
00132     );
00133 }
00134 
00135 
00136 Foam::tmp<Foam::surfaceScalarField> Foam::threePhaseMixture::muf() const
00137 {
00138     surfaceScalarField alpha1f = fvc::interpolate(alpha1_);
00139     surfaceScalarField alpha2f = fvc::interpolate(alpha2_);
00140     surfaceScalarField alpha3f = fvc::interpolate(alpha3_);
00141 
00142     return tmp<surfaceScalarField>
00143     (
00144         new surfaceScalarField
00145         (
00146             "mu",
00147             alpha1f*rho1_*fvc::interpolate(nuModel1_->nu())
00148           + alpha2f*rho2_*fvc::interpolate(nuModel2_->nu())
00149           + alpha3f*rho3_*fvc::interpolate(nuModel3_->nu())
00150         )
00151     );
00152 }
00153 
00154 
00155 Foam::tmp<Foam::surfaceScalarField> Foam::threePhaseMixture::nuf() const
00156 {
00157     surfaceScalarField alpha1f = fvc::interpolate(alpha1_);
00158     surfaceScalarField alpha2f = fvc::interpolate(alpha2_);
00159     surfaceScalarField alpha3f = fvc::interpolate(alpha3_);
00160 
00161     return tmp<surfaceScalarField>
00162     (
00163         new surfaceScalarField
00164         (
00165             "nu",
00166             (
00167                 alpha1f*rho1_*fvc::interpolate(nuModel1_->nu())
00168               + alpha2f*rho2_*fvc::interpolate(nuModel2_->nu())
00169               + alpha3f*rho3_*fvc::interpolate(nuModel3_->nu())
00170             )/(alpha1f*rho1_ + alpha2f*rho2_ + alpha3f*rho3_)
00171         )
00172     );
00173 }
00174 
00175 
00176 bool Foam::threePhaseMixture::read()
00177 {
00178     if (transportModel::read())
00179     {
00180         if
00181         (
00182             nuModel1_().read(*this)
00183          && nuModel2_().read(*this)
00184          && nuModel3_().read(*this)
00185         )
00186         {
00187             nuModel1_->viscosityProperties().lookup("rho") >> rho1_;
00188             nuModel2_->viscosityProperties().lookup("rho") >> rho2_;
00189             nuModel3_->viscosityProperties().lookup("rho") >> rho3_;
00190 
00191             return true;
00192         }
00193         else
00194         {
00195             return false;
00196         }
00197     }
00198     else
00199     {
00200         return false;
00201     }
00202 }
00203 
00204 
00205 // ************************************************************************* //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines