Skip to content

Commit

Permalink
fixes based on PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
asalmgren committed Mar 12, 2024
1 parent 7f7aa67 commit 61f0e38
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
2 changes: 2 additions & 0 deletions Src/AmrCore/AMReX_InterpFaceRegister.H
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ private:

Geometry m_crse_geom;

Box per_grown_domain;

Array<BoxArray, 2*AMREX_SPACEDIM> m_fine_face_ba;
Array<BoxArray, 2*AMREX_SPACEDIM> m_crse_face_ba;
Array<iMultiFab,2*AMREX_SPACEDIM> m_face_mask; // crse/fine: 1, fine/fine & fine/physbc: 0
Expand Down
10 changes: 5 additions & 5 deletions Src/AmrCore/AMReX_InterpFaceRegister.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ void InterpFaceRegister::define (BoxArray const& fba, DistributionMapping const&
m_crse_geom = amrex::coarsen(m_fine_geom, m_ref_ratio);

// We don't need to worry about face-based domain because this is only used in the tangential interpolation
Box per_grown_domain = m_crse_geom.Domain();
per_grown_domain = m_crse_geom.Domain();
for (int dim = 0; dim < AMREX_SPACEDIM; dim++) {
if (m_crse_geom.isPeriodic(dim)) {
per_grown_domain.grow(dim,1);
Expand All @@ -47,6 +47,7 @@ void InterpFaceRegister::define (BoxArray const& fba, DistributionMapping const&
#ifdef AMREX_USE_GPU
Vector<Array4BoxValTag<int> > tags;
#endif

#ifdef AMREX_USE_OMP
#pragma omp parallel if (Gpu::notInLaunchRegion())
#endif
Expand Down Expand Up @@ -99,7 +100,6 @@ namespace {
Array4<Real> slope;
Array4<Real const> crse;
Array4<int const> mask;
Box per_grown_domain;
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
Box box() const noexcept { return Box(mask); }
};
Expand Down Expand Up @@ -159,7 +159,7 @@ InterpFaceRegister::interp (Array<MultiFab*, AMREX_SPACEDIM> const& fine, // NOL
{
if (tag.mask(i,j,k)) {
interp_face_reg(AMREX_D_DECL(i,j,k), rr, tag.fine, scomp, tag.crse,
tag.slope, ncomp, tag.per_grown_domain, idim);
tag.slope, ncomp, per_grown_domain, idim);
}
});
} else
Expand Down Expand Up @@ -187,7 +187,7 @@ InterpFaceRegister::interp (Array<MultiFab*, AMREX_SPACEDIM> const& fine, // NOL
{
if (mlo_arr(i,j,k)) {
interp_face_reg(AMREX_D_DECL(i,j,k), rr, fine_arr, scomp, clo_arr,
slope_arr, ncomp, domlo, idim);
slope_arr, ncomp, per_grown_domain, idim);
}
});
slope.resize(hibx, ncomp);
Expand All @@ -196,7 +196,7 @@ InterpFaceRegister::interp (Array<MultiFab*, AMREX_SPACEDIM> const& fine, // NOL
{
if (mhi_arr(i,j,k)) {
interp_face_reg(AMREX_D_DECL(i,j,k), rr, fine_arr, scomp, chi_arr,
slope_arr, ncomp, domhi, idim);
slope_arr, ncomp, per_grown_domain, idim);
}
});
}
Expand Down
12 changes: 6 additions & 6 deletions Src/AmrCore/AMReX_Interp_C.H
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ face_cons_linear_face_interp (int i, int j, int k, int n, Array4<T> const& fine,
if (!mask || mask(ci, cj, ck, n)) {
fine(i, j, k, n) = crse(ci, cj, ck, n);
#if (AMREX_SPACEDIM >= 2)
if (cj != per_grown_domain.smallEnd(1) && cj != per_grown_domain.bigEnd(1) && ratio[1] > 1) {
if (cj > per_grown_domain.smallEnd(1) && cj < per_grown_domain.bigEnd(1) && ratio[1] > 1) {
Real sfy = Real(1.0);
Real dc = Real(0.5) * (crse(ci,cj+1,ck,n) - crse(ci,cj-1,ck,n));
Real df = Real(2.0) * (crse(ci,cj+1,ck,n) - crse(ci,cj ,ck,n));
Expand All @@ -131,7 +131,7 @@ face_cons_linear_face_interp (int i, int j, int k, int n, Array4<T> const& fine,
fine(i,j,k,n) += yoff * slope * sfy;
} // jc
#if (AMREX_SPACEDIM == 3)
if (ck != per_grown_domain.smallEnd(2) && ck != per_grown_domain.bigEnd(2) && ratio[2] > 1) {
if (ck > per_grown_domain.smallEnd(2) && ck < per_grown_domain.bigEnd(2) && ratio[2] > 1) {
Real sfz = Real(1.0);
Real dc = Real(0.5) * (crse(ci,cj,ck+1,n) - crse(ci,cj,ck-1,n));
Real df = Real(2.0) * (crse(ci,cj,ck+1,n) - crse(ci,cj,ck ,n));
Expand All @@ -156,7 +156,7 @@ face_cons_linear_face_interp (int i, int j, int k, int n, Array4<T> const& fine,
// Check solve mask to ensure we don't overwrite valid fine data.
if (!mask || mask(ci, cj, ck, n)) {
fine(i, j, k, n) = crse(ci, cj, ck, n);
if (ci != per_grown_domain.smallEnd(0) && ci != per_grown_domain.bigEnd(0) && ratio[0] > 1) {
if (ci > per_grown_domain.smallEnd(0) && ci < per_grown_domain.bigEnd(0) && ratio[0] > 1) {
Real sfx = Real(1.0);
Real dc = Real(0.5) * (crse(ci+1,cj,ck,n) - crse(ci-1,cj,ck,n));
Real df = Real(2.0) * (crse(ci+1,cj,ck,n) - crse(ci ,cj,ck,n));
Expand All @@ -172,7 +172,7 @@ face_cons_linear_face_interp (int i, int j, int k, int n, Array4<T> const& fine,
fine(i,j,k,n) += xoff * slope * sfx;
} // ci
#if (AMREX_SPACEDIM == 3)
if (ck != per_grown_domain.smallEnd(2) && ck != per_grown_domain.bigEnd(2) && ratio[2] > 1) {
if (ck > per_grown_domain.smallEnd(2) && ck < per_grown_domain.bigEnd(2) && ratio[2] > 1) {
Real sfz = Real(1.0);
Real dc = Real(0.5) * (crse(ci,cj,ck+1,n) - crse(ci,cj,ck-1,n));
Real df = Real(2.0) * (crse(ci,cj,ck+1,n) - crse(ci,cj,ck ,n));
Expand All @@ -197,7 +197,7 @@ face_cons_linear_face_interp (int i, int j, int k, int n, Array4<T> const& fine,
// Check solve mask to ensure we don't overwrite valid fine data.
if (!mask || mask(ci, cj, ck, n)) {
fine(i, j, k, n) = crse(ci, cj, ck, n);
if (ci != per_grown_domain.smallEnd(0) && ci != per_grown_domain.bigEnd(0) && ratio[0] > 1) {
if (ci > per_grown_domain.smallEnd(0) && ci < per_grown_domain.bigEnd(0) && ratio[0] > 1) {
Real sfx = Real(1.0);
Real dc = Real(0.5) * (crse(ci+1,cj,ck,n) - crse(ci-1,cj,ck,n));
Real df = Real(2.0) * (crse(ci+1,cj,ck,n) - crse(ci ,cj,ck,n));
Expand All @@ -212,7 +212,7 @@ face_cons_linear_face_interp (int i, int j, int k, int n, Array4<T> const& fine,
Real xoff = (static_cast<Real>(i - ci*ratio[0]) + Real(0.5)) / Real(ratio[0]) - Real(0.5);
fine(i,j,k,n) += xoff * slope * sfx;
} // ci
if (cj != per_grown_domain.smallEnd(1) && cj != per_grown_domain.bigEnd(1) && ratio[1] > 1) {
if (cj > per_grown_domain.smallEnd(1) && cj < per_grown_domain.bigEnd(1) && ratio[1] > 1) {
Real sfy = Real(1.0);
Real dc = Real(0.5) * (crse(ci,cj+1,ck,n) - crse(ci,cj-1,ck,n));
Real df = Real(2.0) * (crse(ci,cj+1,ck,n) - crse(ci,cj ,ck,n));
Expand Down
1 change: 0 additions & 1 deletion Src/AmrCore/AMReX_Interpolater.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,6 @@ FaceConservativeLinear::CoarseBox (const Box& fine, const IntVect& ratio)

for (int i = 0; i < AMREX_SPACEDIM; i++) {
if (b.type(i) == IndexType::NODE) {
ng[i] = 0;
if (b.type(i) == IndexType::NODE && b.length(i) < 2) {
// Don't want degenerate boxes in nodal direction.
b.growHi(i,1);
Expand Down

0 comments on commit 61f0e38

Please sign in to comment.