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

Uploaded CPython 3.14

meshplex-0.22.1-cp313-none-any.whl (145.3 kB view details)

Uploaded CPython 3.13

meshplex-0.22.1-cp312-none-any.whl (144.9 kB view details)

Uploaded CPython 3.12

meshplex-0.22.1-cp311-none-any.whl (150.4 kB view details)

Uploaded CPython 3.11

meshplex-0.22.1-cp310-none-any.whl (67.7 kB view details)

Uploaded CPython 3.10

File details

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

File metadata

  • Download URL: meshplex-0.22.1-cp314-none-any.whl
  • Upload date:
  • Size: 154.3 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.1-cp314-none-any.whl
Algorithm Hash digest
SHA256 a06d8142ba31a089eb10ba09dc58ea099205ef24b85e132eaa3affb86816a113
MD5 78ae5d1e317182fe721f360c55c5f7a1
BLAKE2b-256 eb039267480f3db447771727f6b30510f2fef317f3b2eb7006a84be1eaa2acf0

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: meshplex-0.22.1-cp313-none-any.whl
  • Upload date:
  • Size: 145.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.1-cp313-none-any.whl
Algorithm Hash digest
SHA256 d7bb457e427c867d6071a69023eebe6b04115afa864f628e78a0007553fec144
MD5 68397791d6424966ab0470fa48306557
BLAKE2b-256 5ef5dbbcfab4fcaac904dba21a6936a32993abd34acab6b29774a4e79719fbd8

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: meshplex-0.22.1-cp312-none-any.whl
  • Upload date:
  • Size: 144.9 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.1-cp312-none-any.whl
Algorithm Hash digest
SHA256 d5d93014a30e81a81f478ad170d5facf15796a915be7f45dcf8f7231d7fc2733
MD5 9cca4e9b8f6350cb5a19dd6d453a0ee8
BLAKE2b-256 ea7f422a48b8fbcecb8638d856ca099958338783505e9b9b9380b26e7435d510

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: meshplex-0.22.1-cp311-none-any.whl
  • Upload date:
  • Size: 150.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.1-cp311-none-any.whl
Algorithm Hash digest
SHA256 fbff8afb88f6d83bc9056786122a67cc07d1b2288c1b478845427ba9d3d1346c
MD5 0496957695e6acf560131585a63351ba
BLAKE2b-256 e3c2402ea179c1710cab56d85a8123584f791e248275c5afe6c9461b9c665266

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: meshplex-0.22.1-cp310-none-any.whl
  • Upload date:
  • Size: 67.7 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.1-cp310-none-any.whl
Algorithm Hash digest
SHA256 294fd0f3eac75aa5652f56aa78f35fd25091f3a40458eb21ee041f6da1eb5ba2
MD5 c79fc29eeb171795c10452b92a4bd25c
BLAKE2b-256 3bf77f6a1a170c6c9de750ba9823732ea048afb66a7268a9f9f9a2a1b6e2f6fc

See more details on using hashes here.

Provenance

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