Skip to main content

lsmesh

The lsmesh distribution provides the lsmesher Python package. It converts 2D and 3D ViennaLS/ViennaPS interface files into polygonal and volume meshes and includes a command-line interface and a Streamlit/PyVista viewer with runnable example presets.

Run with Nix

Launch the viewer from the repository root:

nix run .

Then open http://localhost:8501.

Run the CLI through the flake:

nix run .#cli -- --help
nix run .#cli -- mesh interface_0.vtp -o mesh.vtp

The flake also provides a development shell with Python build and native mesh dependencies:

nix develop
uv sync --frozen
uv run pytest

Direct commands

Inside nix develop, the project entry points are:

uv run lsmesher --help
uv run lsmesher-viewer

For a library-only installation, viewer dependencies are optional:

uv add lsmesh
uv add "lsmesh[viewer]"  # only when the Streamlit viewer is needed

Python API and ViennaPS

mesh() accepts a live ViennaPS domain, extracts its ordered level sets in memory, validates the generated geometry, runs Triangle or TetGen, and writes the requested result:

import viennaps as vps

from lsmesher import mesh

vps.setDimension(3)
domain = vps.Domain()
vps.MakeTrench(
    domain,
    gridDelta=0.25,
    xExtent=20.0,
    yExtent=20.0,
    trenchWidth=6.0,
    trenchDepth=5.0,
).apply()

# Apply ViennaPS processes here, then create a material-resolved volume mesh.
result = mesh(
    domain,
    "device.vtu",
)

print(result.mesh)
print(result.materials)
print(result.automatic)
print(result.quality)
print(result.validation.issues if result.validation else ())
print(result.log_path)

The SDK infers the dimension and uses the ViennaPS grid spacing to choose surface and volume resolution. It validates material coverage and element quality and performs bounded safer retries when necessary. Use policy="fast" or policy="accurate" to express a different goal; explicit MeshingOptions remain available as the expert override. See automatic meshing for the policy and recovery contract.

For live domains, Triangle/TetGen and the resulting VTU use ViennaPS material IDs directly, so disconnected or repeated layers of the same material share one ID. result.materials retains the corresponding level-set order and names.

Lower-level workflows can use build_from_viennaps(), build_from_files(), validate(), and write() independently. Material-region sampling can be made reproducible with BuildOptions(random_seed=42). Mesher failures raise TriangleError or TetGenError and retain the command, captured output, return code, and log path.

For exported VTP interfaces, pass the paths directly to mesh() or build_from_files(), ordered from the lowest/innermost level set to the topmost one.

Viewer presets

The viewer discovers examples under viewer_presets/. Set LSMESHER_PRESETS_DIR to use another preset directory. It can also load local or uploaded .vtp, .vtu, .vtk, and .off files.

Presets are ordinary ViennaPS scripts that finish with run_preset(domain, dimension=...). The live domain is meshed through the SDK in an isolated subprocess, preserving ViennaPS material identities without exporting intermediate interfaces. See SDK viewer presets for the three-file preset layout and a minimal example.

Metadata

Release files for lsmesh 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lsmesh 0.1.0
File Size Uploaded Provenance Actions
lsmesh-0.1.0.tar.gz 218.5 kB Without provenance Details for lsmesh-0.1.0.tar.gz

Release files / lsmesh-0.1.0.tar.gz

Download URL lsmesh-0.1.0.tar.gz
Size 218.5 kB
Tags Source
SHA-256 checksum
How to use checksums
8bd393b4534a3e73e9d5cef28dfe0ac8358bfece7e1e452214f3f9fda5ba80e0
BLAKE2b-256 checksum
How to use checksums
38a96e7aaf815137293d733f961ae8bb561e772b8d11efdbf6d9d97a287fe7f7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.11.30 {"installer":{"name":"uv","version":"0.11.30","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for lsmesh 0.1.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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page