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"
36
37// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
38
39namespace Foam
40{
41namespace functionObjects
42{
45}
46}
47
48
49// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * * //
50
51template<class modelType>
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
72(
73 const word& name,
74 const Time& runTime,
75 const dictionary& dict
76)
77:
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 (
94 iter
95 )
96 {
97 const phasePair& pair = iter();
98
99 if (pair.contains(phase_) && !pair.ordered())
100 {
102 {
103 forceFields_.set
104 (
107 (
109 (
110 IOobject::groupName("dragForce", phase_.name()),
111 mesh_.time().timeName(),
112 mesh_
113 ),
114 mesh_,
116 )
117 );
118 }
119
121 {
122 forceFields_.set
123 (
126 (
128 (
130 (
131 "virtualMassForce",
132 phase_.name()
133 ),
134 mesh_.time().timeName(),
135 mesh_
136 ),
137 mesh_,
139 )
140 );
141 }
142
144 {
145 forceFields_.set
146 (
149 (
151 (
152 IOobject::groupName("liftForce", phase_.name()),
153 mesh_.time().timeName(),
154 mesh_
155 ),
156 mesh_,
158 )
159 );
160 }
161
163 {
164 forceFields_.set
165 (
168 (
170 (
172 (
173 "wallLubricationForce",
174 phase_.name()
175 ),
176 mesh_.time().timeName(),
177 mesh_
178 ),
179 mesh_,
181 )
182 );
183 }
184
186 {
187 forceFields_.set
188 (
191 (
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
215{}
216
217
218// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
219
221{
223
224 return true;
225}
226
227
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
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.
Definition: HashPtrTable.H:68
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:170
static word groupName(StringType base, const word &group)
Create dot-delimited name.group string.
virtual bool read()
Re-read model coefficients if they have changed.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:80
static word timeName(const scalar t, const int precision=precision_)
Definition: Time.C:780
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
Abstract base-class for Time/database function objects.
Specialization of Foam::functionObject for an Foam::fvMesh, providing a reference to the Foam::fvMesh...
const fvMesh & mesh_
Reference to the fvMesh.
This function object calculates and outputs the blended interfacial forces acting on a given phase,...
Definition: phaseForces.H:106
const phaseSystem & fluid_
Constant access to phaseSystem.
Definition: phaseForces.H:126
tmp< volVectorField > nonDragForce(const phasePair &key) const
Evaluate and return non-drag force.
virtual bool read(const dictionary &dict)
Read the input data.
Definition: phaseForces.C:220
const phaseModel & phase_
Phase for which forces are evaluated.
Definition: phaseForces.H:123
virtual ~phaseForces()
Destructor.
Definition: phaseForces.C:214
HashPtrTable< volVectorField > forceFields_
Definition: phaseForces.H:120
virtual bool execute()
Calculate the force fields.
Definition: phaseForces.C:228
virtual bool write()
Write the force fields.
Definition: phaseForces.C:292
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:290
Single incompressible phase derived from the phase-fraction. Used as part of the multiPhaseMixture fo...
Definition: phaseModel.H:61
const volVectorField & U() const
Definition: phaseModel.H:176
virtual tmp< volVectorField > DUDt() const =0
Return the substantive acceleration.
const word & name() const
Definition: phaseModel.H:144
bool ordered() const noexcept
Return the ordered flag.
Definition: phasePairKey.H:98
Description for mass transfer between a pair of phases. The direction of the mass transfer is from th...
Definition: phasePair.H:56
const phaseModel & otherPhase(const phaseModel &phase) const
Return the other phase relative to the given phase.
Definition: phasePairI.H:49
bool contains(const phaseModel &phase) const
Return true if this phasePair contains the given phase.
Definition: phasePairI.H:42
const multiphaseInter::phaseModel & phase1() const
Definition: phasePairI.H:30
Class to represent a system of phases and model interfacial transfers between them.
Definition: phaseSystem.H:76
const phasePairTable & phasePairs() const
Return the phase pairs.
Definition: phaseSystemI.H:107
const BlendedInterfacialModel< modelType > & lookupBlendedSubModel(const phasePair &key) const
Return a blended sub model between a phase pair.
bool foundBlendedSubModel(const phasePair &key) const
Check availability of a blended sub model for a given phase pair.
A class for managing temporary objects.
Definition: tmp.H:65
A class for handling words, derived from Foam::string.
Definition: word.H:68
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition: className.H:121
engineTime & runTime
Namespace for OpenFOAM.
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition: MSwindows.C:598
const dimensionSet dimForce
const dimensionSet dimVolume(pow3(dimLength))
Definition: dimensionSets.H:60
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
dictionary dict
#define forAllIter(Container, container, iter)
Iterate across all elements in the container object.
Definition: stdFoam.H:362
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object.
Definition: stdFoam.H:381
static const char *const typeName
The type name used in ensight case files.