34 #ifndef vtkStructuredAMRGridConnectivity_h
35 #define vtkStructuredAMRGridConnectivity_h
38 #include "vtkFiltersGeometryModule.h"
64 const unsigned int NumberOfLevels,
const unsigned int N,
const int RefinementRatio = -1);
81 virtual void RegisterGrid(
const int gridIdx,
const int level,
const int refinementRatio,
90 virtual void RegisterGrid(
const int gridIdx,
const int level,
int extents[6],
100 vtkSetMacro(BalancedRefinement,
bool);
101 vtkGetMacro(BalancedRefinement,
bool);
110 vtkSetMacro(NodeCentered,
bool);
111 vtkGetMacro(NodeCentered,
bool);
119 vtkSetMacro(CellCentered,
bool);
120 vtkGetMacro(CellCentered,
bool);
127 int GetNumberOfNeighbors(
const int gridID);
132 void GetGhostedExtent(
const int gridID,
int ext[6]);
151 void CreateGhostedMaskArrays(
const int gridID);
156 void CreateGhostedExtent(
const int gridID,
const int N);
161 void SetGhostedExtent(
const int gridID,
int ext[6]);
166 void GetCoarsenedExtent(
const int gridIdx,
int fromLevel,
int toLevel,
int ext[6]);
171 void GetRefinedExtent(
const int gridIdx,
int fromLevel,
int toLevel,
int ext[6]);
176 void RefineExtent(
int orient[3],
int ndim,
int fromLevel,
int toLevel,
int ext[6]);
182 void GetCellRefinedExtent(
int orient[3],
int ndim,
const int i,
const int j,
const int k,
183 const int fromLevel,
const int toLevel,
int ext[6]);
188 void CoarsenExtent(
int orient[3],
int ndim,
int fromLevel,
int toLevel,
int ext[6]);
193 void GetGridExtent(
const int gridIdx,
int ext[6]);
198 int GetGridLevel(
const int gridIdx);
203 bool LevelExists(
const int level);
208 bool IsNodeInterior(
const int i,
const int j,
const int k,
int GridExtent[6]);
213 bool IsNodeWithinExtent(
const int i,
const int j,
const int k,
int GridExtent[6]);
218 bool IsNodeOnSharedBoundary(
219 const int i,
const int j,
const int k,
const int gridId,
int gridExt[6]);
224 bool IsNodeOnBoundaryOfExtent(
const int i,
const int j,
const int k,
int ext[6]);
229 void InsertGridAtLevel(
const int level,
const int gridID);
235 void ComputeNeighborSendAndRcvExtent(
const int gridID,
const int N);
241 void ComputeWholeExtent();
247 void GetWholeExtentAtLevel(
const int level,
int ext[6]);
253 void EstablishNeighbors(
const int i,
const int j);
258 void GetNodeOrientation(
259 const int i,
const int j,
const int k,
int gridExt[6],
int nodeOrientation[3]);
268 void GetOrientationVector(
const int dataDescription,
int orient[3],
int& ndim);
273 bool HasConstantRefinementRatio();
278 void SetRefinementRatioAtLevel(
const int level,
const int r);
283 int GetRefinementRatioAtLevel(
const int level);
288 bool AreExtentsEqual(
int ext1[6],
int ext2[6]);
293 void SetBlockTopology(
const int gridID);
302 int GetNumberOfConnectingBlockFaces(
const int gridID);
322 assert(
"pre: gridID is out-of-bounds" && (gridID >= 0) &&
323 (gridID < static_cast<int>(this->NumberOfGrids)));
324 assert(
"pre: BlockTopology has not been properly allocated" &&
325 (this->NumberOfGrids == this->BlockTopology.size()));
326 assert(
"pre: blockDirection is out-of-bounds" && (blockDirection >= 0) && (blockDirection < 6));
328 if (this->BlockTopology[gridID] & (1 << blockDirection))
350 void RemoveBlockConnection(
const int gridID,
const int blockDirection);
366 void AddBlockConnection(
const int gridID,
const int blockDirection);
372 void ClearBlockConnections(
const int gridID);
377 virtual void MarkNodeProperty(
const int gridId,
const int i,
const int j,
const int k,
378 int gridExt[6],
int wholeExt[6],
unsigned char& p);
408 const int jLevel,
int next2[6],
const int normalizedLevel,
const int levelDiff,
416 void ComputeAMRNeighborOverlapExtents(
const int iLevel,
const int jLevel,
418 int gridOverlapExtent[6],
int neiOverlapExtent[6]);
423 int Get1DOrientation(
const int idx,
const int ExtentLo,
const int ExtentHi,
const int OnLo,
424 const int OnHi,
const int NotOnBoundary);
429 void PrintExtent(std::ostream& os,
int ext[6]);
434 void InitializeGhostData(
const int gridID);
439 void TransferRegisteredDataToGhostedData(
const int gridID);
476 virtual void TransferGhostDataFromNeighbors(
const int gridID);
519 std::vector<std::vector<vtkStructuredAMRNeighbor>>
Neighbors;
542 assert(
"pre: grid ID is out-of-bounds" && (gridID >= 0) &&
544 assert(
"pre: neighbors vector has not been properly allocated" &&
551 const int gridID,
const int nei)
553 assert(
"pre: grid ID is out-of-bounds" && (gridID >= 0) &&
555 assert(
"pre: neighbors vector has not been properly allocated" &&
557 assert(
"pre: nei index is out-of-bounds" && (nei >= 0) &&
564 const int ExtentHi,
const int OnLo,
const int OnHi,
const int NotOnBoundary)
570 else if (idx == ExtentHi)
574 return NotOnBoundary;
581 assert(
"pre: gridID is out-of-bounds" && (gridID >= 0) &&
583 assert(
"pre: BlockTopology has not been properly allocated" &&
587 for (
int i = 0; i < 6; ++i)
594 assert(
"post: count must be in [0,5]" && (count >= 0 && count <= 6));
600 const int gridID,
const int blockDirection)
603 assert(
"pre: gridID is out-of-bounds" && (gridID >= 0) &&
605 assert(
"pre: BlockTopology has not been properly allocated" &&
607 assert(
"pre: blockDirection is out-of-bounds" && (blockDirection >= 0) && (blockDirection < 6));
614 const int gridID,
const int blockDirection)
617 assert(
"pre: gridID is out-of-bounds" && (gridID >= 0) &&
619 assert(
"pre: BlockTopology has not been properly allocated" &&
621 assert(
"pre: blockDirection is out-of-bounds" && (blockDirection >= 0) && (blockDirection < 6));
629 assert(
"pre: gridID is out-of-bounds" && (gridID >= 0) &&
631 assert(
"pre: BlockTopology has not been properly allocated" &&
633 for (
int i = 0; i < 6; ++i)
642 for (
int i = 0; i < 6; ++i)
644 if (ext1[i] != ext2[i])
655 for (
int i = 0; i < 6; i += 2)
659 os << ext[i + 1] <<
"] ";
666 assert(
"pre: grid Index is out-of-bounds!" && (gridIdx < static_cast<int>(this->
NumberOfGrids)));
667 assert(
"pre: grid levels vector has not been allocated" &&
674 const int level,
const int r)
676 assert(
"pre: RefinementRatios vector is not properly allocated" &&
678 assert(
"pre: leve is out-of-bounds!" && (level >= 0) &&
680 assert(
"pre: invalid refinement ratio" && (r >= 2));
688 assert(
"pre: RefinementRatios vector is not properly allocated" &&
690 assert(
"pre: leve is out-of-bounds!" && (level >= 0) &&
693 "pre: refinement ratio for level has not been set" && (this->
RefinementRatios[level] >= 2));
711 assert(
"pre: grid index is out-of-bounds" &&
712 ((gridIdx >= 0) && (gridIdx < static_cast<int>(this->
GridExtents.size()))));
714 for (
int i = 0; i < 6; ++i)
740 grids.insert(gridID);
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void RemoveBlockConnection(const int gridID, const int blockDirection)
Removes a block connection along the given direction for the block corresponding to the given gridID...
std::vector< unsigned char > BlockTopology
std::vector< int > GridExtents
int GetNumberOfConnectingBlockFaces(const int gridID)
Returns the number of faces of the block corresponding to the given grid ID that are adjacent to at l...
std::vector< int > RefinementRatios
bool LevelExists(const int level)
Checks if the given level has been registered.
bool HasBlockConnection(const int gridID, const int blockDirection)
Checks if the block corresponding to the given grid ID has a block adjacent to it in the given block ...
represent and manipulate point attribute data
int GetGridLevel(const int gridIdx)
Returns the level of the grid with the corresponding grid ID.
std::map< int, std::set< int > > AMRHierarchy
unsigned int NumberOfLevels
void SetRefinementRatioAtLevel(const int level, const int r)
Sets the refinement ratio at the given level.
virtual void ComputeNeighbors()=0
Computes the grid neighboring topology for the domain.
represent and manipulate cell attribute data
int GetRefinementRatioAtLevel(const int level)
Returns the refinement ratio at the given level.
std::vector< int > GridLevels
std::vector< std::vector< int > > CellCenteredDonorLevel
int Get1DOrientation(const int idx, const int ExtentLo, const int ExtentHi, const int OnLo, const int OnHi, const int NotOnBoundary)
Get 1-D orientation.
a simple class to control print indentation
boost::graph_traits< vtkGraph * >::vertex_descriptor target(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
void GetGridExtent(const int gridIdx, int ext[6])
Gets the grid extent for the grid with the given grid ID.
std::vector< int > GhostedExtents
A superclass that defines the interface to be implemented by all concrete grid connectivity classes...
virtual void SetNumberOfGrids(const unsigned int N)=0
Sets the total number of grids in the domain.
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
dynamic, self-adjusting array of unsigned char
unsigned int NumberOfGrids
An internal, light-weight class used to store neighbor information.
int GetNumberOfNeighbors(const int gridID)
Returns the number of neighbors for the grid corresponding to the given grid ID.
void PrintExtent(std::ostream &os, int ext[6])
Prints the extent.
void ClearBlockConnections(const int gridID)
Clears all block connections for the block corresponding to the given grid ID.
std::vector< std::vector< vtkStructuredAMRNeighbor > > Neighbors
An internal, light-weight object used to store neighbor information for AMR grids.
vtkStructuredAMRNeighbor GetNeighbor(const int gridID, const int nei)
Returns the AMR neighbor for the patch with the corresponding grid ID.
virtual void FillGhostArrays(const int gridId, vtkUnsignedCharArray *nodesArray, vtkUnsignedCharArray *cellsArray)=0
Fills the ghost arrays for the given grid.
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
bool AreExtentsEqual(int ext1[6], int ext2[6])
Checks if the extent ext1 and ext2 are equal.
virtual void CreateGhostLayers(const int N=1)=0
Creates N layers of ghost layers where N is the number of cells that will be added to each grid...
bool HasConstantRefinementRatio()
Checks if a constant refinement ratio has been specified.
void AddBlockConnection(const int gridID, const int blockDirection)
Adds a block connection along the given direction for the block corresponding to the given gridID...
represent and manipulate 3D points
represent and manipulate fields of data
void InsertGridAtLevel(const int level, const int gridID)
Inserts the grid corresponding to the given ID at the prescribed level.