8#ifndef PECLET_FLOW_FLOW_IBM_GEOMETRY_HPP
9#define PECLET_FLOW_FLOW_IBM_GEOMETRY_HPP
20 const std::size_t n = (std::size_t)nx_ * ny_ * nz_;
21 if (sdfInner.size() != n)
22 throw std::runtime_error(
"set_solid: expected nx*ny*nz values");
23 CCField din(
"peclet::flow::sdfInner_d", n);
25 Kokkos::View<const double*, Kokkos::HostSpace, Kokkos::MemoryTraits<Kokkos::Unmanaged>>;
30 const double k = u_.lenToInt();
32 std::vector<double> scaled(n);
33 for (std::size_t i = 0; i < n; ++i)
34 scaled[i] = sdfInner[i] * k;
35 Kokkos::deep_copy(din, HostConst(scaled.data(), n));
37 Kokkos::deep_copy(din, HostConst(sdfInner.data(), n));
45 const bool useEx = hasExactCross_ && !Grid::collocated;
47 const mreal lam = (
mreal)(wallSlip_ ? slipLambda_ : 0.0);
48 if (lam > 0.0f && slipSkipDev_.data() ==
nullptr)
49 slipSkipDev_ = Kokkos::View<int, CCMem>(
"peclet::flow::slipSkip");
50 for (
int c = 0; c < 3; ++c) {
54 CCConst(sdf_), e_,
G, off, 0, C[c].ov, C[c].idMap, C[c].counter,
56 useEx ?
CCConst(tEx_[c][2]) :
CCConst(),
C3{nx_, ny_, nz_}, lam, lam > 0.0f ? c : -1,
57 lam > 0.0f ? slipSkipDev_ : Kokkos::View<int, CCMem>(),
62 Kokkos::deep_copy(sk, slipSkipDev_);
63 slipSandwich_[(std::size_t)c] = sk;
65 slipSandwich_[(std::size_t)c] = 0;
76 Kokkos::deep_copy(C[c].u, 0.0);
78 if constexpr (Grid::collocated)
88 Kokkos::deep_copy(uf_, 0.0);
89 Kokkos::deep_copy(vf_, 0.0);
90 Kokkos::deep_copy(wf_, 0.0);
91 faceFieldValid_ =
false;
99 B3 e{e_.x, e_.y, e_.z};
100 for (
int face = 0; face < 6; ++face) {
101 if (!touchesGlobalFace(face))
103 const int a = face / 2, s = face % 2;
106 else if (bc_[face] != 0)
117 cutcellPressure_ = cutcellPressure;
124 if (cutcellPressure_) {
135 geometryBuilt_ =
true;
140 if constexpr (Grid::collocated) {
148 if (colSchemeAuto_) {
149 const bool ok = !(porous_ || varRho_ || hasBc_ || useChebyshev_ || hasExactCross_ ||
150 hasOpenOverride_ || fluidOnlyMode_ != 0);
152 ghostProjection_ =
true;
158 if (ghostProjection_)
160 ghostProjection_ =
false;
163 "peclet::flow SolverColocated: AUTO scheme fell back to gauge-exact "
164 "(configuration unsupported by the ghost projection v1). Select explicitly "
165 "with set_collocated_scheme to silence this notice.\n");
173#ifdef PECLET_FLOW_MPI
174 for (
bool& d : momStencilDirty_)
181 const std::size_t nInner = (std::size_t)nx_ * ny_ * nz_;
184 Kokkos::parallel_reduce(
185 "peclet::flow::has_solid", Kokkos::RangePolicy<CCExec>(0, nInner),
186 KOKKOS_LAMBDA(
const std::size_t i,
int& acc) { acc = acc || (dinC(i) < 0.0); }, anySolid);
187 hasSolid_ = anySolid != 0;
189#ifdef PECLET_FLOW_MPI
191 int local = hasSolid_ ? 1 : 0, global = 0;
192 MPI_Allreduce(&local, &global, 1, MPI_INT, MPI_MAX, comm_);
193 hasSolid_ = global != 0;
196#ifdef PECLET_FLOW_MPI
202 const int ex = e_.x, ey = e_.y,
nx = nx_,
ny = ny_,
nz = nz_, g =
G;
205 Kokkos::parallel_for(
207 KOKKOS_LAMBDA(
int x,
int y,
int z) {
208 sdf((
long)(x + g) + (
long)(y + g) * ex + (
long)(z + g) * (
long)ex * ey) =
209 dinC((std::size_t)x + (std::size_t)y *
nx + (std::size_t)z * (std::size_t)
nx *
ny);
212 velDev_->exchange(sdf_);
219 const int ex = e_.x, ey = e_.y, ez = e_.z,
nx = nx_,
ny = ny_,
nz = nz_, g =
G;
221 Kokkos::parallel_for(
222 "peclet::flow::sdf_periodic_wrap",
MDRange3<CCExec>(space, {0, 0, 0}, {ex, ey, ez}),
223 KOKKOS_LAMBDA(
int x,
int y,
int z) {
224 const int ix = (((x - g) %
nx) +
nx) %
nx, iy = (((y - g) %
ny) +
ny) %
ny,
225 iz = (((z - g) %
nz) +
nz) %
nz;
226 sdf((
long)x + (
long)y * ex + (
long)z * (
long)ex * ey) =
227 din((std::size_t)ix + (std::size_t)iy *
nx + (std::size_t)iz * (std::size_t)
nx *
ny);
258 if (hasBc_ && !Grid::collocated)
292 if (vmgExplicit_ || vmgAutoCells_ == 0)
294 const bool eligible = !varProps_ && !varRho_ && !hasDrag_ && !porous_ && !Grid::collocated &&
295 (!hasBc_ || hasSolid_ || !implicitFou_);
301 1.0 + 4.0 * dt_ * mu_ * (u_.w[0] + u_.w[1] + u_.w[2]) / (rho_ > 0.0 ? rho_ : 1.0);
302 int minExt = std::min({e_.x - 2 *
G, e_.y - 2 *
G, e_.z - 2 *
G});
304 double global = (double)(e_.x - 2 *
G) * (e_.y - 2 *
G) * (e_.z - 2 *
G);
305 double perRank = global;
306#ifdef PECLET_FLOW_MPI
308 int np = 1, g = minExt;
309 MPI_Comm_size(comm_, &np);
310 MPI_Allreduce(&minExt, &g, 1, MPI_INT, MPI_MIN, comm_);
312 global = (double)gnx_ * gny_ * gnz_;
313 perRank = global / (double)np;
316 useVelocityMg_ = eligible && kappa >= vmgAutoMinCond_ && minExt >= vmgAutoMinExtent_ &&
317 global >= (double)vmgAutoMinGlobal_ && perRank < (
double)vmgAutoCells_;
318 if (useVelocityMg_) {
330 if (useVelocityMg_ &&
331 vmg_.levels() == 0) {
335 vmg_.setMetric(u_.w, u_.hp);
336#ifdef PECLET_FLOW_MPI
341 vmg_.initMpi(*dec_, vmgLevels_, comm_);
344 vmg_.init(nx_, ny_, nz_, vmgLevels_);
347 if (!hasBc_ || hasSolid_) {
348 vmgTheta_ =
CCField(
"vmgTheta", n_);
349 vmgClean_ =
CCField(
"vmgClean", n_);
362 if (hasOpenOverride_) {
365 const std::vector<double>* src[3] = {&oxOverride_, &oyOverride_, &ozOverride_};
366 CCField dst[3] = {ox_, oy_, oz_};
367 for (
int f = 0; f < 3; ++f) {
368 CCField din(
"peclet::flow::openOv_d", (std::size_t)nx_ * ny_ * nz_);
371 Kokkos::View<
const double*, Kokkos::HostSpace, Kokkos::MemoryTraits<Kokkos::Unmanaged>>(
372 src[f]->data(), src[f]->size()));
374 const int ex = e_.x, ey = e_.y, ez = e_.z,
nx = nx_,
ny = ny_,
nz = nz_, g =
G;
376 Kokkos::parallel_for(
377 "peclet::flow::open_override_wrap",
MDRange3<CCExec>(space, {0, 0, 0}, {ex, ey, ez}),
378 KOKKOS_LAMBDA(
int x,
int y,
int z) {
379 const int ix = (((x - g) %
nx) +
nx) %
nx, iy = (((y - g) %
ny) +
ny) %
ny,
380 iz = (((z - g) %
nz) +
nz) %
nz;
381 o((
long)x + (
long)y * ex + (
long)z * (
long)ex * ey) = din(
382 (std::size_t)ix + (std::size_t)iy *
nx + (std::size_t)iz * (std::size_t)
nx *
ny);
387 if constexpr (Grid::collocated) {
390 if (faceInterp_ >= 5 && faceInterp_ <= 7) {
397 const std::size_t nn = n_;
398 for (
int c = 0; c < 3; ++c) {
400 Kokkos::parallel_for(
401 "peclet::flow::embed_solid_mask", Kokkos::RangePolicy<CCExec>(0, nn),
402 KOKKOS_LAMBDA(std::size_t i) { m(i) = cs(i) < 1e-6 ? 1.0 : 0.0; });
406 if (fluidOnlyMode_ == 1) {
417 CCField oa[3] = {ox_, oy_, oz_};
419 for (
int a = 0; a < 3; ++a) {
421 const long sa = (a == 0) ? 1 : (a == 1) ? (
long)e.x : (long)e.x * e.y;
422 Kokkos::parallel_for(
423 "peclet::flow::fluid_only_openness",
425 KOKKOS_LAMBDA(
int x,
int y,
int z) {
426 const long i = (long)x + (
long)y * e.x + (long)z * (
long)e.x * e.y;
427 if (sd(i) < 0.0 || sd(i - sa) < 0.0)
432#ifdef PECLET_FLOW_MPI
436 velDev_->exchange(ox_);
437 velDev_->exchange(oy_);
438 velDev_->exchange(oz_);
444 CCField oa[3] = {ox_, oy_, oz_};
445 for (
int a = 0; a < 3; ++a)
446 if (bc_[2 * a + 1] != 0 && touchesGlobalFace(2 * a + 1))
453 B3 e2{e_.x, e_.y, e_.z};
454 CCField oa[3] = {ox_, oy_, oz_};
455 for (
int a = 0; a < 3; ++a)
456 for (
int s = 0; s < 2; ++s) {
457 const int t = bc_[2 * a + s];
458 const bool open = (t == 3) || (t == 2 && (bcProf_[2 * a + s].extent(0) > 0 ||
459 std::fabs(bcVel_[2 * a + s][a]) > 1e-12));
460 if (t != 0 && !open && touchesGlobalFace(2 * a + s))
482 const bool gp = ghostProjection_ && oxb_.extent(0) > 0;
483 CCField dst[3] = {ox1_, oy1_, oz1_};
484 CCField src[3] = {gp ? oxb_ : ox_, gp ? oyb_ : oy_, gp ? ozb_ : oz_};
485 const int de[3] = {e1_.x, e1_.y, e1_.z}, se[3] = {e_.x, e_.y, e_.z};
486 const long dst3[3] = {1, (long)e1_.x, (
long)e1_.x * e1_.y};
487 const long sst3[3] = {1, (long)e_.x, (
long)e_.x * e_.y};
488 for (
int a = 0; a < 3; ++a) {
489 if (bc_[2 * a + 1] != 3 || !touchesGlobalFace(2 * a + 1))
491 const int b = (a + 1) % 3, c = (a + 2) % 3;
492 const long dsa = dst3[a], dsb = dst3[b], dsc = dst3[c];
493 const long ssa = sst3[a], ssb = sst3[b], ssc = sst3[c];
494 const long dbf = de[a] - 1, sbf = se[a] -
G;
495 const int nb = de[b] - 2, nc = de[c] - 2;
498 Kokkos::parallel_for(
500 KOKKOS_LAMBDA(
int p0,
int p1) {
501 d((
long)(p0 + 1) * dsb + (
long)(p1 + 1) * dsc + dbf * dsa) =
502 sv((
long)(p0 +
G) * ssb + (
long)(p1 +
G) * ssc + sbf * ssa);
521 const int dims[3] = {e_.x, e_.y, e_.z};
522 const long st[3] = {1, (long)e_.x, (
long)e_.x * e_.y};
525 for (
int f = 0; f < 6; ++f) {
527 own[f] = touchesGlobalFace(f) ? 1 : 0;
529 long sealedOn[6] = {0, 0, 0, 0, 0, 0};
530 for (
int a = 0; a < 3; ++a)
531 for (
int s = 0; s < 2; ++s) {
532 if (bct[2 * a + s] != 2 || !own[2 * a + s])
534 const int b = (a + 1) % 3, c = (a + 2) % 3;
535 const long sa = st[a], sb = st[b], sc = st[c];
536 const long base = (long)((s == 0) ?
G : dims[a] -
G - 1) * sa;
537 const long inflowFace = (s == 0) ? 0 : sa;
538 const int nb = dims[b] - 2 *
G, nc = dims[c] - 2 *
G;
540 const int dd[3] = {dims[0], dims[1], dims[2]};
541 const long ss[3] = {st[0], st[1], st[2]};
542 const int cA = a, cB = b, cC = c, cS = s;
544 Kokkos::parallel_reduce(
546 KOKKOS_LAMBDA(
int pb,
int pc,
long& acc) {
547 const long i = base + (long)(pb +
G) * sb + (long)(pc +
G) * sc;
548 if (oc[cA](i + inflowFace) <= 0.0)
551 idx[cA] = (cS == 0) ?
G : (dd[cA] -
G - 1);
555 for (
int a2 = 0; a2 < 3; ++a2)
556 for (
int s2 = 0; s2 < 2; ++s2) {
557 const bool global = own[2 * a2 + s2] != 0 &&
558 ((s2 == 0) ? (idx[a2] ==
G) : (idx[a2] == dd[a2] -
G - 1));
559 const int t = bct[2 * a2 + s2];
560 if (global && (t == 1 || t == 2 || t == 4))
562 alpha += oc[a2](i + ((s2 == 0) ? 0 : ss[a2]));
568 sealedOn[2 * a + s] = sealed;
570#ifdef PECLET_FLOW_MPI
573 MPI_Allreduce(sealedOn, g, 6, MPI_LONG, MPI_SUM, comm_);
574 for (
int f = 0; f < 6; ++f)
578 for (
int f = 0; f < 6; ++f) {
579 if (sealedOn[f] == 0)
581 static const char* kFace[6] = {
"-x",
"+x",
"-y",
"+y",
"-z",
"+z"};
582 throw std::runtime_error(
583 std::string(
"set_solid: the immersed solid seals ") + std::to_string(sealedOn[f]) +
584 " fluid cell(s) against the " + kFace[f] +
585 " INFLOW face off from the rest of the domain: their pressure row is entirely closed "
586 "yet the inflow still feeds them, which no pressure field can satisfy (the pressure "
587 "solve would run to its iteration cap with max|div| stuck at the inflow velocity). "
588 "Either pull the solid clear of that face, refine the grid so the pocket connects, or "
589 "make the face a wall. See doc/cutcell_openbc_convergence.md.");
595 if (fluidOnlyMode_ == 2) {
600 if (porous_ || varRho_ || hasBc_ || ghostProjection_ || distributed_ || !Grid::collocated)
601 throw std::runtime_error(
602 "set_fluid_only_constraint(2): v1 is single-rank periodic collocated only");
605 CCField oa1[3] = {ox1_, oy1_, oz1_};
606 const C3 e1 = e1_, e2 = e_;
607 for (
int a = 0; a < 3; ++a) {
609 const long sa2 = (a == 0) ? 1 : (a == 1) ? (
long)e2.x : (long)e2.x * e2.y;
610 Kokkos::parallel_for(
611 "peclet::flow::star_filter_bridge",
MDRange3<CCExec>(space, {0, 0, 0}, {nx_, ny_, nz_}),
612 KOKKOS_LAMBDA(
int x,
int y,
int z) {
614 (long)(x +
G) + (long)(y +
G) * e2.x + (long)(z +
G) * (long)e2.x * e2.y;
615 if (sd(i2) < 0.0 || sd(i2 - sa2) < 0.0)
616 o1((
long)(x + 1) + (
long)(y + 1) * e1.
x + (
long)(z + 1) * (
long)e1.
x * e1.
y) = 0.0;
620 starCounter_ = Kokkos::View<int, CCMem>(
"star_counter");
621 const C3 nn{nx_, ny_, nz_};
634 const std::size_t nTot = work.size();
635 auto id = [&](
int x,
int y,
int z) {
636 return (std::size_t)((x + nx) % nx) + (std::size_t)((y + ny) % ny) * nx +
637 (std::size_t)((z + nz) % nz) * (std::size_t)nx * ny;
639 std::vector<int> comp(nTot, -1);
640 std::vector<std::size_t> stack;
641 int ncomp = 0, mainComp = -1;
642 std::size_t mainSize = 0, nActive = 0;
643 for (std::size_t seed = 0; seed < nTot; ++seed) {
644 if (comp[seed] >= 0 || work[seed] < 0.0)
646 std::size_t size = 0;
648 stack.assign(1, seed);
649 while (!stack.empty()) {
650 const std::size_t c = stack.back();
653 const int x = (int)(c % nx), y = (int)((c / nx) % ny), z = (int)(c / ((std::size_t)nx * ny));
654 const int nb[6][3] = {{x - 1, y, z}, {x + 1, y, z}, {x, y - 1, z},
655 {x, y + 1, z}, {x, y, z - 1}, {x, y, z + 1}};
657 const std::size_t j = id(q[0], q[1], q[2]);
658 if (comp[j] >= 0 || work[j] < 0.0)
661 if (0.5 * (work[c] + work[j]) < 0.0)
667 if (size > mainSize) {
675 std::size_t pockets = 0;
676 for (std::size_t i = 0; i < nTot; ++i)
677 if (work[i] >= 0.0 && comp[i] != mainComp) {
678 work[i] = -(std::abs(work[i]) * 1.001 + 1e-30);
683 "peclet::flow ghost projection: %d fluid components; decoupled %zu pocket "
684 "cells outside the main component (%zu of %zu fluid cells)\n",
685 ncomp, pockets, mainSize, nActive);
690std::vector<double> Solver<Grid>::gpPocketGuardSdf(
CCField din) {
694 std::vector<double> sdfInnerHost_;
695 auto sdfInner_ = [&]() ->
const std::vector<double>& {
696 if (sdfInnerHost_.empty()) {
697 const std::size_t nI = (std::size_t)nx_ * ny_ * nz_;
698 sdfInnerHost_.resize(nI);
700 Kokkos::View<
double*, Kokkos::HostSpace, Kokkos::MemoryTraits<Kokkos::Unmanaged>>(
701 sdfInnerHost_.data(), nI),
704 return sdfInnerHost_;
706 std::vector<double> sdfGpHost;
707 std::vector<double> work;
708 int fx = nx_, fy = ny_, fz = nz_;
710#ifdef PECLET_FLOW_MPI
713 MPI_Comm_rank(comm_, &myRank);
715 MPI_Comm_size(comm_, &nRanks);
719 verbose = myRank == 0;
720 std::vector<int> cnts(nRanks), disp(nRanks);
722 for (
int r = 0;
r < nRanks; ++
r) {
723 const auto b = dec_->block(r);
724 cnts[
r] = (
int)(
b.size[0] *
b.size[1] *
b.size[2]);
728 std::vector<double> flat((std::size_t)acc);
729 MPI_Allgatherv(sdfInner_().data(), (
int)sdfInner_().
size(), MPI_DOUBLE, flat.data(),
730 cnts.data(), disp.data(), MPI_DOUBLE, comm_);
731 work.assign((std::size_t)fx * fy * fz, 0.0);
732 for (
int r = 0;
r < nRanks; ++
r) {
733 const auto b = dec_->block(r);
734 const double* src = flat.data() + disp[
r];
735 for (
int z = 0;
z < (
int)
b.size[2]; ++
z)
736 for (
int y = 0;
y < (
int)
b.size[1]; ++
y)
737 for (
int x = 0;
x < (
int)
b.size[0]; ++
x)
738 work[(std::size_t)(
x +
b.origin[0]) + (std::size_t)(
y +
b.origin[1]) * fx +
739 (std::size_t)(
z +
b.origin[2]) * (std::size_t)
fx * fy] =
740 src[(std::size_t)x + (std::size_t)
y *
b.size[0] +
741 (std::size_t)z * (std::size_t)
b.size[0] *
b.size[1]];
747#ifdef PECLET_FLOW_MPI
749 const auto b = dec_->block(myRank);
750 sdfGpHost.resize(sdfInner_().
size());
751 for (
int z = 0;
z < nz_; ++
z)
752 for (
int y = 0;
y < ny_; ++
y)
753 for (
int x = 0;
x < nx_; ++
x)
754 sdfGpHost[(std::size_t)
x + (std::size_t)y * nx_ +
755 (std::size_t)
z * (std::size_t)nx_ * ny_] =
756 work[(std::size_t)(
x +
b.origin[0]) + (std::size_t)(
y +
b.origin[1]) * fx +
757 (std::size_t)(
z +
b.origin[2]) * (std::size_t)
fx * fy];
760 sdfGpHost = std::move(work);
767#ifdef PECLET_FLOW_MPI
771 auto h = Kokkos::create_mirror_view(sdfGp_);
772 Kokkos::deep_copy(h, sdfGp_);
773 for (
int z = 0; z < nz_; ++z)
774 for (
int y = 0; y < ny_; ++y)
775 for (
int x = 0; x < nx_; ++x)
776 h((
long)(x +
G) + (
long)(y +
G) * e_.x + (
long)(z +
G) * (
long)e_.x * e_.y) =
777 sdfGpHost[(std::size_t)x + (std::size_t)y * nx_ +
778 (std::size_t)z * (std::size_t)nx_ * ny_];
779 Kokkos::deep_copy(sdfGp_, h);
780 velDev_->exchange(sdfGp_);
784 CCField din(
"peclet::flow::sdfGpInner_d", nInner);
787 Kokkos::View<
const double*, Kokkos::HostSpace, Kokkos::MemoryTraits<Kokkos::Unmanaged>>(
788 sdfGpHost.data(), sdfGpHost.size()));
790 const int ex = e_.x, ey = e_.y, ez = e_.z,
nx = nx_,
ny = ny_,
nz = nz_, g =
G;
791 Kokkos::parallel_for(
792 "peclet::flow::sdfgp_wrap",
MDRange3<CCExec>(space, {0, 0, 0}, {ex, ey, ez}),
793 KOKKOS_LAMBDA(
int x,
int y,
int z) {
794 const int ix = (((x - g) %
nx) +
nx) %
nx, iy = (((y - g) %
ny) +
ny) %
ny,
795 iz = (((z - g) %
nz) +
nz) %
nz;
796 sdfGp((
long)x + (
long)y * ex + (
long)z * (
long)ex * ey) =
797 din((std::size_t)ix + (std::size_t)iy *
nx + (std::size_t)iz * (std::size_t)
nx *
ny);
804void Solver<Grid>::gpBuildOverlay(
CCField sdfGp) {
808 gpMatrixOrder_, gpRhsOrder_, hasExactCross_ ?
CCConst(tEx_[0][0]) :
CCConst(),
814#ifdef PECLET_FLOW_MPI
816 MPI_Comm_rank(comm_, &gpDbgRank);
818 gpDebugReport(gpOv_, gpNRows_,
C3{nx_, ny_, nz_}, gpIdMap_, gpDbgRank);
820 copyInner(ox1_, e1_, 1,
CCConst(oxb_), e_,
G);
821 copyInner(oy1_, e1_, 1,
CCConst(oyb_), e_,
G);
822 copyInner(oz1_, e1_, 1,
CCConst(ozb_), e_,
G);
827 if (ghostProjection_) {
832 if (porous_ || varRho_ || hasBc_)
833 throw std::runtime_error(
834 "ghost projection: incompatible with porous/variable-rho/domain-BC (v1)");
835 const std::size_t nInner = (std::size_t)nx_ * ny_ * nz_;
837 gpIdMap_ = Kokkos::View<int*, CCMem>(
"gp_idmap", nInner);
838 gpCounter_ = Kokkos::View<int, CCMem>(
"gp_counter");
859 const std::vector<double> sdfGpHost = gpPocketGuardSdf(din);
860 sdfGp_ =
CCField(
"peclet::flow::sdfGp", n_);
864 gpBuildOverlay(sdfGp);
872 mg_.setBoundaryConditions(bc_);
879 mg_.setMetric(u_.hp);
883 mg_.setAgglomerationMode(pressGraphAmg_ ? 1 : pressAgglomMode_);
884#ifdef PECLET_FLOW_MPI
887 mg_.setRepartition(weightedDec_);
888 mg_.initMpi(gnx_, gny_, gnz_, nLevels_, comm_, dec_.get());
891 mg_.init(nx_, ny_, nz_,
904 mg_.setOutflowCoefficient(hasOutflow_ && outflowOpCoeff_);
906 Kokkos::deep_copy(phi_, 0.0);
907 Kokkos::deep_copy(P_, 0.0);
912 return geometryBuilt_;
918 throw std::runtime_error(
920 ": call BEFORE the geometry (set_solid / set_pressure_geometry / set_solid_from_scene) "
921 "-- this setting is folded into the operators when the geometry is built, so a later "
922 "call would be silently ignored");
void setSolidUploadSdf(CCField din)
void setSolidInitPressureMg()
void extendSdfDomainGhosts(CCField f)
Repair a cell-centred geometry field's ghost band on every rank-owned NON-PERIODIC domain face,...
void setSolid(const std::vector< double > &sdfInner, bool cutcellPressure)
Host entry point: upload the inner SDF once and delegate.
void setSolidSelectScheme()
void bridgeOutflowFacePlanes()
Bridge the HIGH-side boundary-face openness plane of every rank-owned outflow axis from the g=2 block...
void copyInner(CCField dst, C3 de, int dg, CCConst src, C3 se, int sg)
void requireNoGeometry(const char *who) const
void exchangeExtRaw(CCField f)
Raw ghost fill of an extended-block field: the rank halo exchange under MPI, the periodic wrap single...
void setSolidGhostProjectionOverlay(CCField din)
void buildVelocityOverlays(bool resetU)
Build the three per-component Robust-Scaled cut-cell overlays + solid masks from the CURRENT sdf_ (ex...
void setSolidBuildOverlaysAndStencils()
void setPressureGeometry(const std::vector< double > &sdfInner)
void setSolidDevice(CCField din, bool cutcellPressure)
Device entry point (Layer 2): the inner SDF is ALREADY on device, so geometry never round-trips throu...
bool geometryBuilt() const
void setSolidBuildOpenness()
void setSolidStarOverlay()
void gpUploadSdf(const std::vector< double > &sdfGpHost, std::size_t nInner, CCField sdfGp)
void setSolidVelocityMgAuto()
void checkSealedInflowCells()
Reject geometry that seals fluid cells against a prescribed INFLOW face off from the rest of the doma...
void invalidateScalarCutGeometry()
Kokkos::DefaultExecutionSpace CCExec
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).
void buildFaceCentroidDist(CCField xcx, CCField xcy, CCField xcz, CCConst sdf, C3 e)
void ibmSolidMask(CCField mask, CCConst sdf, C3 ext, Off3 off)
void gpBinaryOpenness(CCField ox, CCField oy, CCField oz, CCConst sdf, C3 ext)
Binary openness for the symmetric MG surrogate, on the extended-block layout of buildOpenness: o(face...
Kokkos::View< const double *, CCMem > CCConst
StarOverlay starMakeOverlay(long n)
void buildCellFraction(CCField cs, CCConst sdf, C3 e, int g)
void bcZeroOpenness(BField oa, B3 ext, int g, int a, int s)
GpOverlayReal< Real > gpMakeOverlay(long n)
int buildStarOverlay(CCConst sdf, CCConst ox, CCConst oy, CCConst oz, C3 ext, int g, C3 nn, const StarOverlay &ov, Kokkos::View< int, CCMem > counter)
Count + fill the star overlay from the cell-centered sdf and the ORIGINAL (unfiltered) apertures on t...
int gpDebugLevel()
0 = off (default). Read once per call; cheap enough, and keeps the flag hot-swappable in tests.
void buildOpennessHighFace(CCField oa, CCConst sdf, C3 ext, int g, int a, double dx, double dy, double dz, int order=1)
int buildGpOverlay(CCConst sdf, C3 ext, int g, C3 nn, const GpOverlayReal< Real > &ov, Kokkos::View< int *, CCMem > idMap, Kokkos::View< int, CCMem > counter, int matrixOrder=2, int rhsOrder=2, CCConst tx=CCConst(), CCConst ty=CCConst(), CCConst tz=CCConst(), bool useGhost=false)
Build the overlay over the inner grid nn from the cell-centered sdf on the extended block (ext,...
Kokkos::View< double *, CCMem > CCField
void bcMirrorGhost(BField f, B3 ext, int g, int a, int s)
int buildIbmOverlay(CCConst sdf, C3 ext, int g, Off3 off, int bc_type, const IbmOverlay &ov, Kokkos::View< int *, CCMem > idMap, Kokkos::View< int, CCMem > counter, CCConst tx=CCConst(), CCConst ty=CCConst(), CCConst tz=CCConst(), C3 nn=C3{0, 0, 0}, mreal slipLambda=mreal(0), int comp=-1, Kokkos::View< int, CCMem > sandwichSkipped=Kokkos::View< int, CCMem >(), mreal hpx=mreal(1), mreal hpy=mreal(1), mreal hpz=mreal(1))
slipLambda (WO-V6b, in CELLS, 0 = the validated no-slip closure) + comp (which velocity component thi...
void gpDecouplePockets(std::vector< double > &work, int nx, int ny, int nz, bool verbose)
void gpDebugReport(const GpOverlayReal< Real > &ov, int nRows, C3 nn, Kokkos::View< int *, CCMem > idMap, int rank=0)
Census + optional per-row dump of the built overlay.
void buildOpenness(CCField ox, CCField oy, CCField oz, CCConst sdf, C3 ext, double dx, double dy, double dz, int order=1)
void bcNeumannGhost(BField f, B3 ext, int g, int a, int s)
Kokkos::MDRangePolicy< Exec, Kokkos::Rank< 2, Kokkos::Iterate::Left, Kokkos::Iterate::Left > > MDRange2
2-D range, first index fastest (both the tile order and the order within a tile).
One entry per eliminated solid-centered cell: packed INNER flat index + the apertures of its (up to 6...
Kokkos::View< const double *, CCMem > CCConst
Kokkos::View< double *, CCMem > CCField