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-2023 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 "fvcGrad.H"
29 #include "dragModel.H"
30 #include "virtualMassModel.H"
31 #include "liftModel.H"
32 #include "wallLubricationModel.H"
34 
35 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
36 
37 namespace Foam
38 {
39 namespace functionObjects
40 {
43 }
44 }
45 
46 
47 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
48 
50 (
51  const word& name,
52  const Time& runTime,
53  const dictionary& dict
54 )
55 :
56  fvMeshFunctionObject(name, runTime, dict),
57  phase_
58  (
59  mesh_.lookupObject<phaseModel>
60  (
61  IOobject::groupName("alpha", dict.lookup("phase"))
62  )
63  ),
64  fluid_(mesh_.lookupObject<phaseSystem>(phaseSystem::propertiesName))
65 {
66  read(dict);
67 
68  forAll(fluid_.phases(), phasei)
69  {
70  const phaseModel& otherPhase = fluid_.phases()[phasei];
71 
72  if (&otherPhase == &phase_) continue;
73 
74  const phaseInterface interface(phase_, otherPhase);
75 
77  {
78  forceFields_.insert
79  (
80  dragModel::typeName,
81  new volVectorField
82  (
83  IOobject
84  (
85  IOobject::groupName("dragForce", phase_.name()),
86  mesh_.time().name(),
87  mesh_
88  ),
89  mesh_,
91  )
92  );
93  }
94 
96  {
97  forceFields_.insert
98  (
99  virtualMassModel::typeName,
100  new volVectorField
101  (
102  IOobject
103  (
105  (
106  "virtualMassForce",
107  phase_.name()
108  ),
109  mesh_.time().name(),
110  mesh_
111  ),
112  mesh_,
114  )
115  );
116  }
117 
119  {
120  forceFields_.insert
121  (
122  liftModel::typeName,
123  new volVectorField
124  (
125  IOobject
126  (
127  IOobject::groupName("liftForce", phase_.name()),
128  mesh_.time().name(),
129  mesh_
130  ),
131  mesh_,
133  )
134  );
135  }
136 
137  if
138  (
140  <blendedWallLubricationModel>(interface)
141  )
142  {
143  forceFields_.insert
144  (
145  wallLubricationModel::typeName,
146  new volVectorField
147  (
148  IOobject
149  (
151  (
152  "wallLubricationForce",
153  phase_.name()
154  ),
155  mesh_.time().name(),
156  mesh_
157  ),
158  mesh_,
160  )
161  );
162  }
163 
164  if
165  (
168  )
169  {
170  forceFields_.insert
171  (
172  turbulentDispersionModel::typeName,
173  new volVectorField
174  (
175  IOobject
176  (
178  (
179  "turbulentDispersionForce",
180  phase_.name()
181  ),
182  mesh_.time().name(),
183  mesh_
184  ),
185  mesh_,
187  )
188  );
189  }
190  }
191 }
192 
193 
194 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
195 
197 {}
198 
199 
200 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
201 
203 {
205 
206  return true;
207 }
208 
209 
211 {
212  // Zero the force fields
214  (
216  forceFields_,
217  forceFieldIter
218  )
219  {
220  *forceFieldIter() = Zero;
221  }
222 
223  // Add the forces from all the interfaces which contain this phase
224  forAll(fluid_.phases(), phasei)
225  {
226  const phaseModel& otherPhase = fluid_.phases()[phasei];
227 
228  if (&otherPhase == &phase_) continue;
229 
230  const phaseInterface interface(phase_, otherPhase);
231 
232  if (fluid_.foundInterfacialModel<blendedDragModel>(interface))
233  {
234  *forceFields_[dragModel::typeName] +=
235  fluid_.lookupInterfacialModel<blendedDragModel>(interface).K()
236  *(otherPhase.U() - phase_.U());
237  }
238 
239  if (fluid_.foundInterfacialModel<blendedVirtualMassModel>(interface))
240  {
241  *forceFields_[virtualMassModel::typeName] +=
242  fluid_.lookupInterfacialModel
243  <blendedVirtualMassModel>(interface).K()
244  *(otherPhase.DUDt() - phase_.DUDt());
245  }
246 
247  if (fluid_.foundInterfacialModel<blendedLiftModel>(interface))
248  {
249  *forceFields_[liftModel::typeName] +=
250  (&interface.phase1() == &phase_ ? -1 : +1)
251  *fluid_.lookupInterfacialModel<blendedLiftModel>(interface).F();
252  }
253 
254  if
255  (
256  fluid_.foundInterfacialModel
257  <blendedWallLubricationModel>(interface)
258  )
259  {
260  *forceFields_[wallLubricationModel::typeName] +=
261  (&interface.phase1() == &phase_ ? -1 : +1)
262  *fluid_.lookupInterfacialModel
263  <blendedWallLubricationModel>(interface).F();
264  }
265 
266  if
267  (
268  fluid_.foundInterfacialModel
270  )
271  {
272  *forceFields_[turbulentDispersionModel::typeName] +=
273  fluid_.lookupInterfacialModel
274  <blendedTurbulentDispersionModel>(interface).D()
275  *fvc::grad
276  (
277  otherPhase
278  /max(phase_ + otherPhase, otherPhase.residualAlpha())
279  );
280  }
281  }
282 
283  return true;
284 }
285 
286 
288 {
290  (
292  forceFields_,
293  forceFieldIter
294  )
295  {
296  writeObject(forceFieldIter()->name());
297  }
298 
299  return true;
300 }
301 
302 
303 // ************************************************************************* //
static const Foam::dimensionedScalar D("D", Foam::dimTemperature, 257.14)
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object of type.
Definition: UList.H:477
Macros for easy insertion into run-time selection tables.
Generic GeometricField class.
A HashTable specialisation for hashing pointers.
Definition: HashPtrTable.H:67
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:99
static word groupName(Name name, const word &group)
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:76
tmp< volVectorField > F() const
Return lift force.
Definition: liftModel.C:58
tmp< volVectorField > F() const
Return wall lubrication force.
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:160
const word & name() const
Return const reference to name.
Abstract base-class for Time/database functionObjects.
Specialisation of Foam::functionObject for an Foam::fvMesh, providing a reference to the Foam::fvMesh...
const fvMesh & mesh_
Reference to the fvMesh.
This functionObject calculates and outputs the blended interfacial forces acting on a given phase,...
Definition: phaseForces.H:101
const phaseSystem & fluid_
Constant access to phaseSystem.
Definition: phaseForces.H:113
virtual bool read(const dictionary &dict)
Read the input data.
Definition: phaseForces.C:202
phaseForces(const word &name, const Time &runTime, const dictionary &)
Construct from Time and dictionary.
Definition: phaseForces.C:50
const phaseModel & phase_
Phase for which forces are evaluated.
Definition: phaseForces.H:110
virtual ~phaseForces()
Destructor.
Definition: phaseForces.C:196
HashPtrTable< volVectorField > forceFields_
Force fields.
Definition: phaseForces.H:107
virtual bool execute()
Calculate the force fields.
Definition: phaseForces.C:210
virtual bool write()
Write the force fields.
Definition: phaseForces.C:287
virtual bool read(const dictionary &)
Read optional controls.
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:406
Class to represent an interface between phases. Derivations can further specify the configuration of ...
const phaseModel & phase1() const
Return phase 1.
const dimensionedScalar & residualAlpha() const
Return the residual phase-fraction for given phase.
Definition: phaseModel.C:133
virtual tmp< volVectorField > DUDt() const =0
Return the substantive acceleration.
virtual tmp< volVectorField > U() const =0
Return the velocity.
const word & name() const
Return the name of this phase.
Definition: phaseModel.C:109
Class to represent a system of phases and model interfacial transfers between them.
Definition: phaseSystem.H:73
bool foundInterfacialModel(const phaseInterface &interface) const
Check availability of a sub model for a given interface.
const phaseModelList & phases() const
Return the phase models.
Definition: phaseSystemI.H:41
A class for handling words, derived from string.
Definition: word.H:62
Calculate the gradient of the given field.
K
Definition: pEqn.H:75
defineTypeNameAndDebug(adjustTimeStepToCombustion, 0)
addToRunTimeSelectionTable(functionObject, adjustTimeStepToCombustion, dictionary)
tmp< VolField< typename outerProduct< vector, Type >::type > > grad(const SurfaceField< Type > &ssf)
Definition: fvcGrad.C:46
Namespace for OpenFOAM.
static const zero Zero
Definition: zero.H:97
const dimensionSet dimForce
const dimensionSet dimVolume
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
dictionary dict