22 #ifndef vtkStructuredAMRGridConnectivity_h
23 #define vtkStructuredAMRGridConnectivity_h
26 #include "vtkFiltersGeometryModule.h"
36 VTK_ABI_NAMESPACE_BEGIN
52 void Initialize(
unsigned int NumberOfLevels,
unsigned int N,
int RefinementRatio = -1);
88 vtkSetMacro(BalancedRefinement,
bool);
89 vtkGetMacro(BalancedRefinement,
bool);
98 vtkSetMacro(NodeCentered,
bool);
99 vtkGetMacro(NodeCentered,
bool);
107 vtkSetMacro(CellCentered,
bool);
108 vtkGetMacro(CellCentered,
bool);
115 int GetNumberOfNeighbors(
int gridID);
164 void RefineExtent(
int orient[3],
int ndim,
int fromLevel,
int toLevel,
int ext[6]);
171 int orient[3],
int ndim,
int i,
int j,
int k,
int fromLevel,
int toLevel,
int ext[6]);
176 void CoarsenExtent(
int orient[3],
int ndim,
int fromLevel,
int toLevel,
int ext[6]);
181 void GetGridExtent(
int gridIdx,
int ext[6]);
186 int GetGridLevel(
int gridIdx);
191 bool LevelExists(
int level);
216 void InsertGridAtLevel(
int level,
int gridID);
259 bool HasConstantRefinementRatio();
264 void SetRefinementRatioAtLevel(
int level,
int r);
269 int GetRefinementRatioAtLevel(
int level);
274 bool AreExtentsEqual(
int ext1[6],
int ext2[6]);
288 int GetNumberOfConnectingBlockFaces(
int gridID);
308 assert(
"pre: gridID is out-of-bounds" && (gridID >= 0) &&
309 (gridID <
static_cast<int>(this->NumberOfGrids)));
310 assert(
"pre: BlockTopology has not been properly allocated" &&
311 (this->NumberOfGrids == this->BlockTopology.size()));
312 assert(
"pre: blockDirection is out-of-bounds" && (blockDirection >= 0) && (blockDirection < 6));
314 if (this->BlockTopology[gridID] & (1 << blockDirection))
336 void RemoveBlockConnection(
int gridID,
int blockDirection);
352 void AddBlockConnection(
int gridID,
int blockDirection);
358 void ClearBlockConnections(
int gridID);
364 int gridId,
int i,
int j,
int k,
int gridExt[6],
int wholeExt[6],
unsigned char& p);
403 int neiOverlapExtent[6]);
408 int Get1DOrientation(
int idx,
int ExtentLo,
int ExtentHi,
int OnLo,
int OnHi,
int NotOnBoundary);
413 void PrintExtent(std::ostream& os,
int ext[6]);
503 std::vector<std::vector<vtkStructuredAMRNeighbor>>
Neighbors;
526 assert(
"pre: grid ID is out-of-bounds" && (gridID >= 0) &&
528 assert(
"pre: neighbors vector has not been properly allocated" &&
529 (this->
Neighbors.size() == this->NumberOfGrids));
536 assert(
"pre: grid ID is out-of-bounds" && (gridID >= 0) &&
538 assert(
"pre: neighbors vector has not been properly allocated" &&
539 (this->
Neighbors.size() == this->NumberOfGrids));
540 assert(
"pre: nei index is out-of-bounds" && (nei >= 0) &&
547 int idx,
int ExtentLo,
int ExtentHi,
int OnLo,
int OnHi,
int NotOnBoundary)
553 else if (idx == ExtentHi)
557 return NotOnBoundary;
564 assert(
"pre: gridID is out-of-bounds" && (gridID >= 0) &&
566 assert(
"pre: BlockTopology has not been properly allocated" &&
570 for (
int i = 0; i < 6; ++i)
577 assert(
"post: count must be in [0,5]" && (count >= 0 && count <= 6));
585 assert(
"pre: gridID is out-of-bounds" && (gridID >= 0) &&
587 assert(
"pre: BlockTopology has not been properly allocated" &&
589 assert(
"pre: blockDirection is out-of-bounds" && (blockDirection >= 0) && (blockDirection < 6));
598 assert(
"pre: gridID is out-of-bounds" && (gridID >= 0) &&
600 assert(
"pre: BlockTopology has not been properly allocated" &&
602 assert(
"pre: blockDirection is out-of-bounds" && (blockDirection >= 0) && (blockDirection < 6));
610 assert(
"pre: gridID is out-of-bounds" && (gridID >= 0) &&
612 assert(
"pre: BlockTopology has not been properly allocated" &&
614 for (
int i = 0; i < 6; ++i)
623 for (
int i = 0; i < 6; ++i)
625 if (ext1[i] != ext2[i])
636 for (
int i = 0; i < 6; i += 2)
640 os << ext[i + 1] <<
"] ";
647 assert(
"pre: grid Index is out-of-bounds!" && (gridIdx <
static_cast<int>(this->
NumberOfGrids)));
648 assert(
"pre: grid levels vector has not been allocated" &&
649 (this->
GridLevels.size() == this->NumberOfGrids));
656 assert(
"pre: RefinementRatios vector is not properly allocated" &&
658 assert(
"pre: level is out-of-bounds!" && (
level >= 0) &&
660 assert(
"pre: invalid refinement ratio" && (r >= 2));
668 assert(
"pre: RefinementRatios vector is not properly allocated" &&
670 assert(
"pre: level is out-of-bounds!" && (
level >= 0) &&
673 "pre: refinement ratio for level has not been set" && (this->
RefinementRatios[level] >= 2));
691 assert(
"pre: grid index is out-of-bounds" &&
692 ((gridIdx >= 0) && (gridIdx <
static_cast<int>(this->
GridExtents.size()))));
694 for (
int i = 0; i < 6; ++i)
703 if (this->
AMRHierarchy.find(level) != this->AMRHierarchy.end())
720 grids.insert(gridID);
725 VTK_ABI_NAMESPACE_END
A superclass that defines the interface to be implemented by all concrete grid connectivity classes.
unsigned int NumberOfGrids
represent and manipulate cell attribute data
represent and manipulate fields of data
a simple class to control print indentation
represent and manipulate point attribute data
represent and manipulate 3D points
unsigned int NumberOfLevels
void InsertGridAtLevel(int level, int gridID)
Inserts the grid corresponding to the given ID at the prescribed level.
void CreateGhostedMaskArrays(int gridID)
Creates the ghosted mask arrays.
vtkStructuredAMRNeighbor GetNeighbor(int gridID, int nei)
Returns the AMR neighbor for the patch with the corresponding grid ID.
int Get1DOrientation(int idx, int ExtentLo, int ExtentHi, int OnLo, int OnHi, int NotOnBoundary)
Get 1-D orientation.
virtual void RegisterGrid(int gridIdx, int level, int extents[6], vtkUnsignedCharArray *nodesGhostArray, vtkUnsignedCharArray *cellGhostArray, vtkPointData *pointData, vtkCellData *cellData, vtkPoints *gridNodes)
Registers the AMR grid with the given global linear grid ID (starting numbering from 0) and level.
void GetLocalCellCentersFromFinerLevel(int gridID, vtkStructuredAMRNeighbor &nei)
Copy cell center values from a finer level by cell averaging.
static vtkStructuredAMRGridConnectivity * New()
std::vector< int > GridLevels
virtual void FillNodesGhostArray(int gridId, vtkUnsignedCharArray *nodesArray)
Fills the node ghost arrays for the given grid.
std::vector< int > RefinementRatios
void TransferLocalNeighborData(int gridID, vtkStructuredAMRNeighbor &nei)
Transfers local neighbor data.
bool AreExtentsEqual(int ext1[6], int ext2[6])
Checks if the extent ext1 and ext2 are equal.
void ClearBlockConnections(int gridID)
Clears all block connections for the block corresponding to the given grid ID.
void GetLocalCellCentersAtSameLevel(int gridID, vtkStructuredAMRNeighbor &nei)
Copy cell center values to fill in the ghost levels from a neighbor at the same level as the grid cor...
void RemoveBlockConnection(int gridID, int blockDirection)
Removes a block connection along the given direction for the block corresponding to the given gridID.
void InitializeGhostData(int gridID)
Initializes the ghost data-structures.
int GetNumberOfConnectingBlockFaces(int gridID)
Returns the number of faces of the block corresponding to the given grid ID that are adjacent to at l...
void TransferLocalNodeCenteredNeighborData(int gridID, vtkStructuredAMRNeighbor &nei)
Transfers local node-centered neighbor data.
void CreateGhostLayers(int N=1) override
Creates ghost layers.
void GetGridExtent(int gridIdx, int ext[6])
Gets the grid extent for the grid with the given grid ID.
void SetBlockTopology(int gridID)
Constructs the block topology for the given grid.
bool LevelExists(int level)
Checks if the given level has been registered.
void GetOrientationVector(int dataDescription, int orient[3], int &ndim)
Establishes the orientation vector and dimension based on the computed data description.
std::vector< std::vector< int > > CellCenteredDonorLevel
int GetRefinementRatioAtLevel(int level)
Returns the refinement ratio at the given level.
void GetWholeExtentAtLevel(int level, int ext[6])
Gets the whole extent with respect to the given level.
bool HasBlockConnection(int gridID, int blockDirection)
Checks if the block corresponding to the given grid ID has a block adjacent to it in the given block ...
void TransferRegisteredDataToGhostedData(int gridID)
Transfers the data of the registered grid, to the ghosted data-structures.
void Initialize(unsigned int NumberOfLevels, unsigned int N, int RefinementRatio=-1)
Initializes this instance of vtkStructuredAMRGridConnectivity where N is the total number of grids in...
void GetCoarsenedExtent(int gridIdx, int fromLevel, int toLevel, int ext[6])
Gets the coarsened extent for the grid with the given grid index.
void SetGhostedExtent(int gridID, int ext[6])
Sets the ghost extent for the grid corresponding to the given grid ID.
void TransferLocalCellCenteredNeighborData(int gridID, vtkStructuredAMRNeighbor &nei)
Transfers local cell-centered neighbor data.
virtual void FillCellsGhostArray(int gridId, vtkUnsignedCharArray *cellsArray)
Fills the cell ghost arrays for the given grid.
bool IsNodeOnBoundaryOfExtent(int i, int j, int k, int ext[6])
Checks if the node is on the boundary of the given extent.
std::vector< int > GhostedExtents
void ComputeNeighborSendAndRcvExtent(int gridID, int N)
Loops through the neighbors of this grid and computes the send and rcv extents for the N requested gh...
vtkStructuredAMRGridConnectivity()
bool IsNodeWithinExtent(int i, int j, int k, int GridExtent[6])
Checks if the node is within the extent.
void EstablishNeighbors(int i, int j)
Establishes neighboring relationship between grids i,j wheren i,j are global indices.
virtual void TransferGhostDataFromNeighbors(int gridID)
Fills in the ghost data from the neighbors.
void GetRefinedExtent(int gridIdx, int fromLevel, int toLevel, int ext[6])
Gets the refined extent for the grid with the given grid index.
void GetNodeOrientation(int i, int j, int k, int gridExt[6], int nodeOrientation[3])
Computes the node orientation tuple for the given i,j,k node.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void GetCellRefinedExtent(int orient[3], int ndim, int i, int j, int k, int fromLevel, int toLevel, int ext[6])
Given the global i,j,k index of a cell at a coarse level, fromLevel, this method computes the range o...
std::vector< std::vector< vtkStructuredAMRNeighbor > > Neighbors
void GetLocalCellCentersFromCoarserLevel(int gridID, vtkStructuredAMRNeighbor &nei)
Copy cell center value from a coarser level by direct-injection, i.e., the values within the coarse c...
virtual void RegisterGrid(int gridIdx, int level, int refinementRatio, int extents[6], vtkUnsignedCharArray *nodesGhostArray, vtkUnsignedCharArray *cellGhostArray, vtkPointData *pointData, vtkCellData *cellData, vtkPoints *gridNodes)
Registers the AMR grid with the given global linear grid ID (starting numbering from 0) and level and...
bool IsNodeInterior(int i, int j, int k, int GridExtent[6])
Checks if the node is an interior node in the given extent.
void GetGhostedExtent(int gridID, int ext[6])
Returns the ghost extend for the grid corresponding to the given grid ID.
std::vector< int > GridExtents
void AddBlockConnection(int gridID, int blockDirection)
Adds a block connection along the given direction for the block corresponding to the given gridID.
void ComputeNeighbors() override
Computes neighboring information.
void CopyFieldData(vtkFieldData *source, vtkIdType sourceIdx, vtkFieldData *target, vtkIdType targetIdx)
Loops through all arrays in the source and for each array, it copies the tuples from sourceIdx to the...
~vtkStructuredAMRGridConnectivity() override
std::map< int, std::set< int > > AMRHierarchy
void CoarsenExtent(int orient[3], int ndim, int fromLevel, int toLevel, int ext[6])
Coarsens the given extent.
void ComputeWholeExtent()
Computes the whole extent w.r.t.
bool IsNodeOnSharedBoundary(int i, int j, int k, int gridId, int gridExt[6])
Checks if the node is on a shared boundary.
void ComputeAMRNeighborOverlapExtents(int iLevel, int jLevel, int normalizedLevel, const vtkStructuredNeighbor &nei, int orient[3], int ndim, int gridOverlapExtent[6], int neiOverlapExtent[6])
A Helper method to compute the AMR neighbor overlap extents.
void AverageFieldData(vtkFieldData *source, vtkIdType *sourceIds, int N, vtkFieldData *target, vtkIdType targetIdx)
Loops through all arrays and computes the average of the supplied source indices and stores the corre...
std::vector< unsigned char > BlockTopology
void CreateGhostedExtent(int gridID, int N)
Creates the ghosted extent of the given grid.
void SetRefinementRatioAtLevel(int level, int r)
Sets the refinement ratio at the given level.
void FillGhostArrays(int gridId, vtkUnsignedCharArray *nodesArray, vtkUnsignedCharArray *cellsArray) override
Fills ghost arrays.
void RefineExtent(int orient[3], int ndim, int fromLevel, int toLevel, int ext[6])
Refines the given extent.
int GetGridLevel(int gridIdx)
Returns the level of the grid with the corresponding grid ID.
virtual void MarkNodeProperty(int gridId, int i, int j, int k, int gridExt[6], int wholeExt[6], unsigned char &p)
Marks the ghost property for the given node.
vtkStructuredAMRNeighbor GetAMRNeighbor(int i, int iLevel, int next1[6], int j, int jLevel, int next2[6], int normalizedLevel, int levelDiff, vtkStructuredNeighbor &nei)
Compute the AMR neighbor of grid "i" and its neighbor grid "j".
void PrintExtent(std::ostream &os, int ext[6])
Prints the extent.
bool HasConstantRefinementRatio()
Checks if a constant refinement ratio has been specified.
void SetNumberOfGrids(unsigned int N) override
Sets the total number of grids(blocks) in the AMR hierarchy.
int GetNumberOfNeighbors(int gridID)
Returns the number of neighbors for the grid corresponding to the given grid ID.
An internal, light-weight object used to store neighbor information for AMR grids.
An internal, light-weight class used to store neighbor information.
dynamic, self-adjusting array of unsigned char
const std::string pointData
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
boost::graph_traits< vtkGraph * >::vertex_descriptor target(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)