Skip to content

Commit

Permalink
update fillpatch
Browse files Browse the repository at this point in the history
  • Loading branch information
asalmgren committed Dec 14, 2023
1 parent b2ea063 commit 640c690
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 38 deletions.
15 changes: 8 additions & 7 deletions Source/BoundaryConditions/ROMSX_FillPatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ PhysBCFunctNoOp null_bc;
// values in mf when it is passed in are *not* used.
//
void
ROMSX::FillPatch (int lev, Real time, MultiFab* mf_to_fill, Vector<MultiFab*>& mfs)
ROMSX::FillPatch (int lev, Real time, MultiFab& mf_to_fill, Vector<MultiFab*> const& mfs)
{
BL_PROFILE_VAR("ROMSX::FillPatch()",ROMSX_FillPatch);
int bccomp;
amrex::Interpolater* mapper = nullptr;

const int icomp = 0;
const int ncomp = mf_to_fill->nComp();
const int ncomp = mf_to_fill.nComp();

Box mf_box(mf_to_fill->boxArray()[0]);
Box mf_box(mf_to_fill.boxArray()[0]);
if (mf_box.ixType() == IndexType(IntVect(0,0,0)))
{
bccomp = 0;
Expand Down Expand Up @@ -52,7 +52,7 @@ ROMSX::FillPatch (int lev, Real time, MultiFab* mf_to_fill, Vector<MultiFab*>& m
{
Vector<MultiFab*> fmf = {mfs[lev], mfs[lev]};
Vector<Real> ftime = {t_old[lev], t_new[lev]};
amrex::FillPatchSingleLevel(*mf_to_fill, time, fmf, ftime, icomp, icomp, ncomp,
amrex::FillPatchSingleLevel(mf_to_fill, time, fmf, ftime, icomp, icomp, ncomp,
geom[lev], null_bc, bccomp);
}
else
Expand All @@ -62,7 +62,7 @@ ROMSX::FillPatch (int lev, Real time, MultiFab* mf_to_fill, Vector<MultiFab*>& m
Vector<MultiFab*> cmf = {mfs[lev-1], mfs[lev-1]};
Vector<Real> ctime = {t_old[lev-1], t_new[lev-1]};

amrex::FillPatchTwoLevels(*mf_to_fill, time, cmf, ctime, fmf, ftime,
amrex::FillPatchTwoLevels(mf_to_fill, time, cmf, ctime, fmf, ftime,
0, icomp, ncomp, geom[lev-1], geom[lev],
null_bc, bccomp, null_bc, bccomp, refRatio(lev-1),
mapper, domain_bcs_type, bccomp);
Expand All @@ -73,12 +73,12 @@ ROMSX::FillPatch (int lev, Real time, MultiFab* mf_to_fill, Vector<MultiFab*>& m
(mf_box.ixType() == IndexType(IntVect(0,1,0))) )
{
int khi = geom[lev].Domain().bigEnd(2);
for (MFIter mfi(*mf_to_fill); mfi.isValid(); ++mfi)
for (MFIter mfi(mf_to_fill); mfi.isValid(); ++mfi)
{
Box gbx = mfi.growntilebox(); // Note this is face-centered since vel is
gbx.setSmall(2,khi+1);
if (gbx.ok()) {
Array4<Real> vel_arr = mf_to_fill->array(mfi);
Array4<Real> vel_arr = mf_to_fill.array(mfi);
ParallelFor(gbx, [=] AMREX_GPU_DEVICE (int i, int j, int k)
{
vel_arr(i,j,k) = vel_arr(i,j,khi);
Expand All @@ -88,6 +88,7 @@ ROMSX::FillPatch (int lev, Real time, MultiFab* mf_to_fill, Vector<MultiFab*>& m
}
}


// utility to copy in data from old/new data into a struct that holds data for FillPatching
TimeInterpolatedData
ROMSX::GetDataAtTime (int /*lev*/, Real /*time*/)
Expand Down
8 changes: 4 additions & 4 deletions Source/IO/Plotfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,10 @@ ROMSX::WritePlotFile (int which, Vector<std::string> plot_var_names)
// We fillpatch here because some of the derived quantities require derivatives
// which require ghost cells to be filled
for (int lev = 0; lev <= finest_level; ++lev) {
FillPatch(lev, t_new[lev], cons_new[lev], cons_new);
FillPatch(lev, t_new[lev], xvel_new[lev], xvel_new);
FillPatch(lev, t_new[lev], yvel_new[lev], yvel_new);
FillPatch(lev, t_new[lev], zvel_new[lev], zvel_new);
FillPatch(lev, t_new[lev], *cons_new[lev], cons_new);
FillPatch(lev, t_new[lev], *xvel_new[lev], xvel_new);
FillPatch(lev, t_new[lev], *yvel_new[lev], yvel_new);
FillPatch(lev, t_new[lev], *zvel_new[lev], zvel_new);
}

if (ncomp_mf == 0)
Expand Down
4 changes: 2 additions & 2 deletions Source/ROMSX.H
Original file line number Diff line number Diff line change
Expand Up @@ -606,8 +606,8 @@ public:

// Fill a new MultiFab by copying in phi from valid region and filling ghost cells
void FillPatch (int lev, amrex::Real time,
amrex::MultiFab* mf_to_be_filled,
amrex::Vector<amrex::MultiFab*>& mf);
amrex::MultiFab& mf_to_be_filled,
amrex::Vector<amrex::MultiFab*> const& mfs);

private:

Expand Down
8 changes: 4 additions & 4 deletions Source/ROMSX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -323,10 +323,10 @@ ROMSX::InitData ()
// Fill ghost cells/faces
for (int lev = 0; lev <= finest_level; ++lev)
{
FillPatch(lev, t_new[lev], cons_new[lev], cons_new);
FillPatch(lev, t_new[lev], xvel_new[lev], xvel_new);
FillPatch(lev, t_new[lev], yvel_new[lev], yvel_new);
FillPatch(lev, t_new[lev], zvel_new[lev], zvel_new);
FillPatch(lev, t_new[lev], *cons_new[lev], cons_new);
FillPatch(lev, t_new[lev], *xvel_new[lev], xvel_new);
FillPatch(lev, t_new[lev], *yvel_new[lev], yvel_new);
FillPatch(lev, t_new[lev], *zvel_new[lev], zvel_new);

//
// Copy from new into old just in case
Expand Down
8 changes: 4 additions & 4 deletions Source/ROMSX_make_new_level.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ ROMSX::RemakeLevel (int lev, Real time, const BoxArray& ba, const DistributionMa
MultiFab* tmp_zvel_old; tmp_zvel_old->define(convert(ba, IntVect(0,0,1)), dm, 1, IntVect(ngrow_vels,ngrow_vels,0));

// 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);
FillPatch(lev, time, tmp_xvel_new, xvel_new);
FillPatch(lev, time, tmp_yvel_new, yvel_new);
FillPatch(lev, time, tmp_zvel_new, zvel_new);
FillPatch(lev, time, *tmp_cons_new, cons_new);
FillPatch(lev, time, *tmp_xvel_new, xvel_new);
FillPatch(lev, time, *tmp_yvel_new, yvel_new);
FillPatch(lev, time, *tmp_zvel_new, zvel_new);

MultiFab::Copy(*tmp_cons_old,*tmp_cons_new,0,0,NCONS,tmp_cons_new[lev].nGrowVect());
MultiFab::Copy(*tmp_xvel_old,*tmp_xvel_new,0,0, 1,tmp_xvel_new[lev].nGrowVect());
Expand Down
16 changes: 8 additions & 8 deletions Source/TimeIntegration/ROMSX_advance_3d_ml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ void ROMSX::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_old[lev], cons_old);
FillPatch(lev, t_old[lev], xvel_old[lev], xvel_old);
FillPatch(lev, t_old[lev], yvel_old[lev], yvel_old);
FillPatch(lev, t_old[lev], zvel_old[lev], zvel_old);
FillPatch(lev, t_new[lev], *cons_new[lev], cons_new);
FillPatch(lev, t_new[lev], *xvel_new[lev], xvel_new);
FillPatch(lev, t_new[lev], *yvel_new[lev], yvel_new);
FillPatch(lev, t_new[lev], *zvel_new[lev], zvel_new);

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

Expand All @@ -32,10 +32,10 @@ void ROMSX::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
// Note that we need the fine-fine and physical bc's in order to correctly move the particles
FillPatch(lev, t_new[lev], cons_new[lev], cons_new);
FillPatch(lev, t_new[lev], xvel_new[lev], xvel_new);
FillPatch(lev, t_new[lev], yvel_new[lev], yvel_new);
FillPatch(lev, t_new[lev], zvel_new[lev], zvel_new);
FillPatch(lev, t_new[lev], *cons_new[lev], cons_new);
FillPatch(lev, t_new[lev], *xvel_new[lev], xvel_new);
FillPatch(lev, t_new[lev], *yvel_new[lev], yvel_new);
FillPatch(lev, t_new[lev], *zvel_new[lev], zvel_new);

#ifdef ROMSX_USE_PARTICLES
//***************************************************
Expand Down
8 changes: 4 additions & 4 deletions Source/TimeIntegration/ROMSX_setup_step.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ ROMSX::setup_step (int lev, Real time, Real dt_lev)
int nvars = S_old.nComp();

// Fill ghost cells/faces at old time
FillPatch(lev, time, cons_old[lev], cons_old);
FillPatch(lev, time, xvel_old[lev], xvel_old);
FillPatch(lev, time, yvel_old[lev], yvel_old);
FillPatch(lev, time, zvel_old[lev], zvel_old);
FillPatch(lev, time, *cons_old[lev], cons_old);
FillPatch(lev, time, *xvel_old[lev], xvel_old);
FillPatch(lev, time, *yvel_old[lev], yvel_old);
FillPatch(lev, time, *zvel_old[lev], zvel_old);

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

Expand Down
12 changes: 7 additions & 5 deletions Source/Utils/DepthStretchTransform.H
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,11 @@ ROMSX::stretch_transform (int lev)
});
}

vec_z_w[lev]->FillBoundary(geom[lev].periodicity());
vec_z_r[lev]->FillBoundary(geom[lev].periodicity());
vec_s_r[lev]->FillBoundary(geom[lev].periodicity());
vec_Hz[lev]->FillBoundary(geom[lev].periodicity());
Real time = t_new[lev];
FillPatch(lev, time, *vec_z_w[lev], GetVecOfPtrs(vec_z_w));
FillPatch(lev, time, *vec_z_r[lev], GetVecOfPtrs(vec_z_r));
FillPatch(lev, time, *vec_s_r[lev], GetVecOfPtrs(vec_s_r));
FillPatch(lev, time, *vec_Hz[lev] , GetVecOfPtrs(vec_Hz));

// Define nodal z as average of z on w-faces
for ( MFIter mfi(*cons_new[lev], TilingIfNotGPU()); mfi.isValid(); ++mfi )
Expand Down Expand Up @@ -235,7 +236,8 @@ ROMSX::stretch_transform (int lev)
});
} // mf

// Enforce periodicity
// Note that we do *not* want to do a multilevel fill here -- we have
// already filled z_phys_nd on the grown boxes, but we enforce periodicity just in case
vec_z_phys_nd[lev]->FillBoundary(geom[lev].periodicity());
}

Expand Down

0 comments on commit 640c690

Please sign in to comment.