1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2004-2010 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
13 the Free Software Foundation, either version 3 of the License, or
14 (at your 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, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "twoPhaseMixture.H"
27 #include "addToRunTimeSelectionTable.H"
28 #include "surfaceFields.H"
32 // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
34 //- Calculate and return the laminar viscosity
35 void Foam::twoPhaseMixture::calcNu()
40 const volScalarField limitedAlpha1
43 min(max(alpha1_, scalar(0)), scalar(1))
46 // Average kinematic viscosity calculated from dynamic viscosity
47 nu_ = mu()/(limitedAlpha1*rho1_ + (scalar(1) - limitedAlpha1)*rho2_);
51 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
53 Foam::twoPhaseMixture::twoPhaseMixture
55 const volVectorField& U,
56 const surfaceScalarField& phi,
57 const word& alpha1Name
60 transportModel(U, phi),
62 phase1Name_("phase1"),
63 phase2Name_("phase2"),
86 rho1_(nuModel1_->viscosityProperties().lookup("rho")),
87 rho2_(nuModel2_->viscosityProperties().lookup("rho")),
92 alpha1_(U_.db().lookupObject<const volScalarField> (alpha1Name)),
103 dimensionedScalar("nu", dimensionSet(0, 2, -1, 0, 0), 0),
104 calculatedFvPatchScalarField::typeName
111 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
113 Foam::tmp<Foam::volScalarField> Foam::twoPhaseMixture::mu() const
115 const volScalarField limitedAlpha1
117 min(max(alpha1_, scalar(0)), scalar(1))
120 return tmp<volScalarField>
125 limitedAlpha1*rho1_*nuModel1_->nu()
126 + (scalar(1) - limitedAlpha1)*rho2_*nuModel2_->nu()
132 Foam::tmp<Foam::surfaceScalarField> Foam::twoPhaseMixture::muf() const
134 const surfaceScalarField alpha1f
136 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 Foam::tmp<Foam::surfaceScalarField> Foam::twoPhaseMixture::nuf() const
153 const surfaceScalarField alpha1f
155 min(max(fvc::interpolate(alpha1_), scalar(0)), scalar(1))
158 return tmp<surfaceScalarField>
160 new surfaceScalarField
164 alpha1f*rho1_*fvc::interpolate(nuModel1_->nu())
165 + (scalar(1) - alpha1f)*rho2_*fvc::interpolate(nuModel2_->nu())
166 )/(alpha1f*rho1_ + (scalar(1) - alpha1f)*rho2_)
172 bool Foam::twoPhaseMixture::read()
174 if (transportModel::read())
178 nuModel1_().read(subDict(phase1Name_))
179 && nuModel2_().read(subDict(phase2Name_))
182 nuModel1_->viscosityProperties().lookup("rho") >> rho1_;
183 nuModel2_->viscosityProperties().lookup("rho") >> rho2_;
199 // ************************************************************************* //