meshkernel.py_structures module

class AveragingMethod(value)

Bases: IntEnum

The averaging methods.

CLOSEST_POINT = 2

Takes the maximum sample value.

INVERSE_WEIGHT_DISTANCE = 5

Computes the minimum absolute value.

MAX = 3

Takes the minimum sample value.

MIN = 4

Computes the inverse weighted sample mean.

MIN_ABS = 6
SIMPLE_AVERAGING = 1

Takes the value of the closest sample to the interpolation location.

class Contacts(mesh1d_indices, mesh2d_indices)

Bases: object

This class describes the contacts between a mesh1d and mesh2d.

mesh1d_indices

A 1D integer array describing the mesh1d node indices.

Type:

ndarray

mesh2d_indices

A 1D integer array describing the mesh2d face indices.

Type:

ndarray

plot_edges(ax, mesh1d, mesh2d, *args, **kwargs)

Plots the edges at a given axes. args and kwargs will be used as parameters of the plot method of matplotlib.

Parameters:
  • ax (matplotlib.axes.Axes) – The axes where to plot the edges

  • mesh1d (Mesh1d) – The mesh1d instance used to plot the contacts

  • mesh2d (Mesh2d) – The mesh2d instance used to plot the contacts

remove_invalid_values(int_invalid_value: int)

Removes invalid values that might be present in the arrays. Remove the corresponding entries in the others

Parameters:

int_invalid_value – (int): The int invalid value.

class CurvilinearDirection(value)

Bases: IntEnum

Direction to use in curvilinear grid algorithms.

M = 0
N = 1
class CurvilinearGrid(node_x, node_y, num_m, num_n)

Bases: object

This class is used for getting and setting curvilinear grid data.

node_x

A 1D double array describing the x-coordinates of the nodes.

Type:

ndarray

node_y

A 1D double array describing the y-coordinates of the nodes.

Type:

ndarray

num_m

The number of curvilinear grid nodes along m.

Type:

int

num_n

The number of curvilinear grid nodes along n.

Type:

int

plot_edges(ax, *args, **kwargs)

Plots the edges at a given axes. args and kwargs will be used as parameters of the plot method of matplotlib.

Parameters:

ax (matplotlib.axes.Axes) – The axes where to plot the edges

class CurvilinearParameters(m_refinement=2000, n_refinement=40, smoothing_iterations=10, smoothing_parameter=0.5, attraction_parameter=0.0)

Bases: object

A class holding the parameters for generating a curvilinear grid from splines.

m_refinement

M-refinement factor for regular grid generation. Default is 2000.

Type:

int, optional

n_refinement

N-refinement factor for regular grid generation. Default is 40.

Type:

int, optional

smoothing_iterations

Nr. of inner iterations in regular grid smoothing. Default is 25.

Type:

int, optional

smoothing_parameter

Smoothing parameter. Default is 0.5.

Type:

float, optional

attraction_parameter

Attraction/repulsion parameter. Default is 0.0.

Type:

float, optional

class DeleteMeshOption(value)

Bases: IntEnum

Option to delete the mesh inside a polygon.

FACES_WITH_INCLUDED_CIRCUMCENTERS = 2
INSIDE_AND_INTERSECTED = 1

Deletes the faces with circumcenters included in the polygon

INSIDE_NOT_INTERSECTED = 0

Deletes mesh inside and intersected

class GeometryList(x_coordinates=array([], dtype=float64), y_coordinates=array([], dtype=float64), values=array([], dtype=float64), geometry_separator=-999.0, inner_outer_separator=-998.0)

Bases: object

A class to describe a list of geometries.

x_coordinates

A 1D double array describing the x-coordinates of the nodes.

Type:

ndarray

y_coordinates

A 1D double array describing the y-coordinates of the nodes.

Type:

ndarray

values

A 1D double array describing the values of the nodes.

Type:

ndarray, optional

geometry_separator

The value used as a separator in the coordinates. Default is -999.0.

Type:

float, optional

