Chombo + EB  3.2
Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
AMR Class Reference

Framework for Berger-Oliger timestepping for AMR. More...

#include <AMR.H>

Public Member Functions

 AMR ()
 
virtual ~AMR ()
 
void define (int a_max_level, const Vector< int > &a_ref_ratios, const Box &a_prob_domain, const AMRLevelFactory *const a_amrLevelFact)
 
void define (int a_max_level, const Vector< int > &a_ref_ratios, const ProblemDomain &a_prob_domain, const AMRLevelFactory *const a_amrLevelFact)
 
void setupForRestart (HDF5Handle &a_handle)
 
void setupForNewAMRRun ()
 
void setupForFixedHierarchyRun (const Vector< Vector< Box > > &a_amr_grids, int a_proper_nest=1)
 
void run (Real a_max_time, int a_max_step)
 
void conclude () const
 
Parameter-setting functions
void checkpointPrefix (const std::string &a_checkpointfile_prefix)
 
void plotInterval (int a_plot_interval)
 Tells AMR to write plot files after every a_plot_interval steps. More...
 
void checkForSteadyState (bool a_steadyState)
 Tells AMR to check each level for steady state and stop if we get there. More...
 
void plotPeriod (Real a_plot_period)
 Tells AMR to write plot files after every a_plot_period time units. More...
 
void schedule (RefCountedPtr< Scheduler > a_scheduler)
 Sets up a schedule for periodically-called functions. More...
 
void checkpointInterval (int a_checkpoint_interval)
 
void maxGridSize (int a_max_grid_size)
 
void maxBaseGridSize (int a_max_base_grid_size)
 
void dtToleranceFactor (Real a_dt_tolerance_factor)
 
void setMeshRefine (RefCountedPtr< MeshRefine > a_mesh_refine_ptr)
 
void fillRatio (Real a_fillRat)
 
void blockFactor (int a_blockFactor)
 
void gridBufferSize (int a_grid_buffer_size)
 
void verbosity (int a_verbosity)
 
void regridIntervals (const Vector< int > &a_regridIntervals)
 
void maxDtGrow (Real a_dtGrowFactor)
 
void timeEps (Real a_timeEps)
 
void fixedDt (Real a_dt)
 
void initialTime (Real a_initialTime)
 
void useSubcyclingInTime (bool a_useSubcycling)
 
void plotPrefix (const std::string &a_plotfile_prefix)
 
Access functions
bool isDefined () const
 
bool isSetUp () const
 
int maxGridSize () const
 
int maxBaseGridSize () const
 
int verbosity () const
 
Real maxDtGrow () const
 
Real timeEps () const
 
Real fixedDt () const
 
Vector< AMRLevel * > getAMRLevels ()
 
Real getCurrentTime () const
 

Static Public Attributes

static int s_step
 

Protected Member Functions

int timeStep (int a_level, int a_stepsLeft, bool a_coarseTimeBoundary)
 
void clearMemory ()
 
void regrid (int a_base_level)
 
void initialGrid ()
 
void writePlotFile () const
 
void writeCheckpointFile () const
 
void assignDt ()
 
bool needToRegrid (int a_level, int a_numStepsLeft) const
 
virtual void makeBaseLevelMesh (Vector< Box > &a_grids) const
 
void setDefaultValues ()
 

Protected Attributes

bool m_useSubcycling
 
int m_blockFactor
 
Real m_fillRatio
 
int m_max_level
 
int m_finest_level_old
 
int m_finest_level
 
int m_checkpoint_interval
 
int m_plot_interval
 
Real m_plot_period
 
Real m_next_plot_time
 
int m_max_grid_size
 
int m_max_base_grid_size
 
Real m_dt_tolerance_factor
 
Real m_fixedDt
 
bool m_checkForSteadyState
 
bool m_isDefined
 
bool m_isSetUp
 
Vector< AMRLevel * > m_amrlevels
 
Vector< int > m_ref_ratios
 
Vector< int > m_reduction_factor
 
Vector< int > m_regrid_intervals
 
Real m_dt_base
 
Vector< Realm_dt_new
 
Vector< Realm_dt_cur
 
Real m_maxDtGrow
 
Real m_time_eps
 
RefCountedPtr< MeshRefinem_mesh_refine_ptr
 
bool m_use_meshrefine
 
Vector< Vector< Box > > m_amr_grids
 
int m_cur_step
 
int m_restart_step
 
int m_lastcheck_step
 
Real m_cur_time
 
Vector< int > m_steps_since_regrid
 
Vector< long long > m_cell_updates
 
std::string m_plotfile_prefix
 
