pnm 1.0.3
peclet.pnm — pore-network extraction from SDF geometry (Kokkos)
Loading...
Searching...
No Matches
pnm::kernels Namespace Reference

Classes

struct  FlatFaces
 Per-face field accessors for the film-attachment sweep: label / pair key of face (cell e, d). More...
struct  SplitFaces
struct  ThroatSlots
 Global unique (patch root, pair key) list -> the throat list ordered by (pair, root fid), the sorted root keys and the (key position -> throat slot) map for the device lookup. More...
struct  ThroatExtras
 Host finish of the per-throat extras (both pipelines), every vector triple in z-y-x order (3*nt, row t = (z, y, x)) as the binding hands it over: the momentum flux and the open-area-weighted mean oriented normal Σw0·n / Σw0 (NOT normalised: |n| < 1 on a curved patch), and the area-weighted centroid in the image frame of the LOWER pore's peak voxel (anchor + Σw0·offset / Σw0; not wrapped into the box — no float image decision). More...
struct  PoreVolumeStats
 Host finish of the per-pore volume sums (both pipelines): fluid volume (count * cell volume), volume means of p, ½|u_c|² and u_c (z-y-x), and the volume centroid (peak-voxel anchor + mean integer offset * spacing, i.e. More...

Typedefs

using MD3 = Kokkos::MDRangePolicy<Exec, Kokkos::Rank<3>>
using R1 = Kokkos::RangePolicy<Exec>

Functions

template<class Geo>
MD3 ownedRange (const Exec &space, const Geo &geo)
 The owned box of a geometry as an MDRange policy.
template<class Geo, class SdfView>
bool isPeak (const Geo &g, const SdfView &sdf, int lx, int ly, int lz, float cv, Index cgid)
 Local SDF maximum under the global (sdf, gid) lexicographic order (26-neighbourhood).
template<class Geo, class SdfView>
Pore poreAt (const Geo &g, const SdfView &sdf, int lx, int ly, int lz, float ox, float oy, float oz, float sx, float sy, float sz)
 The pore record at a peak: sub-voxel position by the SDF^2-weighted centroid of the 3^3 neighbourhood (positive part only), in global (wrapped) integer coords, radius = sdf there.
template<class Geo, class SdfView>
Index steepest (const Geo &g, const SdfView &sdf, int lx, int ly, int lz, Index cgid, bool ascent)
 Steepest 26-neighbour under the (sdf, gid) lexicographic order: ascent (pores) or descent (solids); returns the neighbour's gid, or cgid itself at a peak.
template<class Geo, class FieldView>
double trilinear (const Geo &g, const FieldView &p, const double gp[3])
 Trilinear interpolation of a cell-centered periodic field at grid position gp (in cells).
bool facesAdjacent (int dx, int dy, int dz, int d, int d2)
 Face adjacency of the per-patch throat CCL: two faces (cell offset (dx,dy,dz), directions d and d2) connect when their doubled center offset satisfies |2*dc + e_d2 - e_d|^2 <= 8 — a generous edge/corner adjacency in pure integer arithmetic (periodic-safe, decomposition- independent).
template<class KeyView>
Index bsearchKey (const KeyView &keys, Index nkeys, typename KeyView::non_const_value_type key)
 Device binary search over a sorted key view; returns the position or -1.
template<class Geo, class SdfView, class PoreView, class CountView>
void detectPores (const Exec &space, const Geo &geo, const SdfView &sdf, std::array< float, 3 > origin, std::array< float, 3 > spacing, const PoreView &pores, const CountView &counter, int maxPores)
 Emit the owned peaks (local SDF maxima, sdf > 0) as Pore records into pores (atomic slot counter counter, capacity maxPores).
template<class Geo, class SdfView, class ParentView>
void initMarkers (const Exec &space, const Geo &geo, const SdfView &sdf, float thr, const ParentView &parent)
 Deep-solid markers: parent(o) = o where sdf < thr, else -1 (owned-dense).
template<class ParentView>
void cclFlatten (const Exec &space, const ParentView &parent, std::size_t n)
 Path compression: every labelled entry points at its root.
template<class Geo, class ParentView, class FlagView>
void cclMergeMarkers (const Exec &space, const Geo &geo, const ParentView &parent, const FlagView &changed)
 One union sweep of the marker CCL (26-connectivity, 13 forward neighbours, union-by-min via atomic_min on the larger root).
template<class ParentView, class FlagView, class MergeFn>
void cclFixpoint (const Exec &space, const ParentView &parent, std::size_t n, const FlagView &changed, const MergeFn &merge)
 Union-find to fixpoint: merge() launches one union sweep (setting changed), then a flatten; repeat until a sweep changes nothing.
template<class Geo, class SdfView, class LabelView, class FlagView>
void floodSweep (const Exec &space, const Geo &geo, const SdfView &sdf, const LabelView &labels, const LabelView &labelsN, const FlagView &changed)
 One Jacobi flood sweep: every unlabelled solid voxel takes the smallest labelled 26-neighbour (reads labels, writes labelsN; the caller swaps).
template<class Geo, class SdfView, class LabelView, class FlagView, class SyncFn>
void floodFixpoint (const Exec &space, const Geo &geo, const SdfView &sdf, LabelView &labels, LabelView &labelsN, const FlagView &changed, const SyncFn &sync)
 Jacobi flood to fixpoint.
template<class SdfView, class EmitFn>
void gradientWalk (const Exec &space, const GridGeo &geo, const SdfView &sdf, bool ascentAll, const EmitFn &emit)
 Single-rank gradient walk: from every owned cell follow the steepest neighbour (ascent for pores, descent for solids; ascentAll = ascent from every cell, the flow-basin variant) for at most 512 steps; emit(o, walker) receives the end point (a gid == field index here).
template<class Geo, class SdfView, class TargetView, class ChaseFn, class FinalFn, class PeakFn>
void forestInit (const Exec &space, const Geo &geo, const SdfView &sdf, const TargetView &target, const ChaseFn &chase, const FinalFn &finalOf, const PeakFn &peakOf)
 Steepest-neighbour forest for the hold-at-ghost root resolution.
template<class Geo, class TargetView>
int resolveHoldAtGhost (const Exec &space, const Geo &geo, const TargetView &target)
 One round of pointer jumping with the hold-at-ghost invariant: chase within the field, adopt a finalized (negative) value, or HOLD at the last in-field cell when the next hop leaves the field (never store a gid the field cannot reach — that strands the chase outside the ghost ring).
template<class Geo, class SegView, class PairView, class CountView>
void boundaryPairs (const Exec &space, const Geo &geo, const SegView &seg, const PairView &pairs, const CountView &cnt, Index maxPairs)
 Boundary pairs: for every owned cell, the (min,max) label pairs across its +x/+y/+z faces where the label changes, appended to the interleaved pairs (atomic cnt, capacity maxPairs).
template<class PairView>
std::vector< std::pair< int, int > > uniquePairs (const PairView &pairs, std::size_t count)
 Interleaved device pairs -> host (l1,l2) list, sorted and unique.
template<class Geo, class SegView>
int maxLabel (const Exec &space, const Geo &geo, const SegView &seg)
 The largest label over the owned box (= the number of pore labels).
template<class Geo, class LabView, class SdfView, class OpenView, class CoreView, class ParentView, class PairView>
void faceInit (const Exec &space, const Geo &geo, const LabView &flowLab, const SdfView &sdf, const OpenView &ox, const OpenView &oy, const OpenView &oz, bool hasOpen, const CoreView &core, const ParentView &parent, const PairView &fpair)
 Interface predicate + CORE tier per owned face: an interface face separates two different positive flow-basin labels with positive openness; CORE = both cells fluid-centered (sdf > 0), which defines the patches by CCL; the rest are FILM faces that attach later.
template<class Geo, class ParentView, class PairView, class FlagView>
void faceMerge (const Exec &space, const Geo &geo, const ParentView &parent, const PairView &fpair, const FlagView &changed)
 One union sweep of the face CCL over the faces with parent >= 0 (same pair key + adjacency; owned-owned adjacency only, see cclMergeMarkers).
template<class Geo, class ParentView, class MinView>
void faceMinGid (const Exec &space, const Geo &geo, const ParentView &parent, const MinView &mg)
 Per-component minimum GLOBAL face id (3*gid+d) of the local face CCL, keyed by the component root: the decomposition-independent patch label.
template<class ParentView, class PairView, class LabView, class RootFn>
void faceLabelCore (const Exec &space, std::size_t nf, const ParentView &parent, const PairView &fpair, const LabView &faceLab, const RootFn &rootOf)
 Core-tier labels: faceLab = rootOf(parent) for the CCL'd faces, kSent for the remaining interface (film) faces, -1 for non-interface faces.
template<class ParentView, class LabView, class RootFn>
void faceLabelLeftover (const Exec &space, std::size_t nf, const ParentView &parent, const LabView &faceLab, const RootFn &rootOf)
 Leftover-tier labels: the still-kSent films (their own CCL tier) get rootOf(parent).
template<class ParentView, class LabView>
void leftoverInit (const Exec &space, std::size_t nf, const LabView &faceLab, const ParentView &parent)
 Leftover tier init: parent = f for the films no core patch reached, -1 otherwise.
template<class Geo, class LabView, class PairView, class CoreView, class NbLab, class NbPair, class FlagView>
void filmAttachSweep (const Exec &space, const Geo &geo, const LabView &faceLab, const PairView &fpair, const CoreView &core, const NbLab &nbLab, const NbPair &nbPair, const FlagView &changed)
 One Jacobi min-propagation sweep of the film attachment: every film face (interface, not core) takes the minimum attached label among its adjacent same-pair faces (nbLab(e, d) / nbPair(e, d) read the neighbour faces — flat single-rank, per-direction exchanged fields on a block).
ThroatSlots throatSlots (std::vector< std::pair< Index, Index > > rootPair)
template<class Geo, class FieldView>
void faceVelocity (const Geo &g, const FieldView &u, const FieldView &v, const FieldView &w, int lx, int ly, int lz, int d, double un, double uf[3])
 Full velocity vector at the centre of the +d face of field cell (lx,ly,lz) (the shared face with the +d neighbour, where the normal MAC component un lives): each tangential component d2 != d is the plain average of the 4 nearest d2-face values — the -d2 and +d2 faces of the cell and of its +d neighbour (u(i,j,k) is the -x face of cell (i,j,k)).
template<class Geo, class LabView, class FieldView, class OpenView, class FaceLabView, class KeyView, class SlotView, class AncView, class AccView>
void throatFlux (const Exec &space, const Geo &geo, const LabView &flowLab, const FieldView &u, const FieldView &v, const FieldView &w, const FieldView &p, const OpenView &ox, const OpenView &oy, const OpenView &oz, bool hasOpen, const FaceLabView &faceLab, const KeyView &keyD, const SlotView &slotD, std::size_t nt, const AncView &ancX, const AncView &ancY, const AncView &ancZ, std::array< float, 3 > origin, std::array< float, 3 > spacing, std::array< int, 3 > gdims, const AccView &Q, const AccView &A, const AccView &Cx, const AccView &Cy, const AccView &Cz, const AccView &resid, const AccView &ext)
 Accumulate over every owned +face where the flow-basin label changes: the openness-weighted MAC flux o·u·A into the per-pore residual (signed) and, for interface faces of a throat patch, into the throat's flow (positive lower -> higher label), open area and area-weighted centroid (min-imaged relative to the LOWER pore's peak-voxel anchor anc{X,Y,Z} — integer-derived, so the periodic-image branch is deterministic under FMA wobble).
