OpenLB 1.7
Loading...
Searching...
No Matches
particleBoundaries.h
Go to the documentation of this file.
1/* This file is part of the OpenLB library
2 *
3 * Copyright (C) 2022 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 PARTICLE_BOUNDARIES_H
27#define PARTICLE_BOUNDARIES_H
28
29
30namespace olb {
31
32namespace particles {
33
34namespace boundaries {
35
36
40template<bool useCubicBounds=false, typename T, typename PARTICLETYPE>
43 T coefficientOfRestitution=1.0 )
44{
45 using namespace descriptors;
46 //Execute wall treatment
47 doAtParticleWallContact<useCubicBounds>( particle, solidBoundary,
48 [&]( Particle<T,PARTICLETYPE>& particle,
49 Vector<T,PARTICLETYPE::d>& normal, T penetrationDepth ){
50 //Retrieve velocity
51 auto velocity = access::getVelocity( particle );
52 auto position = access::getPosition( particle );
53 //Modify velocity and set after-reflection position
54 for (int iDim=0; iDim<PARTICLETYPE::d; ++iDim){
55 //1. Resurface
56 position[iDim] += normal[iDim] * 2.*penetrationDepth;
57 //2. Reflection
58 velocity[iDim] += std::abs(normal[iDim]) * -2.*velocity[iDim];
59 velocity[iDim] *= coefficientOfRestitution;
60 }
61 //Apply velocity
62 access::setVelocity( particle, velocity );
63 access::setPosition( particle, position );
64 });
65}
66
69template<typename T, typename PARTICLETYPE>
72{
73 //Create solid wall
74 Vector<T,PARTICLETYPE::d> extent = end-origin;
75 IndicatorCuboid3D<T> cuboid(extent, origin);
76 std::unique_ptr<IndicatorF<T,PARTICLETYPE::d>> boundaryIndicator =
77 std::make_unique<IndicInverse<T,PARTICLETYPE::d>>(cuboid);
78 SolidBoundary<T,PARTICLETYPE::d> solidBoundary(std::move(boundaryIndicator), 2, 0);
79 //Execute velocity wall reflection
80 velocityWallReflection<true>( particle, solidBoundary );
81}
82
86template<bool useCubicBounds=false, typename T, typename PARTICLETYPE>
89{
90 using namespace descriptors;
91 //Execute wall treatment
92 doAtParticleWallContact<useCubicBounds>( particle, solidBoundary,
93 [&]( Particle<T,PARTICLETYPE>& particle,
94 Vector<T,PARTICLETYPE::d>& normal, T penetrationDepth ){
95 //Retrieve velocity
96 auto velocity = access::getVelocity( particle );
97 auto position = access::getPosition( particle );
98 //Modify velocity and set after-reflection position
99 for (int iDim=0; iDim<PARTICLETYPE::d; ++iDim){
100 //1. Resurface
101 position[iDim] += normal[iDim] * 2.*penetrationDepth;
102 //2. Velocity swallow //TODO: include momentum transfer treatment
103 velocity[iDim] = 0.;
104 }
105 //Apply velocity
106 access::setVelocity( particle, velocity );
107 access::setPosition( particle, position );
108 });
109}
110
114template<bool useCubicBounds=false, typename T, typename PARTICLETYPE>
116 SolidBoundary<T,PARTICLETYPE::d>& solidBoundary )
117{
118 using namespace descriptors;
119 //Execute wall treatment
120 doAtParticleWallContact<useCubicBounds>( particle, solidBoundary,
121 [&]( Particle<T,PARTICLETYPE>& particle,
123 //Deactivate particle
124 access::setInactive( particle );
125 access::setRestingParticle( particle );
126 });
127}
128
133template<typename T, typename PARTICLETYPE>
136{
137 using namespace descriptors;
138 //Check whether still active
139 bool isActive = access::isActive( particle );
140 if (isActive){
141 bool vicinity = checkMaterialVicinity( materialIndicator, particle );
142 if (vicinity){
143 //Deactivate particle
144 access::setInactive( particle );
145 access::setRestingParticle( particle );
146 }
147 }
148}
149
156template<typename T, typename PARTICLETYPE>
160{
161 using namespace descriptors;
162 //Check whether still active
163 bool isActive = access::isActive( particle );
164 if (isActive){
165 bool vicinity = checkMaterialVicinity( materialIndicator, particle );
166 if (vicinity){
167 //Apply wall capture
168 constexpr bool useCubicBounds=false;
169 wallCapture<useCubicBounds>(particle, solidBoundary);
170 }
171 }
172}
173
174
177template<bool useCubicBounds=false, typename T, typename PARTICLETYPE>
179 SolidBoundary<T,PARTICLETYPE::d>& solidBoundary )
180{
181 using namespace descriptors;
182 //Execute wall treatment
183 doAtParticleWallContact<useCubicBounds>( particle, solidBoundary,
184 [&]( Particle<T,PARTICLETYPE>& particle,
186 //Deactivate particle
187 access::setInactive( particle );
188 });
189}
190
194template<typename T, typename PARTICLETYPE>
197{
198 using namespace descriptors;
199 //Check whether still active
200 bool isActive = access::isActive( particle );
201 if (isActive){
202 bool vicinity = checkMaterialVicinity( materialIndicator, particle );
203 if (vicinity){
204 //Deactivate particle
205 access::setInactive( particle );
206 }
207 }
208}
209
215template<typename T, typename PARTICLETYPE>
219{
220 using namespace descriptors;
221 //Check whether still active
222 bool isActive = access::isActive( particle );
223 if (isActive){
224 bool vicinity = checkMaterialVicinity( materialIndicator, particle );
225 if (vicinity){
226 constexpr bool useCubicBounds=false;
227 boundaries::escape<useCubicBounds>(particle, solidBoundary);
228 }
229 }
230}
231
232
237template<typename T, typename PARTICLETYPE>
239 SuperIndicatorMaterial<T,PARTICLETYPE::d>& captureMaterialIndicator,
240 SuperIndicatorMaterial<T,PARTICLETYPE::d>& escapeMaterialIndicator )
241{
242 using namespace descriptors;
243 //Check whether still active
244 bool isActive = access::isActive( particle );
245 if (isActive){
246 bool vicinity = checkMaterialVicinity( captureMaterialIndicator, particle );
247 if (vicinity){
248 access::setInactive( particle );
249 access::setRestingParticle( particle );
250 }
251 else {
252 vicinity = checkMaterialVicinity( escapeMaterialIndicator, particle );
253 if (vicinity){
254 access::setInactive( particle );
255 }
256 }
257 }
258}
259
265template<typename T, typename PARTICLETYPE>
268 SuperIndicatorMaterial<T,PARTICLETYPE::d>& captureMaterialIndicator,
269 SuperIndicatorMaterial<T,PARTICLETYPE::d>& escapeMaterialIndicator )
270{
271 using namespace descriptors;
272 //Check whether still active
273 bool isActive = access::isActive( particle );
274 if (isActive){
275 bool vicinity = checkMaterialVicinity( captureMaterialIndicator, particle );
276 if (vicinity){
277 constexpr bool useCubicBounds=false;
278 boundaries::wallCapture<useCubicBounds>(particle, solidBoundary);
279 }
280 else {
281 vicinity = checkMaterialVicinity( escapeMaterialIndicator, particle );
282 if (vicinity){
283 constexpr bool useCubicBounds=false;
284 boundaries::escape<useCubicBounds>(particle, solidBoundary);
285 }
286 }
287 }
288}
289
290
291} //namespace boundaries
292
293} //namespace particles
294
295} //namespace olb
296
297
298#endif
indicator function for a 3d-cuboid, parallel to the planes x=0, y=0, z=0.
Plain old scalar vector.
Definition vector.h:47
bool isActive(Particle< T, PARTICLETYPE > particle)
void setRestingParticle(Particle< T, PARTICLETYPE > particle)
Vector< T, PARTICLETYPE::d > getVelocity(Particle< T, PARTICLETYPE > particle)
void setVelocity(Particle< T, PARTICLETYPE > particle, Vector< T, PARTICLETYPE::d > velocity)
void setInactive(Particle< T, PARTICLETYPE > particle, bool value=true)
void setPosition(Particle< T, PARTICLETYPE > particle, Vector< T, PARTICLETYPE::d > position)
Vector< T, PARTICLETYPE::d > getPosition(Particle< T, PARTICLETYPE > particle)
void materialCaptureAndEscape(Particle< T, PARTICLETYPE > &particle, SuperIndicatorMaterial< T, PARTICLETYPE::d > &captureMaterialIndicator, SuperIndicatorMaterial< T, PARTICLETYPE::d > &escapeMaterialIndicator)
Escape and capture based on material rather than SolidBoundary.
void wallCaptureMaterialAware(Particle< T, PARTICLETYPE > &particle, SolidBoundary< T, PARTICLETYPE::d > &solidBoundary, SuperIndicatorMaterial< T, PARTICLETYPE::d > &materialIndicator)
Wall capture with material awareness.
void escapeMaterialAware(Particle< T, PARTICLETYPE > &particle, SolidBoundary< T, PARTICLETYPE::d > &solidBoundary, SuperIndicatorMaterial< T, PARTICLETYPE::d > &materialIndicator)
Escape boundary with material awareness.
void materialEscape(Particle< T, PARTICLETYPE > &particle, SuperIndicatorMaterial< T, PARTICLETYPE::d > &materialIndicator)
Escape boundary based on material rather than SolidBoundary.
void wallCaptureAndEscapeMaterialAware(Particle< T, PARTICLETYPE > &particle, SolidBoundary< T, PARTICLETYPE::d > &solidBoundary, SuperIndicatorMaterial< T, PARTICLETYPE::d > &captureMaterialIndicator, SuperIndicatorMaterial< T, PARTICLETYPE::d > &escapeMaterialIndicator)
Escape boundary with material awareness.
void wallSlip(Particle< T, PARTICLETYPE > &particle, SolidBoundary< T, PARTICLETYPE::d > &solidBoundary)
Wall slip.
void velocityWallReflection(Particle< T, PARTICLETYPE > &particle, SolidBoundary< T, PARTICLETYPE::d > &solidBoundary, T coefficientOfRestitution=1.0)
Velocity wall reflection.
void cuboidVelocityWallReflection(Particle< T, PARTICLETYPE > &particle, Vector< T, PARTICLETYPE::d > origin, Vector< T, PARTICLETYPE::d > end)
Alias for cubic version of velocity wall reflection.
void wallCapture(Particle< T, PARTICLETYPE > &particle, SolidBoundary< T, PARTICLETYPE::d > &solidBoundary)
Wall capture.
void materialCapture(Particle< T, PARTICLETYPE > &particle, SuperIndicatorMaterial< T, PARTICLETYPE::d > &materialIndicator)
Wall capture based on material rather than SolidBoundary.
void escape(Particle< T, PARTICLETYPE > &particle, SolidBoundary< T, PARTICLETYPE::d > &solidBoundary)
Escape.
bool checkMaterialVicinity(SuperIndicatorMaterial< T, PARTICLETYPE::d > &materialIndicator, Particle< T, PARTICLETYPE > &particle)
Top level namespace for all of OpenLB.
std::conditional_t< D==2, SuperIndicatorMaterial2D< T >, SuperIndicatorMaterial3D< T > > SuperIndicatorMaterial
Definition aliases.h:298