59#ifndef PECLET_FLOW_SCALAR_MG_HPP
60#define PECLET_FLOW_SCALAR_MG_HPP
66#include <Kokkos_Core.hpp>
91 return (
unk(i) > 0.5 &&
unk(i -
st) > 0.5) ?
lam *
ap(i) : 0.0;
115 "peclet::flow::smg_restrict_max",
C3{0, 0, 0}, cinner,
116 KOKKOS_LAMBDA(
int icx,
int icy,
int icz) {
117 const long fsy = fext.
x, fsz = (long)fext.
x * fext.
y;
119 for (
int dz = 0; dz < ratio.z; ++dz)
120 for (
int dy = 0; dy < ratio.y; ++dy)
121 for (
int dx = 0; dx < ratio.x; ++dx) {
122 const long fi = (long)(ratio.x * icx + dx + gf) +
123 (long)(ratio.y * icy + dy + gf) * fsy +
124 (long)(ratio.z * icz + dz + gf) * fsz;
125 m = fine(fi) > m ? fine(fi) : m;
127 coarse((
long)(icx + gc) + (
long)(icy + gc) * cext.
x +
128 (
long)(icz + gc) * (
long)cext.
x * cext.
y) = m > 0.5 ? 1.0 : 0.0;
135 "peclet::flow::smg_zero_pinned",
C3{g, g, g},
C3{e.x - g, e.y - g, e.z - g},
136 KOKKOS_LAMBDA(
int lx,
int ly,
int lz) {
137 const long i = (long)lx + (
long)ly * e.x + (long)lz * (
long)e.x * e.y;
148 const int ext[3] = {e.x, e.y, e.z};
149 const int b = (a + 1) % 3, c = (a + 2) % 3;
150 const long st[3] = {1, (long)e.x, (
long)e.x * e.y};
151 const long sa = st[a], sb = st[b], sc = st[c];
152 const int nb = ext[b], nc = ext[c];
154 auto row = KOKKOS_LAMBDA(
long t) {
155 const int pb = (int)(t % nb), pc = (int)(t / nb);
156 for (
int k = lo; k < hi; ++k)
157 f((
long)k * sa + (
long)pb * sb + (
long)pc * sc) = 0.0;
159 if constexpr (std::is_same_v<typename CCExec::memory_space, Kokkos::HostSpace>) {
161 const HostSerialRegion serialRegion(
"peclet::flow::smg_zero_planes@serial");
162 for (
long t = 0; t < (long)nb * nc; ++t)
167 Kokkos::parallel_for(
"peclet::flow::smg_zero_planes",
168 Kokkos::RangePolicy<CCExec>(space, 0, (
long)nb * nc), row);
182 const int nx = inner.x, ny = inner.y, nz = inner.z;
183 const long exy = (long)e.x * e.y;
184 const bool px = per[0], py = per[1], pz = per[2];
186 if constexpr (std::is_same_v<typename CCExec::memory_space, Kokkos::HostSpace>) {
188 const long rZ = 2L * g * e.y, rY = (long)nz * 2 * g, rX = (
long)nz * ny;
189 auto row = [=](
long t) {
193 const int l = (int)(t / e.y), y = (int)(t - (
long)l * e.y);
194 const int z = l < g ? l : nz + l;
195 const bool yg = y < g || y >= g + ny;
196 const int sy = y < g ? y + ny : (y >= g + ny ? y - ny : y);
197 const int sz = z < g ? z + nz : z - nz;
198 zero = !pz || (yg && !py);
199 dst = (long)y * e.x + (
long)z * exy;
200 src = (long)sy * e.x + (
long)sz * exy;
201 }
else if (t < rZ + rY) {
202 const long t2 = t - rZ;
203 const int zi = (int)(t2 / (2 * g)), l = (int)(t2 - (
long)zi * 2 * g);
204 const int y = l < g ? l : ny + l, z = g + zi;
205 const int sy = y < g ? y + ny : y - ny;
207 dst = (long)y * e.x + (
long)z * exy;
208 src = (long)sy * e.x + (
long)z * exy;
210 const long t3 = t - rZ - rY;
211 const int zi = (int)(t3 / ny), yi = (int)(t3 - (
long)zi * ny);
212 const long base = (long)(g + yi) * e.x + (long)(g + zi) * exy;
213 for (
int x = 0; x < g; ++x)
214 ff(base + x) = px ? ff(base + x + nx) : 0.0;
215 for (
int x = g + nx; x < e.x; ++x)
216 ff(base + x) = px ? ff(base + x - nx) : 0.0;
220 for (
int x = 0; x < e.x; ++x)
224 for (
int x = 0; x < g; ++x)
225 ff(dst + x) = px ? ff(src + x + nx) : 0.0;
226 for (
int x = g; x < g + nx; ++x)
227 ff(dst + x) = ff(src + x);
228 for (
int x = g + nx; x < e.x; ++x)
229 ff(dst + x) = px ? ff(src + x - nx) : 0.0;
231 const long cells = 2L * g * exy + (long)nz * 2 * g * e.x + (
long)nz * ny * 2 * g;
234 for (
long t = 0; t < rZ + rY + rX; ++t)
238 Kokkos::parallel_for(
"peclet::flow::smg_fill_shell",
239 Kokkos::RangePolicy<CCExec>(space, 0, rZ + rY + rX), row);
242 const long nZ = 2L * g * exy, nY = (long)nz * 2 * g * e.x, nX = (
long)nz * ny * 2 * g;
243 Kokkos::parallel_for(
244 "peclet::flow::smg_fill_shell", Kokkos::RangePolicy<CCExec>(space, 0, nZ + nY + nX),
245 KOKKOS_LAMBDA(
long t) {
248 const int l = (int)(t / exy);
249 const long r = t - (long)l * exy;
252 z = l < g ? l : nz + l;
253 }
else if (t < nZ + nY) {
254 const long t2 = t - nZ, rw = 2L * g * e.x;
255 const long zi = t2 / rw, r = t2 - zi * rw;
256 const int l = (int)(r / e.x);
258 y = l < g ? l : ny + l;
261 const long t3 = t - nZ - nY, rw = (long)ny * 2 * g;
262 const long zi = t3 / rw, r = t3 - zi * rw;
263 const int l = (int)(r % (2 * g));
264 x = l < g ? l : nx + l;
265 y = g + (int)(r / (2 * g));
268 const bool gx = x < g || x >= g + nx, gy = y < g || y >= g + ny, gz = z < g || z >= g + nz;
269 const long d = (long)x + (
long)y * e.x + (long)z * exy;
270 if ((gx && !px) || (gy && !py) || (gz && !pz)) {
274 const int sx = x < g ? x + nx : (x >= g + nx ? x - nx : x);
275 const int sy = y < g ? y + ny : (y >= g + ny ? y - ny : y);
276 const int sz = z < g ? z + nz : (z >= g + nz ? z - nz : z);
277 ff(d) = ff((
long)sx + (
long)sy * e.x + (
long)sz * exy);
288KOKKOS_INLINE_FUNCTION
Nb nbrs(
int lx,
int ly,
int lz,
C3 n,
int g,
long i,
long sy,
long sz,
291 w.xm = ((
wrap & 1) && lx == g) ? i + (
long)(n.x - 1) : i - 1;
292 w.xp = ((
wrap & 1) && lx == g + n.x - 1) ? i - (
long)(n.x - 1) : i + 1;
293 w.ym = ((
wrap & 2) && ly == g) ? i + (
long)(n.y - 1) * sy : i - sy;
294 w.yp = ((
wrap & 2) && ly == g + n.y - 1) ? i - (
long)(n.y - 1) * sy : i + sy;
295 w.zm = ((
wrap & 4) && lz == g) ? i + (
long)(n.z - 1) * sz : i - sz;
296 w.zp = ((
wrap & 4) && lz == g + n.z - 1) ? i - (
long)(n.z - 1) * sz : i + sz;
303KOKKOS_INLINE_FUNCTION
Nb nbrsOn(
int lx,
int ly,
int lz,
C3 n,
int g,
long i,
long sy,
long sz,
305 if constexpr (std::is_same_v<typename CCExec::memory_space, Kokkos::HostSpace>) {
306 (void)lx, (
void)ly, (void)lz, (
void)n, (void)g, (
void)
wrap;
307 return Nb{i + 1, i - 1, i + sy, i - sy, i + sz, i - sz};
309 return nbrs(lx, ly, lz, n, g, i, sy, sz,
wrap);
317 int g,
int color,
C3 n,
int wrap) {
319 if constexpr (std::is_same_v<typename CCExec::memory_space, Kokkos::HostSpace>) {
320 const int nyi = e.y - 2 * g, nzi = e.z - 2 * g;
321 const long cells = (long)nyi * nzi * (e.x - 2 * g);
322 auto pencil = KOKKOS_LAMBDA(
long t) {
323 const int ly = g + (int)(t % nyi), lz = g + (int)(t / nyi);
324 const long sx = 1, sy = e.x, sz = (long)e.x * e.y;
325 const int P = (color + og.x + og.y + ly + og.z + lz) & 1;
327 for (
int lx = g + ((P ^ (g & 1)) & 1); lx < e.x - g; lx += 2) {
328 const long i = (long)lx + (
long)ly * sy + (long)lz * sz;
330 cutcellSmoothFaceCell(x, rhs,
AC, AFX, AFY, AFZ, i, sx, sy, sz, w.xp, w.xm, w.yp, w.ym,
336 for (
long t = 0; t < (long)nyi * nzi; ++t)
340 Kokkos::parallel_for(
"peclet::flow::smg_smooth",
341 Kokkos::RangePolicy<CCExec>(space, 0, (
long)nyi * nzi), pencil);
345 Kokkos::parallel_for(
346 "peclet::flow::smg_smooth", MD(space, {g, g, g}, {e.x - g, e.y - g, e.z - g}),
347 KOKKOS_LAMBDA(
int lx,
int ly,
int lz) {
348 if (((og.x + lx + og.y + ly + og.z + lz) & 1) != color)
350 const long sx = 1, sy = e.x, sz = (long)e.x * e.y;
351 const long i = (long)lx + (
long)ly * sy + (long)lz * sz;
353 cutcellSmoothFaceCell(x, rhs,
AC, AFX, AFY, AFZ, i, sx, sy, sz, w.xp, w.xm, w.yp, w.ym,
363 "peclet::flow::smg_residual",
C3{g, g, g},
C3{e.x - g, e.y - g, e.z - g},
364 KOKKOS_LAMBDA(
int lx,
int ly,
int lz) {
365 const long sx = 1, sy = e.x, sz = (long)e.x * e.y;
366 const long i = (long)lx + (
long)ly * sy + (long)lz * sz;
368 cutcellResidualFaceCell(r, x, b,
AC, AFX, AFY, AFZ, i, sx, sy, sz, w.xp, w.xm, w.yp, w.ym,
384 return (
unk(i) > 0.5 &&
unk(i -
st) > 0.5) ? Kokkos::fmax(
sgn *
phi(i), 0.0) : 0.0;
390template <
class XV,
class BV>
391KOKKOS_INLINE_FUNCTION
double bandOff(
const XV& x,
const BV& AW,
const BV& AE,
const BV& AS,
392 const BV& AN,
const BV& AB,
const BV& AT,
long i,
394 return ((AW(i) * x(w.xm) + AE(i) * x(w.xp)) + (AS(i) * x(w.ym) + AN(i) * x(w.yp))) +
395 (AB(i) * x(w.zm) + AT(i) * x(w.zp));
401template <
class BV,
class UV>
403 UV unk,
C3 e,
C3 og,
int g,
int color,
C3 n,
int wrap) {
405 if constexpr (std::is_same_v<typename CCExec::memory_space, Kokkos::HostSpace>) {
406 const int nyi = e.y - 2 * g, nzi = e.z - 2 * g;
407 const long cells = (long)nyi * nzi * (e.x - 2 * g);
408 auto pencil = KOKKOS_LAMBDA(
long t) {
409 const int ly = g + (int)(t % nyi), lz = g + (int)(t / nyi);
410 const long sy = e.x, sz = (long)e.x * e.y;
411 const int P = (color + og.x + og.y + ly + og.z + lz) & 1;
412 for (
int lx = g + ((P ^ (g & 1)) & 1); lx < e.x - g; lx += 2) {
413 const long i = (long)lx + (
long)ly * sy + (long)lz * sz;
417 x(i) = (rhs(i) -
bandOff(x, AW, AE, AS, AN, AB, AT, i, w)) /
AC(i);
421 const HostSerialRegion serialRegion(
"peclet::flow::smg_smooth_band@serial");
422 for (
long t = 0; t < (long)nyi * nzi; ++t)
426 Kokkos::parallel_for(
"peclet::flow::smg_smooth_band",
427 Kokkos::RangePolicy<CCExec>(space, 0, (
long)nyi * nzi), pencil);
431 Kokkos::parallel_for(
432 "peclet::flow::smg_smooth_band", MD(space, {g, g, g}, {e.x - g, e.y - g, e.z - g}),
433 KOKKOS_LAMBDA(
int lx,
int ly,
int lz) {
434 if (((og.x + lx + og.y + ly + og.z + lz) & 1) != color)
436 const long sy = e.x, sz = (long)e.x * e.y;
437 const long i = (long)lx + (
long)ly * sy + (long)lz * sz;
441 x(i) = (rhs(i) -
bandOff(x, AW, AE, AS, AN, AB, AT, i, w)) /
AC(i);
447template <
class XV,
class OV>
448KOKKOS_INLINE_FUNCTION
double faceOff(
const XV& x,
const OV& AFX,
const OV& AFY,
const OV& AFZ,
449 long i,
long sx,
long sy,
long sz,
const Nb& w) {
450 return AFX(i + sx) * x(w.xp) + AFX(i) * x(w.xm) + AFY(i + sy) * x(w.yp) + AFY(i) * x(w.ym) +
451 AFZ(i + sz) * x(w.zp) + AFZ(i) * x(w.zm);
462template <
bool Band,
class XV,
class BV>
463KOKKOS_INLINE_FUNCTION
void twoPhaseCell(
const XV& x,
const XV& rhs,
const BV&
AC,
const BV& AFX,
464 const BV& AFY,
const BV& AFZ,
const BV& AW,
const BV& AE,
465 const BV& AS,
const BV& AN,
const BV& AB,
const BV& AT,
466 const XV& xs,
const XV& rhss,
const BV& ACs,
467 const BV& AFXs,
const BV& AFYs,
const BV& AFZs,
468 const BV& W,
const CCConst& unkF,
long i,
long sx,
long sy,
469 long sz,
const Nb& w) {
470 const double wc = W(i);
471 const double af =
AC(i), as = ACs(i);
473 const double nf = Band ?
bandOff(x, AW, AE, AS, AN, AB, AT, i, w)
474 :
faceOff(x, AFX, AFY, AFZ, i, sx, sy, sz, w);
475 const double rf = rhs(i) - nf;
476 const double rs = rhss(i) -
faceOff(xs, AFXs, AFYs, AFZs, i, sx, sy, sz, w);
477 const double det = af * as - wc * wc;
478 if (det > 1e-300 * af * as) {
479 x(i) = (as * rf + wc * rs) / det;
480 xs(i) = (wc * rf + af * rs) / det;
482 x(i) = (rf + wc * xs(i)) / af;
483 xs(i) = (rs + wc * x(i)) / as;
487 if constexpr (Band) {
489 x(i) = (rhs(i) -
bandOff(x, AW, AE, AS, AN, AB, AT, i, w)) / af;
492 x(i) = (rhs(i) -
faceOff(x, AFX, AFY, AFZ, i, sx, sy, sz, w)) / af;
495 xs(i) = (rhss(i) -
faceOff(xs, AFXs, AFYs, AFZs, i, sx, sy, sz, w)) / as;
506 if constexpr (std::is_same_v<typename CCExec::memory_space, Kokkos::HostSpace>) {
507 const int nyi = e.y - 2 * g, nzi = e.z - 2 * g;
508 const long cells = (long)nyi * nzi * (e.x - 2 * g);
509 auto pencil = KOKKOS_LAMBDA(
long t) {
510 const int ly = g + (int)(t % nyi), lz = g + (int)(t / nyi);
511 const long sx = 1, sy = e.x, sz = (long)e.x * e.y;
512 const int P = (color + og.x + og.y + ly + og.z + lz) & 1;
513 for (
int lx = g + ((P ^ (g & 1)) & 1); lx < e.x - g; lx += 2) {
514 const long i = (long)lx + (
long)ly * sy + (long)lz * sz;
516 twoPhaseCell<Band>(x, rhs,
AC, AFX, AFY, AFZ, AW, AE, AS, AN, AB, AT, xs, rhss, ACs, AFXs,
517 AFYs, AFZs, W, unkF, i, sx, sy, sz, w);
522 for (
long t = 0; t < (long)nyi * nzi; ++t)
526 Kokkos::parallel_for(
"peclet::flow::smg_smooth_two",
527 Kokkos::RangePolicy<CCExec>(space, 0, (
long)nyi * nzi), pencil);
531 Kokkos::parallel_for(
532 "peclet::flow::smg_smooth_two", MD(space, {g, g, g}, {e.x - g, e.y - g, e.z - g}),
533 KOKKOS_LAMBDA(
int lx,
int ly,
int lz) {
534 if (((og.x + lx + og.y + ly + og.z + lz) & 1) != color)
536 const long sx = 1, sy = e.x, sz = (long)e.x * e.y;
537 const long i = (long)lx + (
long)ly * sy + (long)lz * sz;
539 twoPhaseCell<Band>(x, rhs,
AC, AFX, AFY, AFZ, AW, AE, AS, AN, AB, AT, xs, rhss, ACs, AFXs,
540 AFYs, AFZs, W, unkF, i, sx, sy, sz, w);
552 "peclet::flow::smg_residual_two",
C3{g, g, g},
C3{e.x - g, e.y - g, e.z - g},
553 KOKKOS_LAMBDA(
int lx,
int ly,
int lz) {
554 const long sx = 1, sy = e.x, sz = (long)e.x * e.y;
555 const long i = (long)lx + (
long)ly * sy + (long)lz * sz;
557 const double ax = Band ?
AC(i) * x(i) +
bandOff(x, AW, AE, AS, AN, AB, AT, i, w)
558 :
AC(i) * x(i) +
faceOff(x, AFX, AFY, AFZ, i, sx, sy, sz, w);
559 const double axs = ACs(i) * xs(i) +
faceOff(xs, AFXs, AFYs, AFZs, i, sx, sy, sz, w);
560 const double wc = W(i);
561 r(i) = (b(i) - ax) + wc * xs(i);
562 rs(i) = (bs(i) - axs) + wc * x(i);
571 "peclet::flow::smg_residual_band",
C3{g, g, g},
C3{e.x - g, e.y - g, e.z - g},
572 KOKKOS_LAMBDA(
int lx,
int ly,
int lz) {
573 const long sy = e.x, sz = (long)e.x * e.y;
574 const long i = (long)lx + (
long)ly * sy + (long)lz * sz;
576 r(i) = b(i) - (
AC(i) * x(i) +
bandOff(x, AW, AE, AS, AN, AB, AT, i, w));
584 static constexpr int G0 = 2;
585 static constexpr int GC = 1;
598 C3 ext{0, 0, 0},
inner{0, 0, 0},
ratio{1, 1, 1},
cfac{1, 1, 1};
607 Kokkos::View<double*, CCMem>
plane[6];
618 CCField xs,
rhss,
ress,
ACs,
AFXs,
AFYs,
AFZs,
unks,
masss,
pxs,
pys,
pzs,
W;
623#ifdef PECLET_FLOW_MPI
624 std::shared_ptr<GridHaloTopology<3>> halo;
625 std::shared_ptr<GridHalo<double>> dev;
631 for (
int a = 0; a < 3; ++a) {
635 aniso_ = !(hp_[0] == 1.0 && hp_[1] == 1.0 && hp_[2] == 1.0);
639 for (
int a = 0; a < 3; ++a)
651 distributed_ =
false;
652 fill0_ = std::move(fill0);
653 C3 inner{nx, ny, nz}, cf{1, 1, 1};
656 v.g = L == 0 ?
G0 :
GC;
659 v.ext =
C3{inner.x + 2 * v.g, inner.y + 2 * v.g, inner.z + 2 * v.g};
661 v.n = (std::size_t)v.ext.x * v.ext.y * v.ext.z;
662 const bool canA[3] = {
can(inner.x),
can(inner.y),
can(inner.z)};
664 const C3 next{ratio.x == 2 ? inner.x / 2 : inner.x, ratio.y == 2 ? inner.y / 2 : inner.y,
665 ratio.z == 2 ? inner.z / 2 : inner.z};
669 if (next.
x == inner.x && next.
y == inner.y && next.
z == inner.z)
672 cf =
C3{cf.x * ratio.x, cf.y * ratio.y, cf.z * ratio.z};
675#ifdef PECLET_FLOW_MPI
679 void initMpi(
const peclet::core::decomp::BlockDecomposer<3>& dec0, MPI_Comm comm,
C3 og0,
684 fill0_ = std::move(fill0);
686 MPI_Comm_rank(comm, &rank);
687 std::array<bool, 3> per{
true,
true,
true};
688 const auto& g0 = dec0.globalSize();
689 C3 gs{(int)g0[0], (
int)g0[1], (int)g0[2]}, cf{1, 1, 1};
690 auto evenOn = [](
const peclet::core::decomp::BlockDecomposer<3>&
d,
int ax) {
691 for (std::size_t b = 0;
b <
d.numBlocks(); ++
b) {
692 const auto blk =
d.block(b);
693 if (blk.origin[ax] % 2 != 0 || blk.size[ax] % 2 != 0)
698 peclet::core::decomp::BlockDecomposer<3> dec = dec0;
703 const auto blk = dec.block((std::size_t)rank);
704 v.inner = C3{(
int)blk.size[0], (
int)blk.size[1], (
int)blk.size[2]};
705 v.ext = C3{
v.inner.x + 2 *
G0,
v.inner.y + 2 *
G0,
v.inner.z + 2 *
G0};
708 v.halo = std::make_shared<GridHaloTopology<3>>();
709 v.halo->buildTopology(dec, rank,
v.g, per, comm);
710 v.dev = std::make_shared<GridHalo<double>>();
711 v.dev->init(*
v.halo);
712 v.dev->setLabel(
"smg L" + std::to_string(L));
713 const auto& idx =
v.halo->indexer();
714 const auto eg = idx.sizeInclGhost(), ino = idx.sizeInner(), oig = idx.originInclGhost();
715 v.ext = {(
int)eg[0], (
int)
eg[1], (
int)eg[2]};
716 v.inner = {(
int)ino[0], (
int)ino[1], (
int)ino[2]};
717 v.og = {(
int)oig[0] +
v.g, (
int)oig[1] +
v.g, (
int)oig[2] +
v.g};
721 v.n = (std::size_t)
v.ext.x *
v.ext.y *
v.ext.z;
722 const bool canA[3] = {
can(
gs.x) && evenOn(dec, 0),
can(
gs.y) && evenOn(dec, 1),
723 can(
gs.z) && evenOn(dec, 2)};
730 if (next.
x ==
gs.x && next.
y ==
gs.y && next.
z ==
gs.z)
739 int levels()
const {
return (
int)lv_.size(); }
746 for (
const auto& v : lv_)
747 r.push_back(v.ratio);
760 Kokkos::View<const double*, CCMem>
facetW;
761 bool dirFace[6] = {
false,
false,
false,
false,
false,
false};
783 Kokkos::View<const double*, CCMem>
facetC;
790 nUse_ = in.
fullTable ? (int)lv_.size() : 1;
813 for (
int f = 0; f < 6; ++f)
817 wallReuse_ = !newLists &&
wallKeep(in);
818 for (
int f = 0; f < 6; ++f)
819 if (dirFace_[f] &&
touches(l0, f))
821 for (
int L = 1; L < nUse_; ++L)
833 Kokkos::deep_copy(
CCExec(), z, 0.0);
835 for (
int k = 0; k < 2; ++k) {
839 for (
int k = 0; k < 2; ++k) {
857 Kokkos::deep_copy(
CCExec(), zf, 0.0);
858 Kokkos::deep_copy(
CCExec(), zs, 0.0);
860 for (
int k = 0; k < 2; ++k) {
864 for (
int k = 0; k < 2; ++k) {
882 AFYs = l0.
AFYs, AFZs = l0.
AFZs, W = l0.
W, AW = l0.
AW, AE = l0.
AE, AS = l0.
AS,
883 AN = l0.
AN, AB = l0.
AB, AT = l0.
AT;
884 const bool band = adv_;
887 "peclet::flow::smg_apply_two",
C3{g, g, g},
C3{e.x - g, e.y - g, e.z - g},
888 KOKKOS_LAMBDA(
int lx,
int ly,
int lz) {
889 const long sx = 1, sy = e.x, sz = (long)e.x * e.y;
890 const long i = (long)lx + (
long)ly * sy + (long)lz * sz;
891 const smg::Nb w{i + sx, i - sx, i + sy, i - sy, i + sz, i - sz};
892 const double ax = band ?
AC(i) * x(i) +
smg::bandOff(x, AW, AE, AS, AN, AB, AT, i, w)
893 :
AC(i) * x(i) +
smg::faceOff(x, AFX, AFY, AFZ, i, sx, sy, sz, w);
894 const double axs = ACs(i) * s(i) +
smg::faceOff(s, AFXs, AFYs, AFZs, i, sx, sy, sz, w);
895 yf(i) = ax - W(i) * s(i);
896 ys(i) = axs - W(i) * x(i);
907 applyCutcellOp(y,
CCConst(x), l0.
AC, l0.
AW, l0.
AE, l0.
AS, l0.
AN, l0.
AB, l0.
AT, e, g);
913 "peclet::flow::smg_apply",
C3{g, g, g},
C3{e.x - g, e.y - g, e.z - g},
914 KOKKOS_LAMBDA(
int lx,
int ly,
int lz) {
915 const long sx = 1, sy = e.x, sz = (long)e.x * e.y;
916 const long i = (long)lx + (
long)ly * sy + (long)lz * sz;
917 y(i) =
cutcellApplyFaceCell(xx,
AC, AFX, AFY, AFZ, i, sx, sy, sz, i + sx, i - sx, i + sy,
918 i - sy, i + sz, i - sz);
928 const C3 ext = l0.
ext, og = l0.
og;
932 "peclet::flow::smg_seed",
C3{g, g, g},
C3{ext.
x - g, ext.
y - g, ext.
z - g},
933 KOKKOS_LAMBDA(
int lx,
int ly,
int lz) {
934 const long i = (long)lx + (
long)ly * ext.
x + (long)lz * (
long)ext.
x * ext.
y;
935 std::uint64_t h = (std::uint64_t)(og.x + lx - g) * 0x9E3779B97F4A7C15ull ^
936 (std::uint64_t)(og.y + ly - g) * 0xC2B2AE3D27D4EB4Full ^
937 (std::uint64_t)(og.z + lz - g) * 0x165667B19E3779F9ull;
939 h *= 0xBF58476D1CE4E5B9ull;
941 e(i) = unk(i) > 0.5 ? (double)(h >> 11) * (1.0 / 9007199254740992.0) - 0.5 : 0.0;
945 std::vector<double> ratios;
946 double prev =
norm2(e);
947 for (
int k = 0; k < iters; ++k) {
953 "peclet::flow::smg_err_update",
C3{g, g, g},
C3{ext.
x - g, ext.
y - g, ext.
z - g},
954 KOKKOS_LAMBDA(
int lx,
int ly,
int lz) {
955 const long i = (long)lx + (
long)ly * ext.
x + (long)lz * (
long)ext.
x * ext.
y;
960 const double cur =
norm2(e);
961 ratios.push_back(prev > 0.0 ? cur / prev : 0.0);
965 const double s = 1.0 / cur;
967 "peclet::flow::smg_err_scale",
C3{g, g, g},
C3{ext.
x - g, ext.
y - g, ext.
z - g},
968 KOKKOS_LAMBDA(
int lx,
int ly,
int lz) {
969 const long i = (long)lx + (
long)ly * ext.
x + (long)lz * (
long)ext.
x * ext.
y;
980 if (L + 1 == nUse_) {
981 for (
int k = 0; k <
kBottom / 2; ++k)
983 for (
int k = 0; k <
kBottom / 2; ++k)
989 for (
int k = 0; k <
kPre; ++k)
997 lv.AB, lv.AT, lv.ext, lv.g, lv.inner, wr < 0 ? 0 : wr);
1000 lv.ext, lv.g, lv.inner, wr < 0 ? 0 : wr);
1001 Level& cs = lv_[L + 1];
1007 prolongAdd(lv.x,
CCConst(cs.x), lv.ext, cs.ext, lv.g, cs.g, lv.inner, lv.ratio);
1009 for (
int k = 0; k <
kPost; ++k)
1018 if (L + 1 == nUse_) {
1019 for (
int k = 0; k <
kBottom / 2; ++k)
1021 for (
int k = 0; k <
kBottom / 2; ++k)
1027 for (
int k = 0; k <
kPre; ++k)
1034 const int w = wr < 0 ? 0 : wr;
1037 lv.AW, lv.AE, lv.AS, lv.AN, lv.AB, lv.AT, lv.ress,
CCConst(lv.xs),
1038 CCConst(lv.rhss), lv.ACs, lv.AFXs, lv.AFYs, lv.AFZs, lv.W, lv.ext,
1042 lv.AW, lv.AE, lv.AS, lv.AN, lv.AB, lv.AT, lv.ress,
CCConst(lv.xs),
1043 CCConst(lv.rhss), lv.ACs, lv.AFXs, lv.AFYs, lv.AFZs, lv.W, lv.ext,
1045 Level& cs = lv_[L + 1];
1053 prolongAdd(lv.x,
CCConst(cs.x), lv.ext, cs.ext, lv.g, cs.g, lv.inner, lv.ratio);
1054 prolongAdd(lv.xs,
CCConst(cs.xs), lv.ext, cs.ext, lv.g, cs.g, lv.inner, lv.ratio);
1057 for (
int k = 0; k <
kPost; ++k)
1067 if (!distributed_) {
1072 Kokkos::deep_copy(
CCExec(), cx, 0.0);
1082 const int w = ws < 0 ? 0 : ws;
1085 const int kc = (rb + 3 * lv.g) & 1;
1091 lv.AN, lv.AB, lv.AT, lv.xs, lv.rhss, lv.ACs, lv.AFXs, lv.AFYs,
1092 lv.AFZs, lv.W,
unkOf(L), lv.ext, lv.og, lv.g, kc, lv.inner, w);
1095 lv.AN, lv.AB, lv.AT, lv.xs, lv.rhss, lv.ACs, lv.AFXs, lv.AFYs,
1096 lv.AFZs, lv.W,
unkOf(L), lv.ext, lv.og, lv.g, kc, lv.inner, w);
1101 unkOf(L), lv.ext, lv.og, lv.g, kc, lv.inner, w);
1122#ifdef PECLET_FLOW_MPI
1124 lv.dev->exchange(f);
1144 if constexpr (std::is_same_v<typename CCExec::memory_space, Kokkos::HostSpace>)
1149 return fill0Wraps_ ? 7 : -1;
1150 return (per_[0] ? 1 : 0) | (per_[1] ? 2 : 0) | (per_[2] ? 4 : 0);
1155 const Level& lv = lv_[L];
1156 if (lv.inner.x % 2 != 0 || lv.inner.y % 2 != 0 || lv.inner.z % 2 != 0)
1163 const int a = f / 2;
1164 const int o = (a == 0) ? lv.og.x : (a == 1) ? lv.og.y : lv.og.z;
1165 const int n = (a == 0) ? lv.inner.x : (a == 1) ? lv.inner.y : lv.inner.z;
1166 const int gn = (a == 0) ? lv.gdim.x : (a == 1) ? lv.gdim.y : lv.gdim.z;
1167 return (f % 2 == 0) ? (o == 0) : (o + n == gn);
1174 static bool can(
int d) {
return (d % 2 == 0) && (d / 2 >= 2); }
1176 const double H[3] = {hp_[0] * (double)cf.x, hp_[1] * (
double)cf.y, hp_[2] * (double)cf.z};
1183 v.res =
CCField(
"smg_res0", v.n);
1184 v.AFX =
CCField(
"smg_afx0", v.n);
1185 v.AFY =
CCField(
"smg_afy0", v.n);
1186 v.AFZ =
CCField(
"smg_afz0", v.n);
1190 v.rhs =
CCField(
"smg_rhs", v.n);
1191 v.res =
CCField(
"smg_res", v.n);
1192 v.AC =
CCField(
"smg_ac", v.n);
1193 v.AFX =
CCField(
"smg_afx", v.n);
1194 v.AFY =
CCField(
"smg_afy", v.n);
1195 v.AFZ =
CCField(
"smg_afz", v.n);
1196 v.unk =
CCField(
"smg_unk", v.n);
1197 v.mass =
CCField(
"smg_mass", v.n);
1198 v.px =
CCField(
"smg_px", v.n);
1199 v.py =
CCField(
"smg_py", v.n);
1200 v.pz =
CCField(
"smg_pz", v.n);
1209 if (v.ress.extent(0) == v.n)
1211 v.ress =
CCField(
"smg_ress", v.n);
1212 v.AFXs =
CCField(
"smg_afxs", v.n);
1213 v.AFYs =
CCField(
"smg_afys", v.n);
1214 v.AFZs =
CCField(
"smg_afzs", v.n);
1217 v.xs =
CCField(
"smg_xs", v.n);
1218 v.rhss =
CCField(
"smg_rhss", v.n);
1219 v.ACs =
CCField(
"smg_acs", v.n);
1220 v.unks =
CCField(
"smg_unks", v.n);
1221 v.masss =
CCField(
"smg_masss", v.n);
1222 v.pxs =
CCField(
"smg_pxs", v.n);
1223 v.pys =
CCField(
"smg_pys", v.n);
1224 v.pzs =
CCField(
"smg_pzs", v.n);
1229 const Level& lv = lv_[L];
1230 const C3 e = lv.ext;
1235 "peclet::flow::smg_count_s",
C3{g, g, g},
C3{e.x - g, e.y - g, e.z - g},
1236 KOKKOS_LAMBDA(
int lx,
int ly,
int lz,
double& acc) {
1237 const long i = (long)lx + (
long)ly * e.x + (long)lz * (
long)e.x * e.y;
1238 acc += unk(i) > 0.5 ? 1.0 : 0.0;
1240 Kokkos::Sum<double>(s));
1248 const Level& lv = lv_[L];
1249 const double nTot = lv.nUnk + lv.nUnkS;
1252 const C3 e = lv.ext;
1257 "peclet::flow::smg_mean_two",
C3{g, g, g},
C3{e.x - g, e.y - g, e.z - g},
1258 KOKKOS_LAMBDA(
int lx,
int ly,
int lz,
double& acc) {
1259 const long i = (long)lx + (
long)ly * e.x + (long)lz * (
long)e.x * e.y;
1260 acc += (uf(i) > 0.5 ? f(i) : 0.0) + (us(i) > 0.5 ? s(i) : 0.0);
1262 Kokkos::Sum<double>(sum));
1264 const double mean = sum / nTot;
1266 "peclet::flow::smg_mean_two_sub",
C3{g, g, g},
C3{e.x - g, e.y - g, e.z - g},
1267 KOKKOS_LAMBDA(
int lx,
int ly,
int lz) {
1268 const long i = (long)lx + (
long)ly * e.x + (long)lz * (
long)e.x * e.y;
1281 const C3 e = l0.
ext;
1282 const double wx = w_[0], wy = w_[1], wz = w_[2];
1286 "peclet::flow::smg_faces0_solid",
C3{0, 0, 0}, e, KOKKOS_LAMBDA(
int x,
int y,
int z) {
1287 const long i = (long)x + (
long)y * e.x + (long)z * (
long)e.x * e.y;
1288 AFX(i) = -(wx * px(i));
1289 AFY(i) = -(wy * py(i));
1290 AFZ(i) = -(wz * pz(i));
1299 Level& fin = lv_[L - 1];
1307 CCField px = c.pxs, py = c.pys, pz = c.pzs;
1308 const C3 ce = c.ext, fe = fin.
ext;
1309 const int gc = c.g, gf = fin.
g;
1314 "peclet::flow::smg_coarsen_faces_solid",
C3{0, 0, 0}, c.inner,
1315 KOKKOS_LAMBDA(
int icx,
int icy,
int icz) {
1316 coarsenOpenAvgCell(px, py, pz, fx, fy, fz, ce, fe, gc, gf, ratio, icx, icy, icz);
1321 const CCField P[3] = {c.pxs, c.pys, c.pzs};
1322 for (
int a = 0; a < 3; ++a)
1323 if (!per_[a] &&
touches(c, 2 * a))
1328 const C3 e = c.ext, ci = c.inner, cf = c.cfac;
1330 const double wx = w_[0] / ((double)cf.x * cf.x), wy = w_[1] / ((
double)cf.y * cf.y),
1331 wz = w_[2] / ((double)cf.z * cf.z);
1332 CCField AC = c.ACs, AFX = c.AFXs, AFY = c.AFYs, AFZ = c.AFZs, W = c.W;
1333 CCConst px = c.pxs, py = c.pys, pz = c.pzs, unk = c.unks, mass = c.masss;
1335 "peclet::flow::smg_coarse_faces_solid",
C3{0, 0, 0}, e, KOKKOS_LAMBDA(
int x,
int y,
int z) {
1336 const long i = (long)x + (
long)y * e.x + (long)z * (
long)e.x * e.y;
1337 AFX(i) = -(wx * px(i));
1338 AFY(i) = -(wy * py(i));
1339 AFZ(i) = -(wz * pz(i));
1342 "peclet::flow::smg_coarse_diag_solid",
C3{0, 0, 0}, ci,
1343 KOKKOS_LAMBDA(
int icx,
int icy,
int icz) {
1344 const long sx = 1, sy = e.x, sz = (long)e.x * e.y;
1345 const long i = (long)(icx + g) + (long)(icy + g) * sy + (long)(icz + g) * sz;
1346 if (!(unk(i) > 0.5)) {
1348 AFX(i) = AFY(i) = AFZ(i) = 0.0;
1352 const double tw = wx * px(i), te = wx * px(i + sx);
1353 const double ts = wy * py(i), tn = wy * py(i + sy);
1354 const double tb = wz * pz(i), tt = wz * pz(i + sz);
1355 AC(i) = (mass(i) + (((tw + te) + (ts + tn)) + (tb + tt))) + W(i);
1360 const int ext[3] = {lv.ext.x, lv.ext.y, lv.ext.z};
1361 for (
int a = 0; a < 3; ++a) {
1373#ifdef PECLET_FLOW_MPI
1375 std::vector<double> o((std::size_t)k);
1376 MPI_Allreduce(v, o.data(), k, MPI_DOUBLE, MPI_SUM, comm_);
1377 for (
int j = 0; j < k; ++j)
1378 v[j] = o[(std::size_t)j];
1385 const Level& lv = lv_[L];
1386 const C3 e = lv.ext;
1391 "peclet::flow::smg_count",
C3{g, g, g},
C3{e.x - g, e.y - g, e.z - g},
1392 KOKKOS_LAMBDA(
int lx,
int ly,
int lz,
double& acc) {
1393 const long i = (long)lx + (
long)ly * e.x + (long)lz * (
long)e.x * e.y;
1394 acc += unk(i) > 0.5 ? 1.0 : 0.0;
1396 Kokkos::Sum<double>(s));
1402 const Level& lv = lv_[L];
1403 if (!(lv.nUnk > 0.0))
1405 const C3 e = lv.ext;
1410 "peclet::flow::smg_mean",
C3{g, g, g},
C3{e.x - g, e.y - g, e.z - g},
1411 KOKKOS_LAMBDA(
int lx,
int ly,
int lz,
double& acc) {
1412 const long i = (long)lx + (
long)ly * e.x + (long)lz * (
long)e.x * e.y;
1416 Kokkos::Sum<double>(s));
1418 const double mean = s / lv.nUnk;
1420 "peclet::flow::smg_mean_sub",
C3{g, g, g},
C3{e.x - g, e.y - g, e.z - g},
1421 KOKKOS_LAMBDA(
int lx,
int ly,
int lz) {
1422 const long i = (long)lx + (
long)ly * e.x + (long)lz * (
long)e.x * e.y;
1428 const Level& lv = lv_[0];
1429 const C3 e = lv.ext;
1433 "peclet::flow::smg_norm",
C3{g, g, g},
C3{e.x - g, e.y - g, e.z - g},
1434 KOKKOS_LAMBDA(
int lx,
int ly,
int lz,
double& acc) {
1435 const long i = (long)lx + (
long)ly * e.x + (long)lz * (
long)e.x * e.y;
1438 Kokkos::Sum<double>(s));
1440 return std::sqrt(s);
1449 const C3 e = l0.
ext;
1450 const double lx = in.
lam * w_[0], ly = in.
lam * w_[1], lz = in.
lam * w_[2];
1454 "peclet::flow::smg_faces0",
C3{0, 0, 0}, e, KOKKOS_LAMBDA(
int x,
int y,
int z) {
1455 const long sx = 1, sy = e.x, sz = (long)e.x * e.y;
1456 const long i = (long)x + (
long)y * sy + (long)z * sz;
1457 const bool u = unk(i) > 0.5;
1458 const double tw = (x > 0 && u && unk(i - sx) > 0.5) ? lx * sax(i) : 0.0;
1459 const double ts = (y > 0 && u && unk(i - sy) > 0.5) ? ly * say(i) : 0.0;
1460 const double tb = (z > 0 && u && unk(i - sz) > 0.5) ? lz * saz(i) : 0.0;
1476 const auto& fo = *in.
fac;
1477 if (cutKey_ == fo.cutCell.data() && cutKeyN_ == fo.nCut && (
int)cutStart_.size() == nUse_)
1479 const Level& l0 = lv_[0];
1481 const int g0 = l0.
g;
1482 auto hc = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(), fo.cutCell);
1484 std::vector<std::pair<long, int>> rows;
1485 rows.reserve((std::size_t)fo.nCut);
1486 for (
long r = 0; r < fo.nCut; ++r) {
1487 const long i0 = hc(r);
1488 const int x = (int)(i0 % e0.x) - g0, y = (int)((i0 / e0.x) % e0.y) - g0,
1489 z = (int)(i0 / ((
long)e0.x * e0.y)) - g0;
1490 if (x >= 0 && x < n0.x && y >= 0 && y < n0.y && z >= 0 && z < n0.z)
1491 rows.emplace_back(i0, (
int)r);
1493 std::sort(rows.begin(), rows.end());
1494 cutStart_.assign((std::size_t)nUse_, Kokkos::View<int*, CCMem>());
1495 cutRows_.assign((std::size_t)nUse_, Kokkos::View<int*, CCMem>());
1496 for (
int L = 1; L < nUse_; ++L) {
1497 const Level& c = lv_[L];
1498 const C3 ci = c.inner, cf = c.cfac;
1499 const long nc = (long)ci.
x * ci.
y * ci.
z;
1500 std::vector<int> start((std::size_t)nc + 1, 0), list(rows.size());
1501 auto coarseOf = [&](
long i0) {
1502 const int x = (int)(i0 % e0.x) - g0, y = (int)((i0 / e0.x) % e0.y) - g0,
1503 z = (int)(i0 / ((
long)e0.x * e0.y)) - g0;
1504 return (
long)(x / cf.x) + (
long)(y / cf.y) * ci.
x + (
long)(z / cf.z) * ci.
x * ci.
y;
1506 for (
const auto& q : rows)
1507 ++start[(std::size_t)coarseOf(q.first) + 1];
1508 for (
long k = 0; k < nc; ++k)
1509 start[(std::size_t)k + 1] += start[(std::size_t)k];
1510 std::vector<int> pos(start.begin(), start.end() - 1);
1511 for (
const auto& q : rows)
1512 list[(std::size_t)pos[(std::size_t)coarseOf(q.first)]++] = q.second;
1513 Kokkos::View<int*, CCMem> ds(
"smg_cut_start", (std::size_t)nc + 1),
1514 dl(
"smg_cut_rows", std::max<std::size_t>(list.size(), 1));
1516 ds, Kokkos::View<
const int*, Kokkos::HostSpace, Kokkos::MemoryTraits<Kokkos::Unmanaged>>(
1517 start.data(), start.size()));
1520 Kokkos::subview(dl, std::make_pair((std::size_t)0, list.size())),
1521 Kokkos::View<
const int*, Kokkos::HostSpace, Kokkos::MemoryTraits<Kokkos::Unmanaged>>(
1522 list.data(), list.size()));
1523 cutStart_[(std::size_t)L] = ds;
1524 cutRows_[(std::size_t)L] = dl;
1526 cutKey_ = fo.cutCell.data();
1540 const auto& fo = *in.
fac;
1542 bool keep = wallValid_ && wallTwo_ == two && wallUse_ == nUse_ &&
1543 wallUnk_ == in.
unknown.data() && cwSnap_.extent(0) == (std::size_t)fo.n &&
1544 (!two || ccSnap_.extent(0) == (std::size_t)fo.n);
1545 if (keep && fo.n > 0) {
1546 auto a = in.
facetW, as = Kokkos::View<const double*, CCMem>(cwSnap_);
1548 cs = two ? Kokkos::View<const double*, CCMem>(ccSnap_) : as;
1550 Kokkos::parallel_reduce(
1551 "peclet::flow::smg_wall_same", Kokkos::RangePolicy<CCExec>(
CCExec(), 0, fo.n),
1552 KOKKOS_LAMBDA(
const long f,
long& d) {
1553 auto same = [](
double u,
double w) {
1554 return u == w && Kokkos::signbit(u) == Kokkos::signbit(w);
1556 if (!
same(a(f), as(f)) || (two && !
same(c(f), cs(f))))
1563 if (cwSnap_.extent(0) != (std::size_t)fo.n)
1564 cwSnap_ = Kokkos::View<double*, CCMem>(
"smg_cw_snap", (std::size_t)fo.n);
1567 if (ccSnap_.extent(0) != (std::size_t)fo.n)
1568 ccSnap_ = Kokkos::View<double*, CCMem>(
"smg_cc_snap", (std::size_t)fo.n);
1583 const int a = f / 2, side = f % 2;
1587 const long st[3] = {1, (long)l0.
ext.
x, (
long)l0.
ext.
x * l0.
ext.
y};
1589 const int n1 = ext[t1] - 2 * g, n2 = ext[t2] - 2 * g;
1590 const long sa = st[a], s1 = st[t1], s2 = st[t2];
1591 const int aInner = side == 0 ? g : ext[a] - g - 1;
1592 if (l0.
plane[f].extent(0) != (std::size_t)n1 * n2)
1593 l0.
plane[f] = Kokkos::View<double*, CCMem>(
"smg_plane0", (
long)n1 * n2);
1594 auto pl = l0.
plane[f];
1597 const double lam = in.
lam;
1599 Kokkos::parallel_for(
1601 KOKKOS_LAMBDA(
int j1,
int j2) {
1602 const long i = (long)aInner * sa + (
long)(j1 + g) * s1 + (
long)(j2 + g) * s2;
1603 const double abf = side == 0 ? saA(i) : saA(i + sa);
1604 pl((
long)j1 + (
long)j2 * n1) = unk(i) > 0.5 ? lam * abf : 0.0;
1609 t1 = (a == 0) ? 1 : 0;
1610 t2 = (a == 2) ? 1 : 2;
1615 Level& fin = lv_[L - 1];
1625 CCField px = c.px, py = c.py, pz = c.pz;
1626 const C3 ce = c.ext, fe = fin.
ext;
1627 const int gc = c.g, gf = fin.
g;
1629 const long sy0 = fe.x, sz0 = (long)fe.x * fe.y;
1634 "peclet::flow::smg_coarsen_faces",
C3{0, 0, 0}, c.inner,
1635 KOKKOS_LAMBDA(
int icx,
int icy,
int icz) {
1636 coarsenOpenAvgCell(px, py, pz, fx, fy, fz, ce, fe, gc, gf, ratio, icx, icy, icz);
1641 "peclet::flow::smg_coarsen_faces",
C3{0, 0, 0}, c.inner,
1642 KOKKOS_LAMBDA(
int icx,
int icy,
int icz) {
1643 coarsenOpenAvgCell(px, py, pz, fx, fy, fz, ce, fe, gc, gf, ratio, icx, icy, icz);
1650 const CCField P[3] = {c.px, c.py, c.pz};
1651 for (
int a = 0; a < 3; ++a)
1652 if (!per_[a] &&
touches(c, 2 * a))
1663 const C3 ce = c.ext, fe = fin.
ext, ci = c.inner;
1664 const int gc = c.g, gf = fin.
g;
1666 "peclet::flow::smg_restrict_mass",
C3{0, 0, 0}, ci,
1667 KOKKOS_LAMBDA(
int icx,
int icy,
int icz) {
1674 for (
int f = 0; f < 6; ++f)
1675 if (dirFace_[f] &&
touches(c, f))
1680 Kokkos::deep_copy(
CCExec(), c.W, 0.0);
1699 Level& fin = lv_[L - 1];
1700 if (c.qp[0].extent(0) != c.n)
1701 for (
int a = 0; a < 3; ++a) {
1702 c.qp[a] =
CCField(
"smg_qp", c.n);
1703 c.qm[a] =
CCField(
"smg_qm", c.n);
1705 const C3 ratio = fin.
ratio, ce = c.ext, fe = fin.
ext;
1706 const int gc = c.g, gf = fin.
g;
1707 const double ir[3] = {1.0 / (double)ratio.x, 1.0 / (
double)ratio.y, 1.0 / (double)ratio.z};
1708 for (
int sgn = 0; sgn < 2; ++sgn) {
1709 CCField qx = sgn == 0 ? c.qp[0] : c.qm[0], qy = sgn == 0 ? c.qp[1] : c.qm[1],
1710 qz = sgn == 0 ? c.qp[2] : c.qm[2];
1711 const double irx = ir[0], iry = ir[1], irz = ir[2];
1713 const long sy0 = fe.x, sz0 = (long)fe.x * fe.y;
1714 const double sg = sgn == 0 ? 1.0 : -1.0;
1719 "peclet::flow::smg_coarsen_adv",
C3{0, 0, 0}, c.inner,
1720 KOKKOS_LAMBDA(
int icx,
int icy,
int icz) {
1721 coarsenOpenAvgCell(qx, qy, qz, fx, fy, fz, ce, fe, gc, gf, ratio, icx, icy, icz);
1723 (long)(icx + gc) + (long)(icy + gc) * ce.x + (long)(icz + gc) * (long)ce.x * ce.y;
1729 const CCConst fx = sgn == 0 ? fin.
qp[0] : fin.
qm[0], fy = sgn == 0 ? fin.
qp[1] : fin.
qm[1],
1730 fz = sgn == 0 ? fin.
qp[2] : fin.
qm[2];
1732 "peclet::flow::smg_coarsen_adv",
C3{0, 0, 0}, c.inner,
1733 KOKKOS_LAMBDA(
int icx,
int icy,
int icz) {
1734 coarsenOpenAvgCell(qx, qy, qz, fx, fy, fz, ce, fe, gc, gf, ratio, icx, icy, icz);
1736 (long)(icx + gc) + (long)(icy + gc) * ce.x + (long)(icz + gc) * (long)ce.x * ce.y;
1743 for (
int a = 0; a < 3; ++a) {
1747 for (
int a = 0; a < 3; ++a)
1748 if (!per_[a] &&
touches(c, 2 * a)) {
1760 if (c.AW.extent(0) != c.n) {
1761 c.AW =
CCField(
"smg_aw", c.n);
1762 c.AE =
CCField(
"smg_ae", c.n);
1763 c.AS =
CCField(
"smg_as", c.n);
1764 c.AN =
CCField(
"smg_an", c.n);
1765 c.AB =
CCField(
"smg_ab", c.n);
1766 c.AT =
CCField(
"smg_at", c.n);
1770 CCField AC = c.AC, AW = c.AW, AE = c.AE, AS = c.AS, AN = c.AN, AB = c.AB, AT = c.AT;
1771 CCConst AFX = c.AFX, AFY = c.AFY, AFZ = c.AFZ, unk = c.unk;
1772 CCConst qpx = c.qp[0], qpy = c.qp[1], qpz = c.qp[2], qmx = c.qm[0], qmy = c.qm[1],
1774 Kokkos::deep_copy(
CCExec(), AW, 0.0);
1775 Kokkos::deep_copy(
CCExec(), AE, 0.0);
1776 Kokkos::deep_copy(
CCExec(), AS, 0.0);
1777 Kokkos::deep_copy(
CCExec(), AN, 0.0);
1778 Kokkos::deep_copy(
CCExec(), AB, 0.0);
1779 Kokkos::deep_copy(
CCExec(), AT, 0.0);
1781 "peclet::flow::smg_coarse_bands",
C3{g, g, g},
C3{e.x - g, e.y - g, e.z - g},
1782 KOKKOS_LAMBDA(
int lx,
int ly,
int lz) {
1783 const long sx = 1, sy = e.x, sz = (long)e.x * e.y;
1784 const long i = (long)lx + (
long)ly * sy + (long)lz * sz;
1785 if (!(unk(i) > 0.5))
1788 AC(i) + ((qmx(i) + qpx(i + sx)) + (qmy(i) + qpy(i + sy))) + (qmz(i) + qpz(i + sz));
1789 AW(i) = AFX(i) - qpx(i);
1790 AE(i) = AFX(i + sx) - qmx(i + sx);
1791 AS(i) = AFY(i) - qpy(i);
1792 AN(i) = AFY(i + sy) - qmy(i + sy);
1793 AB(i) = AFZ(i) - qpz(i);
1794 AT(i) = AFZ(i + sz) - qmz(i + sz);
1800 Level& fin = lv_[L - 1];
1801 const int a = f / 2;
1804 const int cin[3] = {c.inner.x, c.inner.y, c.inner.z};
1807 const int n1 = cin[t1], n2 = cin[t2], f1 = fin3[t1];
1808 const int r1 = rr[t1], r2 = rr[t2];
1809 if (c.plane[f].extent(0) != (std::size_t)n1 * n2)
1810 c.plane[f] = Kokkos::View<double*, CCMem>(
"smg_plane", (
long)n1 * n2);
1811 auto pc = c.plane[f];
1814 Kokkos::parallel_for(
1815 "peclet::flow::smg_coarsen_plane",
MDRange2<CCExec>(space, {0, 0}, {n1, n2}),
1816 KOKKOS_LAMBDA(
int j1,
int j2) {
1818 for (
int p = 0; p < r1; ++p)
1819 for (
int q = 0; q < r2; ++q)
1820 s +=
pf((
long)(r1 * j1 + p) + (
long)(r2 * j2 + q) * f1);
1821 pc((
long)j1 + (
long)j2 * n1) = s / (double)(r1 * r2);
1830 const C3 e = c.ext, ci = c.inner, cf = c.cfac;
1832 const double wx = w_[0] / ((double)cf.x * cf.x), wy = w_[1] / ((
double)cf.y * cf.y),
1833 wz = w_[2] / ((double)cf.z * cf.z);
1834 CCField AC = c.AC, AFX = c.AFX, AFY = c.AFY, AFZ = c.AFZ;
1835 CCConst px = c.px, py = c.py, pz = c.pz;
1837 "peclet::flow::smg_coarse_faces",
C3{0, 0, 0}, e, KOKKOS_LAMBDA(
int x,
int y,
int z) {
1838 const long i = (long)x + (
long)y * e.x + (long)z * (
long)e.x * e.y;
1839 AFX(i) = -(wx * px(i));
1840 AFY(i) = -(wy * py(i));
1841 AFZ(i) = -(wz * pz(i));
1844 const double invN = 1.0 / ((double)cf.x * cf.y * cf.z);
1845 auto cstart = cutStart_[(std::size_t)L];
1846 auto crows = cutRows_[(std::size_t)L];
1849 CCConst unk = c.unk, mass = c.mass;
1855 const bool two = two_;
1858 if (c.wallG.extent(0) != c.n)
1859 c.wallG =
CCField(
"smg_wall_gathered", c.n);
1860 if (two && c.wallCG.extent(0) != c.n)
1861 c.wallCG =
CCField(
"smg_wallc_gathered", c.n);
1862 CCField wg = c.wallG, wcg = c.wallCG;
1863 const bool reuse = wallReuse_;
1865 "peclet::flow::smg_coarse_diag",
C3{0, 0, 0}, ci, KOKKOS_LAMBDA(
int icx,
int icy,
int icz) {
1866 const long sx = 1, sy = e.x, sz = (long)e.x * e.y;
1867 const long i = (long)(icx + g) + (long)(icy + g) * sy + (long)(icz + g) * sz;
1868 if (!(unk(i) > 0.5)) {
1870 AFX(i) = AFY(i) = AFZ(i) = 0.0;
1873 double W = 0.0, Wc = 0.0;
1880 const long ic = (long)icx + (
long)icy * ci.x + (long)icz * ci.x * ci.y;
1881 for (
int k = cstart(ic); k < cstart(ic + 1); ++k) {
1882 const int row = crows(k);
1883 if (!(unk0(cutCell(row)) > 0.5))
1885 for (
int f = cfs(row); f < cfs(row + 1); ++f) {
1898 const double tw = wx * px(i), te = wx * px(i + sx);
1899 const double ts = wy * py(i), tn = wy * py(i + sy);
1900 const double tb = wz * pz(i), tt = wz * pz(i + sz);
1902 AC(i) = ((mass(i) + (((tw + te) + (ts + tn)) + (tb + tt))) + W) + Wc;
1905 AC(i) = (mass(i) + (((tw + te) + (ts + tn)) + (tb + tt))) + W;
1909 const double wa[3] = {wx, wy, wz};
1910 for (
int f = 0; f < 6; ++f) {
1911 if (!(dirFace_[f] &&
touches(c, f)))
1913 const int a = f / 2, side = f % 2;
1916 const int ext[3] = {e.x, e.y, e.z};
1917 const long st[3] = {1, (long)e.x, (
long)e.x * e.y};
1918 const int n1 = ext[t1] - 2 * g, n2 = ext[t2] - 2 * g;
1919 const long sa = st[a], s1 = st[t1], s2 = st[t2];
1920 const int aInner = side == 0 ? g : ext[a] - g - 1;
1921 const double tw2 = 2.0 * wa[a];
1922 auto pl = c.plane[f];
1924 Kokkos::parallel_for(
1925 "peclet::flow::smg_coarse_dirichlet",
MDRange2<CCExec>(space, {0, 0}, {n1, n2}),
1926 KOKKOS_LAMBDA(
int j1,
int j2) {
1927 const long i = (long)aInner * sa + (
long)(j1 + g) * s1 + (
long)(j2 + g) * s2;
1928 if (!(unk(i) > 0.5))
1930 AC(i) += tw2 * pl((
long)j1 + (
long)j2 * n1);
1936 std::vector<Level> lv_;
1938 bool fill0Wraps_ =
false;
1944 std::vector<Kokkos::View<int*, CCMem>> cutStart_, cutRows_;
1945 const void* cutKey_ =
nullptr;
1949 Kokkos::View<double*, CCMem> cwSnap_, ccSnap_;
1950 bool wallValid_ =
false, wallTwo_ =
false, wallReuse_ =
false;
1952 const void* wallUnk_ =
nullptr;
1953 double w_[3] = {1.0, 1.0, 1.0};
1954 double hp_[3] = {1.0, 1.0, 1.0};
1955 bool aniso_ =
false;
1956 bool per_[3] = {
true,
true,
true};
1957 bool dirFace_[6] = {
false,
false,
false,
false,
false,
false};
1958 bool singular_ =
false;
1961 bool distributed_ =
false;
1962#ifdef PECLET_FLOW_MPI
1963 MPI_Comm comm_ = MPI_COMM_NULL;
static C3 mgChooseRatio(const double H[3], const bool canA[3], bool aniso, double theta)
static constexpr int kPre
std::function< void(CCField)> Fill
void assembleCoarse(const Inputs &in, int L)
Coarse face form + diagonal: AF_a = -w_a(L) <Lam a> over the full extent; on unknown inner cells AC =...
static constexpr int GC
coarse levels
void buildLevel0SolidFaces(const Inputs &in)
WO-7, level 0: the solid faces AF_a(i) = -(w_a P_a(i)) from the operator's guarded products — the exp...
void sweep(int L, bool fwd)
One full red-black sweep: R -> B forward, B -> R backward.
void sweepColor(int L, int rb)
One colour of red-black Gauss-Seidel on level L: rb = 0 red (global (gx+gy+gz) even),...
void vcycleTwo(int L)
The two-field V-cycle (WO-7): vcycle's structure on both phases — the same sweeps (the 2x2 block upda...
static void tangents(int a, int &t1, int &t2)
void setMetric(const double w[3], const double hp[3])
Per-axis metric (VelocityMG::setMetric): w_a = 1/h_a'^2 and h_a'. Call before init.
void applySurrogateTwo(CCField yf, CCField ys, CCField xf, CCField xs)
y = S x for the two-field surrogate on level 0 (exchanges x first): y_f = S_ff x_f - W x_s,...
bool wallKeep(const Inputs &in)
The gathered coarse wall terms W (and the conjugate W_c) of the last build are reused when their inpu...
bool touches(const Level &lv, int f) const
Does this rank's block on level lv touch global face f (0..5 = -x,+x,-y,+y,-z,+z)?
void setPeriodic(const bool per[3])
Periodicity per axis (the flow's domain faces); a non-periodic axis' ghosts are pinned.
void assembleBands(int L)
A2: the coarse bands from the face form (assembleCoarse) and Q.
int wrapSmooth(int L) const
A red-black pass reads the wrapped neighbour safely only when it has the OTHER colour (so it still ho...
static constexpr int G0
level 0: the scalar's own block
void init(int nx, int ny, int nz, Fill fill0)
Single-rank level table (VelocityMG::init's rule, no depth cap).
void applySurrogate(CCField y, CCField x)
y = S x on level 0 (exchanges x first). For the contraction instrument and tests.
static constexpr int kMaxLevels
no depth cap in practice (the full table)
int levelsUsed() const
Levels the last build set up for the V-cycle (1: level 0 alone, the transient rule).
static constexpr int kBottom
const Level & level(int L) const
void fill(int L, CCField f)
Ghost exchange of a level-L field: level 0 the solver's own; coarse levels the per-level halo (or the...
void zeroNonPeriodicGhosts(Level &lv, CCField f)
C3 chooseRatio(const bool canA[3], C3 cf) const
std::vector< C3 > levelRatios() const
The per-level coarsening ratios (the level table; equal to VelocityMG's on the same grid).
double countUnknownS(int L) const
void coarsenAdvection(const Inputs &in, int L)
A2: Qp/Qm of level L from level L - 1 — level 1 from the guarded positive parts of the level-0 flux,...
CCConst unkSOf(int L) const
static constexpr int kPost
static constexpr double kFullTableKappa
The transient level rule (design §5.2, Amendment A3 + ruling D-WO9-3): kappa_A = 1 + 4 dt' D' sum_a w...
void build(const Inputs &in)
Rebuild the surrogate on every level from the current operator (the level table is kept).
static constexpr double kAspectTheta
void applyTwo(CCField zf, CCField zs, CCField rf, CCField rs)
The two-field z = M^-1 r (WO-7): one V-cycle on the coupled surrogate from z = 0 (level 0 alone: 2 + ...
void apply(CCField z, CCField r)
z = M^-1 r: one V-cycle on the surrogate (level 0 alone: 2 + 2 sweeps) from z = 0.
void restrictZeroX(Level &cs, Level &lv, CCField crhs, CCField fres, CCField cx)
The coarse rhs = restrictAvg of the fine residual, and the coarse iterate x = 0.
void allocate(Level &v, int L)
void removeMeanTwo(int L, CCField f, CCField s)
f, s -= their joint mean over both phases' unknown cells of level L (the singular two-field problem: ...
void buildPlane0(const Inputs &in, int f)
Level-0 Dirichlet boundary plane of face f: <Lam a_bf> = Lam a_bf on unknown boundary cells (sco::dir...
void coarsenPlane(int L, int f)
std::vector< double > contraction(int iters, CCField e, CCField t, CCField z)
Power estimate of the V-cycle's error contraction rho(I - M^-1 S) on the current surrogate (§11 G-ite...
bool buildCutLists(const Inputs &in)
Per coarse level L the overlay rows (cut cells) under each coarse inner cell, in increasing level-0 l...
double countUnknown(int L) const
void setLevel0Wrap(bool on)
Declare that the injected level-0 fill is the single-rank periodic wrap of ALL three axes (Solver::fi...
void allocateSolid(Level &v, int L)
WO-7: the solid-phase arrays of level L (and W on coarse levels), on the first two-field build.
int wrapReads(int L) const
WO-9b, the fused periodic-wrap reads (flow's A3): the axes (bit a) a level-L pass may read across the...
void buildLevel0Faces(const Inputs &in)
Level-0 faces: AF_a(i) = -(Lam w_a a_a(i)) when cells i - st_a and i are both unknowns — the same exp...
void allSum(double *v, int k) const
void buildCoarse(const Inputs &in, int L)
void removeMean(int L, CCField f)
f -= its mean over the unknown cells of level L (CutcellMG::removeMean's form, unweighted).
void buildCoarseSolid(const Inputs &in, int L)
WO-7: the coarse solid phase of level L (after assembleCoarse, which gathered W): pins = max of the c...
CCConst unkOf(int L) const
double norm2(CCField f) const
#define PECLET_FLOW_OMP_SIMD
flow — portable (Kokkos) geometric multigrid for the cut-cell (variable-openness) pressure Poisson.
flow — portable (Kokkos) cut-cell pressure operator + Chorin projection.
Nb nbrsOn(int lx, int ly, int lz, C3 n, int g, long i, long sy, long sz, int wrap)
nbrs in the kernels: on a host backend always the plain i +- s (ScalarMG::wrapReads never asks a host...
void sweepColorFace(CCField x, CCConst rhs, OpV AC, OpV AFX, OpV AFY, OpV AFZ, C3 e, C3 og, int g, int color, C3 n, int wrap)
One colour of the face-form red-black Gauss-Seidel: cutcellSmoothColorFace (mac_pressure....
void residualFace(CCField r, CCConst x, CCConst b, CCField AC, CCField AFX, CCField AFY, CCField AFZ, C3 e, int g, C3 n, int wrap)
r = b - A x (face form, double), inner cells.
void fillShell(CCField f, C3 e, C3 inner, int g, const bool per[3])
The single-rank ghost fill of a level in ONE launch (WO-9b; CutcellMG::fillWrap's form): a ghost cell...
void sweepColorTwo(CCField x, CCField rhs, CCField AC, CCField AFX, CCField AFY, CCField AFZ, CCField AW, CCField AE, CCField AS, CCField AN, CCField AB, CCField AT, CCField xs, CCField rhss, CCField ACs, CCField AFXs, CCField AFYs, CCField AFZs, CCField W, CCConst unkF, C3 e, C3 og, int g, int color, C3 n, int wrap)
One colour of the two-field red-black sweep (same launch forms as cutcellSmoothColorFace).
void zeroPlanes(CCField f, C3 e, int a, int lo, int hi)
f = 0 on the planes [lo, hi) of axis a (full transverse extent).
Nb nbrs(int lx, int ly, int lz, C3 n, int g, long i, long sy, long sz, int wrap)
void residualTwo(CCField r, CCConst x, CCConst b, CCField AC, CCField AFX, CCField AFY, CCField AFZ, CCField AW, CCField AE, CCField AS, CCField AN, CCField AB, CCField AT, CCField rs, CCConst xs, CCConst bs, CCField ACs, CCField AFXs, CCField AFYs, CCField AFZs, CCField W, C3 e, int g, C3 n, int wrap)
The two-field residual: r_f = rhs_f - (S_ff x_f + N_f) + W x_s (N_f from the bands or the faces),...
double bandOff(const XV &x, const BV &AW, const BV &AE, const BV &AS, const BV &AN, const BV &AB, const BV &AT, long i, const Nb &w)
The band-form off-diagonal sum of A2, in its fixed order: ((AW x_W + AE x_E) + (AS x_S + AN x_N)) + (...
double faceOff(const XV &x, const OV &AFX, const OV &AFY, const OV &AFZ, long i, long sx, long sy, long sz, const Nb &w)
The face-form neighbour sum of cutcellSmoothFaceCell, in its order; x's neighbours from nbrs (the coe...
void zeroPinned(CCField x, CCConst unk, C3 e, int g)
x(i) = 0 on the inner cells that are not unknowns (re-zero the pinned cells).
void residualBand(CCField r, CCConst x, CCConst b, CCField AC, CCField AW, CCField AE, CCField AS, CCField AN, CCField AB, CCField AT, C3 e, int g, C3 n, int wrap)
r = b - (AC x + bandOff) over the inner cells (A2's band-form residual).
void twoPhaseCell(const XV &x, const XV &rhs, const BV &AC, const BV &AFX, const BV &AFY, const BV &AFZ, const BV &AW, const BV &AE, const BV &AS, const BV &AN, const BV &AB, const BV &AT, const XV &xs, const XV &rhss, const BV &ACs, const BV &AFXs, const BV &AFYs, const BV &AFZs, const BV &W, const CCConst &unkF, long i, long sx, long sy, long sz, const Nb &w)
The two-field cell update of the conjugate V-cycle (§5.2, WO-7; design A2's WO-7 note): where both ph...
void sweepColorBand(CCField x, CCConst rhs, BV AC, BV AW, BV AE, BV AS, BV AN, BV AB, BV AT, UV unk, C3 e, C3 og, int g, int color, C3 n, int wrap)
One colour of the band-form Gauss-Seidel (A2), on the unknown inner cells of the colour: x_i <- (rhs_...
void restrictMax(CCField coarse, const FV &fine, C3 cext, C3 fext, int gc, int gf, C3 cinner, C3 ratio)
coarse flag = max of the children's flags (1 unknown, 0 pinned), over the coarse inner cells.
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 restrictAvgZeroX(CCField coarse, CCField coarseX, CCConst fine, C3 cext, C3 fext, int gc, int gf, C3 cinner, C3 ratio)
void cutcellResidualFaceCell(const RV &r, const XV &x, const BV &b, const OpV &AC, const OpV &AFX, const OpV &AFY, const OpV &AFZ, long i, long sx, long sy, long sz, long xp, long xm, long yp, long ym, long zp, long zm)
void prolongAdd(CCField fine, CCConst coarse, C3 fext, C3 cext, int gf, int gc, C3 finner, C3 ratio)
void cutcellSmoothFaceCell(const PV &phi, const BV &b, const OpV &AC, const OpV &AFX, const OpV &AFY, const OpV &AFZ, long i, long sx, long sy, long sz, long xp, long xm, long yp, long ym, long zp, long zm)
Kokkos::View< const double *, CCMem > CCConst
void ccReduce3(const char *name, C3 lo, C3 hi, F f, R &&... reducers)
void applyCutcellOp(CCField y, CCConst x, OpV AC, OpV AW, OpV AE, OpV AS, OpV AN, OpV AB, OpV AT, C3 e, int g)
Kokkos::View< double *, CCMem > CCField
void ccFor3(const char *name, C3 lo, C3 hi, F f)
void restrictAvg(CCField coarse, CCConst fine, C3 cext, C3 fext, int gc, int gf, C3 cinner, C3 ratio)
void coarsenOpenAvgCell(const CV &oxc, const CV &oyc, const CV &ozc, const FV &oxf, const FV &oyf, const FV &ozf, C3 cext, C3 fext, int gc, int gf, C3 ratio, int icx, int icy, int icz)
bool hostRunSerial(long cells)
double cutcellApplyFaceCell(const XV &x, const OpV &AC, const OpV &AFX, const OpV &AFY, const OpV &AFZ, long i, long sx, long sy, long sz, long xp, long xm, long yp, long ym, long zp, long zm)
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).
void restrictAvgCell(const CV &coarse, const FV &fine, C3 cext, C3 fext, int gc, int gf, C3 ratio, int icx, int icy, int icz)
flow — the multidimensional iteration policies: iteration order follows storage.
C3 gdim
GLOBAL dims of this level.
double nUnkS
global count of solid unknowns
CCField pz
coarse levels: m and the face products <Lam a>
CCField xs
Conjugate (WO-7): the solid phase in face form (level 0: x/rhs the caller's, AC = SAC_s,...
CCField AFZ
the surrogate, face form (level 0: AC = the caller's SAC)
CCField wallG
WO-9b: the gathered wall term W (and the conjugate W_c) of this coarse level, per cell,...
CCField unk
1 unknown / 0 pinned (level 0: the geometry's flag)
CCField AW
Advective path (A2): the 7 bands (level 0: the operator's AW..AT, AC = SAC; coarse: owned,...
CCField res
level 0: x / rhs are the caller's (z, r); res owned
C3 og
block inner origin (global red-black parity); {0,0,0} single-rank
Kokkos::View< double *, CCMem > plane[6]
Dirichlet domain faces: <Lam a_bf> (owning rank).
double nUnk
global count of unknown cells (the singular mean)
The facet overlay (§3.5): SoA, facet index fastest. Offsets are LINEAR offsets on the block.
Kokkos::View< int *, CCMem > cellFacetStart
CSR, nCut + 1 entries.
Kokkos::View< long *, CCMem > cutCell
their extended linear index
Level-0 guarded positive part of the signed low-face flux: P(i) = max(sgn phi_a(i),...
double operator()(long i) const
Level-0 guarded face product Lam a (no metric weight): the face between cell i - st and cell i carrie...
double operator()(long i) const
Level-0 mass m = kappa idt on unknowns, 0 elsewhere (read by restrictAvgCell).
double operator()(long i) const
Neighbour indices of an inner cell for the fused periodic-wrap reads (WO-9b; flow's A3,...
static int wrap(int a, int n)
static constexpr double AC
Kokkos::View< double *, peclet::flow::CCMem > OpV
Kokkos::View< float *, IMem > FV
static bool same(double a, double b)
static double mean(const std::vector< double > &a)