Block-Structured AMR Software Framework
Loading...
Searching...
No Matches
amrex::AmrMesh Class Reference

#include <AMReX_AmrMesh.H>

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

Public Member Functions

 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 MakeNewLevelFromScratch (int lev, Real time, const BoxArray &ba, const DistributionMapping &dm)
 Hook invoked by MakeNewGrids() to build a fresh level.
 
virtual void ErrorEst (int lev, TagBoxArray &tags, Real time, int ngrow)
 Hook for tagging cells on level lev.
 
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 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

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
 

Friends

std::ostream & operator<< (std::ostream &os, AmrMesh const &amr_mesh)
 Stream a summary of the mesh hierarchy (level extents, cell counts, etc.).
 

Constructor & Destructor Documentation

◆ AmrMesh() [1/6]

amrex::AmrMesh::AmrMesh ( )

Construct an empty mesh.

◆ AmrMesh() [2/6]

amrex::AmrMesh::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).

Parameters
rbOptional domain definition; nullptr uses defaults.
max_level_inMaximum level count.
n_cell_inLevel-0 cell counts.
coordCoordinate system index (defaults to Cartesian if not specified in ParmParse parameter geometry.coord_sys).
refratOptional refinement ratios per level.
is_perOptional periodicity flags (defaults to non-periodic if not specified in ParmParse parameter geometry.is_periodic).

◆ AmrMesh() [3/6]

amrex::AmrMesh::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.

Parameters
rbLevel-0 physical domain.
max_level_inMaximum level count.
n_cell_inLevel-0 cell counts.
coordCoordinate system index.
a_refratPer-level refinement ratios.
is_perArray of periodicity flags (0 = nonperiodic, 1 = periodic).

◆ AmrMesh() [4/6]

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

Construct from a pre-built Geometry and AmrInfo bundle.

Parameters
level_0_geomGeometry for level 0.
amr_infoAMR configuration.

◆ AmrMesh() [5/6]

amrex::AmrMesh::AmrMesh ( const AmrMesh rhs)
delete

◆ AmrMesh() [6/6]

amrex::AmrMesh::AmrMesh ( AmrMesh &&  rhs)
default

◆ ~AmrMesh()

virtual amrex::AmrMesh::~AmrMesh ( )
virtualdefault

Member Function Documentation

◆ blockingFactor()

const IntVect & amrex::AmrMesh::blockingFactor ( int  lev) const
inlinenoexcept

Return the blocking factor at level lev.

◆ boxArray() [1/3]

const Vector< BoxArray > & amrex::AmrMesh::boxArray ( ) const
inlinenoexcept

◆ boxArray() [2/3]

Vector< BoxArray > amrex::AmrMesh::boxArray ( int  a_coarsest_lev,
int  a_finest_lev 
) const
inlinenoexcept

◆ boxArray() [3/3]

const BoxArray & amrex::AmrMesh::boxArray ( int  lev) const
inlinenoexcept

◆ checkInput()

void amrex::AmrMesh::checkInput ( )
protected

Validate AmrInfo inputs (throws if inconsistent).

◆ ChopGrids()

void amrex::AmrMesh::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.

Parameters
levLevel whose blocking and efficiency rules apply.
baBoxArray to refine in place.
target_sizeDesired minimum number of boxes.

◆ ClearBoxArray()

void amrex::AmrMesh::ClearBoxArray ( int  lev)
noexcept

Clear the stored BoxArray for level lev.

◆ ClearDistributionMap()

void amrex::AmrMesh::ClearDistributionMap ( int  lev)
noexcept

Clear the stored DistributionMapping for level lev.

◆ CountCells()

Long amrex::AmrMesh::CountCells ( int  lev) const
noexcept

Count the total number of cells at level lev.

◆ DistributionMap() [1/3]

const Vector< DistributionMapping > & amrex::AmrMesh::DistributionMap ( ) const
inlinenoexcept

◆ DistributionMap() [2/3]

Vector< DistributionMapping > amrex::AmrMesh::DistributionMap ( int  a_coarsest_lev,
int  a_finest_lev 
) const
inlinenoexcept

◆ DistributionMap() [3/3]

const DistributionMapping & amrex::AmrMesh::DistributionMap ( int  lev) const
inlinenoexcept

◆ ErrorEst()

virtual void amrex::AmrMesh::ErrorEst ( int  lev,
TagBoxArray tags,
Real  time,
int  ngrow 
)
inlinevirtual

Hook for tagging cells on level lev.

Parameters
levLevel index.
tagsTag boxes (built on level lev).
timeSimulation time.
ngrowNumber of ghost layers filled in tags.

Reimplemented in amrex::Amr, and amrex::AmrCore.

◆ finestLevel()

int amrex::AmrMesh::finestLevel ( ) const
inlinenoexcept

Return the finest level.

◆ Geom() [1/5]

const Vector< Geometry > & amrex::AmrMesh::Geom ( ) const
inlinenoexcept

◆ Geom() [2/5]

Vector< Geometry > & amrex::AmrMesh::Geom ( )
inlinenoexcept

◆ Geom() [3/5]

Vector< Geometry > amrex::AmrMesh::Geom ( int  a_coarsest_lev,
int  a_finest_lev 
) const
inlinenoexcept

◆ Geom() [4/5]

const Geometry & amrex::AmrMesh::Geom ( int  lev) const
inlinenoexcept

◆ Geom() [5/5]

Geometry & amrex::AmrMesh::Geom ( int  lev)
inlinenoexcept

◆ GetAreaNotToTag()

virtual BoxArray amrex::AmrMesh::GetAreaNotToTag ( int  lev)
inlinevirtual

Return a BoxArray that should never be tagged on level lev (e.g., buffer zones).

Reimplemented in amrex::Amr.

◆ GetLevel()

int amrex::AmrMesh::GetLevel ( Box const &  domain) const
noexcept

Given domain box, return AMR level. Return -1 if there is no match.

◆ gridEff()

Real amrex::AmrMesh::gridEff ( ) const
inlinenoexcept

Return the minimum allowable grid efficiency.

◆ LevelDefined()

bool amrex::AmrMesh::LevelDefined ( int  lev) const
noexcept

Return true if valid grids/dmaps exist for level lev.

◆ MakeBaseGrids()

BoxArray amrex::AmrMesh::MakeBaseGrids ( ) const

Make a level-0 BoxArray covering the whole domain (without installing it).

◆ MakeDistributionMap()

DistributionMapping amrex::AmrMesh::MakeDistributionMap ( int  lev,
BoxArray const &  ba 
)
virtual

Build a distribution map for level lev grid layout ba (override to customize load balancing).

◆ MakeNewGrids() [1/2]

void amrex::AmrMesh::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].

Build new grids above level lbase using current error tags.

Parameters
lbaseCoarsest level to keep fixed.
timeSimulation time used when tagging.
new_finestOutput: resulting finest level index.
new_gridsOutput: new BoxArrays for levels > lbase (vector sized finest+1).

◆ MakeNewGrids() [2/2]

void amrex::AmrMesh::MakeNewGrids ( Real  time = 0.0)

Convenience overload that rebuilds every level (including level 0) at time time.

◆ MakeNewLevelFromScratch()

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

Hook invoked by MakeNewGrids() to build a fresh level.

Parameters
levLevel index being created.
timeSimulation time used for initialization.
baBoxArray describing the level's grids.
dmDistribution mapping describing ownership.

Reimplemented in amrex::AmrCore, and amrex::Amr.

◆ ManualTagsPlacement()

virtual void amrex::AmrMesh::ManualTagsPlacement ( int  lev,
TagBoxArray tags,
const Vector< IntVect > &  bf_lev 
)
inlinevirtual

Manual tagging hook. Tags are defined on level lev grids coarsened by bf_lev[lev].

Parameters
levLevel index.
tagsTag boxes to update.
bf_levBuffer sizes per level.

Reimplemented in amrex::Amr.

◆ maxGridSize()

const IntVect & amrex::AmrMesh::maxGridSize ( int  lev) const
inlinenoexcept

Return the largest allowable grid.

◆ maxLevel()

int amrex::AmrMesh::maxLevel ( ) const
inlinenoexcept

Return the max level.

◆ MaxRefRatio()

int amrex::AmrMesh::MaxRefRatio ( int  lev) const
noexcept

Return the maximum refinement ratio in any direction.

◆ nErrorBuf()

int amrex::AmrMesh::nErrorBuf ( int  lev,
int  direction = 0 
) const
inlinenoexcept

Return the number of buffer cells (as a single integer) in error estimator.

◆ nErrorBufVect()

const IntVect & amrex::AmrMesh::nErrorBufVect ( int  lev) const
inlinenoexcept

Return the number of buffer cells (as an IntVect) in error estimator.

◆ nProper()

int amrex::AmrMesh::nProper ( ) const
inlinenoexcept

Return the number of cell blocks to define proper nesting.

◆ operator=() [1/2]

AmrMesh & amrex::AmrMesh::operator= ( AmrMesh &&  rhs)
default

◆ operator=() [2/2]

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

◆ PostProcessBaseGrids()

virtual void amrex::AmrMesh::PostProcessBaseGrids ( BoxArray box_array) const
inlinevirtual

Allow derived classes to edit the base-level grids before installing them.

For example, use this function if you want to remove covered grids on the coarsest refinement level.

This is called by MakeNewGrids() after computing the coarsest-level BoxArray and before invoking MakeNewLevelFromScratch().

Parameters
box_arrayBase-level boxes (modifiable in place).

◆ refRatio() [1/2]

const Vector< IntVect > & amrex::AmrMesh::refRatio ( ) const
inlinenoexcept

Return refinement ratios between all levels.

◆ refRatio() [2/2]

IntVect amrex::AmrMesh::refRatio ( int  lev) const
inlinenoexcept

