32 #ifndef vtkStructuredGridConnectivity_h
33 #define vtkStructuredGridConnectivity_h
35 #define VTK_NO_OVERLAP 0
36 #define VTK_NODE_OVERLAP 1
37 #define VTK_EDGE_OVERLAP 2
38 #define VTK_PARTIAL_OVERLAP 3
42 #include "vtkFiltersGeometryModule.h"
71 vtkSetVector6Macro(WholeExtent,
int);
72 vtkGetVector6Macro(WholeExtent,
int);
79 vtkGetMacro(DataDimension,
int);
91 virtual void RegisterGrid(
const int gridID,
int extents[6],
vtkUnsignedCharArray* nodesGhostArray,
98 void GetGridExtent(
const int gridID,
int extent[6]);
104 void SetGhostedGridExtent(
const int gridID,
int ext[6]);
109 void GetGhostedGridExtent(
const int gridID,
int ext[6]);
122 return (static_cast<int>(this->Neighbors[gridID].
size()));
138 vtkIdList* GetNeighbors(
const int gridID,
int* extents);
160 bool InBounds(
const int idx,
const int Lo,
const int Hi) {
return ((idx >= Lo) && (idx <= Hi)); }
167 return ((idx > Lo) && (idx < Hi));
175 return (this->InBounds(A[0], B[0], B[1]) && this->InBounds(A[1], B[0], B[1]));
202 assert(
"ERROR: code should not reach here!" &&
false);
211 void FillNodesGhostArray(
const int gridID,
const int dataDescription,
int GridExtent[6],
217 void FillCellsGhostArray(
const int dataDescription,
const int numNodesPerCell,
int dims[3],
225 void SearchNeighbors(
const int gridID,
const int i,
const int j,
const int k,
vtkIdList* neiList);
231 void MarkNodeProperty(
const int gridID,
const int i,
const int j,
const int k,
int ext[6],
232 int RealExtent[6],
unsigned char& pfield);
238 void MarkCellProperty(
unsigned char& pfield,
unsigned char* nodeGhostFields,
const int numNodes);
243 void GetRealExtent(
const int gridID,
int GridExtent[6],
int RealExtent[6]);
249 bool IsGhostNode(
int GridExtent[6],
int RealExtent[6],
const int i,
const int j,
const int k);
255 bool IsNodeOnBoundaryOfExtent(
const int i,
const int j,
const int k,
int ext[6]);
262 bool IsNodeOnSharedBoundary(
263 const int gridID,
int RealExtent[6],
const int i,
const int j,
const int k);
269 bool IsNodeOnBoundary(
const int i,
const int j,
const int k);
275 bool IsNodeInterior(
const int i,
const int j,
const int k,
int GridExtent[6]);
285 switch (this->DataDescription)
288 if ((GridExtent[0] <= i) && (i <= GridExtent[1]))
294 if ((GridExtent[2] <= j) && (j <= GridExtent[3]))
300 if ((GridExtent[4] <= k) && (k <= GridExtent[5]))
306 if ((GridExtent[0] <= i) && (i <= GridExtent[1]) && (GridExtent[2] <= j) &&
307 (j <= GridExtent[3]))
313 if ((GridExtent[2] <= j) && (j <= GridExtent[3]) && (GridExtent[4] <= k) &&
314 (k <= GridExtent[5]))
320 if ((GridExtent[0] <= i) && (i <= GridExtent[1]) && (GridExtent[4] <= k) &&
321 (k <= GridExtent[5]))
327 if ((GridExtent[0] <= i) && (i <= GridExtent[1]) && (GridExtent[2] <= j) &&
328 (j <= GridExtent[3]) && (GridExtent[4] <= k) && (k <= GridExtent[5]))
334 std::cout <<
"Data description is: " << this->DataDescription <<
"\n";
336 assert(
"pre: Undefined data-description!" &&
false);
346 const int i,
const int j,
int i2jOrientation[3],
int j2iOrientation[3],
int overlapExtent[6]);
356 void DetermineNeighborOrientation(
357 const int idx,
int A[2],
int B[2],
int overlap[2],
int orient[3]);
364 void DetectNeighbors(
365 const int i,
const int j,
int ex1[6],
int ex2[6],
int orientation[3],
int ndim);
376 int IntervalOverlap(
int A[2],
int B[2],
int overlap[2]);
387 int DoPartialOverlap(
int s[2],
int S[2],
int overlap[2]);
399 int A[2],
const int CardinalityOfA,
int B[2],
const int CardinalityOfB,
int overlap[2]);
405 void EstablishNeighbors(
const int i,
const int j);
411 void AcquireDataDescription();
427 bool HasBlockConnection(
const int gridID,
const int blockDirection);
443 void RemoveBlockConnection(
const int gridID,
const int blockDirection);
459 void AddBlockConnection(
const int gridID,
const int blockDirection);
465 void ClearBlockConnections(
const int gridID);
474 int GetNumberOfConnectingBlockFaces(
const int gridID);
479 void SetBlockTopology(
const int gridID);
487 void GetIJKBlockOrientation(
488 const int i,
const int j,
const int k,
int ext[6],
int orientation[3]);
494 int Get1DOrientation(
const int idx,
const int ExtentLo,
const int ExtentHi,
const int OnLo,
495 const int OnHi,
const int NotOnBoundary);
501 void CreateGhostedExtent(
const int gridID,
const int N);
508 void GetGhostedExtent(
509 int* ghostedExtent,
int GridExtent[6],
const int minIdx,
const int maxIdx,
const int N);
515 void CreateGhostedMaskArrays(
const int gridID);
523 void InitializeGhostData(
const int gridID);
543 void TransferRegisteredDataToGhostedData(
const int gridID);
549 void ComputeNeighborSendAndRcvExtent(
const int gridID,
const int N);
556 virtual void TransferGhostDataFromNeighbors(
const int gridID);
566 void CopyCoordinates(
583 int GetNeighborIndex(
const int gridIdx,
const int NeighborGridIdx);
588 void PrintExtent(
int extent[6]);
597 std::vector<std::vector<vtkStructuredNeighbor>>
Neighbors;
611 const int gridIdx,
const int NeighborGridIdx)
613 assert(
"pre: Grid index is out-of-bounds!" && (gridIdx >= 0) &&
615 assert(
"pre: Neighbor grid index is out-of-bounds!" && (NeighborGridIdx >= 0) &&
618 std::pair<int, int> gridPair = std::make_pair(gridIdx, NeighborGridIdx);
619 assert(
"pre: Neighboring grid pair does not exist in hash!" &&
628 int* ghostedExtent,
int GridExtent[6],
const int minIdx,
const int maxIdx,
const int N)
630 assert(
"pre: Number of ghost layers must be N >= 1" && (N >= 1));
631 assert(
"pre: ghosted extent pointer is nullptr" && ghostedExtent !=
nullptr);
633 ghostedExtent[minIdx] = GridExtent[minIdx] - N;
634 ghostedExtent[maxIdx] = GridExtent[maxIdx] + N;
637 ghostedExtent[minIdx] = (ghostedExtent[minIdx] < this->
WholeExtent[minIdx])
639 : ghostedExtent[minIdx];
640 ghostedExtent[maxIdx] = (ghostedExtent[maxIdx] > this->
WholeExtent[maxIdx])
642 : ghostedExtent[maxIdx];
648 assert(
"pre: gridID is out-of-bounds" && (gridID >= 0) &&
650 assert(
"pre: ghosted-extents vector has not been allocated" &&
653 for (
int i = 0; i < 6; ++i)
662 assert(
"pre: gridID out-of-bounds!" &&
663 (gridID >= 0 && gridID < static_cast<int>(this->
NumberOfGrids)));
664 for (
int i = 0; i < 6; ++i)
673 assert(
"pre: gridID out-of-bounds!" &&
674 (gridID >= 0 && gridID < static_cast<int>(this->
NumberOfGrids)));
678 ext[0] = ext[2] = ext[4] = -1;
679 ext[1] = ext[3] = ext[5] = 0;
680 vtkErrorMacro(
"No ghosted extents found for registered grid extends!!!");
684 assert(
"GhostedExtents are not aligned with registered grid extents" &&
686 for (
int i = 0; i < 6; ++i)
694 const int i,
const int j,
const int k,
int ext[6])
705 if (i == ext[0] || i == ext[1])
711 if (j == ext[2] || j == ext[3])
717 if (k == ext[4] || k == ext[5])
723 if ((i == ext[0] || i == ext[1]) || (j == ext[2] || j == ext[3]))
729 if ((j == ext[2] || j == ext[3]) || (k == ext[4] || k == ext[5]))
735 if ((i == ext[0] || i == ext[1]) || (k == ext[4] || k == ext[5]))
741 if ((i == ext[0] || i == ext[1]) || (j == ext[2] || j == ext[3]) ||
742 (k == ext[4] || k == ext[5]))
750 assert(
"pre: Undefined data-description!" &&
false);
758 const int i,
const int j,
const int k,
int GridExtent[6])
765 if ((GridExtent[0] < i) && (i < GridExtent[1]))
771 if ((GridExtent[2] < j) && (j < GridExtent[3]))
777 if ((GridExtent[4] < k) && (k < GridExtent[5]))
783 if ((GridExtent[0] < i) && (i < GridExtent[1]) && (GridExtent[2] < j) && (j < GridExtent[3]))
789 if ((GridExtent[2] < j) && (j < GridExtent[3]) && (GridExtent[4] < k) && (k < GridExtent[5]))
795 if ((GridExtent[0] < i) && (i < GridExtent[1]) && (GridExtent[4] < k) && (k < GridExtent[5]))
801 if ((GridExtent[0] < i) && (i < GridExtent[1]) && (GridExtent[2] < j) &&
802 (j < GridExtent[3]) && (GridExtent[4] < k) && (k < GridExtent[5]))
810 assert(
"pre: Undefined data-description!" &&
false);
818 const int idx,
int A[2],
int B[2],
int overlap[2],
int orient[3])
820 assert(
"pre: idx is out-of-bounds" && (idx >= 0) && (idx < 3));
823 if (overlap[0] == overlap[1])
829 else if (A[0] == B[1])
836 assert(
"ERROR: Code should not reach here!" &&
false);
842 if ((A[0] == B[0]) && (A[1] == B[1]))
851 else if (A[0] == B[0])
855 else if (A[1] == B[1])
862 assert(
"ERROR: Code should not reach here!" &&
false);
873 if (this->
InBounds(A[0], B[0], B[1]))
877 else if (this->
InBounds(A[1], B[0], B[1]))
884 assert(
"ERROR: Code should not reach here!" &&
false);
890 assert(
"ERROR: Code should not reach here!" &&
false);
896 const int ExtentHi,
const int OnLo,
const int OnHi,
const int NotOnBoundary)
902 else if (idx == ExtentHi)
906 return NotOnBoundary;
911 const int gridID,
const int blockDirection)
914 assert(
"pre: gridID is out-of-bounds" && (gridID >= 0) &&
916 assert(
"pre: BlockTopology has not been properly allocated" &&
918 assert(
"pre: blockDirection is out-of-bounds" && (blockDirection >= 0) && (blockDirection < 6));
929 const int gridID,
const int blockDirection)
932 assert(
"pre: gridID is out-of-bounds" && (gridID >= 0) &&
934 assert(
"pre: BlockTopology has not been properly allocated" &&
936 assert(
"pre: blockDirection is out-of-bounds" && (blockDirection >= 0) && (blockDirection < 6));
943 const int gridID,
const int blockDirection)
946 assert(
"pre: gridID is out-of-bounds" && (gridID >= 0) &&
948 assert(
"pre: BlockTopology has not been properly allocated" &&
950 assert(
"pre: blockDirection is out-of-bounds" && (blockDirection >= 0) && (blockDirection < 6));
958 assert(
"pre: gridID is out-of-bounds" && (gridID >= 0) &&
960 assert(
"pre: BlockTopology has not been properly allocated" &&
962 for (
int i = 0; i < 6; ++i)
972 assert(
"pre: gridID is out-of-bounds" && (gridID >= 0) &&
974 assert(
"pre: BlockTopology has not been properly allocated" &&
978 for (
int i = 0; i < 6; ++i)
985 assert(
"post: count must be in [0,5]" && (count >= 0 && count <= 6));
994 vtkErrorMacro(
"Number of grids cannot be 0.");
int Cardinality(int S[2])
Returns the cardinality of a range S.
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...
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
int GetNumberOfNodesPerCell(const int dim)
Returns the number of nodes per cell according to the given dimension.
std::vector< std::vector< vtkStructuredNeighbor > > Neighbors
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
void AddBlockConnection(const int gridID, const int blockDirection)
Adds a block connection along the given direction for the block corresponding to the given gridID...
bool IsSubset(int A[2], int B[2])
Returns true iff A is a subset of B, otherwise false.
void SetGhostedGridExtent(const int gridID, int ext[6])
Sets the ghosted grid extent for the grid corresponding to the given grid ID to the given extent...
void GetGhostedGridExtent(const int gridID, int ext[6])
Returns the ghosted grid extent for the block corresponding the.
virtual void ComputeNeighbors()=0
Computes the grid neighboring topology for the domain.
std::vector< int > GridExtents
represent and manipulate cell attribute data
bool InBounds(const int idx, const int Lo, const int Hi)
Returns true iff Lo <= idx <= Hi, otherwise false.
int GetNeighborIndex(const int gridIdx, const int NeighborGridIdx)
Given a global grid ID and the neighbor grid ID, this method returns the neighbor index w...
void GetGhostedExtent(int *ghostedExtent, int GridExtent[6], const int minIdx, const int maxIdx, const int N)
Gets the ghosted extent from the given grid extent along the dimension given by minIdx and maxIdx...
void DetermineNeighborOrientation(const 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...
void SetNumberOfGrids(const unsigned int N) override
Set/Get the total number of domains distributed among processors.
void RemoveBlockConnection(const int gridID, const int blockDirection)
Removes a block connection along the given direction for the block corresponding to the given gridID...
void GetGridExtent(const int gridID, int extent[6])
Returns the grid extent of the grid 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...
virtual void SetNumberOfGrids(const unsigned int N)=0
Sets the total number of grids in the domain.
bool IsNodeInterior(const int i, const int j, const int k, int GridExtent[6])
Checks if the node, corresponding to the given global i,j,k coordinates is within the interior of the...
bool IsNodeWithinExtent(const int i, const int j, const int k, int GridExtent[6])
Checks if the node corresponding to the given global i,j,k coordinates is within the given extent...
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
dynamic, self-adjusting array of unsigned char
std::map< std::pair< int, int >, int > NeighborPair2NeighborListIndex
int Get1DOrientation(const int idx, const int ExtentLo, const int ExtentHi, const int OnLo, const int OnHi, const int NotOnBoundary)
A helper method that computes the 1-D i-j-k orientation to facilitate the implementation of GetNodeBl...
unsigned int NumberOfGrids
An internal, light-weight class used to store neighbor information.
bool StrictlyInsideBounds(const int idx, const int Lo, const int Hi)
Returns true iff Lo < idx < Hi, otherwise false.
int GetNumberOfNeighbors(const int gridID)
Returns the number of neighbors for the grid corresponding to the given grid ID.
bool IsNodeOnBoundaryOfExtent(const int i, const int j, const 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...
void AllocateUserRegisterDataStructures()
Allocate/De-allocate the data-structures where the user-supplied grids will be registered.
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...
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...
represent and manipulate 3D points
void ClearBlockConnections(const int gridID)
Clears all block connections for the block corresponding to the given grid ID.
represent and manipulate fields of data
std::vector< int > GhostedExtents