Skip to main content

BlueMesh2D is a Python-based unstructured mesh-generator for two-dimensional polygonal geometries, providing a range of relatively simple, yet effective two-dimensional meshing algorithms.

Project description

BlueMesh2D logo

BlueMesh2D is the successor of PyMesh2D. The repository has been recreated under its new name as part of the BlueMath ecosystem. While the repository history has changed, the codebase and its development continue from the original project.

BlueMesh2D: Delaunay-based mesh generation in Python

BlueMesh2D is a Python-based unstructured mesh-generator for two-dimensional polygonal geometries, providing a range of relatively simple, yet effective two-dimensional meshing algorithms. BlueMesh2D includes variations on the "classical" Delaunay refinement technique, a new "Frontal"-Delaunay refinement scheme, a non-linear mesh optimisation method, and auxiliary mesh and geometry pre- and post-processing facilities.

This code is a translation of MESH2D, a MATLAB / OCTAVE-based tool developed by Darren Engwirda.

Algorithms implemented in BlueMesh2D are "probably-good" - ensuring convergence, geometrical and topological correctness, and providing guarantees on algorithm termination and worst-case element quality bounds. Support for user-defined "mesh-spacing" functions and "multi-part" geometry definitions is also provided, allowing BlueMesh2D to handle a wide range of complex domain types and user-defined constraints. BlueMesh2D typically generates very high-quality output, appropriate for a variety of finite-volume/element type applications.

BlueMesh2D is a simplified version of my JIGSAW mesh-generation algorithm (a C++ code). BlueMesh2D aims to provide a straightforward Python implementation of these Delaunay-based triangulation and mesh optimisation techniques.

Code Structure

BlueMesh2D is a pure Python package, consisting of a core library + associated utilities:

BlueMesh2D::
├── bluemesh2d              -- core BlueMesh2D library functions. See refine, smooth, tridemo etc.
├── bluemesh2d/aabb_tree    -- support for fast spatial indexing, via tree-based data-structures.
├── bluemesh2d/geom_util    -- geometry processing, repair, etc.
├── bluemesh2d/geomesh_util -- mesh management, export, interpolation, etc.
├── bluemesh2d/hfun_util    -- mesh-spacing definitions, limiters, etc.
├── bluemesh2d/hjac_util    -- solver for Hamilton-Jacobi eqn's.
├── bluemesh2d/mesh_ball    -- circumscribing balls, orthogonal balls etc.
├── bluemesh2d/mesh_cost    -- mesh cost/quality functions, etc.
├── bluemesh2d/mesh_file    -- mesh i/o via ASCII serialisation.
├── bluemesh2d/mesh_util    -- meshing/triangulation utility functions.
├── bluemesh2d/ortho_merge  -- mesh orthogonalisation & merging (Delft3D-FM).
├── bluemesh2d/poly_data    -- polygon definitions for demo problems, etc.
└── bluemesh2d/poly_test    -- fast inclusion test for polygons.

Quickstart

Installation

You can install bluemesh2d directly from PyPI:

pip install bluemesh2d

If you want to install it in developer mode (for local development and contribution):

pip install -e .

Examples

python -m bluemesh2d.tridemo  0; % a very simple example to get everything started.
python -m bluemesh2d.tridemo  1; % investigate the impact of the "radius-edge" threshold.
python -m bluemesh2d.tridemo  2; % Frontal-Delaunay vs. Delaunay-refinement refinement.
python -m bluemesh2d.tridemo  3; % explore impact of user-defined mesh-size constraints.
python -m bluemesh2d.tridemo  4; % explore impact of "hill-climbing" mesh optimisations.
python -m bluemesh2d.tridemo  5; % assemble triangulations for "multi-part" geometries.
python -m bluemesh2d.tridemo  6; % assemble triangulations with "internal" constraints.
python -m bluemesh2d.tridemo  7; % investigate the use of "quadtree"-type refinement.
python -m bluemesh2d.tridemo  8; % explore use of custom, user-defined mesh-size functions.
python -m bluemesh2d.tridemo  9; % larger-scale problem, mesh refinement + optimisation. 
python -m bluemesh2d.tridemo 10; % medium-scale problem, mesh refinement + optimisation. 

