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-2020 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"
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 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * * //
48 
49 template<class modelType>
51 Foam::functionObjects::phaseForces::nonDragForce(const phasePair& pair) const
52 {
53  const BlendedInterfacialModel<modelType>& model =
54  fluid_.lookupBlendedSubModel<modelType>(pair);
55 
56  if (&pair.phase1() == &phase_)
57  {
58  return -model.template F<vector>();
59  }
60  else
61  {
62  return model.template F<vector>();
63  }
64 }
65 
66 
67 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
68 
70 (
71  const word& name,
72  const Time& runTime,
73  const dictionary& dict
74 )
75 :
76  fvMeshFunctionObject(name, runTime, dict),
77  phase_
78  (
79  mesh_.lookupObject<phaseModel>
80  (
81  IOobject::groupName("alpha", dict.lookup("phase"))
82  )
83  ),
84  fluid_(mesh_.lookupObject<phaseSystem>("phaseProperties"))
85 {
86  read(dict);
87 
89  (
91  fluid_.phasePairs(),
92  pairIter
93  )
94  {
95  const phasePair& pair = pairIter();
96 
97  if (pair.contains(phase_) && !pair.ordered())
98  {
99  if (fluid_.foundBlendedSubModel<dragModel>(pair))
100  {
101  forceFields_.insert
102  (
103  dragModel::typeName,
104  new volVectorField
105  (
106  IOobject
107  (
108  IOobject::groupName("dragForce", phase_.name()),
109  mesh_.time().timeName(),
110  mesh_
111  ),
112  mesh_,
114  )
115  );
116  }
117 
118  if (fluid_.foundBlendedSubModel<virtualMassModel>(pair))
119  {
120  forceFields_.insert
121  (
122  virtualMassModel::typeName,
123  new volVectorField
124  (
125  IOobject
126  (
128  (
129  "virtualMassForce",
130  phase_.name()
131  ),
132  mesh_.time().timeName(),
133  mesh_
134  ),
135  mesh_,
137  )
138  );
139  }
140 
141  if (fluid_.foundBlendedSubModel<liftModel>(pair))
142  {
143  forceFields_.insert
144  (
145  liftModel::typeName,
146  new volVectorField
147  (
148  IOobject
149  (
150  IOobject::groupName("liftForce", phase_.name()),
151  mesh_.time().timeName(),
152  mesh_
153  ),
154  mesh_,
156  )
157  );
158  }
159 
160  if (fluid_.foundBlendedSubModel<wallLubricationModel>(pair))
161  {
162  forceFields_.insert
163  (
164  wallLubricationModel::typeName,
165  new volVectorField
166  (
167  IOobject
168  (
170  (
171  "wallLubricationForce",
172  phase_.name()
173  ),
174  mesh_.time().timeName(),
175  mesh_
176  ),
177  mesh_,
179  )
180  );
181  }
182 
183  if (fluid_.foundBlendedSubModel<turbulentDispersionModel>(pair))
184  {
185  forceFields_.insert
186  (
187  turbulentDispersionModel::typeName,
188  new volVectorField
189  (
190  IOobject
191  (
193  (
194  "turbulentDispersionForce",
195  phase_.name()
196  ),
197  mesh_.time().timeName(),
198  mesh_
199  ),
200  mesh_,
202  )
203  );
204  }
205  }
206  }
207 }
208 
209 
210 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
211 
213 {}
214 
215 
216 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
217 
219 {
221 
222  return true;
223 }
224 
225 
227 {
228  // Zero the force fields
230  (
231  HashPtrTable<volVectorField>,
232  forceFields_,
233  forceFieldIter
234  )
235  {
236  *forceFieldIter() = Zero;
237  }
238 
239  // Add the forces from all the interfaces which contain this phase
241  (
243  fluid_.phasePairs(),
244  pairIter
245  )
246  {
247  const phasePair& pair = pairIter();
248 
249  if (pair.contains(phase_) && !pair.ordered())
250  {
251  if (fluid_.foundBlendedSubModel<dragModel>(pair))
252  {
253  *forceFields_[dragModel::typeName] +=
254  fluid_.lookupBlendedSubModel<dragModel>(pair).K()
255  *(pair.otherPhase(phase_).U() - phase_.U());
256  }
257 
258  if (fluid_.foundBlendedSubModel<virtualMassModel>(pair))
259  {
260  *forceFields_[virtualMassModel::typeName] +=
261  fluid_.lookupBlendedSubModel<virtualMassModel>(pair).K()
262  *(pair.otherPhase(phase_).DUDt() - phase_.DUDt());
263  }
264 
265  if (fluid_.foundBlendedSubModel<liftModel>(pair))
266  {
267  *forceFields_[liftModel::typeName] +=
268  nonDragForce<liftModel>(pair);
269  }
270 
271  if (fluid_.foundBlendedSubModel<wallLubricationModel>(pair))
272  {
273  *forceFields_[wallLubricationModel::typeName] +=
274  nonDragForce<wallLubricationModel>(pair);
275  }
276 
277  if (fluid_.foundBlendedSubModel<turbulentDispersionModel>(pair))
278  {
279  *forceFields_[turbulentDispersionModel::typeName] +=
280  nonDragForce<turbulentDispersionModel>(pair);
281  }
282  }
283  }
284 
285  return true;
286 }
287 
288 
290 {
292  (
293  HashPtrTable<volVectorField>,
294  forceFields_,
295  forceFieldIter
296  )
297  {
298  writeObject(forceFieldIter()->name());
299  }
300 
301  return true;
302 }
303 
304 
305 // ************************************************************************* //
virtual bool read(const dictionary &dict)
Read the input data.
HashTable< autoPtr< phasePair >, phasePairKey, phasePairKey::hash > phasePairTable
Definition: phaseSystem.H:87
IOobject(const word &name, const fileName &instance, const objectRegistry &registry, readOption r=NO_READ, writeOption w=NO_WRITE, bool registerObject=true)
Construct from name, instance, registry, io options.
Definition: IOobject.C:177
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:58
CGAL::Exact_predicates_exact_constructions_kernel K
virtual bool read()
Read the transportProperties dictionary and update.
Macros for easy insertion into run-time selection tables.
dictionary()
Construct top-level dictionary null.
Definition: dictionary.C:464
const dimensionSet dimVolume(pow3(dimLength))
Definition: dimensionSets.H:58
stressControl lookup("compactNormalStress") >> compactNormalStress
virtual ~phaseForces()
Destructor.
static word groupName(Name name, const word &group)
static const zero Zero
Definition: zero.H:97
const word & name() const
Name function is needed to disambiguate those inherited.
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
Definition: pEqn.H:29
virtual bool execute()
Calculate the force fields.
const dimensionSet dimForce
defineTypeNameAndDebug(Qdot, 0)
tmp< volVectorField > nonDragForce(const phasePair &key) const
Evaluate and return non-drag force.
virtual bool writeObject(IOstream::streamFormat, IOstream::versionNumber, IOstream::compressionType, const bool write) const
Write using given format, version and compression.
A class for managing temporary objects.
Definition: PtrList.H:53
phaseForces(const word &name, const Time &runTime, const dictionary &)
Construct from Time and dictionary.
virtual bool write()
Write the force fields.
Namespace for OpenFOAM.