Merge branch 'master' of ssh://opencfd@repo.or.cz/srv/git/OpenFOAM-1.5.x
[OpenFOAM-1.5.x.git] / src / transportModels / incompressible / incompressibleTwoPhaseMixture / twoPhaseMixture.C
blobef1d0f89d210e05897204241e2718a1d084bf900
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2008 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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
19     for more details.
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"
30 #include "fvc.H"
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34 namespace Foam
37 // * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * * //
39 //- Calculate and return the laminar viscosity
40 void twoPhaseMixture::calcNu()
42     nuModel1_->correct();
43     nuModel2_->correct();
45     volScalarField limitedAlpha1
46     (
47         "limitedAlpha1",
48         min(max(alpha1_, scalar(0)), scalar(1))
49     );
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"),
70     nuModel1_
71     (
72         viscosityModel::New
73         (
74             "nu1",
75             subDict(phase1Name_),
76             U,
77             phi
78         )
79     ),
80     nuModel2_
81     (
82         viscosityModel::New
83         (
84             "nu2",
85             subDict(phase2Name_),
86             U,
87             phi
88         )
89     ),
91     rho1_(nuModel1_->viscosityProperties().lookup("rho")),
92     rho2_(nuModel2_->viscosityProperties().lookup("rho")),
94     U_(U),
95     phi_(phi),
97     alpha1_(U_.db().lookupObject<const volScalarField> (alpha1Name)),
99     nu_
100     (
101         IOobject
102         (
103             "nu",
104             U_.time().timeName(),
105             U_.db()
106         ),
107         U_.mesh(),
108         dimensionedScalar("nu", dimensionSet(0, 2, -1, 0, 0), 0),
109         calculatedFvPatchScalarField::typeName
110     )
112     calcNu();
116 // * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * * //
118 tmp<volScalarField> twoPhaseMixture::mu() const
120     volScalarField limitedAlpha1 = min(max(alpha1_, scalar(0)), scalar(1));
122     return tmp<volScalarField>
123     (
124         new volScalarField
125         (
126             "mu",
127             limitedAlpha1*rho1_*nuModel1_->nu()
128           + (scalar(1) - limitedAlpha1)*rho2_*nuModel2_->nu()
129         )
130     );
134 tmp<surfaceScalarField> twoPhaseMixture::muf() const
136     surfaceScalarField alpha1f =
137         min(max(fvc::interpolate(alpha1_), scalar(0)), scalar(1));
139     return tmp<surfaceScalarField>
140     (
141         new surfaceScalarField
142         (
143             "muf",
144             alpha1f*rho1_*fvc::interpolate(nuModel1_->nu())
145           + (scalar(1) - alpha1f)*rho2_*fvc::interpolate(nuModel2_->nu())
146         )
147     );
151 tmp<surfaceScalarField> twoPhaseMixture::nuf() const
153     surfaceScalarField alpha1f =
154         min(max(fvc::interpolate(alpha1_), scalar(0)), scalar(1));
156     return tmp<surfaceScalarField>
157     (
158         new surfaceScalarField
159         (
160             "nuf",
161             (
162                 alpha1f*rho1_*fvc::interpolate(nuModel1_->nu())
163               + (scalar(1) - alpha1f)*rho2_*fvc::interpolate(nuModel2_->nu())
164             )/(alpha1f*rho1_ + (scalar(1) - alpha1f)*rho2_)
165         )
166     );
170 bool twoPhaseMixture::read()
172     if (transportModel::read())
173     {
174         if
175         (
176             nuModel1_().read(subDict(phase1Name_))
177          && nuModel2_().read(subDict(phase2Name_))
178         )
179         {
180             nuModel1_->viscosityProperties().lookup("rho") >> rho1_;
181             nuModel2_->viscosityProperties().lookup("rho") >> rho2_;
183             return true;
184         }
185         else
186         {
187             return false;
188         }
189     }
190     else
191     {
192         return false;
193     }
197 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
199 } // End namespace Foam
201 // ************************************************************************* //