Skip to main content

Fast tools for simplex meshes

Project description

meshplex

Fast tools for simplex meshes.

PyPi Version PyPI pyversions GitHub stars PyPi downloads

Compute all sorts of interesting points, areas, and volumes in simplex (triangle, tetrahedral, n-simplex) meshes of any dimension, with a focus on efficiency. Useful in many contexts, e.g., finite-element and finite-volume computations.

Installation

Install meshplex from PyPI with

pip install meshplex

For full usage of meshplex, you require a license. Licenses for personal and academic use can be purchased here. For more info, see here.

Quickstart

meshplex can compute the following data:

import meshplex

# create a simple Mesh instance
points = [[0.0, 0.0], [1.0, 0.0], [0.0, 1.0]]
cells = [[0, 1, 2]]
mesh = meshplex.Mesh(points, cells)
# or read it from a file
# mesh = meshplex.read("pacman.vtk")

# simplex volumes, heights
print(mesh.cell_volumes)
print(mesh.signed_cell_volumes)
print(mesh.cell_heights)
print(mesh.volume)
print(mesh.surface_area)

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

# circumradius, inradius, cell quality
print(mesh.cell_circumradius)
print(mesh.cell_inradius)
print(mesh.q_radius_ratio)  # d * inradius / circumradius (min 0, max 1)

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

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

# count Delaunay violations
print(mesh.num_delaunay_violations)

# get all boundary angles in radians
print(mesh.outside_boundary_angles_radians)

# removes some cells
mesh.remove_cells([0])

For triangular meshes (MeshTri), meshplex also has some mesh manipulation routines:

mesh.show()  # show the mesh
mesh.angles  # compute angles
mesh.flip_until_delaunay()  # flips edges until the mesh is Delaunay

For a documentation of all classes and functions, see readthedocs.

(For mesh creation, check out this list).

Plotting

Triangles

import meshplex

mesh = meshplex.read("pacman.vtk")
mesh.show(
    # show_coedges=True,
    # control_volume_centroid_color=None,
    # mesh_color="k",
    # nondelaunay_edge_color=None,
    # boundary_edge_color=None,
    # comesh_color=(0.8, 0.8, 0.8),
    show_axes=False,
)

Tetrahedra

import numpy as np
import meshplex

# Generate tetrahedron
points = np.array(
    [
        [1.0, 0.0, -1.0 / np.sqrt(8)],
        [-0.5, +np.sqrt(3.0) / 2.0, -1.0 / np.sqrt(8)],
        [-0.5, -np.sqrt(3.0) / 2.0, -1.0 / np.sqrt(8)],
        [0.0, 0.0, np.sqrt(2.0) - 1.0 / np.sqrt(8)],
    ]
) / np.sqrt(3.0)
cells = [[0, 1, 2, 3]]

# Create mesh object
mesh = meshplex.MeshTetra(points, cells)

# Plot cell 0 with control volume boundaries
mesh.show_cell(
    0,
    # barycenter_rgba=(1, 0, 0, 1.0),
    # circumcenter_rgba=(0.1, 0.1, 0.1, 1.0),
    # circumsphere_rgba=(0, 1, 0, 1.0),
    # incenter_rgba=(1, 0, 1, 1.0),
    # insphere_rgba=(1, 0, 1, 1.0),
    # face_circumcenter_rgba=(0, 0, 1, 1.0),
    control_volume_boundaries_rgba=(1.0, 0.0, 0.0, 1.0),
    line_width=3.0,
)

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

meshplex-0.21.7-cp314-none-any.whl (130.3 kB view details)

Uploaded CPython 3.14

meshplex-0.21.7-cp313-none-any.whl (122.4 kB view details)

Uploaded CPython 3.13

meshplex-0.21.7-cp312-none-any.whl (122.4 kB view details)

Uploaded CPython 3.12

meshplex-0.21.7-cp311-none-any.whl (129.4 kB view details)

Uploaded CPython 3.11

meshplex-0.21.7-cp310-none-any.whl (56.0 kB view details)

Uploaded CPython 3.10

File details

Details for the file meshplex-0.21.7-cp314-none-any.whl.