More examples available in BlueMath.

QGIS Plugin

A QGIS Processing plugin exposes the raster-to-mesh part of BlueMesh2D as a set of Processing algorithms, so a bathymetry-to-mesh workflow can be run without writing any Python. It bundles its own copy of bluemesh2d and covers:

  1. Extract water polygon from a bathymetry raster (coastline / domain extraction).
  2. Build element-size raster (hfun) — depth-polynomial, wavelength (Hunt 1979), or a custom Python sizing function, gradient-limited.
  3. Resample boundary to the element size, producing an editable boundary line layer.
  4. Generate mesh from boundary — Delaunay / Frontal-Delaunay refinement, optional smoothing and smood orthogonalization (Delft3D-FM).
  5. Generate boundary conditions — classify the mesh boundary into open / closed / island lines, editable directly in QGIS.
  6. Export — UGRID NetCDF (with or without Delft3D-FM open-boundary .pli/.bc/.ext files) or ADCIRC .grd.

Each stage's output is an ordinary QGIS layer (polygon, raster, or line), so intermediate results can be inspected and edited before the next step; an all-in-one algorithm is also available for a single-dialog run. See the plugin's own README (bluemesh2d_qgis/README.md) for installation and usage details.

Contact

For questions, bug reports, or feature requests, please open an issue on GitHub.

For direct contact:

Etienne
faugeree@unican.es

References

If you make use of BlueMesh2D please include a reference to the following! BlueMesh2D is a translation of MESH2D, designed to provide a simple and easy-to-understand implementation of Delaunay-based mesh-generation techniques. For a much more advanced and fully three-dimensional mesh-generation library, see the JIGSAW package. MESH2D makes use of the AABBTREE and FINDTRIA packages to compute efficient spatial queries and intersection tests.

[1] - Darren Engwirda, Locally-optimal Delaunay-refinement and optimisation-based mesh generation, Ph.D. Thesis, School of Mathematics and Statistics, The University of Sydney, September 2014.

[2] - Darren Engwirda, Unstructured mesh methods for the Navier-Stokes equations, Honours Thesis, School of Aerospace, Mechanical and Mechatronic Engineering, The University of Sydney, November 2005.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bluemesh2d-0.1.2.tar.gz (351.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bluemesh2d-0.1.2-py3-none-any.whl (343.2 kB view details)

Uploaded Python 3

File details

Details for the file bluemesh2d-0.1.2.tar.gz.

File metadata

  • Download URL: bluemesh2d-0.1.2.tar.gz
  • Upload date:
  • Size: 351.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for bluemesh2d-0.1.2.tar.gz
Algorithm Hash digest
SHA256 ca0e728596d4d58acea0504cb7cfefd47d32c16becb9833d2aef1d9d1a854bdd
MD5 c8b718d59f905f82e4a5721275212704
BLAKE2b-256 5e206af0597f95e6a2f07993310e676bfca4f1ec133c168a9066b1f68eaeea09

See more details on using hashes here.

Provenance

The following attestation bundles were made for bluemesh2d-0.1.2.tar.gz:

Publisher: build-package.yml on GeoOcean/BlueMesh2D

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file bluemesh2d-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: bluemesh2d-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 343.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for bluemesh2d-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c3f2b7d1dec6e2e1b4ec940372985a15ffe8588fdf5538ad6a45fe4212446cb1
MD5 ea69f16fae16f84f9baa2335e8b8d1f0
BLAKE2b-256 f14566e8c1d0f9d1d5512bbfe4383dcb29b40074472c3dc9d6297febc2b239cb

See more details on using hashes here.

Provenance

The following attestation bundles were made for bluemesh2d-0.1.2-py3-none-any.whl:

Publisher: build-package.yml on GeoOcean/BlueMesh2D

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page