Skip to content

Commit

Permalink
pass BCVar into FillPatch rather than inferring it
Browse files Browse the repository at this point in the history
  • Loading branch information
hklion committed Aug 27, 2024
1 parent 896b239 commit ba75622
Show file tree
Hide file tree
Showing 13 changed files with 55 additions and 56 deletions.
8 changes: 4 additions & 4 deletions Exec/IdealMiniGrid/inputs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ geometry.is_periodic = 0 0 0
zlo.type = "SlipWall"
zhi.type = "SlipWall"

xlo.type = "outflow"
xhi.type = "outflow"
ylo.type = "outflow"
yhi.type = "outflow"
xlo.type = "clamped"
xhi.type = "clamped"
ylo.type = "clamped"
yhi.type = "clamped"

# TIME STEP CONTROL
remora.fixed_dt = 200.0 # Timestep size (seconds)
Expand Down
6 changes: 1 addition & 5 deletions Source/BoundaryConditions/REMORA_FillPatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ PhysBCFunctNoOp null_bc;
//
void
REMORA::FillPatch (int lev, Real time, MultiFab& mf_to_fill, Vector<MultiFab*> const& mfs,
const int bccomp,
#ifdef REMORA_USE_NETCDF
const int bdy_var_type,
#else
Expand All @@ -25,7 +26,6 @@ REMORA::FillPatch (int lev, Real time, MultiFab& mf_to_fill, Vector<MultiFab*> c
const int n_not_fill)
{
BL_PROFILE_VAR("REMORA::FillPatch()",REMORA_FillPatch);
int bccomp;
amrex::Interpolater* mapper = nullptr;

Box mf_box(mf_to_fill.boxArray()[0]);
Expand Down Expand Up @@ -72,24 +72,20 @@ REMORA::FillPatch (int lev, Real time, MultiFab& mf_to_fill, Vector<MultiFab*> c

if (mf_box.ixType() == IndexType(IntVect(0,0,0)))
{
bccomp = 0;
mapper = &cell_cons_interp;
mask = vec_mskr[lev].get();
}
else if (mf_box.ixType() == IndexType(IntVect(1,0,0)))
{
bccomp = BCVars::xvel_bc;
mapper = &face_linear_interp;
mask = vec_msku[lev].get();
}
else if (mf_box.ixType() == IndexType(IntVect(0,1,0)))
{
bccomp = BCVars::yvel_bc;
mapper = &face_linear_interp;
mask = vec_mskv[lev].get();
}
else {
bccomp = BCVars::zvel_bc;
mapper = &face_linear_interp;
mask = vec_mskr[lev].get();
}
Expand Down
8 changes: 4 additions & 4 deletions Source/IO/Checkpoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ REMORA::WriteCheckpointFile ()
// should be necessary and could instead be replaced by a FillPatch in a more natural
// location
for (int lev = 0; lev <= finest_level; ++lev) {
FillPatch(lev, t_new[lev], *cons_new[lev], cons_new, BdyVars::t,0,true,false);
FillPatch(lev, t_new[lev], *xvel_new[lev], xvel_new, BdyVars::u,0,true,false);
FillPatch(lev, t_new[lev], *yvel_new[lev], yvel_new, BdyVars::v,0,true,false);
FillPatch(lev, t_new[lev], *zvel_new[lev], zvel_new, BdyVars::null,0,true,false);
FillPatch(lev, t_new[lev], *cons_new[lev], cons_new, BCVars::cons_bc, BdyVars::t, 0,true,false);
FillPatch(lev, t_new[lev], *xvel_new[lev], xvel_new, BCVars::xvel_bc, BdyVars::u, 0,true,false);
FillPatch(lev, t_new[lev], *yvel_new[lev], yvel_new, BCVars::yvel_bc, BdyVars::v, 0,true,false);
FillPatch(lev, t_new[lev], *zvel_new[lev], zvel_new, BCVars::zvel_bc, BdyVars::null,0,true,false);
}

// chk00010 write a checkpoint file with this root directory
Expand Down
1 change: 1 addition & 0 deletions Source/Initialization/REMORA_init_from_netcdf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ REMORA::init_bathymetry_from_netcdf (int lev)

const double dummy_time = 0.0_rt;
FillPatch(lev,dummy_time,*vec_hOfTheConfusingName[lev],GetVecOfPtrs(vec_hOfTheConfusingName),
BCVars::cons_bc,
BdyVars::null,0,true,true,1);

int ng = vec_pm[lev]->nGrow();
Expand Down
29 changes: 15 additions & 14 deletions Source/Initialization/REMORA_make_new_level.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,23 +157,24 @@ REMORA::RemakeLevel (int lev, Real time, const BoxArray& ba, const DistributionM
init_masks(lev, ba, dm);

// This will fill the temporary MultiFabs with data from previous fine data as well as coarse where needed
FillPatch(lev, time, tmp_cons_new, cons_new, BdyVars::t,0,true,false);
FillPatch(lev, time, tmp_xvel_new, xvel_new, BdyVars::u,0,true,false);
FillPatch(lev, time, tmp_yvel_new, yvel_new, BdyVars::v,0,true,false);
FillPatch(lev, time, tmp_zvel_new, zvel_new, BdyVars::null,0,true,false);

FillPatch(lev, time, tmp_h, GetVecOfPtrs(vec_hOfTheConfusingName), BdyVars::null,0,false,false);
FillPatch(lev, time, tmp_h, GetVecOfPtrs(vec_hOfTheConfusingName), BdyVars::null,1,false,false);
FillPatch(lev, time, tmp_Zt_avg1_new, GetVecOfPtrs(vec_Zt_avg1), BdyVars::null,0,true,false);
FillPatch(lev, time, tmp_cons_new, cons_new, BCVars::cons_bc, BdyVars::t,0,true,false);
FillPatch(lev, time, tmp_xvel_new, xvel_new, BCVars::xvel_bc, BdyVars::u,0,true,false);
FillPatch(lev, time, tmp_yvel_new, yvel_new, BCVars::yvel_bc, BdyVars::v,0,true,false);
FillPatch(lev, time, tmp_zvel_new, zvel_new, BCVars::zvel_bc, BdyVars::null,0,true,false);

FillPatch(lev, time, tmp_h, GetVecOfPtrs(vec_hOfTheConfusingName), BCVars::cons_bc, BdyVars::null,0,false,false);
FillPatch(lev, time, tmp_h, GetVecOfPtrs(vec_hOfTheConfusingName), BCVars::cons_bc, BdyVars::null,1,false,false);
FillPatch(lev, time, tmp_Zt_avg1_new, GetVecOfPtrs(vec_Zt_avg1), BCVars::cons_bc, BdyVars::null,0,true,false);
for (int icomp=0; icomp<3; icomp++) {
FillPatch(lev, time, tmp_ubar_new, GetVecOfPtrs(vec_ubar), BdyVars::ubar, icomp,false,false);
FillPatch(lev, time, tmp_vbar_new, GetVecOfPtrs(vec_vbar), BdyVars::vbar, icomp,false,false);
FillPatch(lev, time, tmp_ubar_new, GetVecOfPtrs(vec_ubar), BCVars::ubar_bc, BdyVars::ubar, icomp,false,false);
FillPatch(lev, time, tmp_vbar_new, GetVecOfPtrs(vec_vbar), BCVars::vbar_bc, BdyVars::vbar, icomp,false,false);
}
for (int icomp=0; icomp<2; icomp++) {
FillPatch(lev, time, tmp_ru_new, GetVecOfPtrs(vec_ru), BdyVars::null, icomp,false,false);
FillPatch(lev, time, tmp_rv_new, GetVecOfPtrs(vec_rv), BdyVars::null, icomp,false,false);
FillPatch(lev, time, tmp_ru2d_new, GetVecOfPtrs(vec_ru2d), BdyVars::null, icomp,false,false);
FillPatch(lev, time, tmp_rv2d_new, GetVecOfPtrs(vec_rv2d), BdyVars::null, icomp,false,false);
FillPatch(lev, time, tmp_ru_new, GetVecOfPtrs(vec_ru),BCVars::xvel_bc, BdyVars::null, icomp,false,false);
FillPatch(lev, time, tmp_rv_new, GetVecOfPtrs(vec_rv),BCVars::yvel_bc, BdyVars::null, icomp,false,false);
// These might want to have BCVars::ubar_bc and vbar_bc
FillPatch(lev, time, tmp_ru2d_new, GetVecOfPtrs(vec_ru2d),BCVars::xvel_bc, BdyVars::null, icomp,false,false);
FillPatch(lev, time, tmp_rv2d_new, GetVecOfPtrs(vec_rv2d),BCVars::yvel_bc, BdyVars::null, icomp,false,false);
}

MultiFab::Copy(tmp_cons_old,tmp_cons_new,0,0,NCONS,tmp_cons_new.nGrowVect());
Expand Down
1 change: 1 addition & 0 deletions Source/REMORA.H
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,7 @@ public:
void FillPatch (int lev, amrex::Real time,
amrex::MultiFab& mf_to_be_filled,
amrex::Vector<amrex::MultiFab*> const& mfs,
const int bccomp,
const int bdy_var_type = BdyVars::null,
const int icomp=0,
const bool fill_all=true,
Expand Down
20 changes: 10 additions & 10 deletions Source/REMORA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,10 +287,10 @@ REMORA::InitData ()
Construct_REMORAFillPatchers(lev);
}

FillPatch(lev, t_new[lev], *cons_new[lev], cons_new, BdyVars::t, 0, true, false);
FillPatch(lev, t_new[lev], *xvel_new[lev], xvel_new, BdyVars::u, 0, true, false);
FillPatch(lev, t_new[lev], *yvel_new[lev], yvel_new, BdyVars::v, 0, true, false);
FillPatch(lev, t_new[lev], *zvel_new[lev], zvel_new, BdyVars::null, 0, true, false);
FillPatch(lev, t_new[lev], *cons_new[lev], cons_new, BCVars::cons_bc, BdyVars::t, 0, true, false);
FillPatch(lev, t_new[lev], *xvel_new[lev], xvel_new, BCVars::xvel_bc, BdyVars::u, 0, true, false);
FillPatch(lev, t_new[lev], *yvel_new[lev], yvel_new, BCVars::yvel_bc, BdyVars::v, 0, true, false);
FillPatch(lev, t_new[lev], *zvel_new[lev], zvel_new, BCVars::zvel_bc, BdyVars::null, 0, true, false);

if (restart_chkfile == "") {
// Copy from new into old just in case when initializing from scratch
Expand Down Expand Up @@ -541,7 +541,7 @@ REMORA::set_coriolis(int lev) {
}

Real time = 0.0_rt;
FillPatch(lev, time, *vec_fcor[lev], GetVecOfPtrs(vec_fcor));
FillPatch(lev, time, *vec_fcor[lev], GetVecOfPtrs(vec_fcor),BCVars::cons_bc);
}
}

Expand All @@ -563,9 +563,9 @@ void
REMORA::set_analytical_vmix(int lev) {
Real time = 0.0_rt;
init_custom_vmix(geom[lev], *vec_Akv[lev], *vec_Akt[lev], *vec_z_w[lev], solverChoice);
FillPatch(lev, time, *vec_Akv[lev], GetVecOfPtrs(vec_Akv),BdyVars::null,0,true,false);
FillPatch(lev, time, *vec_Akv[lev], GetVecOfPtrs(vec_Akv),BCVars::zvel_bc,BdyVars::null,0,true,false);
for (int n=0; n<NCONS;n++) {
FillPatch(lev, time, *vec_Akt[lev], GetVecOfPtrs(vec_Akt),BdyVars::null,0,false,false);
FillPatch(lev, time, *vec_Akt[lev], GetVecOfPtrs(vec_Akt),BCVars::zvel_bc,BdyVars::null,0,false,false);
}
}

Expand All @@ -575,9 +575,9 @@ REMORA::set_hmixcoef(int lev)
init_custom_hmix(geom[lev], *vec_visc2_p[lev], *vec_visc2_r[lev], *vec_diff2[lev], solverChoice);

Real time = 0.0_rt;
FillPatch(lev, time, *vec_visc2_p[lev], GetVecOfPtrs(vec_visc2_p));
FillPatch(lev, time, *vec_visc2_r[lev], GetVecOfPtrs(vec_visc2_r));
FillPatch(lev, time, *vec_diff2[lev] , GetVecOfPtrs(vec_diff2));
FillPatch(lev, time, *vec_visc2_p[lev], GetVecOfPtrs(vec_visc2_p),BCVars::cons_bc);
FillPatch(lev, time, *vec_visc2_r[lev], GetVecOfPtrs(vec_visc2_r),BCVars::cons_bc);
FillPatch(lev, time, *vec_diff2[lev] , GetVecOfPtrs(vec_diff2),BCVars::cons_bc);
}

void
Expand Down
6 changes: 3 additions & 3 deletions Source/TimeIntegration/REMORA_TimeStepML.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,9 @@ REMORA::timeStepML (Real time, int /*iteration*/)
FPr_w[lev].RegisterCoarseData({zvel_old[lev], zvel_new[lev]}, {time, time + dt[lev]});
}
}
FillPatch(lev, t_new[lev], *xvel_new[lev], xvel_new, BdyVars::u,0,true,true);
FillPatch(lev, t_new[lev], *yvel_new[lev], yvel_new, BdyVars::v,0,true,true);
FillPatch(lev, t_new[lev], *zvel_new[lev], zvel_new, BdyVars::null,0,true,true);
FillPatch(lev, t_new[lev], *xvel_new[lev], xvel_new, BCVars::xvel_bc, BdyVars::u,0,true,true);
FillPatch(lev, t_new[lev], *yvel_new[lev], yvel_new, BCVars::yvel_bc, BdyVars::v,0,true,true);
FillPatch(lev, t_new[lev], *zvel_new[lev], zvel_new, BCVars::zvel_bc, BdyVars::null,0,true,true);
}

