Skip to main content

Python bindings for splashsurf, a surface reconstruction library for SPH simulations.

Project description

pySplashsurf

splashsurf logo

PyPI - Version PyPI - Python Version

pySplashsurf provides Python bindings for splashsurf, an open source surface reconstruction library for particle data from SPH simulations. Detailed information on the surface reconstruction and library itself and its API can be found on the project website (splashsurf.physics-simulation.org) or the main repository.

Installation

Requires Python version 3.10+

pip install pysplashsurf

To install pysplashsurf with meshio support (which adds some additional IO functionality), use

pip install pysplashsurf[meshio]

This will add support for the .bgeo file extension to meshio, so that particle data in the BGEOV format can be read using meshio. Meshio is also required for the write_to_file method from the bindings to work. The rest of the package, including the CLI, will still work even if meshio is not installed.

Usage

pySplashsurf can either be used as a library in Python scripts or as a command line tool that provides the same interface as the original Rust splashsurf CLI itself.

CLI

To use the CLI, you can use the pysplashsurf command after installing the package:

pysplashsurf --help

For example, to reconstruct a surface from particle data in a VTK file with some smoothing:

splashsurf reconstruct particles.vtk -r=0.025 -l=2.0 -c=0.5 -t=0.6 --mesh-smoothing-weights=on --mesh-smoothing-iters=15 --normals=on --normals-smoothing-iters=10

For more information on the CLI and its arguments, refer to the splashsurf documentation.

Library

Example to reconstruct the surface from an input file, apply some post-processing methods and write the data back to a file:

import meshio
import numpy as np
import pysplashsurf

# Load particles from mesh file
mesh = meshio.read("input.vtk")
particles = np.array(mesh.points, dtype=np.float64)

# Reconstruct the points/particles with some post-processing
mesh_with_data, reconstruction = pysplashsurf.reconstruction_pipeline(
    particles,
    particle_radius=0.025,
    rest_density=1000.0,
    smoothing_length=2.0,
    cube_size=0.5,
    iso_surface_threshold=0.6,
    mesh_smoothing_weights=True,
    mesh_smoothing_weights_normalization=13.0,
    mesh_smoothing_iters=25,
    normals_smoothing_iters=10,
    mesh_cleanup=True,
    compute_normals=True,
    subdomain_grid=True,
    subdomain_num_cubes_per_dim=64,
    output_mesh_smoothing_weights=True
)

# Write the mesh with attributes to file using meshio
mesh_with_data.write_to_file("surface.vtk")

The reconstruction_pipeline method provides (mostly) the same arguments as the splashsurf binary CLI. It may be necessary to specify the dtype of a function input (as done for particles in the example) so that the bindings know what data type to use internally. The extension supports single (np.float32) and double precision floats (np.float64).

Build instructions

You can also manually build the package from the source code:

  1. Clone the repository
  2. cd to the pysplashsurf directory
  3. Create an environment from python_environment.yaml and activate it
    • I recommend creating it in a subfolder, e.g. conda env create --prefix ./env -f python_environment.yaml
    • Then activate it using conda activate ./env
  4. Now, to build the project, use maturin: maturin develop
    • Maturin automatically installs the resulting binary in your python environment
    • Set the release flag -r or --release to build an optimized binary, however, compilation time will be slightly longer

Documentation Build

To generate the Sphinx documentation, make sure that the package is installed through, e.g., maturin, and then run make html in the pysplashsurf/pysplashsurf/docs directory. The resulting HTML files will be in pysplashsurf/pysplashsurf/docs/build/html.

Stub File Generation

To automatically generate a stub file for the package, run cargo run --bin stub_gen --no-default-features from the root project folder (from pysplashsurf/).

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

pysplashsurf-0.14.0.0.tar.gz (496.6 kB view details)

Uploaded Source

Built Distributions

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

pysplashsurf-0.14.0.0-cp310-abi3-win_arm64.whl (2.5 MB view details)

Uploaded CPython 3.10+Windows ARM64

pysplashsurf-0.14.0.0-cp310-abi3-win_amd64.whl (2.7 MB view details)

Uploaded CPython 3.10+Windows x86-64

pysplashsurf-0.14.0.0-cp310-abi3-win32.whl (2.5 MB view details)

Uploaded CPython 3.10+Windows x86

pysplashsurf-0.14.0.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.9 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ x86-64

