OpenLB 1.7
Loading...
Searching...
No Matches
advectionDiffusionForces.hh
Go to the documentation of this file.
1/* This file is part of the OpenLB library
2 *
3 * Copyright (C) 2016 Robin Trunk
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 ADVECTION_DIFFUSION_FORCES_HH
25#define ADVECTION_DIFFUSION_FORCES_HH
26
28
29namespace olb {
30
31template<typename T, typename DESCRIPTOR,
32 typename ADLattice>
34{
35 initArg = 8;
36 dragCoeff = (converter_.getCharPhysVelocity()*converter_.getConversionFactorTime()) / (St_ * converter_.getCharPhysLength());
37}
38
39template<typename T, typename DESCRIPTOR,
40 typename ADLattice>
42{
43 initArg = 8;
44 dragCoeff = (9.*converter_.getPhysViscosity()*converter_.getPhysDensity()*converter_.getConversionFactorTime()) / (2.*pRho_*pRadius_*pRadius_);
45}
46
47template<typename T, typename DESCRIPTOR,
48 typename ADLattice>
50{
51 T velF[3] = {0.,0.,0.};
52 nsCell->computeU(velF);
53 for (int i=0; i < DESCRIPTOR::d; i++) {
54 force[i] += dragCoeff*(velF[i]-vel[i]);
55 }
56}
57
58template<typename T, typename DESCRIPTOR,
59typename ADLattice>
61{
62 initArg = 8;
63 dragCoeff = (9.*converter_.getPhysViscosity()*converter_.getPhysDensity()*converter_.getConversionFactorTime()) / (2.*pRho_*pRadius_*pRadius_);
64 Re_pCoeff = 2.*pRadius_/converter_.getPhysViscosity();
65}
66
67template<typename T, typename DESCRIPTOR,
68typename ADLattice>
70{
71 T velF[3] = {0.,0.,0.};
72 nsCell->computeU(velF);
73 T magVelF = pow((pow(velF[0],2.)+pow(velF[1],2.)+pow(velF[2],2.)),0.5);
74 T magVel = pow((pow(vel[0],2.)+pow(vel[1],2.)+pow(vel[2],2.)),0.5);
75 T Re_p = Re_pCoeff*abs(magVelF - magVel);
76 for (int i=0; i < DESCRIPTOR::d; i++) {
77 force[i] += dragCoeff*(1. + 0.15*pow(Re_p,0.687))*(velF[i]-vel[i]);
78 }
79}
80
81template<typename T, typename DESCRIPTOR,
82typename ADLattice>
84{
85 initArg = 8;
86 densDiff = (pRho_ - converter_.getPhysDensity())*converter_.getConversionFactorTime()/pRho_;
87 gravity[0] = converter_.getLatticeVelocity(g[0]);
88 gravity[1] = converter_.getLatticeVelocity(g[1]);
89 gravity[2] = converter_.getLatticeVelocity(g[2]);
90}
91
92template<typename T, typename DESCRIPTOR,
93typename ADLattice>
95{
96 for (int i=0; i < DESCRIPTOR::d; i++) {
97 force[i] += densDiff*gravity[i];
98 }
99}
100
101template<typename T, typename DESCRIPTOR,
102typename ADLattice>
104 const UnitConverter<T,DESCRIPTOR>& converter_, std::vector<T> axisPoint_, std::vector<T> axisDirection_,
105 T w_, T* frac_, bool centrifugeForceOn_, bool coriolisForceOn_) :
106 sg(superGeometry_), axisPoint(axisPoint_), axisDirection(axisDirection_),
107 w(w_), frac(frac_), centrifugeForceOn(centrifugeForceOn_), coriolisForceOn(coriolisForceOn_)
108{
110}
111
112template<typename T, typename DESCRIPTOR,
113 typename ADLattice>
115{
116 std::vector<T> F_centri(3,0);
117 std::vector<T> F_coriolis(3,0);
118 T wf = w*(*frac);
119// if ( this->_sLattice.getLoadBalancer().rank(latticeR[0]) == singleton::mpi().getRank() ) {
120 // local coords are given, fetch local cell and compute value(s)
121 std::vector<T> physR(3,T());
122 this->sg.getCuboidGeometry().getPhysR(&(physR[0]),&(latticeR[0]));
123
124 T scalar = (physR[0]-axisPoint[0])*axisDirection[0]
125 +(physR[1]-axisPoint[1])*axisDirection[1]
126 +(physR[2]-axisPoint[2])*axisDirection[2];
127
128 if (centrifugeForceOn) {
129 F_centri[0] = wf*wf*(physR[0]-axisPoint[0]-scalar*axisDirection[0]);
130 F_centri[1] = wf*wf*(physR[1]-axisPoint[1]-scalar*axisDirection[1]);
131 F_centri[2] = wf*wf*(physR[2]-axisPoint[2]-scalar*axisDirection[2]);
132 }
133 if (coriolisForceOn) {
134 F_coriolis[0] = -2*wf*(axisDirection[1]*vel[2]-axisDirection[2]*vel[1]);
135 F_coriolis[1] = -2*wf*(axisDirection[2]*vel[0]-axisDirection[0]*vel[2]);
136 F_coriolis[2] = -2*wf*(axisDirection[0]*vel[1]-axisDirection[1]*vel[0]);
137 }
138 force[0] += (F_coriolis[0]+F_centri[0])*invMassLessForce;
139 force[1] += (F_coriolis[1]+F_centri[1])*invMassLessForce;
140 force[2] += (F_coriolis[2]+F_centri[2])*invMassLessForce;
141// }
142}
143
144template<typename T, typename DESCRIPTOR,
145 typename ADLattice>
146AdvDiffMagneticWireForce3D<T,DESCRIPTOR,ADLattice>::AdvDiffMagneticWireForce3D(SuperGeometry<T,3>& superGeometry_, UnitConverter<T,DESCRIPTOR> const& converter_, T pMass, AnalyticalF<3,T, T>& getMagForce) : sg(superGeometry_), _getMagForce(getMagForce)
147{
148 initArg = 8;
149 _pMass = converter_.getConversionFactorTime() / pMass;
150 _conversionVelocity = converter_.getConversionFactorVelocity();
151}
152
153template<typename T, typename DESCRIPTOR,
154 typename ADLattice>
156{
157 std::vector<T> physR(3,T());
158 this->sg.getCuboidGeometry().getPhysR(&(physR[0]),&(latticeR[0]));
159 T pos[3] = { T(), T(), T() };
160 pos[0] = physR[0];
161 pos[1] = physR[1];
162 pos[2] = physR[2];
163 T forceHelp[3] = { T(), T(), T() };
164 _getMagForce(forceHelp, pos);
165 for (int i=0; i < DESCRIPTOR::d; i++) {
166 force[i] += forceHelp[i] * _pMass / _conversionVelocity;
167// std::cout << "----->>>>> force " << forceHelp[i] << std::endl;
168 }
169}
170
171
172}
173#endif
AdvDiffBuoyancyForce3D(UnitConverter< T, DESCRIPTOR > const &converter_, Vector< T, 3 > g, T pRho_)
void applyForce(T force[], Cell< T, DESCRIPTOR > *nsCell, Cell< T, ADLattice > *adCell, T vel[], int latticeR[]) override
AdvDiffDragForce3D(UnitConverter< T, DESCRIPTOR > const &converter_, T St_)
void applyForce(T force[], Cell< T, DESCRIPTOR > *nsCell, Cell< T, ADLattice > *adCell, T vel[], int latticeR[]) override
AdvDiffMagneticWireForce3D(SuperGeometry< T, 3 > &superGeometry_, UnitConverter< T, DESCRIPTOR > const &converter_, T pMass, AnalyticalF< 3, T, T > &getMagForce)
void applyForce(T force[], Cell< T, DESCRIPTOR > *nsCell, Cell< T, ADLattice > *adCell, T vel[], int latticeR[]) override
void applyForce(T force[], Cell< T, DESCRIPTOR > *nsCell, Cell< T, ADLattice > *adCell, T vel[], int latticeR[])
AdvDiffRotatingForce3D(SuperGeometry< T, 3 > &superGeometry_, const UnitConverter< T, DESCRIPTOR > &converter_, std::vector< T > axisPoint_, std::vector< T > axisDirection_, T w_, T *frac_, bool centrifugeForceOn_=true, bool coriolisForceOn_=true)
void applyForce(T force[], Cell< T, DESCRIPTOR > *nsCell, Cell< T, ADLattice > *adCell, T vel[], int latticeR[]) override
AdvDiffSNDragForce3D(UnitConverter< T, DESCRIPTOR > const &converter_, T pRadius_, T pRho_)
AnalyticalF are applications from DD to XD, where X is set by the constructor.
Highest-level interface to Cell data.
Definition cell.h:148
void computeU(T u[descriptors::d< DESCRIPTOR >()]) const
Compute fluid velocity on the cell.
Definition cell.hh:212
Representation of a statistic for a parallel 2D geometry.
Conversion between physical and lattice units, as well as discretization.
constexpr T getCharPhysLength() const
return characteristic length in physical units
constexpr T getPhysDensity() const
return density in physical units
constexpr T getConversionFactorLength() const
access (read-only) to private member variable
constexpr T getConversionFactorVelocity() const
access (read-only) to private member variable
constexpr T getPhysViscosity() const
return viscosity in physical units
constexpr T getLatticeVelocity(T physVelocity) const
conversion from physical to lattice velocity
constexpr T getCharPhysVelocity() const
return characteristic velocity in physical units
constexpr T getConversionFactorTime() const
access (read-only) to private member variable
Plain old scalar vector.
Definition vector.h:47
Top level namespace for all of OpenLB.
std::enable_if_t< std::is_arithmetic< T >::type::value, T > abs(T x)
Definition util.h:396