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. | |
| 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. | |
| virtual void | CreateLevelDirectory (const std::string &dir) |
| Create the Level_ directory for checkpoint and plot files. | |
| void | SetLevelDirectoryCreated (bool ldc) noexcept |
| Set if the Level_ directory was created or to clear the value. CreateLevelDirectory sets levelDirectoryCreated = true. | |
| 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. | |
| virtual void | writePlotFile (const std::string &dir, std::ostream &os, VisMF::How how=VisMF::NFiles) |
| Write plot file stuff to specified directory. | |
| virtual void | writePlotFilePre (const std::string &dir, std::ostream &os) |
| Do pre-plotfile work to avoid synchronizations while writing the amr hierarchy. | |
| virtual void | writePlotFilePost (const std::string &dir, std::ostream &os) |
| Do post-plotfile work to avoid synchronizations while writing the amr hierarchy. | |
| virtual void | writeSmallPlotFile (const std::string &, std::ostream &, VisMF::How=VisMF::NFiles) |
| Write small plot file stuff to specified directory. | |
| 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. | |
| virtual void | checkPointPre (const std::string &dir, std::ostream &os) |
| Do pre-checkpoint work to avoid synchronizations while writing the amr hierarchy. | |
| virtual void | checkPointPost (const std::string &dir, std::ostream &os) |
| Do post-checkpoint work to avoid synchronizations while writing the amr hierarchy. | |
| virtual void | restart (Amr &papa, std::istream &is, bool bReadSpecial=false) |
| Restart from a checkpoint file. | |
| virtual void | set_state_in_checkpoint (Vector< int > &state_in_checkpoint) |
| Old checkpoint may have different number of states than the new source code. | |
| 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. | |
| 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. | |
| 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. | |
| 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. | |
| virtual void | postCoarseTimeStep (Real time) |
| Contains operations to be done only after a full coarse timestep. The default implementation does nothing. | |
| virtual void | post_restart () |
| Operations to be done after restart. | |
| 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. | |
| 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. | |
| virtual int | okToContinue () |
| Is it ok to continue the calculation? | |
| 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. | |
| 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. | |
| virtual void | setTimeLevel (Real time, Real dt_old, Real dt_new) |
| Set the time levels of state data. | |
| virtual void | allocOldData () |
| Alloc space for old time data. | |
| virtual void | removeOldData () |
| Delete old-time data. | |
| 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. | |
| virtual void | init ()=0 |
| void | reset () |
| Reset data to initial time by swapping new and old time data. | |
| int | Level () const noexcept |
| Returns this AmrLevel. | |
| const BoxArray & | boxArray () const noexcept |
| List of grids at this level. | |
| const BoxArray & | getEdgeBoxArray (int dir) const noexcept |
| const BoxArray & | getNodalBoxArray () const noexcept |
| const DistributionMapping & | DistributionMap () const noexcept |
| const FabFactory< FArrayBox > & | Factory () const noexcept |
| const EBFArrayBoxFactory & | EBFactory () const noexcept |
| int | numGrids () const noexcept |
| Number of grids at this level. | |
| int | numStates () const noexcept |
| Number of states at this level. | |
| const Box & | Domain () const noexcept |
| Returns the indices defining physical domain. | |
| int | nStep () const noexcept |
| Timestep n at this level. | |
| const Geometry & | Geom () const noexcept |
| Returns the geometry object. | |
| const IntVect & | fineRatio () const noexcept |
| Long | countCells () const noexcept |
| Returns number of cells on level. | |
| const BoxArray & | getAreaNotToTag () noexcept |
| Get the area not to tag. | |
| const Box & | getAreaToTag () noexcept |
| void | constructAreaNotToTag () |
| Construct the area not to tag. | |
| void | setAreaNotToTag (BoxArray &ba) noexcept |
| Set the area not to tag. | |
| 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. | |
| 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. | |
| 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. | |
| 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. | |
| 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. | |
| StateData & | get_state_data (int state_indx) noexcept |
| State data object. | |
| MultiFab & | get_old_data (int state_indx) noexcept |
| State data at old time. | |
| const MultiFab & | get_old_data (int state_indx) const noexcept |
| State data at old time. | |
| MultiFab & | get_new_data (int state_indx) noexcept |
| State data at new time. | |
| const MultiFab & | get_new_data (int state_indx) const noexcept |
| State data at new time. | |
| int | postStepRegrid () const noexcept |
| Returns whether or not we want a post-timestep regrid. | |
| void | setPostStepRegrid (int new_val) noexcept |
| Sets a new value for the post-timestep regrid trigger. | |
| void | UpdateDistributionMaps (DistributionMapping &dmap) |
| Update the distribution maps in StateData based on the size of the map. | |
| Vector< int > | getBCArray (int State_Type, int gridno, int strt_comp, int ncomp) |
| Boundary condition access function. | |
| MultiFab & | get_data (int state_indx, Real time) noexcept |
| Get state data at specified index and time. | |
| 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. | |
| 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. | |
| virtual void | setPlotVariables () |
| Modify list of variables to be plotted. | |
| virtual void | setSmallPlotVariables () |
| Modify list of variables to be plotted. | |
| 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. | |
| virtual int | WorkEstType () |
| Which state data type is for work estimates? -1 means none. | |
| TimeLevel | which_time (int state_indx, Real time) const noexcept |
| Returns one the TimeLevel enums. Asserts that time is between AmrOldTime and AmrNewTime. | |
| virtual bool | checkPointNow () |
| virtual bool | writePlotNow () |
| Does the AmrLevel want Amr to write a plotfile now? | |
| virtual bool | writeSmallPlotNow () |
| Does the AmrLevel want Amr to write a small plotfile now? | |
| virtual void | particle_redistribute (int=0, bool=false) |
| This function can be called from the parent. | |
| 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. | |
| 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) | |
Static Public Member Functions | |
| static bool | isStateVariable (const std::string &name, int &state_indx, int &ncomp) |
| Is name a state variable? | |
| static void | FlushFPICache () |
| static const DescriptorList & | get_desc_lst () noexcept |
| Returns list of Descriptors. | |
| static DeriveList & | get_derive_lst () noexcept |
| Returns list of derived variables. | |
| 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 void | SetEBMaxGrowCells (int nbasic, int nvolume, int nfull) noexcept |
| static void | SetEBSupportLevel (EBSupport ebs) |
| static IntVect | ProperBlockingFactor (AmrLevel const &amr_level, int boxGrow, IndexType const &boxType, StateDescriptor const &desc, int SComp) |
| Recommendation of a proper blocking factor. | |
Static Public Attributes | |
| static int | m_eb_basic_grow_cells = 5 |
| static int | m_eb_volume_grow_cells = 4 |
| static int | m_eb_full_grow_cells = 2 |
| static EBSupport | m_eb_support_level = EBSupport::volume |
Protected Member Functions | |
| AmrLevel () noexcept | |
| The constructors – for derived classes. | |
| 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. | |
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 [3] |
| 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 |
|
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 |
|
virtual |
This version of derive() fills the dcomp'th component of mf with the derived quantity.
|
inlinenoexcept |
|
inlinenoexcept |
Returns the indices defining physical domain.
|
inlinenoexcept |
|
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.
|
noexcept |
Get state data at specified index and time.
|
staticnoexcept |
Returns list of derived variables.
|
inlinestaticnoexcept |
Returns list of Descriptors.
|
inlinenoexcept |
State data at new time.
|
inlinenoexcept |
State data at new time.
|
inlinenoexcept |
State data at old time.
|
inlinenoexcept |
State data at old time.
|
inlinenoexcept |
State data object.
|
noexcept |
Get the area not to tag.
|
noexcept |
| Vector< int > amrex::AmrLevel::getBCArray | ( | int | State_Type, |
| int | gridno, | ||
| int | strt_comp, | ||
| int | ncomp | ||
| ) |
Boundary condition access function.
|
noexcept |
|
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?
|
inlinenoexcept |
Returns this AmrLevel.
| 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.
|
inlinevirtual |
This function can be called from the parent.
|
pure virtual |
Operations to be done after initialization. This is a pure virtual function and hence MUST be implemented by derived classes.
|
pure virtual |
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.
|
virtual |
Old checkpoint may have different number of states than the new source code.
|
noexcept |
Set the area not to tag.
|
inlinestaticnoexcept |
|
inlinestatic |
|
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 |
|
static |
|
static |
|
static |
|
static |
|
protected |
|
protected |
|
mutableprivate |
|
protected |
|
protected |