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
# (could be tetrahedra or even higher dimensional simplices)
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)

# centers of any kind
print(mesh.cell_circumcenters)
print(mesh.cell_centroids)
print(mesh.cell_incenters)
print(mesh.cell_monge_points)
print(mesh.cell_nagel_points)
print(mesh.cell_spieker_centers)
print(mesh.cell_lemoine_points)
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.22.4-cp314-none-any.whl (162.6 kB view details)

Uploaded CPython 3.14

meshplex-0.22.4-cp313-none-any.whl (153.3 kB view details)

Uploaded CPython 3.13

meshplex-0.22.4-cp312-none-any.whl (152.8 kB view details)

Uploaded CPython 3.12

meshplex-0.22.4-cp311-none-any.whl (157.4 kB view details)

Uploaded CPython 3.11

meshplex-0.22.4-cp310-none-any.whl (70.6 kB view details)

Uploaded CPython 3.10

File details

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

File metadata

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

File hashes

Hashes for meshplex-0.22.4-cp314-none-any.whl
Algorithm Hash digest
SHA256 94d98b5f29f020de9e1caca25724624400bc1690da2a995f8ced0e279a37d9a3
MD5 27562eac3549a509661566ca8da5dbeb
BLAKE2b-256 69e256bec1b198402778393122ade2e1a7a70668d7c5b50f999476a6fcbc2f39

See more details on using hashes here.

Provenance

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

File metadata

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

File hashes

Hashes for meshplex-0.22.4-cp313-none-any.whl
Algorithm Hash digest
SHA256 7f9f933054eb4ba7657d41ce2fe141c2e1f75a89cf75750330eb0d28891a200f
MD5 af70035414d29f180875772f31a0cf6c
BLAKE2b-256 2261d6043d72ef7e63091f4e2a3235c136ee6e944a083afd9132f0a87bcc761c

See more details on using hashes here.

Provenance

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

File metadata

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

File hashes

Hashes for meshplex-0.22.4-cp312-none-any.whl
Algorithm Hash digest
SHA256 9bc4247882c740e31f3224a7754d15803d85599f26b09c7df6293ae6f05630a9
MD5 81e09973a25946d1b61f22f96ec5291a
BLAKE2b-256 05fe15ad07548f29f5dd23ea0d8f92f71ff330183be9b129d2d28366978a2d51

See more details on using hashes here.

Provenance

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

File metadata

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

File hashes

Hashes for meshplex-0.22.4-cp311-none-any.whl
Algorithm Hash digest
SHA256 56b34a20effe553a7c55aabb6e2f2ebb0fac9b55ea353d2b0b960995c1d44870
MD5 91141432284dff62602962c5037ca382
BLAKE2b-256 780d19960e1a4b7a5dd4daa2d48a2770f1dd8aa534f42d1fe42c6c78238b57f6

See more details on using hashes here.

Provenance

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

File metadata

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

File hashes

Hashes for meshplex-0.22.4-cp310-none-any.whl
Algorithm Hash digest
SHA256 cd15b8a801455be49a8cf2bb11f5b7416af2322289920bfca7779a3e3d38f62d
MD5 baf9d1d73055298bdacf6d62023d4303
BLAKE2b-256 eb924931298fd2761340b3f6aa4d851b0e52498aad597927339c42307eda520e

See more details on using hashes here.

Provenance

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