OpenLB 1.7
Loading...
Searching...
No Matches
Functions
olb::particles::sorting Namespace Reference

Functions

template<typename T , typename PARTICLETYPE , typename ... NESTED_FIELDS>
std::size_t partitionParticleSystem (ParticleSystem< T, PARTICLETYPE > &particleSystem)
 

Function Documentation

◆ partitionParticleSystem()

template<typename T , typename PARTICLETYPE , typename ... NESTED_FIELDS>
std::size_t olb::particles::sorting::partitionParticleSystem ( ParticleSystem< T, PARTICLETYPE > & particleSystem)

Definition at line 394 of file particleUtilities.h.

394 {
395 using namespace descriptors;
396 //Find first occurence of element belonging to partition B
397 std::size_t iPfirstB=particleSystem.size(); //Fallback (simple to check)
398 bool valB = true;
399 for (std::size_t iP=0; iP<particleSystem.size(); ++iP){
400 auto particle = particleSystem.get(iP);
401 bool active = particle.template getField<NESTED_FIELDS...>();
402 if (active==valB){
403 iPfirstB=iP;
404 break;
405 }
406 }
407 //Find succeeding elements belonging to partition A and move them to othe beginning
408 for (std::size_t iP=iPfirstB; iP<particleSystem.size(); ++iP){
409 auto particle = particleSystem.get(iP);
410 bool active = particle.template getField<NESTED_FIELDS...>();
411 if (active!=valB){
412 particleSystem.swapParticles(iP,iPfirstB);
413 ++iPfirstB;
414 }
415 }
416 //Return splitpoint between partitions
417 return iPfirstB;
418}
auto & get()
Expose container.
void swapParticles(std::size_t iP, std::size_t jP)
Swap particles by index.
constexpr std::size_t size()
Size of ParticleSystem.

References olb::particles::ParticleSystem< T, PARTICLETYPE >::get(), partitionParticleSystem(), olb::particles::ParticleSystem< T, PARTICLETYPE >::size(), and olb::particles::ParticleSystem< T, PARTICLETYPE >::swapParticles().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: