diff --git a/opm/simulators/flow/rescoup/ReservoirCouplingMasterReportStep.cpp b/opm/simulators/flow/rescoup/ReservoirCouplingMasterReportStep.cpp index 09680e2d64..4a3bbe3bfc 100644 --- a/opm/simulators/flow/rescoup/ReservoirCouplingMasterReportStep.cpp +++ b/opm/simulators/flow/rescoup/ReservoirCouplingMasterReportStep.cpp @@ -120,7 +120,14 @@ receiveInjectionDataFromSlaves() this->logger().info("Receiving injection data from slave processes"); for (unsigned int i = 0; i < num_slaves; i++) { auto num_slave_groups = this->numSlaveGroups(i); - assert( num_slave_groups > 0 ); + if (num_slave_groups == 0) { + // History mode: no slave groups defined, skip data exchange + this->logger().info(fmt::format( + "Slave {} has no slave groups (history mode), skipping injection data exchange", + this->slaveName(i) + )); + continue; + } std::vector injection_data(num_slave_groups); if (this->comm().rank() == 0) { if (this->slaveIsActivated(i)) { @@ -169,7 +176,14 @@ receiveProductionDataFromSlaves() this->logger().info("Receiving production data from slave processes"); for (unsigned int i = 0; i < num_slaves; i++) { auto num_slave_groups = this->numSlaveGroups(i); - assert( num_slave_groups > 0 ); + if (num_slave_groups == 0) { + // History mode: no slave groups defined, skip data exchange + this->logger().info(fmt::format( + "Slave {} has no slave groups (history mode), skipping production data exchange", + this->slaveName(i) + )); + continue; + } std::vector production_data(num_slave_groups); if (this->comm().rank() == 0) { if (this->slaveIsActivated(i)) { diff --git a/opm/simulators/wells/rescoup/RescoupSendSlaveGroupData.cpp b/opm/simulators/wells/rescoup/RescoupSendSlaveGroupData.cpp index a66c82d060..012d089093 100644 --- a/opm/simulators/wells/rescoup/RescoupSendSlaveGroupData.cpp +++ b/opm/simulators/wells/rescoup/RescoupSendSlaveGroupData.cpp @@ -299,6 +299,10 @@ sendSlaveGroupProductionDataToMaster_() const { auto& rescoup_slave = this->reservoir_coupling_slave_; auto num_slave_groups = rescoup_slave.numSlaveGroups(); + if (num_slave_groups == 0) { + // History mode: no slave groups defined, nothing to send + return; + } std::vector production_data; for (std::size_t group_idx = 0; group_idx < num_slave_groups; ++group_idx) { // NOTE: We have to send production data even if the slave group is not a production group, @@ -315,6 +319,10 @@ sendSlaveGroupInjectionDataToMaster_() const { auto& rescoup_slave = this->reservoir_coupling_slave_; auto num_slave_groups = rescoup_slave.numSlaveGroups(); + if (num_slave_groups == 0) { + // History mode: no slave groups defined, nothing to send + return; + } std::vector injection_data; for (std::size_t group_idx = 0; group_idx < num_slave_groups; ++group_idx) { // NOTE: We would like to only send injection data only if the master group is an injector,