phaseModel.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) 2011-2015 OpenFOAM Foundation
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 "phaseModel.H"
27 #include "diameterModel.H"
29 #include "slipFvPatchFields.H"
31 #include "surfaceInterpolate.H"
32 
33 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
34 
36 (
37  const word& phaseName,
38  const dictionary& phaseDict,
39  const fvMesh& mesh
40 )
41 :
43  (
44  IOobject
45  (
46  IOobject::groupName("alpha", phaseName),
47  mesh.time().timeName(),
48  mesh,
49  IOobject::MUST_READ,
50  IOobject::AUTO_WRITE
51  ),
52  mesh
53  ),
54  name_(phaseName),
55  phaseDict_(phaseDict),
56  nu_
57  (
58  "nu",
59  dimensionSet(0, 2, -1, 0, 0),
60  phaseDict_
61  ),
62  kappa_
63  (
64  "kappa",
65  dimensionSet(1, 1, -3, -1, 0),
66  phaseDict_
67  ),
68  Cp_
69  (
70  "Cp",
71  dimensionSet(0, 2, -2, -1, 0),
72  phaseDict_
73  ),
74  rho_
75  (
76  "rho",
77  dimDensity,
78  phaseDict_
79  ),
80  U_
81  (
82  IOobject
83  (
84  IOobject::groupName("U", phaseName),
85  mesh.time().timeName(),
86  mesh,
87  IOobject::MUST_READ,
88  IOobject::AUTO_WRITE
89  ),
90  mesh
91  ),
92  DDtU_
93  (
94  IOobject
95  (
96  IOobject::groupName("DDtU", phaseName),
97  mesh.time().timeName(),
98  mesh
99  ),
100  mesh,
102  ),
103  alphaPhi_
104  (
105  IOobject
106  (
107  IOobject::groupName("alphaPhi", phaseName),
108  mesh.time().timeName(),
109  mesh
110  ),
111  mesh,
112  dimensionedScalar("0", dimensionSet(0, 3, -1, 0, 0), 0)
113  )
114 {
115  const word phiName = IOobject::groupName("phi", name_);
116 
117  IOobject phiHeader
118  (
119  phiName,
120  mesh.time().timeName(),
121  mesh,
123  );
124 
125  if (phiHeader.headerOk())
126  {
127  Info<< "Reading face flux field " << phiName << endl;
128 
129  phiPtr_.reset
130  (
132  (
133  IOobject
134  (
135  phiName,
136  mesh.time().timeName(),
137  mesh,
140  ),
141  mesh
142  )
143  );
144  }
145  else
146  {
147  Info<< "Calculating face flux field " << phiName << endl;
148 
149  wordList phiTypes
150  (
151  U_.boundaryField().size(),
152  calculatedFvPatchScalarField::typeName
153  );
154 
155  forAll(U_.boundaryField(), i)
156  {
157  if
158  (
159  isA<fixedValueFvPatchVectorField>(U_.boundaryField()[i])
160  || isA<slipFvPatchVectorField>(U_.boundaryField()[i])
161  || isA<partialSlipFvPatchVectorField>(U_.boundaryField()[i])
162  )
163  {
164  phiTypes[i] = fixedValueFvPatchScalarField::typeName;
165  }
166  }
167 
168  phiPtr_.reset
169  (
171  (
172  IOobject
173  (
174  phiName,
175  mesh.time().timeName(),
176  mesh,
179  ),
180  fvc::interpolate(U_) & mesh.Sf(),
181  phiTypes
182  )
183  );
184  }
185 
186  dPtr_ = diameterModel::New
187  (
188  phaseDict_,
189  *this
190  );
191 }
192 
193 
194 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
195 
197 {}
198 
199 
200 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
201 
203 {
204  notImplemented("phaseModel::clone() const");
205  return autoPtr<phaseModel>(NULL);
206 }
207 
208 
209 
211 {
212  //nuModel_->correct();
213 }
214 
215 
216 bool Foam::phaseModel::read(const dictionary& phaseDict)
217 {
218  phaseDict_ = phaseDict;
219 
220  //if (nuModel_->read(phaseDict_))
221  {
222  phaseDict_.lookup("nu") >> nu_.value();
223  phaseDict_.lookup("kappa") >> kappa_.value();
224  phaseDict_.lookup("Cp") >> Cp_.value();
225  phaseDict_.lookup("rho") >> rho_.value();
226 
227  return true;
228  }
229  // else
230  // {
231  // return false;
232  // }
233 
234  return true;
235 }
236 
237 
239 {
240  return dPtr_().d();
241 }
242 
243 
244 // ************************************************************************* //
tmp< GeometricField< Type, fvsPatchField, surfaceMesh > > interpolate(const GeometricField< Type, fvPatchField, volMesh > &vf, const surfaceScalarField &faceFlux, Istream &schemeData)
dictionary()
Construct top-level dictionary null.
Definition: dictionary.C:113
static autoPtr< diameterModel > New(const dictionary &dict, const phaseModel &phase)
GeometricBoundaryField & boundaryField()
Return reference to GeometricBoundaryField.
const dimensionSet dimTime(0, 0, 1, 0, 0, 0, 0)
Definition: dimensionSets.H:51
Surface Interpolation.
messageStream Info
dynamicFvMesh & mesh
const dimensionSet dimDensity
autoPtr< phaseModel > clone() const
Return clone.
void correct()
Correct the laminar viscosity.
static word groupName(Name name, const word &group)
virtual ~phaseModel()
Destructor.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:52
#define forAll(list, i)
Definition: UList.H:421
GeometricField< scalar, fvsPatchField, surfaceMesh > surfaceScalarField
dimensioned< vector > dimensionedVector
Dimensioned vector obtained from generic dimensioned type.
tmp< volScalarField > d() const
virtual bool read()
Read phase properties dictionary.
List< word > wordList
A List of words.
Definition: fileName.H:54
IOobject(const word &name, const fileName &instance, const objectRegistry &registry, readOption r=NO_READ, writeOption w=NO_WRITE, bool registerObject=true)
Construct from name, instance, registry, io options.
Definition: IOobject.C:131
Vector< scalar > vector
A scalar version of the templated Vector.
Definition: vector.H:49
phaseModel(const word &phaseName, const volScalarField &p, const volScalarField &T)
Construct from components.
#define notImplemented(functionName)
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:356
const dimensionSet dimVelocity
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:117
A class for managing temporary objects.
Definition: PtrList.H:118
word timeName
Definition: getTimeIndex.H:3