Block-Structured AMR Software Framework
Loading...
Searching...
No Matches
amrex::AmrCore Class Referenceabstract

Provide basic functionalities to set up an AMR hierarchy. More...

#include <AMReX_AmrCore.H>

Inheritance diagram for amrex::AmrCore:
amrex::AmrMesh amrex::AmrInfo amrex::Amr

Public Member Functions

 AmrCore ()
 Construct an empty AmrCore.
 
 AmrCore (const RealBox *rb, int max_level_in, const Vector< int > &n_cell_in, int coord=-1, Vector< IntVect > ref_ratios=Vector< IntVect >(), const int *is_per=nullptr)
 Construct using legacy inputs that mirror AmrMesh.
 
 AmrCore (const RealBox &rb, int max_level_in, const Vector< int > &n_cell_in, int coord, Vector< IntVect > const &ref_ratios, Array< int, 3 > const &is_per)
 Construct with an explicit domain and periodicity array.
 
 AmrCore (Geometry const &level_0_geom, AmrInfo const &amr_info)
 Construct from a ready-made Geometry and AmrInfo bundle.
 
 AmrCore (AmrCore &&rhs) noexcept
 
AmrCoreoperator= (AmrCore &&rhs) noexcept
 
 AmrCore (const AmrCore &rhs)=delete
 
AmrCoreoperator= (const AmrCore &rhs)=delete
 
 ~AmrCore () override
 
AmrParGDBGetParGDB () const noexcept
 Return AmrParGDB pointer for particle containers.
 
void InitFromScratch (Real time)
 Initialize BoxArray, DistributionMapping, and level data from scratch.
 
virtual void regrid (int lbase, Real time, bool initial=false)
 Rebuild all levels finer than lbase at simulation time time.
 
void printGridSummary (std::ostream &os, int min_lev, int max_lev) const noexcept
 Print a human-readable summary of grid sizes between min_lev and max_lev.
 
- Public Member Functions inherited from amrex::AmrMesh
 AmrMesh ()
 Construct an empty mesh.
 
 AmrMesh (const RealBox *rb, int max_level_in, const Vector< int > &n_cell_in, int coord=-1, Vector< IntVect > refrat=Vector< IntVect >(), const int *is_per=nullptr)
 Construct using legacy inputs (same signature as AmrCore).
 
 AmrMesh (const RealBox &rb, int max_level_in, const Vector< int > &n_cell_in, int coord, Vector< IntVect > const &a_refrat, Array< int, 3 > const &is_per)
 Construct with explicit domain and periodicity array.
 
 AmrMesh (Geometry const &level_0_geom, AmrInfo const &amr_info)
 Construct from a pre-built Geometry and AmrInfo bundle.
 
 AmrMesh (const AmrMesh &rhs)=delete
 
AmrMeshoperator= (const AmrMesh &rhs)=delete
 
 AmrMesh (AmrMesh &&rhs)=default
 
AmrMeshoperator= (AmrMesh &&rhs)=default
 
virtual ~AmrMesh ()=default
 
int Verbose () const noexcept
 
int maxLevel () const noexcept
 Return the max level.
 
int finestLevel () const noexcept
 Return the finest level.
 
IntVect refRatio (int lev) const noexcept
 Return the refinement ratio for level lev.
 
int MaxRefRatio (int lev) const noexcept
 Return the maximum refinement ratio in any direction.
 
const Vector< IntVect > & refRatio () const noexcept
 Return refinement ratios between all levels.
 
const Vector< Geometry > & Geom () const noexcept
 
const Vector< DistributionMapping > & DistributionMap () const noexcept
 
const Vector< BoxArray > & boxArray () const noexcept
 
const GeometryGeom (int lev) const noexcept
 
const DistributionMappingDistributionMap (int lev) const noexcept
 
const BoxArrayboxArray (int lev) const noexcept
 
Vector< GeometryGeom (int a_coarsest_lev, int a_finest_lev) const noexcept
 
Vector< BoxArrayboxArray (int a_coarsest_lev, int a_finest_lev) const noexcept
 
Vector< DistributionMappingDistributionMap (int a_coarsest_lev, int a_finest_lev) const noexcept
 
Vector< Geometry > & Geom () noexcept
 
GeometryGeom (int lev) noexcept
 
void SetMaxGridSize (int new_mgs) noexcept
 Override the max grid size constraint for all levels (scalar version).
 
void SetMaxGridSize (const IntVect &new_mgs) noexcept
 Override the max grid size constraint using explicit IntVect new_mgs.
 