inner_outer_separator

The value used to separate the inner part of a polygon from its outer part. Default is -998.0.

Type:

float, optional

class GriddedSamples(num_x=0, num_y=0, x_origin=0.0, y_origin=0.0, cell_size=0.0, x_coordinates=array([], dtype=float64), y_coordinates=array([], dtype=float64), values=array([], dtype=float32))

Bases: object

A class holding gridded samples, both for uniform gridding and non-uniform gridding.

num_x

Number of x gridded samples coordinates. The number of grid points is num_x * num_y.

Type:

int, optional

Default is `0`.
num_y

Number of y gridded samples coordinates. The number of grid points is num_x * num_y.

Type:

int, optional

Default is `0`.
x_origin

X coordinate of the grid origin. Default is 0.0.

Type:

float, optional

y_origin

Y coordinate of the grid origin. Default is 0.0.

Type:

float, optional

cell_size

Constant grid edge size. Default is 0.0.

Type:

float, optional

x_coordinates

Coordinates for non-uniform grid spacing in x direction.

Type:

ndarray, optional

y_coordinates

Coordinates for non-uniform grid spacing in y direction.

Type:

ndarray, optional

values

Sample values.

Type:

ndarray

class InterpolationValues(value)

Bases: IntEnum

The possible types of the values to be interpolated in the gridded sample.

DOUBLE = 3
FLOAT = 1
INT = 2
SHORT = 0
class MakeGridParameters(num_columns=3, num_rows=3, angle=0.0, origin_x=0.0, origin_y=0.0, block_size_x=10.0, block_size_y=10.0, upper_right_x=0.0, upper_right_y=0.0)

Bases: object

A class holding the necessary parameters to create a new curvilinear grid in a C-compatible manner.

num_columns

The number of columns in x direction. Default is 3.

Type:

int, optional

num_rows

The number of columns in y direction. Default is 3.

Type:

int, optional

angle

The grid angle. Default is 0.0.

Type:

float, optional

origin_x

The x coordinate of the origin, located at the bottom left corner.

Type:

float, optional

Default is `0.0`.
origin_y

The y coordinate of the origin, located at the bottom left corner.

Type:

float, optional

Default is `0.0`.
block_size_x

The grid block size in x dimension, used only for squared grids.

Type:

float, optional

Default is `10.0`.
block_size_y

The grid block size in y dimension, used only for squared grids.

Type:

float, optional

Default is `10.0`.
upper_right_x

The x coordinate of the upper right corner.

Type:

float, optional

Default is `0.0`.
upper_right_y

The y coordinate of the upper right corner.

Type:

float, optional

Default is `0.0`.
class Mesh1d(node_x, node_y, edge_nodes)

Bases: object

This class is used for getting and setting one-dimensional mesh data.

node_x

A 1D double array describing the x-coordinates of the nodes.

Type:

ndarray

node_y

A 1D double array describing the y-coordinates of the nodes.

Type:

ndarray

edge_nodes

A 1D integer array describing the nodes composing each mesh edge.

Type:

ndarray, optional

plot_edges(ax, *args, **kwargs)

Plots the edges at a given axes. args and kwargs will be used as parameters of the plot method of matplotlib.

Parameters:

ax (matplotlib.axes.Axes) – The axes where to plot the edges

remove_invalid_values(float_invalid_value: float)

Removes invalid values that might be present in the arrays.

Parameters:

float_invalid_value – (float): The float invalid value.

class Mesh2d(node_x=array([], dtype=float64), node_y=array([], dtype=float64), edge_nodes=array([], dtype=int32), face_nodes=array([], dtype=int32), nodes_per_face=array([], dtype=int32), edge_x=array([], dtype=float64), edge_y=array([], dtype=float64), face_x=array([], dtype=float64), face_y=array([], dtype=float64), edge_faces=array([], dtype=int32), face_edges=array([], dtype=int32))

Bases: object

This class is used for getting and setting two-dimensional mesh data.

node_x

