meshkernel.meshkernel module

class MeshKernel(projection: ProjectionType = ProjectionType.CARTESIAN)

Bases: object

This class is the entry point for interacting with the MeshKernel library

contacts_compute_boundary(node_mask: ~numpy.ndarray, search_radius: float, polygons: ~meshkernel.py_structures.GeometryList = <meshkernel.py_structures.GeometryList object>) None

Computes Mesh1d-Mesh2d contacts, where Mesh1d nodes are connected to the closest Mesh2d faces at the boundary

Parameters:
  • node_mask (ndarray) – A boolean array describing whether Mesh1d nodes should or should not be connected (1 = generate a connection, 0 = do not generate a connection)

  • search_radius (float) – The radius used for searching neighboring Mesh2d faces, in meters for cartesian projection and degrees for spherical projection. If it is equal to the missing value double, the search radius will be calculated internally.

  • polygons (GeometryList, optional) – The polygon selecting the Mesh2d faces to connect.

contacts_compute_multiple(node_mask: ndarray) None

Computes Mesh1d-Mesh2d contacts, where a single Mesh1d node is connected to multiple Mesh2d face circumcenters.

Parameters:

node_mask (ndarray) – A boolean array describing whether Mesh1d nodes should or should not be connected

contacts_compute_single(node_mask: ndarray, polygons: GeometryList, projection_factor: float) None

Computes Mesh1d-Mesh2d contacts, where each single Mesh1d node is connected to one Mesh2d face circumcenter. The boundary nodes of Mesh1d (those sharing only one Mesh1d edge) are not connected to any Mesh2d face.

Parameters:
  • node_mask (ndarray) – A boolean array describing whether Mesh1d nodes should or should not be connected

  • polygons (GeometryList) – The polygons selecting the area where the contacts will be be generated.

  • projection_factor (float) – The projection factor used for generating the contacts when 1d nodes are

  • mesh. (not inside the 2d)

contacts_compute_with_points(node_mask: ~numpy.ndarray, polygons: ~meshkernel.py_structures.GeometryList = <meshkernel.py_structures.GeometryList object>) None

Computes Mesh1d-Mesh2d contacts, where Mesh1d nodes are connected to the Mesh2d face mass centers containing the input point.

Parameters:
  • node_mask (ndarray) – A boolean array describing whether Mesh1d nodes should or should not be connected

  • polygons (GeometryList, optional) – The polygon selecting the Mesh2d faces to connect.

contacts_compute_with_polygons(node_mask: ndarray, polygons: GeometryList) None

Computes Mesh1d-Mesh2d contacts, where a Mesh2d face per polygon is connected to the closest Mesh1d node.

Parameters:
  • node_mask (ndarray) – A boolean array describing whether Mesh1d nodes should or should not be connected

  • polygons (GeometryList) – The polygons in which the closest Mesh2d face to a Mesh1d node will be connected.

contacts_get() Contacts

Gets the Contacts between the Mesh1d and Mesh2d from the MeshKernel.

Please note that this involves a copy of the data.

Returns:

The contacts.

Return type:

Contacts

contacts_set(contacts: Contacts) None

Sets the contacts.

Please note that this involves a copy of the data.

Parameters:

contacts (Contacts) – The input data used for setting the contacts.

curvilinear_compute_curvature(direction: CurvilinearDirection) ndarray

Computes the curvature of a curvilinear grid.

Parameters:

direction (int) – The direction in which to compute the smoothness.

curvilinear_compute_orthogonal_from_splines(splines: GeometryList, curvilinear_parameters: CurvilinearParameters, splines_to_curvilinear_parameters: SplinesToCurvilinearParameters) None

Generates curvilinear grid from splines with the advancing front method.

Parameters:
curvilinear_compute_rectangular_grid(make_grid_parameters: MakeGridParameters) None

Makes a rectangular grid

Parameters:

make_grid_parameters (MakeGridParameters) – The parameters used for making the uniform grid

curvilinear_compute_rectangular_grid_from_polygon(make_grid_parameters: MakeGridParameters, geometry_list: GeometryList) None

Makes a rectangular grid from polygons.

Parameters:
  • make_grid_parameters (MakeGridParameters) – The parameters used for making the uniform grid

  • geometry_list (GeometryList) – The polygon within which the grid will be generated

