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

Uploaded CPython 3.14

meshplex-0.21.5-cp313-none-any.whl (120.9 kB view details)

Uploaded CPython 3.13

meshplex-0.21.5-cp312-none-any.whl (120.9 kB view details)

Uploaded CPython 3.12

meshplex-0.21.5-cp311-none-any.whl (127.8 kB view details)

Uploaded CPython 3.11

meshplex-0.21.5-cp310-none-any.whl (55.3 kB view details)

Uploaded CPython 3.10

File details

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

File metadata

  • Download URL: meshplex-0.21.5-cp314-none-any.whl
  • Upload date:
  • Size: 128.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.5-cp314-none-any.whl
Algorithm Hash digest
SHA256 4d231f10b4b88d123493b9c515501e07a75c9cc24f4c39987bb49e07b132185f
MD5 0959d1511a9f3c5b918394671cf98125
BLAKE2b-256 1e6afd5a363659d3561b0ef0011755e1a54067fb88e3643181c27bab8876a27b

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: meshplex-0.21.5-cp313-none-any.whl
  • Upload date:
  • Size: 120.9 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.5-cp313-none-any.whl
Algorithm Hash digest
SHA256 d115a75c2fe46a9f41c520ce81dae886da8e480759589df2205e4fe4e70843f6
MD5 d01290eaafa48d180424bf64c5799f0d
BLAKE2b-256 f886ac98113110cb0ae11dcd86b9f1b7bdbacf6036e6bc421df8b8a603a34702

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: meshplex-0.21.5-cp312-none-any.whl
  • Upload date:
  • Size: 120.9 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.5-cp312-none-any.whl
Algorithm Hash digest
SHA256 8cc4e70746c8d1e1f42c48efb4a4b4edc5c0ca94cfce1443b4e11b6b2770c37d
MD5 fb236485ec029aab544b7990c1d358c2
BLAKE2b-256 c5cc74159de6b1b3f9851b9258227af7f500bf3df4781a72af61c9829d0235e9

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: meshplex-0.21.5-cp311-none-any.whl
  • Upload date:
  • Size: 127.8 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.5-cp311-none-any.whl
Algorithm Hash digest
SHA256 67aa822d3c1062733f617b79ed9ba83941bc38abca5135434bedee5a5172069f
MD5 1bd28c922d677ef16e4b41460d614ed0
BLAKE2b-256 72da955d2b02b93728bdc9467fc2bfea3e24119bfe1280dcb421eebb1daafb90

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: meshplex-0.21.5-cp310-none-any.whl
  • Upload date:
  • Size: 55.3 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.5-cp310-none-any.whl
Algorithm Hash digest
SHA256 dca9fea0b0e683e7e91ec2d07000162fefa212cbeff25d4175375efec3aac4db
MD5 ab62b797c9be34a881399c6434048770
BLAKE2b-256 563e8bce8ed16cf28ffae5e0db19a1720d9f5fa13e5d52c294770818a1996bb2

See more details on using hashes here.

Provenance

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