Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix segfault in WellStateglobalConnections #979

Merged
merged 1 commit into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions python/resdata/well/well_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ def hasGlobalConnections(self):
def globalConnections(self):
"""@rtype: list of WellConnection"""
global_connections = self._get_global_connections()
if global_connections is None:
return []
count = self._global_connections_size(global_connections)

values = []
Expand Down
37 changes: 37 additions & 0 deletions python/tests/well_tests/test_well_missing_ICON.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import datetime
from tests import ResdataTest
from resdata.grid import GridGenerator
from resdata.resfile import ResdataFile
from resdata.well import (
WellInfo,
WellConnection,
Expand All @@ -24,10 +25,46 @@ def check_connections(self, well_info, expected):
well = well_info["B-2H"]
well_state = well[0]
self.assertEqual(well_state.hasGlobalConnections(), expected)
if not expected:
self.assertEqual(well_state.globalConnections(), [])
else:
self.assertGreater(len(well_state.globalConnections()), 0)
self.assertEqual(well_state.wellType(), WellType.PRODUCER)
self.assertEqual(well_state.name(), "B-2H")
self.assertTrue(well_state.isOpen())
self.assertEqual(well_state.wellHead().ijk(), (14, 30, 8))
self.assertEqual(well_state.wellNumber(), 1)
self.assertEqual(well_state.reportNumber(), 27)
self.assertEqual(
well_state.simulationTime().datetime(),
datetime.datetime(1998, 10, 13, 0, 0),
)
self.assertEqual(len(well_state), 0)
self.assertEqual(well_state.numSegments(), 0)
self.assertEqual(well_state.segments(), [])
self.assertFalse(well_state.isMultiSegmentWell())
self.assertFalse(well_state.hasSegmentData())
self.assertEqual(well_state.gasRate(), 0)
self.assertEqual(well_state.waterRate(), 0)
self.assertEqual(well_state.oilRate(), 0)
self.assertEqual(well_state.volumeRate(), 0)
self.assertEqual(well_state.gasRateSI(), 0)
self.assertEqual(well_state.oilRateSI(), 0)
self.assertEqual(well_state.waterRateSI(), 0)
self.assertEqual(well_state.volumeRateSI(), 0)

def test_missing_icon(self):
well_info_ICON0 = WellInfo(self.grid, self.rst_file_ICON0)
well_info_ICON1 = WellInfo(self.grid, self.rst_file_ICON1)
assert len(well_info_ICON0) == 8

time_line = well_info_ICON0[0]
self.assertEqual(time_line.getName(), "C-4H")
self.assertIn("C-4H", well_info_ICON0.allWellNames())

self.check_connections(well_info_ICON0, False)
self.check_connections(well_info_ICON1, True)

well_info_ICON0.addWellFile(
ResdataFile(self.rst_file_ICON0), load_segment_information=False
)
Loading