From 2df57305afcea8087dfde9213525c3d7bb2c75a5 Mon Sep 17 00:00:00 2001 From: cgilet Date: Wed, 20 Mar 2024 13:55:38 -0400 Subject: [PATCH 1/2] Fixes for position dependent BCs --- EBGodunov/hydro_ebgodunov_edge_state_2D.cpp | 4 +- EBGodunov/hydro_ebgodunov_edge_state_3D.cpp | 6 +-- EBGodunov/hydro_ebgodunov_plm.cpp | 14 +++---- EBGodunov/hydro_ebgodunov_plm_fpu.cpp | 40 ++++++++++--------- .../hydro_godunov_extrap_vel_to_faces_2D.cpp | 4 +- 5 files changed, 34 insertions(+), 34 deletions(-) diff --git a/EBGodunov/hydro_ebgodunov_edge_state_2D.cpp b/EBGodunov/hydro_ebgodunov_edge_state_2D.cpp index 77e3c8d7d..97d890970 100644 --- a/EBGodunov/hydro_ebgodunov_edge_state_2D.cpp +++ b/EBGodunov/hydro_ebgodunov_edge_state_2D.cpp @@ -92,12 +92,12 @@ EBGodunov::ComputeEdgeState ( Box const& bx, int ncomp, EBPLM::PredictStateOnXFace( xebx, ncomp, Imx, Ipx, q, u_mac, flag_arr, vfrac_arr, AMREX_D_DECL(fcx,fcy,fcz),ccent_arr, - geom, l_dt, h_bcrec, pbc, is_velocity); + geom, l_dt, h_bcrec, pbc, is_velocity, bc_arr); EBPLM::PredictStateOnYFace( yebx, ncomp, Imy, Ipy, q, v_mac, flag_arr, vfrac_arr, AMREX_D_DECL(fcx,fcy,fcz),ccent_arr, - geom, l_dt, h_bcrec, pbc, is_velocity); + geom, l_dt, h_bcrec, pbc, is_velocity, bc_arr); // No need for the intermediate upwinded edge state like in 3D. Could combine // with x/yzlo loop below ... diff --git a/EBGodunov/hydro_ebgodunov_edge_state_3D.cpp b/EBGodunov/hydro_ebgodunov_edge_state_3D.cpp index 321f5371d..57c7d13c7 100644 --- a/EBGodunov/hydro_ebgodunov_edge_state_3D.cpp +++ b/EBGodunov/hydro_ebgodunov_edge_state_3D.cpp @@ -116,17 +116,17 @@ EBGodunov::ComputeEdgeState ( Box const& bx, int ncomp, EBPLM::PredictStateOnXFace( xebx, ncomp, Imx, Ipx, q, u_mac, flag_arr, vfrac_arr, AMREX_D_DECL(fcx,fcy,fcz),ccent_arr, - geom, l_dt, h_bcrec, pbc, is_velocity); + geom, l_dt, h_bcrec, pbc, is_velocity, bc_arr); EBPLM::PredictStateOnYFace( yebx, ncomp, Imy, Ipy, q, v_mac, flag_arr, vfrac_arr, AMREX_D_DECL(fcx,fcy,fcz),ccent_arr, - geom, l_dt, h_bcrec, pbc, is_velocity); + geom, l_dt, h_bcrec, pbc, is_velocity, bc_arr); EBPLM::PredictStateOnZFace( zebx, ncomp, Imz, Ipz, q, w_mac, flag_arr, vfrac_arr, AMREX_D_DECL(fcx,fcy,fcz),ccent_arr, - geom, l_dt, h_bcrec, pbc, is_velocity); + geom, l_dt, h_bcrec, pbc, is_velocity, bc_arr); amrex::ParallelFor( xebx, ncomp, [=] AMREX_GPU_DEVICE (int i, int j, int k, int n) noexcept diff --git a/EBGodunov/hydro_ebgodunov_plm.cpp b/EBGodunov/hydro_ebgodunov_plm.cpp index 51a877ebf..73fa5b658 100644 --- a/EBGodunov/hydro_ebgodunov_plm.cpp +++ b/EBGodunov/hydro_ebgodunov_plm.cpp @@ -718,12 +718,12 @@ EBPLM::PredictVelOnZFace (Box const& zebox, auto extdir_lohi_y = has_extdir_or_ho(h_bcrec.data(), AMREX_SPACEDIM, static_cast(Direction::y)); auto extdir_lohi_z = has_extdir_or_ho(h_bcrec.data(), AMREX_SPACEDIM, static_cast(Direction::z)); - bool has_extdir_or_ho_lo_x = extdir_lohi_x.first; - bool has_extdir_or_ho_hi_x = extdir_lohi_x.second; - bool has_extdir_or_ho_lo_y = extdir_lohi_y.first; - bool has_extdir_or_ho_hi_y = extdir_lohi_y.second; - bool has_extdir_or_ho_lo_z = extdir_lohi_z.first; - bool has_extdir_or_ho_hi_z = extdir_lohi_z.second; + bool has_extdir_or_ho_lo_x = bc_arr ? true : extdir_lohi_x.first; + bool has_extdir_or_ho_hi_x = bc_arr ? true : extdir_lohi_x.second; + bool has_extdir_or_ho_lo_y = bc_arr ? true : extdir_lohi_y.first; + bool has_extdir_or_ho_hi_y = bc_arr ? true : extdir_lohi_y.second; + bool has_extdir_or_ho_lo_z = bc_arr ? true : extdir_lohi_z.first; + bool has_extdir_or_ho_hi_z = bc_arr ? true : extdir_lohi_z.second; if ( (has_extdir_or_ho_lo_x && domain_ilo >= zebox.smallEnd(0)-1) || (has_extdir_or_ho_hi_x && domain_ihi <= zebox.bigEnd(0) ) || @@ -807,7 +807,6 @@ EBPLM::PredictVelOnZFace (Box const& zebox, qpls = amrex::max(amrex::min(qpls, qcc_max), qcc_min); qpls -= Real(0.5) * dtdz * ccvel(i,j,k,2) * slopes_eb_hi[2]; - } // end of making qpls // ************************************************* @@ -859,7 +858,6 @@ EBPLM::PredictVelOnZFace (Box const& zebox, qmns = amrex::max(amrex::min(qmns, qcc_max), qcc_min); qmns -= Real(0.5) * dtdz * ccvel(i,j,k-1,2) * slopes_eb_lo[2]; - } // end of making qmns } diff --git a/EBGodunov/hydro_ebgodunov_plm_fpu.cpp b/EBGodunov/hydro_ebgodunov_plm_fpu.cpp index bffd5493c..f2620fa9a 100644 --- a/EBGodunov/hydro_ebgodunov_plm_fpu.cpp +++ b/EBGodunov/hydro_ebgodunov_plm_fpu.cpp @@ -58,17 +58,19 @@ EBPLM::PredictStateOnXFace (Box const& xebox, int ncomp, auto extdir_lohi_x = has_extdir_or_ho(h_bcrec.data(), ncomp, static_cast(Direction::x)); auto extdir_lohi_y = has_extdir_or_ho(h_bcrec.data(), ncomp, static_cast(Direction::y)); - bool has_extdir_or_ho_lo_x = extdir_lohi_x.first; - bool has_extdir_or_ho_hi_x = extdir_lohi_x.second; - bool has_extdir_or_ho_lo_y = extdir_lohi_y.first; - bool has_extdir_or_ho_hi_y = extdir_lohi_y.second; +// If we have a BC Array4, then we can't make these blanket statements about the domain face +// Best to assume we could have face-based BC somewhere + bool has_extdir_or_ho_lo_x = bc_arr ? true : extdir_lohi_x.first; + bool has_extdir_or_ho_hi_x = bc_arr ? true : extdir_lohi_x.second; + bool has_extdir_or_ho_lo_y = bc_arr ? true : extdir_lohi_y.first; + bool has_extdir_or_ho_hi_y = bc_arr ? true : extdir_lohi_y.second; #if (AMREX_SPACEDIM == 3) const int domain_klo = domain_box.smallEnd(2); const int domain_khi = domain_box.bigEnd(2); auto extdir_lohi_z = has_extdir_or_ho(h_bcrec.data(), ncomp, static_cast(Direction::z)); - bool has_extdir_or_ho_lo_z = extdir_lohi_z.first; - bool has_extdir_or_ho_hi_z = extdir_lohi_z.second; + bool has_extdir_or_ho_lo_z = bc_arr ? true : extdir_lohi_z.first; + bool has_extdir_or_ho_hi_z = bc_arr ? true : extdir_lohi_z.second; #endif if ( (has_extdir_or_ho_lo_x && domain_ilo >= xebox.smallEnd(0)-1) || @@ -111,7 +113,7 @@ EBPLM::PredictStateOnXFace (Box const& xebox, int ncomp, // We have enough cells to do 4th order slopes centered on (i,j,k) with all values at cell centers if (vfrac(i,j,k) == 1. && vfrac(i-1,j,k) == 1. && vfrac(i-2,j,k) == 1. && - vfrac(i+1,j,k) == 1. && vfrac(i+2,j,k) == 1.) + vfrac(i+1,j,k) == 1. && vfrac(i+2,j,k) == 1.) { int order = 4; qpls = q(i,j,k,n) + Real(0.5) * (-Real(1.0) - umac(i,j,k,0) * dtdx) * @@ -391,17 +393,17 @@ EBPLM::PredictStateOnYFace ( Box const& yebox, int ncomp, auto extdir_lohi_x = has_extdir_or_ho(h_bcrec.data(), ncomp, static_cast(Direction::x)); auto extdir_lohi_y = has_extdir_or_ho(h_bcrec.data(), ncomp, static_cast(Direction::y)); - bool has_extdir_or_ho_lo_x = extdir_lohi_x.first; - bool has_extdir_or_ho_hi_x = extdir_lohi_x.second; - bool has_extdir_or_ho_lo_y = extdir_lohi_y.first; - bool has_extdir_or_ho_hi_y = extdir_lohi_y.second; + bool has_extdir_or_ho_lo_x = bc_arr ? true : extdir_lohi_x.first; + bool has_extdir_or_ho_hi_x = bc_arr ? true : extdir_lohi_x.second; + bool has_extdir_or_ho_lo_y = bc_arr ? true : extdir_lohi_y.first; + bool has_extdir_or_ho_hi_y = bc_arr ? true : extdir_lohi_y.second; #if (AMREX_SPACEDIM == 3) const int domain_klo = domain_box.smallEnd(2); const int domain_khi = domain_box.bigEnd(2); auto extdir_lohi_z = has_extdir_or_ho(h_bcrec.data(), ncomp, static_cast(Direction::z)); - bool has_extdir_or_ho_lo_z = extdir_lohi_z.first; - bool has_extdir_or_ho_hi_z = extdir_lohi_z.second; + bool has_extdir_or_ho_lo_z = bc_arr ? true : extdir_lohi_z.first; + bool has_extdir_or_ho_hi_z = bc_arr ? true : extdir_lohi_z.second; #endif if ( (has_extdir_or_ho_lo_x && domain_ilo >= yebox.smallEnd(0)-1) || @@ -731,12 +733,12 @@ EBPLM::PredictStateOnZFace ( Box const& zebox, int ncomp, auto extdir_lohi_y = has_extdir_or_ho(h_bcrec.data(), ncomp, static_cast(Direction::y)); auto extdir_lohi_z = has_extdir_or_ho(h_bcrec.data(), ncomp, static_cast(Direction::z)); - bool has_extdir_or_ho_lo_x = extdir_lohi_x.first; - bool has_extdir_or_ho_hi_x = extdir_lohi_x.second; - bool has_extdir_or_ho_lo_y = extdir_lohi_y.first; - bool has_extdir_or_ho_hi_y = extdir_lohi_y.second; - bool has_extdir_or_ho_lo_z = extdir_lohi_z.first; - bool has_extdir_or_ho_hi_z = extdir_lohi_z.second; + bool has_extdir_or_ho_lo_x = bc_arr ? true : extdir_lohi_x.first; + bool has_extdir_or_ho_hi_x = bc_arr ? true : extdir_lohi_x.second; + bool has_extdir_or_ho_lo_y = bc_arr ? true : extdir_lohi_y.first; + bool has_extdir_or_ho_hi_y = bc_arr ? true : extdir_lohi_y.second; + bool has_extdir_or_ho_lo_z = bc_arr ? true : extdir_lohi_z.first; + bool has_extdir_or_ho_hi_z = bc_arr ? true : extdir_lohi_z.second; if ( (has_extdir_or_ho_lo_x && domain_ilo >= zebox.smallEnd(0)-1) || (has_extdir_or_ho_hi_x && domain_ihi <= zebox.bigEnd(0) ) || diff --git a/Godunov/hydro_godunov_extrap_vel_to_faces_2D.cpp b/Godunov/hydro_godunov_extrap_vel_to_faces_2D.cpp index eb300ca79..343d15823 100644 --- a/Godunov/hydro_godunov_extrap_vel_to_faces_2D.cpp +++ b/Godunov/hydro_godunov_extrap_vel_to_faces_2D.cpp @@ -89,9 +89,9 @@ Godunov::ExtrapVelToFaces ( MultiFab const& a_vel, else { PLM::PredictVelOnXFace( Box(u_ad), AMREX_SPACEDIM, Imx, Ipx, vel, vel, - geom, l_dt, h_bcrec, d_bcrec); + geom, l_dt, h_bcrec, d_bcrec, bc_arr); PLM::PredictVelOnYFace( Box(v_ad), AMREX_SPACEDIM, Imy, Ipy, vel, vel, - geom, l_dt, h_bcrec, d_bcrec); + geom, l_dt, h_bcrec, d_bcrec, bc_arr); } ComputeAdvectiveVel( Box(u_ad), Box(v_ad), From 87ce4e57228033dccaf9ae99a0fa76e94e036bcd Mon Sep 17 00:00:00 2001 From: cgilet Date: Wed, 20 Mar 2024 14:11:13 -0400 Subject: [PATCH 2/2] Remove unused headers --- EBGodunov/hydro_ebgodunov_corner_couple.H | 2 -- Godunov/hydro_godunov_corner_couple.H | 2 -- 2 files changed, 4 deletions(-) diff --git a/EBGodunov/hydro_ebgodunov_corner_couple.H b/EBGodunov/hydro_ebgodunov_corner_couple.H index 1e3e24a42..ddc0e89b0 100644 --- a/EBGodunov/hydro_ebgodunov_corner_couple.H +++ b/EBGodunov/hydro_ebgodunov_corner_couple.H @@ -10,8 +10,6 @@ #include #include -#include -#include #include /* This header file contains the inlined __host__ __device__ functions required for diff --git a/Godunov/hydro_godunov_corner_couple.H b/Godunov/hydro_godunov_corner_couple.H index 950b78083..b630d9cd0 100644 --- a/Godunov/hydro_godunov_corner_couple.H +++ b/Godunov/hydro_godunov_corner_couple.H @@ -9,8 +9,6 @@ #define HYDRO_GODUNOV_CORNER_COUPLE_H #include -#include -#include #include #include #include