Skip to content

Commit

Permalink
Update FluxRedist and comments for StateItracker
Browse files Browse the repository at this point in the history
  • Loading branch information
asalmgren committed Aug 4, 2023
1 parent 6e5cb92 commit 3a16101
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 17 deletions.
17 changes: 9 additions & 8 deletions Src/EB/AMReX_EB_FluxRedistribute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ amrex_flux_redistribute (
amrex::Abort("apply_eb_redistribution(): grid spacing must be uniform");
}

const Box dbox = geom.growPeriodicDomain(2);
const Box dbox1 = geom.growPeriodicDomain(1);
const Box dbox2 = geom.growPeriodicDomain(2);

const Box& grown1_bx = amrex::grow(bx,1);
const Box& grown2_bx = amrex::grow(bx,2);

Expand Down Expand Up @@ -75,10 +77,9 @@ amrex_flux_redistribute (
//
AMREX_FOR_3D(grown2_bx, i, j, k,
{
mask(i,j,k) = (dbox.contains(IntVect(AMREX_D_DECL(i,j,k)))) ? 1.0 : 0.0;
mask(i,j,k) = (dbox2.contains(IntVect(AMREX_D_DECL(i,j,k)))) ? 1.0 : 0.0;
});

//LOOK AT THIS
//
// Init to zero tmp array
//
Expand Down Expand Up @@ -107,7 +108,7 @@ amrex_flux_redistribute (
for (int jj = -1; jj <= 1; jj++) {
for (int ii = -1; ii <= 1; ii++) {
if ( (ii != 0 || jj != 0 || kk != 0) && flag(i,j,k).isConnected(ii,jj,kk) &&
dbox.contains(IntVect(AMREX_D_DECL(i+ii,j+jj,k+kk))))
dbox2.contains(IntVect(AMREX_D_DECL(i+ii,j+jj,k+kk))))
{
Real wted_frac = vfrac(i+ii,j+jj,k+kk) * wt(i+ii,j+jj,k+kk) * mask(i+ii,j+jj,k+kk);
vtot += wted_frac;
Expand Down Expand Up @@ -142,7 +143,7 @@ amrex_flux_redistribute (
for (int jj = -1; jj <= 1; jj++) {
for (int ii = -1; ii <= 1; ii++) {
if ( (ii != 0 || jj != 0 || kk != 0) && flag(i,j,k).isConnected(ii,jj,kk) &&
dbox.contains(IntVect(AMREX_D_DECL(i+ii,j+jj,k+kk))))
dbox2.contains(IntVect(AMREX_D_DECL(i+ii,j+jj,k+kk))))
{
Real unwted_frac = vfrac(i+ii,j+jj,k+kk) * mask(i+ii,j+jj,k+kk);
vtot += unwted_frac;
Expand Down Expand Up @@ -219,7 +220,7 @@ amrex_flux_redistribute (
( (i >= bx_ilo) && (i <= bx_ihi) && (j >= bx_jlo) && (j <= bx_jhi) && (k >= bx_klo) && (k <= bx_khi) );
#endif
if (inside) { as_fine_valid_cell = true; }
as_fine_ghost_cell = (levmsk(i,j,k) == level_mask_not_covered); // not covered by other grids
as_fine_ghost_cell = (levmsk(i,j,k) == level_mask_not_covered); // not covered by other grids at this level
}

#if (AMREX_SPACEDIM == 2)
Expand Down Expand Up @@ -264,12 +265,12 @@ amrex_flux_redistribute (
}
}

if (as_fine_valid_cell && !valid_dst_cell)
if (as_fine_valid_cell && !valid_dst_cell && dbox1.contains(IntVect(AMREX_D_DECL(iii,jjj,kkk))))
{
Gpu::Atomic::Add(&dm_as_fine(iii,jjj,kkk,n), dt*drho*vfrac(iii,jjj,kkk));
}

if (as_fine_ghost_cell && valid_dst_cell)
if (as_fine_ghost_cell && valid_dst_cell && dbox1.contains(IntVect(AMREX_D_DECL(i,j,k))))
{
Gpu::Atomic::Add(&dm_as_fine(i,j,k,n), -dt*drho*vfrac(iii,jjj,kkk));
}
Expand Down
21 changes: 12 additions & 9 deletions Src/EB/AMReX_EB_StateRedistItracker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,17 @@ MakeITracker ( Box const& bx,

const Box domain = lev_geom.Domain();

// Note that itracker has 4 components and all are initialized to zero
// We will add to the first component every time this cell is included in a merged neighborhood,
// either by merging or being merged
// We identify the cells in the remaining three components with the following ordering
// Note that itracker has 4 components -- the first component stores the
// number of neighbors and each additional component stores where that neighbor is
//
// We identify the neighbors with the following ordering
//
// ^ 6 7 8
// | 4 5
// j 1 2 3
// i --->

// Note the first component of imap/jmap should never be used
Array<int,9> imap{0,-1,0,1,-1,1,-1,0,1};
Array<int,9> jmap{0,-1,-1,-1,0,0,1,1,1};

Expand Down Expand Up @@ -241,10 +242,10 @@ MakeITracker ( Box const& bx,

const Box domain = lev_geom.Domain();

// Note that itracker has 8 components and all are initialized to zero
// We will add to the first component every time this cell is included in a merged neighborhood,
// either by merging or being merged
// We identify the cells in the remaining three components with the following ordering
// Note that itracker has 8 components -- the first component stores the
// number of neighbors and each additional component stores where that neighbor is
//
// We identify the neighbors with the following ordering
//
// at k-1 | at k | at k+1
//
Expand All @@ -253,7 +254,7 @@ MakeITracker ( Box const& bx,
// j 9 10 11 | 1 2 3 | 18 19 20
// i --->
//
// Note the first component of each of these arrays should never be used
// Note the first component of imap/jmap/kmap should never be used
Array<int,27> imap{0,-1, 0, 1,-1, 1,-1, 0, 1,-1, 0, 1,-1, 0, 1,-1, 0, 1,-1, 0, 1,-1, 0, 1,-1, 0, 1};
Array<int,27> jmap{0,-1,-1,-1, 0, 0, 1, 1, 1,-1,-1,-1, 0, 0, 0, 1, 1, 1,-1,-1,-1, 0, 0, 0, 1, 1, 1};
Array<int,27> kmap{0, 0, 0, 0, 0, 0, 0, 0, 0,-1,-1,-1,-1,-1,-1,-1,-1,-1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
Expand Down Expand Up @@ -331,6 +332,7 @@ MakeITracker ( Box const& bx,
} else {
itracker(i,j,k,1) = 2;
}

// z-component of normal is greatest
} else {
if (nz > 0) {
Expand Down Expand Up @@ -571,6 +573,7 @@ MakeITracker ( Box const& bx,
} else {
itracker(i,j,k,7) = 18;
}

} else { // nz <= 0

itracker(i,j,k,4) = 13;
Expand Down

0 comments on commit 3a16101

Please sign in to comment.