From 3d89dfa1765144259450a20e99a57dcd6875eead Mon Sep 17 00:00:00 2001
From: Rene Halver <r.halver@fz-juelich.de>
Date: Tue, 4 Apr 2023 13:54:37 +0200
Subject: [PATCH] fixed wrong return type for getEfficiency()

---
 include/ALL_ForceBased.hpp | 16 ----------------
 include/ALL_Histogram.hpp  | 16 ----------------
 include/ALL_LB.hpp         | 16 +++++++++++++++-
 include/ALL_Staggered.hpp  | 17 -----------------
 include/ALL_Tensor.hpp     | 16 ----------------
 include/ALL_Voronoi.hpp    | 16 ----------------
 6 files changed, 15 insertions(+), 82 deletions(-)

diff --git a/include/ALL_ForceBased.hpp b/include/ALL_ForceBased.hpp
index e417e24..1b21aae 100644
--- a/include/ALL_ForceBased.hpp
+++ b/include/ALL_ForceBased.hpp
@@ -121,22 +121,6 @@ public:
   /// @param [out] double providing the estimated LB after the balance step
   virtual W getEstimatedEfficiency() override {return (W)-1;}
 
-  /// method to get the current LB efficiency with the given work distribution
-  /// @return current LB efficiency
-  virtual W getEfficiency() override
-  {
-    W localSum = (W)0;
-    for (auto i = this->work.begin(); i < this->work.end(); ++i)
-    {        
-        localSum += *i;
-    }        
-    W globalMin;
-    W globalMax;
-    MPI_Allreduce(&localSum, &globalMin, 1, MPIDataTypeW, MPI_MIN, this->globalComm);
-    MPI_Allreduce(&localSum, &globalMax, 1, MPIDataTypeW, MPI_MAX, this->globalComm);
-    return (W)(1.0 - (globalMax - globalMin) / (globalMax + globalMin));
-  }
-
 private:
   // type for MPI communication
   MPI_Datatype MPIDataTypeT;
diff --git a/include/ALL_Histogram.hpp b/include/ALL_Histogram.hpp
index 139c131..4b198b0 100644
--- a/include/ALL_Histogram.hpp
+++ b/include/ALL_Histogram.hpp
@@ -114,22 +114,6 @@ public:
   /// @param [out] double providing the estimated LB after the balance step
   virtual W getEstimatedEfficiency() override;
 
-  /// method to get the current LB efficiency with the given work distribution
-  /// @return current LB efficiency
-  virtual W getEfficiency() override
-  {
-    W localSum = (W)0;
-    for (auto i = this->work.begin(); i < this->work.end(); ++i)
-    {        
-        localSum += *i;
-    }        
-    W globalMin;
-    W globalMax;
-    MPI_Allreduce(&localSum, &globalMin, 1, MPIDataTypeW, MPI_MIN, this->globalComm);
-    MPI_Allreduce(&localSum, &globalMax, 1, MPIDataTypeW, MPI_MAX, this->globalComm);
-    return (W)(1.0 - (globalMax - globalMin) / (globalMax + globalMin));
-  }
-
 private:
   /// number of bins in each dimension
   std::vector<int> nBins;
diff --git a/include/ALL_LB.hpp b/include/ALL_LB.hpp
index aab7ae4..35e2208 100644
--- a/include/ALL_LB.hpp
+++ b/include/ALL_LB.hpp
@@ -179,7 +179,21 @@ public:
 
   /// method to get the current LB efficiency with the given work distribution
   /// @return current LB efficiency
-  virtual W getEfficiency() = 0;
+  double getEfficiency()
+  {
+    double localSum = 0.0;
+    for (auto i = this->work.begin(); i < this->work.end(); ++i)
+    {        
+        localSum += *i;
+    }        
+    double globalMin;
+    double globalMax;
+    MPI_Allreduce(&localSum, &globalMin, 1, MPI_DOUBLE, MPI_MIN, this->globalComm);
+    MPI_Allreduce(&localSum, &globalMax, 1, MPI_DOUBLE, MPI_MAX, this->globalComm);
+    return (1.0 - (double)(globalMax - globalMin) / 
+                  (double)(globalMax + globalMin));
+  }
+
 
   /// method to provide a list of vertices describing the neighboring domains
   /// currently only implemented for VORONOI, as a means to get the anchor points
