OpenLB 1.7
Loading...
Searching...
No Matches
materialHandling.h
Go to the documentation of this file.
1/* This file is part of the OpenLB library
2 *
3 * Copyright (C) 2023 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_MATERIAL_HANDLING_H
27#define PARTICLE_MATERIAL_HANDLING_H
28
29
30namespace olb {
31
32namespace particles {
33
34namespace boundaries {
35
36
37
38//Return whether location is in direct vicinity of specified materials
39template<typename T,unsigned D>
40bool materialVicinity( SuperIndicatorMaterial<T,D>& materialIndicator, LatticeR<D+1>& latticeR )
41{
42 static_assert((D==2 || D==3), "Dimension unknown!");
43 static_assert(D!=2, "2D VERSION NOT IMPLEMENTED YET");
44 if constexpr(D==2){
45 //TODO: implement 2D version
46 } else if constexpr(D==3){
47 return (materialIndicator(latticeR[0],latticeR[1]+1,latticeR[2], latticeR[3] ) ||
48 materialIndicator(latticeR[0],latticeR[1]+1,latticeR[2], latticeR[3]+1 ) ||
49 materialIndicator(latticeR[0],latticeR[1]+1,latticeR[2]+1,latticeR[3] ) ||
50 materialIndicator(latticeR[0],latticeR[1]+1,latticeR[2]+1,latticeR[3]+1 ) ||
51 materialIndicator(latticeR[0],latticeR[1],latticeR[2], latticeR[3] ) ||
52 materialIndicator(latticeR[0],latticeR[1],latticeR[2], latticeR[3]+1 ) ||
53 materialIndicator(latticeR[0],latticeR[1],latticeR[2]+1, latticeR[3] ) ||
54 materialIndicator(latticeR[0],latticeR[1],latticeR[2]+1, latticeR[3]+1 ));
55 }
56}
57
58
59template<typename T, typename PARTICLETYPE>
62 Particle<T,PARTICLETYPE>& particle )
63{
64 constexpr unsigned D = PARTICLETYPE::d;
65 //Retrieve particle position
66 auto position = access::getPosition( particle );
67 //Retrieve super geometry
68 auto& sGeometry = materialIndicator.getSuperGeometry();
69 //Get lattice position
70 LatticeR<D+1> latticeR;
71 bool foundPos = sGeometry.getCuboidGeometry().getFloorLatticeR(position, latticeR);
72 if (!foundPos) {std::cerr << "LatticeR (" << latticeR << ") not found!" << std::endl; }
73 //Check whether responsible iC
74 bool isLocal = sGeometry.getLoadBalancer().isLocal(latticeR[0]);
75 if(isLocal){
76 //Check if in vicinity of specified material numbers
77 bool vicinity = materialVicinity<T,D>( materialIndicator, latticeR );
78 return vicinity;
79 }
80 return false;
81}
82
83
84} //namespace boundaries
85
86} //namespace particles
87
88} //namespace olb
89
90
91#endif
Plain old scalar vector.
Definition vector.h:47
Vector< T, PARTICLETYPE::d > getPosition(Particle< T, PARTICLETYPE > particle)
bool materialVicinity(SuperIndicatorMaterial< T, D > &materialIndicator, LatticeR< D+1 > &latticeR)
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