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.

Download files

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

Source Distribution

lsmesh-0.1.0.tar.gz (218.5 kB view details)

Uploaded Source

File details

Details for the file lsmesh-0.1.0.tar.gz.

File metadata

  • Download URL: lsmesh-0.1.0.tar.gz
  • Upload date:
  • Size: 218.5 kB
  • Tags: Source
  • Uploaded using 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}

File hashes

Hashes for lsmesh-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8bd393b4534a3e73e9d5cef28dfe0ac8358bfece7e1e452214f3f9fda5ba80e0
MD5 248e28f81e803fce1cc8a2e206cd7184
BLAKE2b-256 38a96e7aaf815137293d733f961ae8bb561e772b8d11efdbf6d9d97a287fe7f7

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.0 This release

1 file

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