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.1-cp313-none-any.whl (121.0 kB view details)

Uploaded CPython 3.13

meshplex-0.21.1-cp312-none-any.whl (121.1 kB view details)

Uploaded CPython 3.12

meshplex-0.21.1-cp311-none-any.whl (127.7 kB view details)

Uploaded CPython 3.11

meshplex-0.21.1-cp310-none-any.whl (55.8 kB view details)

Uploaded CPython 3.10

File details

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

File metadata

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

File hashes

Hashes for meshplex-0.21.1-cp313-none-any.whl
Algorithm Hash digest
SHA256 21a0699e663086deb326787fac5446f1177eff9a412c7d7f2838f49773bc66f8
MD5 22b6546e2f653bddc09e83800bf543fc
BLAKE2b-256 69c6a6ae683323517dc0386544cea27d0a987f471b708179a285ad7f78e166b4

See more details on using hashes here.

Provenance

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

File metadata

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

File hashes

Hashes for meshplex-0.21.1-cp312-none-any.whl
Algorithm Hash digest
SHA256 7175be26132adcb91489279b37ebb37b4686639717b762050b4a4556637b7c41
MD5 f486da8fc8d2bfd52b38a6949e76606f
BLAKE2b-256 b1c8d82c77442163437a813e1fef7b8757603a539bae59fc812ea324a381ab16

See more details on using hashes here.

Provenance

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

File metadata

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

File hashes

Hashes for meshplex-0.21.1-cp311-none-any.whl
Algorithm Hash digest
SHA256 5d9a175fdee15c3e6c392c933f76f152f6bcb3cff50d3825ce9060a8fee16adc
MD5 e6d86040944b6cc549cbdcfe628826f1
BLAKE2b-256 2eb7b3d3202ad9288875394481d74234e5e3728d5a2b0617848d27ac698c2815

See more details on using hashes here.

Provenance

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

File metadata

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

File hashes

Hashes for meshplex-0.21.1-cp310-none-any.whl
Algorithm Hash digest
SHA256 7a76aaf00809b169eb3e773159fb995e9f3a1f59621f15e304186252806c5179
MD5 1b0d2b2e15657d00ed04dc945d303cd8
BLAKE2b-256 4cfe38587e4ae3fa13c796ff79f72753c36e9d8dece41b8ea6bf6315cbbe8b8d

See more details on using hashes here.

Provenance

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