Skip to content
Snippets Groups Projects
Commit 39a70296 authored by Sebastian Eibl's avatar Sebastian Eibl
Browse files

[CLANG-TIDY] readability-delete-null-pointer

parent f6eb600f
No related merge requests found
......@@ -34,6 +34,7 @@ portability-*,
readability-const-return-type,
readability-container-size-empty,
readability-delete-null-pointer,
readability-misleading-indentation,
readability-misplaced-array-index
......
......@@ -222,7 +222,7 @@ createBlockForest( const AABB& domainAABB,
// if possible, create Cartesian MPI communicator
std::vector< uint_t >* processIdMap = nullptr;
std::vector< uint_t > processIdMap(0);
WALBERLA_MPI_SECTION()
{
......@@ -233,13 +233,13 @@ createBlockForest( const AABB& domainAABB,
if ( mpiManager->isCartesianCommValid() ) {
mpiManager->createCartesianComm( numberOfXProcesses, numberOfYProcesses, numberOfZProcesses, xPeriodic, yPeriodic, zPeriodic );
processIdMap = new std::vector< uint_t >( numberOfProcesses );
processIdMap.resize( numberOfProcesses );
for( uint_t z = 0; z != numberOfZProcesses; ++z ) {
for( uint_t y = 0; y != numberOfYProcesses; ++y ) {
for( uint_t x = 0; x != numberOfXProcesses; ++x ) {
(*processIdMap)[ z * numberOfXProcesses * numberOfYProcesses + y * numberOfXProcesses + x ] =
processIdMap[ z * numberOfXProcesses * numberOfYProcesses + y * numberOfXProcesses + x ] =
uint_c( MPIManager::instance()->cartesianRank(x,y,z) );
}
}
......@@ -256,11 +256,9 @@ createBlockForest( const AABB& domainAABB,
// calculate process distribution
sforest.balanceLoad( blockforest::CartesianDistribution( numberOfXProcesses, numberOfYProcesses, numberOfZProcesses, processIdMap ),
sforest.balanceLoad( blockforest::CartesianDistribution( numberOfXProcesses, numberOfYProcesses, numberOfZProcesses, &processIdMap ),
numberOfXProcesses * numberOfYProcesses * numberOfZProcesses );
if( processIdMap != nullptr ) delete processIdMap;
// create StructuredBlockForest (encapsulates a newly created BlockForest)
return std::make_shared< BlockForest >( uint_c( MPIManager::instance()->rank() ), sforest, keepGlobalBlockInformation );
......
......@@ -48,7 +48,7 @@ uint_t CartesianDistribution::operator()( SetupBlockForest & forest, const uint_
WALBERLA_ABORT( "Load balancing failed: \'Number of processes in z-direction\' must be in (0," << forest.getZSize() << "]. "
"You specified \'" << numberOfZProcesses_ << "\'." );
if( processIdMap_ != nullptr )
if( !processIdMap_->empty() )
WALBERLA_CHECK_EQUAL( processIdMap_->size(), numberOfProcesses );
uint_t partitions[3];
......@@ -84,7 +84,7 @@ uint_t CartesianDistribution::operator()( SetupBlockForest & forest, const uint_
{
const uint_t index = z * partitions[0] * partitions[1] + y * partitions[0] + x;
(*block)->assignTargetProcess( ( processIdMap_ != nullptr ) ? (*processIdMap_)[ index ] : index );
(*block)->assignTargetProcess( ( !processIdMap_->empty() ) ? (*processIdMap_)[ index ] : index );
}
}
}
......
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