chombo-discharge
CD_LevelTiles.H
Go to the documentation of this file.
1 /* chombo-discharge
2  * Copyright © 2024 SINTEF Energy Research.
3  * Please refer to Copyright.txt and LICENSE in the chombo-discharge root directory.
4  */
5 
12 #ifndef CD_LevelTiles_H
13 #define CD_LevelTiles_H
14 
15 // Std includes
16 #include <vector>
17 #include <map>
18 
19 // Chombo includes
20 #include <IntVect.H>
21 #include <DisjointBoxLayout.H>
22 #include <DataIndex.H>
23 
24 // Our includes
25 #include <CD_NamespaceHeader.H>
26 
33 {
34 public:
35  using BoxIDs = std::pair<unsigned int, unsigned int>;
36 
43  {
44  bool
45  operator()(const IntVect& a, const IntVect& b) const
46  {
47  D_TERM6(if (a[0] > b[0]) return true; else if (a[0] < b[0]) return false;, if (a[1] > b[1]) return true;
48  else if (a[1] < b[1]) return false;
49  , if (a[2] > b[2]) return true;
50  else if (a[2] < b[2]) return false;
51  , if (a[3] > b[3]) return true;
52  else if (a[3] < b[3]) return false;
53  , if (a[4] > b[4]) return true;
54  else if (a[4] < b[4]) return false;
55  , if (a[5] > b[5]) return true;
56  else if (a[5] < b[5]) return false;);
57  return false;
58  }
59  };
60 
64  LevelTiles() noexcept;
65 
71  LevelTiles(const DisjointBoxLayout& a_grids, const int a_blockingFactor) noexcept;
72 
76  virtual ~LevelTiles() noexcept;
77 
83  virtual void
84  define(const DisjointBoxLayout& a_grids, const int a_blockingFactor) noexcept;
85 
90  virtual const std::map<IntVect, unsigned int, TileComparator>&
91  getMyTiles() const noexcept;
92 
97  virtual const std::map<IntVect, BoxIDs, TileComparator>&
98  getOtherTiles() const noexcept;
99 
104  virtual const std::map<unsigned int, DataIndex>&
105  getMyGrids() const noexcept;
106 
107 protected:
112 
116  std::map<IntVect, unsigned int, TileComparator> m_myTiles;
117 
121  std::map<IntVect, BoxIDs, TileComparator> m_otherTiles;
122 
126  std::map<unsigned int, DataIndex> m_myGrids;
127 };
128 
129 #include <CD_NamespaceFooter.H>
130 
131 #endif
Class for storing the AMR hierarchy as a collection of tiles.
Definition: CD_LevelTiles.H:33
bool m_isDefined
Is defined or not.
Definition: CD_LevelTiles.H:111
virtual const std::map< IntVect, unsigned int, TileComparator > & getMyTiles() const noexcept
Get the tiles own by this rank.
Definition: CD_LevelTiles.cpp:80
LevelTiles() noexcept
Weak constructor. Must subsequently call the define function.
Definition: CD_LevelTiles.cpp:21
virtual const std::map< IntVect, BoxIDs, TileComparator > & getOtherTiles() const noexcept
Get the tiles own by this rank.
Definition: CD_LevelTiles.cpp:92
virtual const std::map< unsigned int, DataIndex > & getMyGrids() const noexcept
Get the tiles own by this rank.
Definition: CD_LevelTiles.cpp:100
std::map< IntVect, BoxIDs, TileComparator > m_otherTiles
Grids owned by other ranks.
Definition: CD_LevelTiles.H:121
std::map< IntVect, unsigned int, TileComparator > m_myTiles
"Tiles" owned by this rank
Definition: CD_LevelTiles.H:116
virtual void define(const DisjointBoxLayout &a_grids, const int a_blockingFactor) noexcept
Define function. Puts object in usable state.
Definition: CD_LevelTiles.cpp:41
std::map< unsigned int, DataIndex > m_myGrids
Mapping of grid index to DataIndex.
Definition: CD_LevelTiles.H:126
For lexicographically comparing tiles.
Definition: CD_LevelTiles.H:43