flow 1.4.0
Kokkos cut-cell IBM incompressible Navier-Stokes solver + pnm pore extraction
Loading...
Searching...
No Matches
flow_bindings.cpp File Reference

nanobind module flow — the Kokkos cut-cell IBM Navier-Stokes solver (peclet.flow.Solver). More...

#include <nanobind/nanobind.h>
#include <nanobind/ndarray.h>
#include <nanobind/stl/array.h>
#include <nanobind/stl/optional.h>
#include <nanobind/stl/pair.h>
#include <nanobind/stl/string.h>
#include <nanobind/stl/tuple.h>
#include <nanobind/stl/vector.h>
#include <array>
#include <cstdint>
#include <Kokkos_Core.hpp>
#include <limits>
#include <string>
#include <vector>
#include "anderson_accelerator.hpp"
#include "flow_bindings_checks.hpp"
#include "flow_bindings_common.hpp"
#include "flow_bindings_core.hpp"
#include "flow_bindings_geometry.hpp"
#include "flow_bindings_phase_change.hpp"
#include "flow_bindings_scalar.hpp"
#include "flow_bindings_sharp_viscous.hpp"
#include "flow_bindings_tuning.hpp"
#include "flow_bindings_vof.hpp"
#include "flow_bindings_vof_blocks.hpp"
#include "flow_bindings_vof_momentum.hpp"
#include "flow_ibm.hpp"
#include "peclet/core/python/kokkos_teardown.hpp"
#include "peclet/core/python/ndarray_interop.hpp"

Go to the source code of this file.

Classes

struct  BoundAccelerator< Grid >
struct  BoundSolver< Grid >
struct  Diagnostics< Grid >
 The developer tier: a view onto one Solver<Grid> (no state of its own). More...

Functions

template<class Grid>
static void bind_accelerator (nb::module_ &m, const char *name)
template<class Grid>
static void bind_diagnostics (nb::module_ &m, const char *name)
template<class Grid>
static void bind_solver (nb::module_ &m, const char *name, const char *diag_name)
 NB_MODULE (_flow, m)

Detailed Description

nanobind module flow — the Kokkos cut-cell IBM Navier-Stokes solver (peclet.flow.Solver).

Exposes peclet::flow::IbmSolver to Python: set rho/mu/dt, a body force, an SDF solid (cut-cell IBM no-slip

  • optional cut-cell pressure projection), step, read back the velocity/pressure, and query the cut-cell flux divergence. Exercised by verify_poiseuille_sdflow (IBM channel) and verify_periodic_spheres_sdflow (cut-cell Stokes through a sphere packing). rank()/bcast_from_root() are single-rank stubs (the multi-rank path lives in tests/kokkos_mpi).

Kokkos teardown follows the suite-wide pattern of peclet/core/python/kokkos_teardown.hpp: Kokkos is initialized at import; every bound Solver is a Releasable (registered on construction) and every zero-copy array (field_view) is a Releasable capsule; the module's single atexit hook (also flow.finalize()) releases all of them and THEN calls Kokkos::finalize, so a Solver or array still referenced at interpreter exit (script globals, a Jupyter/Quarto kernel) can no longer be destroyed after finalize – which is a Kokkos::abort (SIGABRT / exit 134, on OpenMP as on CUDA), not a warning. Nothing needs to be deleted before exit any more.

Arrays cross the boundary through the shared zero-copy bridge (peclet::core::python, in core): fields come back as Fortran-order (nx,ny,nz) float64 NumPy arrays referencing the field buffer, and inputs are read as flat x-fastest buffers. See peclet/core/python/ndarray_interop.hpp.

Definition in file flow_bindings.cpp.

Function Documentation

◆ bind_accelerator()

template<class Grid>
void bind_accelerator ( nb::module_ & m,
const char * name )
static

Definition at line 77 of file flow_bindings.cpp.

Referenced by NB_MODULE().

◆ bind_diagnostics()

◆ bind_solver()

◆ NB_MODULE()

NB_MODULE ( _flow ,
m  )

Definition at line 170 of file flow_bindings.cpp.

References bind_accelerator(), bind_solver(), and weights().