template<class Geo, class SegView, class SdfView, class FieldView, class PkView, class AccView>
void poreVolume (const Exec &space, const Geo &geo, const SegView &seg, const SdfView &sdf, const FieldView &u, const FieldView &v, const FieldView &w, const FieldView &p, const PkView &pkX, const PkView &pkY, const PkView &pkZ, int np, std::array< int, 3 > gdims, const AccView &acc)
 Per-pore volume sums over the owned FLUID cells (sdf > 0) of each watershed segment (seg, labels 1..np).
ThroatExtras throatExtras (const std::vector< std::pair< int, int > > &throats, const std::vector< double > &ext, const std::vector< double > &throatArea, const std::vector< double > &Cx, const std::vector< double > &Cy, const std::vector< double > &Cz, const std::vector< double > &ancX, const std::vector< double > &ancY, const std::vector< double > &ancZ)
PoreVolumeStats poreVolumeStats (const std::vector< double > &acc, int np, std::array< float, 3 > spacing, const std::vector< double > &ancX, const std::vector< double > &ancY, const std::vector< double > &ancZ)
std::vector< double > throatPressureDrops (const std::vector< std::pair< int, int > > &throats, const std::vector< double > &posX, const std::vector< double > &posY, const std::vector< double > &posZ, const std::vector< double > &porePressure, const std::vector< double > &throatArea, const std::vector< double > &Cx, const std::vector< double > &Cy, const std::vector< double > &Cz, const std::vector< double > &ancX, const std::vector< double > &ancY, const std::vector< double > &ancZ, std::array< float, 3 > spacing, std::array< int, 3 > gdims, std::array< double, 3 > grad_p)
 Total-pressure drop per throat: periodic parts + the macroscopic gradient along the throat- anchored two-leg min-image path i -> throat centroid -> j.