curvilinear_compute_rectangular_grid_on_extension(make_grid_parameters: MakeGridParameters) None

Makes a rectangular grid on defined extension.

Parameters:

make_grid_parameters (MakeGridParameters) – The parameters used for making the uniform grid

curvilinear_compute_smoothness(direction: CurvilinearDirection) ndarray

Computes the smoothness of a curvilinear grid.

Parameters:

direction (int) – The direction in which to compute the smoothness.

curvilinear_compute_transfinite_from_polygon(geometry_list: GeometryList, first_node: int, second_node: int, third_node: int, use_fourth_side: bool) None

Computes a curvilinear mesh in a polygon. 3 separate polygon nodes need to be selected.

Parameters:
  • geometry_list (GeometryList) – The input polygon.

  • first_node (int) – The first selected node.

  • second_node (int) – The second selected node.

  • third_node (int) – The third selected node.

  • use_fourth_side (bool) – Use the fourth polygon side to compute the curvilinear grid.

curvilinear_compute_transfinite_from_splines(splines: GeometryList, curvilinear_parameters: CurvilinearParameters) None

Generates curvilinear grid from splines with transfinite interpolation.

Parameters:
curvilinear_compute_transfinite_from_triangle(geometry_list: GeometryList, first_node: int, second_node: int, third_node: int) None

Computes a curvilinear mesh in a triangle. 3 separate polygon nodes need to be selected.

Parameters:
  • geometry_list (GeometryList) – The input polygon.

  • first_node (int) – The first selected node.

  • second_node (int) – The second selected node.

  • third_node (int) – The third selected node.

curvilinear_convert_to_mesh2d() None

Converts a curvilinear grid to an unstructured mesh

curvilinear_delete_node(x_coordinate: float, y_coordinate: float) None

Delete the node closest to a point

Parameters:
  • x_coordinate (float) – The x coordinate of the point.

  • y_coordinate (float) – The y coordinate of the point.

curvilinear_derefine(x_lower_left_corner: float, y_lower_left_corner: float, x_upper_right_corner: float, y_upper_right_corner: float) None

Directional curvilinear grid derefinement. Additional gridlines are removed perpendicularly to the segment defined by lower_left_corner and upper_right_corner

Parameters:
  • x_lower_left_corner (float) – The x coordinate of the lower left corner of the block to refine.

  • y_lower_left_corner (float) – The y coordinate of the lower left corner of the block to refine.

  • x_upper_right_corner (float) – The x coordinate of the upper right corner of the block to refine.

  • y_upper_right_corner (float) – The y coordinate of the upper right corner of the block to refine.

curvilinear_initialize_line_shift() None

Initializes the curvilinear line shift algorithm

curvilinear_initialize_orthogonalize(orthogonalization_parameters: OrthogonalizationParameters) None

Initializes the algorithm for performing curvilinear grid orthogonalization.

Parameters:

orthogonalization_parameters (OrthogonalizationParameters) – The input orthogonalization parameters.

curvilinear_insert_face(x_coordinate: float, y_coordinate: float) None

Inserts a new face on a curvilinear grid. The new face will be inserted on top of the closest edge by linear extrapolation.

Parameters:
  • x_coordinate (float) – The x coordinate of the point used for finding the closest face.

  • y_coordinate (float) – The y coordinate of the point used for finding the closest face.

curvilinear_line_attraction_repulsion(repulsion_parameter: float, x_first_grid_line_node: float, y_first_grid_line_node: float, x_second_grid_line_node: float, y_second_grid_line_node: float, x_lower_left_corner: float, y_lower_left_corner: float, x_upper_right_corner: float, y_upper_right_corner: float)

Attracts/repulses grid lines in a block towards another set grid line.

Parameters:
  • repulsion_parameter (float) – The repulsion parameter.

  • x_first_grid_line_node (float) – The x coordinate of the first node.

  • y_first_grid_line_node (float) – The y coordinate of the first node.

  • x_second_grid_line_node (float) – The x coordinate of the second node.

  • y_second_grid_line_node (float) – The y coordinate of the second node.

  • x_lower_left_corner (float) – The x coordinate of the lower left corner of the block.

  • y_lower_left_corner (float) – The y coordinate of the lower left corner of the block.

  • x_upper_right_corner (float) – The x coordinate of the upper right corner of the block.

  • y_upper_right_corner (float) – The y coordinate of the upper right corner of the block.