std::string m_checkpointfile_prefix
 
int m_verbosity
 
RefCountedPtr< Schedulerm_scheduler
 

Detailed Description

Framework for Berger-Oliger timestepping for AMR.

This class is a framework for Berger-Oliger timestepping for adaptive mesh refinement of time-dependent problems. It is applicable to both hyperbolic and parabolic problems. It represents a hierarchy of levels of refinement as a collection of AMRLevel objects.

The usage pattern is this:

  1. Call define() to define the stuff that does not change throughout the run (maxlevel, refinement ratios, domain, and operator).
  2. Modify any parameters you like (blocking factor, max grid size, etc.) using parameter-setting functions.
  3. Call any one of the three setup functions (setupForRestart(), setupForNewAMRRun(), or setupForFixedHierarchyRun()) so AMR can set up all its internal data structures.
  4. Call run() to run the calculation.
  5. Call conclude() to output (to stdout) how many cells were updated and so forth.

Constructor & Destructor Documentation

◆ AMR()

AMR::AMR ( )

Default constructor. Use must subsequently call a define() function and a setup function.

◆ ~AMR()

virtual AMR::~AMR ( )
virtual

Destructor.

Member Function Documentation

◆ define() [1/2]

void AMR::define ( int  a_max_level,
const Vector< int > &  a_ref_ratios,
const Box a_prob_domain,
const AMRLevelFactory *const  a_amrLevelFact 
)

Defines this object. User must call a setup function before running.

Arguments:

  • a_max_level (not modified): the maximum level allowed, where the base level is zero. There will be a total of a_max_level+1 levels, since level zero and level a_max_level will both exist.
  • a_ref_ratios (not modified): refinement ratios. There must be at least a_max_level+1 elements, or an error will result. Element zero is the base level.
  • a_prob_domain (not modified): problem domain on the base level.
  • a_amrlevelFact (not modified): pointer to a physics class factory object. The object it points to is used to construct the collection of AMRLevel objects in this AMR as objects of the physics class type. It can be destructed after this define() returns.

◆ define() [2/2]

void AMR::define ( int  a_max_level,
const Vector< int > &  a_ref_ratios,
const ProblemDomain a_prob_domain,
const AMRLevelFactory *const  a_amrLevelFact 
)

Defines this object. User must call a setup function before running.

Arguments:

  • a_max_level (not modified): the maximum level allowed, where the base level is zero. There will be a total of a_max_level+1 levels, since level zero and level a_max_level will both exist.
  • a_ref_ratios (not modified): refinement ratios. There must be at least a_max_level+1 elements, or an error will result. Element zero is the base level.
  • a_prob_domain (not modified): problem domain on the base level.
  • a_amrlevelFact (not modified): pointer to a physics class factory object. The object it points to is used to construct the collection of AMRLevel objects in this AMR as objects of the physics class type. It can be destructed after this define() returns.

◆ setupForRestart()

void AMR::setupForRestart ( HDF5Handle a_handle)

Sets up this object from checkpointed data. User must have previously called define().

Need to call this function or setupForNewAMRRun() or setupforFixedHierarchyRun() before you run.

◆ setupForNewAMRRun()

void AMR::setupForNewAMRRun ( )

Sets up this object for cold start. User must have previously called define().

Need to call this function or setupForRestart() or setupforFixedHierarchyRun() before you run.

◆ setupForFixedHierarchyRun()

void AMR::setupForFixedHierarchyRun ( const Vector< Vector< Box > > &  a_amr_grids,
int  a_proper_nest = 1 
)

This function sets the hierarchy and sets m_regrid_intervals to -1 (turns off regridding). If you want to keep regridding on, call regridIntervals() after this call.

◆ run()

void AMR::run ( Real  a_max_time,
int  a_max_step 
)

Runs the calculation. User must have previously called both the define() function and a setup function.

◆ conclude()

void AMR::conclude ( ) const

You should call this last. It writes the last checkpoint file and tells you how many cells you updated and all that.

◆ checkpointPrefix()

void AMR::checkpointPrefix ( const std::string &  a_checkpointfile_prefix)

Sets the checkpoint file prefix.

Should be called after define() and before setup.

◆ plotInterval()

void AMR::plotInterval ( int  a_plot_interval)

Tells AMR to write plot files after every a_plot_interval steps.

◆ checkForSteadyState()

void AMR::checkForSteadyState ( bool  a_steadyState)

Tells AMR to check each level for steady state and stop if we get there.

◆ plotPeriod()

void AMR::plotPeriod ( Real  a_plot_period)

Tells AMR to write plot files after every a_plot_period time units.

◆ schedule()