std::vector< double > throatPressureDrops (const std::vector< std::pair< int, int > > &throats, const std::vector< Pore > &pores, const std::vector< double > &porePressure, const std::vector< double > &throatArea, const std::vector< double > &Cx, const std::vector< double > &Cy, const std::vector< double > &Cz, const std::vector< double > &ancX, const std::vector< double > &ancY, const std::vector< double > &ancZ, std::array< float, 3 > spacing, std::array< int, 3 > gdims, std::array< double, 3 > grad_p)
 Pore-centre form (the throat_dp output): positions = the refined pore centres.

Variables

constexpr Index kSent = 0x7ffffffffffffffeLL
 Film-face sentinel of the per-patch throat labelling: "interface face awaiting attachment".
constexpr int kThroatExt = 8
 Number of per-throat momentum/energy sums of throatFlux (ext, layout [c*nt + slot]): c = 0..2 momentum flux x,y,z; 3 kinetic-energy flux; 4..6 open-area-weighted oriented normal x,y,z; 7 pressure-work flux.
constexpr int kPoreVol = 9
 Number of per-pore volume sums of poreVolume (layout [c*np + k]): c = 0 fluid cell count; 1 sum of p; 2 sum of ½|u_c|²; 3..5 sum of u_c x,y,z; 6..8 sum of the integer min-image cell offset x,y,z from the pore's peak voxel.

