phaseForces.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) 2018-2019 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 "phaseForces.H"
30 #include "BlendedInterfacialModel.H"
31 #include "dragModel.H"
32 #include "virtualMassModel.H"
33 #include "liftModel.H"
34 #include "wallLubricationModel.H"
35 #include "turbulentDispersionModel.H"
36 
37 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
38 
39 namespace Foam
40 {
41 namespace functionObjects
42 {
43  defineTypeNameAndDebug(phaseForces, 0);
44  addToRunTimeSelectionTable(functionObject, phaseForces, dictionary);
45 }
46 }
47 
48 
49 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * * //
50 
51 template<class modelType>
54 {
56  fluid_.lookupBlendedSubModel<modelType>(pair);
57 
58  if (&pair.phase1() == &phase_)
59  {
60  return model.template F<vector>();
61  }
62  else
63  {
64  return -model.template F<vector>();
65  }
66 }
67 
68 
69 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
70 
71 Foam::functionObjects::phaseForces::phaseForces
72 (
73  const word& name,
74  const Time& runTime,
75  const dictionary& dict
76 )
77 :
79  phase_
80  (
81  mesh_.lookupObject<phaseModel>
82  (
83  IOobject::groupName("alpha", dict.get<word>("phase"))
84  )
85  ),
86  fluid_(mesh_.lookupObject<phaseSystem>("phaseProperties"))
87 {
88  read(dict);
89 
91  (
93  fluid_.phasePairs(),
94  iter
95  )
96  {
97  const phasePair& pair = iter();
98 
99  if (pair.contains(phase_) && !pair.ordered())
100  {
101  if (fluid_.foundBlendedSubModel<dragModel>(pair))
102  {
103  forceFields_.set
104  (
105  dragModel::typeName,
106  new volVectorField
107  (
108  IOobject
109  (
110  IOobject::groupName("dragForce", phase_.name()),
111  mesh_.time().timeName(),
112  mesh_
113  ),
114  mesh_,
116  )
117  );
118  }
119 
120  if (fluid_.foundBlendedSubModel<virtualMassModel>(pair))
121  {
122  forceFields_.set
123  (
124  virtualMassModel::typeName,
125  new volVectorField
126  (
127  IOobject
128  (
130  (
131  "virtualMassForce",
132  phase_.name()
133  ),
134  mesh_.time().timeName(),
135  mesh_
136  ),
137  mesh_,
139  )
140  );
141  }
142 
143  if (fluid_.foundBlendedSubModel<liftModel>(pair))
144  {
145  forceFields_.set
146  (
147  liftModel::typeName,
148  new volVectorField
149  (
150  IOobject
151  (
152  IOobject::groupName("liftForce", phase_.name()),
153  mesh_.time().timeName(),
154  mesh_
155  ),
156  mesh_,
158  )
159  );
160  }
161 
162  if (fluid_.foundBlendedSubModel<wallLubricationModel>(pair))
163  {
164  forceFields_.set
165  (
166  wallLubricationModel::typeName,
167  new volVectorField
168  (
169  IOobject
170  (
172  (
173  "wallLubricationForce",
174  phase_.name()
175  ),
176  mesh_.time().timeName(),
177  mesh_
178  ),
179  mesh_,
181  )
182  );
183  }
184 
185  if (fluid_.foundBlendedSubModel<turbulentDispersionModel>(pair))
186  {
187  forceFields_.set
188  (
189  turbulentDispersionModel::typeName,
190  new volVectorField
191  (
192  IOobject
193  (
195  (
196  "turbulentDispersionForce",
197  phase_.name()
198  ),
199  mesh_.time().timeName(),
200  mesh_
201  ),
202  mesh_,
204  )
205  );
206  }
207  }
208  }
209 }
210 
211 
212 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
213 
215 {}
216 
217 
218 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
219 
221 {
223 
224  return true;
225 }
226 
227 
229 {
230  forAllIter
231  (
233  forceFields_,
234  iter
235  )
236  {
237  const word& type = iter.key();
238  volVectorField& force = *iter();
239 
240  force *= 0.0;
241 
243  (
245  fluid_.phasePairs(),
246  iter2
247  )
248  {
249  const phasePair& pair = iter2();
250 
251  if (pair.contains(phase_) && !pair.ordered())
252  {
253  if (type == "dragModel")
254  {
255  force +=
256  fluid_.lookupBlendedSubModel<dragModel>(pair).K()
257  *(pair.otherPhase(phase_).U() - phase_.U());
258  }
259 
260  if (type == "virtualMassModel")
261  {
262  force +=
263  fluid_.lookupBlendedSubModel<virtualMassModel>(pair).K()
264  *(
265  pair.otherPhase(phase_).DUDt()
266  - phase_.DUDt()
267  );
268  }
269 
270  if (type == "liftModel")
271  {
272  force = nonDragForce<liftModel>(pair);
273  }
274 
275  if (type == "wallLubricationModel")
276  {
277  force = nonDragForce<wallLubricationModel>(pair);
278  }
279 
280  if (type == "turbulentDispersionModel")
281  {
282  force = nonDragForce<turbulentDispersionModel>(pair);
283  }
284  }
285  }
286  }
287 
288  return true;
289 }
290 
291 
293 {
294  forAllIter
295  (
297  forceFields_,
298  iter
299  )
300  {
301  writeObject(iter()->name());
302  }
303 
304  return true;
305 }
306 
307 
308 // ************************************************************************* //
Foam::virtualMassModel
Definition: virtualMassModel.H:55
runTime
engineTime & runTime
Definition: createEngineTime.H:13
Foam::phaseModel
Single incompressible phase derived from the phase-fraction. Used as part of the multiPhaseMixture fo...
Definition: phaseModel.H:54
Foam::functionObjects::phaseForces::~phaseForces
virtual ~phaseForces()
Destructor.
Definition: phaseForces.C:214
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:169
Foam::phasePair
Description for mass transfer between a pair of phases. The direction of the mass transfer is from th...
Definition: phasePair.H:53
forAllIter
#define forAllIter(Container, container, iter)
Iterate across all elements in the container object.
Definition: stdFoam.H:325
Foam::Time
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:73
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::turbulentDispersionModel
Definition: turbulentDispersionModel.H:56
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::functionObjects::phaseForces::read
virtual bool read(const dictionary &dict)
Read the input data.
Definition: phaseForces.C:220
Foam::read
bool read(const char *buf, int32_t &val)
Same as readInt32.
Definition: int32.H:108
Foam::dimForce
const dimensionSet dimForce
Foam::functionObjects::fvMeshFunctionObject
Specialization of Foam::functionObject for an Foam::fvMesh, providing a reference to the Foam::fvMesh...
Definition: fvMeshFunctionObject.H:64
forAllConstIter
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object.
Definition: stdFoam.H:344
Foam::dimensionedVector
dimensioned< vector > dimensionedVector
Dimensioned vector obtained from generic dimensioned type.
Definition: dimensionedVector.H:50
phaseForces.H
K
CGAL::Exact_predicates_exact_constructions_kernel K
Definition: CGALTriangulation3DKernel.H:58
Foam::phasePairKey::ordered
bool ordered() const noexcept
Return the ordered flag.
Definition: phasePairKey.H:98
Foam::functionObjects::phaseForces::nonDragForce
tmp< volVectorField > nonDragForce(const phasePair &key) const
Evaluate and return non-drag force.
Foam::phaseSystem::lookupBlendedSubModel
const BlendedInterfacialModel< modelType > & lookupBlendedSubModel(const phasePair &key) const
Return a blended sub model between a phase pair.
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam::functionObjects::phaseForces::phase_
const phaseModel & phase_
Phase for which forces are evaluated.
Definition: phaseForces.H:123
Foam::phasePair::contains
bool contains(const phaseModel &phase) const
Return true if this phasePair contains the given phase.
Definition: phasePairI.H:42
Foam::functionObjects::regionFunctionObject::read
virtual bool read(const dictionary &dict)
Read optional controls.
Definition: regionFunctionObject.C:173
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::HashTable< autoPtr< phasePair >, phasePairKey, phasePairKey::hash >
Foam::phaseModel::U
const volVectorField & U() const
Definition: phaseModel.H:172
Foam::liftModel
Definition: liftModel.H:55
Foam::HashPtrTable
A HashTable of pointers to objects of type <T>, with deallocation management of the pointers.
Definition: HashPtrTable.H:54
Foam::functionObjects::addToRunTimeSelectionTable
addToRunTimeSelectionTable(functionObject, ObukhovLength, dictionary)
Foam::BlendedInterfacialModel
Definition: BlendedInterfacialModel.H:68
Foam::functionObjects::phaseForces::fluid_
const phaseSystem & fluid_
Constant access to phaseSystem.
Definition: phaseForces.H:126
Foam::type
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition: MSwindows.C:590
Foam::functionObjects::defineTypeNameAndDebug
defineTypeNameAndDebug(ObukhovLength, 0)
Foam::functionObjects::phaseForces::write
virtual bool write()
Write the force fields.
Definition: phaseForces.C:292
Foam::name
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
Foam::phaseSystem
Class to represent a system of phases and model interfacial transfers between them.
Definition: phaseSystem.H:66
Foam::dragModel
Definition: dragModel.H:51
Foam::IOobject::groupName
static word groupName(StringType base, const word &group)
Create dot-delimited name.group string.
Foam::dimVolume
const dimensionSet dimVolume(pow3(dimLength))
Definition: dimensionSets.H:60
Foam::phasePair::phase1
const phaseModel & phase1() const
Definition: phasePairI.H:30
Foam::GeometricField< vector, fvPatchField, volMesh >
Foam::phasePair::otherPhase
const phaseModel & otherPhase(const phaseModel &phase) const
Return the other phase relative to the given phase.
Definition: phasePairI.H:49
Foam::functionObjects::phaseForces::execute
virtual bool execute()
Calculate the force fields.
Definition: phaseForces.C:228
Foam::wallLubricationModel
Definition: wallLubricationModel.H:56
Foam::phaseModel::DUDt
virtual tmp< volVectorField > DUDt() const =0
Return the substantive acceleration.