Virtual base class for managing individual levels. AmrLevel functions both as a container for state data on a level and also manages the advancement of data in time. More...
#include <AMReX_AmrLevel.H>
Public Types | |
enum | TimeLevel { AmrOldTime , AmrHalfTime , AmrNewTime , Amr1QtrTime , Amr3QtrTime , AmrOtherTime } |
What time are we at? More... | |
Public Member Functions | |
virtual | ~AmrLevel () |
The destructor. More... | |
AmrLevel (const AmrLevel &)=delete | |
AmrLevel (AmrLevel &&)=delete | |
AmrLevel & | operator= (const AmrLevel &)=delete |
AmrLevel & | operator= (AmrLevel &&)=delete |
void | LevelDirectoryNames (const std::string &dir, std::string &LevelDir, std::string &FullPath) const |
Get the level directory names. More... | |
virtual void | CreateLevelDirectory (const std::string &dir) |
Create the Level_ directory for checkpoint and plot files. More... | |
void | SetLevelDirectoryCreated (bool ldc) noexcept |
Set if the Level_ directory was created or to clear the value. CreateLevelDirectory sets levelDirectoryCreated = true. More... | |
virtual std::string | thePlotFileType () const |
A string written as the first item in writePlotFile() at level zero. It is so we can distinguish between different types of plot files. This default "HyperCLaw-V1.1" is for VisIt software and some of our internal postprocessing routines. More... | |
virtual void | writePlotFile (const std::string &dir, std::ostream &os, VisMF::How how=VisMF::NFiles) |
Write plot file stuff to specified directory. More... | |
virtual void | writePlotFilePre (const std::string &dir, std::ostream &os) |
Do pre-plotfile work to avoid synchronizations while writing the amr hierarchy. More... | |
virtual void | writePlotFilePost (const std::string &dir, std::ostream &os) |
Do post-plotfile work to avoid synchronizations while writing the amr hierarchy. More... | |
virtual void | writeSmallPlotFile (const std::string &, std::ostream &, VisMF::How=VisMF::NFiles) |
Write small plot file stuff to specified directory. More... | |
virtual void | checkPoint (const std::string &dir, std::ostream &os, VisMF::How how=VisMF::NFiles, bool dump_old=true) |
Write current state to checkpoint file. More... | |
virtual void | checkPointPre (const std::string &dir, std::ostream &os) |
Do pre-checkpoint work to avoid synchronizations while writing the amr hierarchy. More... | |
virtual void | checkPointPost (const std::string &dir, std::ostream &os) |
Do post-checkpoint work to avoid synchronizations while writing the amr hierarchy. More... | |
virtual void | restart (Amr &papa, std::istream &is, bool bReadSpecial=false) |
Restart from a checkpoint file. More... | |
virtual void | set_state_in_checkpoint (Vector< int > &state_in_checkpoint) |
Old checkpoint may have different number of states than the new source code. More... | |
virtual void | computeInitialDt (int finest_level, int sub_cycle, Vector< int > &n_cycle, const Vector< IntVect > &ref_ratio, Vector< Real > &dt_level, Real stop_time)=0 |
Compute the initial time step. This is a pure virtual function and hence MUST be implemented by derived classes. More... | |
virtual void | computeNewDt (int finest_level, int sub_cycle, Vector< int > &n_cycle, const Vector< IntVect > &ref_ratio, Vector< Real > &dt_min, Vector< Real > &dt_level, Real stop_time, int post_regrid_flag)=0 |
Compute the next time step. This is a pure virtual function and hence MUST be implemented by derived classes. More... | |
virtual Real | advance (Real time, Real dt, int iteration, int ncycle)=0 |
Do an integration step on this level. Returns maximum safe time step. This is a pure virtual function and hence MUST be implemented by derived classes. More... | |
virtual void | post_timestep (int iteration) |
Contains operations to be done after a timestep. If this function is overridden, don't forget to reset FillPatcher. More... | |
virtual void | postCoarseTimeStep (Real time) |
Contains operations to be done only after a full coarse timestep. The default implementation does nothing. More... | |
virtual void | post_restart () |
Operations to be done after restart. More... | |
virtual void | post_regrid (int lbase, int new_finest)=0 |
Operations to be done after regridding This is a pure virtual function and hence MUST be implemented by derived classes. More... | |
virtual void | post_init (Real stop_time)=0 |
Operations to be done after initialization. This is a pure virtual function and hence MUST be implemented by derived classes. More... | |
virtual int | okToContinue () |
Is it ok to continue the calculation? More... | |
virtual int | okToRegrid () |
Should I regrid with this level as base level? This test is only evaluated if regrid_int > 0 and level_count >= regrid_int as well. Defaults to true. More... | |
virtual void | initData ()=0 |
Init grid data at problem start-up. This is a pure virtual function and hence MUST be implemented by derived classes. More... | |
virtual void | setTimeLevel (Real time, Real dt_old, Real dt_new) |
Set the time levels of state data. More... | |
virtual void | allocOldData () |
Alloc space for old time data. More... | |
virtual void | removeOldData () |
Delete old-time data. More... | |
virtual void | init (AmrLevel &old)=0 |
Init data on this level from another AmrLevel (during regrid). This is a pure virtual function and hence MUST be implemented by derived classes. More... | |
virtual void | init ()=0 |
void | reset () |
Reset data to initial time by swapping new and old time data. More... | |
int | Level () const noexcept |
Returns this AmrLevel. More... | |
const BoxArray & | boxArray () const noexcept |
List of grids at this level. More... | |
const BoxArray & | getEdgeBoxArray (int dir) const noexcept |
const BoxArray & | getNodalBoxArray () const noexcept |
const DistributionMapping & | DistributionMap () const noexcept |
const FabFactory< FArrayBox > & | Factory () const noexcept |
int | numGrids () const noexcept |
Number of grids at this level. More... | |
int | numStates () const noexcept |
Number of states at this level. More... | |
const Box & | Domain () const noexcept |
Returns the indices defining physical domain. More... | |
int | nStep () const noexcept |
Timestep n at this level. More... | |
const Geometry & | Geom () const noexcept |
Returns the geometry object. More... | |
const IntVect & | fineRatio () const noexcept |
Long | countCells () const noexcept |
Returns number of cells on level. More... | |
const BoxArray & | getAreaNotToTag () noexcept |
Get the area not to tag. More... | |
const Box & | getAreaToTag () noexcept |
void | constructAreaNotToTag () |
Construct the area not to tag. More... | |
void | setAreaNotToTag (BoxArray &ba) noexcept |
Set the area not to tag. More... | |
void | resetFillPatcher () |
virtual void | errorEst (TagBoxArray &tb, int clearval, int tagval, Real time, int n_error_buf=0, int ngrow=0)=0 |
Error estimation for regridding. This is a pure virtual function and hence MUST be implemented by derived classes. More... | |
void | FillCoarsePatch (MultiFab &mf, int dcomp, Real time, int state_idx, int scomp, int ncomp, int nghost=0) |
Interpolate from coarse level to the valid area in mf. More... | |
virtual void | setPhysBoundaryValues (FArrayBox &dest, int state_indx, Real time, int dest_comp, int src_comp, int num_comp) |
Function to set physical boundary conditions. More... | |
virtual std::unique_ptr< MultiFab > | derive (const std::string &name, Real time, int ngrow) |
Returns a MultiFab containing the derived data for this level. The user is responsible for deleting this pointer when done with it. If ngrow>0 the MultiFab is built on the appropriately grown BoxArray. More... | |
virtual void | derive (const std::string &name, Real time, MultiFab &mf, int dcomp) |
This version of derive() fills the dcomp'th component of mf with the derived quantity. More... | |
StateData & | get_state_data (int state_indx) noexcept |
State data object. More... | |
MultiFab & | get_old_data (int state_indx) noexcept |
State data at old time. More... | |
const MultiFab & | get_old_data (int state_indx) const noexcept |
State data at old time. More... | |
MultiFab & | get_new_data (int state_indx) noexcept |
State data at new time. More... | |
const MultiFab & | get_new_data (int state_indx) const noexcept |
State data at new time. More... | |
int | postStepRegrid () const noexcept |
Returns whether or not we want a post-timestep regrid. More... | |
void | setPostStepRegrid (int new_val) noexcept |
Sets a new value for the post-timestep regrid trigger. More... | |
void | UpdateDistributionMaps (DistributionMapping &dmap) |
Update the distribution maps in StateData based on the size of the map. More... | |
Vector< int > | getBCArray (int State_Type, int gridno, int strt_comp, int ncomp) |
Boundary condition access function. More... | |
MultiFab & | get_data (int state_indx, Real time) noexcept |
Get state data at specified index and time. More... | |
virtual void | set_preferred_boundary_values (MultiFab &S, int state_index, int scomp, int dcomp, int ncomp, Real time) const |
Hack to allow override of (non-fine-fine) fillpatched boundary data. More... | |
virtual void | manual_tags_placement (TagBoxArray &tags, const Vector< IntVect > &bf_lev) |
Called in grid_places after other tagging routines to modify the list of tagged points. Default implementation does nothing. More... | |
virtual void | setPlotVariables () |
Modify list of variables to be plotted. More... | |
virtual void | setSmallPlotVariables () |
Modify list of variables to be plotted. More... | |
virtual Real | estimateWork () |
Estimate the amount of work required to advance Just this level based on the number of cells. This estimate can be overwritten with different methods. More... | |
virtual int | WorkEstType () |
Which state data type is for work estimates? -1 means none. More... | |
TimeLevel | which_time (int state_indx, Real time) const noexcept |
Returns one the TimeLevel enums. Asserts that time is between AmrOldTime and AmrNewTime. More... | |
virtual bool | writePlotNow () |
Does the AmrLevel want Amr to write a plotfile now? More... | |
virtual bool | writeSmallPlotNow () |
Does the AmrLevel want Amr to write a small plotfile now? More... | |
void | FillPatcherFill (amrex::MultiFab &mf, int dcomp, int ncomp, int nghost, amrex::Real time, int state_index, int scomp) |
Fill with FillPatcher on level > 0 and AmrLevel::FillPatch on level 0. More... | |
template<typename F , typename P = RungeKutta::PostStageNoOp> | |
void | RK (int order, int state_type, Real time, Real dt, int iteration, int ncycle, F &&f, P &&p=RungeKutta::PostStageNoOp()) |
Evolve one step with Runge-Kutta (2, 3, or 4) More... | |
Static Public Member Functions | |
static bool | isStateVariable (const std::string &name, int &state_indx, int &ncomp) |
Is name a state variable? More... | |
static void | FlushFPICache () |
static const DescriptorList & | get_desc_lst () noexcept |
Returns list of Descriptors. More... | |
static DeriveList & | get_derive_lst () noexcept |
Returns list of derived variables. More... | |
static void | FillPatch (AmrLevel &amrlevel, MultiFab &leveldata, int boxGrow, Real time, int index, int scomp, int ncomp, int dcomp=0) |
static void | FillPatchAdd (AmrLevel &amrlevel, MultiFab &leveldata, int boxGrow, Real time, int index, int scomp, int ncomp, int dcomp=0) |
static IntVect | ProperBlockingFactor (AmrLevel const &amr_level, int boxGrow, IndexType const &boxType, StateDescriptor const &desc, int SComp) |
Recommendation of a proper blocking factor. More... | |
Protected Member Functions | |
AmrLevel () noexcept | |
The constructors – for derived classes. More... | |
AmrLevel (Amr &papa, int lev, const Geometry &level_geom, const BoxArray &ba, const DistributionMapping &dm, Real time) | |
void | finishConstructor () |
Common code used by all constructors. More... | |
Protected Attributes | |
int | level {-1} |
Geometry | geom |
BoxArray | grids |
DistributionMapping | dmap |
Amr * | parent {nullptr} |
IntVect | crse_ratio |
IntVect | fine_ratio |
Vector< StateData > | state |
BoxArray | m_AreaNotToTag |
Box | m_AreaToTag |
int | post_step_regrid {0} |
bool | levelDirectoryCreated {false} |
std::unique_ptr< FabFactory< FArrayBox > > | m_factory |
Vector< std::unique_ptr< FillPatcher< MultiFab > > > | m_fillpatcher |
Static Protected Attributes | |
static DeriveList | derive_lst |
static DescriptorList | desc_lst |
Private Member Functions | |
template<std::size_t order> | |
void | storeRKCoarseData (int state_type, Real time, Real dt, MultiFab const &S_old, Array< MultiFab, order > const &rkk) |
void | FillRKPatch (int state_index, MultiFab &S, Real time, int stage, int iteration, int ncycle) |
Private Attributes | |
BoxArray | edge_grids [AMREX_SPACEDIM] |
BoxArray | nodal_grids |
Friends | |
class | Amr |
class | FillPatchIterator |
class | FillPatchIteratorHelper |
Virtual base class for managing individual levels. AmrLevel functions both as a container for state data on a level and also manages the advancement of data in time.
|
virtual |
The destructor.
|
delete |
|
delete |
|
inlineprotectednoexcept |
The constructors – for derived classes.
|
protected |
|
pure virtual |
Do an integration step on this level. Returns maximum safe time step. This is a pure virtual function and hence MUST be implemented by derived classes.
|
virtual |
Alloc space for old time data.
|
inlinenoexcept |
List of grids at this level.
|
virtual |
Write current state to checkpoint file.
|
virtual |
Do post-checkpoint work to avoid synchronizations while writing the amr hierarchy.
|
virtual |
Do pre-checkpoint work to avoid synchronizations while writing the amr hierarchy.
|
pure virtual |
Compute the initial time step. This is a pure virtual function and hence MUST be implemented by derived classes.
|
pure virtual |
Compute the next time step. This is a pure virtual function and hence MUST be implemented by derived classes.
void amrex::AmrLevel::constructAreaNotToTag | ( | ) |
Construct the area not to tag.
|
noexcept |
Returns number of cells on level.
|
virtual |
Create the Level_ directory for checkpoint and plot files.
|
virtual |
This version of derive() fills the dcomp'th component of mf with the derived quantity.
|
inlinenoexcept |
|
inlinenoexcept |
Returns the indices defining physical domain.
|
pure virtual |
Error estimation for regridding. This is a pure virtual function and hence MUST be implemented by derived classes.
|
virtual |
Estimate the amount of work required to advance Just this level based on the number of cells. This estimate can be overwritten with different methods.
|
inlinenoexcept |
void amrex::AmrLevel::FillCoarsePatch | ( | MultiFab & | mf, |
int | dcomp, | ||
Real | time, | ||
int | state_idx, | ||
int | scomp, | ||
int | ncomp, | ||
int | nghost = 0 |
||
) |
Interpolate from coarse level to the valid area in mf.
|
static |
|
static |
void amrex::AmrLevel::FillPatcherFill | ( | amrex::MultiFab & | mf, |
int | dcomp, | ||
int | ncomp, | ||
int | nghost, | ||
amrex::Real | time, | ||
int | state_index, | ||
int | scomp | ||
) |
Fill with FillPatcher on level > 0 and AmrLevel::FillPatch on level 0.
|
private |
|
inlinenoexcept |
|
protected |
Common code used by all constructors.
|
static |
|
inlinenoexcept |
Returns the geometry object.
Get state data at specified index and time.
|
staticnoexcept |
Returns list of derived variables.
|
inlinestaticnoexcept |
Returns list of Descriptors.
State data at new time.
State data at old time.
|
noexcept |
Get the area not to tag.
|
noexcept |
Boundary condition access function.
|
noexcept |
|
pure virtual |
Init data on this level after regridding if old AmrLevel did not previously exist. This is a pure virtual function and hence MUST be implemented by derived classes.
|
pure virtual |
Init data on this level from another AmrLevel (during regrid). This is a pure virtual function and hence MUST be implemented by derived classes.
|
pure virtual |
Init grid data at problem start-up. This is a pure virtual function and hence MUST be implemented by derived classes.
|
static |
Is name a state variable?
void amrex::AmrLevel::LevelDirectoryNames | ( | const std::string & | dir, |
std::string & | LevelDir, | ||
std::string & | FullPath | ||
) | const |
Get the level directory names.
|
virtual |
Called in grid_places after other tagging routines to modify the list of tagged points. Default implementation does nothing.
|
inlinenoexcept |
Timestep n at this level.
|
inlinenoexcept |
Number of grids at this level.
|
inlinenoexcept |
Number of states at this level.
|
inlinevirtual |
Is it ok to continue the calculation?
|
virtual |
Should I regrid with this level as base level? This test is only evaluated if regrid_int > 0 and level_count >= regrid_int as well. Defaults to true.
|
pure virtual |
Operations to be done after initialization. This is a pure virtual function and hence MUST be implemented by derived classes.
Operations to be done after regridding This is a pure virtual function and hence MUST be implemented by derived classes.
|
inlinevirtual |
Operations to be done after restart.
|
virtual |
Contains operations to be done after a timestep. If this function is overridden, don't forget to reset FillPatcher.
|
virtual |
Contains operations to be done only after a full coarse timestep. The default implementation does nothing.
|
inlinenoexcept |
Returns whether or not we want a post-timestep regrid.
|
static |
Recommendation of a proper blocking factor.
|
virtual |
Delete old-time data.
void amrex::AmrLevel::reset | ( | ) |
Reset data to initial time by swapping new and old time data.
void amrex::AmrLevel::resetFillPatcher | ( | ) |
|
virtual |
Restart from a checkpoint file.
void amrex::AmrLevel::RK | ( | int | order, |
int | state_type, | ||
Real | time, | ||
Real | dt, | ||
int | iteration, | ||
int | ncycle, | ||
F && | f, | ||
P && | p = RungeKutta::PostStageNoOp() |
||
) |
Evolve one step with Runge-Kutta (2, 3, or 4)
To use RK, the StateData must have all the ghost cells needed. See namespace RungeKutta for expected function signatures of the callable parameters.
order | order of RK |
state_type | index of StateData |
time | time at the beginning of the step. |
dt | time step |
iteration | iteration number on fine level during a coarse time step. For an AMR simulation with subcycling and a refinement ratio of 2, the number is either 1 or 2, denoting the first and second substep, respectively. |
ncycle | number of subcyling steps. It's usually 2 or 4. Without subcycling, this will be 1. |
f | computing right-hand side for evolving the StateData. One can also register data for flux registers in this. |
p | optionally post-processing RK stage results |
|
virtual |
Hack to allow override of (non-fine-fine) fillpatched boundary data.
Old checkpoint may have different number of states than the new source code.
|
noexcept |
Set the area not to tag.
|
inlinenoexcept |
Set if the Level_ directory was created or to clear the value. CreateLevelDirectory sets levelDirectoryCreated = true.
|
virtual |
Function to set physical boundary conditions.
|
virtual |
Modify list of variables to be plotted.
|
inlinenoexcept |
Sets a new value for the post-timestep regrid trigger.
|
virtual |
Modify list of variables to be plotted.
|
virtual |
Set the time levels of state data.
|
private |
|
inlinevirtual |
A string written as the first item in writePlotFile() at level zero. It is so we can distinguish between different types of plot files. This default "HyperCLaw-V1.1" is for VisIt software and some of our internal postprocessing routines.
void amrex::AmrLevel::UpdateDistributionMaps | ( | DistributionMapping & | dmap | ) |
Update the distribution maps in StateData based on the size of the map.
|
noexcept |
Returns one the TimeLevel enums. Asserts that time is between AmrOldTime and AmrNewTime.
|
inlinevirtual |
Which state data type is for work estimates? -1 means none.
|
virtual |
Write plot file stuff to specified directory.
|
virtual |
Do post-plotfile work to avoid synchronizations while writing the amr hierarchy.
|
virtual |
Do pre-plotfile work to avoid synchronizations while writing the amr hierarchy.
|
inlinevirtual |
Write small plot file stuff to specified directory.
|
virtual |
|
friend |
|
friend |
|
friend |
|
protected |
|
staticprotected |
|
staticprotected |
|
protected |
|
mutableprivate |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
mutableprivate |
|
protected |
|
protected |