diff --git a/Docs/sphinx_doc/MeshRefinement.rst b/Docs/sphinx_doc/MeshRefinement.rst index b6da7e410..efe1da1e5 100644 --- a/Docs/sphinx_doc/MeshRefinement.rst +++ b/Docs/sphinx_doc/MeshRefinement.rst @@ -23,14 +23,13 @@ See the `Gridding`_ section of the AMReX documentation for details of how indivi Static Mesh Refinement ---------------------- -For static refinement, we control the placement of grids by specifying -the low and high extents (in physical space) of each box in the lateral -directions. ERF enforces that all refinement spans the entire vertical direction. +For static refinement, we can control the placement of grids by specifying +the low and high extents (in physical space or index space) of each box. The following example demonstrates how to tag regions for static refinement. -In this first example, all cells in the region ((.15,.25,prob_lo_z)(.35,.45,prob_hi_z)) -and in the region ((.65,.75,prob_lo_z)(.85,.95,prob_hi_z)) are tagged for -one level of refinement, where prob_lo_z and prob_hi_z are the vertical extents of the domain: +In this first example, all cells in the region ((.15,.25,0.)(.35,.45,1.)) +and in the region ((.65,.75,0.0)(.85,.95,1.0)) are tagged for +one level of refinement. :: @@ -39,13 +38,13 @@ one level of refinement, where prob_lo_z and prob_hi_z are the vertical extents erf.refinement_indicators = box1 box2 - erf.box1.in_box_lo = .15 .25 - erf.box1.in_box_hi = .35 .45 + erf.box1.in_box_lo = .15 .25 0.0 + erf.box1.in_box_hi = .35 .45 1.0 - erf.box2.in_box_lo = .65 .75 - erf.box2.in_box_hi = .85 .95 + erf.box2.in_box_lo = .65 .75 0.0 + erf.box2.in_box_hi = .85 .95 1.0 -In the example below, we refine the region ((.15,.25,prob_lo_z)(.35,.45,prob_hi_z)) +In the example below, we refine the region ((.15,.25,0.)(.35,.45,.5)) by two levels of factor 3 refinement. In this case, the refined region at level 1 will be sufficient to enclose the refined region at level 2. @@ -56,11 +55,11 @@ be sufficient to enclose the refined region at level 2. erf.refinement_indicators = box1 - erf.box1.in_box_lo = .15 .25 - erf.box1.in_box_hi = .35 .45 + erf.box1.in_box_lo = .15 .25 0.0 + erf.box1.in_box_hi = .35 .45 1.0 -And in this final example, the region ((.15,.25,prob_lo_z)(.35,.45,prob_hi_z)) -will be refined by two levels of factor 3, but the larger region, ((.05,.05,prob_lo_z)(.75,.75,prob_hi_z)) +And in this final example, the region ((.15,.25,0.)(.35,.45,1.)) +will be refined by two levels of factor 3, but the larger region, ((.05,.05,0.)(.75,.75,1.)) will be refined by a single factor 3 refinement. :: @@ -70,12 +69,30 @@ will be refined by a single factor 3 refinement. erf.refinement_indicators = box1 box2 - erf.box1.in_box_lo = .15 .25 - erf.box1.in_box_hi = .35 .45 + erf.box1.in_box_lo = .15 .25 0.0 + erf.box1.in_box_hi = .35 .45 1.0 - erf.box2.in_box_lo = .05 .05 - erf.box2.in_box_hi = .75 .75 erf.box2.max_level = 1 + erf.box2.in_box_lo = .05 .05 0.0 + erf.box2.in_box_hi = .75 .75 1.0 + + +We note that instead of specifying the physical extent enclosed, we can instead specify the indices of +the bounding box of the refined region in the index space of that fine level. +To do this we use +``in_box_lo_indices`` and ``in_box_hi_indices`` instead of ``in_box_lo`` and ``in_box_hi``. +If we want to refine the inner region (spanning half the width in each direction) by one level of +factor 2 refinement, and the domain has 32x64x8 cells at level 0 covering the domain, then we would set + +:: + + amr.max_level = 1 + amr.ref_ratio = 2 + + erf.refinement_indicators = box1 + + erf.box1.in_box_lo_indices = 16 32 4 + erf.box1.in_box_hi_indices = 47 95 11 Dynamic Mesh Refinement @@ -84,6 +101,8 @@ Dynamic Mesh Refinement Dynamically created tagging functions are based on runtime data specified in the inputs file. These dynamically generated functions test on either state variables or derived variables defined in ERF_derive.cpp and included in the derive_lst in Setup.cpp. +(We note that static refinement can also be achieved by using the refinement criteria as specified below +but setting ``erf.regrid_int`` to a number greater than the total number of steps that will be taken.) Available tests include diff --git a/Exec/RegTests/Couette_Poiseuille/inputs_neumann_test b/Exec/RegTests/Couette_Poiseuille/inputs_neumann_test deleted file mode 100644 index 507aa12d5..000000000 --- a/Exec/RegTests/Couette_Poiseuille/inputs_neumann_test +++ /dev/null @@ -1,72 +0,0 @@ -# --------------------------------------------- -# --------------------------------------------- -# NOTE: to run this test effectively, you must -# hack Source/EOS.H so that getPgivenRTh -# returns just p0; this allows theta to change -# without changing the pressure and generating -# a velocity field -# --------------------------------------------- -# --------------------------------------------- - -max_step = 2000 - -amrex.fpe_trap_invalid = 1 - -fabarray.mfiter_tile_size = 1024 1024 1024 - -# PROBLEM SIZE & GEOMETRY -geometry.prob_lo = 0 0. -1. -geometry.prob_hi = 4. 1. 1. -amr.n_cell = 32 4 16 - -geometry.is_periodic = 1 1 0 - -zlo.type = "NoSlipWall" -zhi.type = "NoSlipWall" - -zlo.density = 2.0 -zlo.theta = 300.0 - -zhi.theta_grad = 3.0 - -# TIME STEP CONTROL -erf.no_substepping = 1 -erf.fixed_dt = 0.005 - -# DIAGNOSTICS & VERBOSITY -erf.sum_interval = 1 # timesteps between computing mass -erf.v = 1 # verbosity in ERF.cpp -amr.v = 1 # verbosity in Amr.cpp - -# REFINEMENT / REGRIDDING -amr.max_level = 0 # maximum level number allowed - -# CHECKPOINT FILES -erf.check_file = chk # root name of checkpoint file -erf.check_int = 1000 # number of timesteps between checkpoints - -# PLOTFILES -erf.plot_file_1 = plt # prefix of plotfile name -erf.plot_int_1 = 1000 # number of timesteps between plotfiles -erf.plot_vars_1 = density rhotheta x_velocity y_velocity z_velocity theta - -# SOLVER CHOICE -erf.use_gravity = false - -erf.alpha_T = 1.0 -erf.alpha_C = 0.0 - -erf.les_type = "None" -erf.rho0_trans = 2.0 -erf.molec_diff_type = "Constant" -erf.dynamicViscosity = 0.1 - -erf.use_coriolis = false - -erf.init_type = "uniform" - -# PROBLEM PARAMETERS -prob.prob_type = 10 - -prob.rho_0 = 2.0 -prob.T_0 = 300.0 diff --git a/Source/ERF_Tagging.cpp b/Source/ERF_Tagging.cpp index fd12b90fe..e8af57f23 100644 --- a/Source/ERF_Tagging.cpp +++ b/Source/ERF_Tagging.cpp @@ -119,11 +119,26 @@ ERF::refinement_criteria_setup () ParmParse ppr(ref_prefix); RealBox realbox; int lev_for_box; - if (ppr.countval("in_box_lo")) { + + int num_real_lo = ppr.countval("in_box_lo"); + int num_indx_lo = ppr.countval("in_box_lo_indices"); + + if ( !((num_real_lo == AMREX_SPACEDIM && num_indx_lo == 0) || + (num_indx_lo == AMREX_SPACEDIM && num_real_lo == 0) || + (num_indx_lo == 0 && num_real_lo == 0)) ) + { + amrex::Abort("Must only specify box for refinement using real OR index space"); + } + + if (num_real_lo > 0) { std::vector box_lo(3), box_hi(3); ppr.get("max_level",lev_for_box); if (lev_for_box <= max_level) { + if (n_error_buf[0] != IntVect::TheZeroVector()) { + amrex::Abort("Don't use n_error_buf > 0 when setting the box explicitly"); + } + ppr.getarr("in_box_lo",box_lo,0,AMREX_SPACEDIM); ppr.getarr("in_box_hi",box_hi,0,AMREX_SPACEDIM); realbox = RealBox(&(box_lo[0]),&(box_hi[0])); @@ -152,6 +167,44 @@ ERF::refinement_criteria_setup () } } + + } else if (num_indx_lo > 0) { + + std::vector box_lo(3), box_hi(3); + ppr.get("max_level",lev_for_box); + if (lev_for_box <= max_level) + { + if (n_error_buf[0] != IntVect::TheZeroVector()) { + amrex::Abort("Don't use n_error_buf > 0 when setting the box explicitly"); + } + + ppr.getarr("in_box_lo_indices",box_lo,0,AMREX_SPACEDIM); + ppr.getarr("in_box_hi_indices",box_hi,0,AMREX_SPACEDIM); + + Box bx(IntVect(box_lo[0],box_lo[1],box_lo[2]),IntVect(box_hi[0],box_hi[1],box_hi[2])); + amrex::Print() << "BOX " << bx << std::endl; + + const auto* dx = geom[lev_for_box].CellSize(); + const Real* plo = geom[lev_for_box].ProbLo(); + realbox = RealBox(plo[0]+ box_lo[0] *dx[0],plo[1] +box_lo[1] *dx[1],plo[2] +box_lo[2] *dx[2], + plo[0]+(box_hi[0]+1)*dx[0],plo[1]+(box_hi[1]+1)*dx[1],plo[2]+(box_hi[2]+1)*dx[2]); + + Print() << "Reading " << bx << " at level " << lev_for_box << std::endl; + num_boxes_at_level[lev_for_box] += 1; + + if ( (box_lo[0]%ref_ratio[lev_for_box-1][0] != 0) || ((box_hi[0]+1)%ref_ratio[lev_for_box-1][0] != 0) || + (box_lo[1]%ref_ratio[lev_for_box-1][1] != 0) || ((box_hi[1]+1)%ref_ratio[lev_for_box-1][1] != 0) || + (box_lo[2]%ref_ratio[lev_for_box-1][2] != 0) || ((box_hi[2]+1)%ref_ratio[lev_for_box-1][2] != 0) ) + amrex::Error("Fine box is not legit with this ref_ratio"); + boxes_at_level[lev_for_box].push_back(bx); + Print() << "Saving in 'boxes at level' as " << bx << std::endl; + } // lev + if (init_type == "real" || init_type == "metgrid") { + if (num_boxes_at_level[lev_for_box] != num_files_at_level[lev_for_box]) { + amrex::Error("Number of boxes doesnt match number of input files"); + + } + } } AMRErrorTagInfo info;