curvilinear_line_mirror(mirroring_factor: float, x_first_grid_line_node: float, y_first_grid_line_node: float, x_second_grid_line_node: float, y_second_grid_line_node: float) None

Mirrors a boundary grid line outwards. The boundary grid line is defined by its start and end points

Parameters:
  • mirroring_factor (float) – The mirroring factor.

  • x_first_grid_line_node (float) – The x coordinate of the first node.

  • y_first_grid_line_node (float) – The y coordinate of the first node.

  • x_second_grid_line_node (float) – The x coordinate of the second node.

  • y_second_grid_line_node (float) – The y coordinate of the second node.

curvilinear_line_shift()

Performs the curvilinear line shifting and finalizes the algorithm.

curvilinear_move_node(x_from_point: float, y_from_point: float, x_to_point: float, y_to_point: float) None

Moves a point of a curvilinear grid from one location to another.

Parameters:
  • x_from_point (float) – The x coordinate of point to move.

  • y_from_point (float) – The y coordinate of point to move.

  • x_to_point (float) – The new x coordinate of the point.

  • y_to_point (float) – The new y coordinate of the point.

curvilinear_move_node_line_shift(x_from_coordinate: float, y_from_coordinate: float, x_to_coordinate: float, y_to_coordinate: float) None

Moves a node of the line to shift. The operation can be performed multiple times.

Parameters:
  • x_from_coordinate (float) – The x coordinate of the node to move.

  • y_from_coordinate (float) – The y coordinate of the node to move.

  • x_to_coordinate (float) – The x coordinate of the new node position.

  • y_to_coordinate (float) – The y coordinate of the new node position.

curvilinear_orthogonalize() None

Performs curvilinear grid orthogonalization and finalizes the algorithm

curvilinear_refine(x_lower_left_corner: float, y_lower_left_corner: float, x_upper_right_corner: float, y_upper_right_corner: float, refinement: int) None

Directional curvilinear grid refinement. Additional gridlines are added perpendicularly to the segment defined by lower_left_corner and upper_right_corner

Parameters:
  • x_lower_left_corner (float) – The x coordinate of the lower left corner of the block to refine.

  • y_lower_left_corner (float) – The y coordinate of the lower left corner of the block to refine.

  • x_upper_right_corner (float) – The x coordinate of the upper right corner of the block to refine.

  • y_upper_right_corner (float) – The y coordinate of the upper right corner of the block to refine.

  • refinement (int) – The number of grid lines to add between lower left and upper right

curvilinear_set_block_line_shift(x_lower_left_corner: float, y_lower_left_corner: float, x_upper_right_corner: float, y_upper_right_corner: float) None

Defines a block on the curvilinear where the grid line shifting is distributed.

Parameters:
  • x_lower_left_corner (float) – The x coordinate of the lower left corner of the block.

  • y_lower_left_corner (float) – The y coordinate of the lower left corner of the block.

  • x_upper_right_corner (float) – The x coordinate of the upper right corner of the block.

  • y_upper_right_corner (float) – The y coordinate of the upper right corner of the block.

curvilinear_set_block_orthogonalize(x_lower_left_corner: float, y_lower_left_corner: float, x_upper_right_corner: float, y_upper_right_corner: float) None

Defines a block on the curvilinear grid where to perform orthogonalization

Parameters:
  • x_lower_left_corner (float) – The x coordinate of the lower left corner of the block to orthogonalize.

  • y_lower_left_corner (float) – The y coordinate of the lower left corner of the block to orthogonalize.

  • x_upper_right_corner (float) – The x coordinate of the upper right corner of the block to orthogonalize.

  • y_upper_right_corner (float) – The y coordinate of the upper right corner of the block to orthogonalize.

curvilinear_set_frozen_lines_orthogonalize(x_first_gridline_node: float, y_first_gridline_node: float, x_second_gridline_node: float, y_second_gridline_node: float) None

Freezes a curvilinear grid line during the orthogonalization process

Parameters:
  • x_first_gridline_node (float) – The x coordinate of the first point of the line to freeze.

  • y_first_gridline_node (float) – The y coordinate of the first point of the line to freeze.

  • x_second_gridline_node (float) – The x coordinate of the second point of the line to freeze.

  • y_second_gridline_node (float) – The y coordinate of the second point of the line to freeze.

curvilinear_set_line_line_shift(x_first_grid_line_node: float, y_first_grid_line_node: float, x_second_grid_line_node: float, y_second_grid_line_node: float) None

Sets the start and end grid nodes of the grid line to shift.

Parameters:
  • x_first_grid_line_node (float) – The x coordinate of the first curvilinear grid node to shift.

  • y_first_grid_line_node (float) – The y coordinate of the first curvilinear grid node to shift.

  • x_second_grid_line_node (float) – The x coordinate of the second curvilinear grid node to shift.

  • y_second_grid_line_node (float) – The y coordinate of the second curvilinear grid node to shift.

curvilinear_smoothing(smoothing_iterations: int, x_lower_left_corner: float, y_lower_left_corner: float, x_upper_right_corner: float, y_upper_right_corner: float) None

Smooths a curvilinear grid.

Parameters:
  • smoothing_iterations (int) – The number of smoothing iterations to perform

  • x_lower_left_corner (float) – The x coordinate of the lower left corner of the block to refine.

  • y_lower_left_corner (float) – The y coordinate of the lower left corner of the block to refine.

  • x_upper_right_corner (float) – The x coordinate of the upper right corner of the block to refine.

  • y_upper_right_corner (float) – The y coordinate of the upper right corner of the block to refine.

curvilinear_smoothing_directional(smoothing_iterations: int, x_first_grid_line_node: float, y_first_grid_line_node: float, x_second_grid_line_node: float, y_second_grid_line_node: float, x_lower_left_corner: float, y_lower_left_corner: float, x_upper_right_corner: float, y_upper_right_corner: float) None

Smooths a curvilinear grid along the direction specified by a segment.

Parameters:
  • smoothing_iterations (int) – The number of smoothing iterations to perform

  • x_first_grid_line_node (float) – The x coordinate of the first curvilinear grid node.

  • y_first_grid_line_node (float) – The y coordinate of the first curvilinear grid node.

  • x_second_grid_line_node (float) – The x coordinate of the second curvilinear grid node.

  • y_second_grid_line_node (float) – The y coordinate of the second curvilinear grid node.

  • x_lower_left_corner (float) – The x coordinate of the lower left corner of the block to refine.

  • y_lower_left_corner (float) – The y coordinate of the lower left corner of the block to refine.

  • x_upper_right_corner (float) – The x coordinate of the upper right corner of the block to refine.

  • y_upper_right_corner (float) – The y coordinate of the upper right corner of the block to refine.

curvilineargrid_get() CurvilinearGrid

Gets the curvilinear grid state from the MeshKernel.

Please note that this involves a copy of the data.

Returns:

A copy of the curvilinear grid state.

Return type:

CurvilinearGrid

get_meshkernel_version() str

Get the version of the underlying C++ MeshKernel library

Returns:

The version string

Return type:

str

get_meshkernelpy_version() str

Get the version of this Python wrapper

Returns:

The version string

Return type:

str

get_projection() ProjectionType

Gets the projection type of the meshkernel state

Returns:

The projection type

Return type:

ProjectionType

get_splines(geometry_list: GeometryList, number_of_points_between_nodes: int) GeometryList

Get the computed spline points between two corner nodes.

Parameters:
  • geometry_list (GeometryList) – The input corner nodes of the splines.

  • number_of_points_between_nodes (int) – The number of spline points to generate between two corner nodes.

Returns:

The output spline.

Return type:

GeometryList

mesh1d_add(mesh1d: Mesh1d) None

Adds a one-dimensional mesh.

Please note that this involves a copy of the data.

Parameters:

mesh1d (Mesh1d) – The input data used for setting the state.

mesh1d_get() Mesh1d

Gets the one-dimensional mesh state from the MeshKernel.

Please note that this involves a copy of the data.

Returns:

A copy of the two-dimensional mesh state.

Return type:

Mesh1d

mesh1d_set(mesh1d: Mesh1d) None

Sets the one-dimensional mesh state of the MeshKernel.

Please note that this involves a copy of the data.

Parameters:

mesh1d (Mesh1d) – The input data used for setting the state.

