Skip to content

Commit

Permalink
Use mesh2d_clip with FACES_WITH_INCLUDED_CIRCUMCENTERS
Browse files Browse the repository at this point in the history
  • Loading branch information
guydup committed Oct 29, 2024
1 parent c08043f commit 38858ad
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions tests/dhydamo/geometry/test_mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def test_create_2d_rectangular_from_multipolygon(do_plot=False):
mesh.mesh2d_clip(
network=network,
polygon=GeometryList.from_geometry(river),
deletemeshoption=DeleteMeshOption.INSIDE_AND_INTERSECTED, #ALL_NODES,
deletemeshoption=DeleteMeshOption.FACES_WITH_INCLUDED_CIRCUMCENTERS,
)

# Plot to verify
Expand All @@ -158,7 +158,7 @@ def test_create_2d_rectangular_from_multipolygon(do_plot=False):
ax.plot(*refinement.exterior.coords.xy, color="g", ls="--")
plt.show()

assert len(network._mesh2d.mesh2d_face_x) == 303
assert len(network._mesh2d.mesh2d_face_x) == 341


def test_create_2d_triangular_from_multipolygon(do_plot=False):
Expand Down Expand Up @@ -204,14 +204,24 @@ def test_2d_clip_outside_polygon(do_plot=False):

rectangle = box(-10, -10, 10, 10)

dmo = DeleteMeshOption.INSIDE_NOT_INTERSECTED
mesh.mesh2d_add_rectilinear(network, rectangle, dx=1, dy=1, deletemeshoption=dmo)
mesh.mesh2d_add_rectilinear(
network,
rectangle,
dx=1,
dy=1,
deletemeshoption=DeleteMeshOption.INSIDE_NOT_INTERSECTED
)

clipgeo = box(-8, -8, 8, 8).difference(
MultiPolygon([box(-6, -1, -4, 2), box(4, 5, 7, 7)])
)

mesh.mesh2d_clip(network, clipgeo, deletemeshoption= DeleteMeshOption.INSIDE_AND_INTERSECTED, inside=False)
mesh.mesh2d_clip(
network,
clipgeo,
deletemeshoption= DeleteMeshOption.FACES_WITH_INCLUDED_CIRCUMCENTERS,
inside=False,
)

# Plot to verify
if do_plot:
Expand All @@ -223,7 +233,7 @@ def test_2d_clip_outside_polygon(do_plot=False):
ax.plot(*hole.coords.xy, color="r", ls="--")
plt.show()

assert len(network._mesh2d.mesh2d_face_x) == 284
assert len(network._mesh2d.mesh2d_face_x) == 244


def test_2d_clip_inside_multipolygon(do_plot=False):
Expand All @@ -244,7 +254,7 @@ def test_2d_clip_inside_multipolygon(do_plot=False):
mesh.mesh2d_clip(
network,
clipgeo,
deletemeshoption=DeleteMeshOption.INSIDE_AND_INTERSECTED,
deletemeshoption=DeleteMeshOption.FACES_WITH_INCLUDED_CIRCUMCENTERS,
inside=True,
)

Expand All @@ -257,7 +267,7 @@ def test_2d_clip_inside_multipolygon(do_plot=False):
ax.plot(*polygon.exterior.coords.xy, color="r", ls="--")
plt.show()

assert len(network._mesh2d.mesh2d_node_x) == 337
assert len(network._mesh2d.mesh2d_node_x) == 357


def test_1d_add_branch_from_linestring(do_plot=False):
Expand Down Expand Up @@ -461,6 +471,7 @@ def test_mesh2d_altitude_from_raster(where, fill_option, fill_value, outcome):
fill_option=fill_option,
fill_value=fill_value,
)
mesh

def test_mesh1d_add_branches_from_gdf(do_plot=False):
# Create full HyDAMO object (use from other test)
Expand Down

0 comments on commit 38858ad

Please sign in to comment.