1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend 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 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "twoPhaseMixture.H"
27 #include "addToRunTimeSelectionTable.H"
28 #include "surfaceFields.H"
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
36 // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
38 //- Calculate and return the laminar viscosity
39 word twoPhaseMixture::getPhaseName(const word& key) const
47 return word(lookup(key));
51 void twoPhaseMixture::calcNu()
56 volScalarField limitedAlpha1
59 min(max(alpha1_, scalar(0)), scalar(1))
62 // Average kinematic viscosity calculated from dynamic viscosity
63 nu_ = mu()/(limitedAlpha1*rho1_ + (scalar(1) - limitedAlpha1)*rho2_);
67 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
69 twoPhaseMixture::twoPhaseMixture
71 const volVectorField& U,
72 const surfaceScalarField& phi,
73 const word& alpha1Name
76 transportModel(U, phi),
78 phase1Name_(getPhaseName("phase1")),
79 phase2Name_(getPhaseName("phase2")),
102 rho1_(nuModel1_->viscosityProperties().lookup("rho")),
103 rho2_(nuModel2_->viscosityProperties().lookup("rho")),
108 alpha1_(U_.db().lookupObject<const volScalarField> (alpha1Name)),
115 U_.time().timeName(),
119 dimensionedScalar("nu", dimensionSet(0, 2, -1, 0, 0), 0),
120 calculatedFvPatchScalarField::typeName
127 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
129 tmp<volScalarField> twoPhaseMixture::rho() const
131 volScalarField limitedAlpha1 = min(max(alpha1_, scalar(0)), scalar(1));
133 return tmp<volScalarField>
137 "rho_twoPhaseMixture",
139 + (scalar(1) - limitedAlpha1)*rho2_
145 tmp<volScalarField> twoPhaseMixture::mu() const
147 volScalarField limitedAlpha1 = min(max(alpha1_, scalar(0)), scalar(1));
149 return tmp<volScalarField>
153 "mu_twoPhaseMixture",
154 limitedAlpha1*rho1_*nuModel1_->nu()
155 + (scalar(1) - limitedAlpha1)*rho2_*nuModel2_->nu()
161 tmp<surfaceScalarField> twoPhaseMixture::muf() const
163 surfaceScalarField alpha1f =
164 min(max(fvc::interpolate(alpha1_), scalar(0)), scalar(1));
166 return tmp<surfaceScalarField>
168 new surfaceScalarField
170 "muf_twoPhaseMixture",
171 alpha1f*rho1_*fvc::interpolate(nuModel1_->nu())
172 + (scalar(1) - alpha1f)*rho2_*fvc::interpolate(nuModel2_->nu())
178 tmp<surfaceScalarField> twoPhaseMixture::nuf() const
180 surfaceScalarField alpha1f =
181 min(max(fvc::interpolate(alpha1_), scalar(0)), scalar(1));
183 return tmp<surfaceScalarField>
185 new surfaceScalarField
187 "nuf_twoPhaseMixture",
189 alpha1f*rho1_*fvc::interpolate(nuModel1_->nu())
190 + (scalar(1) - alpha1f)*rho2_*fvc::interpolate(nuModel2_->nu())
191 )/(alpha1f*rho1_ + (scalar(1) - alpha1f)*rho2_)
197 bool twoPhaseMixture::read()
199 if (transportModel::read())
203 nuModel1_().read(subDict(phase1Name_))
204 && nuModel2_().read(subDict(phase2Name_))
207 nuModel1_->viscosityProperties().lookup("rho") >> rho1_;
208 nuModel2_->viscosityProperties().lookup("rho") >> rho2_;
224 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
226 } // End namespace Foam
228 // ************************************************************************* //