diff --git a/Src/Amr/AMReX_Amr.cpp b/Src/Amr/AMReX_Amr.cpp index 69a7b5d619f..e61f58b4850 100644 --- a/Src/Amr/AMReX_Amr.cpp +++ b/Src/Amr/AMReX_Amr.cpp @@ -1759,6 +1759,9 @@ Amr::timeStep (int level, // when regridding is called with possible lbase > level. which_level_being_advanced = level; + // Update so that by default, we don't force a post-step regrid. + amr_level[level]->setPostStepRegrid(0); + // // Allow regridding of level 0 calculation on restart. // @@ -1854,6 +1857,29 @@ Amr::timeStep (int level, #ifdef USE_SLABSTAT AmrLevel::get_slabstat_lst().update(*amr_level[level],time,dt_level[level]); #endif + + // If the level signified that it wants a regrid after the advance has + // occurred, do that now. + + if (amr_level[level]->postStepRegrid()) { + + int old_finest = finest_level; + + regrid(level, time); + + if (old_finest < finest_level) + { + // + // The new levels will not have valid time steps. + // + for (int k = old_finest + 1; k <= finest_level; ++k) + { + dt_level[k] = dt_level[k-1] / n_cycle[k]; + } + } + + } + // // Advance grids at higher level. // diff --git a/Src/Amr/AMReX_AmrLevel.H b/Src/Amr/AMReX_AmrLevel.H index 00c90aad75b..09476e6e224 100644 --- a/Src/Amr/AMReX_AmrLevel.H +++ b/Src/Amr/AMReX_AmrLevel.H @@ -284,6 +284,10 @@ public: static const DescriptorList& get_desc_lst () { return desc_lst; } //! Returns list of derived variables. static DeriveList& get_derive_lst (); + //! Returns whether or not we want a post-timestep regrid. + int postStepRegrid () { return post_step_regrid; } + //! Sets a new value for the post-timestep regrid trigger. + void setPostStepRegrid (int new_val) { post_step_regrid = new_val; } #ifdef USE_SLABSTAT //! Returns list of slab stats. @@ -385,6 +389,8 @@ protected: BoxArray m_AreaNotToTag; //Area which shouldn't be tagged on this level. Box m_AreaToTag; //Area which is allowed to be tagged on this level. + int post_step_regrid; // Whether or not to do a regrid after the timestep. + bool levelDirectoryCreated; // for checkpoints and plotfiles private: