From 802e73fe2864d716b4a918ac1d2e8b176887c1ca Mon Sep 17 00:00:00 2001 From: Vegard Kippe Date: Fri, 20 Dec 2024 10:46:14 +0100 Subject: [PATCH] Fix RFT output for shut distributed wells and permamently inactive wells split across processors (partition method 3 issue only). --- .../flow/GenericOutputBlackoilModule.cpp | 28 +++++++++---------- .../flow/GenericOutputBlackoilModule.hpp | 2 +- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/opm/simulators/flow/GenericOutputBlackoilModule.cpp b/opm/simulators/flow/GenericOutputBlackoilModule.cpp index 0a345e8ae..7647f8893 100644 --- a/opm/simulators/flow/GenericOutputBlackoilModule.cpp +++ b/opm/simulators/flow/GenericOutputBlackoilModule.cpp @@ -407,32 +407,30 @@ template void GenericOutputBlackoilModule:: accumulateRftDataParallel(const Parallel::Communication& comm) { if (comm.size() > 1) { - collectRftMapOnRoot(oilConnectionPressures_, comm); - collectRftMapOnRoot(waterConnectionSaturations_, comm); - collectRftMapOnRoot(gasConnectionSaturations_, comm); + gatherAndUpdateRftMap(oilConnectionPressures_, comm); + gatherAndUpdateRftMap(waterConnectionSaturations_, comm); + gatherAndUpdateRftMap(gasConnectionSaturations_, comm); } } template void GenericOutputBlackoilModule:: -collectRftMapOnRoot(std::map& local_map, const Parallel::Communication& comm) { +gatherAndUpdateRftMap(std::map& local_map, const Parallel::Communication& comm) { std::vector> pairs(local_map.begin(), local_map.end()); std::vector> all_pairs; std::vector offsets; - std::tie(all_pairs, offsets) = Opm::gatherv(pairs, comm, 0); + std::tie(all_pairs, offsets) = Opm::allGatherv(pairs, comm); - // Insert/update map values on root - if (comm.rank() == 0) { - for (auto i=static_cast(offsets[1]); isecond; - candidate->second = std::max(prev_value, key_value.second); - } else { - local_map[key_value.first] = key_value.second; - } + // Update maps on all ranks + for (auto i=static_cast(offsets[0]); isecond; + candidate->second = std::max(prev_value, key_value.second); + } else { + local_map[key_value.first] = key_value.second; } } } diff --git a/opm/simulators/flow/GenericOutputBlackoilModule.hpp b/opm/simulators/flow/GenericOutputBlackoilModule.hpp index b8f3afdcc..79fe86cd4 100644 --- a/opm/simulators/flow/GenericOutputBlackoilModule.hpp +++ b/opm/simulators/flow/GenericOutputBlackoilModule.hpp @@ -387,7 +387,7 @@ protected: virtual bool isDefunctParallelWell(std::string wname) const = 0; - void collectRftMapOnRoot(std::map& local_map, const Parallel::Communication& comm); + void gatherAndUpdateRftMap(std::map& local_map, const Parallel::Communication& comm); const EclipseState& eclState_; const Schedule& schedule_;