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 {
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 // ************************************************************************* //
Foam::IOobject::groupName
static word groupName(Name name, const word &group)
partialSlipFvPatchFields.H
Foam::IOobject::AUTO_WRITE
@ AUTO_WRITE
Definition: IOobject.H:117
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:118
Foam::multiphaseMixtureThermo::U_
const volVectorField & U_
Definition: multiphaseMixtureThermo.H:130
slipFvPatchFields.H
Foam::dimVelocity
const dimensionSet dimVelocity
Foam::dimDensity
const dimensionSet dimDensity
Foam::phaseModel::~phaseModel
virtual ~phaseModel()
Destructor.
Foam::phaseModel::read
virtual bool read()
Read phase properties dictionary.
Foam::fvc::interpolate
tmp< GeometricField< Type, fvsPatchField, surfaceMesh > > interpolate(const GeometricField< Type, fvPatchField, volMesh > &vf, const surfaceScalarField &faceFlux, Istream &schemeData)
Interpolate field onto faces using scheme given by Istream.
Definition: surfaceInterpolate.C:110
Foam::phaseModel::correct
void correct()
Foam::GeometricField::boundaryField
GeometricBoundaryField & boundaryField()
Return reference to GeometricBoundaryField.
Definition: GeometricField.C:735
Foam::IOobject::MUST_READ
@ MUST_READ
Definition: IOobject.H:108
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Foam::dimensionedVector
dimensioned< vector > dimensionedVector
Dimensioned vector obtained from generic dimensioned type.
Definition: dimensionedVector.H:48
Foam::wordList
List< word > wordList
A List of words.
Definition: fileName.H:54
Foam::phaseModel::d
tmp< volScalarField > d() const
NotImplemented
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:365
Foam::dimTime
const dimensionSet dimTime(0, 0, 1, 0, 0, 0, 0)
Definition: dimensionSets.H:51
Foam::phaseModel::phaseModel
phaseModel(const word &phaseName, const volScalarField &p, const volScalarField &T)
Construct from components.
Foam::IOobject::NO_READ
@ NO_READ
Definition: IOobject.H:111
Foam::phaseModel::clone
autoPtr< phaseModel > clone() const
Return clone.
Foam::Info
messageStream Info
Foam::dimensionedScalar
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
Definition: dimensionedScalarFwd.H:41
Foam::volScalarField
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:52
Foam::dictionaryName::name_
fileName name_
Definition: dictionary.H:82
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:18
surfaceInterpolate.H
Surface Interpolation.
Foam::vector
Vector< scalar > vector
A scalar version of the templated Vector.
Definition: vector.H:49
Foam::autoPtr
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:117
Foam::surfaceScalarField
GeometricField< scalar, fvsPatchField, surfaceMesh > surfaceScalarField
Definition: surfaceFieldsFwd.H:52
Foam::IOobject::IOobject
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:116
fixedValueFvPatchFields.H
timeName
word timeName
Definition: getTimeIndex.H:3
Foam::diameterModel::New
static autoPtr< diameterModel > New(const dictionary &dict, const phaseModel &phase)