Skip to content

Commit

Permalink
cleanup of previous logic
Browse files Browse the repository at this point in the history
  • Loading branch information
asalmgren committed Oct 8, 2024
1 parent e67f7fb commit da3bb8f
Showing 1 changed file with 19 additions and 34 deletions.
53 changes: 19 additions & 34 deletions Source/ERF_make_new_arrays.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -442,50 +442,35 @@ ERF::init_zphys (int lev, Real time)
{
if (solverChoice.use_terrain)
{
if (lev > 0) {
//
// First interpolate from coarser level if there is one
// NOTE: this interpolater assumes that ALL ghost cells of the coarse MultiFab
// have been pre-filled - this includes ghost cells both inside and outside
// the domain
//
InterpFromCoarseLevel(*z_phys_nd[lev], z_phys_nd[lev]->nGrowVect(),
IntVect(0,0,0), // do not fill ghost cells outside the domain
*z_phys_nd[lev-1], 0, 0, 1,
geom[lev-1], geom[lev],
refRatio(lev-1), &node_bilinear_interp,
domain_bcs_type, BCVars::cons_bc);

// This recomputes the fine values using the bottom terrain at the fine resolution,
// and also fills values of z_phys_nd outside the domain
if (init_type != "real" && init_type != "metgrid")
{
if (lev > 0) {
//
// First interpolate from coarser level if there is one
// NOTE: this interpolater assumes that ALL ghost cells of the coarse MultiFab
// have been pre-filled - this includes ghost cells both inside and outside
// the domain
//
InterpFromCoarseLevel(*z_phys_nd[lev], z_phys_nd[lev]->nGrowVect(),
IntVect(0,0,0), // do not fill ghost cells outside the domain
*z_phys_nd[lev-1], 0, 0, 1,
geom[lev-1], geom[lev],
refRatio(lev-1), &node_bilinear_interp,
domain_bcs_type, BCVars::cons_bc);
}

z_phys_nd[lev]->setVal(-1.e23);
prob->init_custom_terrain(geom[lev],*z_phys_nd[lev],time);
init_terrain_grid(lev,geom[lev],*z_phys_nd[lev],zlevels_stag[lev],phys_bc_type);
}

//
// NOTE: we are NOT currently doing this as described -- we will simply use
// the interpolation from coarse done above
// Then, if not using real/metgrid data,
// 1) redefine the terrain at k=0 for every fine box which includes k=0
// 2) recreate z_phys_nd at every fine node using
// the data at the bottom of each fine grid
// which has been either been interpolated from the coarse grid (k>0)
// or set in init_custom_terrain (k=0)
//
if (init_type != "real" && init_type != "metgrid")
{
if (lev == 0) {
z_phys_nd[lev]->setVal(-1.e23);
prob->init_custom_terrain(geom[lev],*z_phys_nd[lev],time);
init_terrain_grid(lev,geom[lev],*z_phys_nd[lev],zlevels_stag[lev],phys_bc_type);

Real zmax = z_phys_nd[0]->max(0,0,false);
Real rel_diff = (zmax - zlevels_stag[0][zlevels_stag[0].size()-1]) / zmax;
AMREX_ALWAYS_ASSERT_WITH_MESSAGE(rel_diff < 1.e-8, "Terrain is taller than domain top!");

} // lev == 0

z_phys_nd[lev]->FillBoundary(geom[lev].periodicity());

} // init_type
} // terrain
}
Expand Down

0 comments on commit da3bb8f

Please sign in to comment.