FreeFOAM The Cross-Platform CFD Toolkit
threePhaseMixture.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-2011 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  Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 
25 \*---------------------------------------------------------------------------*/
26 
27 #include "threePhaseMixture.H"
30 #include <finiteVolume/fvc.H>
31 
32 // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
33 
34 //- Calculate and return the laminar viscosity
35 void Foam::threePhaseMixture::calcNu()
36 {
37  nuModel1_->correct();
38  nuModel2_->correct();
39  nuModel3_->correct();
40 
41  // Average kinematic viscosity calculated from dynamic viscosity
42  nu_ = mu()/(alpha1_*rho1_ + alpha2_*rho2_ + alpha3_*rho3_);
43 }
44 
45 
46 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
47 
49 (
50  const volVectorField& U,
51  const surfaceScalarField& phi
52 )
53 :
54  transportModel(U, phi),
55 
56  phase1Name_("phase1"),
57  phase2Name_("phase2"),
58  phase3Name_("phase3"),
59 
60  nuModel1_
61  (
62  viscosityModel::New
63  (
64  "nu1",
65  subDict(phase1Name_),
66  U,
67  phi
68  )
69  ),
70  nuModel2_
71  (
72  viscosityModel::New
73  (
74  "nu2",
75  subDict(phase2Name_),
76  U,
77  phi
78  )
79  ),
80  nuModel3_
81  (
82  viscosityModel::New
83  (
84  "nu3",
85  subDict(phase3Name_),
86  U,
87  phi
88  )
89  ),
90 
91  rho1_(nuModel1_->viscosityProperties().lookup("rho")),
92  rho2_(nuModel2_->viscosityProperties().lookup("rho")),
93  rho3_(nuModel3_->viscosityProperties().lookup("rho")),
94 
95  U_(U),
96  phi_(phi),
97 
98  alpha1_(U_.db().lookupObject<const volScalarField> ("alpha1")),
99  alpha2_(U_.db().lookupObject<const volScalarField> ("alpha2")),
100  alpha3_(U_.db().lookupObject<const volScalarField> ("alpha3")),
101 
102  nu_
103  (
104  IOobject
105  (
106  "nu",
107  U_.time().timeName(),
108  U_.db()
109  ),
110  U_.mesh(),
111  dimensionedScalar("nu", dimensionSet(0, 2, -1, 0, 0), 0),
112  calculatedFvPatchScalarField::typeName
113  )
114 {
115  calcNu();
116 }
117 
118 
119 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
120 
122 {
123  return tmp<volScalarField>
124  (
125  new volScalarField
126  (
127  "mu",
128  alpha1_*rho1_*nuModel1_->nu()
129  + alpha2_*rho2_*nuModel2_->nu()
130  + alpha3_*rho3_*nuModel3_->nu()
131  )
132  );
133 }
134 
135 
137 {
138  surfaceScalarField alpha1f = fvc::interpolate(alpha1_);
139  surfaceScalarField alpha2f = fvc::interpolate(alpha2_);
140  surfaceScalarField alpha3f = fvc::interpolate(alpha3_);
141 
142  return tmp<surfaceScalarField>
143  (
145  (
146  "mu",
147  alpha1f*rho1_*fvc::interpolate(nuModel1_->nu())
148  + alpha2f*rho2_*fvc::interpolate(nuModel2_->nu())
149  + alpha3f*rho3_*fvc::interpolate(nuModel3_->nu())
150  )
151  );
152 }
153 
154 
156 {
157  surfaceScalarField alpha1f = fvc::interpolate(alpha1_);
158  surfaceScalarField alpha2f = fvc::interpolate(alpha2_);
159  surfaceScalarField alpha3f = fvc::interpolate(alpha3_);
160 
161  return tmp<surfaceScalarField>
162  (
164  (
165  "nu",
166  (
167  alpha1f*rho1_*fvc::interpolate(nuModel1_->nu())
168  + alpha2f*rho2_*fvc::interpolate(nuModel2_->nu())
169  + alpha3f*rho3_*fvc::interpolate(nuModel3_->nu())
170  )/(alpha1f*rho1_ + alpha2f*rho2_ + alpha3f*rho3_)
171  )
172  );
173 }
174 
175 
177 {
178  if (transportModel::read())
179  {
180  if
181  (
182  nuModel1_().read(*this)
183  && nuModel2_().read(*this)
184  && nuModel3_().read(*this)
185  )
186  {
187  nuModel1_->viscosityProperties().lookup("rho") >> rho1_;
188  nuModel2_->viscosityProperties().lookup("rho") >> rho2_;
189  nuModel3_->viscosityProperties().lookup("rho") >> rho3_;
190 
191  return true;
192  }
193  else
194  {
195  return false;
196  }
197  }
198  else
199  {
200  return false;
201  }
202 }
203 
204 
205 // ************************************************************************* //