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

Discord

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")

# triangle volumes, heights
print(mesh.cell_volumes)
print(mesh.signed_cell_volumes)
print(mesh.cell_heights)

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

# 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.3-cp314-none-any.whl (128.3 kB view details)

Uploaded CPython 3.14

meshplex-0.21.3-cp313-none-any.whl (120.5 kB view details)

Uploaded CPython 3.13

meshplex-0.21.3-cp312-none-any.whl (120.6 kB view details)

Uploaded CPython 3.12

meshplex-0.21.3-cp311-none-any.whl (127.2 kB view details)

Uploaded CPython 3.11

meshplex-0.21.3-cp310-none-any.whl (55.2 kB view details)

Uploaded CPython 3.10

File details

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

File metadata

  • Download URL: meshplex-0.21.3-cp314-none-any.whl
  • Upload date:
  • Size: 128.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.3-cp314-none-any.whl
Algorithm Hash digest
SHA256 3e6c8934c2b7f456ef4833679a58bea1d8e0b4002461dcb04740fb15df98a93a
MD5 ded9e731691d657b33f0993d21f8e3ff
BLAKE2b-256 ff157e9485b64e0a95d07a422b985672d6490989b8e57254f245f6572b330dbd

See more details on using hashes here.

Provenance

The following attestation bundles were made for meshplex-0.21.3-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.3-cp313-none-any.whl.

File metadata

  • Download URL: meshplex-0.21.3-cp313-none-any.whl
  • Upload date:
  • Size: 120.5 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.3-cp313-none-any.whl
Algorithm Hash digest
SHA256 0bb0ecf83e146c7d6e43feeab6b0e1b3c46a3b618564822f324d0a79b9239154
MD5 13ff8d0b87ac19e3a3a8a25ec947cb67
BLAKE2b-256 43910167063d275cbb4a1a383aed927a96fd5654731a3c58a54b61437d0e9717

See more details on using hashes here.

Provenance

The following attestation bundles were made for meshplex-0.21.3-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.3-cp312-none-any.whl.

File metadata

  • Download URL: meshplex-0.21.3-cp312-none-any.whl
  • Upload date:
  • Size: 120.6 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.3-cp312-none-any.whl
Algorithm Hash digest
SHA256 1e102cdd6b2b0faf05d787e309a508bf01598e5e21e25efa9f734f41adb88aaf
MD5 01e9a40a7f0f1ff03ef8c8e1c6bd7ffd
BLAKE2b-256 cb71e2d34f5b96b54ba0e3063b3d7e28169e0692b89b044d2ae5b1de765557a0

See more details on using hashes here.

Provenance

The following attestation bundles were made for meshplex-0.21.3-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.3-cp311-none-any.whl.

File metadata

  • Download URL: meshplex-0.21.3-cp311-none-any.whl
  • Upload date:
  • Size: 127.2 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.3-cp311-none-any.whl
Algorithm Hash digest
SHA256 f8a3ef8bd925587194e5c0aa22a1cdca3ef4dc46cadbc214dec8a58a44191877
MD5 ac0e1196d6c968989d65ee8c95ed1686
BLAKE2b-256 64db8c50ee4b1eca220e07dedb883582f2341aaebc0b79a6bb91e1f993b79863

See more details on using hashes here.

Provenance

The following attestation bundles were made for meshplex-0.21.3-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.3-cp310-none-any.whl.

File metadata

  • Download URL: meshplex-0.21.3-cp310-none-any.whl
  • Upload date:
  • Size: 55.2 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.3-cp310-none-any.whl
Algorithm Hash digest
SHA256 64b5a769515e3b0e96e370645038c9672fcc5ea599c896ea58404b1f84ef3a08
MD5 0cfdb08583ceb95c84c56ae87dd98aa4
BLAKE2b-256 d3bbd09d478d7b4194bb65a6396169ddcd75db1b64b18589dd7e443215823b13

See more details on using hashes here.

Provenance

The following attestation bundles were made for meshplex-0.21.3-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