pysplashsurf-0.14.0.0-cp310-abi3-manylinux_2_17_i686.manylinux2014_i686.whl (2.9 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ i686

pysplashsurf-0.14.0.0-cp310-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (2.7 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ ARMv7l

pysplashsurf-0.14.0.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (2.7 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ ARM64

pysplashsurf-0.14.0.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (2.9 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ x86-64

pysplashsurf-0.14.0.0-cp310-abi3-manylinux2014_armv7l.manylinux_2_17_armv7l.whl (2.7 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ ARMv7l

pysplashsurf-0.14.0.0-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl (2.7 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ ARM64

pysplashsurf-0.14.0.0-cp310-abi3-manylinux2010_i686.manylinux2014_i686.manylinux_2_12_i686.manylinux_2_17_i686.whl (2.9 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.12+ i686manylinux: glibc 2.17+ i686

pysplashsurf-0.14.0.0-cp310-abi3-macosx_14_0_arm64.whl (2.6 MB view details)

Uploaded CPython 3.10+macOS 14.0+ ARM64

pysplashsurf-0.14.0.0-cp310-abi3-macosx_13_0_x86_64.whl (2.9 MB view details)

Uploaded CPython 3.10+macOS 13.0+ x86-64

File details

Details for the file pysplashsurf-0.14.0.0.tar.gz.

File metadata

  • Download URL: pysplashsurf-0.14.0.0.tar.gz
  • Upload date:
  • Size: 496.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for pysplashsurf-0.14.0.0.tar.gz
Algorithm Hash digest
SHA256 b8d88cf5650434d32614e24417397ebe3967b5be5b03345049a48eebc75bb405
MD5 61e6488978ec2b52d91fd8f6d8e86e39
BLAKE2b-256 aa232d8770826b2725cd8e10cef3e6b943bab4ad20fd2827c1e02f888fce299b

See more details on using hashes here.

File details

Details for the file pysplashsurf-0.14.0.0-cp310-abi3-win_arm64.whl.

File metadata

File hashes

Hashes for pysplashsurf-0.14.0.0-cp310-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 b5472012f70c1bd350eef89927cd40c1ba05e2956c2469c77b07c151af321dce
MD5 0e02cc6ccf450d56004eb7f6cdd2b176
BLAKE2b-256 2c3155f64a62e6bc893f55254cf22ebdf78b91dc9b4a220df5fda9a5eebaa4d5

See more details on using hashes here.

File details

Details for the file pysplashsurf-0.14.0.0-cp310-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for pysplashsurf-0.14.0.0-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 7db781e6bbca0150bdb86d90a017e2968c6d484d8fa977caa36c3865f0747a42
MD5 0d41570cabf505ad113afb5293d331b4
BLAKE2b-256 edea5c921e602b378537bcf849ca3a793bc6df648d4564085dfffbc8f57037c2

See more details on using hashes here.

File details

Details for the file pysplashsurf-0.14.0.0-cp310-abi3-win32.whl.

File metadata

File hashes

Hashes for pysplashsurf-0.14.0.0-cp310-abi3-win32.whl
Algorithm Hash digest
SHA256 30f02a315335228e754c588bffa19c6aba20039899ab15a6eec575754d96a019
MD5 832db7c5d5918e8e6bc96256d3d0f233
BLAKE2b-256 8d715759f3c228d4c50a246fc13f544ada5159a534bb8a988a7b0d99f1d1379d

See more details on using hashes here.

File details

Details for the file pysplashsurf-0.14.0.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pysplashsurf-0.14.0.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 23b4296eaced1e77d1ead640f0e6d2e74c068dff26b63e641afafb22eb15048d
MD5 1810072221afd7d9f3b32326758b0505
BLAKE2b-256 8a1b98d6e7137de900584196a15149fd0284e6721adbe291372a925ffc255d5e

See more details on using hashes here.

File details

Details for the file pysplashsurf-0.14.0.0-cp310-abi3-manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for pysplashsurf-0.14.0.0-cp310-abi3-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 a704427b32738621bac08864bafdd8f9d68f871fc5a6f0a95946845fa7716fa4
MD5 53e22046f0b22df38746c90dec9844a2
BLAKE2b-256 8aa92da5559635c9972d207128a94eaf0aea09a5003f818de29335a5a867da13

See more details on using hashes here.

File details

Details for the file pysplashsurf-0.14.0.0-cp310-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl.

File metadata

File hashes

Hashes for pysplashsurf-0.14.0.0-cp310-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 df5ec4c11d4572652fc893ba2b90b35d8a44d76f87f0c4b5f577ff86202189ac
MD5 96f4b2c65f8a982ff4584a3e3f99b864
BLAKE2b-256 4cfca80b0ea3ca852da228966ce667ae22ced01e6d4ca3662cfcda904ceb8a36

See more details on using hashes here.

File details

Details for the file pysplashsurf-0.14.0.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pysplashsurf-0.14.0.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 bcb09eaa44330102cad899a679f6d83ad9a4c6bb571f1592d546b2f7269799b4
MD5 7e00d98f78eb25c6cbc642815e8a4fb1
BLAKE2b-256 c424850c6f0f9207338225009d36013b8364785f2d6d7f72830aa1c4311ace4a

See more details on using hashes here.

File details

Details for the file pysplashsurf-0.14.0.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for pysplashsurf-0.14.0.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 c0dd46a1f99b0897e87bbbb1eef8dacf731c1cbf64ce0374a32f5aeb46c7f6b1
MD5 43303aae5c71da032e54adfb130de021
BLAKE2b-256 04b0b15abec50ee12fa546c90943334845a93d7e31aedcc067ea7b2536ff7599

See more details on using hashes here.

File details

Details for the file pysplashsurf-0.14.0.0-cp310-abi3-manylinux2014_armv7l.manylinux_2_17_armv7l.whl.

File metadata

File hashes

Hashes for pysplashsurf-0.14.0.0-cp310-abi3-manylinux2014_armv7l.manylinux_2_17_armv7l.whl
Algorithm Hash digest
SHA256 30b28c616c24e33c5f002b6bf4c57eea4f1973f666d15fb0011dfeb4283a0f7f
MD5 5972233f3de1cac5aa49e966a916ddf5
BLAKE2b-256 c932113adffa042a899ec103e66a5bcf16a0457cae8078210fcf99fe832cfbc3

See more details on using hashes here.

File details

Details for the file pysplashsurf-0.14.0.0-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl.

File metadata

File hashes

Hashes for pysplashsurf-0.14.0.0-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Algorithm Hash digest
SHA256 0546784d2b7fca261d45ce325211d7cc04ba8c73b6a59aaa15a7a153460bf716
MD5 63132ed424a8ffcb347318c4d1239b67
BLAKE2b-256 45bd0c6dd7983b35e406e04af50ba47128acae4478e1c954790e50048a1f2994

See more details on using hashes here.

File details

Details for the file pysplashsurf-0.14.0.0-cp310-abi3-manylinux2010_i686.manylinux2014_i686.manylinux_2_12_i686.manylinux_2_17_i686.whl.

File metadata

File hashes

Hashes for pysplashsurf-0.14.0.0-cp310-abi3-manylinux2010_i686.manylinux2014_i686.manylinux_2_12_i686.manylinux_2_17_i686.whl
Algorithm Hash digest
SHA256 04fb1598906b81c6951efcb60d332e0ebb4cd1787b7e49a4da34db01e459f93b
MD5 1e026c16df793c111324a4b7c605a310
BLAKE2b-256 2c4fd06ad720cc5cde2cf9e3b0c3d27d918526a79153580f46f72d4e86f775ad

See more details on using hashes here.

File details

Details for the file pysplashsurf-0.14.0.0-cp310-abi3-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for pysplashsurf-0.14.0.0-cp310-abi3-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 71cb1586adecd0e3e196cf1954b416533e2612f9e7fad8d887fe4ccba9675b38
MD5 e9d23558c07362a45e5226c3d032ebbc
BLAKE2b-256 f96b04c82356c1a654dbec0b9f24862600c777e1e612f751698b654fd3f8e119

See more details on using hashes here.

File details

Details for the file pysplashsurf-0.14.0.0-cp310-abi3-macosx_13_0_x86_64.whl.

File metadata

File hashes

Hashes for pysplashsurf-0.14.0.0-cp310-abi3-macosx_13_0_x86_64.whl
Algorithm Hash digest
SHA256 c9b13328afbee97c2e5f35d63a62f2247e2b9ce533d6aa99d7c415555198b8dd
MD5 5c02c351d0c8e653da8735d11faeb6e0
BLAKE2b-256 863db01ec7b6bea35d81efac1e3d92e8068d4b196e66365b10c45478a79ddfd9

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