A 1D double array describing the x-coordinates of the nodes.

Type:

ndarray

node_y

A 1D double array describing the y-coordinates of the nodes.

Type:

ndarray

edge_nodes

A 1D integer array describing the nodes composing each mesh 2d edge.

Type:

ndarray, optional

face_nodes

A 1D integer array describing the nodes composing each mesh 2d face.

Type:

ndarray, optional

nodes_per_face

A 1D integer array describing the nodes composing each mesh 2d face.

Type:

ndarray, optional

edge_x

A 1D double array describing x-coordinates of the mesh edges’ middle points.

Type:

ndarray, optional

edge_y

A 1D double array describing x-coordinates of the mesh edges’ middle points.

Type:

ndarray, optional

face_x

A 1D double array describing x-coordinates of the mesh faces’ mass centers.

Type:

ndarray, optional

face_y

A 1D double array describing y-coordinates of the mesh faces’ mass centers.

Type:

ndarray, optional

edge_faces

A 1D integer array describing for each edge the indices of the faces.

Type:

ndarray, optional

face_edges

A 1D integer array describing for each face the indices of the edges.

Type:

ndarray, optional

class Property(value)

Bases: IntEnum

Different properties on a 2D mesh.

EDGE_LENGTHS = 1
ORTHOGONALITY = 0
almost_equal(other: Mesh2d, rtol: float = 1e-05, atol: float = 1e-08) bool
Checks if the mesh is almost equal to another given relative and absolute tolerances.

This applies only to float arrays (node_x, node_y, face_x, faces_y, edge_x, and edge_y). The following must be satisfied for each float array: absolute(self.float_array - other.float_array) <= (atol + rtol * absolute(other.float_array)) Arrays containing indices and counts (face_edges, face_nodes, edge_faces, edge_nodes, nodes_per_face) must be exactly equal in both meshes.

Parameters:
  • other – (Mesh2d): The mesh to compare to.

  • rtol (float) – The relative tolerance. Default is1.0e-5.

  • atol (float) – The absolute tolerance. Default is 1.0e-8.

plot_edges(ax, *args, **kwargs)

Plots the edges at a given axes. args and kwargs will be used as parameters of the plot method of matplotlib.

Parameters:

ax (matplotlib.axes.Axes) – The axes where to plot the edges

plot_faces(ax, *args, **kwargs)

Plots the faces at a given axes. args and kwargs will be used as parameters of the plot method of matplotlib.

Parameters:

ax (matplotlib.axes.Axes) – The axes where to plot the faces

remove_invalid_values(float_invalid_value: float)

Removes invalid values that might be present in the arrays. Remove the corresponding entries in the others

Parameters:

float_invalid_value – (float): The float invalid value.

class Mesh2dLocation(value)

Bases: IntEnum

The Mesh2d location types.

EDGES = 2
FACES = 0
NODES = 1
class MeshRefinementParameters(refine_intersected=False, use_mass_center_when_refining=True, min_edge_size=0.5, refinement_type=RefinementType.REFINEMENT_LEVELS, connect_hanging_nodes=True, account_for_samples_outside_face=False, max_refinement_iterations=10, smoothing_iterations=5, max_courant_time=120.0, directional_refinement=False)

Bases: object

A class holding the parameters for Mesh2d refinement.

refine_intersected

Whether to compute faces intersected by polygon. Default is False.

Type:

bool

use_mass_center_when_refining

Whether to use the mass center when splitting a face in the refinement process. Default is True.

Type:

bool

min_edge_size

Minimum edge size. Default is 0.5.

Type:

float

refinement_type

Refinement criterion type. Default is RefinementType.REFINEMENT_LEVELS.

Type:

RefinementType

connect_hanging_nodes

Whether to connect hanging nodes at the end of the iteration. Default is True.

Type:

bool

account_for_samples_outside

Whether to take samples outside face into account. Default is False.

Type:

bool

max_refinement_iterations

Maximum number of refinement iterations. Default is 10.

Type:

