From 33f63c46ca430d85ae7367fdfefc4dd1e87868e6 Mon Sep 17 00:00:00 2001
From: Frederik Hennig <frederik.hennig@fau.de>
Date: Thu, 9 Jan 2025 16:46:00 +0100
Subject: [PATCH] fix unsigned long and double occurences in blockforest

---
 src/blockforest/BlockForest.cpp                  | 8 ++++----
 src/blockforest/GlobalLoadBalancing.h            | 4 ++--
 src/blockforest/loadbalancing/DynamicDiffusive.h | 2 +-
 src/core/math/DistributedSample.cpp              | 8 ++++----
 4 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/src/blockforest/BlockForest.cpp b/src/blockforest/BlockForest.cpp
index 3137ee19a..654d7789d 100644
--- a/src/blockforest/BlockForest.cpp
+++ b/src/blockforest/BlockForest.cpp
@@ -405,8 +405,8 @@ BlockForest::BlockForest( const uint_t process, const char* const filename, cons
 
    std::array< real_t, 6 > domain;
 
-   for(double & i : domain) {
-      i = byteArrayToReal< real_t >( buffer, offset );
+   for(real_t & dom : domain) {
+      dom = byteArrayToReal< real_t >( buffer, offset );
       offset += sizeof( real_t ) + 1 + 2;
    }
 
@@ -3005,8 +3005,8 @@ void BlockForest::storeFileHeader( std::vector< uint8_t > & data, uint_t & offse
 
    // number of coarse/root blocks in each direction
 
-   for(unsigned long i : size_) {
-      uintToByteArray( i, data, offset, 4 );
+   for(uint_t s : size_) {
+      uintToByteArray( s, data, offset, 4 );
       offset += 4;
    }
 
diff --git a/src/blockforest/GlobalLoadBalancing.h b/src/blockforest/GlobalLoadBalancing.h
index 87382c185..c011e1bc2 100644
--- a/src/blockforest/GlobalLoadBalancing.h
+++ b/src/blockforest/GlobalLoadBalancing.h
@@ -386,7 +386,7 @@ uint_t GlobalLoadBalancing::balanceSorted( const std::vector< BLOCK* >& blocks,
          minWorkload = std::max( minWorkload, sortedBlocks[l][i]->getWorkload() );
          WALBERLA_ASSERT_LESS_EQUAL( sortedBlocks[l][i]->getMemory(), memoryLimit );
       }
-      for(double i : processesWork)
+      for(workload_t i : processesWork)
          minWorkload = std::max( minWorkload, i );
 
       // check min - potentially nothing more to do
@@ -696,7 +696,7 @@ void GlobalLoadBalancing::reorderProcessesByBFS( std::vector< BLOCK* > & blocks,
 
          reorderMap[p] = process++;
 
-         for(unsigned long neighbor : processNeighbors[p]) {
+         for(uint_t neighbor : processNeighbors[p]) {
             if( !processed[neighbor] ) {
                processList.push_back( neighbor );
                processed[neighbor] = true;
diff --git a/src/blockforest/loadbalancing/DynamicDiffusive.h b/src/blockforest/loadbalancing/DynamicDiffusive.h
index 1885265c4..d896508a1 100644
--- a/src/blockforest/loadbalancing/DynamicDiffusive.h
+++ b/src/blockforest/loadbalancing/DynamicDiffusive.h
@@ -769,7 +769,7 @@ bool DynamicDiffusionBalance< PhantomData_T >::operator()( std::vector< std::pai
                         assigned.insert(index);
                      }
                   }
-                  for(unsigned long & index : allBlocks[l])
+                  for(uint_t & index : allBlocks[l])
                   {
                      if( assigned.find(index) == assigned.end() )
                      {
diff --git a/src/core/math/DistributedSample.cpp b/src/core/math/DistributedSample.cpp
index 965ab8169..a2746a058 100644
--- a/src/core/math/DistributedSample.cpp
+++ b/src/core/math/DistributedSample.cpp
@@ -45,11 +45,11 @@ void DistributedSample::mpiAllGather()
    max_ = -std::numeric_limits< real_t >::max();
    size_ = uint_c( data_.size() );
 
-   for( auto it = data_.begin(); it != data_.end(); ++it )
+   for(const real_t it : data_)
    {
-      sum_ += *it;
-      min_ = std::min( min_, *it );
-      max_ = std::max( max_, *it );
+      sum_ += it;
+      min_ = std::min( min_, it );
+      max_ = std::max( max_, it );
    }
 
    WALBERLA_MPI_SECTION()
-- 
GitLab