diff --git a/src/Particles/particles/MPIParticleIdHandler/MPIParticleIdHandler.cpp b/src/Particles/particles/MPIParticleIdHandler/MPIParticleIdHandler.cpp new file mode 100644 index 00000000..056d314c --- /dev/null +++ b/src/Particles/particles/MPIParticleIdHandler/MPIParticleIdHandler.cpp @@ -0,0 +1,70 @@ +#include "MPIParticleIdHandler.hpp" +#include "procCommunication.hpp" + +pFlow::MPI::MPIParticleIdHandler::MPIParticleIdHandler +( + pointStructure& pStruct +) +: + particleIdHandler(pStruct) +{ + initialIdCheck(); +} + +pFlow::Pair + pFlow::MPI::MPIParticleIdHandler::getIdRange(uint32 nNewParticles) +{ + uint32 startId; + if(maxId_==-1) + { + startId = 0; + } + else + { + startId = maxId_+1; + } + uint32 endId = startId+nNewParticles-1; + maxId_ = endId; + return {startId, endId}; +} + +bool pFlow::MPI::MPIParticleIdHandler::initialIdCheck() +{ + /// empty point structure / no particles in simulation + uint32 maxId = -1; + if( !pStruct().empty() ) + { + maxId = max( *this ); + } + + auto maxIdAll = procVector(pFlowProcessors()); + auto numAll = procVector(pFlowProcessors()); + auto comm = procCommunication(pFlowProcessors()); + + comm.collectAllToAll(maxId, maxIdAll); + comm.collectAllToAll(size(),numAll); + + uint32 n = 0; + for(uint32 i=0; i"); + + explicit MPIParticleIdHandler(pointStructure& pStruct); + + ~MPIParticleIdHandler() override = default; + + add_vCtor( + particleIdHandler, + MPIParticleIdHandler, + pointStructure + ); + + Pair getIdRange(uint32 nNewParticles) override; + + uint32 maxId() const override + { + return maxId_; + } +}; + +} + +#endif //__MPIParticleIdHandler_hpp__ \ No newline at end of file