peclet.voro 1.0.0
Device-native moving-particle Voronoi dynamics
Loading...
Searching...
No Matches
Typedefs | Functions
voro_bindings.cpp File Reference

Kokkos nanobind Python module peclet.voro. More...

#include <nanobind/nanobind.h>
#include <nanobind/ndarray.h>
#include <nanobind/stl/array.h>
#include <nanobind/stl/string.h>
#include <array>
#include <cmath>
#include <Kokkos_Core.hpp>
#include <set>
#include <vector>
#include "peclet/core/common/view.hpp"
#include "peclet/core/python/ndarray_interop.hpp"
#include "peclet/voro/convex_cell.hpp"
#include "peclet/voro/mesh_optimizer.hpp"
#include "peclet/voro/repair.hpp"
#include "peclet/voro/topology_store.hpp"
#include "peclet/voro/physics/simulation.hpp"
Include dependency graph for voro_bindings.cpp:

Typedefs

using real_t = double
 
using DView = Kokkos::View< real_t *, peclet::core::MemSpace >
 

Functions

 NB_MODULE (_voro, m)
 

Detailed Description

Kokkos nanobind Python module peclet.voro.

Drives the production device path — multicore CPU (OpenMP), or GPU (CUDA/HIP), selected by the Kokkos backend the extension was built against — from Python. Two surfaces:

Particle data crosses the boundary as NumPy arrays: positions/velocities are (N,3) float64, scalars (masses, viscosities, volumes) are (N,). Arrays move through the shared peclet::core::python bridge (core): returned arrays are backed by host buffers (no extra device copy).

Kokkos is initialized at import and finalized via a Python atexit hook (with every live object's Views released first — required on CUDA). Call peclet.voro.finalize() for deterministic teardown.

Example

import numpy as np, peclet.voro
rng = np.random.default_rng(0)
pos = rng.random((100_000, 3)) # uniform points in the unit box
t = peclet.voro.Tessellation()
t.set_box((1.0, 1.0, 1.0))
t.build(pos) # cold tessellation
vol = t.volumes() # (N,) cell volumes; sum ~= box volume
for _ in range(50): # move + repair each step (faster than rebuilding)
pos = (pos + 1e-4 * rng.standard_normal(pos.shape)) % 1.0
stats = t.step(pos) # {'flagged','pass1','pass2','rebuilt','fell_back'}
nbr = t.neighbor_counts() # (N,) Voronoi neighbours per cell
Definition convex_cell.hpp:40

Typedef Documentation

◆ DView

using DView = Kokkos::View<real_t*, peclet::core::MemSpace>

◆ real_t

using real_t = double

Function Documentation

◆ NB_MODULE()

NB_MODULE ( _voro  ,
 
)