scale_rhs_vars_inv();
Expand Down
6 changes: 3 additions & 3 deletions Source/TimeIntegration/REMORA_advance_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -733,11 +733,11 @@ REMORA::advance_2d (int lev,
// Don't do the FillPatch at the last truncated predictor step.
// We may need to move the zeta FillPatch further up
if (my_iif<nfast) {
FillPatch(lev, t_old[lev], *vec_ubar[lev], GetVecOfPtrs(vec_ubar), BdyVars::ubar,
FillPatch(lev, t_old[lev], *vec_ubar[lev], GetVecOfPtrs(vec_ubar), BCVars::ubar_bc, BdyVars::ubar,
knew, false,true);
FillPatch(lev, t_old[lev], *vec_vbar[lev], GetVecOfPtrs(vec_vbar), BdyVars::vbar,
FillPatch(lev, t_old[lev], *vec_vbar[lev], GetVecOfPtrs(vec_vbar), BCVars::vbar_bc, BdyVars::vbar,
knew, false,true);
FillPatch(lev, t_old[lev], *vec_zeta[lev], GetVecOfPtrs(vec_zeta), BdyVars::zeta,
FillPatch(lev, t_old[lev], *vec_zeta[lev], GetVecOfPtrs(vec_zeta), BCVars::zeta_bc, BdyVars::zeta,
knew, false,false);
}
}
2 changes: 1 addition & 1 deletion Source/TimeIntegration/REMORA_advance_3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ REMORA::advance_3d (int lev, MultiFab& mf_cons,

} // mfi

FillPatch(lev, t_old[lev], mf_cons, cons_new, BdyVars::t);
FillPatch(lev, t_old[lev], mf_cons, cons_new, BCVars::cons_bc, BdyVars::t);

for ( MFIter mfi(mf_cons, TilingIfNotGPU()); mfi.isValid(); ++mfi )
{
Expand Down
12 changes: 6 additions & 6 deletions Source/TimeIntegration/REMORA_advance_3d_ml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ void REMORA::advance_3d_ml (int lev, Real dt_lev)
{
// Fill in three ways: 1) interpolate from coarse grid if lev > 0; 2) fill from physical boundaries;
// 3) fine-fine fill of ghost cells with FillBoundary call
FillPatch(lev, t_old[lev], *cons_new[lev], cons_new, BdyVars::t);
FillPatch(lev, t_old[lev], *cons_new[lev], cons_new, BCVars::cons_bc, BdyVars::t);
xvel_new[lev]->FillBoundary(geom[lev].periodicity());
yvel_new[lev]->FillBoundary(geom[lev].periodicity());
FillPatch(lev, t_old[lev], *zvel_new[lev], zvel_new, BdyVars::null);
FillPatch(lev, t_old[lev], *zvel_new[lev], zvel_new, BCVars::zvel_bc, BdyVars::null);

FillPatch(lev, t_old[lev], *vec_sstore[lev], GetVecOfPtrs(vec_sstore), BdyVars::t);
FillPatch(lev, t_old[lev], *vec_sstore[lev], GetVecOfPtrs(vec_sstore), BCVars::cons_bc, BdyVars::t);

auto N = Geom(lev).Domain().size()[2]-1; // Number of vertical "levs" aka, NZ

Expand All @@ -35,16 +35,16 @@ void REMORA::advance_3d_ml (int lev, Real dt_lev)
FillPatchNoBC(lev, t_old[lev], *vec_vbar[lev], GetVecOfPtrs(vec_vbar), BdyVars::vbar,1,false,false);
FillPatchNoBC(lev, t_old[lev], *vec_ubar[lev], GetVecOfPtrs(vec_ubar), BdyVars::ubar,2,false,false);
FillPatchNoBC(lev, t_old[lev], *vec_vbar[lev], GetVecOfPtrs(vec_vbar), BdyVars::vbar,2,false,false);
FillPatch(lev, t_old[lev], *vec_sstore[lev], GetVecOfPtrs(vec_sstore), BdyVars::t);
FillPatch(lev, t_old[lev], *vec_sstore[lev], GetVecOfPtrs(vec_sstore), BCVars::cons_bc, BdyVars::t);


// Fill in three ways: 1) interpolate from coarse grid if lev > 0; 2) fill from physical boundaries;
// 3) fine-fine fill of ghost cells with FillBoundary call
// Note that we need the fine-fine and physical bc's in order to correctly move the particles
FillPatch(lev, t_old[lev], *cons_new[lev], cons_new, BdyVars::t);
FillPatch(lev, t_old[lev], *cons_new[lev], cons_new, BCVars::cons_bc, BdyVars::t);
xvel_new[lev]->FillBoundary(geom[lev].periodicity());
yvel_new[lev]->FillBoundary(geom[lev].periodicity());
FillPatch(lev, t_old[lev], *zvel_new[lev], zvel_new, BdyVars::null);
FillPatch(lev, t_old[lev], *zvel_new[lev], zvel_new, BCVars::zvel_bc, BdyVars::null);

// Apply land/sea mask to tracers
for ( MFIter mfi(*cons_new[lev], TilingIfNotGPU()); mfi.isValid(); ++mfi )
Expand Down
10 changes: 5 additions & 5 deletions Source/TimeIntegration/REMORA_gls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,8 @@ REMORA::gls_prestep (int lev, MultiFab* mf_gls, MultiFab* mf_tke,
}

for (int icomp=0; icomp<3; icomp++) {
FillPatch(lev, t_old[lev], *vec_tke[lev], GetVecOfPtrs(vec_tke), BdyVars::null, icomp, false, false);
FillPatch(lev, t_old[lev], *vec_gls[lev], GetVecOfPtrs(vec_gls), BdyVars::null, icomp, false, false);
FillPatch(lev, t_old[lev], *vec_tke[lev], GetVecOfPtrs(vec_tke), BCVars::zvel_bc, BdyVars::null, icomp, false, false);
FillPatch(lev, t_old[lev], *vec_gls[lev], GetVecOfPtrs(vec_gls), BCVars::zvel_bc, BdyVars::null, icomp, false, false);
}
}

Expand Down Expand Up @@ -893,11 +893,11 @@ REMORA::gls_corrector (int lev, MultiFab* mf_gls, MultiFab* mf_tke,
}

for (int icomp=0; icomp<3; icomp++) {
FillPatch(lev, t_old[lev], *mf_tke, GetVecOfPtrs(vec_tke), BdyVars::null, icomp, false, false);
FillPatch(lev, t_old[lev], *mf_gls, GetVecOfPtrs(vec_gls), BdyVars::null, icomp, false, false);
FillPatch(lev, t_old[lev], *mf_tke, GetVecOfPtrs(vec_tke), BCVars::zvel_bc, BdyVars::null, icomp, false, false);
FillPatch(lev, t_old[lev], *mf_gls, GetVecOfPtrs(vec_gls), BCVars::zvel_bc, BdyVars::null, icomp, false, false);
}
for (int icomp=0; icomp<NCONS; icomp++) {
FillPatch(lev, t_old[lev], *mf_Akt, GetVecOfPtrs(vec_Akt), BdyVars::null, icomp, false, false);
FillPatch(lev, t_old[lev], *mf_Akt, GetVecOfPtrs(vec_Akt), BCVars::zvel_bc, BdyVars::null, icomp, false, false);
}
FillPatchNoBC(lev, t_old[lev], *mf_Akv, GetVecOfPtrs(vec_Akv), BdyVars::null);
FillPatchNoBC(lev, t_old[lev], *mf_Akp, GetVecOfPtrs(vec_Akp), BdyVars::null);
Expand Down
2 changes: 1 addition & 1 deletion Source/TimeIntegration/REMORA_setup_step.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ REMORA::setup_step (int lev, Real time, Real dt_lev)
FillPatchNoBC(lev, time, *cons_old[lev], cons_old, BdyVars::t);
FillPatchNoBC(lev, time, *xvel_old[lev], xvel_old, BdyVars::u);
FillPatchNoBC(lev, time, *yvel_old[lev], yvel_old, BdyVars::v);
FillPatch(lev, time, *zvel_old[lev], zvel_old, BdyVars::null);
FillPatch(lev, time, *zvel_old[lev], zvel_old, BCVars::zvel_bc, BdyVars::null);

////////// //pre_step3d corrections to boundaries

Expand Down

0 comments on commit ba75622

Please sign in to comment.