Skip to content

Commit

Permalink
update deprecated mk.Mesh2dFactory to newer alternative
Browse files Browse the repository at this point in the history
  • Loading branch information
veenstrajelmer committed Oct 23, 2023
1 parent 71c2719 commit 666e68e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
27 changes: 16 additions & 11 deletions hydrolib/core/dflowfm/net/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,17 +167,22 @@ def create_rectilinear(self, extent: tuple, dx: float, dy: float) -> None:
"""

xmin, ymin, xmax, ymax = extent

# Generate mesh
mesh2d_input = mk.Mesh2dFactory.create(
rows=int((ymax - ymin) / dy),
columns=int((xmax - xmin) / dx),
origin_x=xmin,
origin_y=ymin,
spacing_x=dx,
spacing_y=dy,
)


rows = int((ymax - ymin) / dy)
columns = int((xmax - xmin) / dx)

params = mk.MakeGridParameters(num_columns=columns,
num_rows=rows,
origin_x=xmin,
origin_y=ymin,
block_size_x=dx,
block_size_y=dy)

mesh2d_input = mk.MeshKernel()
mesh2d_input.curvilinear_compute_rectangular_grid(params)
mesh2d_input.curvilinear_convert_to_mesh2d() #convert to ugrid/mesh2d
mesh2d_input = mesh2d_input.mesh2d_get()

# Process
self._process(mesh2d_input)

Expand Down
1 change: 1 addition & 0 deletions tests/dflowfm/test_net.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ def test_create_2d():
@pytest.mark.parametrize(
"deletemeshoption,inside,nnodes,nedgenodes",
[
#TODO: update expected values for nnodes/nedgenodes
(DeleteMeshOption.INSIDE_NOT_INTERSECTED, False, 28, 90),
(DeleteMeshOption.INSIDE_AND_INTERSECTED, False, 23, 72),
(DeleteMeshOption.INSIDE_NOT_INTERSECTED, True, 23, 72),
Expand Down

0 comments on commit 666e68e

Please sign in to comment.