mesh2d_add(mesh2d: Mesh2d) None

Adds a two-dimensional mesh.

Please note that this involves a copy of the data.

Parameters:

mesh2d (Mesh2d) – The input data used for setting the state.

mesh2d_averaging_interpolation(samples: GeometryList, location_type: Mesh2dLocation, averaging_method: AveragingMethod, relative_search_size: float, min_samples: int) GeometryList

Performs averaging interpolation of samples.

Parameters:
  • samples (GeometryList) – The samples to interpolate.

  • location_type (Mesh2dLocation) – The location type on which to interpolate.

  • averaging_method (AveragingMethod) – The averaging method.

  • relative_search_size (float) – The relative search size.

  • min_samples (int) – The minimum number of samples used for some interpolation algorithms to perform a valid interpolation.

Returns:

The interpolated samples.

Return type:

GeometryList

mesh2d_casulli_derefinement() None

De-refine the whole mesh using the Casulli algorithm

mesh2d_casulli_derefinement_on_polygon(polygon: GeometryList) None

De-refine a mesh region using the Casulli algorithm

Parameters:

polygon (GeometryList) – The input polygon.

mesh2d_casulli_refinement() None

Refine the whole mesh using the Casulli algorithm

mesh2d_casulli_refinement_on_polygon(polygon: GeometryList) None

Refine a mesh region using the Casulli algorithm

Parameters:

polygon (GeometryList) – The input polygon.

mesh2d_compute_orthogonalization(project_to_land_boundary_option: ~meshkernel.py_structures.ProjectToLandBoundaryOption, orthogonalization_parameters: ~meshkernel.py_structures.OrthogonalizationParameters, land_boundaries: ~meshkernel.py_structures.GeometryList, selecting_polygon: ~meshkernel.py_structures.GeometryList = <meshkernel.py_structures.GeometryList object>) None

Orthogonalizes the Mesh2d. The function modifies the mesh for achieving orthogonality between the edges and the segments connecting the face circumcenters. The amount of orthogonality is traded against the mesh smoothing (in this case the equality of face areas).

Parameters:
  • project_to_land_boundary_option (ProjectToLandBoundaryOption) – The option to determine how to snap to land boundaries.

  • orthogonalization_parameters (OrthogonalizationParameters) – The orthogonalization parameters.

  • land_boundaries (GeometryList) – The land boundaries to account for in the orthogonalization process.

  • selecting_polygon (GeometryList, optional) – The polygon where to perform the orthogonalization.

mesh2d_connect_meshes(mesh2d: Mesh2d, search_fraction: float) None

Connect a mesh to an existing mesh

Parameters:
  • mesh2d (Mesh2d) – The mesh to connect to the existing mesh

  • search_fraction (float) – Fraction of the shortest edge (along an edge to be connected) to use when determining neighbour edge closeness

mesh2d_convert_projection(projection: ProjectionType, zone: str) None

Converts the projection of a mesh2d.

Parameters:
  • projection (ProjectionType) – The new mesh projection.

  • zone (str) – The UTM zone and information string.

mesh2d_delete(geometry_list: GeometryList, delete_option: DeleteMeshOption, invert_deletion: bool) None

Deletes a mesh in a polygon using several options.

Parameters:
  • geometry_list (GeometryList) – The GeometryList describing the polygon where to perform the operation.

  • delete_option (DeleteMeshOption) – The option describing the strategy to delete the mesh.

  • invert_deletion (bool) – Whether or not to invert the deletion.

mesh2d_delete_edge(x_coordinate: float, y_coordinate: float) None

Deletes the closest mesh2d edge to a point. The coordinates of the edge middle points are used for calculating the distances to the point.

Parameters:
  • x (float) – The x-coordinate of the point.

  • y (float) – The y-coordinate of the point.

mesh2d_delete_hanging_edges() None

Delete the hanging edges in the Mesh2d. A hanging edge is an edge where one of the two nodes is not connected.

mesh2d_delete_node(node_index: int) None

Deletes a Mesh2d node with the given index.

Parameters:

node_index (int) – The index of the node to be deleted.

Raises:

InputError – Raised when node_index is smaller than 0.

mesh2d_delete_small_flow_edges_and_small_triangles(small_flow_edges_length_threshold: float, min_fractional_area_triangles: float) None

