1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software; you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include "twoPhaseMixture.H"
28 #include "addToRunTimeSelectionTable.H"
29 #include "surfaceFields.H"
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
37 // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
39 //- Calculate and return the laminar viscosity
40 void twoPhaseMixture::calcNu()
45 volScalarField limitedAlpha1
48 min(max(alpha1_, scalar(0)), scalar(1))
51 // Average kinematic viscosity calculated from dynamic viscosity
52 nu_ = mu()/(limitedAlpha1*rho1_ + (scalar(1) - limitedAlpha1)*rho2_);
56 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
58 twoPhaseMixture::twoPhaseMixture
60 const volVectorField& U,
61 const surfaceScalarField& phi,
62 const word& alpha1Name
65 transportModel(U, phi),
67 phase1Name_("phase1"),
68 phase2Name_("phase2"),
91 rho1_(nuModel1_->viscosityProperties().lookup("rho")),
92 rho2_(nuModel2_->viscosityProperties().lookup("rho")),
97 alpha1_(U_.db().lookupObject<const volScalarField> (alpha1Name)),
104 U_.time().timeName(),
108 dimensionedScalar("nu", dimensionSet(0, 2, -1, 0, 0), 0),
109 calculatedFvPatchScalarField::typeName
116 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
118 tmp<volScalarField> twoPhaseMixture::mu() const
120 volScalarField limitedAlpha1 = min(max(alpha1_, scalar(0)), scalar(1));
122 return tmp<volScalarField>
127 limitedAlpha1*rho1_*nuModel1_->nu()
128 + (scalar(1) - limitedAlpha1)*rho2_*nuModel2_->nu()
134 tmp<surfaceScalarField> twoPhaseMixture::muf() const
136 surfaceScalarField alpha1f =
137 min(max(fvc::interpolate(alpha1_), scalar(0)), scalar(1));
139 return tmp<surfaceScalarField>
141 new surfaceScalarField
144 alpha1f*rho1_*fvc::interpolate(nuModel1_->nu())
145 + (scalar(1) - alpha1f)*rho2_*fvc::interpolate(nuModel2_->nu())
151 tmp<surfaceScalarField> twoPhaseMixture::nuf() const
153 surfaceScalarField alpha1f =
154 min(max(fvc::interpolate(alpha1_), scalar(0)), scalar(1));
156 return tmp<surfaceScalarField>
158 new surfaceScalarField
162 alpha1f*rho1_*fvc::interpolate(nuModel1_->nu())
163 + (scalar(1) - alpha1f)*rho2_*fvc::interpolate(nuModel2_->nu())
164 )/(alpha1f*rho1_ + (scalar(1) - alpha1f)*rho2_)
170 bool twoPhaseMixture::read()
172 if (transportModel::read())
176 nuModel1_().read(subDict(phase1Name_))
177 && nuModel2_().read(subDict(phase2Name_))
180 nuModel1_->viscosityProperties().lookup("rho") >> rho1_;
181 nuModel2_->viscosityProperties().lookup("rho") >> rho2_;
197 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
199 } // End namespace Foam
201 // ************************************************************************* //