From e6b9bbe750136ace2a07808e75c3f0f118f9693e Mon Sep 17 00:00:00 2001
From: Christoph Rettinger <christoph.rettinger@fau.de>
Date: Thu, 29 Nov 2018 13:30:01 +0100
Subject: [PATCH] clang tidy fixes

---
 .../AMRSedimentSettling.cpp                   | 223 +++++++++---------
 .../WorkloadEvaluation.cpp                    | 123 +++++-----
 src/pe_coupling/amr/InfoCollection.h          |  10 +-
 .../BodyPresenceLevelDetermination.cpp        |  13 +-
 .../GlobalBodyPresenceLevelDetermination.cpp  |  11 +-
 .../MetisAssignmentFunctor.cpp                |  25 +-
 .../WeightAssignmentFunctor.cpp               |   7 +-
 7 files changed, 199 insertions(+), 213 deletions(-)

diff --git a/apps/benchmarks/AdaptiveMeshRefinementFluidParticleCoupling/AMRSedimentSettling.cpp b/apps/benchmarks/AdaptiveMeshRefinementFluidParticleCoupling/AMRSedimentSettling.cpp
index 988079c48..3bb791552 100644
--- a/apps/benchmarks/AdaptiveMeshRefinementFluidParticleCoupling/AMRSedimentSettling.cpp
+++ b/apps/benchmarks/AdaptiveMeshRefinementFluidParticleCoupling/AMRSedimentSettling.cpp
@@ -174,7 +174,7 @@ void VectorGradientRefinement< LatticeModel_T, Filter_T >::operator()( std::vect
 
       const VectorField_T * uField = block->template getData< VectorField_T >( fieldID_ );
 
-      if( uField == NULL )
+      if( uField == nullptr )
       {
          it->second = uint_t(0);
          continue;
@@ -208,7 +208,7 @@ void VectorGradientRefinement< LatticeModel_T, Filter_T >::operator()( std::vect
           // obtain the matrix grad(u) with the help of the gradient formula from
           // See: Ramadugu et al - Lattice differential operators for computational physics (2013)
           // with T = c_s**2
-          const real_t inv_c_s_sqr = real_t(3);
+          const auto inv_c_s_sqr = real_t(3);
           uGradient = real_t(0);
           for( auto dir = Stencil_T::beginNoCenter(); dir != Stencil_T::end(); ++dir)
           {
@@ -237,9 +237,9 @@ void VectorGradientRefinement< LatticeModel_T, Filter_T >::operator()( std::vect
           }
           uGradient *= inv_c_s_sqr;
 
-          real_t norm( real_t(0) );
+          auto norm = real_t(0);
           //compute maximums norm of 3x3 matrix
-          for( uint_t i = uint_t(0); i < uint_t(3*3); ++i )
+          for (auto i = uint_t(0); i < uint_t(3*3); ++i)
              norm = std::max(norm, std::fabs(uGradient[i]));
 
           if( norm > lowerLimit_ )
@@ -447,35 +447,33 @@ private:
 
 static void refinementSelection( SetupBlockForest& forest, uint_t levels, const AABB & refinementBox )
 {
-   real_t dx = real_t(1); // dx on finest level
-   for( auto block = forest.begin(); block != forest.end(); ++block )
-   {
-      uint_t blockLevel = block->getLevel();
+   auto dx = real_t(1); // dx on finest level
+   for (auto &block : forest) {
+      uint_t blockLevel = block.getLevel();
       uint_t levelScalingFactor = ( uint_t(1) << (levels - uint_t(1) - blockLevel) );
       real_t dxOnLevel = dx * real_c(levelScalingFactor);
-      AABB blockAABB = block->getAABB();
+      AABB blockAABB = block.getAABB();
 
       // extend block AABB by ghostlayers
       AABB extendedBlockAABB = blockAABB.getExtended( dxOnLevel * real_c(FieldGhostLayers) );
 
       if( extendedBlockAABB.intersects( refinementBox ) )
          if( blockLevel < ( levels - uint_t(1) ) )
-            block->setMarker( true );
+            block.setMarker( true );
    }
 }
 
 static void workloadAndMemoryAssignment( SetupBlockForest& forest )
 {
-   for( auto block = forest.begin(); block != forest.end(); ++block )
-   {
-      block->setWorkload( numeric_cast< workload_t >( uint_t(1) << block->getLevel() ) );
-      block->setMemory( numeric_cast< memory_t >(1) );
+   for (auto &block : forest) {
+      block.setWorkload( numeric_cast< workload_t >( uint_t(1) << block.getLevel() ) );
+      block.setMemory( numeric_cast< memory_t >(1) );
    }
 }
 
 static shared_ptr< StructuredBlockForest > createBlockStructure( const AABB & domainAABB, Vector3<uint_t> blockSizeInCells,
                                                                  uint_t numberOfLevels, const AABB & refinementBox,
-                                                                 bool useBox, std::string loadDistributionStrategy,
+                                                                 bool useBox, const std::string & loadDistributionStrategy,
                                                                  bool keepGlobalBlockInformation = false )
 {
    SetupBlockForest sforest;
@@ -565,7 +563,7 @@ public:
          blocks_( blocks ), flagFieldID_( flagFieldID ), pdfFieldID_( pdfFieldID ), bodyFieldID_ ( bodyFieldID )
    {}
 
-   BoundaryHandling_T * initialize( IBlock * const block );
+   BoundaryHandling_T * initialize( IBlock * const block ) override;
 
 private:
 
@@ -582,9 +580,9 @@ BoundaryHandling_T * MyBoundaryHandling::initialize( IBlock * const block )
 {
    WALBERLA_ASSERT_NOT_NULLPTR( block );
 
-   FlagField_T * flagField       = block->getData< FlagField_T >( flagFieldID_ );
-   PdfField_T *  pdfField        = block->getData< PdfField_T > ( pdfFieldID_ );
-   BodyField_T * bodyField       = block->getData< BodyField_T >( bodyFieldID_ );
+   auto * flagField = block->getData< FlagField_T >( flagFieldID_ );
+   auto *  pdfField = block->getData< PdfField_T > ( pdfFieldID_ );
+   auto * bodyField = block->getData< BodyField_T >( bodyFieldID_ );
 
    const auto fluid = flagField->flagExists( Fluid_Flag ) ? flagField->getFlag( Fluid_Flag ) : flagField->registerFlag( Fluid_Flag );
 
@@ -634,10 +632,10 @@ public:
    {
       const uint_t timestep (timeloop_->getCurrentTimeStep() );
 
-      uint_t numSediments( uint_t(0));
-      real_t meanPos(real_t(0));
-      real_t meanVel(real_t(0));
-      real_t maxVel(real_t(0));
+      auto numSediments = uint_t(0);
+      auto meanPos = real_t(0);
+      auto meanVel = real_t(0);
+      auto maxVel = real_t(0);
 
       for( auto blockIt = blocks_->begin(); blockIt != blocks_->end(); ++blockIt )
       {
@@ -713,7 +711,7 @@ void clearBoundaryHandling( BlockForest & forest, const BlockDataID & boundaryHa
 {
    for( auto blockIt = forest.begin(); blockIt != forest.end(); ++blockIt )
    {
-      BoundaryHandling_T * boundaryHandling = blockIt->getData<BoundaryHandling_T>(boundaryHandlingID);
+      auto * boundaryHandling = blockIt->getData<BoundaryHandling_T>(boundaryHandlingID);
       boundaryHandling->clear( FieldGhostLayers );
    }
 }
@@ -722,7 +720,7 @@ void clearBodyField( BlockForest & forest, const BlockDataID & bodyFieldID )
 {
    for( auto blockIt = forest.begin(); blockIt != forest.end(); ++blockIt )
    {
-      BodyField_T * bodyField = blockIt->getData<BodyField_T>(bodyFieldID);
+      auto * bodyField = blockIt->getData<BodyField_T>(bodyFieldID);
       bodyField->setWithGhostLayer( NULL );
    }
 }
@@ -731,7 +729,7 @@ void recreateBoundaryHandling( BlockForest & forest, const BlockDataID & boundar
 {
    for( auto blockIt = forest.begin(); blockIt != forest.end(); ++blockIt )
    {
-      BoundaryHandling_T * boundaryHandling = blockIt->getData<BoundaryHandling_T>(boundaryHandlingID);
+      auto * boundaryHandling = blockIt->getData<BoundaryHandling_T>(boundaryHandlingID);
       boundaryHandling->fillWithDomain( FieldGhostLayers );
    }
 }
@@ -747,22 +745,22 @@ public:
    real_t getTimings(const std::vector<std::string> & timerNames, uint_t level )
    {
 
-      real_t timing = real_t(0);
-      for( auto timerIt = timerNames.begin(); timerIt != timerNames.end(); ++timerIt )
+      auto timing = real_t(0);
+      for (const auto &timerName : timerNames)
       {
-         std::string timerNameLvlWise = *timerIt;// +
+         std::string timerNameLvlWise = timerName;// +
          // put level between timer string and possible suffix
-         auto suffixBegin = timerNameLvlWise.find_first_of("[");
+         auto suffixBegin = timerNameLvlWise.find_first_of('[');
          if( suffixBegin != std::string::npos)
          {
             // suffix detected
-            auto suffixEnd = timerNameLvlWise.find_last_of("]");
+            auto suffixEnd = timerNameLvlWise.find_last_of(']');
             if( suffixEnd != std::string::npos)
             {
                auto timerString = timerNameLvlWise.substr(0,suffixBegin);
                auto suffixString = timerNameLvlWise.substr(suffixBegin,suffixEnd-suffixBegin+1);
 
-               timerNameLvlWise = timerString + "(" + std::to_string(level) + ") " + suffixString;
+               timerNameLvlWise = timerString + "(" + std::to_string(level) + ") " + suffixString; // NOLINT
 
             }
             else
@@ -780,9 +778,8 @@ public:
 
          if( level == numberOfLevels_- 1)
          {
-            std::string timerNamePE = *timerIt;
-            if( peTimingTree_.timerExists(timerNamePE))
-               timing += peTimingTree_[timerNamePE].total();
+            if( peTimingTree_.timerExists(timerName))
+               timing += peTimingTree_[timerName].total();
          }
       }
 
@@ -802,18 +799,18 @@ real_t weightEvaluation(BlockForest & forest,
                         const shared_ptr<pe_coupling::InfoCollection>& couplingInfoCollection,
                         const shared_ptr<pe::InfoCollection> & peInfoCollection,
                         real_t peBlockBaseWeight,
-                        std::string loadEvaluationStrategy,
+                        const std::string & loadEvaluationStrategy,
                         uint_t level,
                         bool useEllipsoids )
 {
-   real_t weight = real_t(0);
+   auto weight = real_t(0);
    for( auto blockIt = forest.begin(); blockIt != forest.end(); ++blockIt )
    {
       if( forest.getLevel(*blockIt) != level) continue;
 
 
-      blockforest::Block* block = static_cast<blockforest::Block*> (&(*blockIt));
-      auto blockID = block->getId();
+      auto * block = static_cast<blockforest::Block*> (&(*blockIt));
+      const auto &blockID = block->getId();
 
       if(loadEvaluationStrategy == "LBM")
       {
@@ -849,11 +846,11 @@ uint_t evaluateEdgeCut(BlockForest & forest)
 
    //note: only works for edges in uniform grids
 
-   uint_t edgecut = uint_t(0); // = edge weights between processes
+   auto edgecut = uint_t(0); // = edge weights between processes
 
    for( auto blockIt = forest.begin(); blockIt != forest.end(); ++blockIt )
    {
-      blockforest::Block* block = static_cast<blockforest::Block*> (&(*blockIt));
+      auto * block = static_cast<blockforest::Block*> (&(*blockIt));
 
       real_t blockVolume = block->getAABB().volume();
       real_t approximateEdgeLength = std::cbrt( blockVolume );
@@ -865,7 +862,7 @@ uint_t evaluateEdgeCut(BlockForest & forest)
 
       for( const uint_t idx : blockforest::getFaceNeighborhoodSectionIndices() )
       {
-         for( uint_t nb = uint_t(0); nb < block->getNeighborhoodSectionSize(idx); ++nb )
+         for (auto nb = uint_t(0); nb < block->getNeighborhoodSectionSize(idx); ++nb)
          {
             if( block->neighborExistsRemotely(idx,nb) ) edgecut += faceNeighborWeight;
          }
@@ -873,7 +870,7 @@ uint_t evaluateEdgeCut(BlockForest & forest)
 
       for( const uint_t idx : blockforest::getEdgeNeighborhoodSectionIndices() )
       {
-         for( uint_t nb = uint_t(0); nb < block->getNeighborhoodSectionSize(idx); ++nb )
+         for (auto nb = uint_t(0); nb < block->getNeighborhoodSectionSize(idx); ++nb)
          {
             if( block->neighborExistsRemotely(idx,nb) ) edgecut += edgeNeighborWeight;
          }
@@ -881,7 +878,7 @@ uint_t evaluateEdgeCut(BlockForest & forest)
 
       for( const uint_t idx : blockforest::getCornerNeighborhoodSectionIndices() )
       {
-         for( uint_t nb = uint_t(0); nb < block->getNeighborhoodSectionSize(idx); ++nb )
+         for (auto nb = uint_t(0); nb < block->getNeighborhoodSectionSize(idx); ++nb)
          {
             if( block->neighborExistsRemotely(idx,nb) ) edgecut += cornerNeighborWeight;
          }
@@ -896,14 +893,14 @@ void evaluateTotalSimulationTimePassed(WcTimingPool & timeloopTimingPool, real_t
    shared_ptr< WcTimingPool> reduced = timeloopTimingPool.getReduced(WcTimingPool::REDUCE_TOTAL, 0);
 
    std::string simulationString("LBM refinement time step");
-   real_t totalTime = real_t(0);
+   auto totalTime = real_t(0);
    WALBERLA_ROOT_SECTION(){
       totalTime = (*reduced)[simulationString].total();
    }
    totalSimTime = totalTime;
 
    std::string lbString("refinement checking");
-   real_t lbTime = real_t(0);
+   auto lbTime = real_t(0);
    WALBERLA_ROOT_SECTION(){
       lbTime = (*reduced)[lbString].total();
    }
@@ -920,9 +917,9 @@ void createSedimentLayer(uint_t numberOfSediments, const AABB & generationDomain
 {
    WALBERLA_LOG_INFO_ON_ROOT("Starting creation of sediments");
 
-   real_t xParticle = real_t(0);
-   real_t yParticle = real_t(0);
-   real_t zParticle = real_t(0);
+   auto xParticle = real_t(0);
+   auto yParticle = real_t(0);
+   auto zParticle = real_t(0);
 
    for( uint_t nSed = 0; nSed < numberOfSediments; ++nSed )
    {
@@ -944,7 +941,7 @@ void createSedimentLayer(uint_t numberOfSediments, const AABB & generationDomain
       if( useEllipsoids )
       {
          // prolate ellipsoids
-         real_t axisFactor = real_t(1.5);
+         auto axisFactor = real_t(1.5);
          real_t axisFactor2 = std::sqrt(real_t(1)/axisFactor);
          real_t radius = diameter * real_t(0.5);
          pe::createEllipsoid( *globalBodyStorage, blocks->getBlockStorage(), bodyStorageID, 0, Vector3<real_t>( xParticle, yParticle, zParticle ), Vector3<real_t>(axisFactor*radius, axisFactor2*radius, axisFactor2*radius), peMaterial );
@@ -959,7 +956,7 @@ void createSedimentLayer(uint_t numberOfSediments, const AABB & generationDomain
    syncCall();
 
    // carry out 100 simulations to resolve all overlaps
-   for( uint_t pet = uint_t(1); pet <= uint_t(100); ++pet )
+   for (auto pet = uint_t(1); pet <= uint_t(100); ++pet)
    {
       cr.timestep( real_t(1) );
       syncCall();
@@ -976,15 +973,15 @@ void createSedimentLayer(uint_t numberOfSediments, const AABB & generationDomain
    }
 
 
-   const uint_t maxInitialPeSteps = (shortRun) ? uint_t(10) : uint_t(200000);
-   const real_t dt_PE_init = real_t(1);
+   const auto maxInitialPeSteps = (shortRun) ? uint_t(10) : uint_t(200000);
+   const auto dt_PE_init = real_t(1);
 
    real_t gravityGeneration = real_t(0.1) * gravitationalAcceleration;
    cr.setGlobalLinearAcceleration(Vector3<real_t>(real_t(0), real_t(0), gravityGeneration));
 
-   real_t oldMinBodyPosition = real_t(0);
+   auto oldMinBodyPosition = real_t(0);
    real_t convergenceLimit = std::fabs(gravityGeneration);
-   for( uint_t pet = uint_t(1); pet <= maxInitialPeSteps; ++pet )
+   for (auto pet = uint_t(1); pet <= maxInitialPeSteps; ++pet)
    {
       cr.timestep( dt_PE_init );
       syncCall();
@@ -1025,9 +1022,9 @@ void createSedimentLayer(uint_t numberOfSediments, const AABB & generationDomain
    cr.setGlobalLinearAcceleration(Vector3<real_t>(real_t(0), real_t(0), -gravityGeneration));
 
    // carry out a few time steps to relax the system towards the real condition
-   const uint_t relaxationTimeSteps = uint_t(std::sqrt(real_t(2)/std::fabs(gravitationalAcceleration)));
+   const auto relaxationTimeSteps = uint_t(std::sqrt(real_t(2)/std::fabs(gravitationalAcceleration)));
    WALBERLA_LOG_INFO_ON_ROOT("Carrying out " << relaxationTimeSteps << " more time steps with correct gravity");
-   for( uint_t pet = uint_t(1); pet <= relaxationTimeSteps; ++pet )
+   for (auto pet = uint_t(1); pet <= relaxationTimeSteps; ++pet)
    {
       cr.timestep(dt_PE_init);
       syncCall();
@@ -1101,31 +1098,31 @@ int main( int argc, char **argv )
    std::string baseFolder = "vtk_out_AMRSedimentSettling"; // folder for vtk and file output
 
    // physical setup
-   real_t GalileoNumber = real_t(50);
-   real_t densityRatio = real_t(1.5);
-   real_t diameter = real_t(15);
-   real_t solidVolumeFraction = real_t(0.1);
-   uint_t blockSize = uint_t(32);
-   uint_t XBlocks = uint_t(12);
-   uint_t YBlocks = uint_t(12);
-   uint_t ZBlocks = uint_t(16);
+   auto GalileoNumber = real_t(50);
+   auto densityRatio = real_t(1.5);
+   auto diameter = real_t(15);
+   auto solidVolumeFraction = real_t(0.1);
+   auto blockSize = uint_t(32);
+   auto XBlocks = uint_t(12);
+   auto YBlocks = uint_t(12);
+   auto ZBlocks = uint_t(16);
    bool useBox = false;
    bool useHopper = false;
    bool useEllipsoids = false;
-   real_t hopperRelHeight = real_t(0.5); // for hopper setup
-   real_t hopperRelOpening = real_t(0.3); // for hopper setup
+   auto hopperRelHeight = real_t(0.5); // for hopper setup
+   auto hopperRelOpening = real_t(0.3); // for hopper setup
 
-   uint_t timestepsOnFinestLevel = uint_t(80000);
+   auto timestepsOnFinestLevel = uint_t(80000);
 
    //numerical parameters
    bool averageForceTorqueOverTwoTimSteps = true;
-   uint_t numberOfLevels = uint_t(1);
-   uint_t refinementCheckFrequency = uint_t(100);
-   uint_t numPeSubCycles = uint_t(10);
+   auto numberOfLevels = uint_t(1);
+   auto refinementCheckFrequency = uint_t(100);
+   auto numPeSubCycles = uint_t(10);
 
    // refinement criteria
-   real_t lowerFluidRefinementLimit = real_t(0);
-   real_t upperFluidRefinementLimit = std::numeric_limits<real_t>::infinity();
+   auto lowerFluidRefinementLimit = real_t(0);
+   auto upperFluidRefinementLimit = std::numeric_limits<real_t>::infinity();
    bool useVorticityCriterion = false;
    bool useGradientCriterion = false;
 
@@ -1133,12 +1130,12 @@ int main( int argc, char **argv )
    std::string loadEvaluationStrategy = "LBM"; //LBM, PE, Fit
    std::string loadDistributionStrategy = "Hilbert"; //Morton, Hilbert, ParMetis, Diffusive
 
-   real_t parMetis_ipc2redist = real_t(1000);
-   real_t parMetisTolerance = real_t(-1);
+   auto parMetis_ipc2redist = real_t(1000);
+   auto parMetisTolerance = real_t(-1);
    std::string parMetisAlgorithmString = "ADAPTIVE_REPART";
 
-   uint_t diffusionFlowIterations = uint_t(15);
-   uint_t diffusionMaxIterations = uint_t(20);
+   auto diffusionFlowIterations = uint_t(15);
+   auto diffusionMaxIterations = uint_t(20);
 
 
    for( int i = 1; i < argc; ++i )
@@ -1232,7 +1229,7 @@ int main( int argc, char **argv )
    //////////////////////////
 
    const Vector3<uint_t> domainSize( XBlocks * blockSize, YBlocks * blockSize, ZBlocks * blockSize );
-   const real_t domainVolume = real_t(domainSize[0] * domainSize[1] * domainSize[2]);
+   const auto domainVolume = real_t(domainSize[0] * domainSize[1] * domainSize[2]);
    const real_t sphereVolume = math::M_PI / real_t(6) * diameter * diameter * diameter;
    const uint_t numberOfSediments = uint_c(std::ceil(solidVolumeFraction * domainVolume / sphereVolume));
 
@@ -1240,7 +1237,7 @@ int main( int argc, char **argv )
    const real_t expectedSedimentedVolume = real_t(1)/expectedSedimentVolumeFraction * real_c(numberOfSediments) * sphereVolume;
    const real_t expectedSedimentedHeight = std::max(diameter, expectedSedimentedVolume / real_c(domainSize[0] * domainSize[1]));
 
-   const real_t uRef = real_t(0.02);
+   const auto uRef = real_t(0.02);
    const real_t xRef = diameter;
    const real_t tRef = xRef / uRef;
 
@@ -1249,9 +1246,9 @@ int main( int argc, char **argv )
    const real_t omega = lbm::collision_model::omegaFromViscosity(viscosity);
    const real_t tau = real_t(1) / omega;
 
-   const uint_t loggingDisplayFrequency = uint_t(100);
+   const auto loggingDisplayFrequency = uint_t(100);
 
-   const real_t dx = real_t(1);
+   const auto dx = real_t(1);
    const real_t overlap = real_t( 1.5 ) * dx;
 
    if( useVorticityCriterion && floatIsEqual(lowerFluidRefinementLimit, real_t(0)) && std::isinf(upperFluidRefinementLimit) )
@@ -1327,8 +1324,8 @@ int main( int argc, char **argv )
 
    if( refinementCheckFrequency == 0 && numberOfLevels != 1 )
    {
-      // determine check frequency automatically based on maximum admissable velocity and block sizes
-      real_t uMax = real_t(0.1);
+      // determine check frequency automatically based on maximum admissible velocity and block sizes
+      auto uMax = real_t(0.1);
       refinementCheckFrequency = uint_c(( overlap + real_c(blockSize) - real_t(2) * real_t(FieldGhostLayers) * dx) / uMax) / lbmTimeStepsPerTimeLoopIteration;
    }
    WALBERLA_LOG_INFO_ON_ROOT(" - refinement / load balancing check frequency (coarse time steps): " << refinementCheckFrequency);
@@ -1453,7 +1450,7 @@ int main( int argc, char **argv )
 
       blockforest.setRefreshMinTargetLevelDeterminationFunction( initialMinTargetLevelDeterminationFunctions );
 
-      for( uint_t refreshCycle = uint_t(0); refreshCycle < finestLevel; ++refreshCycle)
+      for ( auto refreshCycle = uint_t(0); refreshCycle < finestLevel; ++refreshCycle)
       {
 
          WALBERLA_LOG_INFO_ON_ROOT("Refreshing blockforest...")
@@ -1477,7 +1474,7 @@ int main( int argc, char **argv )
 
          for (auto blockIt = blocks->begin(); blockIt != blocks->end(); ++blockIt)
          {
-            pe::ccd::ICCD* ccd = blockIt->getData< pe::ccd::ICCD >( ccdID );
+            auto * ccd = blockIt->getData< pe::ccd::ICCD >( ccdID );
             ccd->reloadBodies();
          }
       }
@@ -1505,7 +1502,7 @@ int main( int argc, char **argv )
    BlockDataID flagFieldID = field::addFlagFieldToStorage<FlagField_T>( blocks, "flag field", FieldGhostLayers );
 
    // add body field
-   BlockDataID bodyFieldID = field::addToStorage<BodyField_T>( blocks, "body field", NULL, field::zyxf, FieldGhostLayers );
+   BlockDataID bodyFieldID = field::addToStorage<BodyField_T>( blocks, "body field", nullptr, field::zyxf, FieldGhostLayers );
 
    // add velocity field and utility
    BlockDataID velocityFieldID = field::addToStorage<VelocityField_T>( blocks, "velocity field", Vector3<real_t>(real_t(0)), field::zyxf, uint_t(2) );
@@ -1590,7 +1587,7 @@ int main( int argc, char **argv )
    bool curveAllGather = true;
    bool balanceLevelwise = true;
 
-   real_t peBlockBaseWeight = real_t(1); //default value, might not be the best
+   auto peBlockBaseWeight = real_t(1); //default value, might not be the best
    shared_ptr<pe::InfoCollection> peInfoCollection = walberla::make_shared<pe::InfoCollection>();
 
    if( loadDistributionStrategy == "Hilbert" || loadDistributionStrategy == "Morton")
@@ -1934,41 +1931,41 @@ int main( int argc, char **argv )
    }
 
    std::vector<std::string> LBMTimer;
-   LBMTimer.push_back("collide");
-   LBMTimer.push_back("stream");
-   LBMTimer.push_back("stream & collide");
+   LBMTimer.emplace_back("collide");
+   LBMTimer.emplace_back("stream");
+   LBMTimer.emplace_back("stream & collide");
 
    std::vector<std::string> bhTimer;
-   bhTimer.push_back("boundary handling");
+   bhTimer.emplace_back("boundary handling");
 
    std::vector<std::string> couplingTimer1;
-   couplingTimer1.push_back("Body Mapping");
+   couplingTimer1.emplace_back("Body Mapping");
    std::vector<std::string> couplingTimer2;
-   couplingTimer2.push_back("PDF Restore");
+   couplingTimer2.emplace_back("PDF Restore");
 
    std::vector<std::string> peTimer;
-   peTimer.push_back("Simulation Step.Collision Detection");
-   peTimer.push_back("Simulation Step.Collision Response Integration");
-   peTimer.push_back("Simulation Step.Collision Response Resolution.Collision Response Solving");
+   peTimer.emplace_back("Simulation Step.Collision Detection");
+   peTimer.emplace_back("Simulation Step.Collision Response Integration");
+   peTimer.emplace_back("Simulation Step.Collision Response Resolution.Collision Response Solving");
 
    std::vector<std::string> LBMCommTimer;
-   LBMCommTimer.push_back("communication equal level [pack & send]");
-   LBMCommTimer.push_back("communication equal level [wait & unpack]");
+   LBMCommTimer.emplace_back("communication equal level [pack & send]");
+   LBMCommTimer.emplace_back("communication equal level [wait & unpack]");
 
    std::vector<std::string> peCommTimer;
    //Adapt if using different collision response (like DEM!)
-   peCommTimer.push_back("Simulation Step.Collision Response Resolution.Velocity Sync");
-   peCommTimer.push_back("Sync");
+   peCommTimer.emplace_back("Simulation Step.Collision Response Resolution.Velocity Sync");
+   peCommTimer.emplace_back("Sync");
 
 
    real_t terminationPosition = expectedSedimentedHeight;
    real_t terminationVelocity = real_t(0.05) * uRef;
 
-   real_t oldmTotSim = real_t(0);
-   real_t oldmLB = real_t(0);
+   auto oldmTotSim = real_t(0);
+   auto oldmLB = real_t(0);
 
-   uint_t measurementFileCounter = uint_t(0);
-   uint_t predictionFileCounter = uint_t(0);
+   auto measurementFileCounter = uint_t(0);
+   auto predictionFileCounter = uint_t(0);
 
    std::string loadEvaluationStep("load evaluation");
 
@@ -2119,7 +2116,7 @@ int main( int argc, char **argv )
                syncCall();
 
                for (auto blockIt = blocks->begin(); blockIt != blocks->end(); ++blockIt) {
-                  pe::ccd::ICCD *ccd = blockIt->getData<pe::ccd::ICCD>(ccdID);
+                  auto * ccd = blockIt->getData<pe::ccd::ICCD>(ccdID);
                   ccd->reloadBodies();
                }
 
@@ -2168,26 +2165,24 @@ int main( int argc, char **argv )
          // write process local load predictions to files (per process, per load balancing step)
          {
 
-            real_t wlLBM = real_t(0);
-            real_t wlBH = real_t(0);
-            real_t wlCoup1 = real_t(0);
-            real_t wlCoup2 = real_t(0);
-            real_t wlRB = real_t(0);
+            auto wlLBM = real_t(0);
+            auto wlBH = real_t(0);
+            auto wlCoup1 = real_t(0);
+            auto wlCoup2 = real_t(0);
+            auto wlRB = real_t(0);
 
             auto & forest = blocks->getBlockForest();
             pe_coupling::createWithNeighborhood<BoundaryHandling_T>(forest, boundaryHandlingID, bodyStorageID, ccdID, fcdID, numPeSubCycles, *couplingInfoCollection);
 
             for( auto blockIt = forest.begin(); blockIt != forest.end(); ++blockIt ) {
-               blockforest::Block *block = static_cast<blockforest::Block *> (&(*blockIt));
-               auto blockID = block->getId();
+               auto * block = static_cast<blockforest::Block *> (&(*blockIt));
+               const auto &blockID = block->getId();
                auto infoIt = couplingInfoCollection->find(blockID);
                auto blockInfo = infoIt->second;
 
                if( useEllipsoids )
                {
-
                   WALBERLA_ABORT("Not yet implemented!");
-
                }
                else
                {
diff --git a/apps/benchmarks/AdaptiveMeshRefinementFluidParticleCoupling/WorkloadEvaluation.cpp b/apps/benchmarks/AdaptiveMeshRefinementFluidParticleCoupling/WorkloadEvaluation.cpp
index 038b054a5..0a4fef688 100644
--- a/apps/benchmarks/AdaptiveMeshRefinementFluidParticleCoupling/WorkloadEvaluation.cpp
+++ b/apps/benchmarks/AdaptiveMeshRefinementFluidParticleCoupling/WorkloadEvaluation.cpp
@@ -57,6 +57,7 @@
 #include "timeloop/SweepTimeloop.h"
 
 #include "pe/basic.h"
+#include "pe/cr/ICR.h"
 #include "pe/fcd/GJKEPACollideFunctor.h"
 #include "pe/vtk/BodyVtkOutput.h"
 #include "pe/vtk/EllipsoidVtkOutput.h"
@@ -140,9 +141,9 @@ BoundaryHandling_T * MyBoundaryHandling::operator()( IBlock * const block, const
    WALBERLA_ASSERT_NOT_NULLPTR( block );
    WALBERLA_ASSERT_NOT_NULLPTR( storage );
 
-   FlagField_T * flagField       = block->getData< FlagField_T >( flagFieldID_ );
-   PdfField_T *  pdfField        = block->getData< PdfField_T > ( pdfFieldID_ );
-   BodyField_T * bodyField       = block->getData< BodyField_T >( bodyFieldID_ );
+   auto * flagField = block->getData< FlagField_T >( flagFieldID_ );
+   auto *  pdfField = block->getData< PdfField_T > ( pdfFieldID_ );
+   auto * bodyField = block->getData< BodyField_T >( bodyFieldID_ );
 
    const auto fluid = flagField->flagExists( Fluid_Flag ) ? flagField->getFlag( Fluid_Flag ) : flagField->registerFlag( Fluid_Flag );
 
@@ -163,7 +164,7 @@ BoundaryHandling_T * MyBoundaryHandling::operator()( IBlock * const block, const
 class CollisionPropertiesEvaluator
 {
 public:
-   CollisionPropertiesEvaluator( pe::cr::ICR & collisionResponse ) : collisionResponse_( collisionResponse )
+   explicit CollisionPropertiesEvaluator( pe::cr::ICR & collisionResponse ) : collisionResponse_( collisionResponse )
    {}
 
    real_t get()
@@ -189,12 +190,12 @@ public:
 
    real_t get()
    {
-      real_t maximumPenetration = real_t(0);
+      auto maximumPenetration = real_t(0);
       for (auto it = blocks_->begin(); it != blocks_->end(); ++it) {
          IBlock &currentBlock = *it;
 
-         pe::ccd::ICCD *ccd = currentBlock.getData<pe::ccd::ICCD>(ccdID_);
-         pe::fcd::IFCD *fcd = currentBlock.getData<pe::fcd::IFCD>(fcdID_);
+         auto *ccd = currentBlock.getData<pe::ccd::ICCD>(ccdID_);
+         auto *fcd = currentBlock.getData<pe::fcd::IFCD>(fcdID_);
          ccd->generatePossibleContacts();
          pe::Contacts& contacts = fcd->generateContacts( ccd->getPossibleContacts() );
          size_t numContacts( contacts.size() );
@@ -226,9 +227,9 @@ public:
 
    Vector3<real_t> get()
    {
-      real_t maxVelX = real_t(0);
-      real_t maxVelY = real_t(0);
-      real_t maxVelZ = real_t(0);
+      auto maxVelX = real_t(0);
+      auto maxVelY = real_t(0);
+      auto maxVelZ = real_t(0);
 
       for (auto it = blocks_->begin(); it != blocks_->end(); ++it) {
 
@@ -250,7 +251,7 @@ public:
 
    real_t getMagnitude()
    {
-      real_t magnitude = real_t(0);
+      auto magnitude = real_t(0);
 
       for (auto it = blocks_->begin(); it != blocks_->end(); ++it) {
 
@@ -277,13 +278,13 @@ void evaluateFluidQuantities(const shared_ptr< StructuredBlockStorage > & blocks
 
    for( auto blockIt = blocks->begin(); blockIt != blocks->end(); ++blockIt)
    {
-      BoundaryHandling_T * boundaryHandling = blockIt->getData< BoundaryHandling_T >( boundaryHandlingID );
+      auto * boundaryHandling = blockIt->getData< BoundaryHandling_T >( boundaryHandlingID );
       auto xyzSize = boundaryHandling->getFlagField()->xyzSize();
       numCells += xyzSize.numCells();
 
-      for( cell_idx_t z = cell_idx_t(xyzSize.zMin()); z <= cell_idx_t(xyzSize.zMax()); ++z ){
-         for( cell_idx_t y = cell_idx_t(xyzSize.yMin()); y <= cell_idx_t(xyzSize.yMax()); ++y ){
-            for( cell_idx_t x = cell_idx_t(xyzSize.xMin()); x <= cell_idx_t(xyzSize.xMax()); ++x ) {
+      for(auto z = cell_idx_t(xyzSize.zMin()); z <= cell_idx_t(xyzSize.zMax()); ++z ){
+         for(auto y = cell_idx_t(xyzSize.yMin()); y <= cell_idx_t(xyzSize.yMax()); ++y ){
+            for(auto x = cell_idx_t(xyzSize.xMin()); x <= cell_idx_t(xyzSize.xMax()); ++x ) {
                if (boundaryHandling->isDomain(x, y, z)) {
                   ++numFluidCells;
                }
@@ -297,22 +298,18 @@ void evaluateFluidQuantities(const shared_ptr< StructuredBlockStorage > & blocks
 }
 
 void evaluatePEQuantities( const shared_ptr< StructuredBlockStorage > & blocks, const BlockDataID bodyStorageID,
-                           const BlockDataID ccdID, const BlockDataID fcdID,
+                           const pe::cr::ICR & cr,
                            uint_t & numLocalParticles, uint_t & numShadowParticles, uint_t & numContacts)
 {
 
    for( auto blockIt = blocks->begin(); blockIt != blocks->end(); ++blockIt) {
-      pe::Storage * bodyStorage = blockIt->getData<pe::Storage>(bodyStorageID);
+      auto * bodyStorage = blockIt->getData<pe::Storage>(bodyStorageID);
       pe::BodyStorage const & localStorage  = (*bodyStorage)[pe::StorageType::LOCAL];
       pe::BodyStorage const & shadowStorage = (*bodyStorage)[pe::StorageType::SHADOW];
       numLocalParticles += localStorage.size();
       numShadowParticles += shadowStorage.size();
 
-      pe::ccd::ICCD * ccd = blockIt->getData<pe::ccd::ICCD>(ccdID);
-      pe::fcd::IFCD * fcd = blockIt->getData<pe::fcd::IFCD>(fcdID);
-      ccd->generatePossibleContacts();
-      pe::Contacts& contacts = fcd->generateContacts( ccd->getPossibleContacts() );
-      numContacts += contacts.size();
+      numContacts += cr.getNumberOfContactsTreated();
    }
 }
 
@@ -321,22 +318,21 @@ void evaluateTimers(WcTimingPool & timingPool, WcTimingTree & peTimingTree,
                     std::vector<real_t> & timings )
 {
 
-   for( auto timingsIt = timings.begin(); timingsIt != timings.end(); ++timingsIt )
+   for (auto & timingsIt : timings)
    {
-      *timingsIt = real_t(0);
+      timingsIt = real_t(0);
    }
 
    timingPool.unifyRegisteredTimersAcrossProcesses();
    peTimingTree.synchronize();
 
-   real_t scalingFactor = real_t(1000); // milliseconds
+   auto scalingFactor = real_t(1000); // milliseconds
 
-   for(uint_t i = uint_t(0); i < timerKeys.size(); ++i )
+   for (auto i = uint_t(0); i < timerKeys.size(); ++i )
    {
       auto keys = timerKeys[i];
-      for(auto keyIt = keys.begin(); keyIt != keys.end(); ++keyIt)
+      for (const auto &timerName : keys)
       {
-         std::string timerName = *keyIt;
          if(timingPool.timerExists(timerName))
          {
             timings[i] += real_c(timingPool[timerName].total()) * scalingFactor;
@@ -381,19 +377,19 @@ int main( int argc, char **argv )
    mpi::Environment env( argc, argv );
 
 
-   real_t solidVolumeFraction = real_t(0.2);
+   auto solidVolumeFraction = real_t(0.2);
 
    // LBM / numerical parameters
-   uint_t blockSize  = uint_t(32);
-   real_t uSettling = real_t(0.1); // characteristic settling velocity
-   real_t diameter = real_t(10);
+   auto blockSize  = uint_t(32);
+   auto uSettling = real_t(0.1); // characteristic settling velocity
+   auto diameter = real_t(10);
 
-   real_t Ga = real_t(30); //Galileo number
-   uint_t numPeSubCycles = uint_t(10);
+   auto Ga = real_t(30); //Galileo number
+   auto numPeSubCycles = uint_t(10);
 
-   uint_t vtkIOFreq = 0;
-   real_t timestepsNonDim = real_t(2.5);
-   uint_t numSamples = uint_t(2000);
+   auto vtkIOFreq = uint_t(0);
+   auto timestepsNonDim = real_t(2.5);
+   auto numSamples = uint_t(2000);
    std::string baseFolder = "workload_files"; // folder for vtk and file output
 
    bool useEllipsoids = false;
@@ -437,9 +433,9 @@ int main( int argc, char **argv )
    // SIMULATION PROPERTIES //
    ///////////////////////////
 
-   const uint_t XBlocks = uint_t(4);
-   const uint_t YBlocks = uint_t(4);
-   const uint_t ZBlocks = uint_t(5);
+   const auto XBlocks = uint_t(4);
+   const auto YBlocks = uint_t(4);
+   const auto ZBlocks = uint_t(5);
 
    if( MPIManager::instance()->numProcesses() != XBlocks * YBlocks * ZBlocks )
    {
@@ -471,7 +467,7 @@ int main( int argc, char **argv )
    uint_t numberOfParticles = uint_c(std::ceil(solidVolume / ( math::M_PI / real_t(6) * diameter * diameter * diameter )));
    diameter = std::cbrt( solidVolume / ( real_c(numberOfParticles) * math::M_PI / real_t(6) ) );
 
-   real_t densityRatio = real_t(2.5);
+   auto densityRatio = real_t(2.5);
 
    real_t viscosity = uSettling * diameter / Ga;
    const real_t omega = lbm::collision_model::omegaFromViscosity(viscosity);
@@ -554,9 +550,9 @@ int main( int argc, char **argv )
    pe::createPlane( *globalBodyStorage, 0, Vector3<real_t>(0,0,1), Vector3<real_t>(0,0,0), peMaterial );
    pe::createPlane( *globalBodyStorage, 0, Vector3<real_t>(0,0,-1), Vector3<real_t>(0,0,real_c(ZCells)-topWallOffset), peMaterial );
 
-   real_t xParticle = real_t(0);
-   real_t yParticle = real_t(0);
-   real_t zParticle = real_t(0);
+   auto xParticle = real_t(0);
+   auto yParticle = real_t(0);
+   auto zParticle = real_t(0);
 
    for( uint_t nPart = 0; nPart < numberOfParticles; ++nPart )
    {
@@ -578,7 +574,7 @@ int main( int argc, char **argv )
       if( useEllipsoids )
       {
          // prolate ellipsoids
-         real_t axisFactor = real_t(1.5);
+         auto axisFactor = real_t(1.5);
          real_t axisFactor2 = std::sqrt(real_t(1)/axisFactor);
          real_t radius = diameter * real_t(0.5);
          pe::createEllipsoid( *globalBodyStorage, blocks->getBlockStorage(), bodyStorageID, 0, Vector3<real_t>( xParticle, yParticle, zParticle ), Vector3<real_t>(axisFactor*radius, axisFactor2*radius, axisFactor2*radius), peMaterial );
@@ -595,7 +591,7 @@ int main( int argc, char **argv )
 
    // 100 iterations of solver to resolve all major overlaps
    {
-      for( uint_t pet = uint_t(1); pet <= uint_t(100); ++pet )
+      for (auto pet = uint_t(1); pet <= uint_t(100); ++pet )
       {
          cr.timestep( real_t(1) );
          syncCall();
@@ -615,8 +611,8 @@ int main( int argc, char **argv )
 
    // resolve remaining overlaps via particle simulation
    {
-      const uint_t initialPeSteps = uint_t(2000);
-      const real_t dt_PE_init = real_t(1);
+      const auto initialPeSteps = uint_t(2000);
+      const auto dt_PE_init = real_t(1);
       const real_t overlapLimit = real_t(0.001) * diameter;
 
       WALBERLA_LOG_INFO_ON_ROOT("Particle creation done --- resolving overlaps with goal all < " << overlapLimit / diameter * real_t(100) << "%");
@@ -626,7 +622,7 @@ int main( int argc, char **argv )
       ContactDistanceEvaluator contactDistanceEvaluator(blocks, ccdID, fcdID);
       MaxVelocityEvaluator maxVelEvaluator(blocks, bodyStorageID);
 
-      for( uint_t pet = uint_t(1); pet <= initialPeSteps; ++pet )
+      for(auto pet = uint_t(1); pet <= initialPeSteps; ++pet )
       {
          cr.timestep( dt_PE_init );
          syncCall();
@@ -695,7 +691,7 @@ int main( int argc, char **argv )
    BlockDataID flagFieldID = field::addFlagFieldToStorage<FlagField_T>( blocks, "flag field" );
 
    // add body field
-   BlockDataID bodyFieldID = field::addToStorage<BodyField_T>( blocks, "body field", NULL, field::zyxf );
+   BlockDataID bodyFieldID = field::addToStorage<BodyField_T>( blocks, "body field", nullptr, field::zyxf );
 
    // add boundary handling & initialize outer domain boundaries
    BlockDataID boundaryHandlingID = blocks->addStructuredBlockData< BoundaryHandling_T >(
@@ -850,26 +846,26 @@ int main( int argc, char **argv )
 
    std::vector< std::vector<std::string> > timerKeys;
    std::vector<std::string> LBMTimer;
-   LBMTimer.push_back("Stream&Collide");
-   LBMTimer.push_back("Stream");
-   LBMTimer.push_back("Collide");
+   LBMTimer.emplace_back("Stream&Collide");
+   LBMTimer.emplace_back("Stream");
+   LBMTimer.emplace_back("Collide");
    timerKeys.push_back(LBMTimer);
 
    std::vector<std::string> bhTimer;
-   bhTimer.push_back("Boundary Handling");
+   bhTimer.emplace_back("Boundary Handling");
    timerKeys.push_back(bhTimer);
 
    std::vector<std::string> couplingTimer1;
-   couplingTimer1.push_back("Body Mapping");
+   couplingTimer1.emplace_back("Body Mapping");
    std::vector<std::string> couplingTimer2;
-   couplingTimer2.push_back("PDF Restore");
+   couplingTimer2.emplace_back("PDF Restore");
    timerKeys.push_back(couplingTimer1);
    timerKeys.push_back(couplingTimer2);
 
    std::vector<std::string> peTimer;
-   peTimer.push_back("Simulation Step.Collision Detection");
-   peTimer.push_back("Simulation Step.Collision Response Integration");
-   peTimer.push_back("Simulation Step.Collision Response Resolution.Collision Response Solving");
+   peTimer.emplace_back("Simulation Step.Collision Detection");
+   peTimer.emplace_back("Simulation Step.Collision Response Integration");
+   peTimer.emplace_back("Simulation Step.Collision Response Resolution.Collision Response Solving");
    timerKeys.push_back(peTimer);
 
    uint_t numCells, numFluidCells, numNBCells, numLocalParticles, numShadowParticles, numContacts;
@@ -912,7 +908,7 @@ int main( int argc, char **argv )
    }
 
 
-   uint_t timeStepOfFirstTiming = uint_t(50);
+   auto timeStepOfFirstTiming = uint_t(50);
 
    if( timesteps - timeStepOfFirstTiming < numSamples )
    {
@@ -934,7 +930,7 @@ int main( int argc, char **argv )
          // include -> evaluate all timers and quantities
 
          evaluateFluidQuantities(blocks, boundaryHandlingID, numCells, numFluidCells, numNBCells);
-         evaluatePEQuantities(blocks, bodyStorageID, ccdID, fcdID, numLocalParticles, numShadowParticles, numContacts);
+         evaluatePEQuantities(blocks, bodyStorageID, cr, numLocalParticles, numShadowParticles, numContacts);
 
          evaluateTimers(timeloopTiming, timingTreePE, timerKeys, timings);
 
@@ -945,9 +941,8 @@ int main( int argc, char **argv )
             file << timeloop.getCurrentTimeStep() << " " << real_c(timeloop.getCurrentTimeStep()) / Tref << " "
                  << numCells << " " << numFluidCells << " " << numNBCells << " "
                  << numLocalParticles << " " << numShadowParticles << " " << numContacts << " " << numPeSubCycles;
-            for( auto timeIt = timings.begin(); timeIt != timings.end(); ++timeIt )
-            {
-               file << " " << *timeIt;
+            for (real_t timing : timings) {
+               file << " " << timing;
             }
             file << " " << totalTime << "\n";
          }
diff --git a/src/pe_coupling/amr/InfoCollection.h b/src/pe_coupling/amr/InfoCollection.h
index b1f1be21d..86e508e87 100644
--- a/src/pe_coupling/amr/InfoCollection.h
+++ b/src/pe_coupling/amr/InfoCollection.h
@@ -50,7 +50,7 @@ void createWithNeighborhood(BlockForest& bf, const BlockDataID boundaryHandlingI
 
    for (auto blockIt = bf.begin(); blockIt != bf.end(); ++blockIt)
    {
-      blockforest::Block* block = static_cast<blockforest::Block*> (&(*blockIt));
+      auto * block = static_cast<blockforest::Block*> (&(*blockIt));
 
       // evaluate LBM quantities
       BoundaryHandling_T * boundaryHandling = blockIt->getData< BoundaryHandling_T >( boundaryHandlingID );
@@ -70,14 +70,14 @@ void createWithNeighborhood(BlockForest& bf, const BlockDataID boundaryHandlingI
       }
 
       // evaluate PE quantities
-      pe::Storage * bodyStorage = block->getData<pe::Storage>(bodyStorageID);
+      auto * bodyStorage = block->getData<pe::Storage>(bodyStorageID);
       pe::BodyStorage const & localStorage  = (*bodyStorage)[pe::StorageType::LOCAL];
       pe::BodyStorage const & shadowStorage = (*bodyStorage)[pe::StorageType::SHADOW];
       const uint_t numLocalParticles = localStorage.size();
       const uint_t numShadowParticles = shadowStorage.size();
 
-      pe::ccd::ICCD * ccd = block->getData<pe::ccd::ICCD>(ccdID);
-      pe::fcd::IFCD * fcd = block->getData<pe::fcd::IFCD>(fcdID);
+      auto * ccd = block->getData<pe::ccd::ICCD>(ccdID);
+      auto * fcd = block->getData<pe::fcd::IFCD>(fcdID);
       ccd->generatePossibleContacts();
       pe::Contacts& contacts = fcd->generateContacts( ccd->getPossibleContacts() );
       const uint_t numContacts = contacts.size();
@@ -87,7 +87,7 @@ void createWithNeighborhood(BlockForest& bf, const BlockDataID boundaryHandlingI
 
       ic.insert( infoCollectionEntry );
 
-      for( uint_t nb = uint_t(0); nb < block->getNeighborhoodSize(); ++nb )
+      for( auto nb = uint_t(0); nb < block->getNeighborhoodSize(); ++nb )
       {
          bs.sendBuffer( block->getNeighborProcess(nb) ) << infoCollectionEntry;
       }
diff --git a/src/pe_coupling/amr/level_determination/BodyPresenceLevelDetermination.cpp b/src/pe_coupling/amr/level_determination/BodyPresenceLevelDetermination.cpp
index 4227c7cfa..5eafb9408 100644
--- a/src/pe_coupling/amr/level_determination/BodyPresenceLevelDetermination.cpp
+++ b/src/pe_coupling/amr/level_determination/BodyPresenceLevelDetermination.cpp
@@ -28,11 +28,10 @@ namespace amr {
 void BodyPresenceLevelDetermination::operator()( std::vector< std::pair< const Block *, uint_t > > & minTargetLevels,
                                                  std::vector< const Block * > &, const BlockForest & /*forest*/ )
 {
-   for( auto it = minTargetLevels.begin(); it != minTargetLevels.end(); ++it )
-   {
-      uint_t currentLevelOfBlock = it->first->getLevel();
+   for (auto &minTargetLevel : minTargetLevels) {
+      uint_t currentLevelOfBlock = minTargetLevel.first->getLevel();
 
-      const uint_t numberOfParticlesInDirectNeighborhood = getNumberOfLocalAndShadowBodiesInNeighborhood(it->first);
+      const uint_t numberOfParticlesInDirectNeighborhood = getNumberOfLocalAndShadowBodiesInNeighborhood(minTargetLevel.first);
 
       uint_t targetLevelOfBlock = currentLevelOfBlock; //keep everything as it is
       if ( numberOfParticlesInDirectNeighborhood > uint_t(0) )
@@ -48,13 +47,13 @@ void BodyPresenceLevelDetermination::operator()( std::vector< std::pair< const B
       }
 
       WALBERLA_CHECK_LESS_EQUAL(std::abs(int_c(targetLevelOfBlock) - int_c(currentLevelOfBlock)), uint_t(1), "Only level difference of maximum 1 allowed!");
-      it->second = targetLevelOfBlock;
+      minTargetLevel.second = targetLevelOfBlock;
    }
 }
 
 uint_t BodyPresenceLevelDetermination::getNumberOfLocalAndShadowBodiesInNeighborhood(const Block * block)
 {
-   uint_t numBodies = uint_t(0);
+   auto numBodies = uint_t(0);
 
    // add bodies of current block
    const auto infoIt = infoCollection_->find(block->getId());
@@ -66,7 +65,7 @@ uint_t BodyPresenceLevelDetermination::getNumberOfLocalAndShadowBodiesInNeighbor
    // add bodies of all neighboring blocks
    for(uint_t i = 0; i < block->getNeighborhoodSize(); ++i)
    {
-      BlockID neighborBlockID = block->getNeighborId(i);
+      const BlockID &neighborBlockID = block->getNeighborId(i);
       const auto infoItNeighbor = infoCollection_->find(neighborBlockID);
       WALBERLA_CHECK_UNEQUAL(infoItNeighbor, infoCollection_->end(), "Neighbor block with ID " << neighborBlockID << " not found in info collection!");
 
diff --git a/src/pe_coupling/amr/level_determination/GlobalBodyPresenceLevelDetermination.cpp b/src/pe_coupling/amr/level_determination/GlobalBodyPresenceLevelDetermination.cpp
index 7556523fa..c99118611 100644
--- a/src/pe_coupling/amr/level_determination/GlobalBodyPresenceLevelDetermination.cpp
+++ b/src/pe_coupling/amr/level_determination/GlobalBodyPresenceLevelDetermination.cpp
@@ -29,11 +29,10 @@ namespace amr {
 void GlobalBodyPresenceLevelDetermination::operator()( std::vector< std::pair< const Block *, uint_t > > & minTargetLevels,
                                                        std::vector< const Block * > &, const BlockForest & /*forest*/ )
 {
-   for( auto it = minTargetLevels.begin(); it != minTargetLevels.end(); ++it )
-   {
-      uint_t currentLevelOfBlock = it->first->getLevel();
+   for (auto &minTargetLevel : minTargetLevels) {
+      uint_t currentLevelOfBlock = minTargetLevel.first->getLevel();
 
-      auto blockExtendedAABB = it->first->getAABB().getExtended(blockExtensionLength_);
+      auto blockExtendedAABB = minTargetLevel.first->getAABB().getExtended(blockExtensionLength_);
       bool blockPartiallyOverlapsWithGlobalBodies = checkForPartialOverlapWithGlobalBodies(blockExtendedAABB);
 
       uint_t targetLevelOfBlock = currentLevelOfBlock; //keep everything as it is
@@ -50,7 +49,7 @@ void GlobalBodyPresenceLevelDetermination::operator()( std::vector< std::pair< c
       }
 
       WALBERLA_ASSERT_LESS_EQUAL(std::abs(int_c(targetLevelOfBlock) - int_c(currentLevelOfBlock)), uint_t(1), "Only level difference of maximum 1 allowed!");
-      it->second = targetLevelOfBlock;
+      minTargetLevel.second = targetLevelOfBlock;
    }
 }
 
@@ -58,7 +57,7 @@ bool GlobalBodyPresenceLevelDetermination::checkForPartialOverlapWithGlobalBodie
 {
    const Vector3<real_t> boxMidPoint( box.min() + real_t(0.5) * box.sizes());
    const Vector3<real_t> dxVec( box.sizes() );
-   const uint_t maxDepthSuperSampling = uint_t(2);
+   const auto maxDepthSuperSampling = uint_t(2);
 
    bool partialOverlapWithAllBodies = false;
 
diff --git a/src/pe_coupling/amr/weight_assignment/MetisAssignmentFunctor.cpp b/src/pe_coupling/amr/weight_assignment/MetisAssignmentFunctor.cpp
index 374648d3b..ce01d2870 100644
--- a/src/pe_coupling/amr/weight_assignment/MetisAssignmentFunctor.cpp
+++ b/src/pe_coupling/amr/weight_assignment/MetisAssignmentFunctor.cpp
@@ -27,9 +27,8 @@ namespace amr {
 
 void MetisAssignmentFunctor::operator()( std::vector< std::pair< const PhantomBlock *, walberla::any > > & blockData, const PhantomBlockForest & /*phantomBlockForest*/)
 {
-   for( auto it = blockData.begin(); it != blockData.end(); ++it )
-   {
-      const PhantomBlock * block = it->first;
+   for (auto &it : blockData) {
+      const PhantomBlock * block = it.first;
       //only change of one level is supported!
       WALBERLA_ASSERT_LESS( std::abs(int_c(block->getLevel()) - int_c(block->getSourceLevel())), 2 );
 
@@ -39,7 +38,7 @@ void MetisAssignmentFunctor::operator()( std::vector< std::pair< const PhantomBl
 
       std::vector<int64_t> metisVertexWeights(ncon_);
 
-      for( uint_t con = uint_t(0); con < ncon_; ++con )
+      for( auto con = uint_t(0); con < ncon_; ++con )
       {
          real_t vertexWeight = std::max(weightEvaluationFct_[con](blockInfo), blockBaseWeight_);
 
@@ -51,9 +50,9 @@ void MetisAssignmentFunctor::operator()( std::vector< std::pair< const PhantomBl
 
       blockforest::DynamicParMetisBlockInfo info( metisVertexWeights );
 
-      info.setVertexCoords( it->first->getAABB().center() );
+      info.setVertexCoords(it.first->getAABB().center() );
 
-      real_t blockVolume = it->first->getAABB().volume();
+      real_t blockVolume = it.first->getAABB().volume();
       real_t approximateEdgeLength = std::cbrt( blockVolume );
 
       int64_t faceNeighborWeight = int64_c(approximateEdgeLength * approximateEdgeLength ); //common face
@@ -65,32 +64,32 @@ void MetisAssignmentFunctor::operator()( std::vector< std::pair< const PhantomBl
 
       for( const uint_t idx : blockforest::getFaceNeighborhoodSectionIndices() )
       {
-         for( uint_t nb = uint_t(0); nb < it->first->getNeighborhoodSectionSize(idx); ++nb )
+         for( auto nb = uint_t(0); nb < it.first->getNeighborhoodSectionSize(idx); ++nb )
          {
-            auto neighborBlockID = it->first->getNeighborId(idx,nb);
+            auto neighborBlockID = it.first->getNeighborId(idx,nb);
             info.setEdgeWeight(neighborBlockID, faceNeighborWeight );
          }
       }
 
       for( const uint_t idx : blockforest::getEdgeNeighborhoodSectionIndices() )
       {
-         for( uint_t nb = uint_t(0); nb < it->first->getNeighborhoodSectionSize(idx); ++nb )
+         for( auto nb = uint_t(0); nb < it.first->getNeighborhoodSectionSize(idx); ++nb )
          {
-            auto neighborBlockID = it->first->getNeighborId(idx,nb);
+            auto neighborBlockID = it.first->getNeighborId(idx,nb);
             info.setEdgeWeight(neighborBlockID, edgeNeighborWeight );
          }
       }
 
       for( const uint_t idx : blockforest::getCornerNeighborhoodSectionIndices() )
       {
-         for( uint_t nb = uint_t(0); nb < it->first->getNeighborhoodSectionSize(idx); ++nb )
+         for( auto nb = uint_t(0); nb < it.first->getNeighborhoodSectionSize(idx); ++nb )
          {
-            auto neighborBlockID = it->first->getNeighborId(idx,nb);
+            auto neighborBlockID = it.first->getNeighborId(idx,nb);
             info.setEdgeWeight(neighborBlockID, cornerNeighborWeight );
          }
       }
 
-      it->second = info;
+      it.second = info;
 
    }
 }
diff --git a/src/pe_coupling/amr/weight_assignment/WeightAssignmentFunctor.cpp b/src/pe_coupling/amr/weight_assignment/WeightAssignmentFunctor.cpp
index ce64d8fbe..5fc297aa3 100644
--- a/src/pe_coupling/amr/weight_assignment/WeightAssignmentFunctor.cpp
+++ b/src/pe_coupling/amr/weight_assignment/WeightAssignmentFunctor.cpp
@@ -26,9 +26,8 @@ namespace amr {
 
 void WeightAssignmentFunctor::operator()( std::vector< std::pair< const PhantomBlock *, walberla::any > > & blockData, const PhantomBlockForest & )
 {
-   for( auto it = blockData.begin(); it != blockData.end(); ++it )
-   {
-      const PhantomBlock * block = it->first;
+   for (auto &it : blockData) {
+      const PhantomBlock * block = it.first;
       //only change of one level is supported!
       WALBERLA_ASSERT_LESS( std::abs(int_c(block->getLevel()) - int_c(block->getSourceLevel())), 2 );
 
@@ -37,7 +36,7 @@ void WeightAssignmentFunctor::operator()( std::vector< std::pair< const PhantomB
 
       real_t blockWeight = std::max(weightEvaluationFct_(blockInfo), blockBaseWeight_);
 
-      it->second = PhantomBlockWeight( double_c( blockWeight ) );
+      it.second = PhantomBlockWeight( double_c( blockWeight ) );
 
    }
 }
-- 
GitLab