2#ifndef AMREX_AmrLevel_H_
3#define AMREX_AmrLevel_H_
4#include <AMReX_Config.H>
62 std::string &LevelDir,
63 std::string &FullPath)
const;
81 static const std::string the_plot_file_type(
"HyperCLaw-V1.1");
82 return the_plot_file_type;
106 virtual void checkPoint (
const std::string& dir,
109 bool dump_old =
true);
119 bool bReadSpecial =
false);
151 int post_regrid_flag) = 0;
301 virtual std::unique_ptr<
MultiFab>
derive (const std::
string& name,
308 virtual
void derive (const std::
string& name,
382#ifdef AMREX_PARTICLES
440 template <
typename F,
typename P = RungeKutta::PostStageNoOp>
441 void RK (
int order,
int state_type,
Real time,
Real dt,
int iteration,
503 template <std::
size_t order>
504 void storeRKCoarseData (
int state_type,
Real time,
Real dt,
508 void FillRKPatch (
int state_index,
MultiFab& S,
Real time,
509 int stage,
int iteration,
int ncycle);
511 mutable BoxArray edge_grids[AMREX_SPACEDIM];
553 void FillFromLevel0 (
Real time,
int idx,
int scomp,
int dcomp,
int ncomp);
554 void FillFromTwoLevels (
Real time,
int idx,
int scomp,
int dcomp,
int ncomp);
561 std::vector< std::pair<int,int> > m_range;
602 std::map<int,Box> m_ba;
603 Real m_time = std::numeric_limits<Real>::lowest();
604 int m_growsize = std::numeric_limits<int>::lowest();
608 bool m_FixUpCorners =
false;
610 std::map< int,Vector< Vector<Box> > > m_fbox;
611 std::map< int,Vector< Vector<Box> > > m_cbox;
612 std::map< int,Vector< Vector< Vector<FillBoxId> > > > m_fbid;
615template <
typename F,
typename P>
617 int ncycle,
F&& f, P&& p)
632 }
else if (order == 3) {
635 FillRKPatch(state_type, mf, t, stage, iteration, ncycle);
638 if (level < parent->finestLevel()) {
639 storeRKCoarseData(state_type, time, dt, S_old, rkk);
643 }
else if (order == 4) {
646 FillRKPatch(state_type, mf, t, stage, iteration, ncycle);
649 if (level < parent->finestLevel()) {
650 storeRKCoarseData(state_type, time, dt, S_old, rkk);
655 amrex::Abort(
"AmrLevel::RK: order = "+std::to_string(order)+
" is not supported");
659template <std::
size_t order>
660void AmrLevel::storeRKCoarseData (
int state_type,
Real time,
Real dt,
670 fillpatcher = std::make_unique<FillPatcher<MultiFab>>
675 IntVect(desc.nExtra()), desc.nComp(), desc.interp(0));
677 fillpatcher->storeRKCoarseData(time, dt, S_old, rkk);
#define BL_PROFILE(a)
Definition AMReX_BLProfiler.H:551
#define AMREX_ASSERT(EX)
Definition AMReX_BLassert.H:38
Virtual base class for managing individual levels. AmrLevel functions both as a container for state d...
Definition AMReX_AmrLevel.H:39
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 ...
virtual Real estimateWork()
Estimate the amount of work required to advance Just this level based on the number of cells....
Definition AMReX_AmrLevel.cpp:2053
virtual void restart(Amr &papa, std::istream &is, bool bReadSpecial=false)
Restart from a checkpoint file.
Definition AMReX_AmrLevel.cpp:386
void reset()
Reset data to initial time by swapping new and old time data.
Definition AMReX_AmrLevel.cpp:596
Long countCells() const noexcept
Returns number of cells on level.
Definition AMReX_AmrLevel.cpp:504
IntVect fine_ratio
Definition AMReX_AmrLevel.H:485
int level
Definition AMReX_AmrLevel.H:479
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.
Definition AMReX_AmrLevel.cpp:510
int Level() const noexcept
Returns this AmrLevel.
Definition AMReX_AmrLevel.H:228
virtual void writePlotFilePre(const std::string &dir, std::ostream &os)
Do pre-plotfile work to avoid synchronizations while writing the amr hierarchy.
Definition AMReX_AmrLevel.cpp:372
virtual int WorkEstType()
Which state data type is for work estimates? -1 means none.
Definition AMReX_AmrLevel.H:366
virtual bool writePlotNow()
Does the AmrLevel want Amr to write a plotfile now?
Definition AMReX_AmrLevel.cpp:2065
virtual void init(AmrLevel &old)=0
Init data on this level from another AmrLevel (during regrid). This is a pure virtual function and he...
static int m_eb_volume_grow_cells
Definition AMReX_AmrLevel.H:451
const Geometry & Geom() const noexcept
Returns the geometry object.
Definition AMReX_AmrLevel.H:254
static IntVect ProperBlockingFactor(AmrLevel const &amr_level, int boxGrow, IndexType const &boxType, StateDescriptor const &desc, int SComp)
Recommendation of a proper blocking factor.
Definition AMReX_AmrLevel.cpp:2282
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 deriv...
Vector< std::unique_ptr< FillPatcher< MultiFab > > > m_fillpatcher
Definition AMReX_AmrLevel.H:499
virtual bool writeSmallPlotNow()
Does the AmrLevel want Amr to write a small plotfile now?
Definition AMReX_AmrLevel.cpp:2071
void LevelDirectoryNames(const std::string &dir, std::string &LevelDir, std::string &FullPath) const
Get the level directory names.
Definition AMReX_AmrLevel.cpp:2229
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 ...
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 t...
Definition AMReX_AmrLevel.cpp:1615
const BoxArray & boxArray() const noexcept
List of grids at this level.
Definition AMReX_AmrLevel.H:230
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....
Definition AMReX_AmrLevel.cpp:63
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.
Definition AMReX_AmrLevel.cpp:647
const MultiFab & get_old_data(int state_indx) const noexcept
State data at old time.
Definition AMReX_AmrLevel.H:317
void SetLevelDirectoryCreated(bool ldc) noexcept
Set if the Level_ directory was created or to clear the value. CreateLevelDirectory sets levelDirecto...
Definition AMReX_AmrLevel.H:70
void setPostStepRegrid(int new_val) noexcept
Sets a new value for the post-timestep regrid trigger.
Definition AMReX_AmrLevel.H:329
const IntVect & fineRatio() const noexcept
Definition AMReX_AmrLevel.H:256
virtual void writePlotFilePost(const std::string &dir, std::ostream &os)
Do post-plotfile work to avoid synchronizations while writing the amr hierarchy.
Definition AMReX_AmrLevel.cpp:379
Vector< int > getBCArray(int State_Type, int gridno, int strt_comp, int ncomp)
Boundary condition access function.
Definition AMReX_AmrLevel.cpp:1869
const FabFactory< FArrayBox > & Factory() const noexcept
Definition AMReX_AmrLevel.H:236
Box m_AreaToTag
Definition AMReX_AmrLevel.H:491
static void FillPatch(AmrLevel &amrlevel, MultiFab &leveldata, int boxGrow, Real time, int index, int scomp, int ncomp, int dcomp=0)
Definition AMReX_AmrLevel.cpp:2193
virtual void removeOldData()
Delete old-time data.
Definition AMReX_AmrLevel.cpp:587
Geometry geom
Definition AMReX_AmrLevel.H:480
TimeLevel which_time(int state_indx, Real time) const noexcept
Returns one the TimeLevel enums. Asserts that time is between AmrOldTime and AmrNewTime.
Definition AMReX_AmrLevel.cpp:2018
virtual void setTimeLevel(Real time, Real dt_old, Real dt_new)
Set the time levels of state data.
Definition AMReX_AmrLevel.cpp:476
virtual int okToContinue()
Is it ok to continue the calculation?
Definition AMReX_AmrLevel.H:192
const BoxArray & getNodalBoxArray() const noexcept
Definition AMReX_AmrLevel.cpp:637
StateData & get_state_data(int state_indx) noexcept
State data object.
Definition AMReX_AmrLevel.H:313
MultiFab & get_data(int state_indx, Real time) noexcept
Get state data at specified index and time.
Definition AMReX_AmrLevel.cpp:605
const EBFArrayBoxFactory & EBFactory() const noexcept
Definition AMReX_AmrLevel.H:240
BoxArray grids
Definition AMReX_AmrLevel.H:481
virtual void allocOldData()
Alloc space for old time data.
Definition AMReX_AmrLevel.cpp:578
virtual void set_state_in_checkpoint(Vector< int > &state_in_checkpoint)
Old checkpoint may have different number of states than the new source code.
Definition AMReX_AmrLevel.cpp:467
static int m_eb_full_grow_cells
Definition AMReX_AmrLevel.H:452
void UpdateDistributionMaps(DistributionMapping &dmap)
Update the distribution maps in StateData based on the size of the map.
Definition AMReX_AmrLevel.cpp:1852
const DistributionMapping & DistributionMap() const noexcept
Definition AMReX_AmrLevel.H:234
virtual void postCoarseTimeStep(Real time)
Contains operations to be done only after a full coarse timestep. The default implementation does not...
Definition AMReX_AmrLevel.cpp:43
virtual void post_timestep(int iteration)
Contains operations to be done after a timestep. If this function is overridden, don't forget to rese...
Definition AMReX_AmrLevel.cpp:35
const Box & Domain() const noexcept
Returns the indices defining physical domain.
Definition AMReX_AmrLevel.H:250
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 der...
static DeriveList derive_lst
Definition AMReX_AmrLevel.H:486
void constructAreaNotToTag()
Construct the area not to tag.
Definition AMReX_AmrLevel.cpp:2091
bool levelDirectoryCreated
Definition AMReX_AmrLevel.H:495
static void SetEBSupportLevel(EBSupport ebs)
Definition AMReX_AmrLevel.H:453
static DeriveList & get_derive_lst() noexcept
Returns list of derived variables.
Definition AMReX_AmrLevel.cpp:57
IntVect crse_ratio
Definition AMReX_AmrLevel.H:484
virtual void setPlotVariables()
Modify list of variables to be plotted.
Definition AMReX_AmrLevel.cpp:1897
const Box & getAreaToTag() noexcept
Definition AMReX_AmrLevel.cpp:2081
virtual void writeSmallPlotFile(const std::string &, std::ostream &, VisMF::How=VisMF::NFiles)
Write small plot file stuff to specified directory.
Definition AMReX_AmrLevel.H:102
virtual bool checkPointNow()
Definition AMReX_AmrLevel.cpp:2059
TimeLevel
What time are we at?
Definition AMReX_AmrLevel.H:46
@ Amr1QtrTime
Definition AMReX_AmrLevel.H:49
@ AmrOldTime
Definition AMReX_AmrLevel.H:46
@ AmrNewTime
Definition AMReX_AmrLevel.H:48
@ AmrOtherTime
Definition AMReX_AmrLevel.H:51
@ AmrHalfTime
Definition AMReX_AmrLevel.H:47
@ Amr3QtrTime
Definition AMReX_AmrLevel.H:50
virtual void initData()=0
Init grid data at problem start-up. This is a pure virtual function and hence MUST be implemented by ...
AmrLevel & operator=(const AmrLevel &)=delete
virtual void checkPointPost(const std::string &dir, std::ostream &os)
Do post-checkpoint work to avoid synchronizations while writing the amr hierarchy.
Definition AMReX_AmrLevel.cpp:565
std::unique_ptr< FabFactory< FArrayBox > > m_factory
Definition AMReX_AmrLevel.H:497
void finishConstructor()
Common code used by all constructors.
Definition AMReX_AmrLevel.cpp:473
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)
Definition AMReX_AmrLevel.H:616
virtual void CreateLevelDirectory(const std::string &dir)
Create the Level_ directory for checkpoint and plot files.
Definition AMReX_AmrLevel.cpp:2245
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...
static void SetEBMaxGrowCells(int nbasic, int nvolume, int nfull) noexcept
Definition AMReX_AmrLevel.H:445
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.
Definition AMReX_AmrLevel.cpp:1519
int post_step_regrid
Definition AMReX_AmrLevel.H:493
static EBSupport m_eb_support_level
Definition AMReX_AmrLevel.H:454
BoxArray m_AreaNotToTag
Definition AMReX_AmrLevel.H:490
virtual int okToRegrid()
Should I regrid with this level as base level? This test is only evaluated if regrid_int > 0 and leve...
Definition AMReX_AmrLevel.cpp:1891
static void FillPatchAdd(AmrLevel &amrlevel, MultiFab &leveldata, int boxGrow, Real time, int index, int scomp, int ncomp, int dcomp=0)
Definition AMReX_AmrLevel.cpp:2211
virtual void checkPointPre(const std::string &dir, std::ostream &os)
Do pre-checkpoint work to avoid synchronizations while writing the amr hierarchy.
Definition AMReX_AmrLevel.cpp:557
int numStates() const noexcept
Number of states at this level.
Definition AMReX_AmrLevel.H:248
virtual void writePlotFile(const std::string &dir, std::ostream &os, VisMF::How how=VisMF::NFiles)
Write plot file stuff to specified directory.
Definition AMReX_AmrLevel.cpp:134
virtual std::string thePlotFileType() const
A string written as the first item in writePlotFile() at level zero. It is so we can distinguish betw...
Definition AMReX_AmrLevel.H:79
DistributionMapping dmap
Definition AMReX_AmrLevel.H:482
AmrLevel(AmrLevel &&)=delete
static int m_eb_basic_grow_cells
Definition AMReX_AmrLevel.H:450
virtual void particle_redistribute(int=0, bool=false)
This function can be called from the parent.
Definition AMReX_AmrLevel.H:384
Vector< StateData > state
Definition AMReX_AmrLevel.H:488
const MultiFab & get_new_data(int state_indx) const noexcept
State data at new time.
Definition AMReX_AmrLevel.H:321
int nStep() const noexcept
Timestep n at this level.
Definition AMReX_AmrLevel.H:252
virtual void post_init(Real stop_time)=0
Operations to be done after initialization. This is a pure virtual function and hence MUST be impleme...
static void FlushFPICache()
void setAreaNotToTag(BoxArray &ba) noexcept
Set the area not to tag.
Definition AMReX_AmrLevel.cpp:2086
static bool isStateVariable(const std::string &name, int &state_indx, int &ncomp)
Is name a state variable?
Definition AMReX_AmrLevel.cpp:487
static DescriptorList desc_lst
Definition AMReX_AmrLevel.H:487
const BoxArray & getEdgeBoxArray(int dir) const noexcept
Definition AMReX_AmrLevel.cpp:626
AmrLevel(const AmrLevel &)=delete
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.
Definition AMReX_AmrLevel.cpp:48
virtual void setSmallPlotVariables()
Modify list of variables to be plotted.
Definition AMReX_AmrLevel.cpp:1957
AmrLevel() noexcept
The constructors – for derived classes.
Definition AMReX_AmrLevel.H:464
static const DescriptorList & get_desc_lst() noexcept
Returns list of Descriptors.
Definition AMReX_AmrLevel.H:323
int postStepRegrid() const noexcept
Returns whether or not we want a post-timestep regrid.
Definition AMReX_AmrLevel.H:327
int numGrids() const noexcept
Number of grids at this level.
Definition AMReX_AmrLevel.H:246
Amr * parent
Definition AMReX_AmrLevel.H:483
MultiFab & get_new_data(int state_indx) noexcept
State data at new time.
Definition AMReX_AmrLevel.H:319
MultiFab & get_old_data(int state_indx) noexcept
State data at old time.
Definition AMReX_AmrLevel.H:315
void resetFillPatcher()
Definition AMReX_AmrLevel.cpp:2128
virtual ~AmrLevel()
The destructor.
Definition AMReX_AmrLevel.cpp:572
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.
Definition AMReX_AmrLevel.cpp:2136
virtual void post_restart()
Operations to be done after restart.
Definition AMReX_AmrLevel.H:175
const BoxArray & getAreaNotToTag() noexcept
Get the area not to tag.
Definition AMReX_AmrLevel.cpp:2076
const Vector< DistributionMapping > & DistributionMap() const noexcept
Definition AMReX_AmrMesh.H:109
int finestLevel() const noexcept
Return the finest level.
Definition AMReX_AmrMesh.H:97
const Vector< Geometry > & Geom() const noexcept
Definition AMReX_AmrMesh.H:108
const Vector< BoxArray > & boxArray() const noexcept
Definition AMReX_AmrMesh.H:110
Manage hierarchy of levels for time-dependent AMR computations.
Definition AMReX_Amr.H:36
AmrLevel & getLevel(int lev) noexcept
AmrLevel lev.
Definition AMReX_Amr.H:190
int levelSteps(int lev) const noexcept
Number of time steps at specified level.
Definition AMReX_Amr.H:104
A collection of Boxes stored in an Array.
Definition AMReX_BoxArray.H:567
Long size() const noexcept
Return the number of boxes in the BoxArray.
Definition AMReX_BoxArray.H:614
A list of DeriveRecs.
Definition AMReX_Derive.H:364
Definition AMReX_StateDescriptor.H:437
Calculates the distribution of FABs to MPI processes.
Definition AMReX_DistributionMapping.H:43
Definition AMReX_EBFabFactory.H:25
A Fortran Array of REALs.
Definition AMReX_FArrayBox.H:231
int nGrow(int direction=0) const noexcept
Return the grow factor that defines the region of definition.
Definition AMReX_FabArrayBase.H:78
int nComp() const noexcept
Return number of variables (aka components) associated with each point.
Definition AMReX_FabArrayBase.H:83
Definition AMReX_FabFactory.H:50
Definition AMReX_AmrLevel.H:567
void Initialize(int boxGrow, Real time, int idx, int scomp, int ncomp, InterpBase *mapper)
Definition AMReX_AmrLevel.cpp:739
void fill(FArrayBox &fab, int dcomp, int idx)
Definition AMReX_AmrLevel.cpp:1266
Definition AMReX_AmrLevel.H:523
FArrayBox & operator()() noexcept
Definition AMReX_AmrLevel.H:545
MultiFab & get_mf() noexcept
Definition AMReX_AmrLevel.H:549
Box UngrownBox() const noexcept
Definition AMReX_AmrLevel.H:547
Rectangular problem domain geometry.
Definition AMReX_Geometry.H:74
const Box & Domain() const noexcept
Returns our rectangular domain.
Definition AMReX_Geometry.H:211
Definition AMReX_InterpBase.H:26
Virtual base class for interpolaters.
Definition AMReX_Interpolater.H:22
Iterator for looping ever tiles and boxes of amrex::FabArray based containers.
Definition AMReX_MFIter.H:85
Box validbox() const noexcept
Return the valid Box in which the current tile resides.
Definition AMReX_MFIter.H:160
int index() const noexcept
The index into the underlying BoxArray of the current FAB.
Definition AMReX_MFIter.H:172
void Initialize()
Definition AMReX_MFIter.cpp:278
Definition AMReX_MFCopyDescriptor.H:46
A collection (stored as an array) of FArrayBox objects.
Definition AMReX_MultiFab.H:40
Current and previous level-time data.
Definition AMReX_StateData.H:33
Attributes of StateData.
Definition AMReX_StateDescriptor.H:33
An array of TagBoxes.
Definition AMReX_TagBox.H:150
This class is a thin wrapper around std::vector. Unlike vector, Vector::operator[] provides bound che...
Definition AMReX_Vector.H:28
How
How we write out FabArray<FArrayBox>s. These are deprecated, we always use NFiles....
Definition AMReX_VisMF.H:42
@ NFiles
Definition AMReX_VisMF.H:42
amrex_real Real
Floating Point Type for Fields.
Definition AMReX_REAL.H:79
amrex_long Long
Definition AMReX_INT.H:30
std::array< T, N > Array
Definition AMReX_Array.H:26
void RK2(MF &Uold, MF &Unew, Real time, Real dt, F const &frhs, FB const &fillbndry, P const &post_stage=PostStageNoOp())
Time stepping with RK2.
Definition AMReX_RungeKutta.H:160
void RK4(MF &Uold, MF &Unew, Real time, Real dt, F const &frhs, FB const &fillbndry, R const &store_crse_data, P const &post_stage=PostStageNoOp())
Time stepping with RK4.
Definition AMReX_RungeKutta.H:248
void RK3(MF &Uold, MF &Unew, Real time, Real dt, F const &frhs, FB const &fillbndry, R const &store_crse_data, P const &post_stage=PostStageNoOp())
Time stepping with RK3.
Definition AMReX_RungeKutta.H:198
Definition AMReX_Amr.cpp:49
EBSupport
Definition AMReX_EBSupport.H:7
IntVectND< 3 > IntVect
IntVect is an alias for amrex::IntVectND instantiated with AMREX_SPACEDIM.
Definition AMReX_BaseFwd.H:33
void Abort(const std::string &msg)
Print out message to cerr and exit via abort().
Definition AMReX.cpp:230
Definition AMReX_RungeKutta.H:51