void SetMaxGridSize (const Vector< int > &new_mgs) noexcept
 Override per-level max grid sizes using scalar-per-level vector new_mgs.
 
void SetMaxGridSize (const Vector< IntVect > &new_mgs) noexcept
 Override per-level max grid sizes using explicit IntVect-per-level vector new_mgs.
 
void SetBlockingFactor (int new_bf) noexcept
 Override the blocking factor constraint for all levels (scalar version).
 
void SetBlockingFactor (const IntVect &new_bf) noexcept
 Override blocking factor using explicit IntVect new_bf.
 
void SetBlockingFactor (const Vector< int > &new_bf) noexcept
 Override per-level blocking factors using scalar-per-level vector new_bf.
 
void SetBlockingFactor (const Vector< IntVect > &new_bf) noexcept
 Override per-level blocking factors using explicit IntVect vector new_bf.
 
void SetGridEff (Real eff) noexcept
 Set the minimum acceptable grid efficiency to eff.
 
void SetNProper (int n) noexcept
 Set the number of cell blocks required for proper nesting to n.
 
void SetFinestLevel (int new_finest_level) noexcept
 Update the recorded finest level index to new_finest_level (without reallocating).
 
void SetDistributionMap (int lev, const DistributionMapping &dmap_in) noexcept
 Install a DistributionMapping for level lev.
 
void SetBoxArray (int lev, const BoxArray &ba_in) noexcept
 Install a BoxArray for level lev.
 
void SetGeometry (int lev, const Geometry &geom_in) noexcept
 Install a Geometry object for level lev.
 
int GetLevel (Box const &domain) const noexcept
 Given domain box, return AMR level. Return -1 if there is no match.
 
void ClearDistributionMap (int lev) noexcept
 Clear the stored DistributionMapping for level lev.
 
void ClearBoxArray (int lev) noexcept
 Clear the stored BoxArray for level lev.
 
int nErrorBuf (int lev, int direction=0) const noexcept
 Return the number of buffer cells (as a single integer) in error estimator.
 
const IntVectnErrorBufVect (int lev) const noexcept
 Return the number of buffer cells (as an IntVect) in error estimator.
 
Real gridEff () const noexcept
 Return the minimum allowable grid efficiency.
 
int nProper () const noexcept
 Return the number of cell blocks to define proper nesting.
 
const IntVectblockingFactor (int lev) const noexcept
 Return the blocking factor at level lev.
 
const IntVectmaxGridSize (int lev) const noexcept
 Return the largest allowable grid.
 
bool LevelDefined (int lev) const noexcept
 Return true if valid grids/dmaps exist for level lev.
 
bool useFixedCoarseGrids () const noexcept
 Should we keep the coarser grids fixed (and not regrid those levels) at all?
 
int useFixedUpToLevel () const noexcept
 Up to what level should we keep the coarser grids fixed (and not regrid those levels)?
 
void ChopGrids (int lev, BoxArray &ba, int target_size) const
 Try to chop grids on level lev until BoxArray ba has at least target_size boxes.
 
BoxArray MakeBaseGrids () const
 Make a level-0 BoxArray covering the whole domain (without installing it).
 
void MakeNewGrids (int lbase, Real time, int &new_finest, Vector< BoxArray > &new_grids)
 Make new grids based on error estimates. This function expects that valid BoxArrays exist in this->grids from level lbase to level this->finest_level (the current finest level). new_grids. On return, the new finest level is stored in new_finest, and the new grids are stored in new_grids from Array element lbase+1 to new_finest_level (unless fixed grids are used). Note that this function adds at most one more level to the existing levels, and it may remove all levels above the base level. This function does not change the value of this->finest_level, nor does it modifies any BoxArrays stored in this->grids. It also does not modify new_grids's elements outside the range [lbase+1,new_finest_level].
 
void MakeNewGrids (Real time=0.0)
 Convenience overload that rebuilds every level (including level 0) at time time.
 
virtual void ManualTagsPlacement (int lev, TagBoxArray &tags, const Vector< IntVect > &bf_lev)
 Manual tagging hook. Tags are defined on level lev grids coarsened by bf_lev[lev].
 
virtual void PostProcessBaseGrids (BoxArray &box_array) const
 Allow derived classes to edit the base-level grids before installing them.
 
virtual BoxArray GetAreaNotToTag (int lev)
 Return a BoxArray that should never be tagged on level lev (e.g., buffer zones).
 
Long CountCells (int lev) const noexcept
 Count the total number of cells at level lev.
 
virtual DistributionMapping MakeDistributionMap (int lev, BoxArray const &ba)
 Build a distribution map for level lev grid layout ba (override to customize load balancing).
 

