57#ifndef PECLET_FLOW_VOF_BLOCK_CONTAINER_HPP
58#define PECLET_FLOW_VOF_BLOCK_CONTAINER_HPP
64#include <Kokkos_Core.hpp>
72#include "peclet/core/decomp/block_decomposer.hpp"
92 int n(
int d)
const {
return hi[d] -
lo[d]; }
93 long cells()
const {
return static_cast<long>(
n(0)) *
n(1) *
n(2); }
94 bool empty()
const {
return n(0) <= 0 ||
n(1) <= 0 ||
n(2) <= 0; }
99 for (
int d = 0; d < 3; ++d)
100 if (o.lo[d] <
lo[d] || o.hi[d] >
hi[d])
105 for (
int d = 0; d < 3; ++d)
106 if (
lo[d] != o.lo[d] ||
hi[d] != o.hi[d])
114 for (
int d = 0; d < 3; ++d) {
123 for (
int d = 0; d < 3; ++d) {
124 r.lo[d] = a.lo[d] > b.lo[d] ? a.lo[d] : b.lo[d];
125 r.hi[d] = a.hi[d] < b.hi[d] ? a.hi[d] : b.hi[d];
155 const int s = a < -outside ? -outside : a;
156 const int e = b > gs + outside ? gs + outside : b;
158 out[n++] =
VofRun{s, e - s, s - a};
162 throw std::runtime_error(
"peclet::flow::vof: block range exceeds three periodic images");
164 while (k < b && n < 5) {
165 const int w = ((k % gs) + gs) % gs;
169 out[n++] =
VofRun{w, len, k - a};
178 const int g[3] = {gs.x, gs.y, gs.z};
179 for (
int d = 0; d < 3; ++d) {
190 if (b.hi[d] <= b.lo[d]) {
192 b.hi[d] = g[d] < 1 ? 1 : g[d];
217inline void vofAssignLpt(
const std::vector<long>& w,
int size, std::vector<int>& master) {
218 const std::size_t n = w.size();
220 if (n == 0 || size <= 1)
222 std::vector<std::size_t> ord(n);
223 for (std::size_t i = 0; i < n; ++i)
227 std::stable_sort(ord.begin(), ord.end(),
228 [&](std::size_t a, std::size_t b) { return w[a] > w[b]; });
229 std::vector<long> load(
static_cast<std::size_t
>(size), 0);
230 for (std::size_t k = 0; k < n; ++k) {
232 for (
int r = 1; r < size; ++r)
233 if (load[
static_cast<std::size_t
>(r)] < load[
static_cast<std::size_t
>(best)])
235 master[ord[k]] = best;
236 load[
static_cast<std::size_t
>(best)] += w[ord[k]];
246inline void vofAssignOrb(
const std::vector<long>& w,
int size, std::vector<int>& master) {
247 const std::size_t n = w.size();
249 if (n == 0 || size <= 1)
251 std::vector<peclet::core::Real> wr(n);
252 for (std::size_t i = 0; i < n; ++i)
253 wr[i] =
static_cast<peclet::core::Real
>(w[i]);
254 peclet::core::decomp::BlockDecomposer<1> dec(
255 static_cast<std::size_t
>(size),
256 peclet::core::IVec<1>{
static_cast<peclet::core::Index
>(n)}, wr);
257 for (
int r = 0; r < size; ++r) {
258 const auto b = dec.block(
static_cast<std::size_t
>(r));
259 for (
auto i = b.origin[0]; i < b.origin[0] + b.size[0]; ++i)
260 master[
static_cast<std::size_t
>(i)] = r;
322 bool mine()
const {
return mine_; }
340 for (
int d = 0; d < 3; ++d)
341 out[d] = prevCentroid_[d];
342 out[3] = hasPrev_ ? 1.0 : 0.0;
343 out[4] = st_.debrisReturned;
344 out[5] = st_.debrisLost;
345 out[6] =
static_cast<double>(st_.debrisUnresolved);
346 out[7] = st_.discarded;
347 out[8] =
static_cast<double>(st_.fullAxis);
348 out[9] = st_.residueReturned;
351 for (
int d = 0; d < 3; ++d)
352 prevCentroid_[d] = in[d];
353 hasPrev_ = (in[3] != 0.0);
354 st_.debrisReturned = in[4];
355 st_.debrisLost = in[5];
356 st_.debrisUnresolved =
static_cast<long>(in[6]);
357 st_.discarded = in[7];
358 st_.fullAxis =
static_cast<long>(in[8]);
359 st_.residueReturned = in[9];
366 bool allocated_ =
false;
371 double prevCentroid_[3]{0, 0, 0};
372 bool hasPrev_ =
false;
398 virtual void syncTable(std::vector<VofBlock>& blocks) = 0;
411 throw std::runtime_error(
"peclet::flow::vof: this block exchange has no colour SUM scatter");
416 virtual void migrateColour(std::vector<VofBlock>& blocks,
const std::vector<int>& oldMaster) = 0;
452 for (
auto& b : blocks_) {
457 const VofMetric&
metric()
const {
return metric_; }
459 void setExchange(std::shared_ptr<VofBlockExchangeBase> x) { exch_ = std::move(x); }
463 int ghost()
const {
return ghost_; }
533 for (
auto& b : blocks_)
535 b.adv_.wispEps = eps;
536 b.curv_.pureEps = eps;
576 std::size_t
count()
const {
return blocks_.size(); }
583 const std::vector<VofBlock>&
blocks()
const {
return blocks_; }
584 long step()
const {
return step_; }
590 int masterOf(
long id)
const {
return static_cast<int>(
id % size_); }
598 void seedSphere(
double cx,
double cy,
double cz,
double r,
int subLevels = 4,
int extraPad = 0) {
601 const double c[3] = {cx, cy, cz};
602 for (
int d = 0; d < 3; ++d) {
603 bb.
lo[d] =
static_cast<int>(std::floor((c[d] - r) / h_)) - 1;
604 bb.
hi[d] =
static_cast<int>(std::ceil((c[d] + r) / h_)) + 1;
607 b.id =
static_cast<long>(blocks_.size());
610 b.mine_ = (b.master == rank_);
611 blocks_.push_back(std::move(b));
612 const std::size_t idx = blocks_.size() - 1;
615 for (std::size_t k = 0; k + 1 < blocks_.size(); ++k)
616 if (blocks_[k].mine_ && blocks_[k].allocated_)
621 const I3 e = nb.adv_.extent();
622 const int g = ghost_;
623 const I3 o = nb.box.origin();
624 const double hh = h_;
625 SField cf = nb.adv_.colour();
626 Kokkos::parallel_for(
627 "vof::block::seed_sphere",
629 KOKKOS_LAMBDA(
int x,
int y,
int z) {
630 const double gx = (x - g + o.x) * hh, gy = (y - g + o.y) * hh, gz = (z - g + o.z) * hh;
631 cf(
L3(x, y, z, e)) = sphereCellFraction(cx, cy, cz, r, gx, gy, gz, hh, subLevels);
646 throw std::runtime_error(
"peclet::flow::vof::VofBlockSet: no exchange installed");
647 exch_->gatherFaceVel(blocks_, ghost_);
648 std::vector<VofBlock*> deb;
654 for (
auto& b : blocks_) {
658 b.adv_.advect(dt, step_);
659 b.st_.recentred =
false;
675 for (std::size_t k = 0; k < blocks_.size(); ++k)
676 if (blocks_[k].mine_)
679 exch_->syncTable(blocks_);
680 for (
auto& b : blocks_)
681 b.mine_ = (b.master == rank_);
688 exch_->scatterColourMax(blocks_, cLocal);
692 for (
auto& b : blocks_)
710 for (std::size_t i = 0; i < blocks_.size(); ++i)
711 if (blocks_[i].mine_ && blocks_[i].allocated_)
719 throw std::runtime_error(
"peclet::flow::vof::VofBlockSet: no exchange installed");
723 exch_->scatterForceSum(blocks_, fx, fy, fz);
729 for (
auto& b : blocks_)
730 if (b.mine_ && !b.curv_.useWorklist)
733 std::vector<VofCurvFallbackJob> jobs;
734 for (
auto& b : blocks_)
736 b.curv_.computeBegin(b.adv_.colour());
737 jobs.push_back(b.curv_.fallbackJob(b.adv_.colour()));
741 for (
auto& b : blocks_) {
745 batch ? b.curv_.computeEnd() : b.curv_.compute(b.adv_.colour());
746 curvStats_.interfacial += st.interfacial;
747 curvStats_.hf += st.hf;
748 curvStats_.hfMixed += st.hfMixed;
749 curvStats_.hfFit += st.hfFit;
750 curvStats_.pv += st.pv;
751 curvStats_.pvReduced += st.pvReduced;
752 curvStats_.noEstimate += st.noEstimate;
753 curvStats_.clipped += st.clipped;
756 exch_->scatterForceSum(blocks_, fx, fy, fz);
764 for (
auto& b : blocks_)
765 b.curv_.kappaMax = km;
770 const I3 n = b.adv_.inner();
771 b.curv_.init(n.x, n.y, n.z, ghost_);
777 const long len =
static_cast<long>(b.adv_.extent().x) * b.adv_.extent().y * b.adv_.extent().z;
778 for (
int c = 0; c < 3; ++c)
779 b.f_[c] =
SField(
"vof::block::csf", len);
789 const I3 e = b.adv_.extent(), n = b.adv_.inner();
790 const int g = ghost_;
793 const double sig =
sigma;
794 const double wgt[3] = {metric_.h[0] * metric_.h[0], metric_.h[1] * metric_.h[1],
795 metric_.h[2] * metric_.h[2]};
796 SField cv = b.adv_.colour(), kp = b.curv_.kappa(), kb = b.curv_.branch();
797 const long sy = e.x, sz =
static_cast<long>(e.x) * e.y;
798 for (
int c = 0; c < 3; ++c) {
800 const double wc = wgt[c];
801 const long strd = (c == 0) ? 1 : (c == 1 ? sy : sz);
802 Kokkos::parallel_for(
803 "vof::block::csf_force",
805 {g + n.x, g + n.y, g + n.z}),
806 KOKKOS_LAMBDA(
int x,
int y,
int z) {
807 const long i =
L3(x, y, z, e);
808 const double dC = cv(i) - cv(i - strd);
823 throw std::runtime_error(
"peclet::flow::vof::VofBlockSet: no exchange installed");
824 exch_->scatterColourSum(blocks_, sLocal);
830 throw std::runtime_error(
"peclet::flow::vof::VofBlockSet: no exchange installed");
831 exch_->syncTable(blocks_);
832 exch_->scatterColourMax(blocks_, cLocal);
841 std::vector<long> w(blocks_.size());
842 for (std::size_t i = 0; i < blocks_.size(); ++i)
843 w[i] = blocks_[i].box.cells();
854 m.assign(blocks_.size(), 0);
855 for (std::size_t i = 0; i < blocks_.size(); ++i)
856 m[i] =
static_cast<int>(blocks_[i].
id % size_);
867 if (blocks_.empty() || size_ <= 1)
870 std::vector<int> old(blocks_.size());
872 for (std::size_t i = 0; i < blocks_.size(); ++i) {
873 old[i] = blocks_[i].master;
874 if (old[i] != want[i])
879 for (std::size_t i = 0; i < blocks_.size(); ++i) {
880 blocks_[i].master = want[i];
881 blocks_[i].st_.master = want[i];
884 for (std::size_t i = 0; i < blocks_.size(); ++i)
885 if (want[i] == rank_ && old[i] != rank_) {
886 blocks_[i].mine_ =
true;
890 exch_->migrateColour(blocks_, old);
891 for (std::size_t i = 0; i < blocks_.size(); ++i) {
892 if (old[i] == rank_ && want[i] != rank_) {
894 blocks_[i].mine_ =
false;
895 }
else if (want[i] == rank_ && old[i] != rank_) {
898 blocks_[i].mine_ =
true;
901 blocks_[i].serializeAux(aux);
903 blocks_[i].deserializeAux(aux);
919 b.id =
static_cast<long>(blocks_.size());
920 b.master =
static_cast<int>(b.id % size_);
923 b.mine_ = (b.master == rank_);
924 blocks_.push_back(std::move(b));
925 const std::size_t idx = blocks_.size() - 1;
926 for (std::size_t k = 0; k + 1 < blocks_.size(); ++k)
927 if (blocks_[k].mine_ && blocks_[k].allocated_)
929 if (blocks_[idx].mine_)
936 throw std::runtime_error(
"peclet::flow::vof::VofBlockSet: no exchange installed");
938 exch_->gatherColour(blocks_, cLocal);
939 for (
auto& b : blocks_)
961 if (!b.mine_ || !b.allocated_)
963 const I3 n = b.adv_.inner();
964 SField c = b.adv_.colour();
965 auto hc = Kokkos::create_mirror_view(c);
966 Kokkos::deep_copy(hc, c);
967 std::vector<double> out(
static_cast<std::size_t
>(n.x) *
static_cast<std::size_t
>(n.y) *
968 static_cast<std::size_t
>(n.z));
970 for (
int z = 0; z < n.z; ++z)
971 for (
int y = 0; y < n.y; ++y)
972 for (
int x = 0; x < n.x; ++x)
973 out[q++] = hc(b.adv_.index(x, y, z));
983 const I3 n = b.adv_.inner();
984 SField k = b.curv_.kappa();
985 auto hk = Kokkos::create_mirror_view(k);
986 Kokkos::deep_copy(hk, k);
987 std::vector<double> out(
static_cast<std::size_t
>(n.x) *
static_cast<std::size_t
>(n.y) *
988 static_cast<std::size_t
>(n.z));
990 for (
int z = 0; z < n.z; ++z)
991 for (
int y = 0; y < n.y; ++y)
992 for (
int x = 0; x < n.x; ++x)
993 out[q++] = hk(b.adv_.index(x, y, z));
1003 b.id =
static_cast<long>(blocks_.size());
1006 b.mine_ = (b.master == rank_);
1007 blocks_.push_back(std::move(b));
1008 const std::size_t idx = blocks_.size() - 1;
1009 for (std::size_t k = 0; k + 1 < blocks_.size(); ++k)
1010 if (blocks_[k].mine_ && blocks_[k].allocated_)
1012 if (!blocks_[idx].mine_)
1016 const I3 n = nb.adv_.inner();
1017 const std::size_t want =
static_cast<std::size_t
>(n.x) *
static_cast<std::size_t
>(n.y) *
1018 static_cast<std::size_t
>(n.z);
1019 if (
colour.size() != want)
1020 throw std::runtime_error(
1021 "peclet::flow::vof::VofBlockSet::seedBoxWithColour: colour size does not match the box");
1022 SField c = nb.adv_.colour();
1023 auto hc = Kokkos::create_mirror_view(c);
1024 Kokkos::deep_copy(hc, c);
1026 for (
int z = 0; z < n.z; ++z)
1027 for (
int y = 0; y < n.y; ++y)
1028 for (
int x = 0; x < n.x; ++x)
1029 hc(nb.adv_.index(x, y, z)) =
colour[q++];
1030 Kokkos::deep_copy(c, hc);
1043 const I3 e = b.adv_.extent(), n = b.adv_.inner(), o = b.box.origin();
1044 const int g = ghost_;
1045 const int lx = b.seed_.lo[0], hx = b.seed_.hi[0], ly = b.seed_.lo[1], hy = b.seed_.hi[1],
1046 lz = b.seed_.lo[2], hz = b.seed_.hi[2];
1047 if (hx <= lx || hy <= ly || hz <= lz)
1049 SField c = b.adv_.colour();
1050 Kokkos::parallel_for(
1051 "vof::block::clip_seed",
1053 KOKKOS_LAMBDA(
int x,
int y,
int z) {
1054 const int gx = x + o.x, gy = y + o.y, gz = z + o.z;
1055 if (gx < lx || gx >= hx || gy < ly || gy >= hy || gz < lz || gz >= hz)
1056 c(
L3(x + g, y + g, z + g, e)) = 0.0;
1064 const I3 e = b.adv_.extent(), n = b.adv_.inner(), o = b.box.origin();
1065 const int g = ghost_;
1066 SField f = b.adv_.colour();
1068 Kokkos::parallel_for(
1069 "vof::block::ghost_zero",
1071 KOKKOS_LAMBDA(
int x,
int y,
int z) {
1072 if (x >= g && x < g + n.x && y >= g && y < g + n.y && z >= g && z < g + n.z)
1074 f(
L3(x, y, z, e)) = 0.0;
1077 const bool sx = per_[0] && b.box.n(0) == gs_.x;
1078 const bool sy = per_[1] && b.box.n(1) == gs_.y;
1079 const bool sz = per_[2] && b.box.n(2) == gs_.z;
1084 if (!per_[0] || !per_[1] || !per_[2])
1095 std::vector<VofBlockStats> v;
1096 v.reserve(blocks_.size());
1097 for (
const auto& b : blocks_) {
1100 q.master = b.master;
1101 for (
int d = 0; d < 3; ++d) {
1102 q.lo[d] = b.box.lo[d];
1103 q.hi[d] = b.box.hi[d];
1105 q.cells = b.box.cells();
1114 void masterCensus(std::vector<long>& masters, std::vector<long>& cells)
const {
1115 masters.assign(size_, 0);
1116 cells.assign(size_, 0);
1117 for (
const auto& b : blocks_) {
1118 masters[b.master] += 1;
1124 std::vector<long> m, c;
1126 long tot = 0, mx = 0;
1129 mx = v > mx ? v : mx;
1133 return static_cast<double>(mx) * size_ /
static_cast<double>(tot);
1145 void installHook(std::size_t idx) {
1150 void allocate(std::size_t idx) {
1151 VofBlock& b = blocks_[idx];
1152 b.adv_ = acquireAdvector(b.box.n(0), b.box.n(1), b.box.n(2));
1154 b.allocated_ =
true;
1156 b.st_.master = b.master;
1163 void release(std::size_t idx) {
1164 VofBlock& b = blocks_[idx];
1165 retireAdvector(std::move(b.adv_));
1168 for (
int c = 0; c < 3; ++c)
1170 b.allocated_ =
false;
1180 WyAdvector acquireAdvector(
int nx,
int ny,
int nz) {
1181 const std::array<int, 3>
key{nx,
ny, nz};
1183 auto it = pool_.find(key);
1184 if (it != pool_.end() && !
it->second.empty()) {
1185 WyAdvector
a = std::move(
it->second.back());
1186 it->second.pop_back();
1189 Kokkos::deep_copy(
SExec(),
a.colour(), 0.0);
1190 for (
int d = 0;
d < 3; ++
d)
1191 Kokkos::deep_copy(
SExec(),
a.faceVel(d), 0.0);
1192 SExec().fence(
"vof::block::pool_reset");
1196 a.globalMax =
nullptr;
1197 a.exchange =
nullptr;
1203 a.init(nx, ny, nz, h_, ghost_);
1207 a.globalMax =
nullptr;
1211 void retireAdvector(WyAdvector&& a) {
1212 if (!
usePool ||
a.colour().extent(0) == 0)
1214 const I3
n =
a.inner();
1215 const std::array<int, 3>
key{
n.x,
n.y,
n.z};
1216 auto&
v = pool_[
key];
1219 a.exchange =
nullptr;
1220 v.push_back(std::move(a));
1236 const I3 e = b.adv_.extent(), n = b.adv_.inner();
1237 const int g = ghost_;
1239 SField c = b.adv_.colour();
1240 int lo[3] = {n.x, n.y, n.z}, hi[3] = {-1, -1, -1};
1242 MD pol(
SExec(), {g, g, g}, {g + n.x, g + n.y, g + n.z});
1243 Kokkos::parallel_reduce(
1244 "vof::block::bbox_lo", pol,
1245 KOKKOS_LAMBDA(
int x,
int y,
int z,
int& lx,
int& ly,
int& lz) {
1246 if (!(Kokkos::fabs(c(
L3(x, y, z, e))) > eps))
1248 const int px = x - g, py = y - g, pz = z - g;
1249 lx = px < lx ? px : lx;
1250 ly = py < ly ? py : ly;
1251 lz = pz < lz ? pz : lz;
1253 Kokkos::Min<int>(lo[0]), Kokkos::Min<int>(lo[1]), Kokkos::Min<int>(lo[2]));
1254 Kokkos::parallel_reduce(
1255 "vof::block::bbox_hi", pol,
1256 KOKKOS_LAMBDA(
int x,
int y,
int z,
int& hx,
int& hy,
int& hz) {
1257 if (!(Kokkos::fabs(c(
L3(x, y, z, e))) > eps))
1259 const int px = x - g, py = y - g, pz = z - g;
1260 hx = px > hx ? px : hx;
1261 hy = py > hy ? py : hy;
1262 hz = pz > hz ? pz : hz;
1264 Kokkos::Max<int>(hi[0]), Kokkos::Max<int>(hi[1]), Kokkos::Max<int>(hi[2]));
1268 for (
int d = 0; d < 3; ++d) {
1269 out.lo[d] = lo[d] + b.box.lo[d];
1270 out.hi[d] = hi[d] + 1 + b.box.lo[d];
1287 bool wasteful =
false;
1289 for (
int d = 0; d < 3; ++d)
1290 if (b.box.n(d) > need.
n(d) + 2 * (margin_ +
recentrePad))
1292 if (b.box.contains(need) && !wasteful)
1301 const int L[3] = {gs_.x, gs_.y, gs_.z};
1303 bool anyWrap =
false;
1304 for (
int d = 0; d < 3; ++d) {
1305 wrap[d] = per_[d] && nb.n(d) == L[d];
1306 anyWrap = anyWrap || (
wrap[d] && want.n(d) >= L[d]);
1313 WyAdvector fresh = acquireAdvector(nb.n(0), nb.n(1), nb.n(2));
1314 const I3 se = b.adv_.extent(), de = fresh.
extent();
1316 const int g = ghost_;
1317 const int sx = b.box.lo[0], sy = b.box.lo[1], sz = b.box.lo[2];
1318 const int snx = b.box.n(0), sny = b.box.n(1), snz = b.box.n(2);
1319 const int dx = nb.lo[0], dy = nb.lo[1], dz = nb.lo[2];
1321 const int Lx = L[0], Ly = L[1], Lz = L[2];
1323 Kokkos::parallel_for(
1324 "vof::block::recentre_copy",
1326 KOKKOS_LAMBDA(
int x,
int y,
int z) {
1327 const int gx = x + dx, gy = y + dy, gz = z + dz;
1328 int lx = gx - sx, ly = gy - sy, lz = gz - sz;
1330 lx = ((lx % Lx) + Lx) % Lx;
1332 ly = ((ly % Ly) + Ly) % Ly;
1334 lz = ((lz % Lz) + Lz) % Lz;
1336 if (lx >= 0 && lx < snx && ly >= 0 && ly < sny && lz >= 0 && lz < snz)
1337 v = src(
L3(lx + g, ly + g, lz + g, se));
1338 dst(
L3(x + g, y + g, z + g, de)) = v;
1340 SExec().fence(
"vof::block::recentre_copy");
1342 retireAdvector(std::move(b.adv_));
1343 b.adv_ = std::move(fresh);
1345 b.adv_.globalMax =
nullptr;
1350 blocks_[idx].st_.recentred =
true;
1351 blocks_[idx].st_.discarded += dropped;
1353 ++blocks_[idx].st_.fullAxis;
1374 std::vector<VofBlock*> one{&b};
1390 Kokkos::deep_copy(pkHost_, pk_);
1421 const int g = ghost_;
1429 std::vector<long> off(bs.size() + 1, 0);
1430 for (std::size_t k = 0; k < bs.size(); ++k) {
1431 const I3 n = bs[k]->adv_.inner();
1432 off[k + 1] = off[k] +
static_cast<long>(n.x) * n.y * n.z;
1434 auto ensure = [&](
LField& f,
const char* name) {
1435 if (
static_cast<long>(f.extent(0)) < off.back())
1436 f =
LField(Kokkos::view_alloc(std::string(name), Kokkos::WithoutInitializing), off.back());
1439 ensure(listD_,
"vof::block::debris_list");
1441 ensure(listR_,
"vof::block::residue_list");
1442 std::vector<DebrisPending> pend;
1443 std::vector<DebrisJob> jobs;
1444 for (std::size_t k = 0; k < bs.size(); ++k) {
1446 b.st_.debrisCells = 0;
1447 b.st_.debrisVolume = 0.0;
1448 const I3 e = b.adv_.extent(), n = b.adv_.inner();
1449 const long region =
static_cast<long>(n.x) * n.y * n.z, o = off[k];
1450 const long sy = e.x, sz =
static_cast<long>(e.x) * e.y;
1451 const int nx = n.x, ny = n.y;
1452 SField c = b.adv_.colour();
1453 long nD = 0, nR = 0;
1456 Kokkos::parallel_scan(
1457 "vof::block::debris_mark", Kokkos::RangePolicy<SExec>(
SExec(), 0, region),
1458 KOKKOS_LAMBDA(
const long r,
long& upd,
const bool final) {
1459 const int ix =
static_cast<int>(r % nx);
1460 const int iy =
static_cast<int>((r / nx) % ny);
1461 const int iz =
static_cast<int>(r / (
static_cast<long>(nx) * ny));
1462 const long i =
L3(g + ix, g + iy, g + iz, e);
1473 Kokkos::parallel_scan(
1474 "vof::block::residue_mark", Kokkos::RangePolicy<SExec>(
SExec(), 0, region),
1475 KOKKOS_LAMBDA(
const long r,
long& upd,
const bool final) {
1476 const int ix =
static_cast<int>(r % nx);
1477 const int iy =
static_cast<int>((r / nx) % ny);
1478 const int iz =
static_cast<int>(r / (
static_cast<long>(nx) * ny));
1479 const double ci = c(
L3(g + ix, g + iy, g + iz, e));
1483 listR(o + upd) =
L3(g + ix, g + iy, g + iz, e);
1488 const bool removeD = doDebris &&
debrisRemove && nD > 0;
1489 if (!removeD && nR == 0) {
1490 if (doDebris && nD > 0) {
1493 Kokkos::parallel_reduce(
1494 "vof::block::debris_census", Kokkos::RangePolicy<SExec>(
SExec(), 0, 1),
1495 KOKKOS_LAMBDA(
const long,
double& acc) {
1497 for (
long t = 0; t < nD; ++t)
1498 a += c(listD(o + t));
1502 b.st_.debrisCells = nD;
1503 b.st_.debrisVolume = dVd;
1507 ensure(listA_,
"vof::block::attached_list");
1510 Kokkos::parallel_scan(
1511 "vof::block::debris_attached", Kokkos::RangePolicy<SExec>(
SExec(), 0, region),
1512 KOKKOS_LAMBDA(
const long r,
long& upd,
const bool final) {
1513 const int ix =
static_cast<int>(r % nx);
1514 const int iy =
static_cast<int>((r / nx) % ny);
1515 const int iz =
static_cast<int>(r / (
static_cast<long>(nx) * ny));
1516 const long i =
L3(g + ix, g + iy, g + iz, e);
1524 DebrisPending pb{&b,
static_cast<long>(k), nD, nR, nA, removeD ? nD : 0, removeD};
1528 j.listD = doDebris ? listD_.data() + o :
nullptr;
1529 j.listR = doResidue ? listR_.data() + o :
nullptr;
1530 j.listA = listA_.data() + o;
1531 j.nDc = doDebris ? nD : 0;
1545 const long np =
static_cast<long>(pend.size());
1552 if (
static_cast<long>(debrisOut_.extent(0)) < 6 * np) {
1553 debrisOut_ =
SField(
"vof::block::debris_out", 6 * np);
1554 debrisOutHost_ = Kokkos::create_mirror_view(debrisOut_);
1560 T.nj =
static_cast<int>(std::min<long>(
kDebrisBatch, np - j0));
1561 for (
int q = 0; q < T.nj; ++q)
1562 T.job[q] = jobs[j0 + q];
1563 const long base = 6 * j0;
1564 Kokkos::parallel_for(
1565 "vof::block::debris_sums", Kokkos::RangePolicy<SExec>(
SExec(), 0, T.nj),
1566 KOKKOS_LAMBDA(
const long q) {
1569 const long nDc = J.
nDc, nDr = J.
nDr, nR = J.
nR, nA = J.
nA;
1570 double sD = 0.0, sR = 0.0, W = 0.0, VA = 0.0;
1571 for (
long t = 0; t < nDc; ++t)
1572 sD += c(J.
listD[t]);
1573 for (
long t = 0; t < nR; ++t)
1574 sR += c(J.
listR[t]);
1575 for (
long t = 0; t < nA; ++t) {
1576 const double ca = c(J.
listA[t]);
1577 W += ca * (1.0 - ca);
1580 const long ob = base + 6 * q;
1586 out(ob + 5) = (VA < vaMin || !(W > 0.0)) ? 0.0 : 1.0;
1589 for (
long t = 0; t < nDr; ++t)
1590 dV += c(J.
listD[t]);
1591 for (
long t = 0; t < nR; ++t)
1592 dV += c(J.
listR[t]);
1596 Kokkos::deep_copy(debrisOutHost_, out);
1599 void debrisApply(
const std::vector<DebrisPending>& pend,
const std::vector<long>& off,
1600 bool doDebris,
long np) {
1601 auto hoAll = debrisOutHost_;
1602 for (
long p = 0; p < np; ++p) {
1605 const long o = off[pb.
k];
1606 const I3 n = b.adv_.inner();
1607 const long region =
static_cast<long>(n.x) * n.y * n.z;
1609 for (
int q = 0; q < 6; ++q)
1610 ho[q] = hoAll(6 * p + q);
1611 const long nD = pb.
nD, nR = pb.
nR, nA = pb.
nA, nDr = pb.
nDr;
1612 const bool removeD = pb.
removeD;
1614 const double dV = ho[4], W = ho[2];
1615 if (
static_cast<long>(debrisEx_.extent(0)) < region)
1616 debrisEx_ =
SField(Kokkos::view_alloc(
"vof::block::debris_excess",
1617 Kokkos::WithoutInitializing),
1620 SField c = b.adv_.colour();
1621 LField listD = listD_, listR = listR_, listA = listA_;
1622 const long nZ = nDr + nR, nTot = nZ + nA;
1624 Kokkos::parallel_reduce(
1625 "vof::block::debris_write", Kokkos::RangePolicy<SExec>(
SExec(), 0, nTot),
1626 KOKKOS_LAMBDA(
const long t,
long& cap) {
1628 c(listD(o + t)) = 0.0;
1632 c(listR(o + t - nDr)) = 0.0;
1635 const long ta = t - nZ;
1636 const long i = listA(o + ta);
1637 const double ca = c(i);
1638 const double d = dV * (ca * (1.0 - ca)) / W;
1652 Kokkos::parallel_reduce(
1653 "vof::block::debris_lost", Kokkos::RangePolicy<SExec>(
SExec(), 0, 1),
1654 KOKKOS_LAMBDA(
const long,
double& acc) {
1656 for (
long t = 0; t < nA; ++t)
1665 b.st_.debrisCells = nD;
1666 b.st_.debrisVolume = ho[0];
1670 b.st_.debrisUnresolved += nD;
1675 b.st_.debrisCells = nD;
1676 b.st_.debrisVolume = ho[0];
1677 b.st_.debrisReturned += ho[0];
1679 b.st_.residueReturned += ho[1];
1680 b.st_.debrisLost += ho[4];
1686 const bool nowrap[3] = {
false,
false,
false};
1692 const I3 e = b.adv_.extent(), n = b.adv_.inner();
1693 const int g = ghost_;
1694 const int sx = b.box.lo[0], sy = b.box.lo[1], sz = b.box.lo[2];
1695 const int lx = nb.lo[0], ly = nb.lo[1], lz = nb.lo[2];
1696 const int hx = nb.hi[0], hy = nb.hi[1], hz = nb.hi[2];
1698 SField c = b.adv_.colour();
1700 Kokkos::parallel_reduce(
1701 "vof::block::out_of_box",
1703 {g + n.x, g + n.y, g + n.z}),
1704 KOKKOS_LAMBDA(
int x,
int y,
int z,
double& a) {
1705 const int gx = x - g + sx, gy = y - g + sy, gz = z - g + sz;
1706 const bool inX = wx || (gx >= lx && gx < hx), inY = wy || (gy >= ly && gy < hy),
1707 inZ = wz || (gz >= lz && gz < hz);
1708 if (inX && inY && inZ)
1710 a += c(
L3(x, y, z, e));
1713 SExec().fence(
"vof::block::out_of_box");
1718 const I3 e = b.adv_.extent(), n = b.adv_.inner();
1719 const int g = ghost_;
1720 SField c = b.adv_.colour();
1722 Kokkos::parallel_reduce(
1723 "vof::block::inner_sum",
1725 {g + n.x, g + n.y, g + n.z}),
1726 KOKKOS_LAMBDA(
int x,
int y,
int z,
double& a) { a += c(
L3(x, y, z, e)); }, v);
1738 const I3 e = b.adv_.extent(), n = b.adv_.inner();
1739 const int g = ghost_;
1740 const double hh = h_, aeps =
areaEps;
1741 SField c = b.adv_.colour();
1742 const long sy = e.x, sz =
static_cast<long>(e.x) * e.y;
1744 Kokkos::parallel_reduce(
1747 {g + n.x, g + n.y, g + n.z}),
1748 KOKKOS_LAMBDA(
int x,
int y,
int z,
double& acc) {
1749 const long i =
L3(x, y, z, e);
1750 const double ci = c(i);
1751 if (!(ci > aeps) || !(ci < 1.0 - aeps))
1754 for (
int dz = -1; dz <= 1; ++dz)
1755 for (
int dy = -1; dy <= 1; ++dy)
1756 for (
int dx = -1; dx <= 1; ++dx)
1757 st[vof::plicSt(dx + 1, dy + 1, dz + 1)] = c(i + dx + dy * sy + dz * sz);
1759 vof::mycNormal(st, m);
1760 const double al = vof::plicAlpha(m[0], m[1], m[2], ci);
1761 double v[8][3], ctr[3], ar = 0.0;
1762 const int nv = vof::plicPolygon(m[0], m[1], m[2], al, v);
1763 vof::polygonAreaCentroid(v, nv, ctr, ar);
1774 const I3 e = b.adv_.extent(), n = b.adv_.inner(), o = b.box.origin();
1775 const int g = ghost_;
1776 const double hh = h_;
1777 SField c = b.adv_.colour();
1779 MD pol(
SExec(), {g, g, g}, {g + n.x, g + n.y, g + n.z});
1780 double v = 0.0, mx = 0.0, my = 0.0, mz = 0.0;
1781 Kokkos::parallel_reduce(
1782 "vof::block::moments1", pol,
1783 KOKKOS_LAMBDA(
int x,
int y,
int z,
double& av,
double& ax,
double& ay,
double& az) {
1784 const double q = c(
L3(x, y, z, e));
1786 ax += q * (x - g + o.x + 0.5) * hh;
1787 ay += q * (y - g + o.y + 0.5) * hh;
1788 az += q * (z - g + o.z + 0.5) * hh;
1793 b.st_.master = b.master;
1794 for (
int d = 0; d < 3; ++d) {
1795 b.st_.lo[d] = b.box.lo[d];
1796 b.st_.hi[d] = b.box.hi[d];
1798 b.st_.cells = b.box.cells();
1802 for (
int d = 0; d < 3; ++d)
1803 b.st_.centroid[d] = b.st_.velocity[d] = 0.0;
1804 for (
int d = 0; d < 6; ++d)
1805 b.st_.moment[d] = 0.0;
1808 const double cx = mx / v, cy = my / v, cz = mz / v;
1809 double sxx = 0, syy = 0, szz = 0, sxy = 0, sxz = 0, syz = 0;
1810 Kokkos::parallel_reduce(
1811 "vof::block::moments2", pol,
1812 KOKKOS_LAMBDA(
int x,
int y,
int z,
double& axx,
double& ayy,
double& azz,
double& axy,
1813 double& axz,
double& ayz) {
1814 const double q = c(
L3(x, y, z, e));
1815 const double px = (x - g + o.x + 0.5) * hh - cx, py = (y - g + o.y + 0.5) * hh - cy,
1816 pz = (z - g + o.z + 0.5) * hh - cz;
1824 sxx, syy, szz, sxy, sxz, syz);
1826 const double nc[3] = {cx, cy, cz};
1827 for (
int d = 0; d < 3; ++d) {
1828 b.st_.velocity[d] = (b.hasPrev_ && dt > 0.0) ? (nc[d] - b.prevCentroid_[d]) / dt : 0.0;
1829 b.prevCentroid_[d] = nc[d];
1830 b.st_.centroid[d] = nc[d];
1834 const double iv = 1.0 / v;
1835 b.st_.moment[0] = sxx * iv;
1836 b.st_.moment[1] = syy * iv;
1837 b.st_.moment[2] = szz * iv;
1838 b.st_.moment[3] = sxy * iv;
1839 b.st_.moment[4] = sxz * iv;
1840 b.st_.moment[5] = syz * iv;
1851 for (
const auto& b : blocks_) {
1854 if (!b.curv_.ready() || !b.curv_.useWorklist || b.curv_.timingOn || !b.f_[0].extent(0))
1868 std::vector<VofBlock*> mb;
1869 for (
auto& b : blocks_)
1872 const std::size_t nb = mb.size();
1875 std::vector<VofCurvJob> jobs(nb);
1876 bool anyClip =
false;
1877 for (std::size_t k = 0; k < nb; ++k) {
1890 for (
int c = 0; c < 3; ++c)
1891 J.
f[c] = b.f_[c].data();
1906 anyClip = anyClip || (J.
km > 0.0);
1909 if (
static_cast<std::size_t
>(cStartG_.extent(0)) < nb) {
1910 cStartG_ =
LField(
"vof::block::batch_curv_sG", nb);
1911 cEndG_ =
LField(
"vof::block::batch_curv_eG", nb);
1912 cStartI_ =
LField(
"vof::block::batch_curv_sI", nb);
1913 cEndI_ =
LField(
"vof::block::batch_curv_eI", nb);
1914 cCnt_ =
LField(
"vof::block::batch_curv_counts", 8 * nb);
1915 cCntHost_ = Kokkos::create_mirror_view(cCnt_);
1917 Kokkos::deep_copy(
SExec(), cCnt_, 0L);
1918 const double wgt[3] = {metric_.h[0] * metric_.h[0], metric_.h[1] * metric_.h[1],
1919 metric_.h[2] * metric_.h[2]};
1922 T.nj =
static_cast<int>(std::min<std::size_t>(
kVofBlockBatch, nb - j0));
1923 T.base =
static_cast<int>(j0);
1924 for (
int k = 0; k < T.nj; ++k)
1925 T.job[k] = jobs[j0 + k];
1927 if (
static_cast<long>(cListG_.extent(0)) < rg)
1929 Kokkos::view_alloc(std::string(
"vof::block::batch_curv_listG"), Kokkos::WithoutInitializing),
1933 if (rg >= (1L << 31))
1934 throw std::runtime_error(
1935 "peclet::flow::vof::VofBlockSet: grown list capacity >= 2^31 (the slot map is int)");
1936 if (
static_cast<long>(cCacheG_.extent(0)) < rg)
1937 cCacheG_ = Kokkos::View<PvMoments*, SMem>(
1938 Kokkos::view_alloc(std::string(
"vof::block::batch_curv_cacheG"), Kokkos::WithoutInitializing),
1940 T.cache = cCacheG_.data();
1945 if (
static_cast<long>(cListI_.extent(0)) < ri)
1947 Kokkos::view_alloc(std::string(
"vof::block::batch_curv_listI"), Kokkos::WithoutInitializing),
1955 Kokkos::deep_copy(
SExec(), cCntHost_, cCnt_);
1956 SExec().fence(
"vof::block::curv_census_read");
1957 for (std::size_t k = 0; k < nb; ++k) {
1958 const long* ct = &cCntHost_(8 * k);
1959 curvStats_.interfacial += ct[0];
1960 curvStats_.hf += ct[1];
1961 curvStats_.hfMixed += ct[2];
1962 curvStats_.hfFit += ct[3];
1963 curvStats_.pv += ct[4];
1964 curvStats_.pvReduced += ct[5];
1965 curvStats_.noEstimate += ct[6];
1966 curvStats_.clipped += ct[7];
1977 for (
const auto& b : blocks_) {
1981 if (!b.allocated_ || a.hasGeometry() || a.debugRecomputeDilation || !a.useWorklist ||
1982 a.timingOn || a.globalMax || !a.exchange || a.ghost() != ghost_)
1992 J.
c = a.colour().data();
1993 J.
mx = a.planeM(0).data();
1994 J.
my = a.planeM(1).data();
1995 J.
mz = a.planeM(2).data();
1996 J.
al = a.planeAlpha().data();
1997 J.
fl = a.faceFlux().data();
1998 for (
int d = 0; d < 3; ++d)
1999 J.
u[d] = a.faceVel(d).data();
2000 J.
cc = a.dilationFlag().data();
2001 J.
outside = a.hasOutsideMask() ? a.outsideMask().data() :
nullptr;
2004 J.
o = b.box.origin();
2009 const int L[3] = {gs_.x, gs_.y, gs_.z};
2010 for (
int d = 0; d < 3; ++d)
2011 J.
span[d] = per_[d] && b.box.n(d) == L[d];
2012 for (
int f = 0; f < 6; ++f)
2013 J.
bcOwn[f] = a.bcFaceOwned(f) ? 1u : 0u;
2019 T.nj =
static_cast<int>(std::min<std::size_t>(
kVofBlockBatch, jobs.size() - j0));
2020 T.base =
static_cast<int>(j0);
2021 for (
int k = 0; k < T.nj; ++k)
2022 T.job[k] = jobs[j0 + k];
2031 for (
int a = 0; a < 3; ++a) {
2035 for (
int k = 0; k < T.nj; ++k)
2036 if (T.job[k].span[a])
2037 P.job[P.nj++] = T.job[k];
2040 const int b = (a + 1) % 3, c = (a + 2) % 3;
2042 const int dims[3] = {J.
e.
x, J.
e.
y, J.
e.
z};
2043 return static_cast<long>(dims[b]) * dims[c];
2047 if (!per_[0] || !per_[1] || !per_[2])
2054 if (
static_cast<std::size_t
>(bRead1_.extent(0)) >= len)
2056 if (bRead1_.extent(0) == 0)
2057 bRead1_ =
SField(
"vof::block::batch_read1", len);
2059 Kokkos::resize(bRead1_, len);
2060 bRead1Host_ = Kokkos::create_mirror_view(bRead1_);
2072 std::vector<std::size_t> idx;
2073 for (std::size_t k = 0; k < blocks_.size(); ++k)
2074 if (blocks_[k].mine_)
2076 const std::size_t nb = idx.size();
2079 std::vector<VofBlockJob> jobs(nb);
2080 for (std::size_t k = 0; k < nb; ++k) {
2084 b.st_.master = b.master;
2085 for (
int d = 0; d < 3; ++d) {
2086 b.st_.lo[d] = b.box.lo[d];
2087 b.st_.hi[d] = b.box.hi[d];
2089 b.st_.cells = b.box.cells();
2095 for (
int k = 0; k < T.nj; ++k) {
2096 const VofBlock& b = blocks_[idx[j0 + k]];
2097 for (
int d = 0; d < 3; ++d)
2098 P.c[k][d] = b.prevCentroid_[d];
2099 P.valid[k] = b.hasPrev_ ? 1u : 0u;
2103 statsPend_ = std::move(idx);
2109 for (std::size_t k = 0; k < statsPend_.size(); ++k) {
2110 VofBlock& b = blocks_[statsPend_[k]];
2112 b.st_.volume = q[0];
2115 for (
int d = 0; d < 3; ++d)
2116 b.st_.centroid[d] = b.st_.velocity[d] = 0.0;
2117 for (
int d = 0; d < 6; ++d)
2118 b.st_.moment[d] = 0.0;
2121 for (
int d = 0; d < 3; ++d) {
2122 b.st_.velocity[d] = q[4 + d];
2123 b.prevCentroid_[d] = q[1 + d];
2124 b.st_.centroid[d] = q[1 + d];
2128 for (
int d = 0; d < 6; ++d)
2129 b.st_.moment[d] = q[8 + d];
2137 if (statsPend_.empty())
2139 const std::size_t len =
kVofStats * statsPend_.size();
2140 Kokkos::deep_copy(Kokkos::subview(bRead1Host_, std::make_pair(std::size_t(0), len)),
2141 Kokkos::subview(bRead1_, std::make_pair(std::size_t(0), len)));
2151 std::vector<VofBlock*> mb;
2152 for (
auto& b : blocks_)
2159 const std::size_t nb = mb.size();
2160 std::vector<VofBlockJob> jobs(nb);
2161 bool anyMask =
false;
2162 for (std::size_t k = 0; k < nb; ++k) {
2163 jobs[k] =
makeJob(*mb[k], dt);
2164 anyMask = anyMask || (jobs[k].outside !=
nullptr);
2166 if (
static_cast<std::size_t
>(bStart_.extent(0)) < nb) {
2167 bStart_ =
LField(
"vof::block::batch_start", nb);
2168 bEnd_ =
LField(
"vof::block::batch_end", nb);
2172 const std::size_t off =
kVofStats * statsPend_.size();
2174 auto cfl = Kokkos::subview(bRead1_, std::make_pair(off, off + nb));
2180 Kokkos::deep_copy(
SExec(),
2181 Kokkos::subview(bRead1Host_, std::make_pair(std::size_t(0), off + nb)),
2182 Kokkos::subview(bRead1_, std::make_pair(std::size_t(0), off + nb)));
2183 SExec().fence(
"vof::block::read1");
2185 for (std::size_t k = 0; k < nb; ++k)
2186 mb[k]->adv_.enforceCfl(bRead1Host_(off + k), dt);
2187 Kokkos::deep_copy(
SExec(), pk_, 0.0);
2195 for (
int s = 0; s < 3; ++s) {
2196 const int d =
perm[s];
2198 if (
static_cast<long>(bList_.extent(0)) < region)
2199 bList_ =
LField(Kokkos::view_alloc(std::string(
"vof::block::batch_list"),
2200 Kokkos::WithoutInitializing),
2213 for (std::size_t k = 0; k < nb; ++k)
2214 mb[k]->adv_.noteBatchedStep();
2226 const std::size_t nb = bs.size();
2237 std::vector<VofBlockJob> jobs(nb);
2238 for (std::size_t k = 0; k < nb; ++k) {
2239 bs[k]->st_.debrisCells = 0;
2240 bs[k]->st_.debrisVolume = 0.0;
2241 jobs[k] =
makeJob(*bs[k], 0.0);
2243 if (
static_cast<std::size_t
>(dCap_.extent(0)) < nb) {
2244 for (
int q = 0; q < 6; ++q)
2245 dRange_[q] =
LField(
"vof::block::batch_debris_range", nb);
2246 dCap_ = Kokkos::View<int*, SMem>(
"vof::block::batch_debris_cap", nb);
2249 Kokkos::deep_copy(
SExec(), dCap_, 0);
2250 const LField sD = dRange_[0], eD = dRange_[1], sR = dRange_[2], eR = dRange_[3],
2251 sA = dRange_[4], eA = dRange_[5];
2255 auto ensure = [&](
LField& f,
const char* name) {
2256 if (
static_cast<long>(f.extent(0)) < region)
2257 f =
LField(Kokkos::view_alloc(std::string(name), Kokkos::WithoutInitializing), region);
2260 ensure(listD_,
"vof::block::debris_list");
2264 ensure(listR_,
"vof::block::residue_list");
2267 ensure(listA_,
"vof::block::attached_list");
2269 vofBatchDebrisSums(T,
F, listD_, listR_, listA_, sD, eD, sR, eR, sA, eA, pk_,
kPk, 0);
2270 if (
static_cast<long>(debrisEx_.extent(0)) < region)
2272 Kokkos::view_alloc(
"vof::block::debris_excess", Kokkos::WithoutInitializing), region);
2273 vofBatchDebrisWrite(T,
F, listD_, listR_, listA_, sD, sR, sA, eA, pk_,
kPk, 0, debrisEx_,
2282 for (std::size_t k = 0; k < bs.size(); ++k) {
2284 const double* ho = &pkHost_(
kPk * k);
2285 const long nD =
static_cast<long>(ho[
kDbND]);
2286 const bool removeD = doDebris &&
debrisRemove && nD > 0;
2287 const bool acted = ho[
kDbActed] != 0.0;
2289 if (doDebris && nD > 0) {
2290 st.debrisCells = nD;
2291 st.debrisVolume = ho[
kDbSumD];
2296 st.debrisCells = nD;
2297 st.debrisVolume = ho[
kDbSumD];
2301 st.debrisUnresolved += nD;
2305 st.debrisCells = nD;
2306 st.debrisVolume = ho[
kDbSumD];
2307 st.debrisReturned += ho[
kDbSumD];
2309 st.residueReturned += ho[
kDbSumR];
2310 st.debrisLost += ho[
kDbDV];
2318 if (
static_cast<std::size_t
>(pk_.extent(0)) <
kPk * nb) {
2319 pk_ =
SField(
"vof::block::batch_packet",
kPk * nb);
2320 pkHost_ = Kokkos::create_mirror_view(pk_);
2329 std::vector<std::size_t> idx;
2330 std::vector<VofBlock*> mb;
2331 for (std::size_t k = 0; k < blocks_.size(); ++k)
2332 if (blocks_[k].mine_) {
2334 mb.push_back(&blocks_[k]);
2336 const std::size_t nb = idx.size();
2339 std::vector<VofBlockJob> jobs(nb);
2340 for (std::size_t k = 0; k < nb; ++k)
2341 jobs[k] =
makeJob(*mb[k], 0.0);
2348 Kokkos::deep_copy(
SExec(), pkHost_, pk_);
2349 SExec().fence(
"vof::block::read2");
2352 for (std::size_t k = 0; k < nb; ++k) {
2353 if (jobs[k].outside ==
nullptr)
2355 for (
int f = 0; f < 6; ++f)
2356 if (jobs[k].bcOwn[f])
2357 mb[k]->adv_.addBcFaceVolume(f, pkHost_(
kPk * k +
kPkBcv + f));
2359 for (std::size_t k = 0; k < nb; ++k) {
2360 const double* hb = &pkHost_(
kPk * k +
kPkBox);
2361 const int lo[3] = {
static_cast<int>(hb[0]),
static_cast<int>(hb[1]),
static_cast<int>(hb[2])};
2362 const int hi[3] = {
static_cast<int>(hb[3]),
static_cast<int>(hb[4]),
static_cast<int>(hb[5])};
2367 for (
int d = 0; d < 3; ++d) {
2368 bb.
lo[d] = lo[d] + b.box.lo[d];
2369 bb.
hi[d] = hi[d] + 1 + b.box.lo[d];
2379 std::array<bool, 3> per_{
true,
true,
true};
2385 std::vector<VofBlock> blocks_;
2386 std::shared_ptr<VofBlockExchangeBase> exch_;
2387 std::map<std::array<int, 3>, std::vector<WyAdvector>> pool_;
2388 long poolHits_ = 0, poolMisses_ = 0;
2389 long lastReassigned_ = 0;
2391 LField listD_, listA_, listR_;
2394 SField::host_mirror_type debrisOutHost_;
2397 SField::host_mirror_type bRead1Host_;
2398 std::vector<std::size_t> statsPend_;
2399 LField bList_, bStart_, bEnd_;
2401 Kokkos::View<int*, SMem> dCap_;
2402 LField cListG_, cListI_, cStartG_, cEndG_, cStartI_, cEndI_;
2403 Kokkos::View<PvMoments*, SMem> cCacheG_;
2405 LField::host_mirror_type cCntHost_;
2407 SField::host_mirror_type pkHost_;
flow — VoF rung V1: Weymouth & Yue (2010) directionally-split, exactly volume-conserving geometric ad...
flow — batched execution of the VoF block container's stages (C1, doc/vof_step_performance_design....
The container: a replicated table of blocks, the per-step orchestration (gather → advect → re-centre ...
Curvature of the colour field on an extended (inner + ghost) block.
Weymouth-Yue split advection of a colour field on an extended (inner + ghost) block.
The container: a replicated table of blocks, the per-step orchestration (gather → advect → re-centre ...
void scatterSum(SField sLocal)
S = sum_k C_k of the CURRENT (replicated) table into sLocal's inner region (§5.6).
VofBlockJob makeJob(VofBlock &b, double dt) const
The raw-pointer job of one master block for the batched launches.
VofCurvature::Stats csfCurvatureStats() const
long assignMasters()
Apply plannedMasters(): allocate on the gaining ranks, migrate the colour, free on the losing ranks.
bool bubbleBox(const VofBlock &b, VofBox &out) const
Tight bounding box of C > 0 over the inner region, in GLOBAL indices.
void recentreTo(std::size_t idx, const VofBox &bb)
recentre for a bubble box already measured (the batched path's read #2).
void enableCsf(double sigmaValue)
Turn on the block CSF.
void recentre(std::size_t idx)
Move / resize the block when the bubble has spent its margin (or when the box has grown wastefully la...
double bubbleEps
The colour threshold that defines the BUBBLE EXTENT (and hence the box).
void applyDebrisLedger(std::vector< VofBlock * > &bs, bool doDebris)
The host half of the debris pass: the ledger of debrisPassBatchImpl, from the packet.
void setExchange(std::shared_ptr< VofBlockExchangeBase > x)
VofBlockExchangeBase * exchange() const
long lastReassigned() const
Blocks that changed master at the last advect() (rung W1 item a).
static constexpr double kDebrisMaxC
Debris predicate threshold (doc/vof_overlap_design.md §11): an interfacial cell is debris when NO cel...
void debrisBatched(std::vector< VofBlock * > &bs)
Stage 4 of §5.9, the debris/residue pass of debrisPassBatchImpl on every block of bs in batched launc...
int recentrePad
Cells of slack added beyond the margin when a block is re-centred, so a translating bubble re-allocat...
void flushStats()
Bring deferred statistics to the host now (a separate read; the step itself folds it into read #1).
void debrisPassBatchImpl(std::vector< VofBlock * > &bs)
bool csfEnabled
Rung W2: form the CSF face force on each block (its own curvature cascade, the V4 balanced -force rul...
bool batched
C1 (doc/vof_step_performance_design.md §4.6, §5.9): run each stage of the container step for ALL mast...
double interfaceArea(const VofBlock &b) const
Rung W1 item (d): the marker's interface area, in CELL units squared (the same convention volume uses...
std::vector< VofBlock > & blocks()
The block table.
void debrisPassBatch(std::vector< VofBlock * > &bs, bool deferLedger=false)
The pass on several master blocks at once.
bool timingOn
Instrument: fence-bounded wall time of the debris/residue pass (all blocks, all calls) while timingOn...
void debrisPass(VofBlock &b)
Debris + residue pass on one master block (doc/vof_overlap_design.md §5.2-5.3, predicate of §11,...
double areaEps
Wisp guard on the INTERFACE-AREA predicate (VofBlockStats::area), the same threshold and the same rea...
void computeCsf(SField fx, SField fy, SField fz)
Per-block curvature cascade + the CSF face force, summed into the caller's three face-force patches.
void debrisApply(const std::vector< DebrisPending > &pend, const std::vector< long > &off, bool doDebris, long np)
debrisPassBatchImpl, steps 3-5 per acting block: the per-cell writes and the ledger.
void clipToSeed(VofBlock &b)
A seeded block's colour is its OWN bubble's: the gather copies the whole INNER box (bubble extent + m...
std::array< bool, 3 > periodic() const
VofCurvature curvProto
The curvature cascade's TUNABLES for every block, copied into each block's own VofCurvature when it i...
double sigma
surface-tension coefficient of the block CSF (cell units)
std::vector< double > blockColourHost(std::size_t idx)
One block's INNER colour, copied to the host in x-fastest order over blocks_[idx]....
void setKappaMax(double km)
Set the curvature admissibility clip (VofCurvature::kappaMax, index units) on the prototype AND on ev...
void seedSphere(double cx, double cy, double cz, double r, int subLevels=4, int extraPad=0)
Seed a spherical bubble (centre and radius in CELL units, global).
void finishSeeding(SField cLocal)
Gather the colour of every seedBox-seeded block from cLocal, fill its ghosts and measure.
bool debrisCensus
Run the debris pass in advect() (only while the block CSF is on – a kinematic block run never pays fo...
void advectBatched(double dt)
Stages 1-3 of §5.9 for every master block: the Courant numbers in one launch and ONE host read (the t...
bool debrisRemove
Remove the debris and return its volume (§5.3).
void seedBoxWithColour(const VofBox &bb, const std::vector< double > &colour)
Seed a block whose INNER box is EXACTLY bb (not grown by the margin: bb is what blockColourHost was p...
void buildCsfForce(VofBlock &b)
The V4 balanced-force CSF on the BLOCK's faces — the same csfFaceCurvature + csfFaceForce pair Solver...
void seedBox(const VofBox &bb, int extraPad=0)
Seed one block on the global index box bb (the BUBBLE extent; the inner box is bb grown by margin),...
void recentreBatched(bool ranDebris)
Stage 5 of §5.9 on the batched path: every master block's bubble box in one launch,...
const std::vector< VofBlock > & blocks() const
void init(I3 gs, std::array< bool, 3 > per, int rank, int size, double h=1.0)
void masterCensus(std::vector< long > &masters, std::vector< long > &cells) const
Load-balance census of the CURRENT master assignment: masters[r] = blocks mastered by rank r,...
void ensureRead1(std::size_t len)
Grow read #1's packet to len doubles, KEEPING its contents (deferred statistics may wait in the front...
const VofMetric & metric() const
void measureBatched(double dt)
C2 (§5.10): measure() for every master block batched (vofBatchStats), with NO host read – the values ...
double cellImbalance() const
max/mean of the per-rank block-cell load (1.0 = perfect). 0 blocks -> 1.0.
static VofCurvature blockCurvProto()
The block prototype: the class defaults, plus the admissibility clip ON at 1/Delta_min (doc/vof_overl...
void measure(VofBlock &b, double dt)
Volume, centroid, centroid velocity and the central second moments over the inner box.
void ensurePacket(std::size_t nb)
void applyStats(const double *hs)
Apply the deferred statistics in hs (host, kVofStats doubles per pending block) exactly as measure() ...
void scatter(SField cLocal)
Union the current colour into cLocal without advecting (used right after seeding).
void advect(double dt, SField cLocal)
One kinematic block step: gather the face velocity, advect every local block, re-centre,...
void setMetric(const VofMetric &g)
The anisotropic cell metric (Phase 3).
std::vector< VofBlockStats > statsAll()
Per-bubble census on the master (empty entries on a non-master).
int poolCapacity
advectors kept per extent; beyond it the retired one is freed
static constexpr double kDebrisMinAttached
Guard of the volume return (§5.3 step 3): a marker whose attached interface holds less than this much...
void fillBlockGhosts(VofBlock &b)
The block's own colour ghost policy — see the file header.
bool csfBatchEligible() const
The batched cascade applies where the container step is batched and every master block's cascade runs...
double outOfBoxSum(const VofBlock &b, const VofBox &nb) const
Sum of the block's colour over inner cells whose GLOBAL index falls outside nb.
std::vector< int > plannedMasters() const
The master each block WOULD get under assignMode, from the current block cell counts.
void computeCsfBatched()
Stage 6 of §5.9: the curvature cascade (compaction, planes, tiers 1-2, tier 3, the clip,...
double cflLimit
The Weymouth-Yue cap of every block advector.
double innerSum(const VofBlock &b) const
std::vector< double > blockKappaHost(std::size_t idx)
One marker's OWN curvature over its inner box, x-fastest (empty unless this rank masters it and the b...
VofMasterAssign assignMode
Rung W1 item (a): how masters are chosen, and how often the choice is revisited.
static constexpr int kDebrisBatch
void setWispEps(double eps)
Set wispEps on the set AND on every live advector (pooled ones take it on reuse).
void batchGhostFill(VofBlockTable T)
fillBlockGhosts of every job of T, pass by pass in the per-block pass order: zero,...
bool usePool
Rung W1 item (c): recycle the advectors a re-centring retires, keyed by the EXACT extent.
static constexpr int kPkBox
The per-job packet of read #2 (§5.9): the debris slots (VofDebrisSlot), the bubble box,...
bool batchEligible() const
The batched path applies to the plain advect() configuration: every master block an uncut all-fluid a...
double wispEps
The Weymouth-Yue wisp tolerance of every block advector (WyAdvector::wispEps); the solver sets it to ...
double outOfBoxSum(const VofBlock &b, const VofBox &nb, const bool wrap[3]) const
... where an axis flagged in wrap spans the whole periodic domain in nb and is copied with the wrap: ...
bool allowShrink
Let a block SHRINK when it has grown much larger than the bubble needs.
static constexpr int kPkBcv
static VofBlockTable batchTable(const std::vector< VofBlockJob > &jobs, std::size_t j0)
int masterOf(long id) const
Master assignment: round robin by block id (VOF_PLAN §10 W0; the weighted-ORB assignment is W1).
void debrisSums(const std::vector< DebrisJob > &jobs, long np)
debrisPassBatchImpl, step 2: the sums of every acting block (np jobs) in batched launches of one thre...
void allocateCsf(std::size_t idx)
std::size_t count() const
VofBox extended(int ghost) const
const VofCurvature & curvature() const
SField csfForce(int c) const
void deserializeAux(const double in[kAuxLen])
void serializeAux(double out[kAuxLen]) const
static constexpr int kAuxLen
The non-colour state a master carries between steps: the previous centroid (so a migrated block's rep...
VofBox seed_
The BUBBLE extent this block was seeded from (empty for a sphere seed, which paints its own colour).
VofCurvature & curvature()
Rung W2: the block's own curvature cascade and the CSF face force it forms.
const WyAdvector & advector() const
VofBox box
the INNER box, global
const VofBlockStats & stats() const
Curvature of the colour field on an extended (inner + ghost) block.
double interfaceEps
Wisp threshold on the interfacial predicate.
double monoTol
Tolerance of the column monotonicity test (hfColumnHeight).
static void fallbackBatch(const std::vector< VofCurvFallbackJob > &jobs)
Tier 3 of many cascades in as few launches as possible: one kernel per kFallbackBatch jobs over their...
bool debugSingleDirection
DIAGNOSTIC ONLY — disable tier 2 (the non-preferred column directions), so the branch census separate...
double pureEps
Tolerance of the PURITY test that ends a height-function column (hfIsFull/hfIsEmpty),...
VofCurvFallbackJob fallbackJob(SField c) const
This cascade's tier-3 share for fallbackBatch (worklist mode only: the job walks the compacted interf...
bool useMixedHeightFit
Tier 2b, and it ships OFF — a measured decision, see the WO-O findings entry.
VofMetric metric
The anisotropic cell metric (Phase 3).
bool debugForceFallback
DIAGNOSTIC ONLY — disable tiers 1 and 2 so every interfacial cell goes to the PV fit.
IField slotMap() const
The slot map of the moment cache (design G §5.2), for the batched cascade, which writes it with posit...
double kappaClipValue() const
The bound the clip applies this call (0 = off).
double ptWeightWidth
Wendland support width of the tier-2b height-position fit, in cell units.
Weymouth-Yue split advection of a colour field on an extended (inner + ghost) block.
SField colour() const
Colour field on the extended block (x-fastest).
static double wallSeconds()
flow — VoF rung V2a (WO-J): the bridge between the solver's G = 2 block and the colour field's own g ...
flow — VoF rung V3 (WO-O): the view-level driver for the curvature cascade.
flow — portable (Kokkos) MAC stencil operators: Red-Black Gauss-Seidel smoothers + divergence.
void vofBatchBox(const VofBlockTable &T, double eps, SField out, int stride, int slot0, SField &tile)
The tight box of |C| > eps over each job's inner region, in the block's LOCAL inner frame (bubbleBox'...
long vofJobGrown1(const VofBlockJob &J)
The inner region grown by one cell per side: WyAdvector::reconstructImpl's range.
void vofCurvCompact(const VofCurvTable &T, bool grown, LField list, LField start, LField end)
VofCurvature::compact: the interfacial cells of the grown (grown) or inner region,...
bool vofDebrisCell(const SF &c, long i, long sy, long sz, double ieps, double cfull)
The debris predicate of doc/vof_overlap_design.md §11 on cell i: interfacial, and NO cell of the mark...
void vofBatchFlux(const VofBlockTable &T, int d)
WyAdvector::computeFluxesImpl (uncut): one flux per d-face, wyFaceFlux (or, for a job carrying the WO...
void vofCurvListPasses(const VofCurvTable &T, bool anyClip, LField list, LField start, LField end, LField cnt)
The whole cascade list stage of a chunk: tiers 1-2, tier 3, the clip (only if some job clips),...
void vofBatchCfl(const VofBlockTable &T, SField out)
One team per job: WyAdvector::maxCourant or maxCourantInterface (per the job's interfaceCfl),...
long vofSetOffsets(VofBlockTable &T, F size)
Fill T.off from a per-job range size.
void vofBatchClamp(const VofBlockTable &T, I3 gs, bool px, bool py, bool pz)
Pass 3 (colour_field.hpp::clampFill, skip = 0): the part of each extended block outside a NON-periodi...
void vofBatchPeriodic(const VofBlockTable &T, int a)
Pass 2 on axis a (colour_field.hpp::periodicFill, one axis): only the jobs whose block spans the peri...
constexpr int kWySweepPerm[6][3]
The six permutations of (x, y, z), cycled by step index so no direction is systematically favoured (p...
void vofBatchGhostZero(const VofBlockTable &T)
Pass 1: every ghost cell of every job -> 0.
void vofAssignOrb(const std::vector< long > &w, int size, std::vector< int > &master)
Weighted ORB over a 1-D block space: the blocks are laid out as a 1-D "grid" of N cells in block-id o...
constexpr int kVofStats
Doubles per job in the statistics packet: volume, centroid[3], velocity[3], area, moment[6].
constexpr int kVofBlockBatch
Jobs per launch; a container with more master blocks runs each stage in chunks.
@ kDbActed
1 when the return ran (pending and VA >= kDebrisMinAttached and W > 0)
@ kDbSumR
sum_R C in list order (signed residue)
@ kDbPending
1 when there was something to remove (removeD or nR > 0)
@ kDbSumD
sum_D C in list order (the removed / census debris volume)
@ kDbDV
the volume to return (D if removing, then R); replaced by lost once acted
void vofBatchDebrisSums(const VofBlockTable &T, VofDebrisFlags F, LField listD, LField listR, LField listA, LField sD0, LField eD0, LField sR0, LField eR0, LField sA0, LField eA0, SField out, int stride, int slot0)
Step 2 of the pass: one thread per job, every sum in list order (the per-block kernel's single thread...
long vofJobFaces(const VofBlockJob &J, int d)
A sweep's face range of one job: the inner region with one extra layer on the low side of d.
void vofCurvHfReset(const VofCurvTable &T)
heightPass (worklist mode), part 1: every inner cell to kappa = 0, branch = kCurvNone.
long vofJobInner(const VofBlockJob &J)
void vofCurvPlanesList(const VofCurvTable &T, LField list, LField start, LField end)
Part 2: wyReconstructCell over the grown interfacial list (upper bound: the grown region),...
void vofBatchMark(const VofBlockTable &T, int kind, double ieps, double cfull, double weps, LField list, LField start, LField end)
One mark scan over the concatenated inner regions (T.off = vofJobInner), in each block's inner-box in...
void vofCsfForceBatch(const VofCurvTable &T, double sig, double w0, double w1, double w2)
VofBlockSet::buildCsfForce for every job, the three components per cell: the V4 balanced-force CSF at...
VofBox vofClampBox(VofBox b, I3 gs, const std::array< bool, 3 > &per)
Clamp a block box so it is representable: at most the whole axis on a periodic axis,...
Kokkos::View< long *, SMem > LField
void vofBatchPlic(const VofBlockTable &T, LField list, LField start, LField end)
wyReconstructCell over each job's compacted list: launched over the upper bound (the job's region),...
void vofAssignLpt(const std::vector< long > &w, int size, std::vector< int > &master)
Longest-processing-time greedy (Graham 1969): heaviest block first onto the currently least-loaded ra...
void vofCurvPlanesZero(const VofCurvTable &T)
reconstructPlanes (worklist mode), part 1: zero the four plane fields and clear the slot map (design ...
void vofBatchDebrisLost(const VofBlockTable &T, LField sA0, LField eA0, SField out, int stride, int slot0, SField ex, Kokkos::View< int *, SMem > capf)
lost: the capped excess of an acted job summed in list order on one thread (only where a cap fired,...
int vofAxisRuns(int a, int b, int gs, bool periodic, VofRun out[5], int outside=0)
Decompose [a, b) on one axis into global runs.
void vofBatchBcLedger(const VofBlockTable &T, int d, SField out, int stride, int slot0)
The WO-R boundary ledger (WyAdvector::accumulateBcFaceVolume) of the jobs carrying the mask: one thre...
long vofJobLen(const VofBlockJob &J)
VofMasterAssign
How a block's MASTER rank is chosen.
@ Lpt
longest-processing-time greedy on the block cell counts (rung W1 default)
@ RoundRobin
id % size — rung W0's assignment; blind to block SIZE
@ WeightedOrb
weighted ORB over a 1-D "block space" (core::decomp::BlockDecomposer<1>)
bool vofAttachedCell(const SF &c, long i, long sy, long sz, double ieps, double cfull)
The ATTACHED predicate (§5.3 step 2): interfacial with a cell at or above cfull within two.
void clampFill(SField f, I3 e, int g, I3 o, I3 gs, bool px, bool py, bool pz, int skip=0)
Zero-gradient (Neumann) fill of the ghost cells that lie OUTSIDE the global domain on a non-periodic ...
void vofBatchWorklist(const VofBlockTable &T, LField list, LField start, LField end)
WyAdvector::reconstructImpl's worklist scan, over the concatenated grown-by-one regions (T....
void periodicFill(SField f, I3 e, int g, bool px, bool py, bool pz)
Periodic wrap of a single-block extended field at ghost width g (the single-rank ghost path; under MP...
long vofCurvInner(const VofCurvJob &J)
void vofBatchStats(const VofBlockTable &T, const VofStatsPrev &P, double hh, double aeps, double dt, SField out, long off, SField &tile)
VofBlockSet::measure for every job: the first moments, then the central second moments and the PLIC i...
double csfFaceForce(double sigma, double kf, double dC, double hGrad)
The balanced-force CSF contribution to the momentum RHS at one staggered velocity unknown,...
void vofBatchFreeze(const VofBlockTable &T)
WyAdvector::freezeDilationFlag over every job's extended block.
void vofBatchUpdate(const VofBlockTable &T, int d)
WyAdvector::applySweepImpl (uncut) over the inner regions (T.off = vofJobInner); the expression verba...
bool vofResidueCell(double ci, double weps)
The residue predicate (§13): 0 < |C| <= wispEps.
bool csfFaceCurvature(double k0, double b0, double k1, double b1, double &kf)
Face curvature for the balanced-force CSF, from the two cells sharing the face.
long vofCurvGrown(const VofCurvJob &J)
The inner region grown by kPvHalf: every cell VofCurvature::reconstructPlanes writes.
void vofBatchDebrisWrite(const VofBlockTable &T, VofDebrisFlags F, LField listD, LField listR, LField listA, LField sD0, LField sR0, LField sA0, LField eA0, SField out, int stride, int slot0, SField ex, Kokkos::View< int *, SMem > capf)
Step 4, the act: removed cells -> 0, attached C += dV C(1-C)/W capped at 1 (the per-block write kerne...
Kokkos::MDRangePolicy< Exec, Kokkos::Rank< 3, Kokkos::Iterate::Left, Kokkos::Iterate::Left > > MDRange3
3-D range, x (the first index) fastest (both the tile order and the order within a tile).
Kokkos::View< double *, SMem > SField
long L3(int x, int y, int z, I3 e)
Kokkos::DefaultExecutionSpace SExec
flow — the multidimensional iteration policies: iteration order follows storage.
Per-call census of the cascade over this block's inner region (LOCAL; a distributed caller sums them ...
Gather / scatter / table replication.
virtual void scatterForceSum(std::vector< VofBlock > &blocks, SField fx, SField fy, SField fz)=0
SUM every master block's CSF face force into the caller's three face-force patches (TBFsolver's UNPAC...
virtual void migrateColour(std::vector< VofBlock > &blocks, const std::vector< int > &oldMaster)=0
Move a block's state from oldMaster[i] to blocks[i].master after a re-assignment.
virtual void scatterColourSum(std::vector< VofBlock > &, SField)
SUM every master block's inner colour into the caller's colour patch: S = sum_k C_k,...
virtual void scatterColourMax(std::vector< VofBlock > &blocks, SField cLocal)=0
UNION the masters' inner colour into the caller's local colour patch: zero the inner region,...
virtual ~VofBlockExchangeBase()=default
virtual void syncTable(std::vector< VofBlock > &blocks)=0
Replicate the (possibly re-centred) boxes so every rank's table agrees again.
virtual long scatterBytes() const
virtual void gatherColour(std::vector< VofBlock > &blocks, SField cLocal)=0
Fill every MASTER block's INNER colour from the caller's colour patch (the mirror of scatterColourMax...
virtual long gatherBytes() const
Bytes moved by the last gather / scatter on THIS rank (sent + received).
virtual void gatherFaceVel(std::vector< VofBlock > &blocks, int ghost)=0
Fill every MASTER block's faceU/V/W over its EXTENDED box, from the face velocity the ranks own.
One master block's share of a batched container launch.
unsigned char * cc
the frozen dilation flag
double dth
dt / h of this block's advector
double weps
the advector's wisp tolerance
double * u[3]
face velocities uf, vf, wf
bool interfaceCfl
interfaceLocalCfl: maxCourantInterface, else maxCourant
bool span[3]
the block spans this globally periodic axis (wrap in-block)
I3 o
extended extent, inner counts, global index of inner (0,0,0)
const unsigned char * outside
the WO-R out-of-domain mask; null when there is none
unsigned char bcOwn[6]
WO-R: the global domain faces this block owns.
One block's share of the batched sums (raw pointers: the table rides in the functor).
One acting block of debrisPassBatchImpl: its lists' lengths and whether D is removed.
DebrisJob job[kDebrisBatch]
Per-block Lagrangian census, computed on the master (VOF_PLAN §10 W1 outputs, available at W0).
long debrisUnresolved
cumulative debris cells left for want of an attached interface
double debrisReturned
cumulative sum of debrisVolume over the removals
double area
Interface area of the marker, in cell-size units squared: the sum of the PLIC polygon areas over the ...
double moment[6]
Central second moments Σ C (x−x̄)(y−ȳ)/Σ C, order xx, yy, zz, xy, xz, yz (the deformation).
long fullAxis
Cumulative re-centrings whose box had to span a whole periodic axis (vof_overlap_design §12....
long cells
inner-box cell count (the master's work)
double debrisLost
cumulative volume the return could not place (C capped at 1)
double debrisVolume
their colour, summed in list order (cell volumes), this step
double volume
Σ C over the inner box, in cell volumes.
double residueReturned
Cumulative SIGNED volume of the sub-wispEps residue cleared after each advection and returned to the ...
double discarded
Cumulative colour dropped by re-centrings, i.e.
bool recentred
the box moved at the end of the last step
double velocity[3]
d(centroid)/dt of the last advect
long debrisCells
Marker DEBRIS (doc/vof_overlap_design.md §5.2 as amended by §11): an interfacial cell (vofIsInterface...
The job table of one launch, by value.
Half-open global cell box [lo, hi).
bool operator!=(const VofBox &o) const
bool contains(const VofBox &o) const
static VofBox intersect(const VofBox &a, const VofBox &b)
Intersection in global coordinates (may be empty).
bool operator==(const VofBox &o) const
static VofBox grown(const VofBox &b, int m)
One block's share of a batched tier-3 launch (VofCurvature::fallbackBatch): its fields,...
One master block's cascade (VofCurvature, worklist mode) for the batched launches: its planes,...
double * f[3]
the block's CSF face force, per component
int * slot
the block's slot map (design G §5.2): absolute cListG_ positions
Per-call census of the cascade over this block's inner region (LOCAL; a distributed caller sums them ...
Flags of the pass, uniform over the blocks.
A raw-pointer field accessor with the View<double*> call syntax, for kernels that walk SEVERAL blocks...
One contiguous run of GLOBAL indices covered by a block's index range on one axis,...
int loc0
block-local index (0-based within [a, b)) the run starts at
int g0
first GLOBAL index of the run
What measure() reads besides the colour: each job's previous centroid and whether it is valid (the ho...
flow — VoF rung V4 (WO-P): balanced-force continuum surface force + the capillary Δt.
static int wrap(int a, int n)
static constexpr double F
static double perm(const std::vector< double > &gsdf, const BlockDecomposer< 3 > &dec, int rank, bool amg, int levels, MPI_Comm comm)
Kokkos::View< double *, SMem > SField
static std::vector< double > colour(int m)