44#ifndef PECLET_VORO_REPAIR_HPP
45#define PECLET_VORO_REPAIR_HPP
48#include <Kokkos_Core.hpp>
51#include "peclet/core/common/view.hpp"
92 using Mem = peclet::core::MemSpace;
93 using Exec = peclet::core::ExecSpace;
94 using PlanePolicy = std::conditional_t<Weighted, Power, Voronoi>;
95 static constexpr bool kHasSdf = !std::is_same_v<Sdf, NoSdf>;
110 Real
L[3] = {1, 1, 1};
170 auto h = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace{},
lastStatus);
171 for (
int i = 0; i <
nProc; ++i) {
185 Kokkos::View<Real*, Mem>
vol;
229 int densityCount_ = -1,
int nProc_ = -1) {
231 nProc = (nProc_ < 0) ? n : nProc_;
236 for (
int k = 0; k < 3; ++k)
241 using Kokkos::view_alloc;
242 using Kokkos::WithoutInitializing;
243 vol = Kokkos::View<Real*, Mem>(
"mt.vol", n);
244 xRef = Kokkos::View<Real*, Mem>(view_alloc(std::string(
"mt.xRef"), WithoutInitializing),
246 mask = Kokkos::View<int*, Mem>(
"mt.mask", n);
247 mask2 = Kokkos::View<int*, Mem>(
"mt.mask2", n);
248 mover = Kokkos::View<int*, Mem>(
"mt.mover", n);
249 rebuilt = Kokkos::View<int*, Mem>(
"mt.rebuilt", n);
250 wl1 = Kokkos::View<int*, Mem>(view_alloc(std::string(
"mt.wl1"), WithoutInitializing), n);
251 wl2 = Kokkos::View<int*, Mem>(view_alloc(std::string(
"mt.wl2"), WithoutInitializing), n);
252 wlM = Kokkos::View<int*, Mem>(view_alloc(std::string(
"mt.wlM"), WithoutInitializing), n);
253 extraNbr = Kokkos::View<int*, Mem>(view_alloc(std::string(
"mt.extraNbr"), WithoutInitializing),
255 extraCnt = Kokkos::View<int*, Mem>(
"mt.extraCnt", n);
256 counter = Kokkos::View<int, Mem>(
"mt.counter");
261 constexpr bool host = Kokkos::SpaceAccessibility<Kokkos::HostSpace, Mem>::accessible;
264 near = Kokkos::View<int*, Mem>(view_alloc(std::string(
"mt.near"), WithoutInitializing),
266 nearCnt = Kokkos::View<int*, Mem>(
"mt.nearCnt", n);
267 nearCounter = Kokkos::View<int, Mem>(
"mt.nearCounter");
271 wallCounter = Kokkos::View<int, Mem>(
"mt.wallCounter");
278 KOKKOS_INLINE_FUNCTION
static void dispFromRef(
const Kokkos::View<Real*, Mem>& P,
279 const Kokkos::View<Real*, Mem>& XR,
int i, Real Lx,
280 Real Ly, Real Lz, Real& dx, Real& dy, Real& dz) {
281 dx = P(3 * i) - XR(3 * i);
282 dy = P(3 * i + 1) - XR(3 * i + 1);
283 dz = P(3 * i + 2) - XR(3 * i + 2);
284 const Real Lxh = Real(0.5) * Lx, Lyh = Real(0.5) * Ly, Lzh = Real(0.5) * Lz;
285 dx = dx > Lxh ? dx - Lx : (dx < -Lxh ? dx + Lx : dx);
286 dy = dy > Lyh ? dy - Ly : (dy < -Lyh ? dy + Ly : dy);
287 dz = dz > Lzh ? dz - Lz : (dz < -Lzh ? dz + Lz : dz);
298 void rebuild(
const Kokkos::View<Real*, Mem>& pos,
bool eagerAdj =
true) {
299 Kokkos::View<long*, Mem> gd;
305 auto res = buildTessellation<Real, Weighted, Sdf>(
306 pos,
weight,
N,
L,
sw,
densityCount, gd,
sdf,
false, nBuild,
store.
np,
308 nullptr,
wall,
false, emitNear ?
near : Kokkos::View<int*, Mem>{},
309 emitNear ?
nearCnt : Kokkos::View<int*, Mem>{}, emitNear ?
kNearCap : 0,
314 Kokkos::deep_copy(
vol, res.view.cellVolume);
315 Kokkos::deep_copy(
xRef, pos);
322 int compact(
const Kokkos::View<int*, Mem>& m,
const Kokkos::View<int*, Mem>& wl) {
327 Kokkos::parallel_for(
328 "mt.compact", Kokkos::RangePolicy<Exec>(0,
nProc), KOKKOS_LAMBDA(
int i) {
330 W(Kokkos::atomic_fetch_add(&c(), 1)) = i;
348 template <
bool Local>
349 void certify(
const Kokkos::View<Real*, Mem>& pos,
const Kokkos::View<int*, Mem>& outMask,
350 const Kokkos::View<int*, Mem>& outMover,
bool useSkin) {
351 Kokkos::deep_copy(outMask, 0);
353 Kokkos::deep_copy(outMover, 0);
360 const bool doExtra =
surgical && useSkin;
373 const Real Lx =
L[0], Ly =
L[1], Lz =
L[2];
374 const Real Lxh = Real(0.5) * Lx, Lyh = Real(0.5) * Ly, Lzh = Real(0.5) * Lz;
375 const Real tolL =
tol, half2 = Real(0.25) *
skin *
skin;
376 const bool skinOn = useSkin;
377 const int nP_ =
nProc;
396 Kokkos::parallel_for(
397 "mt.certify", Kokkos::RangePolicy<Exec>(0,
nProc), KOKKOS_LAMBDA(
int i) {
399 st.
load(i, c, Lx, Ly, Lz);
402 const bool wallOk = Wl.
load(i, c, dx, dy, dz);
405 int* wcPtr = WC.data();
406 const bool wallExactC = wallExactL;
407 const Real wallSkin2C = wallSkin2;
408 const Real* wPtr = Wt.data();
409 Real wSelfI = Real(0);
410 if constexpr (Weighted)
412 c.template reevalGeometry<PlanePolicy>(P(3 * i), P(3 * i + 1), P(3 * i + 2), P.data(), Lx,
421 const unsigned char* pk4 = &Pk4((
size_t)i * MAXT * 4);
422 const Real tl = tolL;
423 if constexpr (Local) {
426 bool fullTest =
false;
427 if constexpr (Weighted)
439 mover = (dx * dx + dy * dy + dz * dz) > half2;
445 int*
const mskPtr = M.data();
446 const int nOwned = nP_;
447 if constexpr (Weighted) {
453 vanish = SdC.eval(P(3 * i), P(3 * i + 1), P(3 * i + 2)) > Real(0);
454 }
else if (!(Vv(i) > Real(0))) {
456 for (
int t = 0; t < c.
nt; ++t) {
459 const int ks[3] = {c.
t0[t], c.
t1[t], c.
t2[t]};
461 const int j = c.
pnbr[k];
462 if (k >= 6 && j >= 0 && j < nOwned)
463 Kokkos::atomic_exchange(&mskPtr[j], 1);
479 const Real seed[3] = {P(3 * i), P(3 * i + 1), P(3 * i + 2)};
482 }
else if (Wl.
cnt(i) > 0) {
483 if (wallExactC || (dx * dx + dy * dy + dz * dz) > wallSkin2C) {
488 if (SdC.eval(seed[0], seed[1], seed[2]) <= Real(0))
490 for (
int t = 0; t < c.
nt && !wflag; ++t)
491 if (c.
alive[t] && SdC.eval(seed[0] + c.
vx[t], seed[1] + c.
vy[t],
492 seed[2] + c.
vz[t]) < Real(-1e-8))
495 }
else if (c.
nt == 0) {
496 wflag = SdC.eval(seed[0], seed[1], seed[2]) > Real(0);
501 Kokkos::atomic_inc(wcPtr);
506 const int nc = NC(i);
510 const Real sx = P(3 * i), sy = P(3 * i + 1), sz = P(3 * i + 2);
511 for (
int q = 0; q < nc; ++q) {
512 const int j = NR((
size_t)i * nearCapL + q);
515 Real rx = P(3 * j) - sx, ry = P(3 * j + 1) - sy, rz = P(3 * j + 2) - sz;
516 rx = rx > Lxh ? rx - Lx : (rx < -Lxh ? rx + Lx : rx);
517 ry = ry > Lyh ? ry - Ly : (ry < -Lyh ? ry + Ly : ry);
518 rz = rz > Lzh ? rz - Lz : (rz < -Lzh ? rz + Lz : rz);
519 const Real pv[3] = {rx, ry, rz};
521 if constexpr (Weighted)
523 const Real off = PlanePolicy::template offsetFromRel<Real>(pv, wSelfI, wN);
524 if (c.
planeGap(pv, off) > Real(0)) {
527 Kokkos::atomic_exchange(&M(j), 1);
532 Kokkos::atomic_inc(&NCtr());
534 if (!ok ||
mover || wflag || nflag)
538 for (
int q = 0; q < nP; ++q)
539 if (partners[q] < nP_)
540 Kokkos::atomic_exchange(&M(partners[q]), 1);
543 for (
int q = 0; q < nP; ++q) {
544 const int cell = partners[q];
545 if (cell < 0 || cell >= nP_)
547 for (
int r = 0; r < nP; ++r) {
550 const int nb = partners[r];
553 const int slot = Kokkos::atomic_fetch_add(&EC(cell), 1);
555 EN((
size_t)cell * kCap + slot) = nb;
570 template <
bool Local>
571 void certifyList(
const Kokkos::View<Real*, Mem>& pos,
const Kokkos::View<int*, Mem>& list,
int n,
572 const Kokkos::View<int*, Mem>& outMask) {
573 Kokkos::deep_copy(outMask, 0);
581 const Real Lx =
L[0], Ly =
L[1], Lz =
L[2];
582 const Real tolL =
tol;
583 const int nP_ =
nProc;
587 Kokkos::parallel_for(
588 "mt.certifyList", Kokkos::RangePolicy<Exec>(0, n), KOKKOS_LAMBDA(
int s) {
589 const int i = list(s);
591 st.
load(i, c, Lx, Ly, Lz);
595 Wl.
load(i, c, dx, dy, dz);
597 const Real* wPtr = Wt.data();
598 Real wSelfI = Real(0);
599 if constexpr (Weighted)
601 c.template reevalGeometry<PlanePolicy>(P(3 * i), P(3 * i + 1), P(3 * i + 2), P.data(), Lx,
607 const unsigned char* pk4 =
608 &Pk4((
size_t)i * MAXT * 4);
609 const Real tl = tolL;
610 if constexpr (Local) {
613 bool fullTest =
false;
614 if constexpr (Weighted)
626 for (
int q = 0; q < nP; ++q)
627 if (partners[q] < nP_)
628 Kokkos::atomic_exchange(&M(partners[q]), 1);
643 const Real Lx =
L[0], Ly =
L[1], Lz =
L[2];
647 Kokkos::parallel_for(
648 "mt.rebuildAdjAll", Kokkos::RangePolicy<Exec>(0,
nProc), KOKKOS_LAMBDA(
int i) {
650 st.
load(i, c, Lx, Ly,
655 Wl.
load(i, c, dx, dy, dz);
657 const Real* wPtr = Wt.data();
658 Real wSelfI = Real(0);
659 if constexpr (Weighted)
661 c.template reevalGeometry<PlanePolicy>(P(3 * i), P(3 * i + 1), P(3 * i + 2), P.data(), Lx,
686 const Kokkos::View<Real*, Mem>& pos) {
692 subsetGather<Real, Weighted, true, Sdf>(grid, wl, n,
store.
np,
store.
nt,
store.
pnbr,
store.
tri,
700 Kokkos::parallel_for(
701 "mt.markRebuilt", Kokkos::RangePolicy<Exec>(0, n), KOKKOS_LAMBDA(
int s) {
704 XR(3 * i) = P(3 * i);
705 XR(3 * i + 1) = P(3 * i + 1);
706 XR(3 * i + 2) = P(3 * i + 2);
713 const Kokkos::View<int*, Mem>& outMask) {
714 Kokkos::deep_copy(outMask, 0);
720 const int nP_ =
nProc;
721 Kokkos::parallel_for(
722 "mt.collectNbrs", Kokkos::RangePolicy<Exec>(0, n), KOKKOS_LAMBDA(
int s) {
724 const int np = st.
np(i), nt = st.
nt(i);
725 for (
int k = 6; k < np; ++k) {
726 const int j = st.
pnbr((
size_t)i * MAXP + k);
727 if (j < 0 || j >= nP_ || rb(j))
730 for (
int t = 0; t < nt; ++t) {
731 const unsigned w = st.
tri((
size_t)i * MAXT + t);
732 if (!((w >> 24) & 1u))
734 const int a = (int)(w & 0xffu), b = (int)((w >> 8) & 0xffu),
735 cc = (
int)((w >> 16) & 0xffu);
736 if (a == k || b == k || cc == k)
740 Kokkos::atomic_exchange(&M(j), 1);
754 const Kokkos::View<Real*, Mem>& pos) {
767 const Real Lx =
L[0], Ly =
L[1], Lz =
L[2];
768 const Real Lxh = Real(0.5) * Lx, Lyh = Real(0.5) * Ly, Lzh = Real(0.5) * Lz;
769 Kokkos::parallel_for(
770 "mt.surgical", Kokkos::RangePolicy<Exec>(0, n), KOKKOS_LAMBDA(
int s) {
774 const Real sx = P(3 * i), sy = P(3 * i + 1), sz = P(3 * i + 2);
775 const int npi = st.
np(i);
776 for (
int k = 6; k < npi && !c.
overflow; ++k) {
777 const int j = st.
pnbr((
size_t)i * MAXP + k);
780 Real rx = P(3 * j) - sx, ry = P(3 * j + 1) - sy, rz = P(3 * j + 2) - sz;
781 rx = rx > Lxh ? rx - Lx : (rx < -Lxh ? rx + Lx : rx);
782 ry = ry > Lyh ? ry - Ly : (ry < -Lyh ? ry + Ly : ry);
783 rz = rz > Lzh ? rz - Lz : (rz < -Lzh ? rz + Lz : rz);
784 const Real nrm[3] = {rx, ry, rz};
785 c.
clip(nrm, Real(0.5) * (rx * rx + ry * ry + rz * rz), j);
787 const int ne = EC(i) < kCap ? EC(i) : kCap;
788 for (
int e = 0; e < ne && !c.
overflow; ++e) {
789 const int j = EN((
size_t)i * kCap + e);
792 Real rx = P(3 * j) - sx, ry = P(3 * j + 1) - sy, rz = P(3 * j + 2) - sz;
793 rx = rx > Lxh ? rx - Lx : (rx < -Lxh ? rx + Lx : rx);
794 ry = ry > Lyh ? ry - Ly : (ry < -Lyh ? ry + Ly : ry);
795 rz = rz > Lzh ? rz - Lz : (rz < -Lzh ? rz + Lz : rz);
796 const Real nrm[3] = {rx, ry, rz};
797 c.
clip(nrm, Real(0.5) * (rx * rx + ry * ry + rz * rz), j);
803 &Pk4((
size_t)i * MAXT * 4));
819 const int dimx = grid.
dimx, dimy = grid.
dimy, dimz = grid.
dimz;
820 const int ncell = dimx * dimy * dimz;
821 if ((
int)
cellFlag.extent(0) < ncell)
823 Kokkos::view_alloc(std::string(
"mt.cellFlag"), Kokkos::WithoutInitializing), ncell);
825 const Real icx = grid.
icx, icy = grid.
icy, icz = grid.
icz;
829 Kokkos::parallel_for(
830 "mt.dilate.count", Kokkos::RangePolicy<Exec>(0,
nProc), KOKKOS_LAMBDA(
int i) {
833 const int gx = ((int)Kokkos::floor(P(3 * i) * icx) % dimx + dimx) % dimx;
834 const int gy = ((int)Kokkos::floor(P(3 * i + 1) * icy) % dimy + dimy) % dimy;
835 const int gz = ((int)Kokkos::floor(P(3 * i + 2) * icz) % dimz + dimz) % dimz;
836 Kokkos::atomic_inc(&CF(gx + gy * dimx + gz * dimx * dimy));
840 Kokkos::parallel_reduce(
841 "mt.dilate.mark", Kokkos::RangePolicy<Exec>(0,
nProc),
842 KOKKOS_LAMBDA(
int i,
long& a) {
845 const int gx = ((int)Kokkos::floor(P(3 * i) * icx) % dimx + dimx) % dimx;
846 const int gy = ((int)Kokkos::floor(P(3 * i + 1) * icy) % dimy + dimy) % dimy;
847 const int gz = ((int)Kokkos::floor(P(3 * i + 2) * icz) % dimz + dimz) % dimz;
849 for (
int dz = -1; dz <= 1; ++dz)
850 for (
int dy = -1; dy <= 1; ++dy)
851 for (
int dx = -1; dx <= 1; ++dx) {
852 const int nx = (gx + dx + dimx) % dimx, ny = (gy + dy + dimy) % dimy,
853 nz = (gz + dz + dimz) % dimz;
854 sum += CF(nx + ny * dimx + nz * dimx * dimy);
868 void certifyDispatch(
const Kokkos::View<Real*, Mem>& pos,
const Kokkos::View<int*, Mem>& outMask,
869 const Kokkos::View<int*, Mem>& outMover,
bool useSkin) {
871 certify<true>(pos, outMask, outMover, useSkin);
873 certify<false>(pos, outMask, outMover, useSkin);
876 int n,
const Kokkos::View<int*, Mem>& outMask) {
878 certifyList<true>(pos, list, n, outMask);
880 certifyList<false>(pos, list, n, outMask);
887 Kokkos::View<long*, Mem>());
950 Kokkos::parallel_for(
951 "mt.surgMask", Kokkos::RangePolicy<Exec>(0,
nProc),
952 KOKKOS_LAMBDA(
int i) { M2(i) = (Msk(i) && !Mv(i)) ? 1 : 0; });
976 for (
int vp = 0; vp <
verifyCap + 1; ++vp) {
Device-native Voronoi tessellation, geometry and finite-volume physics.
Definition convex_cell.hpp:41
@ kOverflow
Definition tessellator.hpp:50
@ kBuried
Definition tessellator.hpp:62
@ kReachExceeded
Definition tessellator.hpp:63
@ kDegenerate
Definition tessellator.hpp:67
@ kIncomplete
Definition tessellator.hpp:52
@ kEmpty
Definition tessellator.hpp:51
KOKKOS_INLINE_FUNCTION bool sdfWouldClip(const ConvexCell< Real, MAXP, MAXT, TrackAdj > &c, const Real seed[3], const Sdf &sdf)
Definition sdf.hpp:552
constexpr int kMaxPlanes
Definition params.hpp:18
constexpr int kMaxTriangles
Definition params.hpp:19
constexpr int kSearchWindow
Definition params.hpp:28
A2a validity diagnostics of a cold (re)build (counts over the maintained cells).
Definition repair.hpp:77
long buried
power cells that are empty (exact — see kBuried)
Definition repair.hpp:78
long empty
cells with no volume (in-solid seeds + empty power cells)
Definition repair.hpp:80
long reachExceeded
cells whose search reach passed half the box (min-image invalid)
Definition repair.hpp:79
long incomplete
cells whose coverage did not close
Definition repair.hpp:82
long degenerate
cells cut through a (near-)cospherical vertex (kDegenerate; valid)
Definition repair.hpp:83
int overBufferRebuilds
over-buffer misses of the build (TessellatorResult)
Definition repair.hpp:84
long overflow
cells that hit a capacity (planes / triangles / facets)
Definition repair.hpp:81
Definition convex_cell.hpp:140
KOKKOS_INLINE_FUNCTION Real volumePerVertex() const
Definition convex_cell.hpp:1585
KOKKOS_INLINE_FUNCTION Real planeGap(const Real pdir[3], Real d) const
Definition convex_cell.hpp:611
KOKKOS_INLINE_FUNCTION bool isLocallyConvexPartners(const unsigned char *poke4, Real tol, int *outPartners, int maxPartners, int &nPartners) const
Definition convex_cell.hpp:537
unsigned char t1[MAXT]
Definition convex_cell.hpp:156
KOKKOS_INLINE_FUNCTION void initBox(Real L0, Real L1, Real L2)
Definition convex_cell.hpp:182
bool overflow
set if MAXP/MAXT exceeded -> cell invalid, caller falls back
Definition convex_cell.hpp:160
int nt
triangle high-water mark
Definition convex_cell.hpp:159
KOKKOS_INLINE_FUNCTION void rebuildAdjacency()
Definition convex_cell.hpp:709
Real vy[MAXT]
Definition convex_cell.hpp:157
KOKKOS_INLINE_FUNCTION bool isSelfConsistentPartners(Real tol, int *outPartners, int maxPartners, int &nPartners) const
Definition convex_cell.hpp:424
int pnbr[MAXP]
neighbour seed id per plane (<0 => bounding box)
Definition convex_cell.hpp:154
Real vx[MAXT]
Definition convex_cell.hpp:157
unsigned char t2[MAXT]
triangle = triple of plane indices
Definition convex_cell.hpp:156
KOKKOS_INLINE_FUNCTION bool clip(const Real pdir[3], Real d, int nbr, Real *gapOut=nullptr)
Definition convex_cell.hpp:895
unsigned char t0[MAXT]
Definition convex_cell.hpp:156
KOKKOS_INLINE_FUNCTION bool anyLiveNegOffset() const
Definition convex_cell.hpp:268
KOKKOS_INLINE_FUNCTION void computePoke4(unsigned char *out) const
Definition convex_cell.hpp:474
bool alive[MAXT]
triangle live flag
Definition convex_cell.hpp:158
Real vz[MAXT]
cached dual-vertex position per triangle
Definition convex_cell.hpp:157
Kokkos::View< int, Mem > nearCounter
Definition repair.hpp:209
void gatherSet(const TessGrid< Real > &grid, const Kokkos::View< int *, Mem > &wl, int n, const Kokkos::View< Real *, Mem > &pos)
Definition repair.hpp:685
bool surgical
repair flip cells by re-clipping known candidates instead of gathering
Definition repair.hpp:145
bool wallExact
re-gather every wall-clipped cell that moved (== cold build)
Definition repair.hpp:214
Kokkos::View< int *, Mem > rebuilt
Definition repair.hpp:218
peclet::core::MemSpace Mem
Definition repair.hpp:92
Kokkos::View< int, Mem > counter
Definition repair.hpp:221
double dilateMaxChurn
Definition repair.hpp:129
void certify(const Kokkos::View< Real *, Mem > &pos, const Kokkos::View< int *, Mem > &outMask, const Kokkos::View< int *, Mem > &outMover, bool useSkin)
Definition repair.hpp:349
Kokkos::View< Real *, Mem > vol
Definition repair.hpp:185
bool useNearMiss
Definition repair.hpp:201
WallStore< Real > wall
persisted wall planes (allocated by alloc() when kHasSdf)
Definition repair.hpp:213
int nProc
Definition repair.hpp:106
Kokkos::View< int *, Mem > mask
Definition repair.hpp:218
void certifyDispatch(const Kokkos::View< Real *, Mem > &pos, const Kokkos::View< int *, Mem > &outMask, const Kokkos::View< int *, Mem > &outMover, bool useSkin)
Definition repair.hpp:868
Kokkos::View< int *, Mem > mask2
Definition repair.hpp:218
int densityCount
Definition repair.hpp:109
bool localCert
Definition repair.hpp:149
peclet::core::ExecSpace Exec
Definition repair.hpp:93
Kokkos::View< int *, Mem > cellFlag
Definition repair.hpp:219
int lastOverBufferRebuilds
of the last cold (re)build (BuildReport)
Definition repair.hpp:120
void surgicalRepair(const Kokkos::View< int *, Mem > &wl, int n, const Kokkos::View< Real *, Mem > &pos)
Definition repair.hpp:753
int N
total cells in the resident arrays (single-domain: all; MPI: owned+ghost)
Definition repair.hpp:105
Kokkos::View< int, Mem > wallCounter
Definition repair.hpp:216
void rebuild(const Kokkos::View< Real *, Mem > &pos, bool eagerAdj=true)
Definition repair.hpp:298
RepairStats step(const Kokkos::View< Real *, Mem > &pos)
One moving-point update step. Updates store + vol in place from pos.
Definition repair.hpp:884
Kokkos::View< Real *, Mem > xRef
Definition repair.hpp:186
bool profile
the cold build's timing / over-buffer report on stderr
Definition repair.hpp:119
Real L[3]
Definition repair.hpp:110
void certifyList(const Kokkos::View< Real *, Mem > &pos, const Kokkos::View< int *, Mem > &list, int n, const Kokkos::View< int *, Mem > &outMask)
Definition repair.hpp:571
int gridNcell
Definition repair.hpp:222
void alloc(int n, const Real Lbox[3], Real tol_, Real skin_, int sw_=kSearchWindow, int densityCount_=-1, int nProc_=-1)
Definition repair.hpp:228
bool adjFresh
Definition repair.hpp:157
int clusterNbhd
Definition repair.hpp:132
bool dilate(const TessGrid< Real > &grid, const Kokkos::View< Real *, Mem > &pos)
Definition repair.hpp:818
Kokkos::View< int *, Mem > extraCnt
Definition repair.hpp:220
bool useDilation
Definition repair.hpp:121
Real nearMarginFrac
margin = nearMarginFrac · skin
Definition repair.hpp:203
bool nearFresh
Definition repair.hpp:204
Kokkos::View< Real *, Mem > weight
Definition repair.hpp:187
static KOKKOS_INLINE_FUNCTION void dispFromRef(const Kokkos::View< Real *, Mem > &P, const Kokkos::View< Real *, Mem > &XR, int i, Real Lx, Real Ly, Real Lz, Real &dx, Real &dy, Real &dz)
Definition repair.hpp:278
Kokkos::View< int *, Mem > wl1
Definition repair.hpp:218
int verifyCap
max verify extra-passes before falling back to a full rebuild
Definition repair.hpp:114
static constexpr bool kHasSdf
Definition repair.hpp:95
Real skin
Verlet skin width (absolute); a particle moving > skin/2 is a Pass-1 mover.
Definition repair.hpp:113
void maybeBuildAdj(const Kokkos::View< Real *, Mem > &pos)
Definition repair.hpp:673
Kokkos::View< int *, Mem > extraNbr
Definition repair.hpp:220
Kokkos::View< int *, Mem > mover
Definition repair.hpp:218
bool useGate
high-churn → rebuild routing (the "never slower than rebuild" guard)
Definition repair.hpp:118
Kokkos::View< int *, Mem > wlM
Definition repair.hpp:218
Kokkos::View< int *, Mem > lastStatus
Definition repair.hpp:164
int compact(const Kokkos::View< int *, Mem > &m, const Kokkos::View< int *, Mem > &wl)
Compact the nonzero entries of m[0..nProc) into wl, returning the count.
Definition repair.hpp:322
bool useLocalNow
this step's certify uses the local cert (= localCert && adjFresh)
Definition repair.hpp:162
int sw
Definition repair.hpp:109
BuildReport report() const
A2a validity diagnostics of the last cold (re)build (counts over the maintained cells).
Definition repair.hpp:166
Sdf sdf
the geometry provider (replicated on every rank under MPI)
Definition repair.hpp:212
void rebuildAdjAll(const Kokkos::View< Real *, Mem > &pos)
Definition repair.hpp:637
void setWeights(const Kokkos::View< Real *, Mem > &w)
Set the per-seed power weights (Weighted only). Held by reference; the caller keeps it alive.
Definition repair.hpp:191
Kokkos::View< int *, Mem > near
Definition repair.hpp:208
Kokkos::View< int *, Mem > wl2
Definition repair.hpp:218
std::conditional_t< Weighted, Power, Voronoi > PlanePolicy
Definition repair.hpp:94
Kokkos::View< int *, Mem > nearCnt
Definition repair.hpp:208
Real tol
certificate tolerance (absolute distance); ~1e-4·spacing FP64, ~2e-3·spacing FP32
Definition repair.hpp:111
static constexpr int kExtraCap
per-cell capacity for partner-discovered new neighbours
Definition repair.hpp:147
int kNearCap
per-cell list capacity (overflow ⇒ re-gather every step)
Definition repair.hpp:202
double churnThresh
Definition repair.hpp:126
void certifyListDispatch(const Kokkos::View< Real *, Mem > &pos, const Kokkos::View< int *, Mem > &list, int n, const Kokkos::View< int *, Mem > &outMask)
Definition repair.hpp:875
Store store
Definition repair.hpp:184
Real wallSkin
skin mode (wallExact=false): re-gather a wall cell only past this
Definition repair.hpp:215
void collectNewNbrs(const Kokkos::View< int *, Mem > &wl, int n, const Kokkos::View< int *, Mem > &outMask)
Definition repair.hpp:712
Sentinel "no geometry" provider — the default; the clip stage is skipped.
Definition sdf.hpp:39
Per-step repair telemetry.
Definition repair.hpp:61
int wallFlagged
cells flagged by the SDF boundary watch (0 without an SDF)
Definition repair.hpp:70
int extra
cells gathered across the verify extra-passes
Definition repair.hpp:67
int pass1
cells gathered in Pass 1 (flagged ∪ partners ∪ skin-movers, after dilation)
Definition repair.hpp:64
int surgical
Pass-1 cells repaired surgically (Phase 4, no grid gather)
Definition repair.hpp:68
int pass2
cells gathered in Pass 2 (new face-neighbours of the movers)
Definition repair.hpp:66
bool fellBack
true if the cold-build fallback was triggered (repair did not close)
Definition repair.hpp:73
Route route
Definition repair.hpp:72
int pass1Raw
flagged count BEFORE dilation (the gate signal: pass1Raw/nProc = churn)
Definition repair.hpp:65
Route
Which path the Phase-3 adaptive gate took this step.
Definition repair.hpp:63
@ kDilated
Definition repair.hpp:63
@ kTwoPass
Definition repair.hpp:63
@ kRebuildGate
Definition repair.hpp:63
int nearFlagged
cells flagged by the near-miss (face-gain) check
Definition repair.hpp:71
int verifyPasses
number of verify iterations run
Definition repair.hpp:69
Definition tess_grid.hpp:56
int dimz
Definition tess_grid.hpp:71
int dimy
Definition tess_grid.hpp:71
int dimx
Definition tess_grid.hpp:71
Real icz
Definition tess_grid.hpp:70
Real icx
Definition tess_grid.hpp:70
Real icy
Definition tess_grid.hpp:70
Definition topology_store.hpp:39
void alloc(int n)
Definition topology_store.hpp:53
Kokkos::View< int *, MemSpace > np
Definition topology_store.hpp:42
Kokkos::View< unsigned char *, MemSpace > poke4
Definition topology_store.hpp:47
KOKKOS_INLINE_FUNCTION void load(int i, Cell &c, Real L0, Real L1, Real L2) const
Definition topology_store.hpp:93
Kokkos::View< unsigned *, MemSpace > tri
Definition topology_store.hpp:45
KOKKOS_INLINE_FUNCTION void save(int i, const Cell &c) const
Persist cell c at slot i (call after the cell is finalised — clipped + complete).
Definition topology_store.hpp:75
Kokkos::View< int *, MemSpace > nt
Definition topology_store.hpp:43
Kokkos::View< int *, MemSpace > pnbr
Definition topology_store.hpp:44
void allocPoke4()
Definition topology_store.hpp:67
Kokkos::View< int *, MemSpace > cnt
Definition sdf.hpp:356
KOKKOS_INLINE_FUNCTION bool load(int i, Cell &c, Real dx, Real dy, Real dz) const
Definition sdf.hpp:393