Return the refinement ratio for level lev.

◆ SetBlockingFactor() [1/4]

void amrex::AmrMesh::SetBlockingFactor ( const IntVect new_bf)
inlinenoexcept

Override blocking factor using explicit IntVect new_bf.

◆ SetBlockingFactor() [2/4]

void amrex::AmrMesh::SetBlockingFactor ( const Vector< int > &  new_bf)
inlinenoexcept

Override per-level blocking factors using scalar-per-level vector new_bf.

◆ SetBlockingFactor() [3/4]

void amrex::AmrMesh::SetBlockingFactor ( const Vector< IntVect > &  new_bf)
inlinenoexcept

Override per-level blocking factors using explicit IntVect vector new_bf.

◆ SetBlockingFactor() [4/4]

void amrex::AmrMesh::SetBlockingFactor ( int  new_bf)
inlinenoexcept

Override the blocking factor constraint for all levels (scalar version).

Parameters
new_bfBlocking factor to enforce in every direction.

◆ SetBoxArray()

void amrex::AmrMesh::SetBoxArray ( int  lev,
const BoxArray ba_in 
)
noexcept

Install a BoxArray for level lev.

Parameters
levLevel index.
ba_inGrid layout to store.

◆ SetDistributionMap()

void amrex::AmrMesh::SetDistributionMap ( int  lev,
const DistributionMapping dmap_in 
)
noexcept

Install a DistributionMapping for level lev.

Parameters
levLevel index being updated.
dmap_inDistribution mapping to store.

◆ SetFinestLevel()

void amrex::AmrMesh::SetFinestLevel ( int  new_finest_level)
inlinenoexcept

Update the recorded finest level index to new_finest_level (without reallocating).

◆ SetGeometry()

void amrex::AmrMesh::SetGeometry ( int  lev,
const Geometry geom_in 
)
noexcept

Install a Geometry object for level lev.

Parameters
levLevel index.
geom_inGeometry to store (copied).

◆ SetGridEff()

void amrex::AmrMesh::SetGridEff ( Real  eff)
inlinenoexcept

Set the minimum acceptable grid efficiency to eff.

◆ SetIterateToFalse()

void amrex::AmrMesh::SetIterateToFalse ( )
inlineprotectednoexcept

Disable the iterate-on-new-grids loop for the next MakeNewGrids call.

◆ SetMaxGridSize() [1/4]

void amrex::AmrMesh::SetMaxGridSize ( const IntVect new_mgs)
inlinenoexcept

Override the max grid size constraint using explicit IntVect new_mgs.

◆ SetMaxGridSize() [2/4]

void amrex::AmrMesh::SetMaxGridSize ( const Vector< int > &  new_mgs)
inlinenoexcept

Override per-level max grid sizes using scalar-per-level vector new_mgs.

◆ SetMaxGridSize() [3/4]

void amrex::AmrMesh::SetMaxGridSize ( const Vector< IntVect > &  new_mgs)
inlinenoexcept

Override per-level max grid sizes using explicit IntVect-per-level vector new_mgs.

◆ SetMaxGridSize() [4/4]

void amrex::AmrMesh::SetMaxGridSize ( int  new_mgs)
inlinenoexcept

Override the max grid size constraint for all levels (scalar version).

Parameters
new_mgsMaximum length in each direction.

◆ SetNProper()

void amrex::AmrMesh::SetNProper ( int  n)
inlinenoexcept

Set the number of cell blocks required for proper nesting to n.

◆ SetUseNewChop()

void amrex::AmrMesh::SetUseNewChop ( )
inlineprotectednoexcept

Force MakeNewGrids to use the newer chopping algorithm.

◆ useFixedCoarseGrids()

bool amrex::AmrMesh::useFixedCoarseGrids ( ) const
inlinenoexcept

Should we keep the coarser grids fixed (and not regrid those levels) at all?

◆ useFixedUpToLevel()

int amrex::AmrMesh::useFixedUpToLevel ( ) const
inlinenoexcept

Up to what level should we keep the coarser grids fixed (and not regrid those levels)?

◆ Verbose()

int amrex::AmrMesh::Verbose ( ) const
inlinenoexcept

Friends And Related Symbol Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream &  os,
AmrMesh const &  amr_mesh 
)
friend

Stream a summary of the mesh hierarchy (level extents, cell counts, etc.).

Parameters
osDestination stream.
amr_meshMesh to describe.
Returns
The destination stream for chaining.

Member Data Documentation

◆ dmap

Vector<DistributionMapping> amrex::AmrMesh::dmap
protected

◆ finest_level

int amrex::AmrMesh::finest_level
protected

Current finest level.

◆ geom

Vector<Geometry> amrex::AmrMesh::geom
protected

◆ grids

Vector<BoxArray> amrex::AmrMesh::grids
protected

◆ num_setba

unsigned int amrex::AmrMesh::num_setba = 0
protected

◆ num_setdm

unsigned int amrex::AmrMesh::num_setdm = 0
protected

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