From bca8c36cbf87c127fa5c031407c173021614d65c Mon Sep 17 00:00:00 2001 From: Franz Georg Fuchs Date: Thu, 27 Feb 2020 13:40:07 +0100 Subject: [PATCH] log loadbalancing info on rank 0 removed unused variable my_num aborting all processes if at least one process has zero cells --- opm/grid/cpgrid/CpGrid.cpp | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/opm/grid/cpgrid/CpGrid.cpp b/opm/grid/cpgrid/CpGrid.cpp index 576e9b979..b645199b6 100644 --- a/opm/grid/cpgrid/CpGrid.cpp +++ b/opm/grid/cpgrid/CpGrid.cpp @@ -152,7 +152,6 @@ CpGrid::scatterGrid(EdgeWeightMethod method, const std::vector 1) { - int my_num=cc.rank(); #ifdef HAVE_ZOLTAN auto part_and_wells = cpgrid::zoltanGraphPartitionGridOnRoot(*this, wells, transmissibilities, cc, method, 0); @@ -247,12 +246,23 @@ CpGrid::scatterGrid(EdgeWeightMethod method, const std::vectordistributeGlobalGrid(*this,*this->current_view_data_, cell_part); int num_cells = distributed_data_->cell_to_face_.size(); - std::ostringstream message; - message << "After loadbalancing process " << my_num << " has " << num_cells << " cells."; - if (num_cells == 0) { - throw std::runtime_error(message.str() + " Aborting."); - } else { - std::cout << message.str() << "\n"; + + std::vector cc_num_cells(cc.size(), 0); + cc_num_cells[cc.rank()] = num_cells; + cc.sum(cc_num_cells.data(),cc.size()); + + if (cc.rank() == 0) { + std::string str = "\nAfter loadbalancing on " + std::to_string(cc.size()) + " processes we have\nrank: num cells\n----------------\n"; + for (int i = 0; i < cc.size(); ++i) { + str += std::to_string(i) + ": " + std::to_string(cc_num_cells[i]) + "\n"; + } + str += "----------------\n"; + Opm::OpmLog::info(str); + } + for (const auto& nc : cc_num_cells) { + if (nc == 0) { + throw std::runtime_error("At least one process has zero cells. Aborting."); + } } current_view_data_ = distributed_data_.get();