Typedef Documentation

◆ MD3

using pnm::kernels::MD3 = Kokkos::MDRangePolicy<Exec, Kokkos::Rank<3>>

Definition at line 196 of file pore_kernels.hpp.

◆ R1

using pnm::kernels::R1 = Kokkos::RangePolicy<Exec>

Definition at line 197 of file pore_kernels.hpp.

Function Documentation

◆ ownedRange()

template<class Geo>
MD3 pnm::kernels::ownedRange ( const Exec & space,
const Geo & geo )
inline

◆ isPeak()

template<class Geo, class SdfView>
bool pnm::kernels::isPeak ( const Geo & g,
const SdfView & sdf,
int lx,
int ly,
int lz,
float cv,
Index cgid )

Local SDF maximum under the global (sdf, gid) lexicographic order (26-neighbourhood).

Definition at line 214 of file pore_kernels.hpp.

Referenced by detectPores().

◆ poreAt()

template<class Geo, class SdfView>
Pore pnm::kernels::poreAt ( const Geo & g,
const SdfView & sdf,
int lx,
int ly,
int lz,
float ox,
float oy,
float oz,
float sx,
float sy,
float sz )

The pore record at a peak: sub-voxel position by the SDF^2-weighted centroid of the 3^3 neighbourhood (positive part only), in global (wrapped) integer coords, radius = sdf there.

Definition at line 232 of file pore_kernels.hpp.

Referenced by detectPores().

◆ steepest()

template<class Geo, class SdfView>
Index pnm::kernels::steepest ( const Geo & g,
const SdfView & sdf,
int lx,
int ly,
int lz,
Index cgid,
bool ascent )

Steepest 26-neighbour under the (sdf, gid) lexicographic order: ascent (pores) or descent (solids); returns the neighbour's gid, or cgid itself at a peak.

Ties on value go to the larger gid.

Definition at line 262 of file pore_kernels.hpp.

Referenced by forestInit(), and gradientWalk().

◆ trilinear()

template<class Geo, class FieldView>
double pnm::kernels::trilinear ( const Geo & g,
const FieldView & p,
const double gp[3] )

Trilinear interpolation of a cell-centered periodic field at grid position gp (in cells).

Definition at line 292 of file pore_kernels.hpp.

◆ facesAdjacent()

bool pnm::kernels::facesAdjacent ( int dx,
int dy,
int dz,
int d,
int d2 )

Face adjacency of the per-patch throat CCL: two faces (cell offset (dx,dy,dz), directions d and d2) connect when their doubled center offset satisfies |2*dc + e_d2 - e_d|^2 <= 8 — a generous edge/corner adjacency in pure integer arithmetic (periodic-safe, decomposition- independent).

Definition at line 315 of file pore_kernels.hpp.

Referenced by faceMerge(), and filmAttachSweep().

◆ bsearchKey()

template<class KeyView>
Index pnm::kernels::bsearchKey ( const KeyView & keys,
Index nkeys,
typename KeyView::non_const_value_type key )

Device binary search over a sorted key view; returns the position or -1.

Definition at line 324 of file pore_kernels.hpp.

Referenced by pnm::detail_mpi::applyRemap(), and throatFlux().

◆ detectPores()

template<class Geo, class SdfView, class PoreView, class CountView>
void pnm::kernels::detectPores ( const Exec & space,
const Geo & geo,
const SdfView & sdf,
std::array< float, 3 > origin,
std::array< float, 3 > spacing,
const PoreView & pores,
const CountView & counter,
int maxPores )
inline

Emit the owned peaks (local SDF maxima, sdf > 0) as Pore records into pores (atomic slot counter counter, capacity maxPores).

Definition at line 363 of file pore_kernels.hpp.

References isPeak(), ownedRange(), and poreAt().

Referenced by pnm::extractPoresView().

◆ initMarkers()