Protected Member Functions

void ErrorEst (int lev, TagBoxArray &tags, Real time, int ngrow) override=0
 Tag cells for refinement on level lev.
 
void MakeNewLevelFromScratch (int lev, Real time, const BoxArray &ba, const DistributionMapping &dm) override=0
 Create and fill a new level from scratch.
 
virtual void MakeNewLevelFromCoarse (int lev, Real time, const BoxArray &ba, const DistributionMapping &dm)=0
 Make a new level using provided metadata and populate it from the next coarser level.
 
virtual void RemakeLevel (int lev, Real time, const BoxArray &ba, const DistributionMapping &dm)=0
 Remake an existing level using provided metadata and refill from old data.
 
virtual void ClearLevel (int lev)=0
 Delete level lev data structures owned by the derived class.
 
- Protected Member Functions inherited from amrex::AmrMesh
void checkInput ()
 Validate AmrInfo inputs (throws if inconsistent).
 
void SetIterateToFalse () noexcept
 Disable the iterate-on-new-grids loop for the next MakeNewGrids call.
 
void SetUseNewChop () noexcept
 Force MakeNewGrids to use the newer chopping algorithm.
 

Protected Attributes

std::unique_ptr< AmrParGDBm_gdb
 Geometry, DistributionMapping and BoxArray for particle containers.
 
- Protected Attributes inherited from amrex::AmrMesh
int finest_level
 Current finest level.
 
Vector< Geometrygeom
 
Vector< DistributionMappingdmap
 
Vector< BoxArraygrids
 
unsigned int num_setdm = 0
 
unsigned int num_setba = 0
 
- Protected Attributes inherited from amrex::AmrInfo
int verbose = 0
 
int max_level = 0
 Maximum allowed level.
 
Vector< IntVectref_ratio {{IntVect(2)}}
 Refinement ratios.
 
Vector< IntVectblocking_factor {{IntVect(8)}}
 Blocking factor in grid generation (by level).
 
Vector< IntVectmax_grid_size {{IntVect( 64 )}}
 Maximum allowable grid size (by level).
 
Vector< IntVectn_error_buf {{IntVect(1)}}
 Buffer cells around each tagged cell.
 
Real grid_eff = static_cast<Real>(0.7)
 Grid efficiency.
 
int n_proper = 1
 Cells required for proper nesting.
 
int use_fixed_upto_level = 0
 
bool use_fixed_coarse_grids = false
 
bool refine_grid_layout = true
 
IntVect refine_grid_layout_dims = IntVect(1)
 
bool check_input = true
 
bool use_new_chop = false
 
bool iterate_on_new_grids = true
 
int max_grid_iterations = 4
 

Detailed Description

Provide basic functionalities to set up an AMR hierarchy.

Because it does not own any floating point data, AmrCore used virtual functions to allocate, initialize and delete data. It also requires the derived class to tag cells for refinement.

Constructor & Destructor Documentation

◆ AmrCore() [1/6]

amrex::AmrCore::AmrCore ( )

Construct an empty AmrCore.

◆ AmrCore() [2/6]

amrex::AmrCore::AmrCore ( const RealBox rb,
int  max_level_in,
const Vector< int > &  n_cell_in,
int  coord = -1,
Vector< IntVect ref_ratios = Vector<IntVect>(),
const int is_per = nullptr 
)

Construct using legacy inputs that mirror AmrMesh.

Parameters
rbOptional physical domain for level 0 (nullptr uses defaults).
max_level_inMaximum AMR level allowed.
n_cell_inNumber of cells at level 0 in each direction.
coordCoordinate system index (defaults to Cartesian if not specified in ParmParse parameter geometry.coord_sys).
ref_ratiosPer-level refinement ratios (level 0 onward).
is_perOptional periodicity flags (defaults to non-periodic if not specified in ParmParse parameter geometry.is_periodic).

◆ AmrCore() [3/6]

amrex::AmrCore::AmrCore ( const RealBox rb,
int  max_level_in,
const Vector< int > &  n_cell_in,
int  coord,
Vector< IntVect > const &  ref_ratios,
Array< int, 3 > const &  is_per 
)

Construct with an explicit domain and periodicity array.

Parameters
rbPhysical domain for level 0.
max_level_inMaximum AMR level allowed.
n_cell_inNumber of cells at level 0 in each direction.
coordCoordinate system index.
ref_ratiosPer-level refinement ratios (level 0 onward).
is_perArray of periodicity flags (0 = nonperiodic, 1 = periodic).