Deletes all small mesh2d flow edges and small triangles. The flow edges are the edges connecting faces circumcenters.

Parameters:
  • small_flow_edges_length_threshold (float) – The configurable length for detecting a small flow edge.

  • min_fractional_area_triangles (float) – The ratio of the face area to the average area of neighboring non-triangular faces. This parameter is used for determining whether a triangular face is small.

mesh2d_flip_edges(triangulation_required: bool, project_to_land_boundary_required: bool, selecting_polygon: GeometryList, land_boundaries: GeometryList)

Flips mesh2d edges to optimize the mesh smoothness. Nodes that are connected to more than six other nodes are typically enclosed by faces of highly non-uniform shape and wildly varying areas.

Parameters:
  • triangulation_required (bool) – Whether to triangulate non-triangular cells.

  • project_to_land_boundary_required (bool) – Whether projection to land boundaries is required.

  • selecting_polygon (GeometryList) – The polygon where to perform the edge flipping.

  • land_boundaries (GeometryList) – The land boundaries to account for when flipping the edges.

mesh2d_get() Mesh2d

Gets the two-dimensional mesh state from the MeshKernel.

Please note that this involves a copy of the data.

Returns:

A copy of the two-dimensional mesh state.

Return type:

Mesh2d

mesh2d_get_edge(x: float, y: float) int

Gets the closest mesh2d edge to a point.

Parameters:
  • x (float) – The x-coordinate of the point.

  • y (float) – The y-coordinate of the point.

Returns:

The index of the edge (gap-free array index)

Return type:

int

mesh2d_get_face_polygons(num_edges: int) GeometryList

Gets the faces polygons with a number of edges equal to num_edges.

Parameters:

num_edges (int) – The number of edges

Returns:

The resulting face polygons

Return type:

GeometryList

mesh2d_get_filtered_face_polygons(property: Property, min_value: float, max_value: float) GeometryList

Gets the polygons matching the metric value within the minimum and maximum value.

Parameters:
  • property (Mesh2d.Property) – 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.

Returns:

The resulting face polygons

Return type:

GeometryList

mesh2d_get_hanging_edges() ndarray

Gets the indices of hanging edges. A hanging edge is an edge where one of the two nodes is not connected.

Returns:

The integer array describing the indices of the hanging edges.

Return type:

ndarray

mesh2d_get_mesh_boundaries_as_polygons() GeometryList

Retrieves the boundaries of a mesh as a series of separated polygons.

For example, if a mesh has an single inner hole, two polygons will be generated, one for the inner boundary and one for the outer boundary.

Returns:

The output network boundary polygon.

Return type:

GeometryList

mesh2d_get_node_index(x: float, y: float, search_radius: float) int

Finds the node closest to a point within a given search radius.

Parameters:
  • x (float) – The x-coordinate of the point.

  • y (float) – The y-coordinate of the point.

  • search_radius (float) – The search radius.

Returns:

The index of node (gap-free array index)

Return type:

int

mesh2d_get_nodes_in_polygons(geometry_list: GeometryList, inside: bool) ndarray

Gets the indices of the mesh2d nodes selected with a polygon.

Parameters:
  • geometry_list (GeometryList) – The input polygon.

  • inside (bool) – Selection of the nodes inside the polygon (True) or outside (False).

Returns:

The integer array describing the selected nodes indices.

Return type:

ndarray

mesh2d_get_obtuse_triangles_mass_centers() GeometryList

Gets the mass centers of obtuse mesh2d triangles. Obtuse triangles are those having one angle larger than 90°.

Returns:

The geometry list with the mass center coordinates.

Return type:

GeometryList

mesh2d_get_orthogonality() GeometryList

Gets the mesh orthogonality, expressed as the ratio between the edges and the segments connecting the face circumcenters.

Returns:

The geometry list with the orthogonality values of each edge.

Return type:

GeometryList

mesh2d_get_property(property: Property) GeometryList

Gets the polygons matching the metric value within the minimum and maximum value.

Parameters:

property (Mesh2d.Property) – The property to retrieve

Returns:

The resulting geometry list containing the value of the properties

Return type:

GeometryList

mesh2d_get_small_flow_edge_centers(small_flow_edges_length_threshold: float) GeometryList

