From 25947e2ad51c500f9d57ccedb1ad084f46588294 Mon Sep 17 00:00:00 2001 From: Bill Senior Date: Tue, 11 Aug 2026 17:03:44 +0200 Subject: [PATCH 1/7] GRIDEDIT-2297 Renamed mesh2d.property to Mesh2dProperty Names of several functions are now consistent. --- meshkernel/meshkernel.py | 14 +++++++------- meshkernel/py_structures.py | 19 +++++++++---------- tests/test_mesh2d_basics.py | 22 +++++++++++----------- 3 files changed, 27 insertions(+), 28 deletions(-) diff --git a/meshkernel/meshkernel.py b/meshkernel/meshkernel.py index e89bee75..f1aefc83 100644 --- a/meshkernel/meshkernel.py +++ b/meshkernel/meshkernel.py @@ -515,13 +515,13 @@ def mesh2d_get_face_polygons(self, num_edges: int) -> GeometryList: return face_polygons def mesh2d_get_filtered_face_polygons( - self, property: Mesh2d.Property, min_value: float, max_value: float + self, property: Mesh2dProperty, min_value: float, max_value: float ) -> GeometryList: """Gets the polygons matching the metric value within the minimum and maximum value. Args: - property (Mesh2d.Property): The property used to filter the locations + property (Mesh2dProperty): The property used to filter the locations min_value(float): The minimum value of the metric. max_value(float): The maximum value of the metric. @@ -1657,7 +1657,7 @@ def mesh2d_casulli_derefinement_on_polygon( byref(c_polygon), ) - def mkernel_delete_property(self, propertyId: int): + def mesh2d_delete_property(self, propertyId: int): """ Deletes a property and its calculator. Args: @@ -1670,7 +1670,7 @@ def mkernel_delete_property(self, propertyId: int): c_int(propertyId), ) - def mkernel_set_property( + def mesh2d_set_property( self, interpolation_parameters: InterpolationParameters, sample_data: GeometryList, @@ -1702,7 +1702,7 @@ def mkernel_set_property( return propertyId.value - def mkernel_mesh2d_casulli_refinement_based_on_depths( + def mesh2d_casulli_refinement_based_on_depths( self, polygons: GeometryList, propertyId: int, @@ -1821,12 +1821,12 @@ def mesh2d_get_orthogonality(self) -> GeometryList: return geometry_list_out def mesh2d_get_property( - self, mesh2d_location: Mesh2dLocation, property: Mesh2d.Property + self, mesh2d_location: Mesh2dLocation, property: Mesh2dProperty ) -> GeometryList: """Gets the polygons matching the metric value within the minimum and maximum value. Args: mesh2d_location (Mesh2dLocation): The property location - property (Mesh2d.Property): The property to retrieve + property (Mesh2dProperty): The property to retrieve Returns: GeometryList: The resulting geometry list containing the value of the properties """ diff --git a/meshkernel/py_structures.py b/meshkernel/py_structures.py index f40d0e0c..a1963a92 100644 --- a/meshkernel/py_structures.py +++ b/meshkernel/py_structures.py @@ -57,6 +57,15 @@ class Mesh2dLocation(IntEnum): NODES = 1 EDGES = 2 +@unique +class Mesh2dProperty(IntEnum): + """Different properties on a 2D mesh.""" + + EDGE_ORTHOGONALITY = 0 + EDGE_LENGTHS = 1 + FACE_CIRCUMCENTER = 2 + NETLINK_CONTOUR_POLYGON = 3 + FACE_BOUNDS = 4 @unique class AveragingMethod(IntEnum): @@ -126,16 +135,6 @@ class Mesh2d: """ - @unique - class Property(IntEnum): - """Different properties on a 2D mesh.""" - - ORTHOGONALITY = 0 - EDGE_LENGTHS = 1 - FACE_CIRCUMCENTER = 2 - NETLINK_CONTOUR_POLYGON = 3 - FACE_BOUNDS = 4 - def __init__( self, node_x=np.empty(0, dtype=np.double), diff --git a/tests/test_mesh2d_basics.py b/tests/test_mesh2d_basics.py index 645a2c2a..6ee655e1 100644 --- a/tests/test_mesh2d_basics.py +++ b/tests/test_mesh2d_basics.py @@ -2342,7 +2342,7 @@ def test_mesh2d_deletion_and_get_orthogonality( cases_get_property = [ ( - Mesh2d.Property.ORTHOGONALITY, + Mesh2dProperty.EDGE_ORTHOGONALITY, Mesh2dLocation.EDGES, np.array( [ @@ -2375,7 +2375,7 @@ def test_mesh2d_deletion_and_get_orthogonality( ), ), ( - Mesh2d.Property.EDGE_LENGTHS, + Mesh2dProperty.EDGE_LENGTHS, Mesh2dLocation.EDGES, np.array( [ @@ -2416,7 +2416,7 @@ def test_mesh2d_deletion_and_get_orthogonality( ) def test_mesh2d_get_property( meshkernel_with_mesh2d: MeshKernel, - property: Mesh2d.Property, + property: Mesh2dProperty, location: Mesh2dLocation, expected_values: ndarray, ): @@ -2449,7 +2449,7 @@ def test_mesh2d_get_circumcentre_property(): mk.curvilinear_compute_rectangular_grid_on_extension(make_grid_parameters) mk.curvilinear_convert_to_mesh2d() - property = Mesh2d.Property.FACE_CIRCUMCENTER + property = Mesh2dProperty.FACE_CIRCUMCENTER location = Mesh2dLocation.FACES property_list = mk.mesh2d_get_property(location, property) @@ -2479,7 +2479,7 @@ def test_mesh2d_get_netlink_countour_polygon_property(): mk.curvilinear_compute_rectangular_grid_on_extension(make_grid_parameters) mk.curvilinear_convert_to_mesh2d() - property = Mesh2d.Property.NETLINK_CONTOUR_POLYGON + property = Mesh2dProperty.NETLINK_CONTOUR_POLYGON location = Mesh2dLocation.EDGES property_list = mk.mesh2d_get_property(location, property) @@ -2505,7 +2505,7 @@ def test_mesh2d_get_filtered_face_polygons(): mk.mesh2d_set(input_mesh2d) face_polygons = mk.mesh2d_get_filtered_face_polygons( - Mesh2d.Property.ORTHOGONALITY, 0.04, 1.0 + Mesh2dProperty.EDGE_ORTHOGONALITY, 0.04, 1.0 ) expected_coordinates_x = np.array([57.0, 49.1, 58.9, 66.7, 57.0], dtype=np.double) @@ -2531,11 +2531,11 @@ def test_mesh2d_get_filtered_face_polygons_full_and_empty(): mk.curvilinear_convert_to_mesh2d() orthogonality = mk.mesh2d_get_filtered_face_polygons( - Mesh2d.Property.ORTHOGONALITY, 0.0, 1.0 + Mesh2dProperty.EDGE_ORTHOGONALITY, 0.0, 1.0 ) assert orthogonality.x_coordinates.shape[0] == 503 orthogonality = mk.mesh2d_get_filtered_face_polygons( - Mesh2d.Property.ORTHOGONALITY, 0.1, 10.0 + Mesh2dProperty.EDGE_ORTHOGONALITY, 0.1, 10.0 ) assert orthogonality.x_coordinates.shape[0] == 0 @@ -2577,7 +2577,7 @@ def test_mesh2d_casulli_refinement_based_on_depths(): interpolationParameters = InterpolationParameters() - property_id = mk.mkernel_set_property(interpolationParameters, samples) + property_id = mk.mesh2d_set_property(interpolationParameters, samples) polygons = GeometryList( x_coordinates=np.empty(0, dtype=np.double), @@ -2586,10 +2586,10 @@ def test_mesh2d_casulli_refinement_based_on_depths(): meshRefinementParameters = MeshRefinementParameters() minimumRefinementDepth = 0.0 - mk.mkernel_mesh2d_casulli_refinement_based_on_depths( + mk.mesh2d_casulli_refinement_based_on_depths( polygons, property_id, meshRefinementParameters, minimumRefinementDepth ) - mk.mkernel_delete_property(property_id) + mk.mesh2d_delete_property(property_id) mesh2d_refined = mk.mesh2d_get() # new mesh has more nodes and edges than the starting mesh, it has been refined From 9ada4b5aed845e0418a90f293eb549d49053e2da Mon Sep 17 00:00:00 2001 From: Bill Senior Date: Tue, 11 Aug 2026 17:29:06 +0200 Subject: [PATCH 2/7] GRIDEDIT-2297 Reverted orthogonality enum value name --- tests/test_mesh2d_basics.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/test_mesh2d_basics.py b/tests/test_mesh2d_basics.py index 6ee655e1..f8f9f56a 100644 --- a/tests/test_mesh2d_basics.py +++ b/tests/test_mesh2d_basics.py @@ -2342,7 +2342,7 @@ def test_mesh2d_deletion_and_get_orthogonality( cases_get_property = [ ( - Mesh2dProperty.EDGE_ORTHOGONALITY, + Mesh2dProperty.ORTHOGONALITY, Mesh2dLocation.EDGES, np.array( [ @@ -2505,7 +2505,7 @@ def test_mesh2d_get_filtered_face_polygons(): mk.mesh2d_set(input_mesh2d) face_polygons = mk.mesh2d_get_filtered_face_polygons( - Mesh2dProperty.EDGE_ORTHOGONALITY, 0.04, 1.0 + Mesh2dProperty.ORTHOGONALITY, 0.04, 1.0 ) expected_coordinates_x = np.array([57.0, 49.1, 58.9, 66.7, 57.0], dtype=np.double) @@ -2531,11 +2531,11 @@ def test_mesh2d_get_filtered_face_polygons_full_and_empty(): mk.curvilinear_convert_to_mesh2d() orthogonality = mk.mesh2d_get_filtered_face_polygons( - Mesh2dProperty.EDGE_ORTHOGONALITY, 0.0, 1.0 + Mesh2dProperty.ORTHOGONALITY, 0.0, 1.0 ) assert orthogonality.x_coordinates.shape[0] == 503 orthogonality = mk.mesh2d_get_filtered_face_polygons( - Mesh2dProperty.EDGE_ORTHOGONALITY, 0.1, 10.0 + Mesh2dProperty.ORTHOGONALITY, 0.1, 10.0 ) assert orthogonality.x_coordinates.shape[0] == 0 From 705512d57afd558dd177284cd91bd90b4d7f4daf Mon Sep 17 00:00:00 2001 From: Bill Senior Date: Tue, 11 Aug 2026 17:42:33 +0200 Subject: [PATCH 3/7] GRIDEDIT-2297 Fixed formatting warning --- meshkernel/py_structures.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/meshkernel/py_structures.py b/meshkernel/py_structures.py index a1963a92..3ca9323b 100644 --- a/meshkernel/py_structures.py +++ b/meshkernel/py_structures.py @@ -57,16 +57,18 @@ class Mesh2dLocation(IntEnum): NODES = 1 EDGES = 2 + @unique class Mesh2dProperty(IntEnum): """Different properties on a 2D mesh.""" - EDGE_ORTHOGONALITY = 0 + ORTHOGONALITY = 0 EDGE_LENGTHS = 1 FACE_CIRCUMCENTER = 2 NETLINK_CONTOUR_POLYGON = 3 FACE_BOUNDS = 4 + @unique class AveragingMethod(IntEnum): """The averaging methods.""" From 742172da98b070fad2f059c689b1d7eb2a6e290a Mon Sep 17 00:00:00 2001 From: Bill Senior Date: Tue, 11 Aug 2026 17:44:06 +0200 Subject: [PATCH 4/7] GRIDEDIT-2297 Added missing import for Mesh2dProperty --- meshkernel/meshkernel.py | 1 + tests/test_mesh2d_basics.py | 1 + 2 files changed, 2 insertions(+) diff --git a/meshkernel/meshkernel.py b/meshkernel/meshkernel.py index f1aefc83..5988ea9f 100644 --- a/meshkernel/meshkernel.py +++ b/meshkernel/meshkernel.py @@ -49,6 +49,7 @@ Mesh1d, Mesh2d, Mesh2dLocation, + Mesh2dProperty, MeshRefinementParameters, OrthogonalizationParameters, ProjectionType, diff --git a/tests/test_mesh2d_basics.py b/tests/test_mesh2d_basics.py index f8f9f56a..9616b87b 100644 --- a/tests/test_mesh2d_basics.py +++ b/tests/test_mesh2d_basics.py @@ -15,6 +15,7 @@ MakeGridParameters, Mesh2d, Mesh2dLocation, + Mesh2dProperty, MeshKernel, MeshKernelError, MeshRefinementParameters, From 1e0afcc0380a6394c67a9ec9cac96be885541454 Mon Sep 17 00:00:00 2001 From: BillSenior Date: Wed, 12 Aug 2026 13:07:08 +0200 Subject: [PATCH 5/7] GRIDEDIT-2297 Added missing definition of Mesh2dProperty --- tests/test_py_structures.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test_py_structures.py b/tests/test_py_structures.py index 022d18a6..82313122 100644 --- a/tests/test_py_structures.py +++ b/tests/test_py_structures.py @@ -7,6 +7,7 @@ GeometryList, Mesh2d, Mesh2dLocation, + Mesh2dProperty, MeshRefinementParameters, OrthogonalizationParameters, ProjectToLandBoundaryOption, From 925eafde571d41e867b04cb02e6986ebb4cc9ab5 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 12 Aug 2026 11:28:25 +0000 Subject: [PATCH 6/7] Export Mesh2dProperty from package API Co-authored-by: BillSenior <89970704+BillSenior@users.noreply.github.com> --- meshkernel/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/meshkernel/__init__.py b/meshkernel/__init__.py index ec7100d4..c05ce298 100644 --- a/meshkernel/__init__.py +++ b/meshkernel/__init__.py @@ -17,6 +17,7 @@ Mesh1d, Mesh2d, Mesh2dLocation, + Mesh2dProperty, MeshRefinementParameters, OrthogonalizationParameters, ProjectionType, From a9776beddfa69f68fec2e079fb6077e5186ce4e7 Mon Sep 17 00:00:00 2001 From: BillSenior Date: Wed, 12 Aug 2026 16:53:23 +0200 Subject: [PATCH 7/7] GRIDEDIT-2297 Fixed sonar cloud warning --- meshkernel/meshkernel.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/meshkernel/meshkernel.py b/meshkernel/meshkernel.py index 5988ea9f..1fb824c2 100644 --- a/meshkernel/meshkernel.py +++ b/meshkernel/meshkernel.py @@ -1658,17 +1658,17 @@ def mesh2d_casulli_derefinement_on_polygon( byref(c_polygon), ) - def mesh2d_delete_property(self, propertyId: int): + def mesh2d_delete_property(self, property_id: int): """ Deletes a property and its calculator. Args: - propertyId (int): The property id. + property_id (int): The property id. """ self._execute_function( self.lib.mkernel_deallocate_property, self._meshkernelid, - c_int(propertyId), + c_int(property_id), ) def mesh2d_set_property( @@ -1692,21 +1692,21 @@ def mesh2d_set_property( ) c_sample_data = CGeometryList.from_geometrylist(sample_data) - propertyId = c_int() + property_id = c_int() self._execute_function( self.lib.mkernel_mesh2d_set_property, self._meshkernelid, byref(c_interpolation_parameters), byref(c_sample_data), - byref(propertyId), + byref(property_id), ) - return propertyId.value + return property_id.value def mesh2d_casulli_refinement_based_on_depths( self, polygons: GeometryList, - propertyId: int, + property_id: int, meshRefinementParameters: MeshRefinementParameters, minimumRefinementDepth: float, ) -> None: @@ -1714,7 +1714,7 @@ def mesh2d_casulli_refinement_based_on_depths( Refine mesh using the Casulli refinement algorithm based on the depth values. Args: polygons (GeometryList): The polygon within which the refinement is computed. - propertyId (int): The identifier of the interpolator to be used. + property_id (int): The identifier of the interpolator to be used. meshRefinementParameters (MeshRefinementParameters): Parameters indicating how the mesh is to be refined. minimumRefinementDepth (float): Nodes with depth value less than this value will not be marked for refinement. """ @@ -1727,7 +1727,7 @@ def mesh2d_casulli_refinement_based_on_depths( self.lib.mkernel_mesh2d_casulli_refinement_based_on_depths, self._meshkernelid, byref(c_polygons), - c_int(propertyId), + c_int(property_id), byref(c_refinement_params), c_double(minimumRefinementDepth), )