/meshplex

Compute Voronoi tesselations and everything else you need.

Primary LanguagePythonMIT LicenseMIT

meshplex

CircleCI codecov Code style: black PyPi Version GitHub stars

Compute all sorts of interesting points, areas, and volumes in triangular and tetrahedral meshes, with a focus on efficiency. Useful in many contexts, e.g., finite-element and finite-volume computations.

meshplex is used in optimesh and pyfvm.

Quickstart

import numpy
import meshplex

# create a simple MeshTri instance
points = numpy.array([[0.0, 0.0, 0.0], [1.0, 0.0, 0.0], [0.0, 1.0, 0.0]])
cells = numpy.array([[0, 1, 2]])
mesh = meshplex.MeshTri(points, cells)
# or read it from a file
# mesh = meshplex.read('pacman.msh')

# triangle volumes
print(mesh.cell_volumes)

# circumcenters, centroids, incenters
print(mesh.cell_circumcenters)
print(mesh.cell_centroids)
print(mesh.cell_incenters)

# circumradius, inradius, cell quality, angles
print(mesh.circumradius)
print(mesh.inradius)
print(mesh.cell_quality)  # d * inradius / circumradius (min 0, max 1)
print(mesh.angles)

# control volumes, centroids
print(mesh.control_volumes)
print(mesh.control_volume_centroids)

# covolume/edge length ratios
print(mesh.ce_ratios)

# flip edges until the mesh is Delaunay
mesh.flip_until_delaunay()

# show the mesh
mesh.show()

meshplex works much the same way with tetrahedral meshes.

(For mesh creation, check out this list).

Installation

meshplex is available from the Python Package Index, so simply type

pip3 install --user meshplex

to install.

Testing

To run the meshplex unit tests, check out this repository and type

pytest

Distribution

To create a new release

  1. bump the __version__ number,

  2. publish to PyPi and GitHub:

    make publish
    

License

meshplex is published under the MIT license.