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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2017 OpenFOAM Foundation
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
28 #include "phaseModel.H"
29 #include "diameterModel.H"
31 #include "slipFvPatchFields.H"
33 #include "surfaceInterpolate.H"
34 #include "fvcFlux.H"
35 
36 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
37 
39 (
40  const word& phaseName,
41  const dictionary& phaseDict,
42  const fvMesh& mesh
43 )
44 :
46  (
47  IOobject
48  (
49  IOobject::groupName("alpha", phaseName),
50  mesh.time().timeName(),
51  mesh,
52  IOobject::MUST_READ,
53  IOobject::AUTO_WRITE
54  ),
55  mesh
56  ),
57  name_(phaseName),
58  phaseDict_(phaseDict),
59  nu_
60  (
61  "nu",
63  phaseDict_
64  ),
65  kappa_
66  (
67  "kappa",
68  dimensionSet(1, 1, -3, -1, 0),
69  phaseDict_
70  ),
71  Cp_
72  (
73  "Cp",
75  phaseDict_
76  ),
77  rho_
78  (
79  "rho",
80  dimDensity,
81  phaseDict_
82  ),
83  U_
84  (
85  IOobject
86  (
87  IOobject::groupName("U", phaseName),
88  mesh.time().timeName(),
89  mesh,
90  IOobject::MUST_READ,
91  IOobject::AUTO_WRITE
92  ),
93  mesh
94  ),
95  DDtU_
96  (
97  IOobject
98  (
99  IOobject::groupName("DDtU", phaseName),
100  mesh.time().timeName(),
101  mesh
102  ),
103  mesh,
105  ),
106  alphaPhi_
107  (
108  IOobject
109  (
110  IOobject::groupName("alphaPhi", phaseName),
111  mesh.time().timeName(),
112  mesh
113  ),
114  mesh,
115  dimensionedScalar(dimensionSet(0, 3, -1, 0, 0), Zero)
116  )
117 {
118  alphaPhi_.setOriented();
119 
120  const word phiName = IOobject::groupName("phi", name_);
121 
122  IOobject phiHeader
123  (
124  phiName,
125  mesh.time().timeName(),
126  mesh,
127  IOobject::NO_READ
128  );
129 
130  if (phiHeader.typeHeaderOk<surfaceScalarField>(true))
131  {
132  Info<< "Reading face flux field " << phiName << endl;
133 
134  phiPtr_.reset
135  (
137  (
138  IOobject
139  (
140  phiName,
141  mesh.time().timeName(),
142  mesh,
143  IOobject::MUST_READ,
144  IOobject::AUTO_WRITE
145  ),
146  mesh
147  )
148  );
149  }
150  else
151  {
152  Info<< "Calculating face flux field " << phiName << endl;
153 
154  wordList phiTypes
155  (
156  U_.boundaryField().size(),
157  calculatedFvPatchScalarField::typeName
158  );
159 
160  forAll(U_.boundaryField(), i)
161  {
162  if
163  (
164  isA<fixedValueFvPatchVectorField>(U_.boundaryField()[i])
165  || isA<slipFvPatchVectorField>(U_.boundaryField()[i])
166  || isA<partialSlipFvPatchVectorField>(U_.boundaryField()[i])
167  )
168  {
169  phiTypes[i] = fixedValueFvPatchScalarField::typeName;
170  }
171  }
172 
173  phiPtr_.reset
174  (
176  (
177  IOobject
178  (
179  phiName,
180  mesh.time().timeName(),
181  mesh,
182  IOobject::NO_READ,
183  IOobject::AUTO_WRITE
184  ),
185  fvc::flux(U_),
186  phiTypes
187  )
188  );
189  }
190 
191  dPtr_ = diameterModel::New
192  (
193  phaseDict_,
194  *this
195  );
196 }
197 
198 
199 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
200 
202 {}
203 
204 
205 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
206 
208 {
210  return nullptr;
211 }
212 
213 
214 
216 {
217  //nuModel_->correct();
218 }
219 
220 
221 bool Foam::phaseModel::read(const dictionary& phaseDict)
222 {
223  phaseDict_ = phaseDict;
224 
225  //if (nuModel_->read(phaseDict_))
226  {
227  phaseDict_.readEntry("nu", nu_.value());
228  phaseDict_.readEntry("kappa", kappa_.value());
229  phaseDict_.readEntry("Cp", Cp_.value());
230  phaseDict_.readEntry("rho", rho_.value());
231 
232  return true;
233  }
234 
235  // return false;
236 }
237 
238 
240 {
241  surfaceScalarField::Boundary& alphaPhiBf = alphaPhi.boundaryFieldRef();
242  const volScalarField::Boundary& alphaBf = boundaryField();
243  const surfaceScalarField::Boundary& phiBf = phi().boundaryField();
244 
245  forAll(alphaPhiBf, patchi)
246  {
247  fvsPatchScalarField& alphaPhip = alphaPhiBf[patchi];
248 
249  if (!alphaPhip.coupled())
250  {
251  alphaPhip = phiBf[patchi]*alphaBf[patchi];
252  }
253  }
254 }
255 
256 
258 {
259  return dPtr_().d();
260 }
261 
262 
263 // ************************************************************************* //
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:169
Foam::fvc::flux
tmp< surfaceScalarField > flux(const volVectorField &vvf)
Return the face-flux field obtained from the given volVectorField.
partialSlipFvPatchFields.H
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
slipFvPatchFields.H
Foam::Zero
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
Foam::dimVelocity
const dimensionSet dimVelocity
Foam::dimDensity
const dimensionSet dimDensity
Foam::phaseModel::d
tmp< volScalarField > d() const
Definition: phaseModel.C:257
phaseModel.H
Foam::fvsPatchField
An abstract base class with a fat-interface to all derived classes covering all possible ways in whic...
Definition: fvsPatchField.H:68
Foam::phaseModel::correct
void correct()
Correct the phase properties.
Definition: phaseModel.C:215
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:369
Foam::dimensionSet
Dimension set for the base types, which can be used to implement rigorous dimension checking for alge...
Definition: dimensionSet.H:108
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
Foam::phaseModel::~phaseModel
virtual ~phaseModel()
Destructor.
Definition: phaseModel.C:201
Foam::dimensionedVector
dimensioned< vector > dimensionedVector
Dimensioned vector obtained from generic dimensioned type.
Definition: dimensionedVector.H:50
NotImplemented
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:517
Foam::dimTime
const dimensionSet dimTime(0, 0, 1, 0, 0, 0, 0)
Definition: dimensionSets.H:53
Foam::phaseModel::phaseModel
phaseModel(const word &phaseName, const dictionary &phaseDict, const fvMesh &mesh)
Definition: phaseModel.C:39
alphaPhi
surfaceScalarField alphaPhi(phi.name()+alpha1.name(), fvc::flux(phi, alpha1, alphaScheme))
Foam::Info
messageStream Info
Information stream (stdout output on master, null elsewhere)
Foam::dimSpecificHeatCapacity
const dimensionSet dimSpecificHeatCapacity(dimGasConstant)
Definition: dimensionSets.H:76
Foam::dictionary::readEntry
bool readEntry(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX, bool mandatory=true) const
Definition: dictionaryTemplates.C:302
Foam::dimensionedScalar
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
Definition: dimensionedScalarFwd.H:42
phi
surfaceScalarField & phi
Definition: setRegionFluidFields.H:8
Foam::volScalarField
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:57
Foam::dimViscosity
const dimensionSet dimViscosity
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:85
Foam::New
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
Definition: DimensionedFieldReuseFunctions.H:105
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::phaseModel::correctInflowOutflow
void correctInflowOutflow(surfaceScalarField &alphaPhi) const
Ensure that the flux at inflow/outflow BCs is preserved.
Definition: phaseModel.C:239
Foam::GeometricField::boundaryFieldRef
Boundary & boundaryFieldRef(const bool updateAccessTime=true)
Return a reference to the boundary field.
Definition: GeometricField.C:783
Foam::List< word >
Foam::phaseModel::read
virtual bool read()
Read phase properties dictionary.
Definition: phaseModel.C:321
fvcFlux.H
Calculate the face-flux of the given field.
fixedValueFvPatchFields.H
Foam::GeometricField< scalar, fvsPatchField, surfaceMesh >
Foam::phaseModel::clone
autoPtr< phaseModel > clone() const
Return clone.
Definition: phaseModel.C:207
Foam::fvsPatchField::coupled
virtual bool coupled() const
Return true if this patch field is coupled.
Definition: fvsPatchField.H:310
Foam::GeometricField::boundaryField
const Boundary & boundaryField() const
Return const-reference to the boundary field.
Definition: GeometricFieldI.H:62