Skip to main content

A Python implemenetation of the distmesh algorithm

Project description

DistMeshPy

DistMeshPy is a Python implementation of the DistMesh algorithm based on the original MATLAB implementation.

Features

  • Generate 2D, 3D, and surface meshes with a simple interface.
  • Flexible distance functions for custom geometries.
  • Robust mesh size control through a size function.
  • Backend utility compiled via C++ code.

Installation

pip install distmeshpy

Note: A working C++11 order higher compiler is required.

Usage

Here's a quick example of how to generate a 2D mesh:

from distmeshpy import distmesh2d
from distmeshpy.utils import dcircle, huniform

p, t = distmesh2d(
    lambda p: dcircle(p, 0.0, 0.0, 1.0),  # Distance function
    huniform,  # Uniform size function
    0.2,  # Initial edge size
    ((-1.1, 1.1), (-1.1, 1.1)),  # Bounding box
)

and the mesh can be plotted via matplotlib:

import matplotlib.pyplot as plt
fig, ax = plt.subplots()
ax.triplot(p[:, 0], p[:, 1], t)
ax.set_aspect("equal")
plt.show()

For more examples, see the examples directory.

Contributing

Contributions are welcome! Please fork the repository, create a feature branch, and submit a pull request.

License

Following the original work, this project is licensed under the GNU General Public License. See the LICENSE file for details.

Acknowledgments

DistMeshPy is inspired by the original MATLAB DistMesh implementation by Per-Olof Persson and Gilbert Strang.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

distmeshpy-1.1.0.tar.gz (231.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

distmeshpy-1.1.0-cp39-cp39-macosx_11_0_arm64.whl (229.7 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

File details

Details for the file distmeshpy-1.1.0.tar.gz.

File metadata

  • Download URL: distmeshpy-1.1.0.tar.gz
  • Upload date:
  • Size: 231.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.21

File hashes

Hashes for distmeshpy-1.1.0.tar.gz
Algorithm Hash digest
SHA256 7c8ce66e8f09dae529ee710d20be6d79895955bd46608f284f9ee430ef80fe00
MD5 83e50f1d430f568a1cb72f7bf8840464
BLAKE2b-256 b39ae955ed054b33afc08200aac12ff4e1c886067b13ad264e50e3d04cb0f09a

See more details on using hashes here.

File details

Details for the file distmeshpy-1.1.0-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for distmeshpy-1.1.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a9f9d61686b9902c4e775e2956a4d06d5284af202ba74580a922e40d1b855ea0
MD5 749dbad8e65d40a24ea2d5792b1aba8b
BLAKE2b-256 d043aa9f5e2e25c6447ebf297b1823ca7e71831a807747a98e8a81505be1da8c

See more details on using hashes here.

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