mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Intersection : Add Python support for triangle and result values (#8505)
#8508 Python : Make sure an empty list will be received as empty list in Python Co-authored-by: magnesj <magnesj@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
# Load ResInsight Processing Server Client Library
|
||||
import math, time
|
||||
import rips
|
||||
|
||||
resinsight = rips.Instance.find()
|
||||
|
||||
# The coordinates in this example is based on the Drogon test case from Equinor
|
||||
file_path = "e:/models/from_equinor_sftp/drogon-real0-iter3/DROGON-0.EGRID"
|
||||
|
||||
case = resinsight.project.load_case(file_path)
|
||||
|
||||
view = case.create_view()
|
||||
view.set_time_step(2)
|
||||
|
||||
intersection_coll = resinsight.project.descendants(rips.IntersectionCollection)[0]
|
||||
|
||||
# Add a CurveIntersection and set coordinates for the polyline
|
||||
intersection = intersection_coll.add_new_object(rips.CurveIntersection)
|
||||
intersection.points = [
|
||||
[45854, 595757, 1500],
|
||||
[46493, 534259.1, 1500],
|
||||
[46598, 590044.1, 1500],
|
||||
]
|
||||
intersection.update()
|
||||
|
||||
# Add a new modeled well path
|
||||
well_path_coll = resinsight.project.descendants(rips.WellPathCollection)[0]
|
||||
well_path = well_path_coll.add_new_object(rips.ModeledWellPath)
|
||||
well_path.name = "Test Well-1"
|
||||
well_path.update()
|
||||
|
||||
# Set reference coordinate
|
||||
geometry = well_path.well_path_geometry()
|
||||
reference_point = geometry.reference_point
|
||||
reference_point[0] = 458580
|
||||
reference_point[1] = 5935514
|
||||
reference_point[2] = 1742
|
||||
geometry.update() # Commit updates back to ResInsight
|
||||
|
||||
# Create the first well target at the reference point
|
||||
coord = [0, 0, 0]
|
||||
geometry.append_well_target(coord)
|
||||
|
||||
# Append new well targets relative the the reference point
|
||||
coord = [2229.10, -833.74, -74.70]
|
||||
target = geometry.append_well_target(coord)
|
||||
|
||||
coord = [4577.21, -3043.47, -87.15]
|
||||
target = geometry.append_well_target(coord)
|
||||
geometry.update()
|
||||
|
||||
# Add a curve intersection based on the modeled well path
|
||||
well_path_intersection = intersection_coll.add_new_object(rips.CurveIntersection)
|
||||
well_path_intersection.type = "CS_WELL_PATH"
|
||||
well_path_intersection.well_path = well_path
|
||||
well_path_intersection.update()
|
||||
@@ -223,6 +223,9 @@ class PdmObjectBase:
|
||||
def __makelist(self, list_string):
|
||||
list_string = list_string.lstrip("[")
|
||||
list_string = list_string.rstrip("]")
|
||||
if not list_string:
|
||||
# Return empty list if empty string. Otherwise, the split function will return ['']
|
||||
return []
|
||||
strings = list_string.split(", ")
|
||||
values = []
|
||||
for string in strings:
|
||||
|
||||
@@ -21,3 +21,72 @@ def test_10k(rips_instance, initialize_test):
|
||||
assert len(wells) == 2
|
||||
assert wells[0].name == "Well Path A"
|
||||
assert wells[1].name == "Well Path B"
|
||||
|
||||
|
||||
def test_10k_intersection(rips_instance, initialize_test):
|
||||
case_root_path = dataroot.PATH + "/TEST10K_FLT_LGR_NNC"
|
||||
case_path = case_root_path + "/TEST10K_FLT_LGR_NNC.EGRID"
|
||||
case = rips_instance.project.load_case(path=case_path)
|
||||
assert len(case.grids()) == 2
|
||||
well_path_files = [
|
||||
case_root_path + "/wellpath_a.dev",
|
||||
]
|
||||
|
||||
view = case.create_view()
|
||||
view.set_time_step(1)
|
||||
|
||||
well_path_names = rips_instance.project.import_well_paths(well_path_files)
|
||||
wells = rips_instance.project.well_paths()
|
||||
well_path = wells[0]
|
||||
|
||||
# Add a curve intersection based on the well path
|
||||
intersection_coll = rips_instance.project.descendants(rips.IntersectionCollection)[
|
||||
0
|
||||
]
|
||||
well_path_intersection = intersection_coll.add_new_object(rips.CurveIntersection)
|
||||
well_path_intersection.type = "CS_WELL_PATH"
|
||||
well_path_intersection.well_path = well_path
|
||||
well_path_intersection.update()
|
||||
|
||||
# Three coords per triangle
|
||||
geometry = well_path_intersection.geometry()
|
||||
coord_count = len(geometry.x_coords)
|
||||
assert coord_count == 13254
|
||||
|
||||
# One value per triangle
|
||||
geometry_result_values = well_path_intersection.geometry_result()
|
||||
result_count = len(geometry_result_values.values)
|
||||
assert result_count == 4418
|
||||
|
||||
# Three coords per triangle, one result value per triangle
|
||||
assert (result_count * 3) == coord_count
|
||||
|
||||
|
||||
def test_empty_well_intersection(rips_instance, initialize_test):
|
||||
case_root_path = dataroot.PATH + "/TEST10K_FLT_LGR_NNC"
|
||||
case_path = case_root_path + "/TEST10K_FLT_LGR_NNC.EGRID"
|
||||
case = rips_instance.project.load_case(path=case_path)
|
||||
|
||||
view = case.create_view()
|
||||
view.set_time_step(1)
|
||||
|
||||
# Add a curve intersection based on the well path
|
||||
intersection_coll = rips_instance.project.descendants(rips.IntersectionCollection)[
|
||||
0
|
||||
]
|
||||
|
||||
well_path_intersection = intersection_coll.add_new_object(rips.CurveIntersection)
|
||||
well_path_intersection.type = "CS_WELL_PATH"
|
||||
well_path_intersection.well_path = None
|
||||
well_path_intersection.update()
|
||||
|
||||
# Test with empty geometry. This will also test that an empty list in CAF is converted to an empty list in Python
|
||||
# See __makelist in pdmobject.py
|
||||
geometry = well_path_intersection.geometry()
|
||||
coord_count = len(geometry.x_coords)
|
||||
assert coord_count == 0
|
||||
|
||||
# One value per triangle
|
||||
geometry_result_values = well_path_intersection.geometry_result()
|
||||
result_count = len(geometry_result_values.values)
|
||||
assert result_count == 0
|
||||
|
||||
Reference in New Issue
Block a user