pnm 1.0.3
peclet.pnm — pore-network extraction from SDF geometry (Kokkos)
Loading...
Searching...
No Matches
pnm_bindings_checks.hpp File Reference

Input validation of the peclet.pnm Python binding (src/pnm_bindings.cpp only). More...

#include <cmath>
#include <cstddef>
#include <cstdio>
#include <new>
#include <optional>
#include <stdexcept>
#include <string>
#include <vector>
#include "pore_kernels.hpp"

Go to the source code of this file.

Namespaces

namespace  pnm
namespace  pnm::binding_checks

Functions

std::string pnm::binding_checks::num (double v)
void pnm::binding_checks::require (bool ok, const char *who, const std::string &name, const std::string &rule, double v)
std::string pnm::binding_checks::component (const char *name, std::size_t i)
void pnm::binding_checks::triple (const char *who, const char *name, std::size_t size)
 A z-y-x triple: exactly three values.
void pnm::binding_checks::finiteEach (const char *who, const char *name, const std::vector< double > &a, const char *dim)
 Each component finite once narrowed to float32 (a coordinate: any sign).
void pnm::binding_checks::positiveEach (const char *who, const char *name, const std::vector< double > &a, const char *dim)
 Each component finite and > 0 once narrowed to float32 (a cell size).
void pnm::binding_checks::countEach (const char *who, const char *name, const std::vector< int > &a, int lo)
 Each component an integer >= lo (a voxel count).
void pnm::binding_checks::spacingZyx (const char *who, const std::vector< double > &spacing)
 spacing_zyx: the grid's cell size per axis, three values > 0 (length units).
void pnm::binding_checks::grid (const char *who, const std::vector< double > &origin, const std::vector< double > &spacing)
 origin_zyx + spacing_zyx of extract_pores / extract_pore_network(_mpi).
void pnm::binding_checks::globalShapeZyx (const char *who, const std::vector< int > &shape, bool sized)
 The global grid of the ORB decomposition: at least one voxel per axis.
void pnm::binding_checks::topologyShape (const std::optional< std::vector< int > > &shape)
 extract_topology's shape_zyx, when given as three values: voxel counts >= 0 whose product fits in std::size_t (a wrapped product could match the flat array's length).
void pnm::binding_checks::initPore (Pore *p, float x, float y, float z, float radius)
 Pore(x, y, z, radius): a finite centre and a finite radius >= 0 (Pore() is all zeros).

Detailed Description

Input validation of the peclet.pnm Python binding (src/pnm_bindings.cpp only).

The extraction kernels (pore_extraction*.hpp) trust their caller; the binding refuses a z-y-x triple of the wrong length, a NaN/Inf, a non-positive cell size or a negative count as ValueError (std::invalid_argument) before it reaches them. A valid value takes exactly the path it took before. The message names the function, the parameter, the admissible range with its dimension (pnm works in the caller's consistent length units, those of the SDF) and the offending value. Checks that predate these (array rank, shape matching) keep their RuntimeError.

origin_zyx and spacing_zyx are narrowed to float32 before the kernels, so they are checked as float32: 1e39 is not finite there and 1e-50 is not > 0. Binding-only: no kernel header includes this file.

Definition in file pnm_bindings_checks.hpp.