biomesh
🚀 Installation
biomesh can be installed via pip as
pip install biomesh
If you want to generate a mesh with Gmsh, you also need to install the gmsh python library as
pip install gmsh
📖 Usage
biomesh is composed of multiple utilities for working with complex biomechanical geometries. Below
are some common workflows
Generate a mesh from colored STL files
Colored STL-files (e.g., exported from Materialise 3-matic) can be used to generate a volume mesh.
Although STL color encoding is not standardized, some software packages embed surface IDs in unused
byte fields. biomesh leverages this to extract surface information.
👉 Generating a mesh from stl-files requires the gmsh Python package.
import biomesh
mesh = biomesh.mesh_colored_stl_files(
"path/to/part1.stl",
"path/to/part2.stl",
"path/to/part3.stl",
mesh_size=2.0
)
Alternatively, you can load the meshes from any format supported by meshio:
import meshio
meshio.read("path/to/mesh.vtu")
Convert linear to quadratic elements
Convert linear elements in your mesh to quadratic ones:
mesh = biomesh.lin_to_quad(mesh)
Reorder mesh nodes
Finite element solvers often benefit from reducing bandwidth in the system matrix. biomesh provides
a node reordering algorithm based on Cuthill-McKee's algorithm to improve efficiency:
mesh = biomesh.reorder(mesh)
Merge multiple meshes
Combine several meshes into a single mesh object:
mesh_all = biomesh.merge(mesh1, mesh2, mesh3)
⚠️ Overlapping points are not automatically merged.
Filter a mesh
Extract a subset of a mesh using flexible filters. For example, filtering by cell type:
# keep only hexahedral cells
filter_hex = lambda block : block.type == 'hexahedron'
mesh_filtered = biomesh.filter.by_cellblock(mesh, filter_hex)
# Get point mapping from old -> new IDs
point_mapping = biomesh.filter.points_map_by_cellblock(mesh, filter_hex)
Solve simple Laplace problem
biomesh can also solve basic Laplace problems, commonly used to estimate fiber directions with
rule based methods.
dbc_nodes = np.array([0, 1, 2, 4])
dbc_values = np.array([0.0, 0.0, 1.0, 1.0])
phi = biomesh.solve(mesh, dbc_nodes, dbc_values)
# or equivalently
phi = biomesh.solve_onezero(mesh, np.array([2, 4]), np.array([0, 1]))
The result phi is the solution vector of the Laplace problem.
Finite Element Utilities
biomesh.fe provides helper functions for finite element analysis. For example, compute the nodal
averaged gradient of a scalar field:
grad_phi = biomesh.fe.grad(mesh, phi)
Metadata
Release files for biomesh 0.6.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| biomesh-0.6.0.tar.gz | 101.4 kB | Without provenance | Details for biomesh-0.6.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| biomesh-0.6.0-py3-none-any.whl | Python 3 | none | any | Details for biomesh-0.6.0-py3-none-any.whl |
Total release size: 120.8 kB
Release files / biomesh-0.6.0.tar.gz
| Download URL | biomesh-0.6.0.tar.gz |
|---|---|
| Size | 101.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
781108c98aadde24dd0ca81f79592a86c3c435a6ab28b62ae4e41b40f4781ac1
|
|
BLAKE2b-256 checksum How to use checksums |
cd1b4f1c0ed7fc23106924f6bde0d58b1df9d2cbdb50c1bc61aaa60c77e5f5e0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.9.23
|
Release files / biomesh-0.6.0-py3-none-any.whl
| Download URL | biomesh-0.6.0-py3-none-any.whl |
|---|---|
| Size | 19.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c0539330bcff29657297247a634ffbd4e231272b1239273726d96498f34effd0
|
|
BLAKE2b-256 checksum How to use checksums |
26a361fd39cea047a1a4c5237d891c0bba1a93fdfaa30af29a3652d22188734d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.9.23
|
Security for biomesh 0.6.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.