File metadata

  • Download URL: meshplex-0.21.7-cp314-none-any.whl
  • Upload date:
  • Size: 130.3 kB
  • Tags: CPython 3.14
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for meshplex-0.21.7-cp314-none-any.whl
Algorithm Hash digest
SHA256 fd72b37e3adf31dba3c62114d1b6a3233f31095aedc1ae3fa0b7878ede87b998
MD5 960ca9c2b3feedf48dbe679e89ccb475
BLAKE2b-256 0688b609babf04b7351f11718c9b2e7c1a68b69263dea538e0dc3e6f0bb4a305

See more details on using hashes here.

Provenance

The following attestation bundles were made for meshplex-0.21.7-cp314-none-any.whl:

Publisher: release.yml on meshpro/meshplex-dev

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

File details

Details for the file meshplex-0.21.7-cp313-none-any.whl.

File metadata

  • Download URL: meshplex-0.21.7-cp313-none-any.whl
  • Upload date:
  • Size: 122.4 kB
  • Tags: CPython 3.13
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for meshplex-0.21.7-cp313-none-any.whl
Algorithm Hash digest
SHA256 15723a856caaeb7e876fa79516f0df0202d649f16d96397a0868d769d614fecc
MD5 30f815f09cca925e94db97df38438af9
BLAKE2b-256 6b84fad755570bf228a1f99957083244518615066311c96f3ffea135c456ae0e

See more details on using hashes here.

Provenance

The following attestation bundles were made for meshplex-0.21.7-cp313-none-any.whl:

Publisher: release.yml on meshpro/meshplex-dev

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

File details

Details for the file meshplex-0.21.7-cp312-none-any.whl.

File metadata

  • Download URL: meshplex-0.21.7-cp312-none-any.whl
  • Upload date:
  • Size: 122.4 kB
  • Tags: CPython 3.12
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for meshplex-0.21.7-cp312-none-any.whl
Algorithm Hash digest
SHA256 4019719d937daf0af29eac76a4689545cf0c67c7eeb9cd28ceadd16b5409b62a
MD5 1f0e98ecdcd4244bc44b51ab64106db4
BLAKE2b-256 8b72563ea48e55d0e20d988082631522c9bc7ebc89d97f055ab086b52d7a1b31

See more details on using hashes here.

Provenance

The following attestation bundles were made for meshplex-0.21.7-cp312-none-any.whl:

Publisher: release.yml on meshpro/meshplex-dev

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

File details

Details for the file meshplex-0.21.7-cp311-none-any.whl.

File metadata

  • Download URL: meshplex-0.21.7-cp311-none-any.whl
  • Upload date:
  • Size: 129.4 kB
  • Tags: CPython 3.11
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for meshplex-0.21.7-cp311-none-any.whl
Algorithm Hash digest
SHA256 5f5162291e64047b308dc643abe575c0ae79b6386371d3399a3ec30927eaa782
MD5 445245d4a1dd5d02a652387957df1ef8
BLAKE2b-256 ef0055918a71185ab41d514d0e18f04a31e58ec6dbf51a293342f3d8bc1ac8fc

See more details on using hashes here.

Provenance

The following attestation bundles were made for meshplex-0.21.7-cp311-none-any.whl:

Publisher: release.yml on meshpro/meshplex-dev

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

File details

Details for the file meshplex-0.21.7-cp310-none-any.whl.

File metadata

  • Download URL: meshplex-0.21.7-cp310-none-any.whl
  • Upload date:
  • Size: 56.0 kB
  • Tags: CPython 3.10
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for meshplex-0.21.7-cp310-none-any.whl
Algorithm Hash digest
SHA256 2aceb7b1eea6c3850bb1bea881684ca6d052e0c4faadc051f7482361c60b7057
MD5 4f60f30c40c3e92cdec88f4bb6ce4554
BLAKE2b-256 dd125233cba745ef1989b0b665712fa8ab68b5fd20ad15bda7fde09e38bd1f3b

See more details on using hashes here.

Provenance

The following attestation bundles were made for meshplex-0.21.7-cp310-none-any.whl:

Publisher: release.yml on meshpro/meshplex-dev

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