core 1.5.0
Shared MPI block decomposition, asynchronous ghost-layer exchange, SDF geometry, load balancing (header-only C++20)
Loading...
Searching...
No Matches
peclet::core Namespace Reference

Namespaces

namespace  decomp
 
namespace  detail
 
namespace  geom
 
namespace  halo
 
namespace  interp
 
namespace  mpi_stub
 
namespace  python
 
namespace  scheme
 
namespace  solver
 
namespace  vof
 

Classes

struct  Box
 A physical, axis-aligned box with per-axis periodicity. Continuous — no cells. More...
 
struct  FieldRec
 One registered field: its flat x-fastest device buffer plus the metadata a consumer needs to exchange or redistribute it. More...
 
class  FieldSet
 Name → FieldRec directory. More...
 
struct  NestedLoop
 Compile-time-unrolled nested loop over [bgn, end) in row-major (axis 0 fastest) order. More...
 
struct  NestedLoop< Dim, 0 >
 
struct  Quat
 Quaternion, {x, y, z, w} — dem's F4 ordering (dem_portable.hpp), NOT {w, x, y, z}. More...
 
struct  Range
 Half-open range [begin, end) carrying a label (e.g. a block id). Ported from pbs::IndxRange. More...
 
struct  UniformGrid
 A box resolved by a regular cell grid. More...
 
struct  Vec3
 Real-templated POD 3-vector — the geometry layer's point type on host and device. More...
 

Typedefs

