From eb55456565eb67c4c1cf150a85b1691aae7fdf9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A5rd=20Skaflestad?= Date: Fri, 25 Feb 2022 11:31:57 +0100 Subject: [PATCH] Don't Capture Local Flux Data Unless Needed This is a potentially expensive operation and so we should not run it unless such values are actually needed for output purposes (e.g., inter-region flow summary vectors). --- ebos/eclgenericoutputblackoilmodule.hh | 5 +++++ ebos/eclinterregflows.hh | 5 +++++ ebos/eclwriter.hh | 4 +++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/ebos/eclgenericoutputblackoilmodule.hh b/ebos/eclgenericoutputblackoilmodule.hh index 915a24885..5ff3021fe 100644 --- a/ebos/eclgenericoutputblackoilmodule.hh +++ b/ebos/eclgenericoutputblackoilmodule.hh @@ -186,6 +186,11 @@ public: return 0; } + bool needInterfaceFluxes([[maybe_unused]] const bool isSubStep) const + { + return this->interRegionFlows_.wantInterRegflowSummary(); + } + const std::map& getWBPData() const { return this->wbpData_; diff --git a/ebos/eclinterregflows.hh b/ebos/eclinterregflows.hh index 28e1ff730..c65e2a392 100644 --- a/ebos/eclinterregflows.hh +++ b/ebos/eclinterregflows.hh @@ -274,6 +274,11 @@ namespace Opm { /// Whether or not previous read() operation succeeded. bool readIsConsistent() const; + bool wantInterRegflowSummary() const + { + return !this->regionMaps_.empty(); + } + /// Serialise internal representation to MPI message buffer /// /// \tparam MessageBufferType Linear MPI message buffer. API should diff --git a/ebos/eclwriter.hh b/ebos/eclwriter.hh index 3569762e9..24cfc0773 100644 --- a/ebos/eclwriter.hh +++ b/ebos/eclwriter.hh @@ -187,7 +187,9 @@ public: const auto localWellTestState = simulator_.problem().wellModel().wellTestState(); this->prepareLocalCellData(isSubStep, reportStepNum); - this->captureLocalFluxData(); + if (this->eclOutputModule_->needInterfaceFluxes(isSubStep)) { + this->captureLocalFluxData(); + } if (this->collectToIORank_.isParallel()) { OPM_BEGIN_PARALLEL_TRY_CATCH()