Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a hook so that an AmrLevel can force a post-timestep regrid #1

Merged
merged 1 commit into from
May 7, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions Src/Amr/AMReX_Amr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
//
Expand Down Expand Up @@ -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.
//
Expand Down
6 changes: 6 additions & 0 deletions Src/Amr/AMReX_AmrLevel.H
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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:
Expand Down