template<class Geo, class SdfView, class ParentView>
void pnm::kernels::initMarkers ( const Exec & space,
const Geo & geo,
const SdfView & sdf,
float thr,
const ParentView & parent )
inline

Deep-solid markers: parent(o) = o where sdf < thr, else -1 (owned-dense).

Definition at line 390 of file pore_kernels.hpp.

References ownedRange().

Referenced by pnm::segmentVolumeView().

◆ cclFlatten()

template<class ParentView>
void pnm::kernels::cclFlatten ( const Exec & space,
const ParentView & parent,
std::size_t n )
inline

Path compression: every labelled entry points at its root.

Definition at line 404 of file pore_kernels.hpp.

Referenced by cclFixpoint().

◆ cclMergeMarkers()

template<class Geo, class ParentView, class FlagView>
void pnm::kernels::cclMergeMarkers ( const Exec & space,
const Geo & geo,
const ParentView & parent,
const FlagView & changed )
inline

One union sweep of the marker CCL (26-connectivity, 13 forward neighbours, union-by-min via atomic_min on the larger root).

Owned-owned adjacency only: a periodic neighbour is owned single-rank; a block's cross-block pairs go through its boundary graph.

Definition at line 422 of file pore_kernels.hpp.

References ownedRange().

Referenced by pnm::segmentVolumeView().

◆ cclFixpoint()

template<class ParentView, class FlagView, class MergeFn>
void pnm::kernels::cclFixpoint ( const Exec & space,
const ParentView & parent,
std::size_t n,
const FlagView & changed,
const MergeFn & merge )
inline

Union-find to fixpoint: merge() launches one union sweep (setting changed), then a flatten; repeat until a sweep changes nothing.

Definition at line 461 of file pore_kernels.hpp.

References cclFlatten(), and pnm::readScalar().

Referenced by pnm::segmentVolumeView().

◆ floodSweep()

template<class Geo, class SdfView, class LabelView, class FlagView>
void pnm::kernels::floodSweep ( const Exec & space,
const Geo & geo,
const SdfView & sdf,
const LabelView & labels,
const LabelView & labelsN,
const FlagView & changed )
inline

One Jacobi flood sweep: every unlabelled solid voxel takes the smallest labelled 26-neighbour (reads labels, writes labelsN; the caller swaps).

Labels are voxel ids in the field's label type.

Definition at line 476 of file pore_kernels.hpp.

References ownedRange().

Referenced by floodFixpoint().

◆ floodFixpoint()

template<class Geo, class SdfView, class LabelView, class FlagView, class SyncFn>
void pnm::kernels::floodFixpoint ( const Exec & space,
const Geo & geo,
const SdfView & sdf,
LabelView & labels,
LabelView & labelsN,
const FlagView & changed,
const SyncFn & sync )
inline

Jacobi flood to fixpoint.

Double-buffered: each sweep reads only the previous sweep's labels, so the result is DETERMINISTIC (an in-place sweep could observe same-sweep writes — a device race) and sweep-for-sweep identical between the single-rank and the distributed pipeline. sync(localChanged) -> globalChanged lets a block Allreduce the flag and exchange its ghosts between sweeps (identity single-rank). labels holds the result on return (the views are swapped per sweep).

Definition at line 513 of file pore_kernels.hpp.

References floodSweep(), and pnm::readScalar().

Referenced by pnm::segmentVolumeView().

◆ gradientWalk()

template<class SdfView, class EmitFn>
void pnm::kernels::gradientWalk ( const Exec & space,
const GridGeo & geo,
const SdfView & sdf,
bool ascentAll,
const EmitFn & emit )
inline

Single-rank gradient walk: from every owned cell follow the steepest neighbour (ascent for pores, descent for solids; ascentAll = ascent from every cell, the flow-basin variant) for at most 512 steps; emit(o, walker) receives the end point (a gid == field index here).

GridGeo only — the walk itself does not distribute (its RESULT is the forest root that forestInit + resolveHoldAtGhost compute on a block).

Definition at line 535 of file pore_kernels.hpp.

References steepest().

Referenced by pnm::segmentVolumeView().

◆ forestInit()

template<class Geo, class SdfView, class TargetView, class ChaseFn, class FinalFn, class PeakFn>
void pnm::kernels::forestInit ( const Exec & space,
const Geo & geo,
const SdfView & sdf,
const TargetView & target,
const ChaseFn & chase,
const FinalFn & finalOf,
const PeakFn & peakOf )
inline

Steepest-neighbour forest for the hold-at-ghost root resolution.

target(e) per owned cell: cells with chase(e) false finalize immediately as finalOf(e, gid); chasing cells store the gid of their steepest ascent neighbour, or peakOf(e, gid) when they are a peak. (Negative values are the finalized encoding; a non-negative value is a pending gid.)

