phaseForces.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2018 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 "phaseForces.H"
28 #include "BlendedInterfacialModel.H"
29 #include "dragModel.H"
30 #include "virtualMassModel.H"
31 #include "liftModel.H"
32 #include "wallLubricationModel.H"
33 #include "turbulentDispersionModel.H"
34 
35 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
36 
37 namespace Foam
38 {
39 namespace functionObjects
40 {
41  defineTypeNameAndDebug(phaseForces, 0);
42  addToRunTimeSelectionTable(functionObject, phaseForces, dictionary);
43 }
44 }
45 
46 // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
47 
49 Foam::functionObjects::phaseForces::dragForce() const
50 {
51  tmp<volVectorField> tdragForce
52  (
53  new volVectorField
54  (
55  IOobject
56  (
57  "dragForce",
58  mesh_.time().timeName(),
59  mesh_
60  ),
61  mesh_,
63  )
64  );
65 
66  volVectorField& dragForce = tdragForce.ref();
67 
69  (
71  fluid_.phasePairs(),
72  iter
73  )
74  {
75  const phasePair& pair = iter();
76 
77  if (pair.contains(phase_) && !pair.ordered())
78  {
79  const BlendedInterfacialModel<dragModel>& drag =
80  fluid_.lookupBlendedSubModel<dragModel>(pair);
81 
82  dragForce += drag.K()*(pair.otherPhase(phase_).U() - phase_.U());
83  }
84  }
85 
86  return tdragForce;
87 }
88 
89 
91 Foam::functionObjects::phaseForces::virtualMassForce() const
92 {
93  tmp<volVectorField> tvirtualMassForce
94  (
95  new volVectorField
96  (
97  IOobject
98  (
99  "virtualMassForce",
100  mesh_.time().timeName(),
101  mesh_
102  ),
103  mesh_,
105  )
106  );
107 
108  volVectorField& virtualMassForce = tvirtualMassForce.ref();
109 
111  (
113  fluid_.phasePairs(),
114  iter
115  )
116  {
117  const phasePair& pair = iter();
118 
119  if (pair.contains(phase_) && !pair.ordered())
120  {
121  const BlendedInterfacialModel<virtualMassModel>& virtualMass =
122  fluid_.lookupBlendedSubModel<virtualMassModel>(pair);
123 
124  virtualMassForce +=
125  virtualMass.K()
126  *(
127  pair.otherPhase(phase_).DUDt()
128  - phase_.DUDt()
129  );
130  }
131  }
132 
133  return tvirtualMassForce;
134 }
135 
136 
138 Foam::functionObjects::phaseForces::liftForce() const
139 {
140  tmp<volVectorField> tLiftForce
141  (
142  new volVectorField
143  (
144  IOobject
145  (
146  "liftForce",
147  mesh_.time().timeName(),
148  mesh_
149  ),
150  mesh_,
152  )
153  );
154 
155  volVectorField& liftForce = tLiftForce.ref();
156 
158  (
160  fluid_.phasePairs(),
161  iter
162  )
163  {
164  const phasePair& pair = iter();
165 
166  if (pair.contains(phase_) && !pair.ordered())
167  {
168  const BlendedInterfacialModel<liftModel>& lift =
169  fluid_.lookupBlendedSubModel<liftModel>(pair);
170 
171  if (&pair.phase1() == &phase_)
172  {
173  liftForce += lift.F<vector>();
174  }
175  else
176  {
177  liftForce -= lift.F<vector>();
178  }
179  }
180  }
181 
182  return tLiftForce;
183 }
184 
185 
187 Foam::functionObjects::phaseForces::wallLubricationForce() const
188 {
189  tmp<volVectorField> tWallLubricationForce
190  (
191  new volVectorField
192  (
193  IOobject
194  (
195  "wallLubricationForce",
196  mesh_.time().timeName(),
197  mesh_
198  ),
199  mesh_,
201  )
202  );
203 
204  volVectorField& wallLubricationForce = tWallLubricationForce.ref();
205 
207  (
209  fluid_.phasePairs(),
210  iter
211  )
212  {
213  const phasePair& pair = iter();
214 
215  if (pair.contains(phase_) && !pair.ordered())
216  {
217  const BlendedInterfacialModel<wallLubricationModel>&
218  wallLubrication =
219  fluid_.lookupBlendedSubModel<wallLubricationModel>(pair);
220 
221  if (&pair.phase1() == &phase_)
222  {
223  wallLubricationForce += wallLubrication.F<vector>();
224  }
225  else
226  {
227  wallLubricationForce -= wallLubrication.F<vector>();
228  }
229  }
230  }
231 
232  return tWallLubricationForce;
233 }
234 
235 
237 Foam::functionObjects::phaseForces::turbulentDispersionForce() const
238 {
239  tmp<volVectorField> tturbulentDispersionForce
240  (
241  new volVectorField
242  (
243  IOobject
244  (
245  "turbulentDispersionForce",
246  mesh_.time().timeName(),
247  mesh_
248  ),
249  mesh_,
251  )
252  );
253 
254  volVectorField& turbulentDispersionForce = tturbulentDispersionForce.ref();
255 
257  (
259  fluid_.phasePairs(),
260  iter
261  )
262  {
263  const phasePair& pair = iter();
264 
265  if (pair.contains(phase_) && !pair.ordered())
266  {
267  const BlendedInterfacialModel<turbulentDispersionModel>&
268  turbulentDispersion = fluid_.lookupBlendedSubModel
269  <
270  turbulentDispersionModel
271  >(pair);
272 
273  if (&pair.phase1() == &phase_)
274  {
275  turbulentDispersionForce += turbulentDispersion.F<vector>();
276  }
277  else
278  {
279  turbulentDispersionForce -= turbulentDispersion.F<vector>();
280  }
281  }
282  }
283 
284  return tturbulentDispersionForce;
285 }
286 
287 
288 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
289 
290 Foam::functionObjects::phaseForces::phaseForces
291 (
292  const word& name,
293  const Time& runTime,
294  const dictionary& dict
295 )
296 :
297  fvMeshFunctionObject(name, runTime, dict),
298  phase_
299  (
300  mesh_.lookupObject<phaseModel>
301  (
302  IOobject::groupName("alpha", dict.lookup("phaseName"))
303  )
304  ),
305  fluid_(mesh_.lookupObject<phaseSystem>("phaseProperties")),
306  dragForce_
307  (
308  IOobject
309  (
310  IOobject::groupName("dragForce", phase_.name()),
311  mesh_.time().timeName(),
312  mesh_,
313  IOobject::NO_READ,
314  IOobject::NO_WRITE
315  ),
316  mesh_,
318  ),
319  virtualMassForce_
320  (
321  IOobject
322  (
323  IOobject::groupName("virtualMassForce", phase_.name()),
324  mesh_.time().timeName(),
325  mesh_,
326  IOobject::NO_READ,
327  IOobject::NO_WRITE
328  ),
329  mesh_,
331  ),
332  liftForce_
333  (
334  IOobject
335  (
336  IOobject::groupName("liftForce", phase_.name()),
337  mesh_.time().timeName(),
338  mesh_,
339  IOobject::NO_READ,
340  IOobject::NO_WRITE
341  ),
342  mesh_,
344  ),
345  wallLubricationForce_
346  (
347  IOobject
348  (
349  IOobject::groupName("wallLubricationForce", phase_.name()),
350  mesh_.time().timeName(),
351  mesh_,
352  IOobject::NO_READ,
353  IOobject::NO_WRITE
354  ),
355  mesh_,
357  ),
358  turbulentDispersionForce_
359  (
360  IOobject
361  (
362  IOobject::groupName("turbulentDispersionForce", phase_.name()),
363  mesh_.time().timeName(),
364  mesh_,
365  IOobject::NO_READ,
366  IOobject::NO_WRITE
367  ),
368  mesh_,
370  )
371 {
372  read(dict);
373 }
374 
375 
376 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
377 
379 {}
380 
381 
382 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
383 
384 bool Foam::functionObjects::phaseForces::read(const dictionary& dict)
385 {
387 
388  return true;
389 }
390 
391 
393 {
394  dragForce_ = dragForce();
395  virtualMassForce_ = virtualMassForce();
396  liftForce_ = liftForce();
397  wallLubricationForce_ = wallLubricationForce();
398  turbulentDispersionForce_ = turbulentDispersionForce();
399 
400  return true;
401 }
402 
403 
405 {
406  dragForce_.write();
407  virtualMassForce_.write();
408  liftForce_.write();
409  wallLubricationForce_.write();
410  turbulentDispersionForce_.write();
411 
412  return true;
413 }
414 
415 
416 // ************************************************************************* //
dictionary dict
virtual bool read(const dictionary &dict)
Read the input data.
HashTable< autoPtr< phasePair >, phasePairKey, phasePairKey::hash > phasePairTable
Definition: phaseSystem.H:87
dimensioned< vector > dimensionedVector
Dimensioned vector obtained from generic dimensioned type.
engineTime & runTime
Vector< scalar > vector
A scalar version of the templated Vector.
Definition: vector.H:49
void read(Istream &, label &, const dictionary &)
In-place read with dictionary lookup.
GeometricField< vector, fvPatchField, volMesh > volVectorField
Definition: volFieldsFwd.H:55
Macros for easy insertion into run-time selection tables.
const dimensionSet dimVolume(pow3(dimLength))
Definition: dimensionSets.H:58
bool read(const char *, int32_t &)
Definition: int32IO.C:85
stressControl lookup("compactNormalStress") >> compactNormalStress
virtual ~phaseForces()
Destructor.
word timeName
Definition: getTimeIndex.H:3
static const zero Zero
Definition: zero.H:97
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
Definition: pEqn.H:29
virtual bool execute()
Calculate the force fields.
const dimensionSet dimForce
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
Internal & ref()
Return a reference to the dimensioned internal field.
defineTypeNameAndDebug(fvMeshFunctionObject, 0)
A class for managing temporary objects.
Definition: PtrList.H:53
virtual bool write()
Write the force fields.
addToRunTimeSelectionTable(functionObject, add, dictionary)
Namespace for OpenFOAM.