All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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-2022 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 {
41  defineTypeNameAndDebug(phaseForces, 0);
42  addToRunTimeSelectionTable(functionObject, phaseForces, dictionary);
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 
76  if (fluid_.foundInterfacialModel<blendedDragModel>(interface))
77  {
78  forceFields_.insert
79  (
80  dragModel::typeName,
81  new volVectorField
82  (
83  IOobject
84  (
85  IOobject::groupName("dragForce", phase_.name()),
86  mesh_.time().timeName(),
87  mesh_
88  ),
89  mesh_,
91  )
92  );
93  }
94 
95  if (fluid_.foundInterfacialModel<blendedVirtualMassModel>(interface))
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().timeName(),
110  mesh_
111  ),
112  mesh_,
114  )
115  );
116  }
117 
118  if (fluid_.foundInterfacialModel<blendedLiftModel>(interface))
119  {
120  forceFields_.insert
121  (
122  liftModel::typeName,
123  new volVectorField
124  (
125  IOobject
126  (
127  IOobject::groupName("liftForce", phase_.name()),
128  mesh_.time().timeName(),
129  mesh_
130  ),
131  mesh_,
133  )
134  );
135  }
136 
137  if
138  (
139  fluid_.foundInterfacialModel
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().timeName(),
156  mesh_
157  ),
158  mesh_,
160  )
161  );
162  }
163 
164  if
165  (
166  fluid_.foundInterfacialModel
167  <blendedTurbulentDispersionModel>(interface)
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().timeName(),
183  mesh_
184  ),
185  mesh_,
187  )
188  );
189  }
190  }
191 }
192 
193 
194 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
195 
197 {}
198 
199 
200 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
201 
202 bool Foam::functionObjects::phaseForces::read(const dictionary& dict)
203 {
205 
206  return true;
207 }
208 
209 
211 {
212  // Zero the force fields
214  (
215  HashPtrTable<volVectorField>,
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
269  <blendedTurbulentDispersionModel>(interface)
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  (
291  HashPtrTable<volVectorField>,
292  forceFields_,
293  forceFieldIter
294  )
295  {
296  writeObject(forceFieldIter()->name());
297  }
298 
299  return true;
300 }
301 
302 
303 // ************************************************************************* //
tmp< GeometricField< typename outerProduct< vector, Type >::type, fvPatchField, volMesh >> grad(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
Definition: fvcGrad.C:52
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
virtual bool read(const dictionary &dict)
Read the input data.
label phasei
Definition: pEqn.H:27
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object of type.
Definition: UList.H:477
addToRunTimeSelectionTable(functionObject, Qdot, dictionary)
dimensioned< vector > dimensionedVector
Dimensioned vector obtained from generic dimensioned type.
void read(Istream &, label &, const dictionary &)
In-place read with dictionary lookup.
GeometricField< vector, fvPatchField, volMesh > volVectorField
Definition: volFieldsFwd.H:59
Macros for easy insertion into run-time selection tables.
bool read(const char *, int32_t &)
Definition: int32IO.C:85
stressControl lookup("compactNormalStress") >> compactNormalStress
Calculate the gradient of the given field.
virtual ~phaseForces()
Destructor.
static word groupName(Name name, const word &group)
static const zero Zero
Definition: zero.H:97
const dimensionSet dimForce
virtual bool execute()
Calculate the force fields.
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
defineTypeNameAndDebug(Qdot, 0)
const dimensionSet dimVolume
phaseForces(const word &name, const Time &runTime, const dictionary &)
Construct from Time and dictionary.
virtual bool write()
Write the force fields.
Namespace for OpenFOAM.