chombo-discharge
Loading...
Searching...
No Matches
Classes | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
TiledMeshRefine Class Reference

Class for generating AMR boxes using a tiling algorithm. More...

#include <CD_TiledMeshRefine.H>

Classes

struct  SuperTiles
 Compact representation of one level's tiles over the super-tile grid. More...
 

Public Member Functions

 TiledMeshRefine ()=delete
 Default constructor – deleted because we never need it.
 
 TiledMeshRefine (const ProblemDomain &a_coarsestDomain, const Vector< int > &a_refRatios, const IntVect &a_tileSize, const IntVect &a_maxBlockSize) noexcept
 Constructor.
 
virtual ~TiledMeshRefine () noexcept
 Destructor (does nothing)
 
virtual int regrid (Vector< Vector< Box > > &a_newGrids, const Vector< IntVectSet > &a_tagsLevel) const noexcept
 Regrid using the tile clustering algorithm.
 

Protected Member Functions

std::uint64_t encodeSuper (const IntVect &a_super) const noexcept
 Pack a super-tile index into a 64-bit key (21 bits per direction).
 
IntVect decodeSuper (const std::uint64_t a_key) const noexcept
 Unpack a 64-bit super-tile key into a super-tile index.
 
int subIndex (const IntVect &a_sub) const noexcept
 Linear sub-tile index of a sub-position within a super-tile.
 
void addFineTile (SuperTiles &a_tiles, const IntVect &a_fineTile) const noexcept
 Add a fine tile (tile coordinates) to the representation by setting its sub-tile bit.
 
void classify (SuperTiles &a_tiles) const noexcept
 Promote every partial super-tile whose bitmask is full to the full set.
 
void gatherSuperTiles (SuperTiles &a_tiles) const noexcept
 Gather the (per-rank-local) super-tile representation onto all ranks.
 
void nestFrom (SuperTiles &a_tiles, const SuperTiles &a_finer, const int a_refToFine, const Box &a_thisTileBox) const noexcept
 Inject the proper-nesting buffer into a level from the (classified) finer level.
 
virtual void makeLevelTiles (SuperTiles &a_tiles, const SuperTiles &a_fineTiles, const IntVectSet &a_coarTags, const ProblemDomain &a_domain, const int a_refToFine, const int a_refToCoar) const noexcept
 Make the super-tile representation on the current level from tags and finer-level nesting.
 
virtual void makeBoxesFromTiles (Vector< Box > &a_boxes, const SuperTiles &a_tiles, const ProblemDomain &a_domain) const noexcept
 Turn the super-tile representation into boxes.
 
void packTiles (std::vector< IntVect > &a_tiles, const IntVect &a_maxTile, const IntVect &a_probLo, Vector< Box > &a_boxes) const noexcept
 Pack a set of tiles into variable-sized (anisotropic) boxes via recursive Berger-Rigoutsos bisection. This is the single shared box packer, called per partial super-tile.
 

Protected Attributes

Vector< ProblemDomain > m_amrDomains
 Computational domains on each level.
 
Vector< int > m_refRatios
 Refinement ratios.
 
IntVect m_tileSize
 Tile size (= minimum block size, in cells)
 
IntVect m_maxBlockSize
 Maximum box size (in cells). Merge cap; a multiple of m_tileSize.
 
IntVect m_superFactor
 Number of min_block_size tiles per super-tile, per direction (= m_maxBlockSize / m_tileSize).
 
long long m_superVol
 Number of sub-tiles in a super-tile (the product of m_superFactor).
 
int m_bitmaskWords
 Number of 64-bit words in a super-tile sub-occupancy bitmask.
 

Detailed Description

Class for generating AMR boxes using a tiling algorithm.

This class provides a scalable method for grid generation where the grids are generated in a pre-set tile pattern, by flagging min_block_size tiles rather than cells for refinement.

Generation is top-down over a grid of super-tiles, where a super-tile is a max_block_size block of min_block_size tiles. Each level is represented compactly as the set of fully-tagged super-tiles plus, for partially-tagged super-tiles, a bitmask of which sub-tiles are tagged. Fine tiles are therefore materialized only at the boundary of the refined region (inside partial super-tiles), and only that compact representation is gathered across MPI ranks – the intermediate memory scales with the refined surface plus the box count, not the refined volume. Full super-tiles become one (max_block_size) box each; partial super-tiles are packed into variable-sized boxes by packTiles. When max_block_size == min_block_size every super-tile is a single tile and the output is one box per tile (legacy behaviour).

Constructor & Destructor Documentation

◆ TiledMeshRefine()

TiledMeshRefine::TiledMeshRefine ( const ProblemDomain &  a_coarsestDomain,
const Vector< int > &  a_refRatios,
const IntVect &  a_tileSize,
const IntVect &  a_maxBlockSize 
)
noexcept

Constructor.

Parameters
[in]a_coarsestDomainCoarsest grid domain
[in]a_refRatiosRefinement ratios
[in]a_tileSizeTile size (= minimum block size, in cells)
[in]a_maxBlockSizeMaximum box size (in cells). Tiles are merged into boxes no larger than this per direction. Must be a multiple of a_tileSize. When equal to a_tileSize the output is one box per tile (legacy behaviour).

Member Function Documentation

◆ addFineTile()

void TiledMeshRefine::addFineTile ( SuperTiles a_tiles,
const IntVect &  a_fineTile 
) const
protectednoexcept

Add a fine tile (tile coordinates) to the representation by setting its sub-tile bit.

No-op if the tile's super-tile is already known to be full. Does not reclassify.

Parameters
[in,out]a_tilesRepresentation to add to.
[in]a_fineTileTile to add (non-negative tile coordinates).

◆ classify()

void TiledMeshRefine::classify ( SuperTiles a_tiles) const
protectednoexcept

Promote every partial super-tile whose bitmask is full to the full set.

Parameters
[in,out]a_tilesRepresentation to classify.

◆ decodeSuper()

IntVect TiledMeshRefine::decodeSuper ( const std::uint64_t  a_key) const
protectednoexcept

Unpack a 64-bit super-tile key into a super-tile index.

Parameters
[in]a_keyPacked key.
Returns
Super-tile index.

◆ encodeSuper()

std::uint64_t TiledMeshRefine::encodeSuper ( const IntVect &  a_super) const
protectednoexcept

Pack a super-tile index into a 64-bit key (21 bits per direction).

Parameters
[in]a_superSuper-tile index (non-negative).
Returns
Packed key.

◆ gatherSuperTiles()

void TiledMeshRefine::gatherSuperTiles ( SuperTiles a_tiles) const
protectednoexcept

Gather the (per-rank-local) super-tile representation onto all ranks.

Locally-full super-tiles are classified first and gathered as a single key each (a "full marker", no bitmask); partial super-tiles are gathered as key + bitmask and OR-ed per key. Because tags partition the domain by rank, a super-tile's tagged sub-tiles are disjoint across ranks, so the OR is exact and a locally-full super-tile is globally full. The gathered data scales with the number of touched super-tiles (full ones costing just a key), not the number of fine tiles. Partial super-tiles that OR to all-ones across ranks are promoted by the caller's subsequent classify().

Parameters
[in,out]a_tilesLocal representation in; global representation out.

◆ makeBoxesFromTiles()

void TiledMeshRefine::makeBoxesFromTiles ( Vector< Box > &  a_boxes,
const SuperTiles a_tiles,
const ProblemDomain &  a_domain 
) const
protectedvirtualnoexcept

Turn the super-tile representation into boxes.

Full super-tiles become one (max_block_size) box each; partial super-tiles are packed into variable-sized boxes by packTiles. When max_block_size == min_block_size every super-tile is a single tile and this emits one box per tile (legacy behaviour). Super-tiles are visited in sorted-key order so the box list is identical on every rank.

Parameters
[out]a_boxesGrid boxes generated from the tiles
[in]a_tilesRepresentation to convert
[in]a_domainProblem domain

◆ makeLevelTiles()

void TiledMeshRefine::makeLevelTiles ( SuperTiles a_tiles,
const SuperTiles a_fineTiles,
const IntVectSet &  a_coarTags,
const ProblemDomain &  a_domain,
const int  a_refToFine,
const int  a_refToCoar 
) const
protectedvirtualnoexcept

Make the super-tile representation on the current level from tags and finer-level nesting.

Parameters
[out]a_tilesRepresentation on the current level
[in]a_fineTilesRepresentation on the finer level
[in]a_coarTagsRefinement tags on the current level (cells on the coarser level)
[in]a_domainProblem domain on the current level
[in]a_refToFineRefinement ratio to the finer level
[in]a_refToCoarRefinement ratio to the coarser level

◆ nestFrom()

void TiledMeshRefine::nestFrom ( SuperTiles a_tiles,
const SuperTiles a_finer,
const int  a_refToFine,
const Box &  a_thisTileBox 
) const
protectednoexcept

Inject the proper-nesting buffer into a level from the (classified) finer level.

Reproduces the legacy "grow each finer tile by one and coarsen" buffer exactly, but from the compact finer representation: full finer super-tiles contribute coarsen(grow(block,1)) in bulk, partial ones contribute coarsen(grow(tile,1)) per tagged sub-tile. Adds tiles to a_tiles; the caller reclassifies.

Parameters
[in,out]a_tilesLevel being built (this level).
[in]a_finerClassified finer-level representation.
[in]a_refToFineRefinement ratio from this level to the finer level.
[in]a_thisTileBoxTile-coordinate bounding box of this level (for clipping).

◆ packTiles()

void TiledMeshRefine::packTiles ( std::vector< IntVect > &  a_tiles,
const IntVect &  a_maxTile,
const IntVect &  a_probLo,
Vector< Box > &  a_boxes 
) const
protectednoexcept

Pack a set of tiles into variable-sized (anisotropic) boxes via recursive Berger-Rigoutsos bisection. This is the single shared box packer, called per partial super-tile.

Recursive longest-extent bisection over the tile bounding box. At each node: if the node is fully tagged and within the per-direction cap it is emitted as one box; otherwise it is split. The split is tag-driven (Berger-Rigoutsos): cut at an empty slab (a zero-tag gap) in any direction if one exists, else at the strongest signature inflection, else at the longest-axis midpoint; a node over the cap is split at a cap multiple first. Deterministic (fixed axis/plane tie-breaks) and exact (a box is emitted only when fully tagged, so no untagged cells are covered).

Parameters
[in,out]a_tilesTiles to pack, in tile coordinates; reordered in place.
[in]a_maxTilePer-direction cap in tile units (= max_block_size / tile_size).
[in]a_probLoCell-space origin of the level (added when forming the cell boxes).
[out]a_boxesBoxes (cell coordinates) appended for these tiles.

◆ regrid()

int TiledMeshRefine::regrid ( Vector< Vector< Box > > &  a_newGrids,
const Vector< IntVectSet > &  a_tagsLevel 
) const
virtualnoexcept

Regrid using the tile clustering algorithm.

Parameters
[out]a_newGridsThe new grid boxes
[in]a_tagsLevelGrid tags on each level
Returns
Returns the new finest grid level.

◆ subIndex()

int TiledMeshRefine::subIndex ( const IntVect &  a_sub) const
protectednoexcept

Linear sub-tile index of a sub-position within a super-tile.

Parameters
[in]a_subSub-position in [0, m_superFactor) per direction.
Returns
Linear index in [0, m_superVol).

Member Data Documentation

◆ m_amrDomains

Vector<ProblemDomain> TiledMeshRefine::m_amrDomains
protected

Computational domains on each level.

Note
This are the domains for the grid.

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