From 844091a9d3265f738188363dc4285a32167d7b05 Mon Sep 17 00:00:00 2001 From: Candace Gilet Date: Fri, 14 Jun 2024 18:02:05 -0400 Subject: [PATCH] Add regrid on restart (#101) --- .../source/InputsCheckpoint.rst | 24 +++++++++++-------- src/incflo.H | 1 + src/setup/init.cpp | 1 + src/utilities/io.cpp | 22 ++++++++++------- 4 files changed, 29 insertions(+), 19 deletions(-) diff --git a/Docs/sphinx_documentation/source/InputsCheckpoint.rst b/Docs/sphinx_documentation/source/InputsCheckpoint.rst index 13bae0e4..d0bb1e50 100644 --- a/Docs/sphinx_documentation/source/InputsCheckpoint.rst +++ b/Docs/sphinx_documentation/source/InputsCheckpoint.rst @@ -5,14 +5,18 @@ Checkpoint/Restart The following inputs must be preceded by "amr" and control checkpoint/restart. -+------------------+-----------------------------------------------------------------------+-------------+-----------+ -| | Description | Type | Default | -+==================+=======================================================================+=============+===========+ -| restart | If present, then the name of file to restart from | String | None | -+------------------+-----------------------------------------------------------------------+-------------+-----------+ -| check_int | Frequency of checkpoint output; | Int | -1 | -| | if -1 then no checkpoints will be written | | | -+------------------+-----------------------------------------------------------------------+-------------+-----------+ -| check_file | Prefix to use for checkpoint output | String | chk | -+------------------+-----------------------------------------------------------------------+-------------+-----------+ ++---------------------+-----------------------------------------------------------------------+-------------+-----------+ +| | Description | Type | Default | ++=====================+=======================================================================+=============+===========+ +| restart | If present, then the name of file to restart from | String | None | ++---------------------+-----------------------------------------------------------------------+-------------+-----------+ +| plotfile_on_restart | Write a plotfile before taking a time step | bool | false | ++---------------------+-----------------------------------------------------------------------+-------------+-----------+ +| regrid_on_restart | Create new grids, including level 0, on restart | bool | false | ++---------------------+-----------------------------------------------------------------------+-------------+-----------+ +| check_int | Frequency of checkpoint output; | Int | -1 | +| | if -1 then no checkpoints will be written | | | ++---------------------+-----------------------------------------------------------------------+-------------+-----------+ +| check_file | Prefix to use for checkpoint output | String | chk | ++---------------------+-----------------------------------------------------------------------+-------------+-----------+ diff --git a/src/incflo.H b/src/incflo.H index 73891cb5..16061dba 100644 --- a/src/incflo.H +++ b/src/incflo.H @@ -520,6 +520,7 @@ private: std::string m_tag_file; bool m_plotfile_on_restart = false; + bool m_regrid_on_restart = false; amrex::Vector tag_region_lo; amrex::Vector tag_region_hi; diff --git a/src/setup/init.cpp b/src/setup/init.cpp index c0fff1cf..b307df41 100644 --- a/src/setup/init.cpp +++ b/src/setup/init.cpp @@ -216,6 +216,7 @@ void incflo::ReadIOParameters() pp.query("restart", m_restart_file); pp.query("plotfile_on_restart", m_plotfile_on_restart); + pp.query("regrid_on_restart", m_regrid_on_restart); pp.query("plot_file", m_plot_file); pp.query("plot_int" , m_plot_int); diff --git a/src/utilities/io.cpp b/src/utilities/io.cpp index e000d203..8b6aee32 100644 --- a/src/utilities/io.cpp +++ b/src/utilities/io.cpp @@ -188,17 +188,21 @@ void incflo::ReadCheckpointFile() Geom(lev).isPeriodic())); } - for(int lev = 0; lev <= finest_level; ++lev) - { - // read in level 'lev' BoxArray from Header - BoxArray ba; - ba.readFrom(is); - GotoNextLine(is); + if ( m_regrid_on_restart ) { + MakeNewGrids(m_cur_time); + } else { + for(int lev = 0; lev <= finest_level; ++lev) + { + // read in level 'lev' BoxArray from Header + BoxArray ba; + ba.readFrom(is); + GotoNextLine(is); - // Create distribution mapping - DistributionMapping dm{ba, ParallelDescriptor::NProcs()}; + // Create distribution mapping + DistributionMapping dm{ba, ParallelDescriptor::NProcs()}; - MakeNewLevelFromScratch(lev, m_cur_time, ba, dm); + MakeNewLevelFromScratch(lev, m_cur_time, ba, dm); + } } /***************************************************************************