13#ifndef CD_LEVELTILES_H
14#define CD_LEVELTILES_H
19#include <unordered_map>
26#include <RefCountedPtr.H>
28#include <DisjointBoxLayout.H>
32#include <CD_NamespaceHeader.H>
46 using BoxIDs = std::pair<unsigned int, unsigned int>;
64 std::size_t hash = 14695981039346656037ULL;
65 for (
int dir = 0; dir < SpaceDim; dir++) {
66 hash ^=
static_cast<std::size_t
>(
static_cast<unsigned int>(a_tile[dir]));
67 hash *= 1099511628211ULL;
83 LevelTiles(const DisjointBoxLayout& a_dbl, const
int a_minBlockSize) noexcept;
96 define(const DisjointBoxLayout& a_dbl, const
int a_minBlockSize) noexcept;
102 virtual const std::unordered_map<IntVect,
unsigned int, TileHasher>&
109 virtual const std::unordered_map<IntVect,
BoxIDs, TileHasher>&
116 virtual const std::unordered_map<
unsigned int, DataIndex>&
162 const RealVect& a_probLo,
163 const Vector<RealVect>& a_dx,
164 const int a_minBlockSize,
165 const Vector<RefCountedPtr<LevelTiles>>& a_levelTiles,
166 const int a_finestLevel)
noexcept
169 for (
int lvl = a_finestLevel; lvl >= 0; lvl--) {
172 for (
int dir = 0; dir < SpaceDim; dir++) {
173 tile[dir] =
static_cast<int>(std::floor((a_pos[dir] - a_probLo[dir]) / (a_minBlockSize * a_dx[lvl][dir])));
179 const auto mit = myTiles.find(tile);
181 if (mit != myTiles.end()) {
182 return LevelAndBox{lvl, mit->second, procID(),
true};
187 const auto oit = otherTiles.find(tile);
189 if (oit != otherTiles.end()) {
190 return LevelAndBox{lvl, oit->second.first,
static_cast<int>(oit->second.second),
true};
207 std::unordered_map<IntVect, unsigned int, TileHasher>
m_myTiles;
220#include <CD_NamespaceFooter.H>
Class for storing the AMR hierarchy as a collection of tiles.
Definition CD_LevelTiles.H:43
virtual const std::unordered_map< IntVect, BoxIDs, TileHasher > & getOtherTiles() const noexcept
Get the tiles owned by other ranks.
Definition CD_LevelTiles.cpp:95
virtual void define(const DisjointBoxLayout &a_dbl, const int a_minBlockSize) noexcept
Define function. Puts object in usable state.
Definition CD_LevelTiles.cpp:41
bool m_isDefined
Is defined or not.
Definition CD_LevelTiles.H:202
std::unordered_map< IntVect, BoxIDs, TileHasher > m_otherTiles
Grids owned by other ranks.
Definition CD_LevelTiles.H:212
LevelTiles() noexcept
Weak constructor. Must subsequently call the define function.
Definition CD_LevelTiles.cpp:23
virtual const std::unordered_map< IntVect, unsigned int, TileHasher > & getMyTiles() const noexcept
Get the tiles owned by this rank.
Definition CD_LevelTiles.cpp:87
std::unordered_map< IntVect, unsigned int, TileHasher > m_myTiles
"Tiles" owned by this rank
Definition CD_LevelTiles.H:207
std::unordered_map< unsigned int, DataIndex > m_myGrids
Mapping of grid index to DataIndex.
Definition CD_LevelTiles.H:217
static LevelAndBox findDestination(const RealVect &a_pos, const RealVect &a_probLo, const Vector< RealVect > &a_dx, const int a_minBlockSize, const Vector< RefCountedPtr< LevelTiles > > &a_levelTiles, const int a_finestLevel) noexcept
Map a physical position to its owning (level, grid index, rank) via the finest containing tile.
Definition CD_LevelTiles.H:161
virtual const std::unordered_map< unsigned int, DataIndex > & getMyGrids() const noexcept
Get the mapping of grid index to DataIndex.
Definition CD_LevelTiles.cpp:103
std::pair< unsigned int, unsigned int > BoxIDs
alias type alias.
Definition CD_LevelTiles.H:46
Result of a point->block query. See findDestination.
Definition CD_LevelTiles.H:123
unsigned int gridIndex
Global grid/box index of the covering box within that level's LevelTiles.
Definition CD_LevelTiles.H:132
int rank
MPI rank owning that box.
Definition CD_LevelTiles.H:137
int level
Owning AMR level (finest tile that contains the point), or -1 if not found.
Definition CD_LevelTiles.H:127
bool valid
True if a covering tile/box was found (false when the point is off-domain).
Definition CD_LevelTiles.H:142
Hash functor for using IntVect tiles as unordered_map keys.
Definition CD_LevelTiles.H:55
std::size_t operator()(const IntVect &a_tile) const noexcept
Hash operator.
Definition CD_LevelTiles.H:62