1 #ifndef AMREX_ML_CURL_CURL_K_H_
2 #define AMREX_ML_CURL_CURL_K_H_
3 #include <AMReX_Config.H>
192 #if (AMREX_SPACEDIM == 1)
195 #elif (AMREX_SPACEDIM == 2)
209 #if (AMREX_SPACEDIM == 1)
212 #elif (AMREX_SPACEDIM == 2)
224 #if (AMREX_SPACEDIM < 3)
236 #if (AMREX_SPACEDIM == 1)
250 }
else if (dim == 1) {
275 #if (AMREX_SPACEDIM > 1)
277 bool ylo_is_symmetric (
int j)
const
283 bool yhi_is_symmetric (
int j)
const
289 #if (AMREX_SPACEDIM == 3)
291 bool zlo_is_symmetric (
int k)
const
297 bool zhi_is_symmetric (
int k)
const
305 #if (AMREX_SPACEDIM == 1)
308 #elif (AMREX_SPACEDIM == 2)
312 return (side == 0) ? ylo_is_symmetric(idx) : yhi_is_symmetric(idx);
317 }
else if (dir == 1) {
318 return (side == 0) ? ylo_is_symmetric(idx) : yhi_is_symmetric(idx);
320 return (side == 0) ? zlo_is_symmetric(idx) : zhi_is_symmetric(idx);
335 #if (AMREX_SPACEDIM == 1)
338 #elif (AMREX_SPACEDIM == 2)
340 Real dyy = adxinv[1] * adxinv[1];
341 Real dxy = adxinv[0] * adxinv[1];
342 Real ccex = ex(i ,j ,k ) * dyy * Real(2.0)
343 - dyy * (ex(i ,j-1,k ) +
345 + dxy * (ey(i ,j-1,k )
349 #elif (AMREX_SPACEDIM == 3)
350 Real dyy = adxinv[1] * adxinv[1];
351 Real dzz = adxinv[2] * adxinv[2];
352 Real dxy = adxinv[0] * adxinv[1];
353 Real dxz = adxinv[0] * adxinv[2];
354 Real ccex = ex(i ,j ,k ) * (dyy+dzz)*Real(2.0)
355 - dyy * (ex(i ,j-1,k ) +
357 - dzz * (ex(i ,j ,k+1) +
359 + dxy * (ey(i ,j-1,k )
363 + dxz * (ez(i ,j ,k-1)
368 Ax(i,j,k) = ccex + beta * ex(i,j,k);
378 #if (AMREX_SPACEDIM == 1)
380 Real dxx = adxinv[0] * adxinv[0];
381 Real ccey = ey(i ,j ,k ) * dxx * Real(2.0)
382 - dxx * (ey(i-1,j ,k ) +
384 #elif (AMREX_SPACEDIM == 2)
386 Real dxx = adxinv[0] * adxinv[0];
387 Real dxy = adxinv[0] * adxinv[1];
388 Real ccey = ey(i ,j ,k ) * dxx * Real(2.0)
389 - dxx * (ey(i-1,j ,k ) +
391 + dxy * (ex(i-1,j ,k )
395 #elif (AMREX_SPACEDIM == 3)
396 Real dxx = adxinv[0] * adxinv[0];
397 Real dzz = adxinv[2] * adxinv[2];
398 Real dxy = adxinv[0] * adxinv[1];
399 Real dyz = adxinv[1] * adxinv[2];
400 Real ccey = ey(i ,j ,k ) * (dxx+dzz)*Real(2.0)
401 - dxx * (ey(i-1,j ,k ) +
403 - dzz * (ey(i ,j ,k-1) +
405 + dxy * (ex(i-1,j ,k )
409 + dyz * (ez(i ,j ,k-1)
414 Ay(i,j,k) = ccey + beta * ey(i,j,k);
424 #if (AMREX_SPACEDIM == 1)
426 Real dxx = adxinv[0] * adxinv[0];
427 Real ccez = ez(i ,j ,k ) * dxx*Real(2.0)
428 - dxx * (ez(i-1,j ,k ) +
430 #elif (AMREX_SPACEDIM == 2)
432 Real dxx = adxinv[0] * adxinv[0];
433 Real dyy = adxinv[1] * adxinv[1];
434 Real ccez = ez(i ,j ,k ) * (dxx+dyy)*Real(2.0)
435 - dxx * (ez(i-1,j ,k ) +
437 - dyy * (ez(i ,j-1,k ) +
439 #elif (AMREX_SPACEDIM == 3)
440 Real dxx = adxinv[0] * adxinv[0];
441 Real dyy = adxinv[1] * adxinv[1];
442 Real dxz = adxinv[0] * adxinv[2];
443 Real dyz = adxinv[1] * adxinv[2];
444 Real ccez = ez(i ,j ,k ) * (dxx+dyy)*Real(2.0)
445 - dxx * (ez(i-1,j ,k ) +
447 - dyy * (ez(i ,j-1,k ) +
449 + dxz * (ex(i-1,j ,k )
453 + dyz * (ey(i ,j-1,k )
458 Az(i,j,k) = ccez + beta * ez(i,j,k);
461 #if (AMREX_SPACEDIM == 1)
477 Real dxx = adxinv[0] * adxinv[0];
481 if (my_color == color)
483 ex(i,j,k) = rhsx(i,j,k) / beta;
485 Real gamma_y = dxx * Real(2.0) + beta;
486 Real ccey = - dxx * (ey(i-1,j ,k ) +
488 Real res_y = rhsy(i,j,k) - ( gamma_y * ey(i,j,k) + ccey );
489 ey(i,j,k) += res_y/gamma_y;
491 Real gamma_z = dxx * Real(2.0) + beta;
492 Real ccez = -dxx * (ez(i-1,j ,k ) +
494 Real res_z = rhsz(i,j,k) - ( gamma_z * ez(i,j,k) + ccez );
495 ez(i,j,k) += res_z/gamma_z;
516 Real dxx = adxinv[0] * adxinv[0];
520 if (my_color == color)
522 ex(i,j,k) = rhsx(i,j,k) / betax(i,j,k);
524 Real gamma_y = dxx * Real(2.0) + betay(i,j,k);
525 Real ccey = - dxx * (ey(i-1,j ,k ) +
527 Real res_y = rhsy(i,j,k) - ( gamma_y * ey(i,j,k) + ccey );
528 ey(i,j,k) += res_y/gamma_y;
530 Real gamma_z = dxx * Real(2.0) + betaz(i,j,k);
531 Real ccez = -dxx * (ez(i-1,j ,k ) +
533 Real res_z = rhsz(i,j,k) - ( gamma_z * ez(i,j,k) + ccez );
534 ez(i,j,k) += res_z/gamma_z;
541 #if (AMREX_SPACEDIM > 1)
544 void mlcurlcurl_gs4_lu (
int i,
int j,
int k,
545 Array4<Real>
const& ex,
546 Array4<Real>
const& ey,
547 Array4<Real>
const& ez,
548 Array4<Real const>
const& rhsx,
549 Array4<Real const>
const& rhsy,
550 Array4<Real const>
const& rhsz,
551 #
if (AMREX_SPACEDIM == 2)
554 GpuArray<Real,AMREX_SPACEDIM>
const& adxinv,
555 int color, LUSolver<AMREX_SPACEDIM*2,Real>
const& lusolver,
556 CurlCurlDirichletInfo
const& dinfo,
557 CurlCurlSymmetryInfo
const& sinfo)
559 if (dinfo.is_dirichlet_node(i,j,k)) {
return; }
561 int my_color = i%2 + 2*(j%2);
563 my_color = 3 - my_color;
566 #if (AMREX_SPACEDIM == 2)
568 Real dxx = adxinv[0] * adxinv[0];
569 Real dyy = adxinv[1] * adxinv[1];
571 if (((my_color == 0 || my_color == 3) && (color == 0 || color == 3)) ||
572 ((my_color == 1 || my_color == 2) && (color == 1 || color == 2)))
574 Real gamma = (dxx+dyy)*Real(2.0) + beta;
575 Real ccez = - dxx * (ez(i-1,j ,k ) +
577 - dyy * (ez(i ,j-1,k ) +
579 Real res = rhsz(i,j,k) - (gamma*ez(i,j,k) + ccez);
580 constexpr Real omega = Real(1.15);
581 ez(i,j,k) += omega/gamma * res;
584 if (my_color != color) {
return; }
586 Real dxy = adxinv[0]*adxinv[1];
589 {rhsx(i-1,j,k) - (-dyy * ( ex(i-1,j-1,k ) +
591 + dxy * ( ey(i-1,j-1,k )
593 rhsx(i ,j,k) - (-dyy * ( ex(i ,j-1,k ) +
595 + dxy * (-ey(i+1,j-1,k )
597 rhsy(i,j-1,k) - (-dxx * ( ey(i-1,j-1,k ) +
599 + dxy * ( ex(i-1,j-1,k )
601 rhsy(i,j ,k) - (-dxx * ( ey(i-1,j ,k ) +
603 + dxy * (-ex(i-1,j+1,k )
606 if (sinfo.xlo_is_symmetric(i)) {
608 }
else if (sinfo.xhi_is_symmetric(i)) {
612 if (sinfo.ylo_is_symmetric(j)) {
614 }
else if (sinfo.yhi_is_symmetric(j)) {
619 lusolver(
x.data(),
b.data());
620 ex(i-1,j ,k ) =
x[0];
622 ey(i ,j-1,k ) =
x[2];
625 #elif (AMREX_SPACEDIM == 3)
627 if (my_color != color) {
return; }
629 Real dxx = adxinv[0]*adxinv[0];
630 Real dyy = adxinv[1]*adxinv[1];
631 Real dzz = adxinv[2]*adxinv[2];
632 Real dxy = adxinv[0]*adxinv[1];
633 Real dxz = adxinv[0]*adxinv[2];
634 Real dyz = adxinv[1]*adxinv[2];
637 {rhsx(i-1,j,k) - (-dyy * ( ex(i-1,j-1,k ) +
639 - dzz * ( ex(i-1,j ,k+1) +
641 + dxy * ( ey(i-1,j-1,k )
643 + dxz * ( ez(i-1,j ,k-1)
645 rhsx(i ,j,k) - (-dyy * ( ex(i ,j-1,k ) +
647 - dzz * ( ex(i ,j ,k+1) +
649 + dxy * (-ey(i+1,j-1,k )
651 + dxz * (-ez(i+1,j ,k-1)
653 rhsy(i,j-1,k) - (-dxx * ( ey(i-1,j-1,k ) +
655 - dzz * ( ey(i ,j-1,k-1) +
657 + dxy * ( ex(i-1,j-1,k )
659 + dyz * ( ez(i ,j-1,k-1)
661 rhsy(i,j ,k) - (-dxx * ( ey(i-1,j ,k ) +
663 - dzz * ( ey(i ,j ,k-1) +
665 + dxy * (-ex(i-1,j+1,k )
667 + dyz * (-ez(i ,j+1,k-1)
669 rhsz(i,j,k-1) - (-dxx * ( ez(i-1,j ,k-1) +
671 - dyy * ( ez(i ,j-1,k-1) +
673 + dxz * ( ex(i-1,j ,k-1)
675 + dyz * ( ey(i ,j-1,k-1)
677 rhsz(i,j,k ) - (-dxx * ( ez(i-1,j ,k ) +
679 - dyy * ( ez(i ,j-1,k ) +
681 + dxz * (-ex(i-1,j ,k+1)
683 + dyz * (-ey(i ,j-1,k+1)
686 if (sinfo.xlo_is_symmetric(i)) {
688 }
else if (sinfo.xhi_is_symmetric(i)) {
692 if (sinfo.ylo_is_symmetric(j)) {
694 }
else if (sinfo.yhi_is_symmetric(j)) {
698 if (sinfo.zlo_is_symmetric(k)) {
700 }
else if (sinfo.zhi_is_symmetric(k)) {
705 lusolver(
x.data(),
b.data());
706 ex(i-1,j ,k ) =
x[0];
708 ey(i ,j-1,k ) =
x[2];
710 ez(i ,j ,k-1) =
x[4];
717 void mlcurlcurl_gs4 (
int i,
int j,
int k,
718 Array4<Real>
const& ex,
719 Array4<Real>
const& ey,
720 Array4<Real>
const& ez,
721 Array4<Real const>
const& rhsx,
722 Array4<Real const>
const& rhsy,
723 Array4<Real const>
const& rhsz,
724 GpuArray<Real,AMREX_SPACEDIM>
const& adxinv,
726 Array4<Real const>
const& betax,
727 Array4<Real const>
const& betay,
728 Array4<Real const>
const& betaz,
729 CurlCurlDirichletInfo
const& dinfo,
730 CurlCurlSymmetryInfo
const& sinfo)
732 if (dinfo.is_dirichlet_node(i,j,k)) {
return; }
734 int my_color = i%2 + 2*(j%2);
736 my_color = 3 - my_color;
739 #if (AMREX_SPACEDIM == 2)
741 Real dxx = adxinv[0] * adxinv[0];
742 Real dyy = adxinv[1] * adxinv[1];
744 if (((my_color == 0 || my_color == 3) && (color == 0 || color == 3)) ||
745 ((my_color == 1 || my_color == 2) && (color == 1 || color == 2)))
747 Real gamma = (dxx+dyy)*Real(2.0) + betaz(i,j,k);
748 Real ccez = - dxx * (ez(i-1,j ,k ) +
750 - dyy * (ez(i ,j-1,k ) +
752 Real res = rhsz(i,j,k) - (gamma*ez(i,j,k) + ccez);
753 constexpr Real omega = Real(1.15);
754 ez(i,j,k) += omega/gamma * res;
757 if (my_color != color) {
return; }
759 Real dxy = adxinv[0]*adxinv[1];
762 {rhsx(i-1,j,k) - (-dyy * ( ex(i-1,j-1,k ) +
764 + dxy * ( ey(i-1,j-1,k )
766 rhsx(i ,j,k) - (-dyy * ( ex(i ,j-1,k ) +
768 + dxy * (-ey(i+1,j-1,k )
770 rhsy(i,j-1,k) - (-dxx * ( ey(i-1,j-1,k ) +
772 + dxy * ( ex(i-1,j-1,k )
774 rhsy(i,j ,k) - (-dxx * ( ey(i-1,j ,k ) +
776 + dxy * (-ex(i-1,j+1,k )
779 GpuArray<Real,4> beta;
781 if (sinfo.xlo_is_symmetric(i)) {
783 beta[0] = beta[1] = betax(i,j,k);
784 }
else if (sinfo.xhi_is_symmetric(i)) {
786 beta[0] = beta[1] = betax(i-1,j,k);
788 beta[0] = betax(i-1,j,k);
789 beta[1] = betax(i ,j,k);
792 if (sinfo.ylo_is_symmetric(j)) {
794 beta[2] = beta[3] = betay(i,j,k);
795 }
else if (sinfo.yhi_is_symmetric(j)) {
797 beta[2] = beta[3] = betay(i,j-1,k);
799 beta[2] = betay(i,j-1,k);
800 beta[3] = betay(i,j ,k);
804 Real diagInv[4] = {Real(1.0) / (dyy*Real(2.0) + beta[0]),
805 Real(1.0) / (dyy*Real(2.0) + beta[1]),
806 Real(1.0) / (dxx*Real(2.0) + beta[2]),
807 Real(1.0) / (dxx*Real(2.0) + beta[3])};
811 for (
int m = 0; m < 4; ++m) { z[m] =
r[m] * diagInv[m]; }
816 Av[0] = (dyy*Real(2.0) + beta[0]) * v[0] - dxy * v[2] + dxy * v[3];
817 Av[1] = (dyy*Real(2.0) + beta[1]) * v[1] + dxy * v[2] - dxy * v[3];
818 Av[2] = -dxy * v[0] + dxy * v[1] + (dxx*Real(2.0) + beta[2]) * v[2];
819 Av[3] = dxy * v[0] - dxy * v[1] + (dxx*Real(2.0) + beta[3]) * v[3];
821 Real sol[4] = {0, 0, 0, 0};
822 pcg_solve<4>(sol,
b.data(), mat, precond, 8, Real(1.e-8));
823 ex(i-1,j ,k ) = sol[0];
824 ex(i ,j ,k ) = sol[1];
825 ey(i ,j-1,k ) = sol[2];
826 ey(i ,j ,k ) = sol[3];
828 LUSolver<4,Real> lusolver
829 ({dyy*Real(2.0) + beta[0],
835 dyy*Real(2.0) + beta[1],
841 dxx*Real(2.0) + beta[2],
847 dxx*Real(2.0) + beta[3]});
848 lusolver(beta.data(),
b.data());
849 ex(i-1,j ,k ) = beta[0];
850 ex(i ,j ,k ) = beta[1];
851 ey(i ,j-1,k ) = beta[2];
852 ey(i ,j ,k ) = beta[3];
855 #elif (AMREX_SPACEDIM == 3)
857 if (my_color != color) {
return; }
859 Real dxx = adxinv[0]*adxinv[0];
860 Real dyy = adxinv[1]*adxinv[1];
861 Real dzz = adxinv[2]*adxinv[2];
862 Real dxy = adxinv[0]*adxinv[1];
863 Real dxz = adxinv[0]*adxinv[2];
864 Real dyz = adxinv[1]*adxinv[2];
867 {rhsx(i-1,j,k) - (-dyy * ( ex(i-1,j-1,k ) +
869 - dzz * ( ex(i-1,j ,k+1) +
871 + dxy * ( ey(i-1,j-1,k )
873 + dxz * ( ez(i-1,j ,k-1)
875 rhsx(i ,j,k) - (-dyy * ( ex(i ,j-1,k ) +
877 - dzz * ( ex(i ,j ,k+1) +
879 + dxy * (-ey(i+1,j-1,k )
881 + dxz * (-ez(i+1,j ,k-1)
883 rhsy(i,j-1,k) - (-dxx * ( ey(i-1,j-1,k ) +
885 - dzz * ( ey(i ,j-1,k-1) +
887 + dxy * ( ex(i-1,j-1,k )
889 + dyz * ( ez(i ,j-1,k-1)
891 rhsy(i,j ,k) - (-dxx * ( ey(i-1,j ,k ) +
893 - dzz * ( ey(i ,j ,k-1) +
895 + dxy * (-ex(i-1,j+1,k )
897 + dyz * (-ez(i ,j+1,k-1)
899 rhsz(i,j,k-1) - (-dxx * ( ez(i-1,j ,k-1) +
901 - dyy * ( ez(i ,j-1,k-1) +
903 + dxz * ( ex(i-1,j ,k-1)
905 + dyz * ( ey(i ,j-1,k-1)
907 rhsz(i,j,k ) - (-dxx * ( ez(i-1,j ,k ) +
909 - dyy * ( ez(i ,j-1,k ) +
911 + dxz * (-ex(i-1,j ,k+1)
913 + dyz * (-ey(i ,j-1,k+1)
916 GpuArray<Real,6> beta;
918 if (sinfo.xlo_is_symmetric(i)) {
920 beta[0] = beta[1] = betax(i,j,k);
921 }
else if (sinfo.xhi_is_symmetric(i)) {
923 beta[0] = beta[1] = betax(i-1,j,k);
925 beta[0] = betax(i-1,j,k);
926 beta[1] = betax(i ,j,k);
929 if (sinfo.ylo_is_symmetric(j)) {
931 beta[2] = beta[3] = betay(i,j,k);
932 }
else if (sinfo.yhi_is_symmetric(j)) {
934 beta[2] = beta[3] = betay(i,j-1,k);
936 beta[2] = betay(i,j-1,k);
937 beta[3] = betay(i,j ,k);
940 if (sinfo.zlo_is_symmetric(k)) {
942 beta[4] = beta[5] = betaz(i,j,k);
943 }
else if (sinfo.zhi_is_symmetric(k)) {
945 beta[4] = beta[5] = betaz(i,j,k-1);
947 beta[4] = betaz(i,j,k-1);
948 beta[5] = betaz(i,j,k );
952 Real diagInv[6] = {Real(1.0) / ((dyy+dzz)*Real(2.0) + beta[0]),
953 Real(1.0) / ((dyy+dzz)*Real(2.0) + beta[1]),
954 Real(1.0) / ((dxx+dzz)*Real(2.0) + beta[2]),
955 Real(1.0) / ((dxx+dzz)*Real(2.0) + beta[3]),
956 Real(1.0) / ((dxx+dyy)*Real(2.0) + beta[4]),
957 Real(1.0) / ((dxx+dyy)*Real(2.0) + beta[5])};
961 for (
int m = 0; m < 6; ++m) { z[m] =
r[m] * diagInv[m]; }
966 Av[0] = ((dyy+dzz)*Real(2.0) + beta[0]) * v[0] - dxy * v[2]
967 + dxy * v[3] - dxz * v[4] + dxz * v[5];
968 Av[1] = ((dyy+dzz)*Real(2.0) + beta[1]) * v[1] + dxy * v[2]
969 - dxy * v[3] + dxz * v[4] - dxz * v[5];
970 Av[2] = -dxy * v[0] + dxy * v[1] + ((dxx+dzz)*Real(2.0) + beta[2]) * v[2]
971 - dyz * v[4] + dyz * v[5];
972 Av[3] = dxy * v[0] - dxy * v[1] + ((dxx+dzz)*Real(2.0) + beta[3]) * v[3]
973 + dyz * v[4] - dyz * v[5];
974 Av[4] = -dxz * v[0] + dxz * v[1] - dyz * v[2] + dyz * v[3]
975 + ((dxx+dyy)*Real(2.0) + beta[4]) * v[4];
976 Av[5] = dxz * v[0] - dxz * v[1] + dyz * v[2] - dyz * v[3]
977 + ((dxx+dyy)*Real(2.0) + beta[5]) * v[5];
979 Real sol[6] = {0, 0, 0, 0, 0, 0};
980 pcg_solve<6>(sol,
b.data(), mat, precond, 8, Real(1.e-8));
981 ex(i-1,j ,k ) = sol[0];
982 ex(i ,j ,k ) = sol[1];
983 ey(i ,j-1,k ) = sol[2];
984 ey(i ,j ,k ) = sol[3];
985 ez(i ,j ,k-1) = sol[4];
986 ez(i ,j ,k ) = sol[5];
988 LUSolver<6,Real> lusolver
989 ({(dyy+dzz)*Real(2.0) + beta[0],
997 (dyy+dzz)*Real(2.0) + beta[1],
1005 (dxx+dzz)*Real(2.0) + beta[2],
1013 (dxx+dzz)*Real(2.0) + beta[3],
1021 (dxx+dyy)*Real(2.0) + beta[4],
1029 (dxx+dyy)*Real(2.0) + beta[5]});
1030 lusolver(beta.data(),
b.data());
1031 ex(i-1,j ,k ) = beta[0];
1032 ex(i ,j ,k ) = beta[1];
1033 ey(i ,j-1,k ) = beta[2];
1034 ey(i ,j ,k ) = beta[3];
1035 ez(i ,j ,k-1) = beta[4];
1036 ez(i ,j ,k ) = beta[5];
1052 bool j_is_odd = (jc*2 != j);
1053 bool k_is_odd = (kc*2 != k);
1054 if (j_is_odd && k_is_odd) {
1055 fine(i,j,k) += Real(0.25) *
1056 (
crse(ic,jc,kc ) +
crse(ic,jc+1,kc ) +
1057 crse(ic,jc,kc+1) +
crse(ic,jc+1,kc+1));
1058 }
else if (j_is_odd) {
1059 fine(i,j,k) += Real(0.5) * (
crse(ic,jc,kc) +
crse(ic,jc+1,kc));
1060 }
else if (k_is_odd) {
1061 fine(i,j,k) += Real(0.5) * (
crse(ic,jc,kc) +
crse(ic,jc,kc+1));
1065 }
else if (dir == 1) {
1066 bool i_is_odd = (ic*2 != i);
1067 bool k_is_odd = (kc*2 != k);
1068 if (i_is_odd && k_is_odd) {
1069 fine(i,j,k) += Real(0.25) *
1070 (
crse(ic ,jc,kc ) +
crse(ic+1,jc,kc ) +
1071 crse(ic ,jc,kc+1) +
crse(ic+1,jc,kc+1));
1072 }
else if (i_is_odd) {
1073 fine(i,j,k) += Real(0.5) * (
crse(ic,jc,kc) +
crse(ic+1,jc,kc));
1074 }
else if (k_is_odd) {
1075 fine(i,j,k) += Real(0.5) * (
crse(ic,jc,kc) +
crse(ic,jc,kc+1));
1080 bool i_is_odd = (ic*2 != i);
1081 bool j_is_odd = (jc*2 != j);
1082 if (i_is_odd && j_is_odd) {
1083 fine(i,j,k) += Real(0.25) *
1084 (
crse(ic ,jc ,kc) +
crse(ic+1,jc ,kc) +
1085 crse(ic ,jc+1,kc) +
crse(ic+1,jc+1,kc));
1086 }
else if (i_is_odd) {
1087 fine(i,j,k) += Real(0.5) * (
crse(ic,jc,kc) +
crse(ic+1,jc,kc));
1088 }
else if (j_is_odd) {
1089 fine(i,j,k) += Real(0.5) * (
crse(ic,jc,kc) +
crse(ic,jc+1,kc));
1106 crse(i,j,k) = Real(0.0);
1110 #if (AMREX_SPACEDIM == 3)
1112 crse(i,j,k) = Real(1./32.) * (
fine(ii ,jj-1,kk-1) +
1113 fine(ii ,jj ,kk-1) * Real(2.0) +
1114 fine(ii ,jj+1,kk-1) +
1115 fine(ii ,jj-1,kk ) * Real(2.0) +
1116 fine(ii ,jj ,kk ) * Real(4.0) +
1117 fine(ii ,jj+1,kk ) * Real(2.0) +
1118 fine(ii ,jj-1,kk+1) +
1119 fine(ii ,jj ,kk+1) * Real(2.0) +
1120 fine(ii ,jj+1,kk+1) +
1121 fine(ii+1,jj-1,kk-1) +
1122 fine(ii+1,jj ,kk-1) * Real(2.0) +
1123 fine(ii+1,jj+1,kk-1) +
1124 fine(ii+1,jj-1,kk ) * Real(2.0) +
1125 fine(ii+1,jj ,kk ) * Real(4.0) +
1126 fine(ii+1,jj+1,kk ) * Real(2.0) +
1127 fine(ii+1,jj-1,kk+1) +
1128 fine(ii+1,jj ,kk+1) * Real(2.0) +
1129 fine(ii+1,jj+1,kk+1) );
1130 }
else if (dir == 1) {
1131 crse(i,j,k) = Real(1./32.) * (
fine(ii-1,jj ,kk-1) +
1132 fine(ii ,jj ,kk-1) * Real(2.0) +
1133 fine(ii+1,jj ,kk-1) +
1134 fine(ii-1,jj ,kk ) * Real(2.0) +
1135 fine(ii ,jj ,kk ) * Real(4.0) +
1136 fine(ii+1,jj ,kk ) * Real(2.0) +
1137 fine(ii-1,jj ,kk+1) +
1138 fine(ii ,jj ,kk+1) * Real(2.0) +
1139 fine(ii+1,jj ,kk+1) +
1140 fine(ii-1,jj+1,kk-1) +
1141 fine(ii ,jj+1,kk-1) * Real(2.0) +
1142 fine(ii+1,jj+1,kk-1) +
1143 fine(ii-1,jj+1,kk ) * Real(2.0) +
1144 fine(ii ,jj+1,kk ) * Real(4.0) +
1145 fine(ii+1,jj+1,kk ) * Real(2.0) +
1146 fine(ii-1,jj+1,kk+1) +
1147 fine(ii ,jj+1,kk+1) * Real(2.0) +
1148 fine(ii+1,jj+1,kk+1) );
1150 crse(i,j,k) = Real(1./32.) * (
fine(ii-1,jj-1,kk ) +
1151 fine(ii ,jj-1,kk ) * Real(2.0) +
1152 fine(ii+1,jj-1,kk ) +
1153 fine(ii-1,jj ,kk ) * Real(2.0) +
1154 fine(ii ,jj ,kk ) * Real(4.0) +
1155 fine(ii+1,jj ,kk ) * Real(2.0) +
1156 fine(ii-1,jj+1,kk ) +
1157 fine(ii ,jj+1,kk ) * Real(2.0) +
1158 fine(ii+1,jj+1,kk ) +
1159 fine(ii-1,jj-1,kk+1) +
1160 fine(ii ,jj-1,kk+1) * Real(2.0) +
1161 fine(ii+1,jj-1,kk+1) +
1162 fine(ii-1,jj ,kk+1) * Real(2.0) +
1163 fine(ii ,jj ,kk+1) * Real(4.0) +
1164 fine(ii+1,jj ,kk+1) * Real(2.0) +
1165 fine(ii-1,jj+1,kk+1) +
1166 fine(ii ,jj+1,kk+1) * Real(2.0) +
1167 fine(ii+1,jj+1,kk+1) );
1169 #elif (AMREX_SPACEDIM == 2)
1171 crse(i,j,0) = Real(0.125) * (
fine(ii ,jj-1,0) +
1172 fine(ii ,jj ,0) * Real(2.0) +
1175 fine(ii+1,jj ,0) * Real(2.0) +
1176 fine(ii+1,jj+1,0) );
1177 }
else if (dir == 1) {
1178 crse(i,j,0) = Real(0.125) * (
fine(ii-1,jj ,0) +
1179 fine(ii ,jj ,0) * Real(2.0) +
1182 fine(ii ,jj+1,0) * Real(2.0) +
1183 fine(ii+1,jj+1,0) );
1185 crse(i,j,0) = Real(1./16.)*(
fine(ii-1,jj-1,0) + Real(2.)*
fine(ii ,jj-1,0) +
fine(ii+1,jj-1,0)
1186 + Real(2.)*
fine(ii-1,jj ,0) + Real(4.)*
fine(ii ,jj ,0) + Real(2.)*
fine(ii+1,jj ,0)
1187 +
fine(ii-1,jj+1,0) + Real(2.)*
fine(ii ,jj+1,0) +
fine(ii+1,jj+1,0));
1191 #elif (AMREX_SPACEDIM == 1)
1193 crse(i,0,0) = Real(0.5) * (
fine(ii,0,0) +
fine(ii+1,0,0));
1195 crse(i,0,0) = Real(0.25) * (
fine(ii-1,0,0) +
1196 fine(ii ,0,0) * Real(2.0) +
1218 a(i,j,k) = sign * a(i+
offset,j,k);
1219 }
else if (
idir == 1) {
1220 a(i,j,k) = sign * a(i,j+
offset,k);
1222 a(i,j,k) = sign * a(i,j,k+
offset);
#define AMREX_FORCE_INLINE
Definition: AMReX_Extension.H:119
#define AMREX_RESTRICT
Definition: AMReX_Extension.H:37
#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
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool cellCentered() const noexcept
True if the IndexTypeND is CELL based in all directions.
Definition: AMReX_IndexType.H:101
Encapsulation of the Orientation of the Faces of a Box.
Definition: AMReX_Orientation.H:29
AMREX_GPU_HOST_DEVICE int coordDir() const noexcept
Returns the coordinate direction.
Definition: AMReX_Orientation.H:83
AMREX_GPU_HOST_DEVICE bool isLow() const noexcept
Returns true if Orientation is low.
Definition: AMReX_Orientation.H:89
Definition: AMReX_Amr.cpp:49
CurlCurlStateType
Definition: AMReX_MLCurlCurl_K.H:326
AMREX_GPU_DEVICE AMREX_FORCE_INLINE void mlcurlcurl_interpadd(int dir, int i, int j, int k, Array4< Real > const &fine, Array4< Real const > const &crse)
Definition: AMReX_MLCurlCurl_K.H:1044
AMREX_GPU_DEVICE AMREX_FORCE_INLINE void mlcurlcurl_1D(int i, int j, int k, Array4< Real > const &ex, Array4< Real > const &ey, Array4< Real > const &ez, Array4< Real const > const &rhsx, Array4< Real const > const &rhsy, Array4< Real const > const &rhsz, Real beta, GpuArray< Real, AMREX_SPACEDIM > const &adxinv, int color, CurlCurlDirichletInfo const &dinfo)
Definition: AMReX_MLCurlCurl_K.H:463
AMREX_GPU_DEVICE AMREX_FORCE_INLINE void mlcurlcurl_adotx_y(int i, int j, int k, Array4< Real > const &Ay, Array4< Real const > const &ex, Array4< Real const > const &ey, Array4< Real const > const &ez, Real beta, GpuArray< Real, AMREX_SPACEDIM > const &adxinv)
Definition: AMReX_MLCurlCurl_K.H:372
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void ignore_unused(const Ts &...)
This shuts up the compiler about unused variables.
Definition: AMReX.H:111
AMREX_GPU_DEVICE AMREX_FORCE_INLINE void mlcurlcurl_bc_symmetry(int i, int j, int k, Orientation face, IndexType it, Array4< Real > const &a)
Definition: AMReX_MLCurlCurl_K.H:1204
AMREX_GPU_DEVICE AMREX_FORCE_INLINE void mlcurlcurl_adotx_z(int i, int j, int k, Array4< Real > const &Az, Array4< Real const > const &ex, Array4< Real const > const &ey, Array4< Real const > const &ez, Real beta, GpuArray< Real, AMREX_SPACEDIM > const &adxinv)
Definition: AMReX_MLCurlCurl_K.H:418
AMREX_GPU_DEVICE AMREX_FORCE_INLINE void mlcurlcurl_adotx_x(int i, int j, int k, Array4< Real > const &Ax, Array4< Real const > const &ex, Array4< Real const > const &ey, Array4< Real const > const &ez, Real beta, GpuArray< Real, AMREX_SPACEDIM > const &adxinv)
Definition: AMReX_MLCurlCurl_K.H:329
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 void mlcurlcurl_restriction(int dir, int i, int j, int k, Array4< Real > const &crse, Array4< Real const > const &fine, CurlCurlDirichletInfo const &dinfo)
Definition: AMReX_MLCurlCurl_K.H:1097
Definition: AMReX_Array4.H:61
Definition: AMReX_MLCurlCurl_K.H:185
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool is_dirichlet_node(int i, int j, int k) const
Definition: AMReX_MLCurlCurl_K.H:190
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool is_dirichlet_edge(int dim, int i, int j, int k) const
Definition: AMReX_MLCurlCurl_K.H:246
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool is_dirichlet_z_edge(int i, int j, int) const
Definition: AMReX_MLCurlCurl_K.H:234
IntVect dirichlet_hi
Definition: AMReX_MLCurlCurl_K.H:187
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool is_dirichlet_y_edge(int i, int, int k) const
Definition: AMReX_MLCurlCurl_K.H:222
IntVect dirichlet_lo
Definition: AMReX_MLCurlCurl_K.H:186
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool is_dirichlet_x_edge(int, int j, int k) const
Definition: AMReX_MLCurlCurl_K.H:207
Definition: AMReX_MLCurlCurl_K.H:259
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool xlo_is_symmetric(int i) const
Definition: AMReX_MLCurlCurl_K.H:264
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool xhi_is_symmetric(int i) const
Definition: AMReX_MLCurlCurl_K.H:270
IntVect symmetry_hi
Definition: AMReX_MLCurlCurl_K.H:261
IntVect symmetry_lo
Definition: AMReX_MLCurlCurl_K.H:260
bool is_symmetric(int dir, int side, int idx) const
Definition: AMReX_MLCurlCurl_K.H:303