diff --git a/opm/grid/common/ZoltanGraphFunctions.cpp b/opm/grid/common/ZoltanGraphFunctions.cpp index cb19937e3..1863d5ad0 100644 --- a/opm/grid/common/ZoltanGraphFunctions.cpp +++ b/opm/grid/common/ZoltanGraphFunctions.cpp @@ -183,17 +183,15 @@ template EdgeWeightType sumOfGridEdges(const Dune::CpGrid& grid, const CombinedGridWellGraph& graph) { - EdgeWeightType weWeight = 0; - for (int edge=0; edge= std::numeric_limits::max()-addend) { - weWeight = std::numeric_limits::max(); - break; - } - weWeight += graph.transmissibility(edge); + double total = 0.0; + for (int edge = 0; edge < grid.numFaces(); ++edge) { + total += graph.transmissibility(edge); + } + const double maxVal = static_cast(std::numeric_limits::max()); + if (total > maxVal) { + return std::numeric_limits::max(); } - return weWeight; + return static_cast(total); } template