OpenLB 1.7
Loading...
Searching...
No Matches
momentumExchangeForce.h
Go to the documentation of this file.
1/* This file is part of the OpenLB library
2 *
3 * Copyright (C) 2021 Nicolas Hafen, Mathias J. Krause
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
25
26#ifndef MOMENTUM_EXCHANGE_FORCE_H
27#define MOMENTUM_EXCHANGE_FORCE_H
28
29
30namespace olb {
31
32namespace particles {
33
34namespace resolved {
35
36
37template<typename T, unsigned D, bool useLadd=false>
39template<typename T>
40//Momentum Exchange Wen2014
42 static constexpr T calculate( T f1, T f2, T c, T pVel, T deltaR )
43 {
44 return (f1*(c-pVel) + f2*(c+pVel))*(1./deltaR) ;
45 }
46};
47template<typename T>
49 static constexpr T calculate( T f1, T f2, T c, T pVel, T deltaR )
50 {
51 return (f1*(c-pVel) + f2*(c+pVel));
52 }
53};
54//Momentum Exchange Ladd1994
55template<typename T>
57 static constexpr T calculate( T f1, T f2, T c, T pVel, T deltaR )
58 {
59 return ((f1 + f2)*c)*(1./deltaR) ;
60 }
61};
62template<typename T>
64 static constexpr T calculate( T f1, T f2, T c, T pVel, T deltaR )
65 {
66 return ((f1 + f2)*c);
67 }
68};
69
70
71
72//Evaluate local momentum exchange contribution and return whether particle and bulk found
73template<typename T, typename DESCRIPTOR, typename PARTICLETYPE>
75 T momentumExchange[],
77 const LatticeR<DESCRIPTOR::d>& latticeRinner,
78 const BlockGeometry<T,DESCRIPTOR::d>& blockGeometry,
79 BlockLattice<T,DESCRIPTOR>& blockLattice,
80 const UnitConverter<T,DESCRIPTOR>& converter,
82 const int bulkMaterial = 1
83)
84{
85
86 using namespace descriptors;
87 constexpr unsigned D = DESCRIPTOR::d;
88 auto position = particle.template getField<GENERAL,POSITION>();
89
90 //Retrieve grid spacing
91 const T deltaR = blockGeometry.getDeltaR();
92 //Get inner phys position
93 T physRinner[D] = { };
94 blockGeometry.getPhysR(physRinner, latticeRinner);
95 //Retrieve inner porosity
96 T porosityInner[1] = { };
97 particles::resolved::evalSolidVolumeFraction(porosityInner, physRinner, particle);
98 //Check whether particle and bulk is existent at location
99 if ( !util::nearZero(porosityInner[0]) && blockGeometry.get(latticeRinner)==bulkMaterial ) {
100 //Loop over distribution functions
101 for (int iPop = 1; iPop < DESCRIPTOR::q ; ++iPop) {
102 //Calculate outer lattice position (get next cell located in current direction)
103 const Vector<int,D> c = descriptors::c<DESCRIPTOR>(iPop);
104 const LatticeR<D> latticeRouter = latticeRinner + c;
105 //Retrieve outer phys position
106 T physRouter[D] = {0.};
107 blockGeometry.getPhysR(physRouter, latticeRouter);
108 //Retrieve outer porosity
109 T porosityOuter[1] = {0.};
110 particles::resolved::evalSolidVolumeFraction(porosityOuter, physRouter, particle);
111 //if not both cells are in the full solid domain calculate force
112 if ( !(porosityInner[0]==1 && porosityOuter[0]==1) ) {
113 //Momentum Exchange Wen
114 const T f1 = blockLattice.get( latticeRouter )[iPop];
115 const T f2 = blockLattice.get( latticeRinner )[descriptors::opposite<DESCRIPTOR>(iPop)];
116 T pVel[D] = {0.};
117 for (unsigned iDim=0; iDim<D; ++iDim) {
118 pVel[iDim] = converter.getLatticeVelocity(particles::dynamics::calculateLocalVelocity(particle, PhysR<T,D>(physRinner))[iDim]);
119 momentumExchange[iDim] -= converter.getPhysForce(
120 population_momentum_exchange<T,D>::calculate( f1, f2, c[iDim], pVel[iDim], deltaR ) );
121 }
122 }
123 }
124 //Calculate lever (necessary for torque calculation)
125 lever = PhysR<T,D>(physRinner)-position;
126 return true;
127 }
128 else {
129 return false;
130 }
131}
132
133
134
135
136
137
138} //namespace resolved
139
140} //namespace particles
141
142} //namespace olb
143
144#endif
Representation of a block geometry.
Vector< T, D > getPhysR(LatticeR< D > latticeR)
T getDeltaR() const
Read only access to the voxel size given in SI units (meter)
std::enable_if_t< sizeof...(L)==D, int > get(L... latticeR) const
Read-only access to a material number.
Platform-abstracted block lattice for external access and inter-block interaction.
Cell< T, DESCRIPTOR > get(CellID iCell)
Get Cell interface for index iCell.
Conversion between physical and lattice units, as well as discretization.
constexpr T getLatticeVelocity(T physVelocity) const
conversion from physical to lattice velocity
constexpr T getPhysForce(T latticeForce) const
conversion from lattice to physical force
Plain old scalar vector.
Definition vector.h:47
constexpr Vector< T, PARTICLETYPE::d > calculateLocalVelocity(Particle< T, PARTICLETYPE > &particle, const PhysR< T, PARTICLETYPE::d > &input)
bool momentumExchangeAtSurfaceLocation(T momentumExchange[], PhysR< T, DESCRIPTOR::d > &lever, const LatticeR< DESCRIPTOR::d > &latticeRinner, const BlockGeometry< T, DESCRIPTOR::d > &blockGeometry, BlockLattice< T, DESCRIPTOR > &blockLattice, const UnitConverter< T, DESCRIPTOR > &converter, Particle< T, PARTICLETYPE > &particle, const int bulkMaterial=1)
bool evalSolidVolumeFraction(T output[], const S input[], Particle< T, PARTICLETYPE > &particle)
bool nearZero(const ADf< T, DIM > &a)
Definition aDiff.h:1087
Top level namespace for all of OpenLB.
static constexpr T calculate(T f1, T f2, T c, T pVel, T deltaR)
static constexpr T calculate(T f1, T f2, T c, T pVel, T deltaR)
static constexpr T calculate(T f1, T f2, T c, T pVel, T deltaR)
static constexpr T calculate(T f1, T f2, T c, T pVel, T deltaR)