int, optional

smoothing_iterations

The number of smoothing iterations. Default is 5.

Type:

int, optional

max_courant_time

Maximum courant time in seconds. Default is 120.

Type:

double, optional

directional_refinement

Directional refinement, cannot be used when the number of smoothing

Type:

bool, optional

iterations is larger than 0. Default is `False`.
class OrthogonalizationParameters(outer_iterations=2, boundary_iterations=25, inner_iterations=25, orthogonalization_to_smoothing_factor=0.975, orthogonalization_to_smoothing_factor_at_boundary=1.0, areal_to_angle_smoothing_factor=1.0)

Bases: object

A class holding the parameters for orthogonalization.

outer_iterations

Number of outer iterations in orthogonalization. Increase this parameter for complex grids. Default is 2.

Type:

int, optional

boundary_iterations

Number of boundary iterations in grid/net orthogonalization within itatp. Default is 25.

Type:

int, optional

inner_iterations

Number of inner iterations in grid/net orthogonalization within itbnd. Default is 25.

Type:

int, optional

orthogonalization_to_smoothing_factor

Factor from between grid smoothing (0) and grid orthogonality (1). Default is 0.975.

Type:

float, optional

orthogonalization_to_smoothing_factor_at_boundary

Minimum ATPF on the boundary. Default is 1.0.

Type:

float, optional

areal_to_angle_smoothing_factor

Factor between smoother 1d0 and area-homogenizer 0d0. Default is 1.0.

Type:

float, optional

class ProjectToLandBoundaryOption(value)

Bases: IntEnum

Option how to project to the land boundary.

DO_NOT_PROJECT_TO_LANDBOUNDARY = 0
INNER_AND_OUTER_MESH_BOUNDARY_TO_LANDBOUNDARY = 3
OUTER_MESH_BOUNDARY_TO_LANDBOUNDARY = 2
TO_ORIGINAL_NETBOUNDARY = 1
WHOLE_MESH = 4
class ProjectionType(value)

Bases: IntEnum

The projection types.

CARTESIAN = 0
SPHERICAL = 1
SPHERICALACCURATE = 2
class RefinementType(value)

Bases: IntEnum

Refinement type

REFINEMENT_LEVELS = 2

Refinement based on ridge detection.

RIDGE_DETECTION = 3
WAVE_COURANT = 1

Refinement that refines recursively a fixed number of times.

class SplinesToCurvilinearParameters(aspect_ratio=0.1, aspect_ratio_grow_factor=1.1, average_width=500.0, curvature_adapted_grid_spacing=1, grow_grid_outside=False, maximum_num_faces_in_uniform_part=5, nodes_on_top_of_each_other_tolerance=0.0001, min_cosine_crossing_angles=0.95, check_front_collisions=False, remove_skinny_triangles=True)

Bases: object

A class holding the additional parameters required for generating a curvilinear grid from splines using the advancing front method.

aspect_ratio

Aspect ratio. Default is 0.1.

Type:

float, optional

aspect_ratio_grow_factor

Grow factor of aspect ratio. Default is 1.1.

Type:

float, optional

average_width

Average mesh width on center spline. Default is 0.005.

Type:

float, optional

curvature_adapted_grid_spacing

Curvature adapted grid spacing. Default is 1.

Type:

int, optional

grow_grid_outside

Grow the grid outside the prescribed grid height. Default is 0.

Type:

int, optional

maximum_num_faces_in_uniform_part

Maximum number of layers in the uniform part Default is 5.

Type:

int, optional

nodes_on_top_of_each_other_tolerance

On-top-of-each-other tolerance.). Default is 0.0001.

Type:

float, optional

min_cosine_crossing_angles

Minimum allowed absolute value of crossing-angle cosine.

Type:

float, optional

Default is `0.95`.
check_front_collisions

Check for collisions with other parts of the front. Default is 0.

Type:

int, optional

remove_skinny_triangles

Check for collisions with other parts of the front. Default is 1.

Type:

int, optional