Commit acc0eff4 authored by Marcel Koch's avatar Marcel Koch
Browse files

simplify roundrobinvolume redistribution

parent 2e83a2a1
Pipeline #34774 failed with stages
in 7 minutes and 11 seconds
......@@ -388,6 +388,7 @@ MigrationInfo roundRobinVolume( PrimitiveStorage& storage, uint_t minRank, uint_
const uint_t numProcesses = walberla::mpi::MPIManager::instance()->numProcesses();
const uint_t numReceivingProcesses = maxRank - minRank + 1;
const uint_t rank = uint_c( walberla::mpi::MPIManager::instance()->rank() );
const auto reduction = static_cast<double>(numReceivingProcesses) / static_cast<double>(numProcesses);
MigrationMap_T migrationMap;
uint_t numReceivingPrimitives = 0;
......@@ -404,27 +405,13 @@ MigrationInfo roundRobinVolume( PrimitiveStorage& storage, uint_t minRank, uint_
// Heuristic: let's assign primitives with consecutive IDs to the same process.
// Often, meshes are generated in a way that primitives with consecutive IDs are located next to each other.
// We are assuming here, that the current distribution was already obtained from loadbalancing::roundRobinVolume.
auto setup_volume_ids = [&]( const auto& ids ) {
auto it = ids.begin();
for ( uint_t currentRank = 0; currentRank < numReceivingProcesses; currentRank++ )
{
uint_t numVolumesOnThisRank = 0;
while ( numVolumesOnThisRank < ids.size() / numReceivingProcesses )
{
migrationMap[it->getID()] = minRank + currentRank;
numVolumesOnThisRank++;
it++;
}
if ( currentRank < ids.size() % numReceivingProcesses )
{
migrationMap[it->getID()] = minRank + currentRank;
it++;
}
numPrimitivesPerRank[minRank + currentRank] =
ids.size() / numReceivingProcesses + ( currentRank < ids.size() % numReceivingProcesses );
auto target_rank = minRank + static_cast<uint_t>(static_cast<double>(rank) * reduction);
for(const auto& p: ids){
migrationMap[p.getID()] = target_rank;
}
WALBERLA_CHECK( it == ids.end() );
numPrimitivesPerRank[target_rank] = ids.size();
};
if ( storage.hasGlobalCells() )
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment