mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
[bugfix,mswell] Throw for connections not attached to segments.
If there are connections of a multisegment well that are not connected to any segment, we throw with a meaningful error message instead of a silent segmentation fault. In that case an invalid segment index of zero would be returned. The corresponding storage index returned by segmentToNumberIndex ould become -1. This previously lead to segmentation faults when using it to index a container.
This commit is contained in:
@@ -37,6 +37,8 @@
|
|||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
|
#include <fmt/format.h>
|
||||||
|
|
||||||
namespace Opm
|
namespace Opm
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -65,6 +67,13 @@ MultisegmentWellGeneric(WellInterfaceGeneric& baseif)
|
|||||||
const Connection& connection = completion_set.get(perf);
|
const Connection& connection = completion_set.get(perf);
|
||||||
if (connection.state() == Connection::State::OPEN) {
|
if (connection.state() == Connection::State::OPEN) {
|
||||||
const int segment_index = segmentNumberToIndex(connection.segment());
|
const int segment_index = segmentNumberToIndex(connection.segment());
|
||||||
|
if ( segment_index == -1) {
|
||||||
|
OPM_THROW(std::logic_error,
|
||||||
|
fmt::format("COMPSEGS: Well {} has connection in cell {}, {}, {} "
|
||||||
|
"without associated segment.", baseif_.wellEcl().name(),
|
||||||
|
connection.getI() + 1, connection.getJ() + 1,
|
||||||
|
connection.getK() + 1));
|
||||||
|
}
|
||||||
segment_perforations_[segment_index].push_back(i_perf_wells);
|
segment_perforations_[segment_index].push_back(i_perf_wells);
|
||||||
baseif.perfDepth()[i_perf_wells] = connection.depth();
|
baseif.perfDepth()[i_perf_wells] = connection.depth();
|
||||||
const double segment_depth = segmentSet()[segment_index].depth();
|
const double segment_depth = segmentSet()[segment_index].depth();
|
||||||
|
|||||||
@@ -627,6 +627,14 @@ void WellState::initWellStateMSWell(const std::vector<Well>& wells_ecl,
|
|||||||
const Connection& connection = completion_set.get(perf);
|
const Connection& connection = completion_set.get(perf);
|
||||||
if (connection.state() == Connection::State::OPEN) {
|
if (connection.state() == Connection::State::OPEN) {
|
||||||
const int segment_index = segment_set.segmentNumberToIndex(connection.segment());
|
const int segment_index = segment_set.segmentNumberToIndex(connection.segment());
|
||||||
|
if ( segment_index == -1) {
|
||||||
|
OPM_THROW(std::logic_error,
|
||||||
|
fmt::format("COMPSEGS: Well {} has connection in cell {}, {}, {} "
|
||||||
|
"without associated segment.", well_ecl.name(),
|
||||||
|
connection.getI() + 1 , connection.getJ() + 1,
|
||||||
|
connection.getK() + 1 ));
|
||||||
|
}
|
||||||
|
|
||||||
segment_perforations[segment_index].push_back(n_activeperf);
|
segment_perforations[segment_index].push_back(n_activeperf);
|
||||||
n_activeperf++;
|
n_activeperf++;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user