From d6c9caa0c6dd0b914192e68db5be219e9db29c35 Mon Sep 17 00:00:00 2001 From: Weiqun Zhang Date: Mon, 11 Nov 2024 16:39:23 -0800 Subject: [PATCH] Fix #4223 (#4226) If EB is not built, m_phi_eb's size is zero. So we should then use the non-EB version of the function. Close #4223. --- .../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 } }