using Index = std::int64_t
 Signed index type for grids and particles (supersedes block_decomposer's long int IndxT).
 
using Real = double
 Default host floating type. Device kernels may use float; conversions happen at the boundary.
 
template<int Dim>
using IVec = std::array< Index, Dim >
 Multi-dimensional integer index / coordinate (x-fastest order by convention).
 
template<int Dim>
using Vec = std::array< Real, Dim >
 Multi-dimensional real vector.
 
using ExecSpace = Kokkos::DefaultExecutionSpace
 
using MemSpace = ExecSpace::memory_space
 
template<class T >
using View = Kokkos::View< T *, MemSpace >
 1D device array.
 
template<class T >
using HostView = decltype(Kokkos::create_mirror_view(std::declval< View< T > >()))
 Host-accessible mirror of View<T> (identical to View<T> on host backends).
 
using IndexView = Kokkos::View< Index *, MemSpace >
 Device array of grid/particle indices (the matched send/recv/self-copy lists).
 
template<class T >
using Field3D = Kokkos::View< T ***, Kokkos::LayoutLeft, MemSpace >
 3D structured field in the suite's x-fastest convention: LayoutLeft makes the leftmost (x) index contiguous, i.e.
 

Enumerations

enum class  Centering { Cell , FaceX , FaceY , FaceZ }
 Where a field's samples sit relative to a cell. More...
 

Functions

int usableCpus ()
 How many CPUs this process may actually use: the affinity count, lowered by any cgroup quota binding it.
 
int defaultHostThreads (bool hostBackendSizesItself)
 The host thread count to hand a backend that has not been told one, or 0 for "say nothing".
 
bool hostParallelActive ()
 Is the parallel backend actually live for this process? (Kokkos compiled in AND initialized.) Exposed so a builder can assert/report; the shim itself already falls back transparently.
 
template<class Body >
void hostParFor (Index n, Body &&body)
 Parallel for (Index i = 0; i < n; ++i) body(i); over the Kokkos HOST execution space.
 
template<class Body >
void hostParScan (Index n, Body &&body)
 Exclusive integer scan over the host space: body(i, update, final) where update carries the running sum of everything BEFORE i when final is true.
 
template<class Real >
PECLET_HD Vec3< Real > add (Vec3< Real > a, Vec3< Real > b)
 
template<class Real >
PECLET_HD Vec3< Real > sub (Vec3< Real > a, Vec3< Real > b)
 
template<class Real >
PECLET_HD Vec3< Real > scale (Vec3< Real > a, Real s)
 
template<class Real >
PECLET_HD Real dot (Vec3< Real > a, Vec3< Real > b)
 
template<class Real >
PECLET_HD Vec3< Real > cross (Vec3< Real > a, Vec3< Real > b)
 
template<class Real >
PECLET_HD Vec3< Real > rotate (Quat< Real > q, Vec3< Real > v)
 Rotate v by q.
 
template<class Real >
PECLET_HD Vec3< Real > invRotate (Quat< Real > q, Vec3< Real > v)
 Rotate v by the conjugate of q — dem invRotateVector.
 
template<class Real >
PECLET_HD Quat< Real > mulQuat (Quat< Real > a, Quat< Real > b)
 Hamilton product a ⊗ b in the (x, y, z, w) storage convention rotate uses, so rotate(mulQuat(a, b), v) == rotate(a, rotate(b, v)) — i.e.
 
Index wrap (Index x, Index n)
 Periodic wrap of a coordinate into [0, n): wrap(x, n) = (x % n + n) % n.
 
template<int Dim, typename Func >
void forEachInBox (const IVec< Dim > &bgn, const IVec< Dim > &end, Func &&func)
 Iterate the box [bgn, end) calling func(const IVec<Dim>&).
 
template<class T >
View< T > toDevice (const std::vector< T > &h, const std::string &label)
 Upload a host std::vector into a freshly-sized device View (empty vector => empty view).
 
template<class V >
std::vector< std::remove_const_t< typename V::value_type > > toVector (const V &view)
 Copy a (host- or device-resident) Kokkos View of any rank into a contiguous host std::vector, flattened in C/row order (last index fastest) — an Nx3 View comes back as out[i*3 + c] == view(i,c), the suite's particle-SoA Python export order.
 

Typedef Documentation

◆ Index

Signed index type for grids and particles (supersedes block_decomposer's long int IndxT).

Definition at line 15 of file types.hpp.

◆ Real

Default host floating type. Device kernels may use float; conversions happen at the boundary.

Definition at line 18 of file types.hpp.

◆ IVec

template<int Dim>
using peclet::core::IVec = typedef std::array<Index, Dim>

Multi-dimensional integer index / coordinate (x-fastest order by convention).

Definition at line 22 of file types.hpp.

◆ Vec

template<int Dim>
using peclet::core::Vec = typedef std::array<Real, Dim>

Multi-dimensional real vector.

Definition at line 26 of file types.hpp.

◆ ExecSpace

using peclet::core::ExecSpace = typedef Kokkos::DefaultExecutionSpace

Definition at line 20 of file view.hpp.

◆ MemSpace

using peclet::core::MemSpace = typedef ExecSpace::memory_space

Definition at line 21 of file view.hpp.

◆ View

template<class T >
using peclet::core::View = typedef Kokkos::View<T*, MemSpace>

1D device array.

The halo addresses cells by precomputed flat local index, so a contiguous per-cell field is a View<T>; the x-fastest ordering lives in the indices, not the View layout.

Definition at line 26 of file view.hpp.

◆ HostView

template<class T >
using peclet::core::HostView = typedef decltype(Kokkos::create_mirror_view(std::declval<View<T> >()))

Host-accessible mirror of View<T> (identical to View<T> on host backends).

Defined via the actual create_mirror_view return type to stay correct across Kokkos backends/versions.

Definition at line 31 of file view.hpp.

◆ IndexView

Device array of grid/particle indices (the matched send/recv/self-copy lists).

Definition at line 34 of file view.hpp.

◆ Field3D

template<class T >
using peclet::core::Field3D = typedef Kokkos::View<T***, Kokkos::LayoutLeft, MemSpace>

3D structured field in the suite's x-fastest convention: LayoutLeft makes the leftmost (x) index contiguous, i.e.

I = x + y*nx + z*nx*ny — identical to peclet::core::Index linearization and cfd-gpu grids.

Definition at line 40 of file view.hpp.

Enumeration Type Documentation

◆ Centering

Where a field's samples sit relative to a cell.

Scalars/properties are cell-centred; the MAC face-normal velocity components are face-centred. (The staggered solver stores its face fields as cell-indexed arrays, so Centering is metadata for consumers — it does not change the buffer.)

Enumerator
Cell 
FaceX 
FaceY 
FaceZ 

Definition at line 32 of file field_set.hpp.

Function Documentation

◆ usableCpus()

int peclet::core::usableCpus ( )
inline

How many CPUs this process may actually use: the affinity count, lowered by any cgroup quota binding it.

At least 1. Falls back to the affinity count alone where no quota can be read.

Definition at line 140 of file cpu_budget.hpp.

References peclet::core::detail::affinityCpus(), and peclet::core::detail::cgroupQuota().

Referenced by defaultHostThreads().

◆ defaultHostThreads()

int peclet::core::defaultHostThreads ( bool  hostBackendSizesItself)
inline

The host thread count to hand a backend that has not been told one, or 0 for "say nothing".

0 whenever the user has expressed a preference the backend will act on itself — their choice is never overridden — and 0 when the budget is the whole machine, so that on an ordinary workstation this function changes NOTHING: same thread count, same schedule, same results. It speaks up only in the two cases it exists for: a quota narrower than the visible machine, and an OMP_NUM_THREADS that nothing else is going to read.

Parameters
hostBackendSizesItselftrue iff the host backend is OpenMP. Two things follow from it, and neither is true of the C++ threads or Serial backends — which is what a Windows or macOS wheel carries, since neither toolchain supplies an OpenMP that Kokkos accepts:
  1. It reads OMP_NUM_THREADS. The OpenMP runtime does; Kokkos itself reads only KOKKOS_NUM_THREADS (Kokkos_Core.cpp). So on any other backend that variable reaches nobody at all unless it is honoured here — and every peclet page tells a container user to set exactly it.
  2. Its own default is the whole machine. Kokkos::Threads asks hwloc for the topology and falls back to one thread when hwloc is absent (Kokkos_Threads_Instance.cpp:487), which it is in every peclet wheel. Measured 2026-09-13 on 48 cores: unset, the quick start takes 4.43 s, exactly its one-thread time, against 0.64 s at 24 threads. So on those backends saying nothing is not neutral — it is a 7x cut, silently. Say the budget.

Definition at line 172 of file cpu_budget.hpp.

References peclet::core::detail::affinityCpus(), and usableCpus().

Referenced by peclet::core::python::install().

◆ hostParallelActive()

bool peclet::core::hostParallelActive ( )
inline

Is the parallel backend actually live for this process? (Kokkos compiled in AND initialized.) Exposed so a builder can assert/report; the shim itself already falls back transparently.

Definition at line 73 of file host_parallel.hpp.

◆ hostParFor()

template<class Body >
void peclet::core::hostParFor ( Index  n,
Body &&  body 
)
inline

Parallel for (Index i = 0; i < n; ++i) body(i); over the Kokkos HOST execution space.

CONTRACT: iterations must write disjoint memory (see the header note) — the shim does not and cannot check it, and a violation is a data race, not merely a nondeterminism.

Definition at line 85 of file host_parallel.hpp.

◆ hostParScan()

template<class Body >
void peclet::core::hostParScan ( Index  n,
Body &&  body 
)
inline

Exclusive integer scan over the host space: body(i, update, final) where update carries the running sum of everything BEFORE i when final is true.

Semantics are Kokkos parallel_scan's, and the serial fallback reproduces them exactly.

Typical use (two-pass CSR): pass counts in, read row offsets out. hostParScan(n, [&](Index i, Index& acc, bool final) { const Index c = count[i]; if (final) start[i] = acc; acc += c; });

Definition at line 112 of file host_parallel.hpp.

◆ add()

◆ sub()

◆ scale()

◆ dot()

◆ cross()

◆ rotate()

template<class Real >
PECLET_HD Vec3< Real > peclet::core::rotate ( Quat< Real >  q,
Vec3< Real >  v 
)

Rotate v by q.

Verbatim port of dem rotateVector (dem_portable.hpp) — keep the operation order: a rewritten-but-algebraically-equal form would break the rung-3 bit-exactness gate.

Definition at line 81 of file portable.hpp.

References add(), cross(), scale(), peclet::core::Quat< Real >::w, peclet::core::Quat< Real >::x, peclet::core::Quat< Real >::y, and peclet::core::Quat< Real >::z.

Referenced by peclet::core::geom::SceneBuilder< Real >::composeTransform(), peclet::core::geom::evalTreeGrad(), peclet::core::geom::instanceBound(), invRotate(), and peclet::core::geom::query_detail::nodeBound().

◆ invRotate()

template<class Real >
PECLET_HD Vec3< Real > peclet::core::invRotate ( Quat< Real >  q,
Vec3< Real >  v 
)

◆ mulQuat()

template<class Real >
PECLET_HD Quat< Real > peclet::core::mulQuat ( Quat< Real >  a,
Quat< Real >  b 
)

Hamilton product a ⊗ b in the (x, y, z, w) storage convention rotate uses, so rotate(mulQuat(a, b), v) == rotate(a, rotate(b, v)) — i.e.

b applies first.

Definition at line 96 of file portable.hpp.

References peclet::core::Quat< Real >::w, peclet::core::Quat< Real >::x, peclet::core::Quat< Real >::y, and peclet::core::Quat< Real >::z.

Referenced by peclet::core::geom::SceneBuilder< Real >::composeTransform().

◆ wrap()

Index peclet::core::wrap ( Index  x,
Index  n 
)
inline

Periodic wrap of a coordinate into [0, n): wrap(x, n) = (x % n + n) % n.

Definition at line 37 of file types.hpp.

Referenced by peclet::core::halo::GridHaloTopology< Dim >::buildTopology(), and peclet::core::halo::ParticleMigrator< Dim >::cellOf().

◆ forEachInBox()

template<int Dim, typename Func >
void peclet::core::forEachInBox ( const IVec< Dim > &  bgn,
const IVec< Dim > &  end,
Func &&  func 
)
inline

Iterate the box [bgn, end) calling func(const IVec<Dim>&).

Definition at line 65 of file types.hpp.

References peclet::core::NestedLoop< Dim, Axis >::run().

◆ toDevice()

template<class T >
View< T > peclet::core::toDevice ( const std::vector< T > &  h,
const std::string &  label 
)
inline

◆ toVector()

template<class V >
std::vector< std::remove_const_t< typename V::value_type > > peclet::core::toVector ( const V &  view)

Copy a (host- or device-resident) Kokkos View of any rank into a contiguous host std::vector, flattened in C/row order (last index fastest) — an Nx3 View comes back as out[i*3 + c] == view(i,c), the suite's particle-SoA Python export order.

This replaces the redundant "create_mirror_view → deep_copy → element-by-element loop → std::vector" idiom in the binding getters (S2a) with a single device→host transfer and no hand-written loop. The row-order flatten is layout-correct on every backend: a LayoutLeft (e.g. CUDA-default) device View is transposed on the host hop rather than blindly memcpy'd, so the exported ordering matches across CPU/GPU builds.

Definition at line 63 of file view.hpp.