diff --git a/src/blockforest/loadbalancing/DynamicCurve.h b/src/blockforest/loadbalancing/DynamicCurve.h index d9767ecf055e8b1106bbcd2746381c5be4b89db1..d72b60726f0b1dab41e8e5708051b1bc7b238a22 100644 --- a/src/blockforest/loadbalancing/DynamicCurve.h +++ b/src/blockforest/loadbalancing/DynamicCurve.h @@ -792,8 +792,9 @@ void DynamicCurveBalance< PhantomData_T >::balanceWeighted( const std::vector< s long double weight( 0 ); int numBlocks( 0 ); while( c < blocks.size() && - std::abs( pWeight - weight - numeric_cast< long double >( allBlocks[ uint_c( blocks[c].first ) ][ blocks[c].second ].second ) ) <= - std::abs( pWeight - weight ) && + ( isIdentical(weight, 0.0l) || + std::abs( pWeight - weight - numeric_cast< long double >( allBlocks[ uint_c( blocks[c].first ) ][ blocks[c].second ].second ) ) <= + std::abs( pWeight - weight ) ) && numBlocks < maxBlocksPerProcess_ ) { targets[ uint_c( blocks[c].first ) ][ blocks[c].second ] = pid_c(p); diff --git a/src/blockforest/loadbalancing/StaticCurve.cpp b/src/blockforest/loadbalancing/StaticCurve.cpp index 9bb9c184dcc24b10cfd1bc93f388d59523911301..e90ec3bc10ac72a04ebbfe9ce6609552c4276158 100644 --- a/src/blockforest/loadbalancing/StaticCurve.cpp +++ b/src/blockforest/loadbalancing/StaticCurve.cpp @@ -123,9 +123,9 @@ uint_t StaticLevelwiseCurveBalanceWeighted::operator()( SetupBlockForest & fores { const workload_t pWeight = totalWeight / workload_c( numberOfProcesses - p ); workload_t weight( 0 ); - while( c < blocksOnLevel.size() && + while( c < blocksOnLevel.size() && ( isIdentical(weight, workload_t(0)) || std::abs( pWeight - weight - blocksOnLevel[c]->getWorkload() ) <= - std::abs( pWeight - weight ) ) + std::abs( pWeight - weight ) ) ) { blocksOnLevel[c]->assignTargetProcess(p);