Gets the small mesh2d flow edges centers. The flow edges are the edges connecting face circumcenters.

Parameters:

small_flow_edges_length_threshold (float) – The configurable length for detecting a small flow edge.

Returns:

The geometry list with the small flow edge center coordinates.

Return type:

int

mesh2d_get_smoothness()

Gets the smoothness, expressed as the ratio between the values of two neighboring faces areas.

Returns:

The geometry list with the smoothness values of each edge.

Return type:

GeometryList

mesh2d_insert_edge(start_node: int, end_node: int) int

Insert a new mesh2d edge connecting two given nodes.

Parameters:
  • start_node (int) – The index of the first node.

  • end_node (int) – The index of the second node.

Returns:

The index of the new edge.

Return type:

int

mesh2d_insert_node(x: float, y: float) int

Insert a new node at the specified coordinates

Parameters:
  • x (float) – The x-coordinate of the new node.

  • y (float) – The y-coordinate of the new node.

Returns:

The index of the new node.

Return type:

int

mesh2d_make_global(num_longitude_nodes: int, num_latitude_nodes: int) None

Compute the global mesh with a given number of points along the longitude and latitude directions.

Args: num_longitude_nodes (int): The number of points along the longitude. num_latitude_nodes (int): The number of points along the latitude (half hemisphere)

mesh2d_make_rectangular_mesh(make_grid_parameters: MakeGridParameters) None

Generates a rectangular mesh2d.

Parameters:

make_grid_parameters (MakeGridParameters) – The parameters used for making the uniform grid

mesh2d_make_rectangular_mesh_from_polygon(make_grid_parameters: MakeGridParameters, polygon: GeometryList) None

Generates a rectangular mesh2d within a polygon.

Parameters:
  • make_grid_parameters (MakeGridParameters) – The parameters used for making the uniform grid

  • geometry_list (GeometryList) – The polygon within which the grid will be generated

mesh2d_make_rectangular_mesh_on_extension(make_grid_parameters: MakeGridParameters) None

Generates a rectangular mesh2d.

Parameters:

make_grid_parameters (MakeGridParameters) – The parameters used for making the uniform grid

mesh2d_make_triangular_mesh_from_polygon(polygon: GeometryList) None

Generates a triangular mesh2d within a polygon. The size of the triangles is determined from the length of the polygon edges.

Parameters:

polygon (GeometryList) – The polygon.

mesh2d_make_triangular_mesh_from_samples(sample_points: GeometryList) None

Makes a triangular mesh from a set of samples, triangulating the sample points.

Parameters:

sample_points (GeometryList) – The sample points.

mesh2d_merge_nodes(geometry_list: GeometryList) None

Merges the mesh2d nodes, effectively removing all small edges.

Parameters:

geometry_list (GeometryList) – The polygon defining the area where the operation will be performed.

mesh2d_merge_nodes_with_merging_distance(geometry_list: GeometryList, merging_distance: float) None

Merges the mesh2d nodes, effectively removing all small edges.

Parameters:
  • geometry_list (GeometryList) – The polygon defining the area where the operation will be performed.

  • merging_distance (float) – The distance below which two nodes will be merged.

mesh2d_merge_two_nodes(first_node: int, second_node: int) None

Merges first_node into second_node.

Parameters:
  • first_node (int) – The index of the first node to merge.

  • second_node (int) – The index of the second node to merge.

mesh2d_move_node(x: float, y: float, node_index: int) None

Moves a Mesh2d node with the given index to the point position.

Parameters:
  • x (float) – The x-coordinate of the new position of the node.

  • y (float) – The y-coordinate of the new position of the node.

  • node_index (int) – The index of the node to be moved.

Raises:

InputError – Raised when node_index is smaller than 0.

mesh2d_refine_based_on_gridded_samples(gridded_samples: GriddedSamples, mesh_refinement_params: MeshRefinementParameters, use_nodal_refinement: bool = True) None

Computes mesh refinement based of gridded samples and bilinear interpolation

Parameters:
  • gridded_samples (GriddedSamples) – The gridded samples.

  • mesh_refinement_params (MeshRefinementParameters) – The mesh refinement parameters.

  • use_nodal_refinement (bool) – If the depth value at nodes is used for refinement. Default True.

