FreeFOAM The Cross-Platform CFD Toolkit
twoPhaseMixture.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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.
15 
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.
20 
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/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "twoPhaseMixture.H"
29 #include <finiteVolume/fvc.H>
30 
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
32 
33 namespace Foam
34 {
35 
36 // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
37 
38 //- Calculate and return the laminar viscosity
40 {
41  nuModel1_->correct();
42  nuModel2_->correct();
43 
44  volScalarField limitedAlpha1
45  (
46  "limitedAlpha1",
47  min(max(alpha1_, scalar(0)), scalar(1))
48  );
49 
50  // Average kinematic viscosity calculated from dynamic viscosity
51  nu_ = mu()/(limitedAlpha1*rho1_ + (scalar(1) - limitedAlpha1)*rho2_);
52 }
53 
54 
55 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
56 
58 (
59  const volVectorField& U,
60  const surfaceScalarField& phi,
61  const word& alpha1Name
62 )
63 :
64  transportModel(U, phi),
65 
66  phase1Name_("phase1"),
67  phase2Name_("phase2"),
68 
69  nuModel1_
70  (
72  (
73  "nu1",
74  subDict(phase1Name_),
75  U,
76  phi
77  )
78  ),
79  nuModel2_
80  (
82  (
83  "nu2",
84  subDict(phase2Name_),
85  U,
86  phi
87  )
88  ),
89 
90  rho1_(nuModel1_->viscosityProperties().lookup("rho")),
91  rho2_(nuModel2_->viscosityProperties().lookup("rho")),
92 
93  U_(U),
94  phi_(phi),
95 
96  alpha1_(U_.db().lookupObject<const volScalarField> (alpha1Name)),
97 
98  nu_
99  (
100  IOobject
101  (
102  "nu",
103  U_.time().timeName(),
104  U_.db()
105  ),
106  U_.mesh(),
107  dimensionedScalar("nu", dimensionSet(0, 2, -1, 0, 0), 0),
108  calculatedFvPatchScalarField::typeName
109  )
110 {
111  calcNu();
112 }
113 
114 
115 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
116 
118 {
119  volScalarField limitedAlpha1 = min(max(alpha1_, scalar(0)), scalar(1));
120 
121  return tmp<volScalarField>
122  (
123  new volScalarField
124  (
125  "mu",
126  limitedAlpha1*rho1_*nuModel1_->nu()
127  + (scalar(1) - limitedAlpha1)*rho2_*nuModel2_->nu()
128  )
129  );
130 }
131 
132 
134 {
135  surfaceScalarField alpha1f =
136  min(max(fvc::interpolate(alpha1_), scalar(0)), scalar(1));
137 
139  (
141  (
142  "muf",
143  alpha1f*rho1_*fvc::interpolate(nuModel1_->nu())
144  + (scalar(1) - alpha1f)*rho2_*fvc::interpolate(nuModel2_->nu())
145  )
146  );
147 }
148 
149 
151 {
152  surfaceScalarField alpha1f =
153  min(max(fvc::interpolate(alpha1_), scalar(0)), scalar(1));
154 
156  (
158  (
159  "nuf",
160  (
161  alpha1f*rho1_*fvc::interpolate(nuModel1_->nu())
162  + (scalar(1) - alpha1f)*rho2_*fvc::interpolate(nuModel2_->nu())
163  )/(alpha1f*rho1_ + (scalar(1) - alpha1f)*rho2_)
164  )
165  );
166 }
167 
168 
170 {
171  if (transportModel::read())
172  {
173  if
174  (
177  )
178  {
181 
182  return true;
183  }
184  else
185  {
186  return false;
187  }
188  }
189  else
190  {
191  return false;
192  }
193 }
194 
195 
196 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
197 
198 } // End namespace Foam
199 
200 // ************************ vim: set sw=4 sts=4 et: ************************ //