diff --git a/Source/BoundaryConditions/BoundaryConditions_cons.cpp b/Source/BoundaryConditions/BoundaryConditions_cons.cpp index befa578a..634938c0 100644 --- a/Source/BoundaryConditions/BoundaryConditions_cons.cpp +++ b/Source/BoundaryConditions/BoundaryConditions_cons.cpp @@ -45,9 +45,11 @@ void REMORAPhysBCFunct::impose_cons_bcs (const Array4& dest_arr, const Box GpuArray,AMREX_SPACEDIM+NCONS> l_bc_extdir_vals_d; - for (int i = 0; i < ncomp; i++) - for (int ori = 0; ori < 2*AMREX_SPACEDIM; ori++) + for (int i = 0; i < ncomp; i++) { + for (int ori = 0; ori < 2*AMREX_SPACEDIM; ori++) { l_bc_extdir_vals_d[i][ori] = m_bc_extdir_vals[bccomp+i][ori]; + } + } GeometryData const& geomdata = m_geom.data(); bool is_periodic_in_x = geomdata.isPeriodic(0); diff --git a/Source/Particles/TracerPC.H b/Source/Particles/TracerPC.H index c0d87d42..b1eab157 100644 --- a/Source/Particles/TracerPC.H +++ b/Source/Particles/TracerPC.H @@ -66,4 +66,32 @@ public: amrex::MultiFab& a_z_height); }; + template + AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE + void update_location_idata (P& p, + amrex::GpuArray const& plo, + amrex::GpuArray const& dxi, + const amrex::Array4& height_arr) + { + amrex::IntVect iv( int(amrex::Math::floor((p.pos(0)-plo[0])*dxi[0])), + int(amrex::Math::floor((p.pos(1)-plo[1])*dxi[1])), + p.idata(0) ); + + amrex::Real lx = (p.pos(0)-plo[0])*dxi[0] - static_cast(iv[0]); + amrex::Real ly = (p.pos(1)-plo[1])*dxi[1] - static_cast(iv[1]); + auto zlo = height_arr(iv[0] ,iv[1] ,iv[2] ) * (1.0-lx) * (1.0-ly) + + height_arr(iv[0]+1,iv[1] ,iv[2] ) * lx * (1.0-ly) + + height_arr(iv[0] ,iv[1]+1,iv[2] ) * (1.0-lx) * ly + + height_arr(iv[0]+1,iv[1]+1,iv[2] ) * lx * ly; + auto zhi = height_arr(iv[0] ,iv[1] ,iv[2]+1) * (1.0-lx) * (1.0-ly) + + height_arr(iv[0]+1,iv[1] ,iv[2]+1) * lx * (1.0-ly) + + height_arr(iv[0] ,iv[1]+1,iv[2]+1) * (1.0-lx) * ly + + height_arr(iv[0]+1,iv[1]+1,iv[2]+1) * lx * ly; + + if (p.pos(2) > zhi) { + p.idata(0) += 1; + } else if (p.pos(2) <= zlo) { + p.idata(0) -= 1; + } + } #endif diff --git a/Source/Particles/TracerPC.cpp b/Source/Particles/TracerPC.cpp index 70848846..48ba211c 100644 --- a/Source/Particles/TracerPC.cpp +++ b/Source/Particles/TracerPC.cpp @@ -135,7 +135,7 @@ TracerPC::AdvectWithUmac (Array umac, ParticleType& p = p_pbox[i]; if (p.id() <= 0) { return; } ParticleReal v[AMREX_SPACEDIM]; - mac_interpolate(p, plo, dxi, umacarr, v); + mac_interpolate_mapped_z(p, plo, dxi, umacarr, zheight, v); if (ipass == 0) { for (int dim=0; dim < AMREX_SPACEDIM; dim++) @@ -161,24 +161,15 @@ TracerPC::AdvectWithUmac (Array umac, iv[1] += domain.smallEnd()[1]; ParticleReal zlo, zhi; if (use_terrain) { - Real lx = (p.pos(0)-plo[0])*dxi[0] - static_cast(iv[0]-domain.smallEnd()[0]); - Real ly = (p.pos(1)-plo[1])*dxi[1] - static_cast(iv[1]-domain.smallEnd()[1]); - zlo = zheight(iv[0] ,iv[1] ,iv[2] ) * (1.0_rt-lx) * (1.0_rt-ly) + - zheight(iv[0]+1,iv[1] ,iv[2] ) * lx * (1.0_rt-ly) + - zheight(iv[0] ,iv[1]+1,iv[2] ) * (1.0_rt-lx) * ly + - zheight(iv[0]+1,iv[1]+1,iv[2] ) * lx * ly; - zhi = zheight(iv[0] ,iv[1] ,iv[2]+1) * (1.0_rt-lx) * (1.0_rt-ly) + - zheight(iv[0]+1,iv[1] ,iv[2]+1) * lx * (1.0_rt-ly) + - zheight(iv[0] ,iv[1]+1,iv[2]+1) * (1.0_rt-lx) * ly + - zheight(iv[0]+1,iv[1]+1,iv[2]+1) * lx * ly; + update_location_idata(p,plo,dxi,zheight); } else { zlo = iv[2] * dx[2]; zhi = (iv[2]+1) * dx[2]; - } - if (p.pos(2) > zhi) { // need to be careful here - p.idata(0) += 1; - } else if (p.pos(2) <= zlo) { - p.idata(0) -= 1; + if (p.pos(2) > zhi) { // need to be careful here + p.idata(0) += 1; + } else if (p.pos(2) <= zlo) { + p.idata(0) -= 1; + } } } }); diff --git a/Submodules/AMReX b/Submodules/AMReX index e0b77e1f..d121723c 160000 --- a/Submodules/AMReX +++ b/Submodules/AMReX @@ -1 +1 @@ -Subproject commit e0b77e1fce491021696d22f1496138e8d9942d65 +Subproject commit d121723c7491acedf8e2e010cfb1bf3773224b95