OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

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