52 T distB = (1/std::sqrt(2))*distA;
53 T distC = (1/std::sqrt(2))*distB;
56 std::array<Vector<T,3>,26> pointsOnSphericalHull = {
57 Vector<T,3>(position[0]-distC, position[1]-distC, position[2]-distC),
58 Vector<T,3>(position[0], position[1]-distB, position[2]-distB),
59 Vector<T,3>(position[0]+distC, position[1]-distC, position[2]-distC),
61 Vector<T,3>(position[0]-distB, position[1], position[2]-distB),
62 Vector<T,3>(position[0], position[1], position[2]-distA),
63 Vector<T,3>(position[0]+distB, position[1], position[2]-distB),
65 Vector<T,3>(position[0]-distC, position[1]+distC, position[2]-distC),
66 Vector<T,3>(position[0], position[1]+distB, position[2]-distB),
67 Vector<T,3>(position[0]+distC, position[1]+distC, position[2]-distC),
70 Vector<T,3>(position[0]-distB, position[1]-distB, position[2] ),
71 Vector<T,3>(position[0], position[1]-distA, position[2] ),
72 Vector<T,3>(position[0]+distB, position[1]-distB, position[2] ),
74 Vector<T,3>(position[0]-distA, position[1], position[2] ),
76 Vector<T,3>(position[0]+distA, position[1], position[2] ),
78 Vector<T,3>(position[0]-distB, position[1]+distB, position[2] ),
79 Vector<T,3>(position[0], position[1]+distA, position[2] ),
80 Vector<T,3>(position[0]+distB, position[1]+distB, position[2] ),
83 Vector<T,3>(position[0]-distC, position[1]-distC, position[2]+distC),
84 Vector<T,3>(position[0], position[1]-distB, position[2]+distB),
85 Vector<T,3>(position[0]+distC, position[1]-distC, position[2]+distC),
87 Vector<T,3>(position[0]-distB, position[1], position[2]+distB),
88 Vector<T,3>(position[0], position[1], position[2]+distA),
89 Vector<T,3>(position[0]+distB, position[1], position[2]+distB),
91 Vector<T,3>(position[0]-distC, position[1]+distC, position[2]+distC),
92 Vector<T,3>(position[0], position[1]+distB, position[2]+distB),
93 Vector<T,3>(position[0]+distC, position[1]+distC, position[2]+distC)
96 return pointsOnSphericalHull;
105 T distB = (1/std::sqrt(2))*distA;
108 std::array<Vector<T,2>,8> pointsOnSphericalHull = {
122 return pointsOnSphericalHull;
150 if constexpr (access::providesParallelization<PARTICLETYPE>()){
151 auto& sParticleSystem = xParticleSystem;
157 while(iP < particleSystem.
size()){
158 auto particle = particleSystem.get(iP);
161 doWhenMeetingCondition<T,PARTICLETYPE,PCONDITION>( particle,
162 [&](Particle<T,PARTICLETYPE> particle){
164 auto& container = particleSystem.get();
165 container.erase( particle.getId() );
171 auto& particleSystem = xParticleSystem;
173 while(iP < particleSystem.size()){
174 auto particle = particleSystem.get(iP);
177 doWhenMeetingCondition<T,PARTICLETYPE,PCONDITION>( particle,
178 [&](Particle<T,PARTICLETYPE> particle){
180 auto& container = particleSystem.get();
181 container.erase( particle.getId() );
203 std::size_t globalIDrequested, std::size_t& localParticleID )
205 using namespace descriptors;
206 static_assert(PARTICLETYPE::template providesNested<PARALLELIZATION,ID>(),
"Field PARALLELIZATION:ID has to be provided");
211 for (std::size_t iP=0; iP<particleSystem.
size(); ++iP) {
213 auto particle = particleSystem.
get(iP);
215 doWhenMeetingCondition<T,PARTICLETYPE,PCONDITION>( particle,
217 auto globalID = particle.template getField<PARALLELIZATION,ID>();
218 if (globalID==globalIDrequested){
219 localParticleID = particle.
getId();
241 std::size_t globalIDrequested, std::size_t& localParticleID,
int& globiC )
243 using namespace descriptors;
244 static_assert(PARTICLETYPE::template providesNested<PARALLELIZATION,ID>(),
"Field PARALLELIZATION:ID has to be provided");
252 for (
int iC=0; iC<loadBalancer.size(); ++iC){
254 int globiC = loadBalancer.glob(iC);
257 auto& particleSystem = *bParticleSystems[iC];
260 for (std::size_t iP=0; iP<particleSystem.size(); ++iP) {
262 auto particle = particleSystem.get(iP);
264 doWhenMeetingCondition<T,PARTICLETYPE,PCONDITION>( particle,
266 auto globalID = particle.template getField<PARALLELIZATION,ID>();
267 if (globalID==globalIDrequested){
268 localParticleID = particle.
getId();
280#ifdef PARALLEL_MODE_MPI
282 singleton::mpi().reduceAndBcast(found, MPI_LOR);
284 singleton::mpi().reduceAndBcast(globiC, MPI_MAX);
285 singleton::mpi().reduceAndBcast(localParticleID, MPI_MAX);
303 int globiC, F f=[](
int){} )
306 if constexpr(checkDiscretePoints) {
308 std::unordered_set<int> iCs;
310 auto pointsOnHull = discrete_points_on_hull::calculate( position, circumRadius );
315 const bool cuboidFound = getCuboid(cuboidGeometry,
316 periodicity, point, globiConHull);
317 if constexpr(domainWarning){
319 std::cerr <<
"Warning [during getSurfaceTouchingICs]: Cuboid not found for point "
320 << point << std::endl;
324 if (cuboidFound && globiConHull!=globiC){
326 if(iCs.insert(globiConHull).second) {
334 const T physDeltaX = cuboidGeometry.getMotherCuboid().getDeltaR();
335 std::vector<int> tmp = communication::getNeighborCuboids<T,D,false>(
336 cuboidGeometry, util::ceil(circumRadius/physDeltaX), globiC);
337 std::unordered_set<int> iCs;
338 for(
const int entry : tmp) {
339 if( globiC != entry ) {
346 __builtin_unreachable();
371 int globiC, F f=[](
int){} )
373 const std::unordered_set<int> touchedICs{getSurfaceTouchingICs<T,D,F,domainWarning>(
374 cuboidGeometry, position, circumRadius, periodicity, globiC, f)};
375 std::vector<int> listOfICs;
376 listOfICs.insert(listOfICs.end(), touchedICs.begin(), touchedICs.end());
void swapParticles(std::size_t iP, std::size_t jP)
Swap particles by index.
constexpr std::size_t size()
Size of ParticleSystem.
std::size_t getId() const
Return memory ID of the currently represented particle.
SuperStructure< T, PARTICLETYPE::d > & getSuperStructure()
const std::vector< std::unordered_set< int > > & getCuboidNeighborhood()
std::vector< ParticleSystem< T, PARTICLETYPE > * > & getBlockParticleSystems()
T getRadius(Particle< T, PARTICLETYPE > &particle)
Vector< T, PARTICLETYPE::d > getPosition(Particle< T, PARTICLETYPE > particle)
void forSystemsInSuperParticleSystem(SuperParticleSystem< T, PARTICLETYPE > &sParticleSystem, F f)
std::unordered_set< int > getSurfaceTouchingICs(CuboidGeometry< T, D > &cuboidGeometry, Vector< T, D > position, T circumRadius, const Vector< bool, D > &periodicity, int globiC, F f=[](int){})
Get a set of surface touching iCs (that are not globiC) Allows to run an optional function per unique...
std::vector< int > getVectorOfSurfaceTouchingICs(CuboidGeometry< T, D > &cuboidGeometry, Vector< T, D > position, T circumRadius, const Vector< bool, D > &periodicity, int globiC, F f=[](int){})
bool searchParticleGlobally(SuperParticleSystem< T, PARTICLETYPE > &sParticleSystem, std::size_t globalIDrequested, std::size_t &localParticleID, int &globiC)
Search particle in SuperParticleSystem by globalParticleID and return globiC if found.
std::size_t partitionParticleSystem(ParticleSystem< T, PARTICLETYPE > &particleSystem)
std::conditional_t< PARTICLETYPE::template providesNested< descriptors::PARALLELIZATION >(), SuperParticleSystem< T, PARTICLETYPE >, ParticleSystem< T, PARTICLETYPE > > XParticleSystem
void purgeInvalidParticles(XParticleSystem< T, PARTICLETYPE > &xParticleSystem)
std::array< Vector< T, 3 >, 26 > discretePointsOnSphericalHull(Vector< T, 3 > position, T radius)
bool searchParticleLocally(ParticleSystem< T, PARTICLETYPE > &particleSystem, std::size_t globalIDrequested, std::size_t &localParticleID)
void doForParticleMatchingID(XParticleSystem< T, PARTICLETYPE > &xParticleSystem, F f)
static constexpr auto calculate(Particle< T, PARTICLETYPE > &particle)
static constexpr auto calculate(Vector< T, D > position, T radius)