Definition at line 562 of file pore_kernels.hpp.

References ownedRange(), and steepest().

◆ resolveHoldAtGhost()

template<class Geo, class TargetView>
int pnm::kernels::resolveHoldAtGhost ( const Exec & space,
const Geo & geo,
const TargetView & target )
inline

One round of pointer jumping with the hold-at-ghost invariant: chase within the field, adopt a finalized (negative) value, or HOLD at the last in-field cell when the next hop leaves the field (never store a gid the field cannot reach — that strands the chase outside the ghost ring).

Returns the number of owned cells still pending.

Definition at line 586 of file pore_kernels.hpp.

Referenced by pnm::detail_mpi::resolveToFixpoint().

◆ boundaryPairs()

template<class Geo, class SegView, class PairView, class CountView>
void pnm::kernels::boundaryPairs ( const Exec & space,
const Geo & geo,
const SegView & seg,
const PairView & pairs,
const CountView & cnt,
Index maxPairs )
inline

Boundary pairs: for every owned cell, the (min,max) label pairs across its +x/+y/+z faces where the label changes, appended to the interleaved pairs (atomic cnt, capacity maxPairs).

Definition at line 630 of file pore_kernels.hpp.

References ownedRange().

Referenced by pnm::extractTopologyView().

◆ uniquePairs()

template<class PairView>
std::vector< std::pair< int, int > > pnm::kernels::uniquePairs ( const PairView & pairs,
std::size_t count )
inline

Interleaved device pairs -> host (l1,l2) list, sorted and unique.

Definition at line 654 of file pore_kernels.hpp.

References pnm::downloadN().

Referenced by pnm::extractTopologyView().

◆ maxLabel()

template<class Geo, class SegView>
int pnm::kernels::maxLabel ( const Exec & space,
const Geo & geo,
const SegView & seg )
inline

The largest label over the owned box (= the number of pore labels).

Definition at line 666 of file pore_kernels.hpp.

◆ faceInit()

template<class Geo, class LabView, class SdfView, class OpenView, class CoreView, class ParentView, class PairView>
void pnm::kernels::faceInit ( const Exec & space,
const Geo & geo,
const LabView & flowLab,
const SdfView & sdf,
const OpenView & ox,
const OpenView & oy,
const OpenView & oz,
bool hasOpen,
const CoreView & core,
const ParentView & parent,
const PairView & fpair )
inline

Interface predicate + CORE tier per owned face: an interface face separates two different positive flow-basin labels with positive openness; CORE = both cells fluid-centered (sdf > 0), which defines the patches by CCL; the rest are FILM faces that attach later.

Writes (owned- dense 3*o+d) core, parent (= f for core faces, -1 otherwise) and fpair ((lo<<32|hi) pair key, -1 for a non-interface face).

Definition at line 694 of file pore_kernels.hpp.

References ownedRange().

◆ faceMerge()

template<class Geo, class ParentView, class PairView, class FlagView>
void pnm::kernels::faceMerge ( const Exec & space,
const Geo & geo,
const ParentView & parent,
const PairView & fpair,
const FlagView & changed )
inline

One union sweep of the face CCL over the faces with parent >= 0 (same pair key + adjacency; owned-owned adjacency only, see cclMergeMarkers).

Definition at line 723 of file pore_kernels.hpp.

References facesAdjacent(), and ownedRange().

◆ faceMinGid()

template<class Geo, class ParentView, class MinView>
void pnm::kernels::faceMinGid ( const Exec & space,
const Geo & geo,
const ParentView & parent,
const MinView & mg )
inline

Per-component minimum GLOBAL face id (3*gid+d) of the local face CCL, keyed by the component root: the decomposition-independent patch label.

mg must be pre-filled with a large value.

Definition at line 769 of file pore_kernels.hpp.

References ownedRange().

◆ faceLabelCore()

template<class ParentView, class PairView, class LabView, class RootFn>
void pnm::kernels::faceLabelCore ( const Exec & space,
std::size_t nf,
const ParentView & parent,
const PairView & fpair,
const LabView & faceLab,
const RootFn & rootOf )
inline

Core-tier labels: faceLab = rootOf(parent) for the CCL'd faces, kSent for the remaining interface (film) faces, -1 for non-interface faces.

rootOf(parentValue) maps a component root to its patch label (identity single-rank; the min global fid of faceMinGid on a block).

Definition at line 787 of file pore_kernels.hpp.

References kSent.

◆ faceLabelLeftover()

template<class ParentView, class LabView, class RootFn>
void pnm::kernels::faceLabelLeftover ( const Exec & space,
std::size_t nf,
const ParentView & parent,
const LabView & faceLab,
const RootFn & rootOf )
inline

