20 #ifndef vtkStructuredGridConnectivity_h
21 #define vtkStructuredGridConnectivity_h
23 #define VTK_NO_OVERLAP 0
24 #define VTK_NODE_OVERLAP 1
25 #define VTK_EDGE_OVERLAP 2
26 #define VTK_PARTIAL_OVERLAP 3
30 #include "vtkFiltersGeometryModule.h"
42 VTK_ABI_NAMESPACE_BEGIN
60 vtkSetVector6Macro(WholeExtent,
int);
61 vtkGetVector6Macro(WholeExtent,
int);
68 vtkGetMacro(DataDimension,
int);
87 void GetGridExtent(
int gridID,
int extent[6]);
93 void SetGhostedGridExtent(
int gridID,
int ext[6]);
98 void GetGhostedGridExtent(
int gridID,
int ext[6]);
111 return (static_cast<int>(this->Neighbors[gridID].
size()));
127 vtkIdList* GetNeighbors(
int gridID,
int extents[6]);
149 bool InBounds(
int idx,
int Lo,
int Hi) {
return ((idx >= Lo) && (idx <= Hi)); }
161 return (this->InBounds(A[0], B[0], B[1]) && this->InBounds(A[1], B[0], B[1]));
188 assert(
"ERROR: code should not reach here!" &&
false);
197 void FillNodesGhostArray(
int gridID,
int dataDescription,
int GridExtent[6],
int RealExtent[6],
203 void FillCellsGhostArray(
int dataDescription,
int numNodesPerCell,
int dims[3],
int CellExtent[6],
211 void SearchNeighbors(
int gridID,
int i,
int j,
int k,
vtkIdList* neiList);
217 void MarkNodeProperty(
218 int gridID,
int i,
int j,
int k,
int ext[6],
int RealExtent[6],
unsigned char& pfield);
224 void MarkCellProperty(
unsigned char& pfield,
unsigned char* nodeGhostFields,
int numNodes);
229 void GetRealExtent(
int gridID,
int GridExtent[6],
int RealExtent[6]);
235 bool IsGhostNode(
int GridExtent[6],
int RealExtent[6],
int i,
int j,
int k);
241 bool IsNodeOnBoundaryOfExtent(
int i,
int j,
int k,
int ext[6]);
248 bool IsNodeOnSharedBoundary(
int gridID,
int RealExtent[6],
int i,
int j,
int k);
254 bool IsNodeOnBoundary(
int i,
int j,
int k);
260 bool IsNodeInterior(
int i,
int j,
int k,
int GridExtent[6]);
270 switch (this->DataDescription)
273 if ((GridExtent[0] <= i) && (i <= GridExtent[1]))
279 if ((GridExtent[2] <= j) && (j <= GridExtent[3]))
285 if ((GridExtent[4] <= k) && (k <= GridExtent[5]))
291 if ((GridExtent[0] <= i) && (i <= GridExtent[1]) && (GridExtent[2] <= j) &&
292 (j <= GridExtent[3]))
298 if ((GridExtent[2] <= j) && (j <= GridExtent[3]) && (GridExtent[4] <= k) &&
299 (k <= GridExtent[5]))
305 if ((GridExtent[0] <= i) && (i <= GridExtent[1]) && (GridExtent[4] <= k) &&
306 (k <= GridExtent[5]))
312 if ((GridExtent[0] <= i) && (i <= GridExtent[1]) && (GridExtent[2] <= j) &&
313 (j <= GridExtent[3]) && (GridExtent[4] <= k) && (k <= GridExtent[5]))
319 std::cout <<
"Data description is: " << this->DataDescription <<
"\n";
321 assert(
"pre: Undefined data-description!" &&
false);
331 int i,
int j,
int i2jOrientation[3],
int j2iOrientation[3],
int overlapExtent[6]);
341 void DetermineNeighborOrientation(
int idx,
int A[2],
int B[2],
int overlap[2],
int orient[3]);
348 void DetectNeighbors(
int i,
int j,
int ex1[6],
int ex2[6],
int orientation[3],
int ndim);
359 int IntervalOverlap(
int A[2],
int B[2],
int overlap[2]);
370 int DoPartialOverlap(
int s[2],
int S[2],
int overlap[2]);
381 int PartialOverlap(
int A[2],
int CardinalityOfA,
int B[2],
int CardinalityOfB,
int overlap[2]);
387 void EstablishNeighbors(
int i,
int j);
394 void AcquireDataDescription();
410 bool HasBlockConnection(
int gridID,
int blockDirection);
426 void RemoveBlockConnection(
int gridID,
int blockDirection);
442 void AddBlockConnection(
int gridID,
int blockDirection);
448 void ClearBlockConnections(
int gridID);
457 int GetNumberOfConnectingBlockFaces(
int gridID);
462 void SetBlockTopology(
int gridID);
470 void GetIJKBlockOrientation(
int i,
int j,
int k,
int ext[6],
int orientation[3]);
476 int Get1DOrientation(
int idx,
int ExtentLo,
int ExtentHi,
int OnLo,
int OnHi,
int NotOnBoundary);
482 void CreateGhostedExtent(
int gridID,
int N);
489 void GetGhostedExtent(
490 int ghostedExtent[6], VTK_FUTURE_CONST
int GridExtent[6],
int minIdx,
int maxIdx,
int N);
496 void CreateGhostedMaskArrays(
int gridID);
504 void InitializeGhostData(
int gridID);
524 void TransferRegisteredDataToGhostedData(
int gridID);
530 void ComputeNeighborSendAndRcvExtent(
int gridID,
int N);
537 virtual void TransferGhostDataFromNeighbors(
int gridID);
547 void CopyCoordinates(
564 int GetNeighborIndex(
int gridIdx,
int NeighborGridIdx);
569 void PrintExtent(
int extent[6]);
578 std::vector<std::vector<vtkStructuredNeighbor>>
Neighbors;
593 assert(
"pre: Grid index is out-of-bounds!" && (gridIdx >= 0) &&
595 assert(
"pre: Neighbor grid index is out-of-bounds!" && (NeighborGridIdx >= 0) &&
598 std::pair<int, int> gridPair = std::make_pair(gridIdx, NeighborGridIdx);
599 assert(
"pre: Neighboring grid pair does not exist in hash!" &&
608 int ghostedExtent[6], VTK_FUTURE_CONST
int GridExtent[6],
int minIdx,
int maxIdx,
int N)
610 assert(
"pre: Number of ghost layers must be N >= 1" && (N >= 1));
611 assert(
"pre: ghosted extent pointer is nullptr" && ghostedExtent !=
nullptr);
613 ghostedExtent[minIdx] = GridExtent[minIdx] - N;
614 ghostedExtent[maxIdx] = GridExtent[maxIdx] + N;
617 ghostedExtent[minIdx] = (ghostedExtent[minIdx] < this->
WholeExtent[minIdx])
619 : ghostedExtent[minIdx];
620 ghostedExtent[maxIdx] = (ghostedExtent[maxIdx] > this->
WholeExtent[maxIdx])
622 : ghostedExtent[maxIdx];
628 assert(
"pre: gridID is out-of-bounds" && (gridID >= 0) &&
630 assert(
"pre: ghosted-extents vector has not been allocated" &&
633 for (
int i = 0; i < 6; ++i)
642 assert(
"pre: gridID out-of-bounds!" &&
643 (gridID >= 0 && gridID < static_cast<int>(this->
NumberOfGrids)));
644 for (
int i = 0; i < 6; ++i)
653 assert(
"pre: gridID out-of-bounds!" &&
654 (gridID >= 0 && gridID < static_cast<int>(this->
NumberOfGrids)));
658 ext[0] = ext[2] = ext[4] = -1;
659 ext[1] = ext[3] = ext[5] = 0;
660 vtkErrorMacro(
"No ghosted extents found for registered grid extends!!!");
664 assert(
"GhostedExtents are not aligned with registered grid extents" &&
666 for (
int i = 0; i < 6; ++i)
684 if (i == ext[0] || i == ext[1])
690 if (j == ext[2] || j == ext[3])
696 if (k == ext[4] || k == ext[5])
702 if ((i == ext[0] || i == ext[1]) || (j == ext[2] || j == ext[3]))
708 if ((j == ext[2] || j == ext[3]) || (k == ext[4] || k == ext[5]))
714 if ((i == ext[0] || i == ext[1]) || (k == ext[4] || k == ext[5]))
720 if ((i == ext[0] || i == ext[1]) || (j == ext[2] || j == ext[3]) ||
721 (k == ext[4] || k == ext[5]))
729 assert(
"pre: Undefined data-description!" &&
false);
743 if ((GridExtent[0] < i) && (i < GridExtent[1]))
749 if ((GridExtent[2] < j) && (j < GridExtent[3]))
755 if ((GridExtent[4] < k) && (k < GridExtent[5]))
761 if ((GridExtent[0] < i) && (i < GridExtent[1]) && (GridExtent[2] < j) && (j < GridExtent[3]))
767 if ((GridExtent[2] < j) && (j < GridExtent[3]) && (GridExtent[4] < k) && (k < GridExtent[5]))
773 if ((GridExtent[0] < i) && (i < GridExtent[1]) && (GridExtent[4] < k) && (k < GridExtent[5]))
779 if ((GridExtent[0] < i) && (i < GridExtent[1]) && (GridExtent[2] < j) &&
780 (j < GridExtent[3]) && (GridExtent[4] < k) && (k < GridExtent[5]))
788 assert(
"pre: Undefined data-description!" &&
false);
796 int idx,
int A[2],
int B[2],
int overlap[2],
int orient[3])
798 assert(
"pre: idx is out-of-bounds" && (idx >= 0) && (idx < 3));
801 if (overlap[0] == overlap[1])
807 else if (A[0] == B[1])
814 assert(
"ERROR: Code should not reach here!" &&
false);
820 if ((A[0] == B[0]) && (A[1] == B[1]))
829 else if (A[0] == B[0])
833 else if (A[1] == B[1])
840 assert(
"ERROR: Code should not reach here!" &&
false);
851 if (this->
InBounds(A[0], B[0], B[1]))
855 else if (this->
InBounds(A[1], B[0], B[1]))
862 assert(
"ERROR: Code should not reach here!" &&
false);
868 assert(
"ERROR: Code should not reach here!" &&
false);
874 int idx,
int ExtentLo,
int ExtentHi,
int OnLo,
int OnHi,
int NotOnBoundary)
880 else if (idx == ExtentHi)
884 return NotOnBoundary;
891 assert(
"pre: gridID is out-of-bounds" && (gridID >= 0) &&
893 assert(
"pre: BlockTopology has not been properly allocated" &&
895 assert(
"pre: blockDirection is out-of-bounds" && (blockDirection >= 0) && (blockDirection < 6));
908 assert(
"pre: gridID is out-of-bounds" && (gridID >= 0) &&
910 assert(
"pre: BlockTopology has not been properly allocated" &&
912 assert(
"pre: blockDirection is out-of-bounds" && (blockDirection >= 0) && (blockDirection < 6));
921 assert(
"pre: gridID is out-of-bounds" && (gridID >= 0) &&
923 assert(
"pre: BlockTopology has not been properly allocated" &&
925 assert(
"pre: blockDirection is out-of-bounds" && (blockDirection >= 0) && (blockDirection < 6));
933 assert(
"pre: gridID is out-of-bounds" && (gridID >= 0) &&
935 assert(
"pre: BlockTopology has not been properly allocated" &&
937 for (
int i = 0; i < 6; ++i)
947 assert(
"pre: gridID is out-of-bounds" && (gridID >= 0) &&
949 assert(
"pre: BlockTopology has not been properly allocated" &&
953 for (
int i = 0; i < 6; ++i)
960 assert(
"post: count must be in [0,5]" && (count >= 0 && count <= 6));
969 vtkErrorMacro(
"Number of grids cannot be 0.");
980 VTK_ABI_NAMESPACE_END
int Cardinality(int S[2])
Returns the cardinality of a range S.
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 PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
int GetNeighborIndex(int gridIdx, int NeighborGridIdx)
Given a global grid ID and the neighbor grid ID, this method returns the neighbor index w...
std::vector< std::vector< vtkStructuredNeighbor > > Neighbors
bool IsNodeInterior(int i, int j, int k, int GridExtent[6])
Checks if the node, corresponding to the given global i,j,k coordinates is within the interior of the...
represent and manipulate point attribute data
bool IsSubset(int A[2], int B[2])
Returns true iff A is a subset of B, otherwise false.
void RemoveBlockConnection(int gridID, int blockDirection)
Removes a block connection along the given direction for the block corresponding to the given gridID...
void DetermineNeighborOrientation(int idx, int A[2], int B[2], int overlap[2], int orient[3])
Given two overlapping extents A,B and the corresponding overlap extent this method computes A's relat...
int GetNumberOfNodesPerCell(int dim)
Returns the number of nodes per cell according to the given dimension.
virtual void ComputeNeighbors()=0
Computes the grid neighboring topology for the domain.
std::vector< int > GridExtents
represent and manipulate cell attribute data
void GetGhostedGridExtent(int gridID, int ext[6])
Returns the ghosted grid extent for the block corresponding the.
const std::string pointData
void ClearBlockConnections(int gridID)
Clears all block connections for the block corresponding to the given grid ID.
vtkStructuredGridConnectivity is a concrete instance of vtkObject that implements functionality for c...
std::vector< unsigned char > BlockTopology
a simple class to control print indentation
boost::graph_traits< vtkGraph * >::vertex_descriptor target(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
list of point or cell ids
A superclass that defines the interface to be implemented by all concrete grid connectivity classes...
void GetGhostedExtent(int ghostedExtent[6], VTK_FUTURE_CONST int GridExtent[6], int minIdx, int maxIdx, int N)
Gets the ghosted extent from the given grid extent along the dimension given by minIdx and maxIdx...
virtual void CreateGhostLayers(int N=1)=0
Creates N layers of ghost layers where N is the number of cells that will be added to each grid...
int Get1DOrientation(int idx, int ExtentLo, int ExtentHi, int OnLo, int OnHi, int NotOnBoundary)
A helper method that computes the 1-D i-j-k orientation to facilitate the implementation of GetNodeBl...
virtual void SetNumberOfGrids(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 *)
bool IsNodeWithinExtent(int i, int j, int k, int GridExtent[6])
Checks if the node corresponding to the given global i,j,k coordinates is within the given extent...
dynamic, self-adjusting array of unsigned char
std::map< std::pair< int, int >, int > NeighborPair2NeighborListIndex
unsigned int NumberOfGrids
An internal, light-weight class used to store neighbor information.
bool InBounds(int idx, int Lo, int Hi)
Returns true iff Lo <= idx <= Hi, otherwise false.
void SetNumberOfGrids(unsigned int N) override
Set/Get the total number of domains distributed among processors.
void AllocateUserRegisterDataStructures()
Allocate/De-allocate the data-structures where the user-supplied grids will be registered.
virtual void FillGhostArrays(int gridId, vtkUnsignedCharArray *nodesArray, vtkUnsignedCharArray *cellsArray)=0
Fills the ghost arrays for the given grid.
bool IsNodeOnBoundaryOfExtent(int i, int j, int k, int ext[6])
Checks if the node corresponding to the given global i,j,k coordinates is on the boundary of the give...
int GetNumberOfConnectingBlockFaces(int gridID)
Returns the number of faces of the block corresponding to the given grid ID that are adjacent to at l...
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
void GetGridExtent(int gridID, int extent[6])
Returns the grid extent of the grid corresponding to the given grid ID.
bool StrictlyInsideBounds(int idx, int Lo, int Hi)
Returns true iff Lo < idx < Hi, otherwise false.
void SetGhostedGridExtent(int gridID, int ext[6])
Sets the ghosted grid extent for the grid corresponding to the given grid ID to the given extent...
represent and manipulate 3D points
Represents and manipulates a collection of data arrays.
int GetNumberOfNeighbors(int gridID)
Returns the number of neighbors for the grid corresponding to the given grid ID.
std::vector< int > GhostedExtents
void AddBlockConnection(int gridID, int blockDirection)
Adds a block connection along the given direction for the block corresponding to the given gridID...