Loading...
Searching...
No Matches
phaseForces.C
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ========= |
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4 \\ / O peration |
5 \\ / A nd | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2018-2019 OpenFOAM Foundation
9-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM.
12
13 OpenFOAM is free software: you can redistribute it and/or modify it
14 under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26\*---------------------------------------------------------------------------*/
27
28#include "phaseForces.H"
30#include "BlendedInterfacialModel.H"
31#include "dragModel.H"
32#include "virtualMassModel.H"
33#include "liftModel.H"
34#include "wallLubricationModel.H"
35#include "turbulentDispersionModel.H"
37// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
38
39namespace Foam
40{
41namespace functionObjects
42{
43 defineTypeNameAndDebug(phaseForces, 0);
45}
46}
47
48
49// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * * //
50
51template<class modelType>
53Foam::functionObjects::phaseForces::nonDragForce(const phasePair& pair) const
54{
56 fluid_.lookupBlendedSubModel<modelType>(pair);
57
58 if (&pair.phase1() == &phase_)
59 {
60 return model.template F<vector>();
61 }
62 else
63 {
64 return -model.template F<vector>();
65 }
66}
67
68
69// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
70
71Foam::functionObjects::phaseForces::phaseForces
72(
73 const word& name,
74 const Time& runTime,
75 const dictionary& dict
76)
77:
78 fvMeshFunctionObject(name, runTime, dict),
79 phase_
80 (
81 mesh_.lookupObject<phaseModel>
82 (
83 IOobject::groupName("alpha", dict.get<word>("phase"))
84 )
85 ),
86 fluid_(mesh_.lookupObject<phaseSystem>("phaseProperties"))
87{
88 read(dict);
89
91 (
93 fluid_.phasePairs(),
94 iter
95 )
96 {
97 const phasePair& pair = iter();
98
99 if (pair.contains(phase_) && !pair.ordered())
100 {
101 if (fluid_.foundBlendedSubModel<dragModel>(pair))
102 {
103 forceFields_.set
104 (
105 dragModel::typeName,
107 (
108 IOobject
109 (
110 IOobject::groupName("dragForce", phase_.name()),
111 mesh_.time().timeName(),
112 mesh_
113 ),
114 mesh_,
116 )
117 );
118 }
119
120 if (fluid_.foundBlendedSubModel<virtualMassModel>(pair))
121 {
122 forceFields_.set
123 (
124 virtualMassModel::typeName,
126 (
127 IOobject
128 (
130 (
131 "virtualMassForce",
132 phase_.name()
133 ),
134 mesh_.time().timeName(),
135 mesh_
136 ),
137 mesh_,
139 )
140 );
141 }
142
143 if (fluid_.foundBlendedSubModel<liftModel>(pair))
144 {
145 forceFields_.set
146 (
147 liftModel::typeName,
149 (
150 IOobject
151 (
152 IOobject::groupName("liftForce", phase_.name()),
153 mesh_.time().timeName(),
154 mesh_
155 ),
156 mesh_,
158 )
159 );
160 }
161
162 if (fluid_.foundBlendedSubModel<wallLubricationModel>(pair))
163 {
164 forceFields_.set
165 (
166 wallLubricationModel::typeName,
168 (
169 IOobject
170 (
172 (
173 "wallLubricationForce",
174 phase_.name()
175 ),
176 mesh_.time().timeName(),
177 mesh_
178 ),
179 mesh_,
181 )
182 );
183 }
184
185 if (fluid_.foundBlendedSubModel<turbulentDispersionModel>(pair))
186 {
187 forceFields_.set
188 (
189 turbulentDispersionModel::typeName,
191 (
192 IOobject
193 (
195 (
196 "turbulentDispersionForce",
197 phase_.name()
198 ),
199 mesh_.time().timeName(),
200 mesh_
201 ),
202 mesh_,
204 )
205 );
206 }
207 }
208 }
209}
210
211
212// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
213
214Foam::functionObjects::phaseForces::~phaseForces()
215{}
216
217
218// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
219
220bool Foam::functionObjects::phaseForces::read(const dictionary& dict)
221{
222 fvMeshFunctionObject::read(dict);
223
224 return true;
225}
226
227
228bool Foam::functionObjects::phaseForces::execute()
229{
231 (
233 forceFields_,
234 iter
235 )
236 {
237 const word& type = iter.key();
238 volVectorField& force = *iter();
239
240 force *= 0.0;
241
243 (
245 fluid_.phasePairs(),
246 iter2
247 )
248 {
249 const phasePair& pair = iter2();
250
251 if (pair.contains(phase_) && !pair.ordered())
252 {
253 if (type == "dragModel")
254 {
255 force +=
256 fluid_.lookupBlendedSubModel<dragModel>(pair).K()
257 *(pair.otherPhase(phase_).U() - phase_.U());
258 }
259
260 if (type == "virtualMassModel")
261 {
262 force +=
263 fluid_.lookupBlendedSubModel<virtualMassModel>(pair).K()
264 *(
265 pair.otherPhase(phase_).DUDt()
266 - phase_.DUDt()
267 );
268 }
269
270 if (type == "liftModel")
271 {
272 force = nonDragForce<liftModel>(pair);
273 }
274
275 if (type == "wallLubricationModel")
276 {
277 force = nonDragForce<wallLubricationModel>(pair);
278 }
279
280 if (type == "turbulentDispersionModel")
281 {
282 force = nonDragForce<turbulentDispersionModel>(pair);
283 }
284 }
285 }
286 }
287
288 return true;
289}
290
291
292bool Foam::functionObjects::phaseForces::write()
293{
295 (
297 forceFields_,
298 iter
299 )
300 {
301 writeObject(iter()->name());
302 }
303
304 return true;
305}
306
307
308// ************************************************************************* //
CGAL::Exact_predicates_exact_constructions_kernel K
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
A HashTable of pointers to objects of type <T>, with deallocation management of the pointers.
static word groupName(StringType base, const word &group)
Create dot-delimited name.group string.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
Abstract base-class for Time/database function objects.
Description for mass transfer between a pair of phases. The direction of the mass transfer is from th...
Definition phasePair.H:52
const multiphaseInter::phaseModel & phase1() const
Definition phasePairI.H:23
HashTable< autoPtr< phasePair >, phasePairKey, phasePairKey::hash > phasePairTable
Definition phaseSystem.H:89
A class for managing temporary objects.
Definition tmp.H:75
A class for handling words, derived from Foam::string.
Definition word.H:66
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition className.H:142
U
Definition pEqn.H:72
engineTime & runTime
auto & name
volVectorField F(fluid.F())
List< ReturnType > get(const UPtrList< T > &list, const AccessOp &aop)
List of values generated by applying the access operation to each list item.
Function objects are OpenFOAM utilities to ease workflow configurations and enhance workflows.
Namespace for OpenFOAM.
GeometricField< vector, fvPatchField, volMesh > volVectorField
bool read(const char *buf, int32_t &val)
Same as readInt32.
Definition int32.H:127
const dimensionSet dimForce
const dimensionSet dimVolume(pow3(dimLength))
dimensioned< vector > dimensionedVector
Dimensioned vector obtained from generic dimensioned type.
dictionary dict
#define forAllIter(Container, container, iter)
Iterate across all elements in the container object.
Definition stdFoam.H:334
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object.
Definition stdFoam.H:356