void AMR::schedule ( RefCountedPtr< Scheduler a_scheduler)

Sets up a schedule for periodically-called functions.

◆ checkpointInterval()

void AMR::checkpointInterval ( int  a_checkpoint_interval)

Sets the interval to write checkpoint files, in terms of the base level time step.

◆ maxGridSize() [1/2]

void AMR::maxGridSize ( int  a_max_grid_size)

Set the maximum grid size. Should be called after define() and before setup.

◆ maxBaseGridSize() [1/2]

void AMR::maxBaseGridSize ( int  a_max_base_grid_size)

Set the maximum grid size for level 0 grids.

Defaults to m_max_grid_size, so should be called after maxGridSize() and before setup.

◆ dtToleranceFactor()

void AMR::dtToleranceFactor ( Real  a_dt_tolerance_factor)

Set the factor by which the current dt must exceed the new (max) dt for time subcycling to occur (i.e., reduction of the current dt by powers of 2).

◆ setMeshRefine()

void AMR::setMeshRefine ( RefCountedPtr< MeshRefine a_mesh_refine_ptr)

Set the MeshRefine instance. Should be called before define() if you want a_mesh_refine_ptr defined.

◆ fillRatio()

void AMR::fillRatio ( Real  a_fillRat)

Set the fill ratio for MeshRefine. Should be called after define() and before setup.

◆ blockFactor()

void AMR::blockFactor ( int  a_blockFactor)

Set the blocking factor for MeshRefine. Should be called after define() and before setup.

◆ gridBufferSize()

void AMR::gridBufferSize ( int  a_grid_buffer_size)

Set the buffering for MeshRefine. Should be called after define() and before setup.

◆ verbosity() [1/2]

void AMR::verbosity ( int  a_verbosity)

Sets verbosity level to a_verbosity.

-inf to 0: print nothing.
1: prints a message every coarse time step.
2: also prints a message when regridding and writing files.
3: also prints function trace, and some more inf during file I/O.
4 to inf: also prints list of boxes and processor maps during regrid.

This should be OK to call any time after define and before run.

◆ regridIntervals()

void AMR::regridIntervals ( const Vector< int > &  a_regridIntervals)

Sets the regridding intervals. This should be OK to call any time after define() and before run.

◆ maxDtGrow() [1/2]

void AMR::maxDtGrow ( Real  a_dtGrowFactor)

Set maximum factor by which a timestep can grow.

◆ timeEps() [1/2]

void AMR::timeEps ( Real  a_timeEps)

