1 #ifndef AMREX_MLNODELAP_2D_K_H_
2 #define AMREX_MLNODELAP_2D_K_H_
3 #include <AMReX_Config.H>
13 Array4<int const>
const& cmsk) noexcept
15 using namespace nodelap_detail;
17 int s = cmsk(i-1,j-1,k) + cmsk(i ,j-1,k)
18 + cmsk(i-1,j ,k) + cmsk(i ,j ,k);
31 Array4<int const>
const& omsk,
Box const& dom,
32 GpuArray<LinOpBCType, AMREX_SPACEDIM>
const& bclo,
33 GpuArray<LinOpBCType, AMREX_SPACEDIM>
const& bchi) noexcept
37 for (
int j = lo.y; j <= hi.y; ++j) {
39 for (
int i = lo.x; i <= hi.x; ++i) {
41 dmsk(i,j,0) = (omsk(i-1,j-1,0) == 1 || omsk(i,j-1,0) == 1 ||
42 omsk(i-1,j ,0) == 1 || omsk(i,j ,0) == 1);
49 if (bclo[0] == LinOpBCType::Dirichlet && lo.x == domlo.x) {
50 for (
int j = lo.y; j <= hi.y; ++j) {
55 if (bchi[0] == LinOpBCType::Dirichlet && hi.x == domhi.x) {
56 for (
int j = lo.y; j <= hi.y; ++j) {
61 if (bclo[1] == LinOpBCType::Dirichlet && lo.y == domlo.y) {
63 for (
int i = lo.x; i <= hi.x; ++i) {
68 if (bchi[1] == LinOpBCType::Dirichlet && hi.y == domhi.y) {
70 for (
int i = lo.x; i <= hi.x; ++i) {
78 Array4<int const>
const& omsk,
Box const& dom,
79 GpuArray<LinOpBCType, AMREX_SPACEDIM>
const& bclo,
80 GpuArray<LinOpBCType, AMREX_SPACEDIM>
const& bchi) noexcept
84 for (
int j = lo.y; j <= hi.y; ++j) {
86 for (
int i = lo.x; i <= hi.x; ++i) {
87 dmsk(i,j,0) =
static_cast<Real
>(omsk(i,j,0));
93 if ((bclo[0] == LinOpBCType::Neumann || bclo[0] == LinOpBCType::inflow)
96 for (
int j = lo.y; j <= hi.y; ++j) {
97 dmsk(lo.x,j,0) *= Real(0.5);
101 if ((bchi[0] == LinOpBCType::Neumann || bchi[0] == LinOpBCType::inflow)
104 for (
int j = lo.y; j <= hi.y; ++j) {
105 dmsk(hi.x,j,0) *= Real(0.5);
109 if ((bclo[1] == LinOpBCType::Neumann || bclo[1] == LinOpBCType::inflow)
113 for (
int i = lo.x; i <= hi.x; ++i) {
114 dmsk(i,lo.y,0) *= Real(0.5);
118 if ((bchi[1] == LinOpBCType::Neumann || bchi[1] == LinOpBCType::inflow)
122 for (
int i = lo.x; i <= hi.x; ++i) {
123 dmsk(i,hi.y,0) *= Real(0.5);
130 Array4<int const>
const& msk,
int fine_flag) noexcept
134 if (msk(i-1,j-1,0) == fine_flag &&
135 msk(i ,j-1,0) == fine_flag &&
136 msk(i-1,j ,0) == fine_flag &&
137 msk(i ,j ,0) == fine_flag)
139 phi(i,j,0) = Real(0.0);
149 Array4<Real const>
const&
fine) noexcept
151 Real a =
fine(2*i ,2*j,k) +
fine(2*i ,2*j+1,k);
152 Real
b =
fine(2*i+1,2*j,k) +
fine(2*i+1,2*j+1,k);
160 Real a =
fine(2*i,2*j ,k) +
fine(2*i+1,2*j ,k);
161 Real
b =
fine(2*i,2*j+1,k) +
fine(2*i+1,2*j+1,k);
167 Array4<Real const>
const&
fine,
int idir) noexcept
170 Real a =
fine(2*i ,j,k);
171 Real b =
fine(2*i+1,j,k);
172 crse(i,j,k) = Real(2.0)*a*b/(a+b);
174 Real a =
fine(i,2*j ,k);
175 Real
b =
fine(i,2*j+1,k);
176 crse(i,j,k) = Real(2.0)*a*
b/(a+
b);
184 template <
typename T>
186 GpuArray<bool,AMREX_SPACEDIM>
const& bflo,
187 GpuArray<bool,AMREX_SPACEDIM>
const& bfhi) noexcept
189 Box gdomain = domain;
190 for (
int idim = 0; idim < AMREX_SPACEDIM; ++idim) {
191 if (! bflo[idim]) { gdomain.
growLo(idim,1); }
192 if (! bfhi[idim]) { gdomain.
growHi(idim,1); }
195 if (gdomain.strictly_contains(vbx)) {
return; }
197 const int offset = domain.cellCentered() ? 0 : 1;
205 if (! gdomain.contains(
IntVect(i,j))) {
207 if (i == dlo.x-1 && j == dlo.y-1 && (bflo[0] || bflo[1]))
209 if (bflo[0] && bflo[1])
211 a(i,j,k) = a(i+1+offset, j+1+offset, k);
215 a(i,j,k) = a(i+1+
offset, j, k);
219 a(i,j,k) = a(i, j+1+
offset, k);
223 else if (i == dhi.x+1 && j == dlo.y-1 && (bfhi[0] || bflo[1]))
225 if (bfhi[0] && bflo[1])
231 a(i,j,k) = a(i-1-
offset, j, k);
235 a(i,j,k) = a(i, j+1+
offset, k);
239 else if (i == dlo.x-1 && j == dhi.y+1 && (bflo[0] || bfhi[1]))
241 if (bflo[0] && bfhi[1])
247 a(i,j,k) = a(i+1+
offset, j, k);
251 a(i,j,k) = a(i, j-1-
offset, k);
255 else if (i == dhi.x+1 && j == dhi.y+1 && (bfhi[0] || bfhi[1]))
257 if (bfhi[0] && bfhi[1])
263 a(i,j,k) = a(i-1-
offset, j, k);
267 a(i,j,k) = a(i, j-1-
offset, k);
270 else if (i == dlo.x-1 && bflo[0])
272 a(i,j,k) = a(i+1+
offset, j, k);
274 else if (i == dhi.x+1 && bfhi[0])
276 a(i,j,k) = a(i-1-
offset, j, k);
278 else if (j == dlo.y-1 && bflo[1])
280 a(i,j,k) = a(i, j+1+
offset, k);
282 else if (j == dhi.y+1 && bfhi[1])
284 a(i,j,k) = a(i, j-1-
offset, k);
303 Real facx = Real(1./6.)*dxinv[0]*dxinv[0];
304 Real facy = Real(1./6.)*dxinv[1]*dxinv[1];
305 Real y =
x(i-1,j-1,k)*(facx*sx(i-1,j-1,k)+facy*sy(i-1,j-1,k))
306 +
x(i+1,j-1,k)*(facx*sx(i ,j-1,k)+facy*sy(i ,j-1,k))
307 +
x(i-1,j+1,k)*(facx*sx(i-1,j ,k)+facy*sy(i-1,j ,k))
308 +
x(i+1,j+1,k)*(facx*sx(i ,j ,k)+facy*sy(i ,j ,k))
309 +
x(i-1,j,k)*(Real(2.0)*facx*(sx(i-1,j-1,k)+sx(i-1,j,k))
310 - facy*(sy(i-1,j-1,k)+sy(i-1,j,k)))
311 +
x(i+1,j,k)*(Real(2.0)*facx*(sx(i ,j-1,k)+sx(i ,j,k))
312 - facy*(sy(i ,j-1,k)+sy(i ,j,k)))
313 +
x(i,j-1,k)*( -facx*(sx(i-1,j-1,k)+sx(i,j-1,k))
314 +Real(2.0)*facy*(sy(i-1,j-1,k)+sy(i,j-1,k)))
315 +
x(i,j+1,k)*( -facx*(sx(i-1,j ,k)+sx(i,j ,k))
316 +Real(2.0)*facy*(sy(i-1,j ,k)+sy(i,j ,k)))
317 +
x(i,j,k)*(-Real(2.0))*(facx*(sx(i-1,j-1,k)+sx(i,j-1,k)+sx(i-1,j,k)+sx(i,j,k))
318 +facy*(sy(i-1,j-1,k)+sy(i,j-1,k)+sy(i-1,j,k)+sy(i,j,k)));
320 Real fp = facy /
static_cast<Real
>(2*i+1);
321 Real fm = facy /
static_cast<Real
>(2*i-1);
322 y += (fm*sy(i-1,j ,k)-fp*sy(i,j ,k))*(
x(i,j+1,k)-
x(i,j,k))
323 + (fm*sy(i-1,j-1,k)-fp*sy(i,j-1,k))*(
x(i,j-1,k)-
x(i,j,k));
337 Real facx = Real(1.0/6.0)*dxinv[0]*dxinv[0];
338 Real facy = Real(1.0/6.0)*dxinv[1]*dxinv[1];
339 Real fxy = facx + facy;
340 Real f2xmy = Real(2.0)*facx - facy;
341 Real fmx2y = Real(2.0)*facy - facx;
342 Real y =
x(i-1,j-1,k)*fxy*sig(i-1,j-1,k)
343 +
x(i+1,j-1,k)*fxy*sig(i ,j-1,k)
344 +
x(i-1,j+1,k)*fxy*sig(i-1,j ,k)
345 +
x(i+1,j+1,k)*fxy*sig(i ,j ,k)
346 +
x(i-1,j,k)*f2xmy*(sig(i-1,j-1,k)+sig(i-1,j,k))
347 +
x(i+1,j,k)*f2xmy*(sig(i ,j-1,k)+sig(i ,j,k))
348 +
x(i,j-1,k)*fmx2y*(sig(i-1,j-1,k)+sig(i,j-1,k))
349 +
x(i,j+1,k)*fmx2y*(sig(i-1,j ,k)+sig(i,j ,k))
350 +
x(i,j,k)*(-Real(2.0))*fxy*(sig(i-1,j-1,k)+sig(i,j-1,k)
351 +sig(i-1,j,k)+sig(i,j,k));
353 Real fp = facy /
static_cast<Real
>(2*i+1);
354 Real fm = facy /
static_cast<Real
>(2*i-1);
355 y += (fm*sig(i-1,j ,k)-fp*sig(i,j ,k))*(
x(i,j+1,k)-
x(i,j,k))
356 + (fm*sig(i-1,j-1,k)-fp*sig(i,j-1,k))*(
x(i,j-1,k)-
x(i,j,k));
370 Real facx = Real(1.0/6.0)*dxinv[0]*dxinv[0];
371 Real facy = Real(1.0/6.0)*dxinv[1]*dxinv[1];
372 Real fxy = facx + facy;
373 Real f2xmy = Real(2.0)*facx - facy;
374 Real fmx2y = Real(2.0)*facy - facx;
375 Real y = (
x(i-1,j-1,k)*fxy
379 +
x(i-1,j,k)*f2xmy*Real(2.)
380 +
x(i+1,j,k)*f2xmy*Real(2.)
381 +
x(i,j-1,k)*fmx2y*Real(2.)
382 +
x(i,j+1,k)*fmx2y*Real(2.)
383 +
x(i,j,k)*(-Real(2.0))*fxy*Real(4.));
385 Real fp = facy /
static_cast<Real
>(2*i+1);
386 Real fm = facy /
static_cast<Real
>(2*i-1);
387 y += ((fm-fp)*(
x(i,j+1,k)-
x(i,j,k))
388 + (fm-fp)*(
x(i,j-1,k)-
x(i,j,k)));
399 Real facx = Real(1.0/6.0)*dxinv[0]*dxinv[0];
400 Real facy = Real(1.0/6.0)*dxinv[1]*dxinv[1];
403 x(i,j,k) /= (-Real(2.0))*(facx*(sx(i-1,j-1,k)+sx(i,j-1,k)+sx(i-1,j,k)+sx(i,j,k))
404 +facy*(sy(i-1,j-1,k)+sy(i,j-1,k)+sy(i-1,j,k)+sy(i,j,k)));
409 void mlndlap_normalize_aa (
int i,
int j,
int k, Array4<Real>
const& x, Array4<Real const>
const& sig,
410 Array4<int const>
const& msk, GpuArray<Real,AMREX_SPACEDIM>
const& dxinv) noexcept
412 Real facx = Real(1.0/6.0)*dxinv[0]*dxinv[0];
413 Real facy = Real(1.0/6.0)*dxinv[1]*dxinv[1];
414 Real fxy = facx + facy;
417 x(i,j,k) /= (-Real(2.0))*fxy*(sig(i-1,j-1,k)+sig(i,j-1,k)+sig(i-1,j,k)+sig(i,j,k));
427 Real facx = -Real(2.0/6.0)*dxinv[0]*dxinv[0];
428 Real facy = -Real(2.0/6.0)*dxinv[1]*dxinv[1];
431 sol(i,j,k) = Real(0.0);
433 sol(i,j,k) += Real(2.0/3.0) * (rhs(i,j,k) - Ax)
434 / (facx*(sx(i-1,j-1,k)+sx(i,j-1,k)+sx(i-1,j,k)+sx(i,j,k))
435 + facy*(sy(i-1,j-1,k)+sy(i,j-1,k)+sy(i-1,j,k)+sy(i,j,k)));
445 Real facx = -Real(2.0/6.0)*dxinv[0]*dxinv[0];
446 Real facy = -Real(2.0/6.0)*dxinv[1]*dxinv[1];
451 sol(i,j,k) = Real(0.0);
453 sol(i,j,k) += Real(2.0/3.0) * (rhs(i,j,k) - Ax(i,j,k))
454 / (facx*(sx(i-1,j-1,k)+sx(i,j-1,k)+sx(i-1,j,k)+sx(i,j,k))
455 + facy*(sy(i-1,j-1,k)+sy(i,j-1,k)+sy(i-1,j,k)+sy(i,j,k)));
462 Array4<Real const>
const& rhs, Array4<Real const>
const& sig,
463 Array4<int const>
const& msk, GpuArray<Real,AMREX_SPACEDIM>
const& dxinv) noexcept
465 Real fac = -Real(2.0/6.0)*(dxinv[0]*dxinv[0] + dxinv[1]*dxinv[1]);
468 sol(i,j,k) = Real(0.0);
470 sol(i,j,k) += Real(2.0/3.0) * (rhs(i,j,k) - Ax)
471 / (fac*(sig(i-1,j-1,k)+sig(i,j-1,k)+sig(i-1,j,k)+sig(i,j,k)));
476 void mlndlap_jacobi_c (
int i,
int j,
int k, Array4<Real>
const& sol, Real Ax,
477 Array4<Real const>
const& rhs, Real sig,
478 Array4<int const>
const& msk, GpuArray<Real,AMREX_SPACEDIM>
const& dxinv) noexcept
480 Real fac = -Real(2.0/6.0)*(dxinv[0]*dxinv[0] + dxinv[1]*dxinv[1]);
483 sol(i,j,k) = Real(0.0);
485 sol(i,j,k) += Real(2.0/3.0) * (rhs(i,j,k) - Ax)
486 / (fac*Real(4.)*sig);
492 Array4<Real const>
const& rhs, Array4<Real const>
const& sig,
493 Array4<int const>
const& msk, GpuArray<Real,AMREX_SPACEDIM>
const& dxinv) noexcept
495 Real fac = -Real(2.0/6.0)*(dxinv[0]*dxinv[0] + dxinv[1]*dxinv[1]);
500 sol(i,j,k) = Real(0.0);
502 sol(i,j,k) += Real(2.0/3.0) * (rhs(i,j,k) - Ax(i,j,k))
503 / (fac*(sig(i-1,j-1,k)+sig(i,j-1,k)+sig(i-1,j,k)+sig(i,j,k)));
509 void mlndlap_jacobi_c (
Box const& bx, Array4<Real>
const& sol, Array4<Real const>
const& Ax,
510 Array4<Real const>
const& rhs, Real sig,
511 Array4<int const>
const& msk, GpuArray<Real,AMREX_SPACEDIM>
const& dxinv) noexcept
513 Real fac = -Real(2.0/6.0)*(dxinv[0]*dxinv[0] + dxinv[1]*dxinv[1]);
518 sol(i,j,k) = Real(0.0);
520 sol(i,j,k) += Real(2.0/3.0) * (rhs(i,j,k) - Ax(i,j,k))
521 / (fac*Real(4.)*sig);
533 Real facx = Real(1.0/6.0)*dxinv[0]*dxinv[0];
534 Real facy = Real(1.0/6.0)*dxinv[1]*dxinv[1];
539 sol(i,j,k) = Real(0.0);
541 Real s0 = Real(-2.0)*(facx*(sx(i-1,j-1,k)+sx(i,j-1,k)+sx(i-1,j,k)+sx(i,j,k))
542 +facy*(sy(i-1,j-1,k)+sy(i,j-1,k)+sy(i-1,j,k)+sy(i,j,k)));
544 Real Ax = sol(i-1,j-1,k)*(facx*sx(i-1,j-1,k)+facy*sy(i-1,j-1,k))
545 + sol(i+1,j-1,k)*(facx*sx(i ,j-1,k)+facy*sy(i ,j-1,k))
546 + sol(i-1,j+1,k)*(facx*sx(i-1,j ,k)+facy*sy(i-1,j ,k))
547 + sol(i+1,j+1,k)*(facx*sx(i ,j ,k)+facy*sy(i ,j ,k))
548 + sol(i-1,j,k)*(Real(2.0)*facx*(sx(i-1,j-1,k)+sx(i-1,j,k))
549 - facy*(sy(i-1,j-1,k)+sy(i-1,j,k)))
550 + sol(i+1,j,k)*(Real(2.0)*facx*(sx(i ,j-1,k)+sx(i ,j,k))
551 - facy*(sy(i ,j-1,k)+sy(i ,j,k)))
552 + sol(i,j-1,k)*( -facx*(sx(i-1,j-1,k)+sx(i,j-1,k))
553 +Real(2.0)*facy*(sy(i-1,j-1,k)+sy(i,j-1,k)))
554 + sol(i,j+1,k)*( -facx*(sx(i-1,j ,k)+sx(i,j ,k))
555 +Real(2.0)*facy*(sy(i-1,j ,k)+sy(i,j ,k)))
559 Real fp = facy /
static_cast<Real
>(2*i+1);
560 Real fm = facy /
static_cast<Real
>(2*i-1);
561 Real frzlo = fm*sy(i-1,j-1,k)-fp*sy(i,j-1,k);
562 Real frzhi = fm*sy(i-1,j ,k)-fp*sy(i,j ,k);
563 s0 += - frzhi - frzlo;
564 Ax += frzhi*(sol(i,j+1,k)-sol(i,j,k))
565 + frzlo*(sol(i,j-1,k)-sol(i,j,k));
568 sol(i,j,k) += (rhs(i,j,k) - Ax) / s0;
580 Real facx = Real(1.0/6.0)*dxinv[0]*dxinv[0];
581 Real facy = Real(1.0/6.0)*dxinv[1]*dxinv[1];
582 Real fxy = facx + facy;
583 Real f2xmy = Real(2.0)*facx - facy;
584 Real fmx2y = Real(2.0)*facy - facx;
589 sol(i,j,k) = Real(0.0);
591 Real s0 = (-Real(2.0))*fxy*(sig(i-1,j-1,k)+sig(i,j-1,k)+sig(i-1,j,k)+sig(i,j,k));
592 Real Ax = sol(i-1,j-1,k)*fxy*sig(i-1,j-1,k)
593 + sol(i+1,j-1,k)*fxy*sig(i ,j-1,k)
594 + sol(i-1,j+1,k)*fxy*sig(i-1,j ,k)
595 + sol(i+1,j+1,k)*fxy*sig(i ,j ,k)
596 + sol(i-1,j,k)*f2xmy*(sig(i-1,j-1,k)+sig(i-1,j,k))
597 + sol(i+1,j,k)*f2xmy*(sig(i ,j-1,k)+sig(i ,j,k))
598 + sol(i,j-1,k)*fmx2y*(sig(i-1,j-1,k)+sig(i,j-1,k))
599 + sol(i,j+1,k)*fmx2y*(sig(i-1,j ,k)+sig(i,j ,k))
603 Real fp = facy /
static_cast<Real
>(2*i+1);
604 Real fm = facy /
static_cast<Real
>(2*i-1);
605 Real frzlo = fm*sig(i-1,j-1,k)-fp*sig(i,j-1,k);
606 Real frzhi = fm*sig(i-1,j ,k)-fp*sig(i,j ,k);
607 s0 += - frzhi - frzlo;
608 Ax += frzhi*(sol(i,j+1,k)-sol(i,j,k))
609 + frzlo*(sol(i,j-1,k)-sol(i,j,k));
612 sol(i,j,k) += (rhs(i,j,k) - Ax) / s0;
624 Real facx = Real(1.0/6.0)*dxinv[0]*dxinv[0];
625 Real facy = Real(1.0/6.0)*dxinv[1]*dxinv[1];
626 Real fxy = facx + facy;
627 Real f2xmy = Real(2.0)*facx - facy;
628 Real fmx2y = Real(2.0)*facy - facx;
633 sol(i,j,k) = Real(0.0);
635 Real s0 = (-Real(2.0))*fxy*Real(4.);
636 Real Ax = sol(i-1,j-1,k)*fxy
640 + sol(i-1,j,k)*f2xmy*Real(2.)
641 + sol(i+1,j,k)*f2xmy*Real(2.)
642 + sol(i,j-1,k)*fmx2y*Real(2.)
643 + sol(i,j+1,k)*fmx2y*Real(2.)
647 Real fp = facy /
static_cast<Real
>(2*i+1);
648 Real fm = facy /
static_cast<Real
>(2*i-1);
651 s0 += - frzhi - frzlo;
652 Ax += frzhi*(sol(i,j+1,k)-sol(i,j,k))
653 + frzlo*(sol(i,j-1,k)-sol(i,j,k));
656 sol(i,j,k) += (rhs(i,j,k) - Ax*sig) / (s0*sig);
667 u_ls(0) = r_ls(0) / bet;
669 for (
int i = 1; i <= ilen - 1; i++) {
670 gam(i) = c_ls(i-1) / bet;
671 bet = b_ls(i) - a_ls(i)*gam(i);
673 u_ls(i) = (r_ls(i)-a_ls(i)*u_ls(i-1)) / bet;
675 for (
int i = ilen-2; i >= 0; i--) {
676 u_ls(i) = u_ls(i) - gam(i+1)*u_ls(i+1);
687 Real facx = Real(1.0/6.0)*dxinv[0]*dxinv[0];
688 Real facy = Real(1.0/6.0)*dxinv[1]*dxinv[1];
689 Real fxy = facx + facy;
690 Real f2xmy = Real(2.0)*facx - facy;
691 Real fmx2y = Real(2.0)*facy - facx;
694 amrex::Abort(
"mlndlap_gauss_seidel_with_line_solve_aa is not implemented in r-z 2D ");
703 if (dxinv[0] <= dxinv[1]) {
705 ilen = hi.y - lo.y + 1;
707 if (dxinv[1] <= dxinv[0]) {
709 ilen = hi.x - lo.x + 1;
713 amrex::Abort(
"mlndlap_gauss_seidel_with_line_solve_aa is hard-wired to be no longer than 32");
719 for (
int i = lo.x; i <= hi.x; ++i)
721 for (
int j = lo.y; j <= hi.y; ++j)
732 Real s0 = (-Real(2.0))*fxy*(sig(i-1,j-1,k)+sig(i,j-1,k)+sig(i-1,j,k)+sig(i,j,k));
734 Real Ax = sol(i-1,j-1,k)*fxy*sig(i-1,j-1,k)
735 + sol(i+1,j-1,k)*fxy*sig(i ,j-1,k)
736 + sol(i-1,j+1,k)*fxy*sig(i-1,j ,k)
737 + sol(i+1,j+1,k)*fxy*sig(i ,j ,k)
738 + sol(i-1,j,k)*f2xmy*(sig(i-1,j-1,k)+sig(i-1,j,k))
739 + sol(i+1,j,k)*f2xmy*(sig(i ,j-1,k)+sig(i ,j,k));
741 a_ls(j-lo.y) = fmx2y*(sig(i-1,j-1,k)+sig(i,j-1,k));
743 c_ls(j-lo.y) = fmx2y*(sig(i-1,j ,k)+sig(i,j ,k));
745 r_ls(j-lo.y) = rhs(i,j,k) - Ax;
750 for (
int j = lo.y; j <= hi.y; ++j)
752 sol(i,j,k) = u_ls(j-lo.y);
755 }
else if (
idir == 0) {
756 for (
int j = lo.y ;j <= hi.y; ++j)
758 for (
int i = lo.x; i <= hi.x; ++i)
769 Real s0 = (-Real(2.0))*fxy*(sig(i-1,j-1,k)+sig(i,j-1,k)+sig(i-1,j,k)+sig(i,j,k));
771 Real Ax = sol(i-1,j-1,k)*fxy*sig(i-1,j-1,k)
772 + sol(i+1,j-1,k)*fxy*sig(i ,j-1,k)
773 + sol(i-1,j+1,k)*fxy*sig(i-1,j ,k)
774 + sol(i+1,j+1,k)*fxy*sig(i ,j ,k)
775 + sol(i,j-1,k)*fmx2y*(sig(i-1,j-1,k)+sig(i,j-1,k))
776 + sol(i,j+1,k)*fmx2y*(sig(i-1,j ,k)+sig(i,j ,k));
778 a_ls(i-lo.x) = f2xmy*(sig(i-1,j-1,k)+sig(i-1,j,k));
780 c_ls(i-lo.x) = f2xmy*(sig(i ,j-1,k)+sig(i ,j,k));
782 r_ls(i-lo.x) = rhs(i,j,k) - Ax;
788 for (
int i = lo.x; i <= hi.x; ++i)
790 sol(i,j,k) = u_ls(i-lo.x);
794 amrex::Abort(
"mlndlap_gauss_seidel_with_line_solve_aa is wrong direction.");
805 Array4<Real const>
const&
fine, Array4<int const>
const& msk) noexcept
811 crse(i,j,k) = Real(0.0);
813 crse(i,j,k) = Real(1./16.)*(
fine(ii-1,jj-1,kk) + Real(2.)*
fine(ii ,jj-1,kk) +
fine(ii+1,jj-1,kk)
814 + Real(2.)*
fine(ii-1,jj ,kk) + Real(4.)*
fine(ii ,jj ,kk) + Real(2.)*
fine(ii+1,jj ,kk)
815 +
fine(ii-1,jj+1,kk) + Real(2.)*
fine(ii ,jj+1,kk) +
fine(ii+1,jj+1,kk));
822 Array4<Real const>
const&
fine, Array4<int const>
const& msk,
824 GpuArray<LinOpBCType, AMREX_SPACEDIM>
const& bclo,
825 GpuArray<LinOpBCType, AMREX_SPACEDIM>
const& bchi) noexcept
830 crse(i,j,k) = Real(0.0);
834 Real tmp = Real(0.0);
835 for (
int joff = -rr+1; joff <= rr-1; ++joff) {
837 for (
int ioff = -rr+1; ioff <= rr-1; ++ioff) {
839 int itmp = ii + ioff;
840 int jtmp = jj + joff;
841 if ((itmp < ndlo.x && (bclo[0] == LinOpBCType::Neumann ||
842 bclo[0] == LinOpBCType::inflow)) ||
843 (itmp > ndhi.x && (bchi[0] == LinOpBCType::Neumann ||
844 bchi[0] == LinOpBCType::inflow))) {
847 if ((jtmp < ndlo.y && (bclo[1] == LinOpBCType::Neumann ||
848 bclo[1] == LinOpBCType::inflow)) ||
849 (jtmp > ndhi.y && (bchi[1] == LinOpBCType::Neumann ||
850 bchi[1] == LinOpBCType::inflow))) {
853 tmp += wx*wy*
fine(itmp,jtmp,0);
856 crse(i,j,k) = tmp*(Real(1.0)/Real(rr*rr*rr*rr));
862 Array4<Real const>
const&
fine, Array4<int const>
const& msk,
int idir) noexcept
869 crse(i,j,k) = Real(0.0);
871 crse(i,j,k) = Real(1./4.)*(
fine(ii-1,jj,kk) + Real(2.)*
fine(ii,jj,kk) +
fine(ii+1,jj,kk));
873 }
else if (
idir == 0) {
877 crse(i,j,k) = Real(0.0);
879 crse(i,j,k) = Real(1./4.)*(
fine(ii,jj-1,kk) + Real(2.)*
fine(ii,jj,kk) +
fine(ii,jj+1,kk));
890 int i,
int j,
int ic,
int jc) noexcept
892 Real w1 = sig(i-1,j-1,0) + sig(i-1,j,0);
893 Real w2 = sig(i ,j-1,0) + sig(i ,j,0);
894 return (w1*
crse(ic,jc,0)+w2*
crse(ic+1,jc,0))/(w1+w2);
899 int i,
int j,
int ic,
int jc) noexcept
901 Real w1 = sig(i-1,j-1,0) + sig(i,j-1,0);
902 Real w2 = sig(i-1,j ,0) + sig(i,j ,0);
903 return (w1*
crse(ic,jc,0)+w2*
crse(ic,jc+1,0))/(w1+w2);
908 int i,
int j,
int ic,
int jc) noexcept
910 Real w1 = sig(i-1,j-1,0) + sig(i-1,j,0);
911 Real w2 = sig(i ,j-1,0) + sig(i ,j,0);
912 Real w3 = sig(i-1,j-1,0) + sig(i,j-1,0);
913 Real w4 = sig(i-1,j ,0) + sig(i,j ,0);
922 Array4<Real const>
const&
crse,
923 Array4<int const>
const& msk) noexcept
928 bool i_is_odd = (ic*2 != i);
929 bool j_is_odd = (jc*2 != j);
930 if (i_is_odd && j_is_odd) {
932 fine(i,j,0) += Real(0.25) * (
crse(ic ,jc ,0) +
936 }
else if (i_is_odd) {
938 fine(i,j,0) += Real(0.5) * (
crse(ic,jc,0)+
crse(ic+1,jc,0));
939 }
else if (j_is_odd) {
941 fine(i,j,0) += Real(0.5) * (
crse(ic,jc,0)+
crse(ic,jc+1,0));
951 Array4<Real const>
const&
crse, Array4<Real const>
const& sig,
952 Array4<int const>
const& msk) noexcept
957 bool i_is_odd = (ic*2 != i);
958 bool j_is_odd = (jc*2 != j);
959 if (i_is_odd && j_is_odd) {
962 }
else if (i_is_odd) {
965 }
else if (j_is_odd) {
977 Array4<Real const>
const&
crse, Array4<Real const>
const& sig,
978 Array4<int const>
const& msk,
int idir) noexcept
984 bool i_is_odd = (ic*2 != i);
993 }
else if (
idir == 0 ) {
997 bool j_is_odd = (ic*2 != i);
1012 int i,
int j,
int ic,
int jc) noexcept
1014 Real w1 = sigx(i-1,j-1,0) + sigx(i-1,j,0);
1015 Real w2 = sigx(i ,j-1,0) + sigx(i ,j,0);
1016 Real w3 = sigy(i-1,j-1,0) + sigy(i,j-1,0);
1017 Real w4 = sigy(i-1,j ,0) + sigy(i,j ,0);
1033 bool i_is_odd = (ic*2 != i);
1034 bool j_is_odd = (jc*2 != j);
1035 if (i_is_odd && j_is_odd) {
1038 }
else if (i_is_odd) {
1041 }
else if (j_is_odd) {
1058 Box const& nodal_domain,
1061 bool is_rz) noexcept
1063 Real facx = Real(0.5)*dxinv[0];
1064 Real facy = Real(0.5)*dxinv[1];
1070 rhs(i,j,k) = Real(0.0);
1073 Real zero_ilo = Real(1.0);
1074 Real zero_ihi = Real(1.0);
1075 Real zero_jlo = Real(1.0);
1076 Real zero_jhi = Real(1.0);
1080 if ((bclo[0] == LinOpBCType::Neumann || bclo[0] == LinOpBCType::inflow)
1083 zero_ilo = Real(0.0);
1085 if ((bchi[0] == LinOpBCType::Neumann || bchi[0] == LinOpBCType::inflow)
1088 zero_ihi = Real(0.0);
1090 if ((bclo[1] == LinOpBCType::Neumann || bclo[1] == LinOpBCType::inflow)
1093 zero_jlo = Real(0.0);
1095 if ((bchi[1] == LinOpBCType::Neumann || bchi[1] == LinOpBCType::inflow)
1098 zero_jhi = Real(0.0);
1101 rhs(i,j,k) = facx*(-vel(i-1,j-1,k,0)*zero_jlo + vel(i,j-1,k,0)*zero_jlo
1102 -vel(i-1,j ,k,0)*zero_jhi + vel(i,j ,k,0)*zero_jhi)
1103 + facy*(-vel(i-1,j-1,k,1)*zero_ilo - vel(i,j-1,k,1)*zero_ihi
1104 +vel(i-1,j ,k,1)*zero_ilo + vel(i,j ,k,1)*zero_ihi);
1107 Real fm = facy /
static_cast<Real
>(6*i-3);
1108 Real fp = facy /
static_cast<Real
>(6*i+3);
1109 rhs(i,j,k) += fm*(vel(i-1,j,k,1)-vel(i-1,j-1,k,1))
1110 - fp*(vel(i ,j,k,1)-vel(i ,j-1,k,1));
1116 Real
mlndlap_rhcc (
int i,
int j,
int k, Array4<Real const>
const& rhcc,
1117 Array4<int const>
const& msk) noexcept
1123 r = Real(0.25) * (rhcc(i-1,j-1,k)+rhcc(i,j-1,k)+rhcc(i-1,j,k)+rhcc(i,j,k));
1131 bool is_rz) noexcept
1133 Real facx = Real(0.5)*dxinv[0];
1134 Real facy = Real(0.5)*dxinv[1];
1135 u(i,j,k,0) -= sig(i,j,k)*facx*(-p(i,j,k)+p(i+1,j,k)-p(i,j+1,k)+p(i+1,j+1,k));
1136 u(i,j,k,1) -= sig(i,j,k)*facy*(-p(i,j,k)-p(i+1,j,k)+p(i,j+1,k)+p(i+1,j+1,k));
1138 Real frz = sig(i,j,k)*facy /
static_cast<Real
>(6*i+3);
1139 u(i,j,k,1) += frz*(p(i,j,k)-p(i+1,j,k)-p(i,j+1,k)+p(i+1,j+1,k));
1146 bool is_rz) noexcept
1148 Real facx = Real(0.5)*dxinv[0];
1149 Real facy = Real(0.5)*dxinv[1];
1150 u(i,j,k,0) -= sig*facx*(-p(i,j,k)+p(i+1,j,k)-p(i,j+1,k)+p(i+1,j+1,k));
1151 u(i,j,k,1) -= sig*facy*(-p(i,j,k)-p(i+1,j,k)+p(i,j+1,k)+p(i+1,j+1,k));
1153 Real frz = sig*facy /
static_cast<Real
>(6*i+3);
1154 u(i,j,k,1) += frz*(p(i,j,k)-p(i+1,j,k)-p(i,j+1,k)+p(i+1,j+1,k));
1162 Real fm = is_rz ? facy /
static_cast<Real
>(6*ii-3) : Real(0.0);
1163 Real fp = is_rz ? facy /
static_cast<Real
>(6*ii+3) : Real(0.0);
1165 Real Df = Real(0.0);
1166 if (velbx.contains(ii-1,jj-1,0)) {
1167 Df += -facx*vel(ii-1,jj-1,0,0) - (facy+fm)*vel(ii-1,jj-1,0,1);
1169 if (velbx.contains(ii,jj-1,0)) {
1170 Df += facx*vel(ii,jj-1,0,0) - (facy-fp)*vel(ii,jj-1,0,1);
1172 if (velbx.contains(ii-1,jj,0)) {
1173 Df += -facx*vel(ii-1,jj,0,0) + (facy+fm)*vel(ii-1,jj,0,1);
1175 if (velbx.contains(ii,jj,0)) {
1176 Df += facx*vel(ii,jj,0,0) + (facy-fp)*vel(ii,jj,0,1);
1188 const int ii = rr*i;
1189 const int jj = rr*j;
1191 const Real facx = Real(0.5)*dxinv[0];
1192 const Real facy = Real(0.5)*dxinv[1];
1194 Real Df = Real(0.0);
1196 const int ilo =
amrex::max(ii-rr+1, fvbx.smallEnd(0));
1197 const int ihi =
amrex::min(ii+rr-1, fvbx.bigEnd (0));
1198 const int jlo =
amrex::max(jj-rr+1, fvbx.smallEnd(1));
1199 const int jhi =
amrex::min(jj+rr-1, fvbx.bigEnd (1));
1201 for (
int joff = jlo; joff <= jhi; ++joff) {
1202 for (
int ioff = ilo; ioff <= ihi; ++ioff) {
1205 if (fvbx.strictly_contains(ioff,joff,0)) {
1206 Df +=
scale * frhs(ioff,joff,0);
1212 rhs(i,j,0) = Df * (Real(1.0)/
static_cast<Real
>(rr*rr*rr*rr));
1214 rhs(i,j,0) = Real(0.0);
1221 Array4<Real>
const& rhs, Array4<Real const>
const& cc,
1222 Array4<int const>
const& msk) noexcept
1224 const int ii = rr*i;
1225 const int jj = rr*j;
1227 Real tmp = Real(0.0);
1229 const int ilo =
amrex::max(ii-rr , ccbx.smallEnd(0));
1230 const int ihi =
amrex::min(ii+rr-1, ccbx.bigEnd (0));
1231 const int jlo =
amrex::max(jj-rr , ccbx.smallEnd(1));
1232 const int jhi =
amrex::min(jj+rr-1, ccbx.bigEnd (1));
1234 for (
int joff = jlo; joff <= jhi; ++joff) {
1235 for (
int ioff = ilo; ioff <= ihi; ++ioff) {
1236 Real
scale = (
static_cast<Real
>(rr)-
std::abs(
static_cast<Real
>(ioff-ii)+Real(0.5)))
1237 * (
static_cast<Real
>(rr)-
std::abs(
static_cast<Real
>(joff-jj)+Real(0.5)));
1238 tmp += cc(ioff,joff,0) *
scale;
1241 rhs(i,j,0) += tmp * (Real(1.0)/Real(rr*rr*rr*rr));
1250 Real val = Real(1.0);
1255 if ((i == ndlo.x && ( bclo[0] == LinOpBCType::Neumann ||
1256 bclo[0] == LinOpBCType::inflow)) ||
1257 (i == ndhi.x && ( bchi[0] == LinOpBCType::Neumann ||
1258 bchi[0] == LinOpBCType::inflow))) {
1262 if ((j == ndlo.y && ( bclo[1] == LinOpBCType::Neumann ||
1263 bclo[1] == LinOpBCType::inflow)) ||
1264 (j == ndhi.y && ( bchi[1] == LinOpBCType::Neumann ||
1265 bchi[1] == LinOpBCType::inflow))) {
1278 Box const& ccdom_p,
Box const& veldom,
Box const& nddom,
1282 using namespace nodelap_detail;
1285 Real facx = Real(0.5) * dxinv[0];
1286 Real facy = Real(0.5) * dxinv[1];
1287 Real tmp = fc(i,j,0);
1289 Real fm = is_rz ? facy /
static_cast<Real
>(6*i-3) : Real(0.0);
1290 Real fp = is_rz ? facy /
static_cast<Real
>(6*i+3) : Real(0.0);
1295 if (ccmsk(i-1,j-1,0) ==
crse_cell && veldom.contains(i-1,j-1,0)) {
1296 tmp += -facx*vel(i-1,j-1,0,0) - (facy+fm)*vel(i-1,j-1,0,1);
1297 if (rhcc && ccdom_p.contains(i-1,j-1,0)) {
1298 tmp += Real(0.25) * rhcc(i-1,j-1,0);
1302 if (ccmsk(i,j-1,0) ==
crse_cell && veldom.contains(i,j-1,0)) {
1303 tmp += facx*vel(i,j-1,0,0) - (facy-fp)*vel(i,j-1,0,1);
1304 if (rhcc && ccdom_p.contains(i,j-1,0)) {
1305 tmp += Real(0.25) * rhcc(i,j-1,0);
1309 if (ccmsk(i-1,j,0) ==
crse_cell && veldom.contains(i-1,j,0)) {
1310 tmp += -facx*vel(i-1,j,0,0) + (facy+fm)*vel(i-1,j,0,1);
1311 if (rhcc && ccdom_p.contains(i-1,j,0)) {
1312 tmp += Real(0.25) * rhcc(i-1,j,0);
1316 if (ccmsk(i,j,0) ==
crse_cell && veldom.contains(i,j,0)) {
1317 tmp += facx*vel(i,j,0,0) + (facy-fp)*vel(i,j,0,1);
1318 if (rhcc && ccdom_p.contains(i,j,0)) {
1319 tmp += Real(0.25) * rhcc(i,j,0);
1333 Array4<Real const>
const& rhs, Array4<int const>
const& msk,
1334 Box const& nddom, GpuArray<LinOpBCType,AMREX_SPACEDIM>
const& bclo,
1335 GpuArray<LinOpBCType,AMREX_SPACEDIM>
const& bchi,
1336 bool neumann_doubling) noexcept
1338 if ( msk(i-1,j-1,k ) == 0 ||
1339 msk(i ,j-1,k ) == 0 ||
1340 msk(i-1,j ,k ) == 0 ||
1341 msk(i ,j ,k ) == 0 )
1343 Real fac = Real(1.0);
1344 if (neumann_doubling) {
1347 if ((i == ndlo.x && ( bclo[0] == LinOpBCType::Neumann ||
1348 bclo[0] == LinOpBCType::inflow)) ||
1349 (i == ndhi.x && ( bchi[0] == LinOpBCType::Neumann ||
1350 bchi[0] == LinOpBCType::inflow))) {
1353 if ((j == ndlo.y && ( bclo[1] == LinOpBCType::Neumann ||
1354 bclo[1] == LinOpBCType::inflow)) ||
1355 (j == ndhi.y && ( bchi[1] == LinOpBCType::Neumann ||
1356 bchi[1] == LinOpBCType::inflow))) {
1361 resid(i,j,k) = (rhs(i,j,k) - resid(i,j,k)) * fac;
1363 resid(i,j,k) = Real(0.);
1371 template <
typename P,
typename S>
1376 Real Ax = Real(0.0);
1377 Real fp = Real(0.0), fm = Real(0.0);
1379 fp = facy /
static_cast<Real
>(2*i+1);
1380 fm = facy /
static_cast<Real
>(2*i-1);
1382 if (pred(i-1,j-1)) {
1383 Ax += sig(i-1,j-1,0)*(facx*(Real(2.)*(phi(i-1,j ,0)-phi(i ,j ,0))
1384 + (phi(i-1,j-1,0)-phi(i ,j-1,0)))
1385 + facy*(Real(2.)*(phi(i ,j-1,0)-phi(i ,j ,0))
1386 + (phi(i-1,j-1,0)-phi(i-1,j ,0)))
1387 + fm * (phi(i ,j-1,0)-phi(i ,j ,0)));
1390 Ax += sig(i,j-1,0)*(facx*(Real(2.)*(phi(i+1,j ,0)-phi(i ,j ,0))
1391 + (phi(i+1,j-1,0)-phi(i ,j-1,0)))
1392 + facy*(Real(2.)*(phi(i ,j-1,0)-phi(i ,j ,0))
1393 + (phi(i+1,j-1,0)-phi(i+1,j ,0)))
1394 - fp * (phi(i ,j-1,0)-phi(i ,j ,0)));
1397 Ax += sig(i-1,j,0)*(facx*(Real(2.)*(phi(i-1,j ,0)-phi(i ,j ,0))
1398 + (phi(i-1,j+1,0)-phi(i ,j+1,0)))
1399 + facy*(Real(2.)*(phi(i ,j+1,0)-phi(i ,j ,0))
1400 + (phi(i-1,j+1,0)-phi(i-1,j ,0)))
1401 + fm * (phi(i ,j+1,0)-phi(i ,j ,0)));
1404 Ax += sig(i,j,0)*(facx*(Real(2.)*(phi(i+1,j ,0)-phi(i ,j ,0))
1405 + (phi(i+1,j+1,0)-phi(i ,j+1,0)))
1406 + facy*(Real(2.)*(phi(i ,j+1,0)-phi(i ,j ,0))
1407 + (phi(i+1,j+1,0)-phi(i+1,j ,0)))
1408 - fp * (phi(i ,j+1,0)-phi(i ,j ,0)));
1413 template <
int rr,
typename S>
1422 const int ii = rr*i;
1423 const int jj = rr*j;
1425 Real facx = Real(1./6.)*dxinv[0]*dxinv[0];
1426 Real facy = Real(1./6.)*dxinv[1]*dxinv[1];
1428 auto is_fine = [&ccbx] (
int ix,
int iy) ->
bool {
1429 return ccbx.contains(
ix,
iy,0);
1432 Real Df = Real(0.0);
1434 const int ilo =
amrex::max(ii-rr+1, ndbx.smallEnd(0));
1435 const int ihi =
amrex::min(ii+rr-1, ndbx.bigEnd (0));
1436 const int jlo =
amrex::max(jj-rr+1, ndbx.smallEnd(1));
1437 const int jhi =
amrex::min(jj+rr-1, ndbx.bigEnd (1));
1439 for (
int joff = jlo; joff <= jhi; ++joff) {
1440 for (
int ioff = ilo; ioff <= ihi; ++ioff) {
1443 if (ndbx.strictly_contains(ioff,joff,0)) {
1444 Df +=
scale * (rhs(ioff,joff,0)-res(ioff,joff,0));
1447 (is_fine, sig, ioff, joff, facx, facy, phi, is_rz);
1451 f(i,j,0) = Df * (Real(1.0)/
static_cast<Real
>(rr*rr*rr*rr));
1453 f(i,j,0) = Real(0.0);
1466 mlndlap_Ax_fine_contrib_doit<rr>
1467 ([&sig] (
int ix,
int iy,
int) -> Real
const& {
return sig(
ix,
iy,0); },
1468 i,j,ndbx,ccbx,
f,res,rhs,phi,msk,is_rz,dxinv);
1480 mlndlap_Ax_fine_contrib_doit<rr>
1481 ([=] (
int,
int,
int) -> Real {
return sig; },
1482 i,j,ndbx,ccbx,
f,res,rhs,phi,msk,is_rz,dxinv);
1492 Box const& ccdom_p,
Box const& nddom,
1496 bool neumann_doubling) noexcept
1498 using namespace nodelap_detail;
1501 Real facx = Real(1./6.)*dxinv[0]*dxinv[0];
1502 Real facy = Real(1./6.)*dxinv[1]*dxinv[1];
1506 return ccdom_p.contains(
ix,
iy,0)
1509 [&sig] (
int ix,
int iy,
int) -> Real
const&
1511 return sig(
ix,
iy,0);
1513 i, j, facx, facy, phi, is_rz);
1515 Real
const ns = (neumann_doubling) ?
neumann_scale(i,j,nddom,bclo,bchi) : Real(1.0);
1516 res(i,j,0) = rhs(i,j,0) - Ax*ns;
1527 Box const& ccdom_p,
Box const& nddom,
1531 bool neumann_doubling) noexcept
1533 using namespace nodelap_detail;
1536 Real facx = Real(1./6.)*dxinv[0]*dxinv[0];
1537 Real facy = Real(1./6.)*dxinv[1]*dxinv[1];
1541 return ccdom_p.contains(
ix,
iy,0)
1548 i, j, facx, facy, phi, is_rz);
1550 Real
const ns = (neumann_doubling) ?
neumann_scale(i,j,nddom,bclo,bchi) : Real(1.0);
1551 res(i,j,0) = rhs(i,j,0) - Ax*ns;
1561 Array4<Real const>
const& sigma,
1562 GpuArray<Real,AMREX_SPACEDIM>
const& dxinv) noexcept
1564 Real facx = Real(1.0/6.0)*dxinv[0]*dxinv[0];
1565 Real facy = Real(1.0/6.0)*dxinv[1]*dxinv[1];
1566 Real fxy = facx + facy;
1567 Real f2xmy = Real(2.0)*facx - facy;
1568 Real fmx2y = Real(2.0)*facy - facx;
1572 sten(i,j,k,1) = f2xmy*(sigma(i,j-1,k)+sigma(i,j,k));
1573 sten(i,j,k,2) = fmx2y*(sigma(i-1,j,k)+sigma(i,j,k));
1574 sten(i,j,k,3) = fxy*sigma(i,j,k);
1581 using namespace nodelap_detail;
1583 sten(i,j,k,0) = -(sten(i-1,j ,k,1) + sten(i ,j ,k,1)
1584 + sten(i ,j-1,k,2) + sten(i ,j ,k,2)
1585 + sten(i-1,j-1,k,3) + sten(i ,j-1,k,3)
1586 + sten(i-1,j ,k,3) + sten(i ,j ,k,3));
1587 sten(i,j,k,4) = Real(1.0) / (
std::abs(sten(i-1,j ,k,1)) +
std::abs(sten(i,j ,k,1))
1595 Array4<Real const>
const& fsten) noexcept
1597 using namespace nodelap_detail;
1599 constexpr
int k = 0;
1602 auto interp_from_mm_to = [&fsten] (
int i_,
int j_) -> Real {
1605 Real wmm =
std::abs(fsten(i_-1,j_-1,0,3)) * (Real(1.) + wxm + wym);
1606 return wmm * fsten(i_,j_,0,4);
1610 auto interp_from_mp_to = [&fsten] (
int i_,
int j_) -> Real {
1613 Real wmp =
std::abs(fsten(i_-1,j_ ,0,3)) *(Real(1.) + wxm + wyp);
1614 return wmp * fsten(i_,j_,0,4);
1617 auto interp_from_pm_to = [&fsten] (
int i_,
int j_) -> Real {
1620 Real wpm =
std::abs(fsten(i_ ,j_-1,0,3)) * (Real(1.) + wxp + wym);
1621 return wpm * fsten(i_,j_,0,4);
1624 auto interp_from_pp_to = [&fsten] (
int i_,
int j_) -> Real {
1627 Real wpp =
std::abs(fsten(i_ ,j_ ,0,3)) * (Real(1.) + wxp + wyp);
1628 return wpp * fsten(i_,j_,0,4);
1631 auto interp_from_m0_to = [&fsten] (
int i_,
int j_) -> Real {
1635 auto interp_from_p0_to = [&fsten] (
int i_,
int j_) -> Real {
1639 auto interp_from_0m_to = [&fsten] (
int i_,
int j_) -> Real {
1643 auto interp_from_0p_to = [&fsten] (
int i_,
int j_) -> Real {
1648 auto Amm = [&fsten] (
int i_,
int j_) -> Real {
1649 return fsten(i_-1,j_-1,0,3);
1653 auto A0m = [&fsten] (
int i_,
int j_) -> Real {
1654 return fsten(i_,j_-1,0,2);
1657 auto Apm = [&fsten] (
int i_,
int j_) -> Real {
1658 return fsten(i_,j_-1,0,3);
1661 auto Am0 = [&fsten] (
int i_,
int j_) -> Real {
1662 return fsten(i_-1,j_,0,1);
1665 auto A00 = [&fsten] (
int i_,
int j_) -> Real {
1666 return fsten(i_,j_,0,0);
1669 auto Ap0 = [&fsten] (
int i_,
int j_) -> Real {
1670 return fsten(i_,j_,0,1);
1673 auto Amp = [&fsten] (
int i_,
int j_) -> Real {
1674 return fsten(i_-1,j_,0,3);
1677 auto A0p = [&fsten] (
int i_,
int j_) -> Real {
1678 return fsten(i_,j_,0,2);
1681 auto App = [&fsten] (
int i_,
int j_) -> Real {
1682 return fsten(i_,j_,0,3);
1686 auto restrict_from_mm_to = [&fsten] (
int ii_,
int jj_) -> Real {
1689 Real wpp =
std::abs(fsten(ii_-1,jj_-1,0,3))*(Real(1.)+wxp+wyp);
1690 return wpp * fsten(ii_-1,jj_-1,0,4);
1694 auto restrict_from_0m_to = [&fsten] (
int ii_,
int jj_) -> Real {
1698 auto restrict_from_pm_to = [&fsten] (
int ii_,
int jj_) -> Real {
1701 Real wmp =
std::abs(fsten(ii_ ,jj_-1,0,3)) *(Real(1.) + wxm + wyp);
1702 return wmp * fsten(ii_+1,jj_-1,0,4);
1705 auto restrict_from_m0_to = [&fsten] (
int ii_,
int jj_) -> Real {
1709 auto restrict_from_p0_to = [&fsten] (
int ii_,
int jj_) -> Real {
1713 auto restrict_from_mp_to = [&fsten] (
int ii_,
int jj_) -> Real {
1716 Real wpm =
std::abs(fsten(ii_-1,jj_ ,0,3)) * (Real(1.) + wxp + wym);
1717 return wpm * fsten(ii_-1,jj_+1,0,4);
1720 auto restrict_from_0p_to = [&fsten] (
int ii_,
int jj_) -> Real {
1724 auto restrict_from_pp_to = [&fsten] (
int ii_,
int jj_) -> Real {
1727 Real wmm =
std::abs(fsten(ii_ ,jj_ ,0,3)) * (Real(1.) + wxm + wym);
1728 return wmm * fsten(ii_+1,jj_+1,0,4);
1733 Array2D<Real,-1,1,-1,1> ap, p;
1736 p(-1,-1) = interp_from_pp_to(ii+1,jj-1);
1737 p( 0,-1) = interp_from_0p_to(ii+2,jj-1);
1738 p(-1, 0) = interp_from_p0_to(ii+1,jj );
1739 p( 0, 0) = Real(1.);
1740 p(-1, 1) = interp_from_pm_to(ii+1,jj+1);
1741 p( 0, 1) = interp_from_0m_to(ii+2,jj+1);
1743 ap(0,-1) = Ap0(ii,jj-1)*p(-1,-1) + App(ii,jj-1)*p(-1,0);
1744 ap(1,-1) = A00(ii+1,jj-1)*p(-1,-1) + Ap0(ii+1,jj-1)*p(0,-1)
1745 + A0p(ii+1,jj-1)*p(-1,0) + App(ii+1,jj-1)*p(0,0);
1746 ap(0,0) = Apm(ii,jj)*p(-1,-1) + Ap0(ii,jj)*p(-1,0) + App(ii,jj)*p(-1,1);
1747 ap(1,0) = A0m(ii+1,jj)*p(-1,-1) + Apm(ii+1,jj)*p(0,-1)
1748 + A00(ii+1,jj)*p(-1,0) + Ap0(ii+1,jj)*p(0,0)
1749 + A0p(ii+1,jj)*p(-1,1) + App(ii+1,jj)*p(0,1);
1750 ap(0,1) = Apm(ii,jj+1)*p(-1,0) + Ap0(ii,jj+1)*p(-1,1);
1751 ap(1,1) = A0m(ii+1,jj+1)*p(-1,0) + Apm(ii+1,jj+1)*p(0,0)
1752 + A00(ii+1,jj+1)*p(-1,1) + Ap0(ii+1,jj+1)*p(0,1);
1754 csten(i,j,k,1) = Real(0.25)*(restrict_from_0m_to(ii,jj)*ap(0,-1)
1755 + restrict_from_pm_to(ii,jj)*ap(1,-1)
1757 + restrict_from_p0_to(ii,jj)*ap(1,0)
1758 + restrict_from_0p_to(ii,jj)*ap(0,1)
1759 + restrict_from_pp_to(ii,jj)*ap(1,1));
1762 p(-1,-1) = interp_from_pp_to(ii-1,jj+1);
1763 p( 0,-1) = interp_from_0p_to(ii ,jj+1);
1764 p( 1,-1) = interp_from_mp_to(ii+1,jj+1);
1765 p(-1, 0) = interp_from_p0_to(ii-1,jj+2);
1766 p( 0, 0) = Real(1.);
1767 p( 1, 0) = interp_from_m0_to(ii+1,jj+2);
1769 ap(-1,0) = A0p(ii-1,jj)*p(-1,-1) + App(ii-1,jj)*p(0,-1);
1770 ap(0,0) = Amp(ii,jj)*p(-1,-1) + A0p(ii,jj)*p(0,-1) + App(ii,jj)*p(1,-1);
1771 ap(1,0) = Amp(ii+1,jj)*p(0,-1) + A0p(ii+1,jj)*p(1,-1);
1772 ap(-1,1) = A00(ii-1,jj+1)*p(-1,-1) + Ap0(ii-1,jj+1)*p(0,-1)
1773 + A0p(ii-1,jj+1)*p(-1,0) + App(ii-1,jj+1)*p(0,0);
1774 ap(0,1) = Am0(ii,jj+1)*p(-1,-1) + A00(ii,jj+1)*p(0,-1) + Ap0(ii,jj+1)*p(1,-1)
1775 + Amp(ii,jj+1)*p(-1,0) + A0p(ii,jj+1)*p(0,0) + App(ii,jj+1)*p(1,0);
1776 ap(1,1) = Am0(ii+1,jj+1)*p(0,-1) + A00(ii+1,jj+1)*p(1,-1)
1777 + Amp(ii+1,jj+1)*p(0,0) + A0p(ii+1,jj+1)*p(1,0);
1779 csten(i,j,k,2) = Real(0.25)*(restrict_from_m0_to(ii,jj)*ap(-1,0)
1781 + restrict_from_p0_to(ii,jj)*ap(1,0)
1782 + restrict_from_mp_to(ii,jj)*ap(-1,1)
1783 + restrict_from_0p_to(ii,jj)*ap(0,1)
1784 + restrict_from_pp_to(ii,jj)*ap(1,1));
1787 p(-1,-1) = interp_from_pp_to(ii+1,jj+1);
1788 p( 0,-1) = interp_from_0p_to(ii+2,jj+1);
1789 p(-1, 0) = interp_from_p0_to(ii+1,jj+2);
1790 p( 0, 0) = Real(1.);
1792 ap(0,0) = App(ii,jj)*p(-1,-1);
1793 ap(1,0) = A0p(ii+1,jj)*p(-1,-1) + App(ii+1,jj)*p(0,-1);
1794 ap(0,1) = Ap0(ii,jj+1)*p(-1,-1) + App(ii,jj+1)*p(-1,0);
1795 ap(1,1) = A00(ii+1,jj+1)*p(-1,-1) + Ap0(ii+1,jj+1)*p(0,-1)
1796 + A0p(ii+1,jj+1)*p(-1,0) + App(ii+1,jj+1)*p(0,0);
1798 Real cross1 = Real(0.25)*(ap(0,0)
1799 + restrict_from_p0_to(ii,jj)*ap(1,0)
1800 + restrict_from_0p_to(ii,jj)*ap(0,1)
1801 + restrict_from_pp_to(ii,jj)*ap(1,1));
1803 p(0,-1) = interp_from_0p_to(ii,jj+1);
1804 p(1,-1) = interp_from_mp_to(ii+1,jj+1);
1806 p(1, 0) = interp_from_m0_to(ii+1,jj+2);
1808 ap(-1,0) = Amp(ii+1,jj)*p(0,-1) + A0p(ii+1,jj)*p(1,-1);
1809 ap( 0,0) = Amp(ii+2,jj)*p(1,-1);
1810 ap(-1,1) = Am0(ii+1,jj+1)*p(0,-1) + A00(ii+1,jj+1)*p(1,-1) + Amp(ii+1,jj+1)*p(0,0)
1811 + A0p(ii+1,jj+1)*p(1,0);
1812 ap( 0,1) = Am0(ii+2,jj+1)*p(1,-1) + Amp(ii+2,jj+1)*p(1,0);
1814 Real cross2 = Real(0.25)*(ap(0,0)
1815 + restrict_from_m0_to(ii+2,jj)*ap(-1,0)
1816 + restrict_from_mp_to(ii+2,jj)*ap(-1,1)
1817 + restrict_from_0p_to(ii+2,jj)*ap( 0,1));
1819 csten(i,j,k,3) = Real(0.5)*(cross1+cross2);
1826 return x(i-1,j-1,k)*sten(i-1,j-1,k,3)
1827 +
x(i ,j-1,k)*sten(i ,j-1,k,2)
1828 +
x(i+1,j-1,k)*sten(i ,j-1,k,3)
1829 +
x(i-1,j ,k)*sten(i-1,j ,k,1)
1830 +
x(i ,j ,k)*sten(i ,j ,k,0)
1831 +
x(i+1,j ,k)*sten(i ,j ,k,1)
1832 +
x(i-1,j+1,k)*sten(i-1,j ,k,3)
1833 +
x(i ,j+1,k)*sten(i ,j ,k,2)
1834 +
x(i+1,j+1,k)*sten(i ,j ,k,3);
1839 Array4<Real const>
const& sten, Array4<int const>
const& msk) noexcept
1855 sol(i,j,k) = Real(0.0);
1856 }
else if (sten(i,j,k,0) != Real(0.0)) {
1858 sol(i,j,k) += (rhs(i,j,k) - Ax) / sten(i,j,k,0);
1864 Array4<Real const>
const& rhs,
1865 Array4<Real const>
const& sten,
1866 Array4<int const>
const& msk) noexcept
1876 Array4<Real const>
const&
crse, Array4<Real const>
const& sten,
1877 Array4<int const>
const& msk) noexcept
1879 using namespace nodelap_detail;
1881 if (!msk(i,j,0) && sten(i,j,0,0) != Real(0.0)) {
1884 bool ieven = ic*2 == i;
1885 bool jeven = jc*2 == j;
1887 if (ieven && jeven) {
1890 Real wym =
std::abs(sten(i,j-1,0,2));
1891 Real wyp =
std::abs(sten(i,j ,0,2));
1892 fv = (wym*
crse(ic,jc,0) + wyp*
crse(ic,jc+1,0)) / (wym+wyp+
eps);
1894 Real wxm =
std::abs(sten(i-1,j,0,1));
1895 Real wxp =
std::abs(sten(i ,j,0,1));
1896 fv = (wxm*
crse(ic,jc,0) + wxp*
crse(ic+1,jc,0)) / (wxm+wxp+
eps);
1898 Real wxm =
std::abs(sten(i-1,j ,0,1)) /
1900 Real wxp =
std::abs(sten(i ,j ,0,1)) /
1902 Real wym =
std::abs(sten(i ,j-1,0,2)) /
1904 Real wyp =
std::abs(sten(i ,j ,0,2)) /
1906 Real wmm =
std::abs(sten(i-1,j-1,0,3)) * (Real(1.0) + wxm + wym);
1907 Real wpm =
std::abs(sten(i,j-1,0,3)) * (Real(1.0) + wxp + wym);
1908 Real wmp =
std::abs(sten(i-1,j,0,3)) *(Real(1.0) + wxm + wyp);
1909 Real wpp =
std::abs(sten(i,j,0,3)) * (Real(1.0) + wxp + wyp);
1910 fv = (wmm*
crse(ic,jc,0) + wpm*
crse(ic+1,jc,0)
1911 + wmp*
crse(ic,jc+1,0) + wpp*
crse(ic+1,jc+1,0))
1912 / (wmm+wpm+wmp+wpp+
eps);
1921 Array4<Real const>
const&
fine, Array4<Real const>
const& sten,
1922 Array4<int const>
const& msk) noexcept
1924 using namespace nodelap_detail;
1929 crse(i,j,0) = Real(0.0);
1932 Real cv =
fine(ii,jj,0)
1946 Real wxp =
std::abs(sten(ii-1,jj-1,0,1))
1949 Real wyp =
std::abs(sten(ii-1,jj-1,0,2))
1952 Real wpp =
std::abs(sten(ii-1,jj-1,0,3))*(Real(1.0) + wxp + wyp);
1953 cv += wpp*sten(ii-1,jj-1,0,4)*
fine(ii-1,jj-1,0);
1955 Real wxm =
std::abs(sten(ii ,jj-1,0,1))
1958 wyp =
std::abs(sten(ii+1,jj-1,0,2))
1961 Real wmp =
std::abs(sten(ii ,jj-1,0,3))*(Real(1.0) + wxm + wyp);
1962 cv += wmp*sten(ii+1,jj-1,0,4)*
fine(ii+1,jj-1,0);
1964 wxp =
std::abs(sten(ii-1,jj+1,0,1))
1967 Real wym =
std::abs(sten(ii-1,jj ,0,2))
1970 Real wpm =
std::abs(sten(ii-1,jj ,0,3)) * (Real(1.0) + wxp + wym);
1971 cv += wpm*sten(ii-1,jj+1,0,4)*
fine(ii-1,jj+1,0);
1979 Real wmm =
std::abs(sten(ii ,jj ,0,3)) * (Real(1.0) + wxm + wym);
1980 cv += wmm*sten(ii+1,jj+1,0,4)*
fine(ii+1,jj+1,0);
1982 crse(i,j,0) = cv * Real(0.25);
1988 namespace nodelap_detail {
1989 constexpr
int i_S_x = 0;
1990 constexpr
int i_S_y = 1;
1991 constexpr
int i_S_x2 = 2;
1992 constexpr
int i_S_y2 = 3;
1993 constexpr
int i_S_xy = 4;
1994 constexpr
int n_Sintg = 5;
1996 constexpr
int i_B_x = 0;
1997 constexpr
int i_B_y = 1;
1998 constexpr
int i_B_xy = 2;
1999 constexpr
int n_Bintg = 3;
2003 void mlndlap_set_connection (
int i,
int j,
int, Array4<Real>
const& conn,
2004 Array4<Real const>
const& intg, Array4<Real const>
const& vol,
2005 Array4<EBCellFlag const>
const& flag) noexcept
2007 using namespace nodelap_detail;
2009 if (flag(i,j,0).isCovered()) {
2010 for (
int n = 0; n < 6; ++n) { conn(i,j,0,n) = Real(0.); }
2011 }
else if (flag(i,j,0).isRegular() || vol(i,j,0) >=
almostone) {
2012 for (
int n = 0; n < 6; ++n) { conn(i,j,0,n) = Real(1.); }
2016 conn(i,j,0,0) = Real(3.)*(Real(0.25)*vol(i,j,0) + intg(i,j,0,
i_S_y2) - intg(i,j,0,
i_S_y));
2017 conn(i,j,0,1) = Real(6.)*(Real(0.25)*vol(i,j,0) - intg(i,j,0,
i_S_y2));
2018 conn(i,j,0,2) = Real(3.)*(Real(0.25)*vol(i,j,0) + intg(i,j,0,
i_S_y2) + intg(i,j,0,
i_S_y));
2020 conn(i,j,0,3) = Real(3.)*(Real(0.25)*vol(i,j,0) + intg(i,j,0,
i_S_x2) - intg(i,j,0,
i_S_x));
2021 conn(i,j,0,4) = Real(6.)*(Real(0.25)*vol(i,j,0) - intg(i,j,0,
i_S_x2));
2022 conn(i,j,0,5) = Real(3.)*(Real(0.25)*vol(i,j,0) + intg(i,j,0,
i_S_x2) + intg(i,j,0,
i_S_x));
2027 void mlndlap_set_stencil_eb (
int i,
int j,
int, Array4<Real>
const& sten,
2028 Array4<Real const>
const& sig, Array4<Real const>
const& conn,
2029 GpuArray<Real,AMREX_SPACEDIM>
const& dxinv) noexcept
2031 Real facx = Real(1./6.)*dxinv[0]*dxinv[0];
2032 Real facy = Real(1./6.)*dxinv[1]*dxinv[1];
2034 sten(i,j,0,1) = Real(2.)*facx*(sig(i,j-1,0)*conn(i,j-1,0,2)+sig(i,j,0)*conn(i,j,0,0))
2035 -facy*(sig(i,j-1,0)*conn(i,j-1,0,4)+sig(i,j,0)*conn(i,j,0,4));
2036 sten(i,j,0,2) = Real(2.)*facy*(sig(i-1,j,0)*conn(i-1,j,0,5)+sig(i,j,0)*conn(i,j,0,3))
2037 -facx*(sig(i-1,j,0)*conn(i-1,j,0,1)+sig(i,j,0)*conn(i,j,0,1));
2038 sten(i,j,0,3) = (facx*conn(i,j,0,1)+facy*conn(i,j,0,4))*sig(i,j,0);
2043 void mlndlap_divu_eb (
int i,
int j,
int, Array4<Real>
const& rhs, Array4<Real const>
const& vel,
2044 Array4<Real const>
const& vfrac, Array4<Real const>
const& intg,
2045 Array4<int const>
const& msk, GpuArray<Real,AMREX_SPACEDIM>
const& dxinv,
2046 Box const& nodal_domain,
2047 GpuArray<LinOpBCType, AMREX_SPACEDIM>
const& bclo,
2048 GpuArray<LinOpBCType, AMREX_SPACEDIM>
const& bchi) noexcept
2050 Real facx = Real(0.5)*dxinv[0];
2051 Real facy = Real(0.5)*dxinv[1];
2058 Real zero_ilo = Real(1.0);
2059 Real zero_ihi = Real(1.0);
2060 Real zero_jlo = Real(1.0);
2061 Real zero_jhi = Real(1.0);
2065 if ((bclo[0] == LinOpBCType::Neumann || bclo[0] == LinOpBCType::inflow)
2068 zero_ilo = Real(0.0);
2070 if ((bchi[0] == LinOpBCType::Neumann || bchi[0] == LinOpBCType::inflow)
2073 zero_ihi = Real(0.0);
2075 if ((bclo[1] == LinOpBCType::Neumann || bclo[1] == LinOpBCType::inflow)
2078 zero_jlo = Real(0.0);
2080 if ((bchi[1] == LinOpBCType::Neumann || bchi[1] == LinOpBCType::inflow)
2083 zero_jhi = Real(0.0);
2086 rhs(i,j,0) = facx*(-vel(i-1,j-1,0,0)*(vfrac(i-1,j-1,0)+Real(2.)*intg(i-1,j-1,0,1))*zero_jlo
2087 +vel(i ,j-1,0,0)*(vfrac(i ,j-1,0)+Real(2.)*intg(i ,j-1,0,1))*zero_jlo
2088 -vel(i-1,j ,0,0)*(vfrac(i-1,j ,0)-Real(2.)*intg(i-1,j ,0,1))*zero_jhi
2089 +vel(i ,j ,0,0)*(vfrac(i ,j ,0)-Real(2.)*intg(i ,j ,0,1))*zero_jhi)
2090 + facy*(-vel(i-1,j-1,0,1)*(vfrac(i-1,j-1,0)+Real(2.)*intg(i-1,j-1,0,0))*zero_ilo
2091 -vel(i ,j-1,0,1)*(vfrac(i ,j-1,0)-Real(2.)*intg(i ,j-1,0,0))*zero_ihi
2092 +vel(i-1,j ,0,1)*(vfrac(i-1,j ,0)+Real(2.)*intg(i-1,j ,0,0))*zero_ilo
2093 +vel(i ,j ,0,1)*(vfrac(i ,j ,0)-Real(2.)*intg(i ,j ,0,0))*zero_ihi);
2095 rhs(i,j,0) = Real(0.);
2100 void add_eb_flow_contribution (
int i,
int j,
int, Array4<Real>
const& rhs,
2101 Array4<int const>
const& msk, GpuArray<Real,AMREX_SPACEDIM>
const& dxinv,
2102 Array4<Real const>
const& bareaarr,
2103 Array4<Real const>
const& sintg,
2104 Array4<Real const>
const& eb_vel_dot_n) noexcept
2106 using namespace nodelap_detail;
2108 Real fac_eb = 0.25 *dxinv[0];
2111 rhs(i,j,0) += fac_eb*(
2112 eb_vel_dot_n(i-1,j-1,0)*( bareaarr(i-1,j-1,0)
2113 +Real(2.)*sintg(i-1,j-1,0,
i_B_x )
2114 +Real(2.)*sintg(i-1,j-1,0,
i_B_y )
2115 +Real(4.)*sintg(i-1,j-1,0,i_B_xy))
2116 +eb_vel_dot_n(i ,j-1,0)*( bareaarr(i ,j-1,0)
2117 -Real(2.)*sintg(i ,j-1,0,
i_B_x )
2118 +Real(2.)*sintg(i ,j-1,0,
i_B_y )
2119 -Real(4.)*sintg(i ,j-1,0,i_B_xy))
2120 +eb_vel_dot_n(i-1,j ,0)*( bareaarr(i-1,j ,0)
2121 +Real(2.)*sintg(i-1,j ,0,
i_B_x )
2122 -Real(2.)*sintg(i-1,j ,0,
i_B_y )
2123 -Real(4.)*sintg(i-1,j ,0,i_B_xy))
2124 +eb_vel_dot_n(i ,j ,0)*( bareaarr(i ,j ,0)
2125 -Real(2.)*sintg(i ,j ,0,
i_B_x )
2126 -Real(2.)*sintg(i ,j ,0,
i_B_y )
2127 +Real(4.)*sintg(i ,j ,0,i_B_xy)));
2132 void mlndlap_mknewu_eb (
int i,
int j,
int, Array4<Real>
const& u, Array4<Real const>
const& p,
2133 Array4<Real const>
const& sig, Array4<Real const>
const& vfrac,
2134 Array4<Real const>
const& intg, GpuArray<Real,AMREX_SPACEDIM>
const& dxinv) noexcept
2136 Real facx = Real(0.5)*dxinv[0];
2137 Real facy = Real(0.5)*dxinv[1];
2138 if (vfrac(i,j,0) == Real(0.)) {
2139 u(i,j,0,0) = u(i,j,0,1) = Real(0.);
2141 Real dpdx = facx*(-p(i,j,0)+p(i+1,j,0)-p(i,j+1,0)+p(i+1,j+1,0));
2142 Real dpdy = facy*(-p(i,j,0)-p(i+1,j,0)+p(i,j+1,0)+p(i+1,j+1,0));
2143 Real dpp = (p(i,j,0)+p(i+1,j+1,0)-p(i+1,j,0)-p(i,j+1,0))/vfrac(i,j,0);
2144 u(i,j,0,0) -= sig(i,j,0)*(dpdx + dxinv[0]*intg(i,j,0,1)*dpp);
2145 u(i,j,0,1) -= sig(i,j,0)*(dpdy + dxinv[1]*intg(i,j,0,0)*dpp);
2150 void mlndlap_mknewu_eb_c (
int i,
int j,
int, Array4<Real>
const& u, Array4<Real const>
const& p,
2151 Real sig, Array4<Real const>
const& vfrac,
2152 Array4<Real const>
const& intg, GpuArray<Real,AMREX_SPACEDIM>
const& dxinv) noexcept
2154 Real facx = Real(0.5)*dxinv[0];
2155 Real facy = Real(0.5)*dxinv[1];
2156 if (vfrac(i,j,0) == Real(0.)) {
2157 u(i,j,0,0) = u(i,j,0,1) = Real(0.);
2159 Real dpdx = facx*(-p(i,j,0)+p(i+1,j,0)-p(i,j+1,0)+p(i+1,j+1,0));
2160 Real dpdy = facy*(-p(i,j,0)-p(i+1,j,0)+p(i,j+1,0)+p(i+1,j+1,0));
2161 Real dpp = (p(i,j,0)+p(i+1,j+1,0)-p(i+1,j,0)-p(i,j+1,0))/vfrac(i,j,0);
2162 u(i,j,0,0) -= sig*(dpdx + dxinv[0]*intg(i,j,0,1)*dpp);
2163 u(i,j,0,1) -= sig*(dpdy + dxinv[1]*intg(i,j,0,0)*dpp);
2168 Real mlndlap_rhcc_eb (
int i,
int j,
int, Array4<Real const>
const& rhcc,
2169 Array4<Real const>
const& vfrac, Array4<Real const>
const& intg,
2170 Array4<int const>
const& msk) noexcept
2172 using namespace nodelap_detail;
2176 rhcc(i ,j ,0)*(Real(0.25)*vfrac(i ,j ,0)-intg(i ,j ,0,
i_S_x)-intg(i ,j ,0,
i_S_y)+intg(i ,j ,0,i_S_xy)) +
2177 rhcc(i-1,j ,0)*(Real(0.25)*vfrac(i-1,j ,0)+intg(i-1,j ,0,
i_S_x)-intg(i-1,j ,0,
i_S_y)-intg(i-1,j ,0,i_S_xy)) +
2178 rhcc(i-1,j-1,0)*(Real(0.25)*vfrac(i-1,j-1,0)+intg(i-1,j-1,0,
i_S_x)+intg(i-1,j-1,0,
i_S_y)+intg(i-1,j-1,0,i_S_xy)) +
2179 rhcc(i ,j-1,0)*(Real(0.25)*vfrac(i ,j-1,0)-intg(i ,j-1,0,
i_S_x)+intg(i ,j-1,0,
i_S_y)-intg(i ,j-1,0,i_S_xy));
2186 void mlndlap_set_integral (
int i,
int j,
int, Array4<Real>
const& intg) noexcept
2188 using namespace nodelap_detail;
2190 intg(i,j,0,
i_S_x ) = Real(0.);
2191 intg(i,j,0,
i_S_y ) = Real(0.);
2192 intg(i,j,0,
i_S_x2) = Real(1./12.);
2193 intg(i,j,0,
i_S_y2) = Real(1./12.);
2194 intg(i,j,0,i_S_xy) = Real(0.);
2198 void mlndlap_set_surface_integral (
int i,
int j,
int, Array4<Real>
const& sintg) noexcept
2200 using namespace nodelap_detail;
2202 sintg(i,j,0,
i_B_x ) = Real(0.);
2203 sintg(i,j,0,
i_B_y ) = Real(0.);
2204 sintg(i,j,0,i_B_xy) = Real(0.);
2208 void mlndlap_set_integral_eb (
int i,
int j,
int, Array4<Real>
const& intg,
2209 Array4<EBCellFlag const>
const& flag, Array4<Real const>
const& vol,
2210 Array4<Real const>
const& ax, Array4<Real const>
const& ay,
2211 Array4<Real const>
const& bcen) noexcept
2213 using namespace nodelap_detail;
2215 if (flag(i,j,0).isCovered()) {
2216 intg(i,j,0,
i_S_x ) = Real(0.);
2217 intg(i,j,0,
i_S_y ) = Real(0.);
2218 intg(i,j,0,
i_S_x2) = Real(0.);
2219 intg(i,j,0,
i_S_y2) = Real(0.);
2220 intg(i,j,0,i_S_xy) = Real(0.);
2221 }
else if (flag(i,j,0).isRegular() || vol(i,j,0) >=
almostone) {
2222 intg(i,j,0,
i_S_x ) = Real(0.);
2223 intg(i,j,0,
i_S_y ) = Real(0.);
2224 intg(i,j,0,
i_S_x2) = Real(1./12.);
2225 intg(i,j,0,
i_S_y2) = Real(1./12.);
2226 intg(i,j,0,i_S_xy) = Real(0.);
2228 Real axm = ax(i,j,0);
2229 Real axp = ax(i+1,j,0);
2230 Real aym = ay(i,j,0);
2231 Real ayp = ay(i,j+1,0);
2233 Real apnorm =
std::sqrt((axm-axp)*(axm-axp) + (aym-ayp)*(aym-ayp));
2234 if (apnorm == Real(0.)) {
2235 amrex::Abort(
"amrex_mlndlap_set_integral: we are in trouble");
2238 Real apnorminv = Real(1.)/apnorm;
2239 Real anrmx = (axm-axp) * apnorminv;
2240 Real anrmy = (aym-ayp) * apnorminv;
2242 Real bcx = bcen(i,j,0,0);
2243 Real bcy = bcen(i,j,0,1);
2245 Real Sx, Sy, Sx2, Sy2, Sxy;
2248 Sx2 = Real(1./24.)*(axm+axp);
2251 Sx = Real(1./8.) *(axp-axm) + anrmx*Real(0.5)*(bcx*bcx);
2252 Sx2 = Real(1./24.)*(axp+axm) + anrmx*Real(1./3.)*(bcx*bcx*bcx);
2256 if (anrmx > Real(0.)) {
2263 Real xmin3 = xmin*xmin*xmin;
2264 Real xmin4 = xmin3*xmin;
2265 Real xmax3 = xmax*xmax*xmax;
2266 Real xmax4 = xmax3*xmax;
2267 Sx = Real(1./8.) *(axp-axm) + (anrmx/
std::abs(anrmy))*Real(1./6.) *(xmax3-xmin3);
2268 Sx2 = Real(1./24.)*(axp+axm) + (anrmx/
std::abs(anrmy))*Real(1./12.)*(xmax4-xmin4);
2270 Real kk = -anrmx/anrmy;
2271 Real bb = bcy-kk*bcx;
2272 Sxy = Real(1./8.)*kk*kk*(xmax4-xmin4) + Real(1./3.)*kk*bb*(xmax3-xmin3)
2273 + (Real(0.25)*bb*bb-Real(1./16.))*(xmax*xmax-xmin*xmin);
2274 Sxy = std::copysign(Sxy, anrmy);
2279 Sy2 = Real(1./24.)*(aym+ayp);
2281 Sy = Real(1./8.) *(ayp-aym) + anrmy*Real(0.5)*(bcy*bcy);
2282 Sy2 = Real(1./24.)*(ayp+aym) + anrmy*Real(1./3.)*(bcy*bcy*bcy);
2285 if (anrmy > Real(0.)) {
2292 Real ymin3 = ymin*ymin*ymin;
2293 Real ymin4 = ymin3*ymin;
2294 Real ymax3 = ymax*ymax*ymax;
2295 Real ymax4 = ymax3*ymax;
2296 Sy = Real(1./8.) *(ayp-aym) + (anrmy/
std::abs(anrmx))*Real(1./6.) *(ymax3-ymin3);
2297 Sy2 = Real(1./24.)*(ayp+aym) + (anrmy/
std::abs(anrmx))*Real(1./12.)*(ymax4-ymin4);
2300 intg(i,j,0,
i_S_x ) = Sx;
2301 intg(i,j,0,
i_S_y ) = Sy;
2302 intg(i,j,0,
i_S_x2) = Sx2;
2303 intg(i,j,0,
i_S_y2) = Sy2;
2304 intg(i,j,0,i_S_xy) = Sxy;
2309 void mlndlap_set_surface_integral_eb (
int i,
int j,
int, Array4<Real>
const& sintg,
2310 Array4<EBCellFlag const>
const& flag,
2311 Array4<Real const>
const& bcen,
2312 Array4<Real const>
const& barea,
2313 Array4<Real const>
const& bnorm) noexcept
2315 using namespace nodelap_detail;
2317 if (flag(i,j,0).isCovered() || flag(i,j,0).isRegular()) {
2318 sintg(i,j,0,
i_B_x ) = Real(0.);
2319 sintg(i,j,0,
i_B_y ) = Real(0.);
2320 sintg(i,j,0,i_B_xy) = Real(0.);
2322 Real bcx = bcen(i,j,0,0);
2323 Real bcy = bcen(i,j,0,1);
2325 Real btanx = bnorm(i,j,0,1);
2326 Real btany = -bnorm(i,j,0,0);
2328 Real x0 = bcx - Real(0.5)*barea(i,j,0)*btanx;
2329 Real x1 = bcx + Real(0.5)*barea(i,j,0)*btanx;
2331 Real y0 = bcy - Real(0.5)*barea(i,j,0)*btany;
2332 Real y1 = bcy + Real(0.5)*barea(i,j,0)*btany;
2334 Real Bx = barea(i,j,0)*Real(0.5)*(x1 + x0);
2335 Real By = barea(i,j,0)*Real(0.5)*(y1 + y0);
2336 Real Bxy = barea(i,j,0)*(x0*y0 + (x0*(y1 - y0) + y0*(x1 - x0))/Real(2.) + (x1 - x0)*(y1 - y0)/Real(3.));
2338 sintg(i,j,0,
i_B_x ) = Bx;
2339 sintg(i,j,0,
i_B_y ) = By;
2340 sintg(i,j,0,i_B_xy) = Bxy;
2346 #if defined(AMREX_USE_HYPRE)
2348 template <
typename HypreInt,
typename AtomicInt>
2349 void mlndlap_fillijmat_sten_cpu (
Box const& ndbx,
2350 Array4<AtomicInt const>
const& gid,
2351 Array4<int const>
const& lid,
2352 HypreInt* ncols, HypreInt* cols,
2354 Array4<Real const>
const& sten) noexcept
2357 HypreInt nelems = 0;
2360 if (lid(i,j,k) >= 0)
2362 cols[nelems] = gid(i,j,k);
2363 mat[nelems] = sten(i,j,k,0);
2367 if (gid(i-1,j-1,k) < gidmax) {
2368 cols[nelems] = gid(i-1,j-1,k);
2369 mat[nelems] = sten(i-1,j-1,k,3);
2373 if (gid(i,j-1,k) < gidmax) {
2374 cols[nelems] = gid(i,j-1,k);
2375 mat[nelems] = sten(i,j-1,k,2);
2379 if (gid(i+1,j-1,k) < gidmax) {
2380 cols[nelems] = gid(i+1,j-1,k);
2381 mat[nelems] = sten(i ,j-1,k,3);
2385 if (gid(i-1,j,k) < gidmax) {
2386 cols[nelems] = gid(i-1,j,k);
2387 mat[nelems] = sten(i-1,j,k,1);
2391 if (gid(i+1,j,k) < gidmax) {
2392 cols[nelems] = gid(i+1,j,k);
2393 mat[nelems] = sten(i ,j,k,1);
2397 if (gid(i-1,j+1,k) < gidmax) {
2398 cols[nelems] = gid(i-1,j+1,k);
2399 mat[nelems] = sten(i-1,j ,k,3);
2403 if (gid(i,j+1,k) < gidmax) {
2404 cols[nelems] = gid(i,j+1,k);
2405 mat[nelems] = sten(i,j ,k,2);
2409 if (gid(i+1,j+1,k) < gidmax) {
2410 cols[nelems] = gid(i+1,j+1,k);
2411 mat[nelems] = sten(i ,j ,k,3);
2415 ncols[lid(i,j,k)] = nelems - nelems_old;
2420 template <
typename HypreInt,
typename AtomicInt>
2421 void mlndlap_fillijmat_aa_cpu (
Box const& ndbx,
2422 Array4<AtomicInt const>
const& gid,
2423 Array4<int const>
const& lid,
2424 HypreInt* ncols, HypreInt* cols,
2426 Array4<Real const>
const& sig,
2427 GpuArray<Real,AMREX_SPACEDIM>
const& dxinv,
2428 Box const& ccdom,
bool is_rz) noexcept
2430 Real facx = Real(1.0/6.0)*dxinv[0]*dxinv[0];
2431 Real facy = Real(1.0/6.0)*dxinv[1]*dxinv[1];
2432 Real fxy = facx + facy;
2433 Real f2xmy = Real(2.0)*facx - facy;
2434 Real fmx2y = Real(2.0)*facy - facx;
2440 HypreInt nelems = 0;
2443 if (lid(i,j,k) >= 0)
2447 fp = facy /
static_cast<Real
>(2*i+1);
2448 fm = facy /
static_cast<Real
>(2*i-1);
2450 fp = fm = Real(0.0);
2453 HypreInt nelems_old = nelems;
2454 cols[nelems_old] = gid(i,j,k);
2458 if (nddom.contains(i-1,j-1,k)) {
2459 Real tmp = fxy*sig(i-1,j-1,k);
2461 if ( gid(i-1,j-1,k) < gidmax) {
2462 cols[nelems] = gid(i-1,j-1,k);
2468 if (nddom.contains(i,j-1,k)) {
2469 Real tmp = Real(0.0);
2470 if ( ccdom.contains(i-1,j-1,k)) {
2471 tmp += sig(i-1,j-1,k) * (fmx2y + fm);
2473 if ( ccdom.contains(i,j-1,k)) {
2474 tmp += sig(i,j-1,k) * (fmx2y - fp);
2477 if (gid(i,j-1,k) < gidmax) {
2478 cols[nelems] = gid(i,j-1,k);
2484 if (nddom.contains(i+1,j-1,k)) {
2485 Real tmp = fxy*sig(i ,j-1,k);
2487 if (gid(i+1,j-1,k) < gidmax) {
2488 cols[nelems] = gid(i+1,j-1,k);
2494 if (nddom.contains(i-1,j,k)) {
2495 Real tmp = Real(0.0);
2496 if ( ccdom.contains(i-1,j-1,k)) {
2497 tmp += f2xmy*sig(i-1,j-1,k);
2499 if ( ccdom.contains(i-1,j,k)) {
2500 tmp += f2xmy*sig(i-1,j,k);
2503 if (gid(i-1,j,k) < gidmax) {
2504 cols[nelems] = gid(i-1,j,k);
2510 if (nddom.contains(i+1,j,k)) {
2511 Real tmp = Real(0.0);
2512 if ( ccdom.contains(i ,j-1,k)) {
2513 tmp += f2xmy*sig(i ,j-1,k);
2515 if ( ccdom.contains(i ,j,k)) {
2516 tmp += f2xmy*sig(i ,j,k);
2519 if (gid(i+1,j,k) < gidmax) {
2520 cols[nelems] = gid(i+1,j,k);
2526 if (nddom.contains(i-1,j+1,k)) {
2527 Real tmp = fxy*sig(i-1,j ,k);
2529 if (gid(i-1,j+1,k) < gidmax) {
2530 cols[nelems] = gid(i-1,j+1,k);
2536 if (nddom.contains(i,j+1,k)) {
2537 Real tmp = Real(0.0);
2538 if ( ccdom.contains(i-1,j ,k)) {
2539 tmp += sig(i-1,j ,k) * (fmx2y + fm);
2541 if ( ccdom.contains(i,j ,k)) {
2542 tmp += sig(i,j ,k) * (fmx2y - fp);
2545 if (gid(i,j+1,k) < gidmax) {
2546 cols[nelems] = gid(i,j+1,k);
2552 if (nddom.contains(i+1,j+1,k)) {
2553 Real tmp = fxy*sig(i ,j ,k);
2555 if (gid(i+1,j+1,k) < gidmax) {
2556 cols[nelems] = gid(i+1,j+1,k);
2562 mat[nelems_old] = m0;
2563 ncols[lid(i,j,k)] = nelems - nelems_old;
2568 template <
typename HypreInt,
typename AtomicInt>
2569 void mlndlap_fillijmat_ha_cpu (
Box const& ndbx,
2570 Array4<AtomicInt const>
const& gid,
2571 Array4<int const>
const& lid,
2572 HypreInt* ncols, HypreInt* cols,
2574 Array4<Real const>
const& sx,
2575 Array4<Real const>
const& sy,
2576 GpuArray<Real,AMREX_SPACEDIM>
const& dxinv,
2577 Box const& ccdom,
bool is_rz) noexcept
2579 Real facx = Real(1.0/6.0)*dxinv[0]*dxinv[0];
2580 Real facy = Real(1.0/6.0)*dxinv[1]*dxinv[1];
2586 HypreInt nelems = 0;
2589 if (lid(i,j,k) >= 0)
2593 fp = facy /
static_cast<Real
>(2*i+1);
2594 fm = facy /
static_cast<Real
>(2*i-1);
2596 fp = fm = Real(0.0);
2599 HypreInt nelems_old = nelems;
2600 cols[nelems_old] = gid(i,j,k);
2604 if (nddom.contains(i-1,j-1,k)) {
2605 Real tmp = facx*sx(i-1,j-1,k) + facy*sy(i-1,j-1,k);
2607 if ( gid(i-1,j-1,k) < gidmax) {
2608 cols[nelems] = gid(i-1,j-1,k);
2614 if (nddom.contains(i,j-1,k)) {
2615 Real tmp = Real(0.0);
2616 if ( ccdom.contains(i-1,j-1,k)) {
2617 tmp += sy(i-1,j-1,k) * (facy * Real(2.0) + fm)
2618 - sx(i-1,j-1,k) * facx;
2620 if ( ccdom.contains(i,j-1,k)) {
2621 tmp += sy(i,j-1,k) * (facy * Real(2.0) - fp)
2622 - sx(i,j-1,k) * facx;
2625 if (gid(i,j-1,k) < gidmax) {
2626 cols[nelems] = gid(i,j-1,k);
2632 if (nddom.contains(i+1,j-1,k)) {
2633 Real tmp = facx*sx(i ,j-1,k) + facy*sy(i ,j-1,k);
2635 if (gid(i+1,j-1,k) < gidmax) {
2636 cols[nelems] = gid(i+1,j-1,k);
2642 if (nddom.contains(i-1,j,k)) {
2643 Real tmp = Real(0.0);
2644 if ( ccdom.contains(i-1,j-1,k)) {
2645 tmp += sx(i-1,j-1,k) * facx*Real(2.0)
2646 - sy(i-1,j-1,k) * facy;
2648 if ( ccdom.contains(i-1,j,k)) {
2649 tmp += sx(i-1,j,k) * facx*Real(2.0)
2650 - sy(i-1,j,k) * facy;
2653 if (gid(i-1,j,k) < gidmax) {
2654 cols[nelems] = gid(i-1,j,k);
2660 if (nddom.contains(i+1,j,k)) {
2661 Real tmp = Real(0.0);
2662 if ( ccdom.contains(i ,j-1,k)) {
2663 tmp += sx(i ,j-1,k) * facx*Real(2.0)
2664 - sy(i ,j-1,k) * facy;
2666 if ( ccdom.contains(i ,j,k)) {
2667 tmp += sx(i ,j,k) * facx*Real(2.0)
2668 - sy(i ,j,k) * facy;
2671 if (gid(i+1,j,k) < gidmax) {
2672 cols[nelems] = gid(i+1,j,k);
2678 if (nddom.contains(i-1,j+1,k)) {
2679 Real tmp = facx*sx(i-1,j ,k) + facy*sy(i-1,j ,k);
2681 if (gid(i-1,j+1,k) < gidmax) {
2682 cols[nelems] = gid(i-1,j+1,k);
2688 if (nddom.contains(i,j+1,k)) {
2689 Real tmp = Real(0.0);
2690 if ( ccdom.contains(i-1,j ,k)) {
2691 tmp += sy(i-1,j ,k) * (facy*Real(2.0) + fm)
2692 - sx(i-1,j ,k) * facx;
2694 if ( ccdom.contains(i,j ,k)) {
2695 tmp += sy(i,j ,k) * (facy*Real(2.0) - fp)
2696 - sx(i,j ,k) * facx;
2699 if (gid(i,j+1,k) < gidmax) {
2700 cols[nelems] = gid(i,j+1,k);
2706 if (nddom.contains(i+1,j+1,k)) {
2707 Real tmp = facx*sx(i ,j ,k) + facy*sy(i ,j ,k);
2709 if (gid(i+1,j+1,k) < gidmax) {
2710 cols[nelems] = gid(i+1,j+1,k);
2716 mat[nelems_old] = m0;
2717 ncols[lid(i,j,k)] = nelems - nelems_old;
2722 template <
typename HypreInt,
typename AtomicInt>
2723 void mlndlap_fillijmat_cs_cpu (
Box const& ndbx,
2724 Array4<AtomicInt const>
const& gid,
2725 Array4<int const>
const& lid,
2726 HypreInt* ncols, HypreInt* cols,
2729 GpuArray<Real,AMREX_SPACEDIM>
const& dxinv,
2730 Box const& ccdom,
bool is_rz) noexcept
2732 Real facx = Real(1.0/6.0)*dxinv[0]*dxinv[0] * sig;
2733 Real facy = Real(1.0/6.0)*dxinv[1]*dxinv[1] * sig;
2734 Real fxy = facx + facy;
2735 Real f2xmy = Real(2.0)*facx - facy;
2736 Real fmx2y = Real(2.0)*facy - facx;
2742 HypreInt nelems = 0;
2745 if (lid(i,j,k) >= 0)
2749 fp = facy /
static_cast<Real
>(2*i+1);
2750 fm = facy /
static_cast<Real
>(2*i-1);
2752 fp = fm = Real(0.0);
2755 HypreInt nelems_old = nelems;
2756 cols[nelems_old] = gid(i,j,k);
2760 if (nddom.contains(i-1,j-1,k)) {
2763 if ( gid(i-1,j-1,k) < gidmax) {
2764 cols[nelems] = gid(i-1,j-1,k);
2770 if (nddom.contains(i,j-1,k)) {
2771 Real tmp = Real(0.0);
2772 if ( ccdom.contains(i-1,j-1,k)) {
2775 if ( ccdom.contains(i,j-1,k)) {
2779 if (gid(i,j-1,k) < gidmax) {
2780 cols[nelems] = gid(i,j-1,k);
2786 if (nddom.contains(i+1,j-1,k)) {
2789 if (gid(i+1,j-1,k) < gidmax) {
2790 cols[nelems] = gid(i+1,j-1,k);
2796 if (nddom.contains(i-1,j,k)) {
2797 Real tmp = Real(0.0);
2798 if ( ccdom.contains(i-1,j-1,k)) {
2801 if ( ccdom.contains(i-1,j,k)) {
2805 if (gid(i-1,j,k) < gidmax) {
2806 cols[nelems] = gid(i-1,j,k);
2812 if (nddom.contains(i+1,j,k)) {
2813 Real tmp = Real(0.0);
2814 if ( ccdom.contains(i ,j-1,k)) {
2817 if ( ccdom.contains(i ,j,k)) {
2821 if (gid(i+1,j,k) < gidmax) {
2822 cols[nelems] = gid(i+1,j,k);
2828 if (nddom.contains(i-1,j+1,k)) {
2831 if (gid(i-1,j+1,k) < gidmax) {
2832 cols[nelems] = gid(i-1,j+1,k);
2838 if (nddom.contains(i,j+1,k)) {
2839 Real tmp = Real(0.0);
2840 if ( ccdom.contains(i-1,j ,k)) {
2843 if ( ccdom.contains(i,j ,k)) {
2847 if (gid(i,j+1,k) < gidmax) {
2848 cols[nelems] = gid(i,j+1,k);
2854 if (nddom.contains(i+1,j+1,k)) {
2857 if (gid(i+1,j+1,k) < gidmax) {
2858 cols[nelems] = gid(i+1,j+1,k);
2864 mat[nelems_old] = m0;
2865 ncols[lid(i,j,k)] = nelems - nelems_old;
2870 #ifdef AMREX_USE_GPU
2872 template <
typename HypreInt,
typename AtomicInt>
2874 void mlndlap_fillijmat_sten_gpu (
const int ps,
const int i,
const int j,
const int k,
2876 Array4<AtomicInt const>
const& gid,
2877 Array4<int const>
const& lid,
2878 HypreInt* ncols, HypreInt* cols,
2880 Array4<Real const>
const& sten) noexcept
2882 if (lid(i,j,k) >= 0)
2888 if (gid(i-1,j-1,k) < gidmax) {
2890 cols[ps] = gid(i-1,j-1,k);
2891 mat[ps] = sten(i-1,j-1,k,3);
2895 if (
offset != 0) {
return; }
2899 if (gid(i,j-1,k) < gidmax) {
2901 cols[ps] = gid(i,j-1,k);
2902 mat[ps] = sten(i,j-1,k,2);
2906 if (
offset != 0) {
return; }
2910 if (gid(i+1,j-1,k) < gidmax) {
2912 cols[ps] = gid(i+1,j-1,k);
2913 mat[ps] = sten(i ,j-1,k,3);
2917 if (
offset != 0) {
return; }
2921 if (gid(i-1,j,k) < gidmax) {
2923 cols[ps] = gid(i-1,j,k);
2924 mat[ps] = sten(i-1,j,k,1);
2928 if (
offset != 0) {
return; }
2932 if (gid(i+1,j,k) < gidmax) {
2934 cols[ps] = gid(i+1,j,k);
2935 mat[ps] = sten(i ,j,k,1);
2939 if (
offset != 0) {
return; }
2943 if (gid(i-1,j+1,k) < gidmax) {
2945 cols[ps] = gid(i-1,j+1,k);
2946 mat[ps] = sten(i-1,j ,k,3);
2950 if (
offset != 0) {
return; }
2954 if (gid(i,j+1,k) < gidmax) {
2956 cols[ps] = gid(i,j+1,k);
2957 mat[ps] = sten(i,j ,k,2);
2961 if (
offset != 0) {
return; }
2965 if (gid(i+1,j+1,k) < gidmax) {
2967 cols[ps] = gid(i+1,j+1,k);
2968 mat[ps] = sten(i ,j ,k,3);
2972 if (
offset != 0) {
return; }
2976 cols[ps] = gid(i,j,k);
2977 mat[ps] = sten(i,j,k,0);
2978 ncols[lid(i,j,k)] = nelems+1;
2982 template <
typename HypreInt,
typename AtomicInt>
2984 void mlndlap_fillijmat_aa_gpu (
const int ps,
const int i,
const int j,
const int k,
2986 Box const& ndbx, Array4<AtomicInt const>
const& gid,
2987 Array4<int const>
const& lid,
2988 HypreInt* ncols, HypreInt* cols,
2990 Array4<Real const>
const& sig,
2991 GpuArray<Real,AMREX_SPACEDIM>
const& dxinv,
2992 Box const& ccdom,
bool is_rz) noexcept
2994 if (lid(i,j,k) >= 0)
2996 Real facx = Real(1.0/6.0)*dxinv[0]*dxinv[0];
2997 Real facy = Real(1.0/6.0)*dxinv[1]*dxinv[1];
2998 Real fxy = facx + facy;
2999 Real f2xmy = Real(2.0)*facx - facy;
3000 Real fmx2y = Real(2.0)*facy - facx;
3004 fp = facy /
static_cast<Real
>(2*i+1);
3005 fm = facy /
static_cast<Real
>(2*i-1);
3007 fp = fm = Real(0.0);
3017 if (nddom.contains(i-1,j-1,k)) {
3018 Real tmp = fxy*sig(i-1,j-1,k);
3020 if (gid(i-1,j-1,k) < gidmax) {
3022 cols[ps] = gid(i-1,j-1,k);
3028 if (
offset != 0) {
return; }
3032 if (nddom.contains(i,j-1,k)) {
3033 Real tmp = Real(0.0);
3034 if ( ccdom.contains(i-1,j-1,k)) {
3035 tmp += sig(i-1,j-1,k) * (fmx2y + fm);
3037 if ( ccdom.contains(i,j-1,k)) {
3038 tmp += sig(i,j-1,k) * (fmx2y - fp);
3041 if (gid(i,j-1,k) < gidmax) {
3043 cols[ps] = gid(i,j-1,k);
3049 if (
offset != 0) {
return; }
3053 if (nddom.contains(i+1,j-1,k)) {
3054 Real tmp = fxy*sig(i ,j-1,k);
3056 if (gid(i+1,j-1,k) < gidmax) {
3058 cols[ps] = gid(i+1,j-1,k);
3064 if (
offset != 0) {
return; }
3068 if (nddom.contains(i-1,j,k)) {
3069 Real tmp = Real(0.0);
3070 if ( ccdom.contains(i-1,j-1,k)) {
3071 tmp += f2xmy*sig(i-1,j-1,k);
3073 if ( ccdom.contains(i-1,j,k)) {
3074 tmp += f2xmy*sig(i-1,j,k);
3077 if (gid(i-1,j,k) < gidmax) {
3079 cols[ps] = gid(i-1,j,k);
3085 if (
offset != 0) {
return; }
3089 if (nddom.contains(i+1,j,k)) {
3090 Real tmp = Real(0.0);
3091 if ( ccdom.contains(i ,j-1,k)) {
3092 tmp += f2xmy*sig(i ,j-1,k);
3094 if ( ccdom.contains(i ,j,k)) {
3095 tmp += f2xmy*sig(i ,j,k);
3098 if (gid(i+1,j,k) < gidmax) {
3100 cols[ps] = gid(i+1,j,k);
3106 if (
offset != 0) {
return; }
3110 if (nddom.contains(i-1,j+1,k)) {
3111 Real tmp = fxy*sig(i-1,j ,k);
3113 if (gid(i-1,j+1,k) < gidmax) {
3115 cols[ps] = gid(i-1,j+1,k);
3121 if (
offset != 0) {
return; }
3125 if (nddom.contains(i,j+1,k)) {
3126 Real tmp = Real(0.0);
3127 if ( ccdom.contains(i-1,j ,k)) {
3128 tmp += sig(i-1,j ,k) * (fmx2y + fm);
3130 if ( ccdom.contains(i,j ,k)) {
3131 tmp += sig(i,j ,k) * (fmx2y - fp);
3134 if (gid(i,j+1,k) < gidmax) {
3136 cols[ps] = gid(i,j+1,k);
3142 if (
offset != 0) {
return; }
3146 if (nddom.contains(i+1,j+1,k)) {
3147 Real tmp = fxy*sig(i ,j ,k);
3149 if (gid(i+1,j+1,k) < gidmax) {
3151 cols[ps] = gid(i+1,j+1,k);
3157 if (
offset != 0) {
return; }
3161 cols[ps] = gid(i,j,k);
3163 ncols[lid(i,j,k)] = nelems+1;
3167 template <
typename HypreInt,
typename AtomicInt>
3169 void mlndlap_fillijmat_ha_gpu (
const int ps,
const int i,
const int j,
const int k,
3171 Box const& ndbx, Array4<AtomicInt const>
const& gid,
3172 Array4<int const>
const& lid,
3173 HypreInt* ncols, HypreInt* cols,
3175 Array4<Real const>
const& sx,
3176 Array4<Real const>
const& sy,
3177 GpuArray<Real,AMREX_SPACEDIM>
const& dxinv,
3178 Box const& ccdom,
bool is_rz) noexcept
3180 if (lid(i,j,k) >= 0)
3182 Real facx = Real(1.0/6.0)*dxinv[0]*dxinv[0];
3183 Real facy = Real(1.0/6.0)*dxinv[1]*dxinv[1];
3187 fp = facy /
static_cast<Real
>(2*i+1);
3188 fm = facy /
static_cast<Real
>(2*i-1);
3190 fp = fm = Real(0.0);
3200 if (nddom.contains(i-1,j-1,k)) {
3201 Real tmp = facx*sx(i-1,j-1,k) + facy*sy(i-1,j-1,k);
3203 if ( gid(i-1,j-1,k) < gidmax) {
3205 cols[ps] = gid(i-1,j-1,k);
3211 if (
offset != 0) {
return; }
3215 if (nddom.contains(i,j-1,k)) {
3216 Real tmp = Real(0.0);
3217 if ( ccdom.contains(i-1,j-1,k)) {
3218 tmp += sy(i-1,j-1,k) * (facy * Real(2.0) + fm)
3219 - sx(i-1,j-1,k) * facx;
3221 if ( ccdom.contains(i,j-1,k)) {
3222 tmp += sy(i,j-1,k) * (facy * Real(2.0) - fp)
3223 - sx(i,j-1,k) * facx;
3226 if (gid(i,j-1,k) < gidmax) {
3228 cols[ps] = gid(i,j-1,k);
3234 if (
offset != 0) {
return; }
3238 if (nddom.contains(i+1,j-1,k)) {
3239 Real tmp = facx*sx(i ,j-1,k) + facy*sy(i ,j-1,k);
3241 if (gid(i+1,j-1,k) < gidmax) {
3243 cols[ps] = gid(i+1,j-1,k);
3249 if (
offset != 0) {
return; }
3253 if (nddom.contains(i-1,j,k)) {
3254 Real tmp = Real(0.0);
3255 if ( ccdom.contains(i-1,j-1,k)) {
3256 tmp += sx(i-1,j-1,k) * facx*Real(2.0)
3257 - sy(i-1,j-1,k) * facy;
3259 if ( ccdom.contains(i-1,j,k)) {
3260 tmp += sx(i-1,j,k) * facx*Real(2.0)
3261 - sy(i-1,j,k) * facy;
3264 if (gid(i-1,j,k) < gidmax) {
3266 cols[ps] = gid(i-1,j,k);
3272 if (
offset != 0) {
return; }
3276 if (nddom.contains(i+1,j,k)) {
3277 Real tmp = Real(0.0);
3278 if ( ccdom.contains(i ,j-1,k)) {
3279 tmp += sx(i ,j-1,k) * facx*Real(2.0)
3280 - sy(i ,j-1,k) * facy;
3282 if ( ccdom.contains(i ,j,k)) {
3283 tmp += sx(i ,j,k) * facx*Real(2.0)
3284 - sy(i ,j,k) * facy;
3287 if (gid(i+1,j,k) < gidmax) {
3289 cols[ps] = gid(i+1,j,k);
3295 if (
offset != 0) {
return; }
3299 if (nddom.contains(i-1,j+1,k)) {
3300 Real tmp = facx*sx(i-1,j ,k) + facy*sy(i-1,j ,k);
3302 if (gid(i-1,j+1,k) < gidmax) {
3304 cols[ps] = gid(i-1,j+1,k);
3310 if (
offset != 0) {
return; }
3314 if (nddom.contains(i,j+1,k)) {
3315 Real tmp = Real(0.0);
3316 if ( ccdom.contains(i-1,j ,k)) {
3317 tmp += sy(i-1,j ,k) * (facy*Real(2.0) + fm)
3318 - sx(i-1,j ,k) * facx;
3320 if ( ccdom.contains(i,j ,k)) {
3321 tmp += sy(i,j ,k) * (facy*Real(2.0) - fp)
3322 - sx(i,j ,k) * facx;
3325 if (gid(i,j+1,k) < gidmax) {
3327 cols[ps] = gid(i,j+1,k);
3333 if (
offset != 0) {
return; }
3337 if (nddom.contains(i+1,j+1,k)) {
3338 Real tmp = facx*sx(i ,j ,k) + facy*sy(i ,j ,k);
3340 if (gid(i+1,j+1,k) < gidmax) {
3342 cols[ps] = gid(i+1,j+1,k);
3348 if (
offset != 0) {
return; }
3352 cols[ps] = gid(i,j,k);
3354 ncols[lid(i,j,k)] = nelems+1;
3358 template <
typename HypreInt,
typename AtomicInt>
3360 void mlndlap_fillijmat_cs_gpu (
const int ps,
const int i,
const int j,
const int k,
3362 Box const& ndbx, Array4<AtomicInt const>
const& gid,
3363 Array4<int const>
const& lid,
3364 HypreInt* ncols, HypreInt* cols,
3366 Real sig, GpuArray<Real,AMREX_SPACEDIM>
const& dxinv,
3367 Box const& ccdom,
bool is_rz) noexcept
3369 if (lid(i,j,k) >= 0)
3371 Real facx = Real(1.0/6.0)*dxinv[0]*dxinv[0] * sig;
3372 Real facy = Real(1.0/6.0)*dxinv[1]*dxinv[1] * sig;
3373 Real fxy = facx + facy;
3374 Real f2xmy = Real(2.0)*facx - facy;
3375 Real fmx2y = Real(2.0)*facy - facx;
3379 fp = facy /
static_cast<Real
>(2*i+1);
3380 fm = facy /
static_cast<Real
>(2*i-1);
3382 fp = fm = Real(0.0);
3393 if (nddom.contains(i-1,j-1,k)) {
3396 if ( gid(i-1,j-1,k) < gidmax) {
3398 cols[ps] = gid(i-1,j-1,k);
3404 if (
offset != 0) {
return; }
3408 if (nddom.contains(i,j-1,k)) {
3409 Real tmp = Real(0.0);
3410 if ( ccdom.contains(i-1,j-1,k)) {
3413 if ( ccdom.contains(i,j-1,k)) {
3417 if (gid(i,j-1,k) < gidmax) {
3419 cols[ps] = gid(i,j-1,k);
3425 if (
offset != 0) {
return; }
3429 if (nddom.contains(i+1,j-1,k)) {
3432 if (gid(i+1,j-1,k) < gidmax) {
3434 cols[ps] = gid(i+1,j-1,k);
3440 if (
offset != 0) {
return; }
3444 if (nddom.contains(i-1,j,k)) {
3445 Real tmp = Real(0.0);
3446 if ( ccdom.contains(i-1,j-1,k)) {
3449 if ( ccdom.contains(i-1,j,k)) {
3453 if (gid(i-1,j,k) < gidmax) {
3455 cols[ps] = gid(i-1,j,k);
3461 if (
offset != 0) {
return; }
3465 if (nddom.contains(i+1,j,k)) {
3466 Real tmp = Real(0.0);
3467 if ( ccdom.contains(i ,j-1,k)) {
3470 if ( ccdom.contains(i ,j,k)) {
3474 if (gid(i+1,j,k) < gidmax) {
3476 cols[ps] = gid(i+1,j,k);
3482 if (
offset != 0) {
return; }
3486 if (nddom.contains(i-1,j+1,k)) {
3489 if (gid(i-1,j+1,k) < gidmax) {
3491 cols[ps] = gid(i-1,j+1,k);
3497 if (
offset != 0) {
return; }
3501 if (nddom.contains(i,j+1,k)) {
3502 Real tmp = Real(0.0);
3503 if ( ccdom.contains(i-1,j ,k)) {
3506 if ( ccdom.contains(i,j ,k)) {
3510 if (gid(i,j+1,k) < gidmax) {
3512 cols[ps] = gid(i,j+1,k);
3518 if (
offset != 0) {
return; }
3522 if (nddom.contains(i+1,j+1,k)) {
3525 if (gid(i+1,j+1,k) < gidmax) {
3527 cols[ps] = gid(i+1,j+1,k);
3533 if (
offset != 0) {
return; }
3537 cols[ps] = gid(i,j,k);
3539 ncols[lid(i,j,k)] = nelems+1;
3550 return (i%2) + (j%2)*2;
3558 bool is_rz) noexcept
3562 sol(i,j,k) = Real(0.0);
3564 Real facx = Real(1.0/6.0)*dxinv[0]*dxinv[0];
3565 Real facy = Real(1.0/6.0)*dxinv[1]*dxinv[1];
3567 Real s0 = Real(-2.0)*(facx*(sx(i-1,j-1,k)+sx(i,j-1,k)+sx(i-1,j,k)+sx(i,j,k))
3568 +facy*(sy(i-1,j-1,k)+sy(i,j-1,k)+sy(i-1,j,k)+sy(i,j,k)));
3570 Real Ax = sol(i-1,j-1,k)*(facx*sx(i-1,j-1,k)+facy*sy(i-1,j-1,k))
3571 + sol(i+1,j-1,k)*(facx*sx(i ,j-1,k)+facy*sy(i ,j-1,k))
3572 + sol(i-1,j+1,k)*(facx*sx(i-1,j ,k)+facy*sy(i-1,j ,k))
3573 + sol(i+1,j+1,k)*(facx*sx(i ,j ,k)+facy*sy(i ,j ,k))
3574 + sol(i-1,j,k)*(Real(2.0)*facx*(sx(i-1,j-1,k)+sx(i-1,j,k))
3575 - facy*(sy(i-1,j-1,k)+sy(i-1,j,k)))
3576 + sol(i+1,j,k)*(Real(2.0)*facx*(sx(i ,j-1,k)+sx(i ,j,k))
3577 - facy*(sy(i ,j-1,k)+sy(i ,j,k)))
3578 + sol(i,j-1,k)*( -facx*(sx(i-1,j-1,k)+sx(i,j-1,k))
3579 +Real(2.0)*facy*(sy(i-1,j-1,k)+sy(i,j-1,k)))
3580 + sol(i,j+1,k)*( -facx*(sx(i-1,j ,k)+sx(i,j ,k))
3581 +Real(2.0)*facy*(sy(i-1,j ,k)+sy(i,j ,k)))
3585 Real fp = facy /
static_cast<Real
>(2*i+1);
3586 Real fm = facy /
static_cast<Real
>(2*i-1);
3587 Real frzlo = fm*sy(i-1,j-1,k)-fp*sy(i,j-1,k);
3588 Real frzhi = fm*sy(i-1,j ,k)-fp*sy(i,j ,k);
3589 s0 += - frzhi - frzlo;
3590 Ax += frzhi*(sol(i,j+1,k)-sol(i,j,k))
3591 + frzlo*(sol(i,j-1,k)-sol(i,j,k));
3594 sol(i,j,k) += (rhs(i,j,k) - Ax) / s0;
3604 bool is_rz) noexcept
3608 sol(i,j,k) = Real(0.0);
3610 Real facx = Real(1.0/6.0)*dxinv[0]*dxinv[0];
3611 Real facy = Real(1.0/6.0)*dxinv[1]*dxinv[1];
3612 Real fxy = facx + facy;
3613 Real f2xmy = Real(2.0)*facx - facy;
3614 Real fmx2y = Real(2.0)*facy - facx;
3616 Real s0 = (-Real(2.0))*fxy*(sig(i-1,j-1,k)+sig(i,j-1,k)+sig(i-1,j,k)+sig(i,j,k));
3617 Real Ax = sol(i-1,j-1,k)*fxy*sig(i-1,j-1,k)
3618 + sol(i+1,j-1,k)*fxy*sig(i ,j-1,k)
3619 + sol(i-1,j+1,k)*fxy*sig(i-1,j ,k)
3620 + sol(i+1,j+1,k)*fxy*sig(i ,j ,k)
3621 + sol(i-1,j,k)*f2xmy*(sig(i-1,j-1,k)+sig(i-1,j,k))
3622 + sol(i+1,j,k)*f2xmy*(sig(i ,j-1,k)+sig(i ,j,k))
3623 + sol(i,j-1,k)*fmx2y*(sig(i-1,j-1,k)+sig(i,j-1,k))
3624 + sol(i,j+1,k)*fmx2y*(sig(i-1,j ,k)+sig(i,j ,k))
3628 Real fp = facy /
static_cast<Real
>(2*i+1);
3629 Real fm = facy /
static_cast<Real
>(2*i-1);
3630 Real frzlo = fm*sig(i-1,j-1,k)-fp*sig(i,j-1,k);
3631 Real frzhi = fm*sig(i-1,j ,k)-fp*sig(i,j ,k);
3632 s0 += - frzhi - frzlo;
3633 Ax += frzhi*(sol(i,j+1,k)-sol(i,j,k))
3634 + frzlo*(sol(i,j-1,k)-sol(i,j,k));
3637 sol(i,j,k) += (rhs(i,j,k) - Ax) / s0;
3647 bool is_rz) noexcept
3651 sol(i,j,k) = Real(0.0);
3653 Real facx = Real(1.0/6.0)*dxinv[0]*dxinv[0];
3654 Real facy = Real(1.0/6.0)*dxinv[1]*dxinv[1];
3655 Real fxy = facx + facy;
3656 Real f2xmy = Real(2.0)*facx - facy;
3657 Real fmx2y = Real(2.0)*facy - facx;
3659 Real s0 = (-Real(2.0))*fxy*Real(4.);
3660 Real Ax = sol(i-1,j-1,k)*fxy
3661 + sol(i+1,j-1,k)*fxy
3662 + sol(i-1,j+1,k)*fxy
3663 + sol(i+1,j+1,k)*fxy
3664 + sol(i-1,j,k)*f2xmy*Real(2.)
3665 + sol(i+1,j,k)*f2xmy*Real(2.)
3666 + sol(i,j-1,k)*fmx2y*Real(2.)
3667 + sol(i,j+1,k)*fmx2y*Real(2.)
3671 Real fp = facy /
static_cast<Real
>(2*i+1);
3672 Real fm = facy /
static_cast<Real
>(2*i-1);
3675 s0 += - frzhi - frzlo;
3676 Ax += frzhi*(sol(i,j+1,k)-sol(i,j,k))
3677 + frzlo*(sol(i,j-1,k)-sol(i,j,k));
3680 sol(i,j,k) += (rhs(i,j,k) - Ax*sig) / (s0*sig);
3687 Array4<Real const>
const& rhs,
3688 Array4<Real const>
const& sten,
3689 Array4<int const>
const& msk,
int color) noexcept
#define AMREX_PRAGMA_SIMD
Definition: AMReX_Extension.H:80
#define AMREX_FORCE_INLINE
Definition: AMReX_Extension.H:119
#define AMREX_HOST_DEVICE_FOR_3D(...)
Definition: AMReX_GpuLaunch.nolint.H:50
#define AMREX_GPU_DEVICE
Definition: AMReX_GpuQualifiers.H:18
#define AMREX_GPU_HOST_DEVICE
Definition: AMReX_GpuQualifiers.H:20
int idir
Definition: AMReX_HypreMLABecLap.cpp:1093
Array4< int const > offset
Definition: AMReX_HypreMLABecLap.cpp:1089
Array4< Real > fine
Definition: AMReX_InterpFaceRegister.cpp:90
Array4< Real const > crse
Definition: AMReX_InterpFaceRegister.cpp:92
#define AMREX_LOOP_3D(bx, i, j, k, block)
Definition: AMReX_Loop.nolint.H:4
if(!(yy_init))
Definition: amrex_iparser.lex.nolint.H:935
AMREX_GPU_HOST_DEVICE BoxND & growHi(int idir, int n_cell=1) noexcept
Grow the BoxND on the high end by n_cell cells in direction idir. NOTE: n_cell negative shrinks the B...
Definition: AMReX_Box.H:659
AMREX_GPU_HOST_DEVICE BoxND & growLo(int idir, int n_cell=1) noexcept
Grow the BoxND on the low end by n_cell cells in direction idir. NOTE: n_cell negative shrinks the Bo...
Definition: AMReX_Box.H:648
HYPRE_Int Int
Definition: AMReX_HypreNodeLap.H:36
#define abs(x)
Definition: complex-type.h:85
static int f(amrex::Real t, N_Vector y_data, N_Vector y_rhs, void *user_data)
Definition: AMReX_SundialsIntegrator.H:44
static constexpr int i_S_x2
Definition: AMReX_algoim.H:15
static constexpr int i_S_y
Definition: AMReX_algoim.H:13
static constexpr int i_S_x
Definition: AMReX_algoim.H:12
static constexpr int i_B_x
Definition: AMReX_algoim.H:36
static constexpr int i_B_y
Definition: AMReX_algoim.H:37
static constexpr int i_S_y2
Definition: AMReX_algoim.H:16
@ max
Definition: AMReX_ParallelReduce.H:17
constexpr int iy
Definition: AMReX_Interp_2D_C.H:33
constexpr int ix
Definition: AMReX_Interp_2D_C.H:32
constexpr int fine_cell
Definition: AMReX_MLNodeLap_K.H:57
constexpr int fine_node
Definition: AMReX_MLNodeLap_K.H:60
constexpr int crse_node
Definition: AMReX_MLNodeLap_K.H:58
constexpr Real almostzero
Definition: AMReX_MLNodeLap_K.H:67
constexpr int crse_cell
Definition: AMReX_MLNodeLap_K.H:56
constexpr int crse_fine_node
Definition: AMReX_MLNodeLap_K.H:59
constexpr double eps
Definition: AMReX_MLNodeLap_K.H:64
constexpr Real almostone
Definition: AMReX_MLNodeLap_K.H:66
static constexpr int P
Definition: AMReX_OpenBC.H:14
Definition: AMReX_Amr.cpp:49
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real mlndlap_adotx_ha(int i, int, int, Array4< Real const > const &x, Array4< Real const > const &sx, Array4< int const > const &msk, GpuArray< Real, AMREX_SPACEDIM > const &dxinv) noexcept
Definition: AMReX_MLNodeLap_1D_K.H:158
AMREX_GPU_DEVICE AMREX_FORCE_INLINE void mlndlap_gscolor_ha(int i, int j, int k, Array4< Real > const &sol, Array4< Real const > const &rhs, Array4< Real const > const &sx, Array4< int const > const &msk, GpuArray< Real, AMREX_SPACEDIM > const &dxinv, int color) noexcept
Definition: AMReX_MLNodeLap_1D_K.H:585
void mlndlap_bc_doit(Box const &vbx, Array4< T > const &a, Box const &domain, GpuArray< bool, AMREX_SPACEDIM > const &bflo, GpuArray< bool, AMREX_SPACEDIM > const &bfhi) noexcept
Definition: AMReX_MLNodeLap_1D_K.H:110
AMREX_ATTRIBUTE_FLATTEN_FOR void LoopOnCpu(Dim3 lo, Dim3 hi, F const &f) noexcept
Definition: AMReX_Loop.H:354
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlndlap_set_nodal_mask(int i, int, int, Array4< int > const &nmsk, Array4< int const > const &cmsk) noexcept
Definition: AMReX_MLNodeLap_1D_K.H:8
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlndlap_Ax_fine_contrib_cs(int i, int j, int, Box const &ndbx, Box const &ccbx, Array4< Real > const &f, Array4< Real const > const &res, Array4< Real const > const &rhs, Array4< Real const > const &phi, Real const sig, Array4< int const > const &msk, bool is_rz, GpuArray< Real, AMREX_SPACEDIM > const &dxinv) noexcept
Definition: AMReX_MLNodeLap_2D_K.H:1473
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlndlap_divu_fine_contrib(int i, int j, int, Box const &fvbx, Box const &velbx, Array4< Real > const &rhs, Array4< Real const > const &vel, Array4< Real const > const &frhs, Array4< int const > const &msk, GpuArray< Real, AMREX_SPACEDIM > const &dxinv, bool is_rz) noexcept
Definition: AMReX_MLNodeLap_2D_K.H:1183
BoxND< AMREX_SPACEDIM > Box
Definition: AMReX_BaseFwd.H:27
AMREX_ATTRIBUTE_FLATTEN_FOR void LoopConcurrentOnCpu(Dim3 lo, Dim3 hi, F const &f) noexcept
Definition: AMReX_Loop.H:377
void mlndlap_gauss_seidel_with_line_solve_aa(Box const &, Array4< Real > const &, Array4< Real const > const &, Array4< Real const > const &, Array4< int const > const &, GpuArray< Real, AMREX_SPACEDIM > const &) noexcept
Definition: AMReX_MLNodeLap_1D_K.H:331
AMREX_GPU_DEVICE AMREX_FORCE_INLINE void mlndlap_jacobi_ha(int i, int, int, Array4< Real > const &sol, Real Ax, Array4< Real const > const &rhs, Array4< Real const > const &sx, Array4< int const > const &msk, GpuArray< Real, AMREX_SPACEDIM > const &dxinv) noexcept
Definition: AMReX_MLNodeLap_1D_K.H:198
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlndlap_semi_avgdown_coeff(int i, int j, int k, Array4< Real > const &crse, Array4< Real const > const &fine, int) noexcept
Definition: AMReX_MLNodeLap_1D_K.H:103
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlndlap_interpadd_rap(int, int, int, Array4< Real > const &, Array4< Real const > const &, Array4< Real const > const &, Array4< int const > const &) noexcept
Definition: AMReX_MLNodeLap_1D_K.H:567
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlndlap_avgdown_coeff_y(int i, int j, int k, Array4< Real > const &crse, Array4< Real const > const &fine) noexcept
Definition: AMReX_MLNodeLap_2D_K.H:157
void mlndlap_gauss_seidel_aa(Box const &bx, Array4< Real > const &sol, Array4< Real const > const &rhs, Array4< Real const > const &sx, Array4< int const > const &msk, GpuArray< Real, AMREX_SPACEDIM > const &dxinv) noexcept
Definition: AMReX_MLNodeLap_1D_K.H:299
AMREX_GPU_HOST_DEVICE constexpr AMREX_FORCE_INLINE const T & max(const T &a, const T &b) noexcept
Definition: AMReX_Algorithm.H:35
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real mlndlap_adotx_aa(int i, int j, int k, Array4< Real const > const &x, Array4< Real const > const &sx, Array4< int const > const &msk, GpuArray< Real, AMREX_SPACEDIM > const &dxinv) noexcept
Definition: AMReX_MLNodeLap_1D_K.H:172
AMREX_GPU_DEVICE AMREX_FORCE_INLINE void mlndlap_jacobi_c(int i, int, int, Array4< Real > const &sol, Real Ax, Array4< Real const > const &rhs, Real sig, Array4< int const > const &msk, GpuArray< Real, AMREX_SPACEDIM > const &dxinv) noexcept
Definition: AMReX_MLNodeLap_1D_K.H:247
AMREX_GPU_DEVICE AMREX_FORCE_INLINE void mlndlap_jacobi_aa(int i, int j, int k, Array4< Real > const &sol, Real Ax, Array4< Real const > const &rhs, Array4< Real const > const &sig, Array4< int const > const &msk, GpuArray< Real, AMREX_SPACEDIM > const &dxinv) noexcept
Definition: AMReX_MLNodeLap_1D_K.H:231
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE BoxND< dim > grow(const BoxND< dim > &b, int i) noexcept
Grow BoxND in all directions by given amount.
Definition: AMReX_Box.H:1211
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real mlndlap_adotx_sten(int, int, int, Array4< Real const > const &, Array4< Real const > const &, Array4< int const > const &) noexcept
Definition: AMReX_MLNodeLap_1D_K.H:555
AMREX_GPU_HOST_DEVICE constexpr AMREX_FORCE_INLINE const T & min(const T &a, const T &b) noexcept
Definition: AMReX_Algorithm.H:21
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlndlap_interpadd_c(int i, int, int, Array4< Real > const &fine, Array4< Real const > const &crse, Array4< int const > const &msk) noexcept
Definition: AMReX_MLNodeLap_1D_K.H:392
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlndlap_set_stencil_s0(int, int, int, Array4< Real > const &) noexcept
Definition: AMReX_MLNodeLap_1D_K.H:546
void mlndlap_gauss_seidel_ha(Box const &bx, Array4< Real > const &sol, Array4< Real const > const &rhs, Array4< Real const > const &sx, Array4< int const > const &msk, GpuArray< Real, AMREX_SPACEDIM > const &dxinv) noexcept
Definition: AMReX_MLNodeLap_1D_K.H:276
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlndlap_res_cf_contrib(int, int, int, Array4< Real > const &, Array4< Real const > const &, Array4< Real const > const &, Array4< Real const > const &, Array4< int const > const &, Array4< int const > const &, Array4< int const > const &, Array4< Real const > const &, GpuArray< Real, AMREX_SPACEDIM > const &, Box const &, GpuArray< LinOpBCType, AMREX_SPACEDIM > const &, GpuArray< LinOpBCType, AMREX_SPACEDIM > const &, bool) noexcept
Definition: AMReX_MLNodeLap_1D_K.H:516
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlndlap_normalize_aa(int i, int j, int k, Array4< Real > const &x, Array4< Real const > const &sx, Array4< int const > const &msk, GpuArray< Real, AMREX_SPACEDIM > const &dxinv) noexcept
Definition: AMReX_MLNodeLap_1D_K.H:190
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real mlndlap_sum_Ax(P const &pred, S const &sig, int i, int j, Real facx, Real facy, Array4< Real const > const &phi, bool is_rz) noexcept
Definition: AMReX_MLNodeLap_2D_K.H:1373
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlndlap_restriction(int i, int, int, Array4< Real > const &crse, Array4< Real const > const &fine, Array4< int const > const &msk) noexcept
Definition: AMReX_MLNodeLap_1D_K.H:340
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Dim3 ubound(Array4< T > const &a) noexcept
Definition: AMReX_Array4.H:315
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlndlap_rhcc_fine_contrib(int, int, int, Box const &, Array4< Real > const &, Array4< Real const > const &, Array4< int const > const &) noexcept
Definition: AMReX_MLNodeLap_1D_K.H:491
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlndlap_semi_interpadd_aa(int, int, int, Array4< Real > const &, Array4< Real const > const &, Array4< Real const > const &, Array4< int const > const &, int) noexcept
Definition: AMReX_MLNodeLap_1D_K.H:429
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Dim3 lbound(Array4< T > const &a) noexcept
Definition: AMReX_Array4.H:308
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlndlap_semi_restriction(int, int, int, Array4< Real > const &, Array4< Real const > const &, Array4< int const > const &, int) noexcept
Definition: AMReX_MLNodeLap_1D_K.H:385
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlndlap_set_stencil(Box const &, Array4< Real > const &, Array4< Real const > const &, GpuArray< Real, AMREX_SPACEDIM > const &) noexcept
Definition: AMReX_MLNodeLap_1D_K.H:540
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real aa_interp_line_y(Array4< Real const > const &crse, Array4< Real const > const &sig, int i, int j, int ic, int jc) noexcept
Definition: AMReX_MLNodeLap_2D_K.H:898
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlndlap_zero_fine(int i, int, int, Array4< Real > const &phi, Array4< int const > const &msk, int fine_flag) noexcept
Definition: AMReX_MLNodeLap_1D_K.H:81
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real mlndlap_adotx_c(int i, int, int, Array4< Real const > const &x, Real sigma, Array4< int const > const &msk, GpuArray< Real, AMREX_SPACEDIM > const &dxinv) noexcept
Definition: AMReX_MLNodeLap_1D_K.H:143
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real ha_interp_face_xy(Array4< Real const > const &crse, Array4< Real const > const &sigx, Array4< Real const > const &sigy, int i, int j, int ic, int jc) noexcept
Definition: AMReX_MLNodeLap_2D_K.H:1010
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlndlap_interpadd_aa(int i, int, int, Array4< Real > const &fine, Array4< Real const > const &crse, Array4< Real const > const &sig, Array4< int const > const &msk) noexcept
Definition: AMReX_MLNodeLap_1D_K.H:410
IntVectND< AMREX_SPACEDIM > IntVect
Definition: AMReX_BaseFwd.H:30
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlndlap_res_cf_contrib_cs(int, int, int, Array4< Real > const &, Array4< Real const > const &, Array4< Real const > const &, Real, Array4< int const > const &, Array4< int const > const &, Array4< int const > const &, Array4< Real const > const &, GpuArray< Real, AMREX_SPACEDIM > const &, Box const &, GpuArray< LinOpBCType, AMREX_SPACEDIM > const &, GpuArray< LinOpBCType, AMREX_SPACEDIM > const &, bool) noexcept
Definition: AMReX_MLNodeLap_1D_K.H:528
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlndlap_divu(int i, int, int, Array4< Real > const &rhs, Array4< Real const > const &vel, Array4< int const > const &msk, GpuArray< Real, AMREX_SPACEDIM > const &dxinv, Box const &, GpuArray< LinOpBCType, AMREX_SPACEDIM > const &, GpuArray< LinOpBCType, AMREX_SPACEDIM > const &) noexcept
Definition: AMReX_MLNodeLap_1D_K.H:443
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlndlap_divu_cf_contrib(int, int, int, Array4< Real > const &, Array4< Real const > const &, Array4< Real const > const &, Array4< Real const > const &, Array4< int const > const &, Array4< int const > const &, Array4< int const > const &, GpuArray< Real, AMREX_SPACEDIM > const &, Box const &, GpuArray< LinOpBCType, AMREX_SPACEDIM > const &, GpuArray< LinOpBCType, AMREX_SPACEDIM > const &, bool) noexcept
Definition: AMReX_MLNodeLap_1D_K.H:497
void mlndlap_gauss_seidel_sten(Box const &, Array4< Real > const &, Array4< Real const > const &, Array4< Real const > const &, Array4< int const > const &) noexcept
Definition: AMReX_MLNodeLap_1D_K.H:560
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlndlap_gscolor_sten(int, int, int, Array4< Real > const &, Array4< Real const > const &, Array4< Real const > const &, Array4< int const > const &, int) noexcept
Definition: AMReX_MLNodeLap_1D_K.H:638
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE BoxND< dim > surroundingNodes(const BoxND< dim > &b, int dir) noexcept
Returns a BoxND with NODE based coordinates in direction dir that encloses BoxND b....
Definition: AMReX_Box.H:1399
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE IntVectND< dim > scale(const IntVectND< dim > &p, int s) noexcept
Returns a IntVectND obtained by multiplying each of the components of this IntVectND by s.
Definition: AMReX_IntVect.H:1006
AMREX_GPU_DEVICE AMREX_FORCE_INLINE void mlndlap_gscolor_aa(int i, int j, int k, Array4< Real > const &sol, Array4< Real const > const &rhs, Array4< Real const > const &sx, Array4< int const > const &msk, GpuArray< Real, AMREX_SPACEDIM > const &dxinv, int color) noexcept
Definition: AMReX_MLNodeLap_1D_K.H:607
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlndlap_mknewu(int i, int, int, Array4< Real > const &u, Array4< Real const > const &p, Array4< Real const > const &sig, GpuArray< Real, AMREX_SPACEDIM > const &dxinv) noexcept
Definition: AMReX_MLNodeLap_1D_K.H:471
AMREX_GPU_HOST_DEVICE AMREX_ATTRIBUTE_FLATTEN_FOR void LoopConcurrent(Dim3 lo, Dim3 hi, F const &f) noexcept
Definition: AMReX_Loop.H:149
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlndlap_restriction_rap(int, int, int, Array4< Real > const &, Array4< Real const > const &, Array4< Real const > const &, Array4< int const > const &) noexcept
Definition: AMReX_MLNodeLap_1D_K.H:573
AMREX_GPU_DEVICE AMREX_FORCE_INLINE void mlndlap_gscolor_c(int i, int j, int k, Array4< Real > const &sol, Array4< Real const > const &rhs, Real sig, Array4< int const > const &msk, GpuArray< Real, AMREX_SPACEDIM > const &dxinv, int color) noexcept
Definition: AMReX_MLNodeLap_1D_K.H:617
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real mlndlap_sum_Df(int ii, int jj, Real facx, Real facy, Array4< Real const > const &vel, Box const &velbx, bool is_rz) noexcept
Definition: AMReX_MLNodeLap_2D_K.H:1159
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlndlap_Ax_fine_contrib_doit(S const &sig, int i, int j, Box const &ndbx, Box const &ccbx, Array4< Real > const &f, Array4< Real const > const &res, Array4< Real const > const &rhs, Array4< Real const > const &phi, Array4< int const > const &msk, bool is_rz, GpuArray< Real, AMREX_SPACEDIM > const &dxinv) noexcept
Definition: AMReX_MLNodeLap_2D_K.H:1415
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real aa_interp_face_xy(Array4< Real const > const &crse, Array4< Real const > const &sig, int i, int j, int ic, int jc) noexcept
Definition: AMReX_MLNodeLap_2D_K.H:907
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE BoxND< dim > coarsen(const BoxND< dim > &b, int ref_ratio) noexcept
Coarsen BoxND by given (positive) refinement ratio. NOTE: if type(dir) = CELL centered: lo <- lo/rati...
Definition: AMReX_Box.H:1304
AMREX_GPU_DEVICE AMREX_FORCE_INLINE int mlndlap_color(int i, int, int)
Definition: AMReX_MLNodeLap_1D_K.H:579
void Abort(const std::string &msg)
Print out message to cerr and exit via abort().
Definition: AMReX.cpp:221
const int[]
Definition: AMReX_BLProfiler.cpp:1664
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlndlap_crse_resid(int, int, int, Array4< Real > const &, Array4< Real const > const &, Array4< int const > const &, Box const &, GpuArray< LinOpBCType, AMREX_SPACEDIM > const &, GpuArray< LinOpBCType, AMREX_SPACEDIM > const &, bool) noexcept
Definition: AMReX_MLNodeLap_1D_K.H:508
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlndlap_set_dirichlet_mask(Box const &bx, Array4< int > const &dmsk, Array4< int const > const &omsk, Box const &dom, GpuArray< LinOpBCType, AMREX_SPACEDIM > const &bclo, GpuArray< LinOpBCType, AMREX_SPACEDIM > const &bchi) noexcept
Definition: AMReX_MLNodeLap_1D_K.H:24
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlndlap_normalize_ha(int i, int, int, Array4< Real > const &x, Array4< Real const > const &sx, Array4< int const > const &msk, GpuArray< Real, AMREX_SPACEDIM > const &dxinv) noexcept
Definition: AMReX_MLNodeLap_1D_K.H:180
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlndlap_avgdown_coeff_x(int i, int, int, Array4< Real > const &crse, Array4< Real const > const &fine) noexcept
Definition: AMReX_MLNodeLap_1D_K.H:94
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlndlap_set_dot_mask(Box const &bx, Array4< Real > const &dmsk, Array4< int const > const &omsk, Box const &dom, GpuArray< LinOpBCType, AMREX_SPACEDIM > const &bclo, GpuArray< LinOpBCType, AMREX_SPACEDIM > const &bchi) noexcept
Definition: AMReX_MLNodeLap_1D_K.H:51
void mlndlap_gauss_seidel_c(Box const &bx, Array4< Real > const &sol, Array4< Real const > const &rhs, Real sig, Array4< int const > const &msk, GpuArray< Real, AMREX_SPACEDIM > const &dxinv) noexcept
Definition: AMReX_MLNodeLap_1D_K.H:309
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlndlap_interpadd_ha(int i, int j, int k, Array4< Real > const &fine, Array4< Real const > const &crse, Array4< Real const > const &sig, Array4< int const > const &msk) noexcept
Definition: AMReX_MLNodeLap_1D_K.H:435
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlndlap_Ax_fine_contrib(int i, int j, int, Box const &ndbx, Box const &ccbx, Array4< Real > const &f, Array4< Real const > const &res, Array4< Real const > const &rhs, Array4< Real const > const &phi, Array4< Real const > const &sig, Array4< int const > const &msk, bool is_rz, GpuArray< Real, AMREX_SPACEDIM > const &dxinv) noexcept
Definition: AMReX_MLNodeLap_2D_K.H:1459
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real aa_interp_line_x(Array4< Real const > const &crse, Array4< Real const > const &sig, int i, int j, int ic, int jc) noexcept
Definition: AMReX_MLNodeLap_2D_K.H:889
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlndlap_stencil_rap(int, int, int, Array4< Real > const &, Array4< Real const > const &) noexcept
Definition: AMReX_MLNodeLap_1D_K.H:550
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real mlndlap_adotx_sten_doit(int i, int j, int k, Array4< Real const > const &x, Array4< Real const > const &sten) noexcept
Definition: AMReX_MLNodeLap_2D_K.H:1823
AMREX_FORCE_INLINE void tridiagonal_solve(Array1D< T, 0, 31 > &a_ls, Array1D< T, 0, 31 > &b_ls, Array1D< T, 0, 31 > &c_ls, Array1D< T, 0, 31 > &r_ls, Array1D< T, 0, 31 > &u_ls, Array1D< T, 0, 31 > &gam, int ilen) noexcept
Definition: AMReX_MLABecLap_3D_K.H:432
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real mlndlap_rhcc(int i, int, int, Array4< Real const > const &rhcc, Array4< int const > const &msk) noexcept
Definition: AMReX_MLNodeLap_1D_K.H:458
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlndlap_mknewu_c(int i, int, int, Array4< Real > const &u, Array4< Real const > const &p, Real sig, GpuArray< Real, AMREX_SPACEDIM > const &dxinv) noexcept
Definition: AMReX_MLNodeLap_1D_K.H:481
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE GpuComplex< T > sqrt(const GpuComplex< T > &a_z) noexcept
Return the square root of a complex number.
Definition: AMReX_GpuComplex.H:373
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real neumann_scale(int i, int j, Box const &nddom, GpuArray< LinOpBCType, AMREX_SPACEDIM > const &bclo, GpuArray< LinOpBCType, AMREX_SPACEDIM > const &bchi) noexcept
Definition: AMReX_MLNodeLap_2D_K.H:1246
Definition: AMReX_Array.H:164
Definition: AMReX_Array4.H:61