HydroMesh#
- class hydromodpy.spatial.HydroMesh(vertices, cell_blocks, cell_data=<factory>, point_data=<factory>, structured_shape=None)[source]#
Bases:
objectUnified mesh pivot for structured and unstructured grids.
Parameters#
- verticesndarray, shape (n_nodes, 2) or (n_nodes, 3)
Node coordinates. 2-column for planar meshes, 3-column for 3D.
- cell_blockstuple of CellBlock
One or more homogeneous connectivity blocks.
- cell_datadict[str, ndarray]
Per-cell scalar fields. Each value has shape
(total_n_cells,).- point_datadict[str, ndarray]
Per-point scalar fields. Each value has shape
(n_nodes,).- structured_shapetuple of int, optional
(nrow, ncol)for 2D structured grids,(nlay, nrow, ncol)for 3D. When set, signals that the vertices follow a regular grid layout and enables optimized adapters (e.g. flopy DIS).
- param vertices:
- type vertices:
- param cell_blocks:
- type cell_blocks:
- param cell_data:
- type cell_data:
- param point_data:
- type point_data:
- param structured_shape:
- type structured_shape:
- property flat_connectivity: ndarray | tuple[ndarray, ...]#
Connectivity across all blocks as a per-cell sequence.
Returns a rectangular
(n_cells, k)array for a single fixed-size block (the common case), or a tuple of 1D arrays for a raggedPOLYGONblock. Either way it is indexable per cell (conn[ic]) and haslen(conn) == n_cells, which is all the DISV adapter needs. Mixing ragged and rectangular blocks is not supported here.
- cell_centroids()[source]#
Per-cell
(x, y)centers, matching the field-mesh signature.Returns the explicit
cell_data["disv_cell_center"](the generator seeds, exact for a Voronoi/PEBI DISV) when present, otherwise the per-cell vertex mean. Ragged-safe (handlesPOLYGONblocks).
- with_cell_data(**fields)[source]#
Return a new mesh with validated per-cell arrays added.
The method preserves immutability of the original mesh and therefore behaves as a light builder around the frozen dataclass.