Leftover-tier labels: the still-kSent films (their own CCL tier) get rootOf(parent).

Definition at line 798 of file pore_kernels.hpp.

References kSent.

◆ leftoverInit()

template<class ParentView, class LabView>
void pnm::kernels::leftoverInit ( const Exec & space,
std::size_t nf,
const LabView & faceLab,
const ParentView & parent )
inline

Leftover tier init: parent = f for the films no core patch reached, -1 otherwise.

Definition at line 810 of file pore_kernels.hpp.

References kSent.

◆ filmAttachSweep()

template<class Geo, class LabView, class PairView, class CoreView, class NbLab, class NbPair, class FlagView>
void pnm::kernels::filmAttachSweep ( const Exec & space,
const Geo & geo,
const LabView & faceLab,
const PairView & fpair,
const CoreView & core,
const NbLab & nbLab,
const NbPair & nbPair,
const FlagView & changed )
inline

One Jacobi min-propagation sweep of the film attachment: every film face (interface, not core) takes the minimum attached label among its adjacent same-pair faces (nbLab(e, d) / nbPair(e, d) read the neighbour faces — flat single-rank, per-direction exchanged fields on a block).

A film can never bridge two core patches: it only ever adopts, never unions.

Definition at line 825 of file pore_kernels.hpp.

References facesAdjacent(), kSent, and ownedRange().

◆ throatSlots()

ThroatSlots pnm::kernels::throatSlots ( std::vector< std::pair< Index, Index > > rootPair)
inline

◆ faceVelocity()

template<class Geo, class FieldView>
void pnm::kernels::faceVelocity ( const Geo & g,
const FieldView & u,
const FieldView & v,
const FieldView & w,
int lx,
int ly,
int lz,
int d,
double un,
double uf[3] )

Full velocity vector at the centre of the +d face of field cell (lx,ly,lz) (the shared face with the +d neighbour, where the normal MAC component un lives): each tangential component d2 != d is the plain average of the 4 nearest d2-face values — the -d2 and +d2 faces of the cell and of its +d neighbour (u(i,j,k) is the -x face of cell (i,j,k)).

Unweighted by openness: a face value is the fluid velocity of its open part. Reaches field offsets up to +1 along two axes, so a g=1 block suffices.

Definition at line 902 of file pore_kernels.hpp.

Referenced by throatFlux().

◆ throatFlux()

template<class Geo, class LabView, class FieldView, class OpenView, class FaceLabView, class KeyView, class SlotView, class AncView, class AccView>
void pnm::kernels::throatFlux ( const Exec & space,
const Geo & geo,
const LabView & flowLab,
const FieldView & u,
const FieldView & v,
const FieldView & w,
const FieldView & p,
const OpenView & ox,
const OpenView & oy,
const OpenView & oz,
bool hasOpen,
const FaceLabView & faceLab,
const KeyView & keyD,
const SlotView & slotD,
std::size_t nt,
const AncView & ancX,
const AncView & ancY,
const AncView & ancZ,
std::array< float, 3 > origin,
std::array< float, 3 > spacing,
std::array< int, 3 > gdims,
const AccView & Q,
const AccView & A,
const AccView & Cx,
const AccView & Cy,
const AccView & Cz,
const AccView & resid,
const AccView & ext )
inline

Accumulate over every owned +face where the flow-basin label changes: the openness-weighted MAC flux o·u·A into the per-pore residual (signed) and, for interface faces of a throat patch, into the throat's flow (positive lower -> higher label), open area and area-weighted centroid (min-imaged relative to the LOWER pore's peak-voxel anchor anc{X,Y,Z} — integer-derived, so the periodic-image branch is deterministic under FMA wobble).

ext (kThroatExt*nt, zeroed) takes, per throat face of open-area weight w0 = o·A and oriented normal n (+-e_d, lower -> higher label): the momentum flux w0·u_vec·(u·n), the kinetic-energy flux w0·½|u_vec|²·(u·n) (u_vec from faceVelocity), w0·n and the pressure-work flux w0·p_f·(u·n), p_f the mean of the two adjacent cell pressures (the periodic p as passed in). Per unit density; Q, A and the centroid sums are accumulated exactly as before the extension (separate views, same expressions).

Definition at line 931 of file pore_kernels.hpp.

References bsearchKey(), faceVelocity(), and ownedRange().

◆ poreVolume()

template<class Geo, class SegView, class SdfView, class FieldView, class PkView, class AccView>
void pnm::kernels::poreVolume ( const Exec & space,
const Geo & geo,
const SegView & seg,
const SdfView & sdf,
const FieldView & u,
const FieldView & v,
const FieldView & w,
const FieldView & p,
const PkView & pkX,
const PkView & pkY,
const PkView & pkZ,
int np,
std::array< int, 3 > gdims,
const AccView & acc )
inline