mesh2d_refine_based_on_polygon(polygon: GeometryList, mesh_refinement_params: MeshRefinementParameters) None

Refines a mesh2d within a polygon. Refinement is achieved by splitting the edges contained in the polygon in two.

Parameters:
mesh2d_refine_based_on_samples(samples: GeometryList, relative_search_radius: float, minimum_num_samples: int, mesh_refinement_params: MeshRefinementParameters) None

Refines a mesh2d based on samples. Refinement is achieved by successive splits of the face edges. The number of successive splits is indicated by the sample value. For example: - a value of 0 means no split and hence no refinement; - a value of 1 means a single split (a quadrilateral face generates 4 faces); - a value of 2 two splits (a quadrilateral face generates 16 faces).

Parameters:
  • samples (GeometryList) – The samples.

  • relative_search_radius (float) – The relative search radius relative to the face size, used for some interpolation algorithms.

  • minimum_num_samples (int) – The minimum number of samples used for some averaging algorithms.

  • mesh_refinement_params (MeshRefinementParameters) – The mesh refinement parameters.

mesh2d_refine_ridges_based_on_gridded_samples(gridded_samples: GriddedSamples, relative_search_radius: float, minimum_num_samples: int, number_of_smoothing_iterations: int, mesh_refinement_params: MeshRefinementParameters) None

Refines a mesh2d based on samples with ridge refinement. This method automatically detects the ridges in a sample set.

Parameters:
  • gridded_samples (GriddedSamples) – The gridded samples.

  • relative_search_radius (float) – The relative search radius relative to the face size, used for some interpolation algorithms.

  • minimum_num_samples (int) – The minimum number of samples used for some averaging algorithms.

  • number_of_smoothing_iterations (int) – The number of smoothing iterations to apply to the input sample set.

  • mesh_refinement_params (MeshRefinementParameters) – The mesh refinement parameters.

mesh2d_remove_disconnected_regions() None

Remove any disconnected regions from a mesh2d. Only the most frequent remains

mesh2d_rotate(centre_x: float, centre_y: float, angle: float) None

Rotates a mesh2d by about a centre of rotation.

Args: centre_x (float): X-coordinate of the centre of rotation. centre_y (float): Y-coordinate of the centre of rotation. angle (float): Angle of rotation in degrees.

mesh2d_set(mesh2d: Mesh2d) None

Sets the two-dimensional mesh state of the MeshKernel.

Please note that this involves a copy of the data.

Parameters:

mesh2d (Mesh2d) – The input data used for setting the state.

mesh2d_translate(translation_x: float, translation_y: float) None

Translates a mesh2d.

Args: translation_x (float): X-component of the translation vector. translation_y (float): Y-component of the translation vector

mesh2d_triangulation_interpolation(samples: GeometryList, location_type: Mesh2dLocation) GeometryList

Performs triangulation interpolation of samples.

Parameters:
  • samples (GeometryList) – The samples to interpolate.

  • location_type (Mesh2dLocation) – The location type on which to interpolate.

Returns:

The interpolated samples.

Return type:

GeometryList

mkernel_get_inner_outer_separator() float

Get the separator used in MeshKernel for separating the outer perimeter of a polygon from is inner perimeter

Returns:

The polygon inner/outer separator

Return type:

float

mkernel_get_separator() float

Get the separator used in MeshKernel

Returns:

The separator

Return type:

float

polygon_get_included_points(selecting_polygon: GeometryList, selected_polygon: GeometryList) GeometryList

Selects the polygon points within another polygon.

Parameters:
  • selecting_polygon (GeometryList) – The selection polygon.

  • selected_polygon (GeometryList) – The polygon of which to get the selected points.

Returns:

The selection result. The selected points are contained in the values array of the returned

GeometryList (0.0 not selected, 1.0 selected).

Return type:

GeometryList

polygon_refine(polygon: GeometryList, first_node: int, second_node: int, target_edge_length: float) GeometryList

Refines the polygon perimeter between two nodes. This interval is refined to achieve a target edge length.

Parameters:
  • polygon (GeometryList) – The input polygon to refine.

  • first_node (int) – The first index of the refinement interval.

  • second_node (int) – The second index of the refinement interval.

  • target_edge_length (float) – The target interval edge length.

Returns:

The refined polygon.

Return type:

GeometryList