Skip to content

Commit

Permalink
removed mesh2d _process function
Browse files Browse the repository at this point in the history
  • Loading branch information
veenstrajelmer committed Nov 1, 2023
1 parent 2b0c00e commit f6ebfa5
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 59 deletions.
36 changes: 0 additions & 36 deletions hydrolib/core/dflowfm/net/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,12 +227,6 @@ def create_rectilinear(self, extent: tuple, dx: float, dy: float) -> None:
mesh2d_input = self.meshkernel # mk.MeshKernel()
mesh2d_input.curvilinear_compute_rectangular_grid(params)
mesh2d_input.curvilinear_convert_to_mesh2d() # convert to ugrid/mesh2d
mesh2d_input_m2d = mesh2d_input.mesh2d_get() # get Mesh2d object

# mesh2d_input_raw = mk.Mesh2d(mesh2d_input_m2d.node_x, mesh2d_input_m2d.node_y, mesh2d_input_m2d.edge_nodes)

# Process
self._process(mesh2d_input_m2d)

def create_triangular(self, geometry_list: mk.GeometryList) -> None:
"""Create triangular grid within GeometryList object
Expand All @@ -242,30 +236,6 @@ def create_triangular(self, geometry_list: mk.GeometryList) -> None:
"""
# Call meshkernel
self.meshkernel.mesh2d_make_triangular_mesh_from_polygon(geometry_list)

# Process new mesh
self._process(self.get_mesh2d())

def _process(self, mesh2d_input) -> None: # TODO: input arg is not used, so remove
#TODO: remove this commented function
# Add input
# self.meshkernel.mesh2d_set(mesh2d_input) #TODO: in this meshkernel function duplicates the amount of nodes. Seems not desireable, but more testbanks fail if commented.
# Get output
# mesh2d_output = self.meshkernel.mesh2d_get()

# Add to mesh2d variables
# self.mesh2d_node_x = mesh2d_output.node_x
# self.mesh2d_node_y = mesh2d_output.node_y

# self.mesh2d_edge_x = mesh2d_output.edge_x
# self.mesh2d_edge_y = mesh2d_output.edge_y
# self.mesh2d_edge_nodes = mesh2d_output.edge_nodes.reshape((-1, 2))

# self.mesh2d_face_x = mesh2d_output.face_x
# self.mesh2d_face_y = mesh2d_output.face_y
# TODO: commented since caused errors in hydromt_delft3dfm
# TODO: this is the mesh2d_face_node_connectivity, not mesh2d_face_nodes
return

def clip(
self,
Expand Down Expand Up @@ -337,9 +307,6 @@ def clip(
invert_deletion=inside,
)

# Process
self._process(self.meshkernel.mesh2d_get())

def refine(self, polygon: mk.GeometryList, level: int, min_edge_size=10.0):
"""Refine the mesh within a polygon, by a number of steps (level)
Expand Down Expand Up @@ -373,9 +340,6 @@ def refine(self, polygon: mk.GeometryList, level: int, min_edge_size=10.0):
)
self.meshkernel.mesh2d_refine_based_on_polygon(polygon, parameters)

# Process
self._process(self.meshkernel.mesh2d_get())


class Branch:
def __init__(
Expand Down
1 change: 0 additions & 1 deletion hydrolib/core/dflowfm/net/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ def read_mesh2d(self, mesh2d: Mesh2d) -> None:

# TODO: we still require this here to sync new attrs with meshkernel instance
mesh2d._set_mesh2d(node_x=node_x, node_y=node_y, edge_nodes=edge_nodes)
mesh2d._process(None)

# bathymetry
node_z = self._read_nc_attribute(ds["mesh2d_node_z"])
Expand Down
28 changes: 6 additions & 22 deletions tests/dflowfm/test_net.py
Original file line number Diff line number Diff line change
Expand Up @@ -477,33 +477,17 @@ def test_read_file_expected_results(self):
),
# fmt: on

#TODO: also get commented properties from mesh
mesh2d_output = mesh.get_mesh2d()
mesh_mesh2d_node_x = mesh2d_output.node_x
mesh_mesh2d_node_y = mesh2d_output.node_y
# mesh_mesh2d_node_z = mesh2d_output.node_z

mesh_mesh2d_edge_x = mesh2d_output.edge_x
mesh_mesh2d_edge_y = mesh2d_output.edge_y
# mesh_mesh2d_edge_z = mesh2d_output.edge_z
# mesh_mesh2d_edge_nodes = mesh2d_output.edge_nodes

mesh_mesh2d_face_x = mesh2d_output.face_x
mesh_mesh2d_face_y = mesh2d_output.face_y
# mesh_mesh2d_face_z = mesh2d_output.face_z #TODO: not available
# mesh_mesh2d_face_nodes = mesh2d_output.face_nodes

assert np.array_equiv(mesh_mesh2d_node_x, mesh2d_node_x)
assert np.array_equiv(mesh_mesh2d_node_y, mesh2d_node_y)
assert np.array_equiv(mesh.mesh2d_node_x, mesh2d_node_x)
assert np.array_equiv(mesh.mesh2d_node_y, mesh2d_node_y)
assert np.array_equiv(mesh.mesh2d_node_z, mesh2d_node_z)

# assert np.array_equiv(mesh_mesh2d_edge_x, mesh2d_edge_x) #TODO: fix expected values
# assert np.array_equiv(mesh_mesh2d_edge_y, mesh2d_edge_y) #TODO: fix expected values
# assert np.array_equiv(mesh.mesh2d_edge_x, mesh2d_edge_x) #TODO: fix expected values
# assert np.array_equiv(mesh.mesh2d_edge_y, mesh2d_edge_y) #TODO: fix expected values
# assert np.array_equiv(mesh.mesh2d_edge_z, mesh2d_edge_z) #TODO: edge_z is used nowhere in code except on init
assert np.array_equiv(mesh.mesh2d_edge_nodes, mesh2d_edge_nodes)

assert np.array_equiv(mesh_mesh2d_face_x, mesh2d_face_x)
assert np.array_equiv(mesh_mesh2d_face_y, mesh2d_face_y)
assert np.array_equiv(mesh.mesh2d_face_x, mesh2d_face_x)
assert np.array_equiv(mesh.mesh2d_face_y, mesh2d_face_y)
assert np.array_equiv(mesh.mesh2d_face_z, mesh2d_face_z)
assert np.array_equiv(mesh.mesh2d_face_nodes, mesh2d_face_nodes)

Expand Down

0 comments on commit f6ebfa5

Please sign in to comment.