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-2019 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 
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  iter
93  )
94  {
95  const phasePair& pair = iter();
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 
218 bool Foam::functionObjects::phaseForces::read(const dictionary& dict)
219 {
221 
222  return true;
223 }
224 
225 
227 {
228  forAllIter
229  (
230  HashPtrTable<volVectorField>,
231  forceFields_,
232  iter
233  )
234  {
235  const word& type = iter.key();
236  volVectorField& force = *iter();
237 
238  force = Zero;
239 
241  (
243  fluid_.phasePairs(),
244  iter2
245  )
246  {
247  const phasePair& pair = iter2();
248 
249  if (pair.contains(phase_) && !pair.ordered())
250  {
251  if (type == "dragModel")
252  {
253  force +=
254  fluid_.lookupBlendedSubModel<dragModel>(pair).K()
255  *(pair.otherPhase(phase_).U() - phase_.U());
256  }
257 
258  if (type == "virtualMassModel")
259  {
260  force +=
261  fluid_.lookupBlendedSubModel<virtualMassModel>(pair).K()
262  *(
263  pair.otherPhase(phase_).DUDt()
264  - phase_.DUDt()
265  );
266  }
267 
268  if (type == "liftModel")
269  {
270  force = nonDragForce<liftModel>(pair);
271  }
272 
273  if (type == "wallLubricationModel")
274  {
275  force = nonDragForce<wallLubricationModel>(pair);
276  }
277 
278  if (type == "turbulentDispersionModel")
279  {
280  force = nonDragForce<turbulentDispersionModel>(pair);
281  }
282  }
283  }
284  }
285 
286  return true;
287 }
288 
289 
291 {
292  forAllIter
293  (
294  HashPtrTable<volVectorField>,
295  forceFields_,
296  iter
297  )
298  {
299  writeObject(iter()->name());
300  }
301 
302  return true;
303 }
304 
305 
306 // ************************************************************************* //
virtual bool read(const dictionary &dict)
Read the input data.
HashTable< autoPtr< phasePair >, phasePairKey, phasePairKey::hash > phasePairTable
Definition: phaseSystem.H:87
#define forAllIter(Container, container, iter)
Iterate across all elements in the container object of type.
Definition: UList.H:459
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:55
CGAL::Exact_predicates_exact_constructions_kernel K
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.
static word groupName(Name name, const word &group)
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
defineTypeNameAndDebug(Qdot, 0)
tmp< volVectorField > nonDragForce(const phasePair &key) const
Evaluate and return non-drag force.
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.