Initial commit for version 2.0.x patch release
[OpenFOAM-2.0.x.git] / src / transportModels / incompressible / incompressibleTwoPhaseMixture / twoPhaseMixture.C
blob48143dd5c309c504a8cbe24844ea27029d04fc5c
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2004-2010 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
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
19     for more details.
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"
29 #include "fvc.H"
32 // * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * * //
34 //- Calculate and return the laminar viscosity
35 void Foam::twoPhaseMixture::calcNu()
37     nuModel1_->correct();
38     nuModel2_->correct();
40     const volScalarField limitedAlpha1
41     (
42         "limitedAlpha1",
43         min(max(alpha1_, scalar(0)), scalar(1))
44     );
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"),
65     nuModel1_
66     (
67         viscosityModel::New
68         (
69             "nu1",
70             subDict(phase1Name_),
71             U,
72             phi
73         )
74     ),
75     nuModel2_
76     (
77         viscosityModel::New
78         (
79             "nu2",
80             subDict(phase2Name_),
81             U,
82             phi
83         )
84     ),
86     rho1_(nuModel1_->viscosityProperties().lookup("rho")),
87     rho2_(nuModel2_->viscosityProperties().lookup("rho")),
89     U_(U),
90     phi_(phi),
92     alpha1_(U_.db().lookupObject<const volScalarField> (alpha1Name)),
94     nu_
95     (
96         IOobject
97         (
98             "nu",
99             U_.time().timeName(),
100             U_.db()
101         ),
102         U_.mesh(),
103         dimensionedScalar("nu", dimensionSet(0, 2, -1, 0, 0), 0),
104         calculatedFvPatchScalarField::typeName
105     )
107     calcNu();
111 // * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * * //
113 Foam::tmp<Foam::volScalarField> Foam::twoPhaseMixture::mu() const
115     const volScalarField limitedAlpha1
116     (
117         min(max(alpha1_, scalar(0)), scalar(1))
118     );
120     return tmp<volScalarField>
121     (
122         new volScalarField
123         (
124             "mu",
125             limitedAlpha1*rho1_*nuModel1_->nu()
126           + (scalar(1) - limitedAlpha1)*rho2_*nuModel2_->nu()
127         )
128     );
132 Foam::tmp<Foam::surfaceScalarField> Foam::twoPhaseMixture::muf() const
134     const surfaceScalarField alpha1f
135     (
136         min(max(fvc::interpolate(alpha1_), scalar(0)), scalar(1))
137     );
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 Foam::tmp<Foam::surfaceScalarField> Foam::twoPhaseMixture::nuf() const
153     const surfaceScalarField alpha1f
154     (
155         min(max(fvc::interpolate(alpha1_), scalar(0)), scalar(1))
156     );
158     return tmp<surfaceScalarField>
159     (
160         new surfaceScalarField
161         (
162             "nuf",
163             (
164                 alpha1f*rho1_*fvc::interpolate(nuModel1_->nu())
165               + (scalar(1) - alpha1f)*rho2_*fvc::interpolate(nuModel2_->nu())
166             )/(alpha1f*rho1_ + (scalar(1) - alpha1f)*rho2_)
167         )
168     );
172 bool Foam::twoPhaseMixture::read()
174     if (transportModel::read())
175     {
176         if
177         (
178             nuModel1_().read(subDict(phase1Name_))
179          && nuModel2_().read(subDict(phase2Name_))
180         )
181         {
182             nuModel1_->viscosityProperties().lookup("rho") >> rho1_;
183             nuModel2_->viscosityProperties().lookup("rho") >> rho2_;
185             return true;
186         }
187         else
188         {
189             return false;
190         }
191     }
192     else
193     {
194         return false;
195     }
199 // ************************************************************************* //