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.21.14-cp314-none-any.whl (139.7 kB view details)

Uploaded CPython 3.14

meshplex-0.21.14-cp313-none-any.whl (131.7 kB view details)

Uploaded CPython 3.13

meshplex-0.21.14-cp312-none-any.whl (131.7 kB view details)

Uploaded CPython 3.12

meshplex-0.21.14-cp311-none-any.whl (136.4 kB view details)

Uploaded CPython 3.11

meshplex-0.21.14-cp310-none-any.whl (58.7 kB view details)

Uploaded CPython 3.10

File details

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

File metadata

  • Download URL: meshplex-0.21.14-cp314-none-any.whl
  • Upload date:
  • Size: 139.7 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.14-cp314-none-any.whl
Algorithm Hash digest
SHA256 83791ff1669ee0d7e67913e3de3d2d17d11afaf84b1f548bbc7a6ef94067d68f
MD5 bd22d55aaa688d406841ad397547934e
BLAKE2b-256 9599f3ebbf2c82569b638b4720963f08c1490bfee2e97d24a2c70fcde49a45de

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: meshplex-0.21.14-cp313-none-any.whl
  • Upload date:
  • Size: 131.7 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.14-cp313-none-any.whl
Algorithm Hash digest
SHA256 932772789771dda000f1b35f72af0d8323e15049f3c16b938564b309bb4f08d0
MD5 4c1607ad95ffb60bbdf087358ee5d9f0
BLAKE2b-256 92291067ea879767016e87ee39519157c9a813f89122bbe7f83ae30c5f3bde53

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: meshplex-0.21.14-cp312-none-any.whl
  • Upload date:
  • Size: 131.7 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.14-cp312-none-any.whl
Algorithm Hash digest
SHA256 8e9817f124ebe749fcbddbdf92346a4915d3c64e487e54926178aaf8816b2f67
MD5 ea0fa86908942081beac8e696ccdd6f4
BLAKE2b-256 2a83fe17c9b71cde40cbba61b95d2cb9eb502ab52a05e2d6dfed9bbde8651b90

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: meshplex-0.21.14-cp311-none-any.whl
  • Upload date:
  • Size: 136.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.14-cp311-none-any.whl
Algorithm Hash digest
SHA256 cc6f737decad7d650ef2acd06e45546cab202730fad61e01e7fc34f1d0a13e17
MD5 f5c673fde88e2a9bfd5f522ce0769663
BLAKE2b-256 6fc8fb8aa32a7d2637125540e38885208732c2c1c65dd6274aef9b581ed7c2d5

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: meshplex-0.21.14-cp310-none-any.whl
  • Upload date:
  • Size: 58.7 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.14-cp310-none-any.whl
Algorithm Hash digest
SHA256 c565d9c7444db230dd10a85f13f70f0771ea0456e95a7f480c83981c16933652
MD5 428a8b43c840d6aa1d615c505ed7ae19
BLAKE2b-256 059040ca9893b9c389c4b69bf3204a76b8054ac477e8ce58ab5024cd8e2604de

See more details on using hashes here.

Provenance

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