diff --git a/include/ALL_Staggered.hpp b/include/ALL_Staggered.hpp
index 1478b1c..290eeed 100644
--- a/include/ALL_Staggered.hpp
+++ b/include/ALL_Staggered.hpp
@@ -96,23 +96,6 @@ public:
   /// @param [out] double providing the estimated LB after the balance step
   virtual W getEstimatedEfficiency() override {return (W)-1;};
 
-  /// method to get the current LB efficiency with the given work distribution
-  /// @return current LB efficiency
-  virtual W getEfficiency() override
-  {
-    W localSum = (W)0;
-    for (auto i = this->work.begin(); i < this->work.end(); ++i)
-    {        
-        localSum += *i;
-    }        
-    W globalMin;
-    W globalMax;
-    MPI_Allreduce(&localSum, &globalMin, 1, MPIDataTypeW, MPI_MIN, this->globalComm);
-    MPI_Allreduce(&localSum, &globalMax, 1, MPIDataTypeW, MPI_MAX, this->globalComm);
-    return (W)(1.0 - (globalMax - globalMin) / (globalMax + globalMin));
-  }
-
-
 private:
   /// data type for the communication of vertex-related data
   MPI_Datatype MPIDataTypeT;
diff --git a/include/ALL_Tensor.hpp b/include/ALL_Tensor.hpp
index 180fa81..4d32277 100644
--- a/include/ALL_Tensor.hpp
+++ b/include/ALL_Tensor.hpp
@@ -101,22 +101,6 @@ public:
   /// @param [out] double providing the estimated LB after the balance step
   virtual W getEstimatedEfficiency() override {return (W)-1;};
 
-  /// method to get the current LB efficiency with the given work distribution
-  /// @return current LB efficiency
-  virtual W getEfficiency() override
-  {
-    W localSum = (W)0;
-    for (auto i = this->work.begin(); i < this->work.end(); ++i)
-    {        
-        localSum += *i;
-    }        
-    W globalMin;
-    W globalMax;
-    MPI_Allreduce(&localSum, &globalMin, 1, MPIDataTypeW, MPI_MIN, this->globalComm);
-    MPI_Allreduce(&localSum, &globalMax, 1, MPIDataTypeW, MPI_MAX, this->globalComm);
-    return (W)(1.0 - (globalMax - globalMin) / (globalMax + globalMin));
-  }
-
 private:
   // type for MPI communication
   MPI_Datatype MPIDataTypeT;
diff --git a/include/ALL_Voronoi.hpp b/include/ALL_Voronoi.hpp
index 82c2eb3..cc7ff0d 100644
--- a/include/ALL_Voronoi.hpp
+++ b/include/ALL_Voronoi.hpp
@@ -109,22 +109,6 @@ public:
   /// @param [out] double providing the estimated LB after the balance step
   virtual W getEstimatedEfficiency() override {return (W)-1;};
 
-  /// method to get the current LB efficiency with the given work distribution
-  /// @return current LB efficiency
-  virtual W getEfficiency() override
-  {
-    W localSum = (W)0;
-    for (auto i = this->work.begin(); i < this->work.end(); ++i)
-    {        
-        localSum += *i;
-    }        
-    W globalMin;
-    W globalMax;
-    MPI_Allreduce(&localSum, &globalMin, 1, MPIDataTypeW, MPI_MIN, this->globalComm);
-    MPI_Allreduce(&localSum, &globalMax, 1, MPIDataTypeW, MPI_MAX, this->globalComm);
-    return (W)(1.0 - (globalMax - globalMin) / (globalMax + globalMin));
-  }
-
 private:
   // MPI values
 
-- 
GitLab