OpenLB 1.7
Loading...
Searching...
No Matches
stokesDragForce3D.hh
Go to the documentation of this file.
1/* This file is part of the OpenLB library
2 *
3 * Copyright (C) 2016 Thomas Henn
4 * E-mail contact: info@openlb.net
5 * The most recent release of OpenLB can be downloaded at
6 * <http://www.openlb.net/>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public
19 * License along with this program; if not, write to the Free
20 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301, USA.
22 */
23
24#ifndef STOKESDRAGFORCE_3D_HH
25#define STOKESDRAGFORCE_3D_HH
26
27#include<cmath>
28#include "stokesDragForce3D.h"
29
30#ifndef M_PI
31#define M_PI 3.14159265358979323846
32#endif
33
34namespace olb {
35
36template<typename T, template<typename U> class PARTICLETYPE, typename DESCRIPTOR>
38 : Force3D<T, PARTICLETYPE>(),
39 _getVel(getVel),
40 _mu(mu)
41{
42 _C1 = 6. * M_PI * _mu * dT ;
43 _dTinv = 1. / dT;
44 _scaleFactor = 1.;
45}
46
47template<typename T, template<typename U> class PARTICLETYPE, typename DESCRIPTOR>
49 : Force3D<T, PARTICLETYPE>(),
50 _getVel(getVel)
51{
52 //implicit formulation
53 _C1 = 6. * M_PI * converter.getPhysViscosity() * converter.getPhysDensity() * converter.getConversionFactorTime();
54 _mu = converter.getPhysViscosity() * converter.getPhysDensity();
55 // explicit formulation
56 // _C1 = 6. * M_PI * converter.getDynamicViscosity();
57 _dTinv = 1. / converter.getConversionFactorTime();
58 _scaleFactor = 1. ;
59}
60
61template<typename T, template<typename U> class PARTICLETYPE, typename DESCRIPTOR>
63 : Force3D<T, PARTICLETYPE>(),
64 _getVel(getVel),
65 _scaleFactor(scaleFactor)
66{
67 //implicit formulation
68 _C1 = 6. * M_PI * converter.getPhysViscosity() * converter.getPhysDensity() * converter.getConversionFactorTime();
69 _mu = converter.getPhysViscosity() * converter.getPhysDensity();
70 // explicit formulation
71 // _C1 = 6. * M_PI * converter.getDynamicViscosity();
72 _dTinv = 1. / converter.getConversionFactorTime();
73}
74
76template<typename T, template<typename U> class PARTICLETYPE, typename DESCRIPTOR>
78 typename std::deque<PARTICLETYPE<T> >::iterator p, int pInt,
80{
81 T fluidVel[3] = {0., 0., 0.};
82
83 //implicit formulation
84 _getVel(fluidVel, &p->getPos()[0], p->getCuboid());
85 fluidVel[0] *= _scaleFactor;
86 fluidVel[1] *= _scaleFactor;
87 fluidVel[2] *= _scaleFactor;
88
89 T c = _C1 * p->getRad() * p->getInvMass();
90 T C2 = 1. / (1. + c);
91
92 // p->getVel() is particle velocity of the last time step
93 // formulation of new force with particle velocity of the last time step with
94 // implicit Euler
95 p->getForce()[0] += p->getMass() * _dTinv
96 * ((c * fluidVel[0] + p->getVel()[0]) * C2 - p->getVel()[0]);
97 p->getForce()[1] += p->getMass() * _dTinv
98 * ((c * fluidVel[1] + p->getVel()[1]) * C2 - p->getVel()[1]);
99 p->getForce()[2] += p->getMass() * _dTinv
100 * ((c * fluidVel[2] + p->getVel()[2]) * C2 - p->getVel()[2]);
101}
102
103template<typename T, template<typename U> class PARTICLETYPE, typename DESCRIPTOR>
105 int pInt, ParticleSystem3D<T, PARTICLETYPE>* psSys, T force[3])
106{
107 T fluidVel[3] = {0., 0., 0.};
108
109 _getVel(fluidVel, &psSys->operator[](pInt).getPos()[0], psSys->operator[](pInt).getCuboid());
110
111 T c = _C1 * psSys->operator[](pInt).getRad() * psSys->operator[](pInt).getInvMass();
112 T C2 = 1. / (1. + c);
113 T mass = psSys->operator[](pInt).getMass();
114 std::vector<T> vel = psSys->operator[](pInt).getVel();
115 force[0] = mass * _dTinv * ((c * fluidVel[0] + vel[0]) * C2 - vel[0]);
116 force[1] = mass * _dTinv * ((c * fluidVel[1] + vel[1]) * C2 - vel[1]);
117 force[2] = mass * _dTinv * ((c * fluidVel[2] + vel[2]) * C2 - vel[2]);
118}
119
120}
121#endif /* STOKESDRAGFORCE_3D_HH */
#define M_PI
Prototype for all particle forces.
Definition force3D.h:43
StokesDragForce3D(SuperLatticeInterpPhysVelocity3D< T, DESCRIPTOR > &getVel, T dT, T mu)
Constructor, FluidVelocity, physicalTimeStep, physicalDynamicViscosity.
void computeForce(int pInt, ParticleSystem3D< T, PARTICLETYPE > *psSys, T force[3])
Compute Force for subgrid scale particles.
void applyForce(typename std::deque< PARTICLETYPE< T > >::iterator p, int pInt, ParticleSystem3D< T, PARTICLETYPE > &psSys) override
6 Pi r mu (u_f-u_p)
Conversion between physical and lattice units, as well as discretization.
constexpr T getPhysDensity() const
return density in physical units
constexpr T getPhysViscosity() const
return viscosity in physical units
constexpr T getConversionFactorTime() const
access (read-only) to private member variable
Top level namespace for all of OpenLB.