Set amount by which two times may differ and still be considered equal (used to determine whether we've reached stop time yet) In practice, this is multiplied by the current base-level timestep, so we consider ourselves finished if (stopTime - time) < timeEps*dt0

◆ fixedDt() [1/2]

void AMR::fixedDt ( Real  a_dt)

Set a fixed timestep. This must be called before calling setupForFixedHierarchyRun(), setupForNewAMRRun(), or setupForRestart(). Note also that fixedDt is not currently saved in checkpoint files

◆ initialTime()

void AMR::initialTime ( Real  a_initialTime)

Sets the initial time before starting compututation; this must be called before calling setupForFixedHierarchyRun() or setupForNewAMRRun(). Note that this will be over-ridden by m_checkpointfile if restarting using setupForRestart().

◆ useSubcyclingInTime()

void AMR::useSubcyclingInTime ( bool  a_useSubcycling)

Turn subcycling in time off or on. Default is true (use cycling).

◆ plotPrefix()

void AMR::plotPrefix ( const std::string &  a_plotfile_prefix)

Sets the plot file prefix.

Should be called after define() and before setup.

◆ isDefined()

bool AMR::isDefined ( ) const

Has a define() function been called? Lots of these functions will assert fail if not.

◆ isSetUp()

bool AMR::isSetUp ( ) const

Has a setup function been called? If not, you can't call run().

◆ maxGridSize() [2/2]

int AMR::maxGridSize ( ) const

Returns the maximum grid size.

◆ maxBaseGridSize() [2/2]

int AMR::maxBaseGridSize ( ) const

Returns the maximum grid size for level 0 grids.

◆ verbosity() [2/2]

int AMR::verbosity ( ) const

Returns current verbosity level.

-inf to 0: print nothing.
1: prints a message every coarse time step.
2: also prints a message when regridding and writing files.
3: also prints function trace, and some more inf during file I/O.
4 to inf: also prints list of boxes and processor maps during regrid.

◆ maxDtGrow() [2/2]

Real AMR::maxDtGrow ( ) const

Returns current maximum factor by which a timestep can grow.

◆ timeEps() [2/2]

Real AMR::timeEps ( ) const

Returns amount by which two times may differ and still be considered equal (used to determine whether we've reached stop time yet)

◆ fixedDt() [2/2]

Real AMR::fixedDt ( ) const

Returns the fixed timestep.

◆ getAMRLevels()

Vector<AMRLevel*> AMR::getAMRLevels ( )

Returns a vector of all the AMR levels

◆ getCurrentTime()

Real AMR::getCurrentTime ( ) const

Returns the current time

◆ timeStep()

int AMR::timeStep ( int  a_level,
int  a_stepsLeft,
bool  a_coarseTimeBoundary 
)
protected

◆ clearMemory()

void AMR::clearMemory ( )
protected

◆ regrid()

void AMR::regrid ( int  a_base_level)
protected

◆ initialGrid()

void AMR::initialGrid ( )
protected

◆ writePlotFile()

void AMR::writePlotFile ( ) const
protected

◆ writeCheckpointFile()

void AMR::writeCheckpointFile ( ) const
protected

◆ assignDt()

void AMR::assignDt ( )
protected

◆ needToRegrid()

bool AMR::needToRegrid ( int  a_level,
int  a_numStepsLeft 
) const
protected

◆ makeBaseLevelMesh()

virtual void AMR::makeBaseLevelMesh ( Vector< Box > &  a_grids) const
protectedvirtual

◆ setDefaultValues()

void AMR::setDefaultValues ( )
protected

Member Data Documentation

◆ s_step

int AMR::s_step
static

◆ m_useSubcycling

bool AMR::m_useSubcycling
protected

◆ m_blockFactor

int AMR::m_blockFactor
protected

◆ m_fillRatio

Real AMR::m_fillRatio
protected

◆ m_max_level

int AMR::m_max_level
protected

◆ m_finest_level_old

int AMR::m_finest_level_old
protected

◆ m_finest_level

int AMR::m_finest_level
protected

◆ m_checkpoint_interval

int AMR::m_checkpoint_interval
protected

◆ m_plot_interval

int AMR::m_plot_interval
protected

◆ m_plot_period

Real AMR::m_plot_period
protected

◆ m_next_plot_time

Real AMR::m_next_plot_time
protected

◆ m_max_grid_size

int AMR::m_max_grid_size
protected

◆ m_max_base_grid_size

int AMR::m_max_base_grid_size
protected

◆ m_dt_tolerance_factor

Real AMR::m_dt_tolerance_factor
protected

◆ m_fixedDt

Real AMR::m_fixedDt
protected

◆ m_checkForSteadyState

bool AMR::m_checkForSteadyState
protected

◆ m_isDefined

bool AMR::m_isDefined
protected

◆ m_isSetUp

bool AMR::m_isSetUp
protected

◆ m_amrlevels

Vector<AMRLevel*> AMR::m_amrlevels
protected

◆ m_ref_ratios

Vector<int> AMR::m_ref_ratios
protected

◆ m_reduction_factor

Vector<int> AMR::m_reduction_factor
protected

◆ m_regrid_intervals

Vector<int> AMR::m_regrid_intervals
protected

◆ m_dt_base

Real AMR::m_dt_base
protected

◆ m_dt_new

Vector<Real> AMR::m_dt_new
protected

◆ m_dt_cur

Vector<Real> AMR::m_dt_cur
protected

◆ m_maxDtGrow

Real AMR::m_maxDtGrow
protected

◆ m_time_eps

Real AMR::m_time_eps
protected

◆ m_mesh_refine_ptr

RefCountedPtr<MeshRefine> AMR::m_mesh_refine_ptr
protected

◆ m_use_meshrefine

bool AMR::m_use_meshrefine
protected

◆ m_amr_grids

Vector<Vector<Box> > AMR::m_amr_grids
protected

◆ m_cur_step

int AMR::m_cur_step
protected

◆ m_restart_step

int AMR::m_restart_step
protected

◆ m_lastcheck_step

int AMR::m_lastcheck_step
protected

◆ m_cur_time

Real AMR::m_cur_time
protected

◆ m_steps_since_regrid

Vector<int> AMR::m_steps_since_regrid
protected

◆ m_cell_updates

Vector<long long> AMR::m_cell_updates
protected

◆ m_plotfile_prefix

std::string AMR::m_plotfile_prefix
protected

◆ m_checkpointfile_prefix

std::string AMR::m_checkpointfile_prefix
protected

◆ m_verbosity

int AMR::m_verbosity
protected

◆ m_scheduler

RefCountedPtr<Scheduler> AMR::m_scheduler
protected

The documentation for this class was generated from the following file: