Merge pull request #5824 from vkip/fix_rft_inactive_and_shut_distributed_wells

Fix RFT output for shut distributed wells
This commit is contained in:
Atgeirr Flø Rasmussen
2025-01-10 13:48:48 +01:00
committed by GitHub
2 changed files with 14 additions and 16 deletions

View File

@@ -407,32 +407,30 @@ template<class FluidSystem>
void GenericOutputBlackoilModule<FluidSystem>:: void GenericOutputBlackoilModule<FluidSystem>::
accumulateRftDataParallel(const Parallel::Communication& comm) { accumulateRftDataParallel(const Parallel::Communication& comm) {
if (comm.size() > 1) { if (comm.size() > 1) {
collectRftMapOnRoot(oilConnectionPressures_, comm); gatherAndUpdateRftMap(oilConnectionPressures_, comm);
collectRftMapOnRoot(waterConnectionSaturations_, comm); gatherAndUpdateRftMap(waterConnectionSaturations_, comm);
collectRftMapOnRoot(gasConnectionSaturations_, comm); gatherAndUpdateRftMap(gasConnectionSaturations_, comm);
} }
} }
template<class FluidSystem> template<class FluidSystem>
void GenericOutputBlackoilModule<FluidSystem>:: void GenericOutputBlackoilModule<FluidSystem>::
collectRftMapOnRoot(std::map<std::size_t, Scalar>& local_map, const Parallel::Communication& comm) { gatherAndUpdateRftMap(std::map<std::size_t, Scalar>& local_map, const Parallel::Communication& comm) {
std::vector<std::pair<int, Scalar>> pairs(local_map.begin(), local_map.end()); std::vector<std::pair<int, Scalar>> pairs(local_map.begin(), local_map.end());
std::vector<std::pair<int, Scalar>> all_pairs; std::vector<std::pair<int, Scalar>> all_pairs;
std::vector<int> offsets; std::vector<int> 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 // Update maps on all ranks
if (comm.rank() == 0) { for (auto i=static_cast<std::size_t>(offsets[0]); i<all_pairs.size(); ++i) {
for (auto i=static_cast<std::size_t>(offsets[1]); i<all_pairs.size(); ++i) { const auto& key_value = all_pairs[i];
const auto& key_value = all_pairs[i]; if (auto candidate = local_map.find(key_value.first); candidate != local_map.end()) {
if (auto candidate = local_map.find(key_value.first); candidate != local_map.end()) { const Scalar prev_value = candidate->second;
const Scalar prev_value = candidate->second; candidate->second = std::max(prev_value, key_value.second);
candidate->second = std::max(prev_value, key_value.second); } else {
} else { local_map[key_value.first] = key_value.second;
local_map[key_value.first] = key_value.second;
}
} }
} }
} }

View File

@@ -387,7 +387,7 @@ protected:
virtual bool isDefunctParallelWell(std::string wname) const = 0; virtual bool isDefunctParallelWell(std::string wname) const = 0;
void collectRftMapOnRoot(std::map<std::size_t, Scalar>& local_map, const Parallel::Communication& comm); void gatherAndUpdateRftMap(std::map<std::size_t, Scalar>& local_map, const Parallel::Communication& comm);
const EclipseState& eclState_; const EclipseState& eclState_;
const Schedule& schedule_; const Schedule& schedule_;