Skip to content

Commit

Permalink
Fix bug in #137 (#138)
Browse files Browse the repository at this point in the history
We do need alias fab in the EB case because dm_as_fine starts with component
0.
  • Loading branch information
WeiqunZhang authored Jul 5, 2023
1 parent 8bbcc4d commit 0f349d2
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions Source/NavierStokesBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5212,24 +5212,24 @@ NavierStokesBase::ComputeAofs ( MultiFab& advc, int a_comp, // Advection term "A
}
}

AMREX_D_TERM( const auto& fx_fr_fab = cfluxes[0][mfi];,
const auto& fy_fr_fab = cfluxes[1][mfi];,
const auto& fz_fr_fab = cfluxes[2][mfi];);
AMREX_D_TERM(FArrayBox fx_fr_fab(fx_fab,amrex::make_alias,flux_comp,ncomp);,
FArrayBox fy_fr_fab(fy_fab,amrex::make_alias,flux_comp,ncomp);,
FArrayBox fz_fr_fab(fz_fab,amrex::make_alias,flux_comp,ncomp););

// Now update the flux registers (inside test on AMREX_USE_EB)
if ( do_reflux && do_crse_add && (level < parent->finestLevel()) ) {
if (flagfab.getType(amrex::grow(bx,1)) == FabType::regular)
{
getAdvFluxReg(level+1).CrseAdd(mfi,
{AMREX_D_DECL(&fx_fr_fab,&fy_fr_fab,&fz_fr_fab)},
dxDp, dt, flux_comp, state_indx, ncomp, amrex::RunOn::Device);
dxDp, dt, 0, state_indx, ncomp, amrex::RunOn::Device);

} else if (flagfab.getType(bx) != FabType::covered ) {
getAdvFluxReg(level + 1).CrseAdd(mfi,
{AMREX_D_DECL(&fx_fr_fab,&fy_fr_fab,&fz_fr_fab)},
dxDp, dt, (*volfrac)[mfi],
{AMREX_D_DECL(&(*areafrac[0])[mfi], &(*areafrac[1])[mfi], &(*areafrac[2])[mfi])},
flux_comp, state_indx, ncomp, amrex::RunOn::Device);
0, state_indx, ncomp, amrex::RunOn::Device);
}
} // do_reflux && level < finest_level

Expand All @@ -5245,21 +5245,17 @@ NavierStokesBase::ComputeAofs ( MultiFab& advc, int a_comp, // Advection term "A
{
advflux_reg->FineAdd(mfi,
{AMREX_D_DECL(&fx_fr_fab,&fy_fr_fab,&fz_fr_fab)},
dxDp, sync_factor*dt, flux_comp, state_indx, ncomp, amrex::RunOn::Device);
dxDp, sync_factor*dt, 0, state_indx, ncomp, amrex::RunOn::Device);
} else if (flagfab.getType(bx) != FabType::covered ) {
advflux_reg->FineAdd(mfi,
{AMREX_D_DECL(&fx_fr_fab,&fy_fr_fab,&fz_fr_fab)},
dxDp, sync_factor*dt, (*volfrac)[mfi],
{AMREX_D_DECL(&(*areafrac[0])[mfi], &(*areafrac[1])[mfi], &(*areafrac[2])[mfi])},
dm_as_fine, flux_comp, state_indx, ncomp, amrex::RunOn::Device);
dm_as_fine, 0, state_indx, ncomp, amrex::RunOn::Device);
}
} // do_reflux && (level > 0)
} // not covered
#else
AMREX_D_TERM( const auto& fx_fr_fab = cfluxes[0][mfi];,
const auto& fy_fr_fab = cfluxes[1][mfi];,
const auto& fz_fr_fab = cfluxes[2][mfi];);

// This is a hack-y way of testing whether this ComputeAofs call
// came from the mac_sync (do_crse_add = false)
// or from the regular advance (do_crse_add = true). When the call
Expand All @@ -5270,13 +5266,13 @@ NavierStokesBase::ComputeAofs ( MultiFab& advc, int a_comp, // Advection term "A
// Update the flux registers when no EB
if ( do_reflux && (level < parent->finestLevel()) ) {
getAdvFluxReg(level+1).CrseAdd(mfi,
{AMREX_D_DECL(&fx_fr_fab,&fy_fr_fab,&fz_fr_fab)},
{AMREX_D_DECL(&fx_fab,&fy_fab,&fz_fab)},
dxDp, sync_factor*dt, flux_comp, state_indx, ncomp, amrex::RunOn::Device);
} // do_reflux && level < finest_level

if ( do_reflux && (level > 0) ) {
advflux_reg->FineAdd(mfi,
{AMREX_D_DECL(&fx_fr_fab,&fy_fr_fab,&fz_fr_fab)},
{AMREX_D_DECL(&fx_fab,&fy_fab,&fz_fab)},
dxDp, sync_factor*dt, flux_comp, state_indx, ncomp, amrex::RunOn::Device);
} // do_reflux && (level > 0)
#endif
Expand Down

0 comments on commit 0f349d2

Please sign in to comment.