◆ AmrCore() [4/6]

amrex::AmrCore::AmrCore ( Geometry const &  level_0_geom,
AmrInfo const &  amr_info 
)

Construct from a ready-made Geometry and AmrInfo bundle.

Parameters
level_0_geomGeometry describing level 0.
amr_infoConfiguration struct controlling level counts and limits.

◆ AmrCore() [5/6]

amrex::AmrCore::AmrCore ( AmrCore &&  rhs)
noexcept

◆ AmrCore() [6/6]

amrex::AmrCore::AmrCore ( const AmrCore rhs)
delete

◆ ~AmrCore()

amrex::AmrCore::~AmrCore ( )
override

Member Function Documentation

◆ ClearLevel()

virtual void amrex::AmrCore::ClearLevel ( int  lev)
protectedpure virtual

Delete level lev data structures owned by the derived class.

Parameters
levLevel index whose data should be released.

Implemented in amrex::Amr.

◆ ErrorEst()

void amrex::AmrCore::ErrorEst ( int  lev,
TagBoxArray tags,
Real  time,
int  ngrow 
)
overrideprotectedpure virtual

Tag cells for refinement on level lev.

Parameters
levLevel whose valid region is being tagged.
tagsTag array built on level lev grids.
timeSimulation time used by tagging logic.
ngrowNumber of ghost layers in tags that must be filled.

Reimplemented from amrex::AmrMesh.

Implemented in amrex::Amr.

◆ GetParGDB()

AmrParGDB * amrex::AmrCore::GetParGDB ( ) const
inlinenoexcept

Return AmrParGDB pointer for particle containers.

◆ InitFromScratch()

void amrex::AmrCore::InitFromScratch ( Real  time)

Initialize BoxArray, DistributionMapping, and level data from scratch.

Calling this function requires the derived class to implement MakeNewLevelFromScratch() so it can allocate and initialize data on every level. After initialization completes, most applications average the fine data back down to the coarse levels.

Parameters
timeSimulation time associated with the freshly initialized hierarchy.

◆ MakeNewLevelFromCoarse()

virtual void amrex::AmrCore::MakeNewLevelFromCoarse ( int  lev,
Real  time,
const BoxArray ba,
const DistributionMapping dm 
)
protectedpure virtual

Make a new level using provided metadata and populate it from the next coarser level.

Parameters
levLevel index being created.
timeSimulation time when the level is initialized.
baBoxArray describing the new grids.
dmDistribution mapping describing ownership of those grids.

Implemented in amrex::Amr.

◆ MakeNewLevelFromScratch()

void amrex::AmrCore::MakeNewLevelFromScratch ( int  lev,
Real  time,
const BoxArray ba,
const DistributionMapping dm 
)
overrideprotectedpure virtual

Create and fill a new level from scratch.

Only invoked during initialization; derived classes must allocate and populate all data for level lev using the supplied metadata.

Reimplemented from amrex::AmrMesh.

Implemented in amrex::Amr.

◆ operator=() [1/2]

AmrCore & amrex::AmrCore::operator= ( AmrCore &&  rhs)
noexcept

◆ operator=() [2/2]

AmrCore & amrex::AmrCore::operator= ( const AmrCore rhs)
delete

◆ printGridSummary()

void amrex::AmrCore::printGridSummary ( std::ostream &  os,
int  min_lev,
int  max_lev 
) const
noexcept

Print a human-readable summary of grid sizes between min_lev and max_lev.

Parameters
osDestination stream.
min_levFirst level to report.
max_levLast level to report (inclusive).

◆ regrid()

void amrex::AmrCore::regrid ( int  lbase,
Real  time,
bool  initial = false 
)
virtual

Rebuild all levels finer than lbase at simulation time time.

Parameters
lbaseCoarse level after which to regenerate hierarchy.
timePhysical time used when calling user callbacks.
initialWhether this regrid corresponds to initial creation.

Reimplemented in amrex::Amr.

◆ RemakeLevel()

virtual void amrex::AmrCore::RemakeLevel ( int  lev,
Real  time,
const BoxArray ba,
const DistributionMapping dm 
)
protectedpure virtual

Remake an existing level using provided metadata and refill from old data.

Parameters
levLevel index being regenerated.
timeSimulation time to stamp on the data.
baNew BoxArray layout for that level.
dmDistribution mapping describing ownership.

Implemented in amrex::Amr.

Member Data Documentation

◆ m_gdb

std::unique_ptr<AmrParGDB> amrex::AmrCore::m_gdb
protected

Geometry, DistributionMapping and BoxArray for particle containers.


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