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

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