Per-pore volume sums over the owned FLUID cells (sdf > 0) of each watershed segment (seg, labels 1..np).

u_c is the cell-centred velocity, the mean of the cell's two MAC faces per component (reaches field offset +1, g=1 suffices). The centroid offset is integer min-image arithmetic relative to the pore's peak voxel pk{X,Y,Z} (global coords; wrapped to [-n/2, n/2) per axis), so it — like the count — is an exact integer sum, independent of the accumulation order. acc (kPoreVol*np) must be zeroed.

Definition at line 1025 of file pore_kernels.hpp.

References ownedRange(), and pnm::wrapc().

◆ throatExtras()

ThroatExtras pnm::kernels::throatExtras ( const std::vector< std::pair< int, int > > & throats,
const std::vector< double > & ext,
const std::vector< double > & throatArea,
const std::vector< double > & Cx,
const std::vector< double > & Cy,
const std::vector< double > & Cz,
const std::vector< double > & ancX,
const std::vector< double > & ancY,
const std::vector< double > & ancZ )
inline

◆ poreVolumeStats()

PoreVolumeStats pnm::kernels::poreVolumeStats ( const std::vector< double > & acc,
int np,
std::array< float, 3 > spacing,
const std::vector< double > & ancX,
const std::vector< double > & ancY,
const std::vector< double > & ancZ )
inline

◆ throatPressureDrops() [1/2]

std::vector< double > pnm::kernels::throatPressureDrops ( const std::vector< std::pair< int, int > > & throats,
const std::vector< double > & posX,
const std::vector< double > & posY,
const std::vector< double > & posZ,
const std::vector< double > & porePressure,
const std::vector< double > & throatArea,
const std::vector< double > & Cx,
const std::vector< double > & Cy,
const std::vector< double > & Cz,
const std::vector< double > & ancX,
const std::vector< double > & ancY,
const std::vector< double > & ancZ,
std::array< float, 3 > spacing,
std::array< int, 3 > gdims,
std::array< double, 3 > grad_p )
inline

Total-pressure drop per throat: periodic parts + the macroscopic gradient along the throat- anchored two-leg min-image path i -> throat centroid -> j.

Every position term cancels except the integer periodic image count k, decided in SNAPPED integer-cell arithmetic (peak-voxel anchors + the bias-rounded throat centroid) so float wobble can never flip the image branch. (A single min-image between the pore centers is ambiguous at exactly half the period.) Position form: pore k sits at (posX, posY, posZ)[k] — any point in the image frame of its peak-voxel anchor (the refined pore centre, or the pore's volume centroid).

Definition at line 1146 of file pore_kernels.hpp.

Referenced by throatPressureDrops().

◆ throatPressureDrops() [2/2]

std::vector< double > pnm::kernels::throatPressureDrops ( const std::vector< std::pair< int, int > > & throats,
const std::vector< Pore > & pores,
const std::vector< double > & porePressure,
const std::vector< double > & throatArea,
const std::vector< double > & Cx,
const std::vector< double > & Cy,
const std::vector< double > & Cz,
const std::vector< double > & ancX,
const std::vector< double > & ancY,
const std::vector< double > & ancZ,
std::array< float, 3 > spacing,
std::array< int, 3 > gdims,
std::array< double, 3 > grad_p )
inline

Pore-centre form (the throat_dp output): positions = the refined pore centres.

Definition at line 1179 of file pore_kernels.hpp.

References throatPressureDrops().

Variable Documentation

◆ kSent

Index pnm::kernels::kSent = 0x7ffffffffffffffeLL
constexpr

Film-face sentinel of the per-patch throat labelling: "interface face awaiting attachment".

Definition at line 206 of file pore_kernels.hpp.

Referenced by faceLabelCore(), faceLabelLeftover(), filmAttachSweep(), and leftoverInit().

◆ kThroatExt

int pnm::kernels::kThroatExt = 8
constexpr

Number of per-throat momentum/energy sums of throatFlux (ext, layout [c*nt + slot]): c = 0..2 momentum flux x,y,z; 3 kinetic-energy flux; 4..6 open-area-weighted oriented normal x,y,z; 7 pressure-work flux.

Definition at line 893 of file pore_kernels.hpp.

◆ kPoreVol

int pnm::kernels::kPoreVol = 9
constexpr

Number of per-pore volume sums of poreVolume (layout [c*np + k]): c = 0 fluid cell count; 1 sum of p; 2 sum of ½|u_c|²; 3..5 sum of u_c x,y,z; 6..8 sum of the integer min-image cell offset x,y,z from the pore's peak voxel.

Definition at line 1016 of file pore_kernels.hpp.