from shapely import Point, box
from refined_quads import generate
quad_mesh = generate(
box(155_000, 463_000, 155_640, 463_480),
cell_size=32.0,
refinement_areas=[(Point(155_250, 463_240).buffer(70), 3)],
transition_rows=[1, 1, 1],
crs="EPSG:28992",
)refined-quads
refined-quads generates and refines refined quad meshes for D-Flow FM: axis-aligned squares on a fixed lattice, locally refined by repeated halving, with transition cells only where refinement levels meet.
mesh next to D-HyDAMO
D-HyDAMO scripts usually import from hydrolib.dhydamo.geometry import mesh (the module with mesh2d_clip, links1d2d_add_links_1d_to_2d and so on). mesh = generate(...) replaces that module, and the next mesh.<function>(...) fails with an AttributeError. That is why the examples use quad_mesh.
The package is under construction. The API described here is not stable yet.
What it does
- Generate a mesh over a domain with refinement areas, transition rows and water areas, in Python or from a TOML file on the command line.
- Refine an existing mesh, also one made by another program, with new refinement areas. The original input is not needed, and cells that do not change stay exactly as they are.
- Check a mesh for hanging nodes, 2:1 balance and FM orthogonality.
- Read and write the UGRID net files that D-HYDRO and D-Flow FM use.
Install
Install the package from PyPI:
pip install refined-quadsOr, in a uv project, use uv add refined-quads.
Its dependencies (numpy, shapely, netCDF4, pyogrio, pyproj and meshkernel) all come as wheels; no separate GDAL installation is needed. On macOS the meshkernel wheel needs OpenMP from Homebrew (brew install libomp); the package runs on Windows and Linux.
Where to go next
- Your first mesh walks through generating, checking and writing a mesh.
- The how-to guides cover GIS layers, TOML files and the command line, water areas, refining and D-HYDRO.
- The explanation pages describe the concepts.
- The API reference documents every public function.