42#include <Kokkos_Core.hpp>
50#if defined(__CUDACC__) || defined(__HIPCC__)
51#define PECLET_BOTTOM_UNROLL _Pragma("unroll 16")
53#define PECLET_BOTTOM_UNROLL
57#if defined(__CUDACC__) || defined(__HIPCC__)
58#define PECLET_BOTTOM_HOST_SIMD
60#define PECLET_BOTTOM_HOST_SIMD PECLET_FLOW_OMP_SIMD
68 return attempt == 0 ? 0.0 : (attempt == 1 ? 1e-4 : 1e-2);
79 int bcf[6] = {0, 0, 0, 0, 0, 0};
81 KOKKOS_INLINE_FUNCTION
bool valid()
const {
return s >= 0; }
93 for (
int f = 0; f < 6; ++f)
94 p.bcf[f] = bc[f] != 0 ? 1 : 0;
95 for (
int a = 0; a < 3; ++a)
96 per[a] = (bc[2 * a] == 0 && bc[2 * a + 1] == 0) ? 1 : 0;
97 const long ncell = (long)inner.x * inner.y * inner.z;
98 auto longer = [&](
int a,
int c) {
return p.n[a] > p.n[c] || (p.n[a] == p.n[c] && a > c); };
100 const bool anyWall = !per[0] || !per[1] || !per[2];
101 for (
int a = 0; a < 3; ++a)
102 if ((!anyWall || !per[a]) && (first < 0 || longer(a, first)))
104 auto fits = [&](
int a) {
return p.n[a] > 0 && ncell / p.n[a] <=
kBottomMaxPlane; };
110 for (
int a = 0; a < 3; ++a)
113 if (longer(r[1], r[0])) {
118 for (
int i = 0; i < 2 && s < 0; ++i)
125 p.a0 = (s == 0) ? 1 : 0;
126 p.a1 = (s == 2) ? 1 : 2;
128 p.b = (int)(ncell / p.P);
129 p.border = (per[s] && p.P >= 3) ? 1 : 0;
134template <
class FacReal>
136 using Mat = Kokkos::View<FacReal***, Kokkos::LayoutRight, CCMem>;
137 using Sq = Kokkos::View<FacReal**, Kokkos::LayoutRight, CCMem>;
144 Kokkos::View<double*, CCMem>
s;
145 Kokkos::View<FacReal*, CCMem>
g,
u;
148 Kokkos::View<int*, CCMem>
stat;
156 const int n = p.P * p.b;
157 d.Q =
Mat(
"peclet::flow::mg_bottom_Q", p.P, p.b, p.b);
159 d.Y =
Mat(
"peclet::flow::mg_bottom_Y", p.P - 1, p.b, p.b);
160 d.e =
Sq(
"peclet::flow::mg_bottom_e", p.P, p.b);
161 d.Sg =
Sq(
"peclet::flow::mg_bottom_sigma", p.b, p.b);
162 d.L =
Sq(
"peclet::flow::mg_bottom_L", p.b, p.b);
163 d.W =
Sq(
"peclet::flow::mg_bottom_W", p.b, p.b);
164 d.s = Kokkos::View<double*, CCMem>(
"peclet::flow::mg_bottom_s",
n);
165 d.g = Kokkos::View<FacReal*, CCMem>(
"peclet::flow::mg_bottom_g",
n);
166 d.u = Kokkos::View<FacReal*, CCMem>(
"peclet::flow::mg_bottom_u",
n);
167 d.stat = Kokkos::View<int*, CCMem>(
"peclet::flow::mg_bottom_stat", 2 +
kBottomAttempts);
170 KOKKOS_INLINE_FUNCTION
int n()
const {
return pl.P *
pl.b; }
172 KOKKOS_INLINE_FUNCTION
void coords(
int f,
int c[3])
const {
173 const int k = f /
pl.b, q = f - k *
pl.b;
174 const int c1 = q /
pl.n[
pl.a0];
176 c[
pl.a0] = q - c1 *
pl.n[
pl.a0];
179 KOKKOS_INLINE_FUNCTION
int extIndex(
const int c[3])
const {
180 return (c[0] + 1) + (c[1] + 1) *
ext.x + (c[2] + 1) *
ext.x *
ext.y;
182 KOKKOS_INLINE_FUNCTION
int extOf(
int f)
const {
188 return c[
pl.s] *
pl.b + c[
pl.a0] +
pl.n[
pl.a0] * c[
pl.a1];
195 KOKKOS_INLINE_FUNCTION
bool face(
const OpV& AFX,
const OpV& AFY,
const OpV& AFZ,
const int c[3],
196 int i,
int f6,
int nb[3],
double& af)
const {
197 const int a = f6 >> 1, side = f6 & 1;
201 int v = c[a] + (side ? 1 : -1);
202 if (v < 0 || v >=
pl.n[a]) {
205 v = (v < 0) ? v +
pl.n[a] : v -
pl.n[a];
208 const int st = (a == 0) ? 1 : (a == 1 ?
ext.x :
ext.x *
ext.y);
209 const int slotIdx = side ? i + st : i;
210 af = (a == 0) ? (
double)AFX(slotIdx) : (a == 1 ? (double)AFY(slotIdx) : (double)AFZ(slotIdx));
226 static constexpr bool kHostLaneM = std::is_same_v<CCMem, Kokkos::HostSpace>;
227 template <
class Member,
class RV,
class ZV,
class CV>
228 KOKKOS_INLINE_FUNCTION
void apply(
const Member& t,
const RV& r,
const ZV& z,
const CV& comp,
229 const ZV* keep,
bool teamAlgorithm =
false)
const {
230 const int P =
pl.P, b =
pl.b, nn = P * b;
231 Kokkos::parallel_for(Kokkos::TeamThreadRange(t, nn), [&](
int f) {
232 const int ei =
extOf(f);
235 u(f) = (FacReal)(
s(f) * r(ei));
246 Kokkos::parallel_for(Kokkos::TeamThreadRange(t, nn), [&](
int f) {
247 const int ei =
extOf(f);
248 z(ei) = (comp(ei) >= 0) ?
s(f) * (double)
g(f) : 0.0;
255 KOKKOS_INLINE_FUNCTION
static void laneMatVec(FacReal* acc,
const FacReal* x,
const FacReal* v,
256 int b,
int lo,
int hi) {
258 for (
int i = lo; i < hi; ++i)
261 for (; j + 4 <= b; j += 4) {
262 const FacReal *x0 = x + j * b, *x1 = x0 + b, *x2 = x1 + b, *x3 = x2 + b;
263 const FacReal v0 = v[j], v1 = v[j + 1], v2 = v[j + 2], v3 = v[j + 3];
265 for (
int i = lo; i < hi; ++i) {
275 const FacReal* xj = x + j * b;
276 const FacReal vj = v[j];
278 for (
int i = lo; i < hi; ++i)
279 acc[i] += xj[i] * vj;
283 template <
class Member>
285 const int P =
pl.P, b =
pl.b;
286 const int Pt =
pl.border ? P - 1 : P;
287 const int rank = t.team_rank(), T = t.team_size();
288 const int lo = (int)((
long)b * rank / T), hi = (int)((
long)b * (rank + 1) / T);
289 FacReal* gp =
g.data();
290 const FacReal* up =
u.data();
292 for (
int k = 0; k < Pt; ++k) {
293 const int o = k * b, op = o - b;
295 for (
int j = 0; j < b; ++j)
298 for (
int j = 0; j < b; ++j)
299 v[j] = up[o + j] -
e(k, j) * gp[op + j];
303 for (
int i = lo; i < hi; ++i)
307 for (
int k = Pt - 2; k >= 0; --k) {
308 const int o = k * b, on = o + b;
309 for (
int j = 0; j < b; ++j)
310 v[j] =
e(k + 1, j) * gp[on + j];
313 for (
int i = lo; i < hi; ++i)
314 gp[o + i] = gp[o + i] - acc[i];
318 const int oB = (P - 1) * b, oL = (P - 2) * b;
319 for (
int j = 0; j < b; ++j)
320 v[j] = (up[oB + j] -
e(0, j) * gp[j]) -
e(P - 1, j) * gp[oL + j];
323 for (
int i = lo; i < hi; ++i)
326 for (
int j = 0; j < b; ++j)
328 for (
int k = 0; k < P - 1; ++k) {
332 for (
int i = lo; i < hi; ++i)
333 gp[o + i] = gp[o + i] - acc[i];
339 template <
class Member>
341 const int P =
pl.P, b =
pl.b;
342 const int Pt =
pl.border ? P - 1 : P;
343 for (
int k = 0; k < Pt; ++k) {
344 const int o = k * b, op = o - b;
345 Kokkos::parallel_for(Kokkos::TeamThreadRange(t, b), [&](
int i) {
349 for (
int j = 0; j < b; ++j)
350 acc +=
Q(k, j, i) *
u(o + j);
353 for (
int j = 0; j < b; ++j)
354 acc +=
Q(k, j, i) * (
u(o + j) -
e(k, j) *
g(op + j));
360 for (
int k = Pt - 2; k >= 0; --k) {
361 const int o = k * b, on = o + b;
362 Kokkos::parallel_for(Kokkos::TeamThreadRange(t, b), [&](
int i) {
365 for (
int j = 0; j < b; ++j)
366 acc +=
Q(k, j, i) * (
e(k + 1, j) *
g(on + j));
367 g(o + i) =
g(o + i) - acc;
372 const int oB = (P - 1) * b, oL = (P - 2) * b;
373 Kokkos::parallel_for(Kokkos::TeamThreadRange(t, b), [&](
int i) {
376 for (
int j = 0; j < b; ++j)
377 acc +=
Q(P - 1, j, i) * ((
u(oB + j) -
e(0, j) *
g(j)) -
e(P - 1, j) *
g(oL + j));
381 Kokkos::parallel_for(Kokkos::TeamThreadRange(t, oB), [&](
int f) {
382 const int k = f / b, i = f - k * b;
385 for (
int j = 0; j < b; ++j)
386 acc +=
Y(k, j, i) *
g(oB + j);
397template <
class FacReal,
class OpV>
399 using Member = Kokkos::TeamPolicy<CCExec>::member_type;
403 using SMat = Kokkos::View<FacReal**, Kokkos::LayoutRight,
typename CCExec::scratch_memory_space,
404 Kokkos::MemoryTraits<Kokkos::Unmanaged>>;
410 Kokkos::View<const int*, CCMem>
comp,
kc;
411 Kokkos::View<const double*, CCMem>
aug;
415 static constexpr bool kHostFactor = std::is_same_v<CCMem, Kokkos::HostSpace>;
417#ifdef PECLET_FLOW_BOTTOM_PROBE
422 static constexpr int kProbeLast = 15;
423 Kokkos::View<long long*, CCMem> probe;
424 KOKKOS_INLINE_FUNCTION
void probeMark(
const Member& t,
int cat)
const {
425 if (t.team_rank() == 0) {
426 const long long now = (
long long)Kokkos::Impl::clock_tic();
428 probe(cat) += now - probe(kProbeLast);
429 probe(kProbeLast) = now;
432#define PECLET_BOTTOM_PROBE_MARK(t, cat) probeMark(t, cat)
434#define PECLET_BOTTOM_PROBE_MARK(t, cat)
439 Kokkos::parallel_for(Kokkos::TeamThreadRange(t,
D.n()), [&](
int f) {
442 const int i = D.extIndex(c);
443 double sum = 0.0, af = 0.0;
444 for (int f6 = 0; f6 < 6; ++f6)
445 if (D.face(AFX, AFY, AFZ, c, i, f6, nb, af))
447 const double d = -sum;
448 D.s(f) = (comp(i) >= 0 && d > 0.0) ? 1.0 / Kokkos::sqrt(d) : 0.0;
456 const int P =
D.pl.P;
457 Kokkos::parallel_for(Kokkos::TeamThreadRange(t,
D.n()), [&](
int f) {
460 const int i = D.extIndex(c), k = c[D.pl.s], q = f - k * D.pl.b;
461 const int km = (k - 1 + P) % P;
462 double v = 0.0, af = 0.0;
463 if (km != k && (k >= 1 || D.pl.border)) {
464 const double si = D.s(f);
465 for (int f6 = 0; f6 < 6; ++f6)
466 if (D.face(AFX, AFY, AFZ, c, i, f6, nb, af) && nb[D.pl.s] == km)
467 v += si * af * D.s(D.factorIndex(nb));
469 D.e(k, q) = (FacReal)v;
475 KOKKOS_INLINE_FUNCTION
double entry(
int k,
int i,
int j,
double delta)
const {
476 const int b =
D.pl.b, fi = k * b + i, fj = k * b + j;
479 const int ei =
D.extIndex(c);
480 double v = (i == j) ? 1.0 : 0.0, af = 0.0;
481 const double si =
D.s(fi);
482 for (
int f6 = 0; f6 < 6; ++f6)
483 if (
D.face(
AFX,
AFY,
AFZ, c, ei, f6, nb, af) &&
D.factorIndex(nb) == fj)
484 v += si * af *
D.s(fj);
485 const int ci =
comp(ei);
486 if (ci >= 0 && ci < (
int)
kc.extent(0) &&
kc(ci) == k &&
comp(
D.extOf(fj)) == ci)
494 KOKKOS_INLINE_FUNCTION
void assemble(
const Member& t,
int k,
int mode,
double delta,
495 const SMat& St)
const {
496 const int b =
D.pl.b, P =
D.pl.P;
497 Kokkos::parallel_for(Kokkos::TeamThreadRange(t, b * b), [&](
int idx) {
498 const int i = idx / b, j = idx - i * b;
501 FacReal a = (FacReal)
entry(k, i, j, delta);
503 a = a -
D.e(k, i) *
D.Q(k - 1, i, j) *
D.e(k, j);
505 a = (a -
D.e(0, i) *
D.Y(0, j, i)) -
D.e(P - 1, i) *
D.Y(P - 2, j, i);
517 KOKKOS_INLINE_FUNCTION
bool invert(
const Member& t,
int k,
double tauPiv,
int flag,
518 const SMat& Ls,
const SMat& St)
const {
519 const int b =
D.pl.b;
520 const auto& S =
D.Sg;
525 const int nc = j1 - j0;
530 for (
int c = -1; c < nc; ++c) {
531 Kokkos::parallel_for(Kokkos::TeamThreadRange(t, nc), [&](
int r) {
534 const int i = j0 + r;
536 const int j = j0 + c;
538 for (
int m = 0; m < c; ++m)
539 a2 += Ls(i, m) * Ls(j, m);
540 const FacReal lij = (St(r, c) - a2) / Ls(j, c);
546 for (
int m = 0; m < r; ++m)
547 acc += Ls(i, m) * Ls(i, m);
548 const FacReal p = St(r, r) - acc;
549 if (!((
double)p > tauPiv))
551 const FacReal lii = Kokkos::sqrt(p);
562 Kokkos::parallel_for(Kokkos::TeamThreadRange(t, j1, b), [&](
int i) {
563 for (
int c = 0; c < nc; ++c) {
564 const int j = j0 + c;
566 for (
int m = 0; m < c; ++m)
567 acc += Ls(i, m) * Ls(j, m);
568 const FacReal lij = (S(i, j) - acc) / Ls(j, c);
575 const int nt = b - j1;
576 Kokkos::parallel_for(Kokkos::TeamThreadRange(t, nt * nt), [&](
int idx) {
577 const int i = j1 + idx / nt, j = j1 + (idx - (idx / nt) * nt);
581 for (
int m = 0; m < nc; ++m)
582 acc += Ls(i, m) * Ls(j, m);
583 const FacReal v = S(i, j) - acc;
586 St(i - j1, j - j1) = v;
600 const int nr = i1 - i0;
601 Kokkos::parallel_for(Kokkos::TeamThreadRange(t, nr * i0 + nr * nr), [&](
int idx) {
603 const int r = idx / i0, j = idx - r * i0, i = i0 + r;
606 for (
int m = j; m < i0; ++m)
607 acc += L(i, m) * W(m, j);
610 const int q = idx - nr * i0, r = q / nr, c = q - r * nr;
612 St(r, c) = L(i0 + r, i0 + c);
616 Kokkos::parallel_for(Kokkos::TeamThreadRange(t, i1), [&](
int j) {
621 const int i = i0 + r;
627 wb[r] = FacReal(1) / St(r, r);
631 FacReal acc = (j < i0) ? A(r, j) : FacReal(0);
632 const int m0 = (j > i0) ? j : i0;
633 for (
int m = m0; m < i; ++m)
634 acc += St(r, m - i0) * wb[m - i0];
635 wb[r] = -acc / St(r, r);
642 Kokkos::parallel_for(Kokkos::TeamThreadRange(t, b * b), [&](
int idx) {
643 const int i = idx / b, j = idx - i * b;
648 for (
int m = i; m < b; ++m)
649 acc += W(m, i) * W(m, j);
660 const int P =
D.pl.P, b =
D.pl.b;
661 for (
int k = 0; k <= P - 2; ++k) {
662 Kokkos::parallel_for(Kokkos::TeamThreadRange(t, b * b), [&](
int idx) {
663 const int c = idx / b, i = idx - c * b;
666 for (
int j = 0; j < b; ++j) {
669 bj = (k == 0 ?
D.e(0, j) : FacReal(0)) + (k == P - 2 ?
D.e(P - 1, j) : FacReal(0));
670 const FacReal br = (k == 0) ? bj : bj -
D.e(k, j) *
D.Y(k - 1, c, j);
671 acc +=
D.Q(k, j, i) * br;
677 for (
int k = P - 3; k >= 0; --k) {
678 Kokkos::parallel_for(Kokkos::TeamThreadRange(t, b * b), [&](
int idx) {
679 const int c = idx / b, i = idx - c * b;
682 for (
int j = 0; j < b; ++j)
683 acc +=
D.Q(k, j, i) * (
D.e(k + 1, j) *
D.Y(k + 1, c, j));
684 D.Y(k, c, i) =
D.Y(k, c, i) - acc;
703 KOKKOS_INLINE_FUNCTION
static void hostAccumulate(FacReal* acc,
const FacReal* x,
704 const FacReal* y,
int b,
int m0,
int m1,
int lo,
707 for (; m + 4 <= m1; m += 4) {
708 const FacReal *x0 = x + m * b, *x1 = x0 + b, *x2 = x1 + b, *x3 = x2 + b;
709 const FacReal y0 = y[m * b], y1 = y[(m + 1) * b], y2 = y[(m + 2) * b], y3 = y[(m + 3) * b];
711 for (
int i = lo; i < hi; ++i) {
720 for (; m < m1; ++m) {
721 const FacReal* xm = x + m * b;
722 const FacReal ym = y[m * b];
724 for (
int i = lo; i < hi; ++i)
725 acc[i] += xm[i] * ym;
731 KOKKOS_INLINE_FUNCTION
static void hostShare(
const Member& t,
int n,
const Wf& w,
int& lo,
733 const int rank = t.team_rank(), T = t.team_size();
735 for (
int i = 0; i < n; ++i)
740 for (
int i = 0; i < n; ++i) {
741 if (lo == n && cum >= tot * rank / T)
743 if (cum >= tot * (rank + 1) / T) {
757 const int b =
D.pl.b, P =
D.pl.P, s =
D.pl.s;
758 FacReal* S =
D.Sg.data();
760 hostShare(t, b, [](
int i) {
return (
double)(i + 1); }, lo, hi);
761 for (
int i = lo; i < hi; ++i) {
763 for (
int j = 0; j < i; ++j)
766 const int fi = k * b + i;
769 const int ei =
D.extIndex(c);
770 const double si =
D.s(fi);
772 for (
int f6 = 0; f6 < 6; ++f6)
773 if (
D.face(
AFX,
AFY,
AFZ, c, ei, f6, nb, af) && nb[s] == k) {
774 const int fj =
D.factorIndex(nb);
776 v[fj - k * b] += si * af *
D.s(fj);
778 const int ci =
comp(ei);
779 if (ci >= 0 && ci < (
int)
kc.extent(0) &&
kc(ci) == k)
780 for (
int j = 0; j <= i; ++j)
781 if (
comp(
D.extOf(k * b + j)) == ci)
784 for (
int j = 0; j <= i; ++j) {
785 FacReal a = (FacReal)v[j];
787 a = a -
D.e(k, i) *
D.Q(k - 1, i, j) *
D.e(k, j);
789 a = (a -
D.e(0, i) *
D.Y(0, j, i)) -
D.e(P - 1, i) *
D.Y(P - 2, j, i);
801 KOKKOS_INLINE_FUNCTION
bool hostInvert(
const Member& t,
int k,
double tauPiv,
int flag)
const {
802 const int b =
D.pl.b, rank = t.team_rank(), T = t.team_size();
803 FacReal* S =
D.Sg.data();
804 FacReal* Lt =
D.L.data();
805 FacReal* W =
D.W.data();
808 const int nc = j1 - j0;
809 Kokkos::single(Kokkos::PerTeam(t), [&]() {
810 for (
int r = 0; r < nc; ++r) {
811 const int i = j0 + r;
812 for (
int c = 0; c < r; ++c) {
813 const int j = j0 + c;
815 for (
int m = 0; m < c; ++m)
816 a2 += Lt[(j0 + m) * b + i] * Lt[(j0 + m) * b + j];
817 Lt[j * b + i] = (S[j * b + i] - a2) / Lt[j * b + j];
820 for (
int m = 0; m < r; ++m)
821 acc += Lt[(j0 + m) * b + i] * Lt[(j0 + m) * b + i];
822 const FacReal p = S[i * b + i] - acc;
823 if (!((
double)p > tauPiv))
825 Lt[i * b + i] = Kokkos::sqrt(p);
829 for (
int c = 0; c < nc; ++c) {
830 const int j = j0 + c;
833 for (
int i = j1; i < b; ++i)
835 hostAccumulate(acc, Lt + j0 * b, Lt + j0 * b + j, b, 0, c, j1, b);
836 const FacReal ljj = Lt[j * b + j];
837 FacReal* Lj = Lt + j * b;
838 const FacReal* Sj = S + j * b;
840 for (
int i = j1; i < b; ++i)
841 Lj[i] = (Sj[i] - acc[i]) / ljj;
848 for (
int j = j1 + rank; j < b; j += T) {
851 for (
int i = j; i < b; ++i)
853 hostAccumulate(acc, Lt + j0 * b, Lt + j0 * b + j, b, 0, nc, j, b);
854 FacReal* Sj = S + j * b;
856 for (
int i = j; i < b; ++i)
857 Sj[i] = Sj[i] - acc[i];
866 hostShare(t, b, [&](
int j) {
return (
double)(b - j) * (b - j); }, ja, jz);
867 for (
int i = ja; i < b; ++i) {
869 const int jt = (i < jz) ? i : jz;
871 for (
int j = ja; j < jt; ++j)
874 for (; m + 4 <= i; m += 4) {
875 hostAccumulate(acc, W, Lt + i, b, m, m + 4, ja, (m + 1 < jz) ? m + 1 : jz);
876 for (
int d = 1; d < 4 && m + d < jz; ++d)
877 for (
int q = m + d; q < m + 4; ++q)
878 acc[m + d] += Lt[q * b + i] * W[q * b + m + d];
881 hostAccumulate(acc, W, Lt + i, b, m, m + 1, ja, (m + 1 < jz) ? m + 1 : jz);
882 const FacReal lii = Lt[i * b + i];
883 FacReal* Wi = W + i * b;
885 for (
int j = ja; j < jt; ++j)
886 Wi[j] = -acc[j] / lii;
888 Wi[i] = FacReal(1) / lii;
891 FacReal* Qk = &
D.Q(k, 0, 0);
893 hostShare(t, b, [&](
int i) {
return (
double)(b - i) * (i + 1); }, qa, qz);
894 for (
int i = qa; i < qz; ++i) {
897 for (
int j = 0; j <= i; ++j)
900 for (
int j = 0; j <= i; ++j) {
901 Qk[i * b + j] = acc[j];
902 Qk[j * b + i] = acc[j];
911 const int P =
D.pl.P, b =
D.pl.b, rank = t.team_rank(), T = t.team_size();
912 for (
int c = rank; c < b; c += T) {
914 for (
int k = 0; k <= P - 2; ++k) {
915 for (
int j = 0; j < b; ++j) {
918 bj = (k == 0 ?
D.e(0, j) : FacReal(0)) + (k == P - 2 ?
D.e(P - 1, j) : FacReal(0));
919 br[j] = (k == 0) ? bj : bj -
D.e(k, j) *
D.Y(k - 1, c, j);
922 for (
int i = 0; i < b; ++i)
924 for (
int j = 0; j < b; ++j) {
925 const FacReal* Qj = &
D.Q(k, j, 0);
926 const FacReal bj = br[j];
928 for (
int i = 0; i < b; ++i)
929 acc[i] += Qj[i] * bj;
931 FacReal* Yk = &
D.Y(k, c, 0);
933 for (
int i = 0; i < b; ++i)
936 for (
int k = P - 3; k >= 0; --k) {
938 for (
int i = 0; i < b; ++i)
940 for (
int j = 0; j < b; ++j) {
941 const FacReal* Qj = &
D.Q(k, j, 0);
942 const FacReal y =
D.e(k + 1, j) *
D.Y(k + 1, c, j);
944 for (
int i = 0; i < b; ++i)
947 FacReal* Yk = &
D.Y(k, c, 0);
949 for (
int i = 0; i < b; ++i)
950 Yk[i] = Yk[i] - acc[i];
957 const int P =
D.pl.P;
958 const int Pt =
D.pl.border ? P - 1 : P;
959 Kokkos::single(Kokkos::PerTeam(t), [&]() {
971 for (
int k = 0; k < Pt && ok; ++k) {
975 if (ok &&
D.pl.border) {
978 ok =
hostInvert(t, P - 1, tauPiv, 2 + attempt);
981 const int restarts = attempt - 1;
982 Kokkos::single(Kokkos::PerTeam(t), [&]() {
983 D.stat(0) = ok ? 1 : 0;
984 D.stat(1) = restarts;
989 const int P =
D.pl.P;
990 const int Pt =
D.pl.border ? P - 1 : P;
999 Kokkos::single(Kokkos::PerTeam(t), [&]() {
1013 for (
int k = 0; k < Pt && ok; ++k) {
1014 assemble(t, k, k == 0 ? 0 : 1, delta, St);
1015 ok =
invert(t, k, tauPiv, 2 + attempt, Ls, St);
1017 if (ok &&
D.pl.border) {
1020 ok =
invert(t, P - 1, tauPiv, 2 + attempt, Ls, St);
1023 const int restarts = attempt - 1;
1024 Kokkos::single(Kokkos::PerTeam(t), [&]() {
1025 D.stat(0) = ok ? 1 : 0;
1026 D.stat(1) = restarts;
flow — portable (Kokkos) cut-cell pressure-operator face openness from an SDF.
#define PECLET_BOTTOM_HOST_SIMD
#define PECLET_BOTTOM_PROBE_MARK(t, cat)
#define PECLET_BOTTOM_UNROLL
double bottomShift(int attempt)
constexpr int kBottomMaxPlane
BottomPlanes bottomChoosePlanes(C3 inner, const int bc[6])
constexpr int kBottomAttempts
constexpr int kBottomTile
constexpr double kBottomPivotTol
Kokkos::View< FacReal ***, Kokkos::LayoutRight, CCMem > Mat
static void laneMatVec(FacReal *acc, const FacReal *x, const FacReal *v, int b, int lo, int hi)
void teamSubstitute(const Member &t) const
int factorIndex(const int c[3]) const
Kokkos::View< FacReal *, CCMem > u
Kokkos::View< FacReal *, CCMem > g
void apply(const Member &t, const RV &r, const ZV &z, const CV &comp, const ZV *keep, bool teamAlgorithm=false) const
Kokkos::View< FacReal **, Kokkos::LayoutRight, CCMem > Sq
static BottomDirect allocate(const BottomPlanes &p, C3 ext)
Kokkos::View< double *, CCMem > s
void coords(int f, int c[3]) const
static constexpr bool kHostLaneM
void laneSubstitute(const Member &t) const
bool face(const OpV &AFX, const OpV &AFY, const OpV &AFZ, const int c[3], int i, int f6, int nb[3], double &af) const
Kokkos::View< int *, CCMem > stat
int extIndex(const int c[3]) const
Kokkos::View< const double *, CCMem > aug
Kokkos::View< const int *, CCMem > comp
void couplings(const Member &t) const
Kokkos::View< const int *, CCMem > kc
bool hostInvert(const Member &t, int k, double tauPiv, int flag) const
static constexpr bool kHostFactor
void assemble(const Member &t, int k, int mode, double delta, const SMat &St) const
Kokkos::TeamPolicy< CCExec >::member_type Member
Kokkos::View< FacReal **, Kokkos::LayoutRight, typename CCExec::scratch_memory_space, Kokkos::MemoryTraits< Kokkos::Unmanaged > > SMat
void hostAssemble(const Member &t, int k, int mode, double delta) const
void scaling(const Member &t) const
static void hostAccumulate(FacReal *acc, const FacReal *x, const FacReal *y, int b, int m0, int m1, int lo, int hi)
void operator()(const Member &t) const
void border(const Member &t) const
bool invert(const Member &t, int k, double tauPiv, int flag, const SMat &Ls, const SMat &St) const
static void hostShare(const Member &t, int n, const Wf &w, int &lo, int &hi)
static std::size_t scratchBytes(int b)
double entry(int k, int i, int j, double delta) const
void hostBorder(const Member &t) const
BottomDirect< FacReal > D
void hostFactor(const Member &t) const
Kokkos::View< double *, peclet::flow::CCMem > OpV