From ab1e2909e069b9a5d32565b1e73af213fc28d0bc Mon Sep 17 00:00:00 2001 From: Weiqun Zhang Date: Mon, 11 Nov 2024 15:54:23 -0800 Subject: [PATCH] Fix #4223 If EB is not built, m_phi_eb's size is zero. So we should then use the non-EB version of the function. --- .../MLMG/AMReX_MLEBNodeFDLaplacian.cpp | 105 +++++++++--------- 1 file changed, 54 insertions(+), 51 deletions(-) diff --git a/Src/LinearSolvers/MLMG/AMReX_MLEBNodeFDLaplacian.cpp b/Src/LinearSolvers/MLMG/AMReX_MLEBNodeFDLaplacian.cpp index 0a0bdf39a1..b5a69e455a 100644 --- a/Src/LinearSolvers/MLMG/AMReX_MLEBNodeFDLaplacian.cpp +++ b/Src/LinearSolvers/MLMG/AMReX_MLEBNodeFDLaplacian.cpp @@ -671,59 +671,62 @@ MLEBNodeFDLaplacian::compGrad (int amrlev, const Array Array4 const& gpy = grad[1]->array(mfi);, Array4 const& gpz = grad[2]->array(mfi);) #ifdef AMREX_USE_EB - Array4 const& dmarr = dmask.const_array(mfi); - bool cutfab = edgecent[0] && edgecent[0]->ok(mfi); - AMREX_D_TERM(Array4 const& ecx - = cutfab ? edgecent[0]->const_array(mfi) : Array4{};, - Array4 const& ecy - = cutfab ? edgecent[1]->const_array(mfi) : Array4{};, - Array4 const& ecz - = cutfab ? edgecent[2]->const_array(mfi) : Array4{};) - if (phieb == std::numeric_limits::lowest()) { - auto const& phiebarr = m_phi_eb[amrlev].const_array(mfi); - AMREX_LAUNCH_HOST_DEVICE_LAMBDA_DIM( - xbox, txbox, - { - mlebndfdlap_grad_x(txbox, gpx, p, dmarr, ecx, phiebarr, dxi); - } - , ybox, tybox, - { - mlebndfdlap_grad_y(tybox, gpy, p, dmarr, ecy, phiebarr, dyi); - } - , zbox, tzbox, - { - mlebndfdlap_grad_z(tzbox, gpz, p, dmarr, ecz, phiebarr, dzi); - }); - } else { + if (factory) { + Array4 const& dmarr = dmask.const_array(mfi); + bool cutfab = edgecent[0] && edgecent[0]->ok(mfi); + AMREX_D_TERM(Array4 const& ecx + = cutfab ? edgecent[0]->const_array(mfi) : Array4{};, + Array4 const& ecy + = cutfab ? edgecent[1]->const_array(mfi) : Array4{};, + Array4 const& ecz + = cutfab ? edgecent[2]->const_array(mfi) : Array4{};) + if (phieb == std::numeric_limits::lowest()) { + auto const& phiebarr = m_phi_eb[amrlev].const_array(mfi); + AMREX_LAUNCH_HOST_DEVICE_LAMBDA_DIM( + xbox, txbox, + { + mlebndfdlap_grad_x(txbox, gpx, p, dmarr, ecx, phiebarr, dxi); + } + , ybox, tybox, + { + mlebndfdlap_grad_y(tybox, gpy, p, dmarr, ecy, phiebarr, dyi); + } + , zbox, tzbox, + { + mlebndfdlap_grad_z(tzbox, gpz, p, dmarr, ecz, phiebarr, dzi); + }); + } else { + AMREX_LAUNCH_HOST_DEVICE_LAMBDA_DIM( + xbox, txbox, + { + mlebndfdlap_grad_x(txbox, gpx, p, dmarr, ecx, phieb, dxi); + } + , ybox, tybox, + { + mlebndfdlap_grad_y(tybox, gpy, p, dmarr, ecy, phieb, dyi); + } + , zbox, tzbox, + { + mlebndfdlap_grad_z(tzbox, gpz, p, dmarr, ecz, phieb, dzi); + }); + } + } else +#endif + { AMREX_LAUNCH_HOST_DEVICE_LAMBDA_DIM( - xbox, txbox, - { - mlebndfdlap_grad_x(txbox, gpx, p, dmarr, ecx, phieb, dxi); - } - , ybox, tybox, - { - mlebndfdlap_grad_y(tybox, gpy, p, dmarr, ecy, phieb, dyi); - } - , zbox, tzbox, - { - mlebndfdlap_grad_z(tzbox, gpz, p, dmarr, ecz, phieb, dzi); - }); + xbox, txbox, + { + mlebndfdlap_grad_x(txbox, gpx, p, dxi); + } + , ybox, tybox, + { + mlebndfdlap_grad_y(tybox, gpy, p, dyi); + } + , zbox, tzbox, + { + mlebndfdlap_grad_z(tzbox, gpz, p, dzi); + }); } -#else - AMREX_LAUNCH_HOST_DEVICE_LAMBDA_DIM( - xbox, txbox, - { - mlebndfdlap_grad_x(txbox, gpx, p, dxi); - } - , ybox, tybox, - { - mlebndfdlap_grad_y(tybox, gpy, p, dyi); - } - , zbox, tzbox, - { - mlebndfdlap_grad_z(tzbox, gpz, p, dzi); - }); -#endif } }