31 #ifndef vtkStructuredGridConnectivity_H_
32 #define vtkStructuredGridConnectivity_H_
34 #define VTK_NO_OVERLAP 0
35 #define VTK_NODE_OVERLAP 1
36 #define VTK_EDGE_OVERLAP 2
37 #define VTK_PARTIAL_OVERLAP 3
69 vtkSetVector6Macro(WholeExtent,
int);
70 vtkGetVector6Macro(WholeExtent,
int);
75 vtkGetMacro(DataDimension,
int);
84 virtual void RegisterGrid(
const int gridID,
int extents[6],
94 void GetGridExtent(
const int gridID,
int extent[6] );
98 void SetGhostedGridExtent(
const int gridID,
int ext[6] );
101 void GetGhostedGridExtent(
const int gridID,
int ext[6] );
110 {
return( static_cast<int>(this->Neighbors[ gridID ].
size() )); };
120 vtkIdList* GetNeighbors(
const int gridID,
int *extents );
141 bool InBounds(
const int idx,
const int Lo,
const int Hi )
142 {
return( (idx>=Lo) && (idx<=Hi) ); };
148 {
return( (idx > Lo) && (idx < Hi) ); };
154 {
return( this->InBounds(A[0], B[0], B[1]) &&
155 this->InBounds(A[1], B[0], B[1]) ); };
179 assert(
"ERROR: code should not reach here!" &&
false );
187 void FillNodesGhostArray(
188 const int gridID,
const int dataDescription,
194 void FillCellsGhostArray(
195 const int dataDescription,
const int numNodesPerCell,
204 void SearchNeighbors(
206 const int i,
const int j,
const int k,
213 void MarkNodeProperty(
215 const int i,
const int j,
const int k,
216 int ext[6],
int RealExtent[6],
unsigned char &pfield );
222 void MarkCellProperty(
223 unsigned char &pfield,
224 unsigned char *nodeGhostFields,
const int numNodes );
228 void GetRealExtent(
const int gridID,
int GridExtent[6],
int RealExtent[6] );
234 int GridExtent[6],
int RealExtent[6],
235 const int i,
const int j,
const int k );
241 bool IsNodeOnBoundaryOfExtent(
242 const int i,
const int j,
const int k,
int ext[6] );
249 bool IsNodeOnSharedBoundary(
250 const int gridID,
int RealExtent[6],
251 const int i,
const int j,
const int k );
257 bool IsNodeOnBoundary(
const int i,
const int j,
const int k );
263 const int i,
const int j,
const int k,
272 const int i,
const int j,
const int k,
278 switch( this->DataDescription )
281 if( (GridExtent[0] <= i) && (i <= GridExtent[1]) )
287 if( (GridExtent[2] <= j) && (j <= GridExtent[3] ) )
293 if( (GridExtent[4] <= k) && (k <= GridExtent[5] ) )
299 if( (GridExtent[0] <= i) && (i <= GridExtent[1]) &&
300 (GridExtent[2] <= j) && (j <= GridExtent[3]) )
306 if( (GridExtent[2] <= j) && (j <= GridExtent[3] ) &&
307 (GridExtent[4] <= k) && (k <= GridExtent[5] ) )
313 if( (GridExtent[0] <= i) && (i <= GridExtent[1] ) &&
314 (GridExtent[4] <= k) && (k <= GridExtent[5] ) )
320 if( (GridExtent[0] <= i) && (i <= GridExtent[1]) &&
321 (GridExtent[2] <= j) && (j <= GridExtent[3]) &&
322 (GridExtent[4] <= k) && (k <= GridExtent[5]) )
328 std::cout <<
"Data description is: " << this->DataDescription <<
"\n";
330 assert(
"pre: Undefined data-description!" &&
false );
339 const int i,
const int j,
340 int i2jOrientation[3],
int j2iOrientation[3],
341 int overlapExtent[6] );
351 void DetermineNeighborOrientation(
352 const int idx,
int A[2],
int B[2],
int overlap[2],
int orient[3] );
359 void DetectNeighbors(
360 const int i,
const int j,
int ex1[6],
int ex2[6],
369 int IntervalOverlap(
int A[2],
int B[2],
int overlap[2] );
376 int DoPartialOverlap(
int s[2],
int S[2],
int overlap[2] );
385 int A[2],
const int CofA,
386 int B[2],
const int CofB,
392 void EstablishNeighbors(
const int i,
const int j );
397 void AcquireDataDescription();
406 bool HasBlockConnection(
const int gridID,
const int blockDirection );
415 void RemoveBlockConnection(
const int gridID,
const int blockDirection );
424 void AddBlockConnection(
const int gridID,
const int blockDirection );
428 void ClearBlockConnections(
const int gridID );
435 int GetNumberOfConnectingBlockFaces(
const int gridID );
439 void SetBlockTopology(
const int gridID );
447 void GetIJKBlockOrientation(
448 const int i,
const int j,
const int k,
int ext[6],
int orientation[3] );
454 int Get1DOrientation(
455 const int idx,
const int ExtentLo,
const int ExtentHi,
456 const int OnLo,
const int OnHi,
const int NotOnBoundary );
461 void CreateGhostedExtent(
const int gridID,
const int N );
467 void GetGhostedExtent(
468 int *ghostedExtent,
int GridExtent[6],
469 const int minIdx,
const int maxIdx,
const int N);
475 void CreateGhostedMaskArrays(
const int gridID);
481 void InitializeGhostData(
const int gridID );
495 void TransferRegisteredDataToGhostedData(
const int gridID );
499 void ComputeNeighborSendAndRcvExtent(
const int gridID,
const int N );
504 virtual void TransferGhostDataFromNeighbors(
const int gridID );
508 void TransferLocalNeighborData(
514 void CopyCoordinates(
533 int GetNeighborIndex(
const int gridIdx,
const int NeighborGridIdx );
536 void PrintExtent(
int extent[6] );
546 std::vector< std::vector<vtkStructuredNeighbor> >
Neighbors;
561 const int gridIdx,
const int NeighborGridIdx )
563 assert(
"pre: Grid index is out-of-bounds!" &&
566 assert(
"pre: Neighbor grid index is out-of-bounds!" &&
567 (NeighborGridIdx >= 0) &&
568 (NeighborGridIdx < static_cast<int>(this->
NumberOfGrids) ) );
570 std::pair<int,int> gridPair = std::make_pair(gridIdx,NeighborGridIdx);
571 assert(
"pre: Neighboring grid pair does not exist in hash!" &&
580 int *ghostedExtent,
int GridExtent[6],
581 const int minIdx,
const int maxIdx,
const int N )
583 assert(
"pre: Number of ghost layers must be N >= 1" && (N >= 1) );
584 assert(
"pre: ghosted extent pointer is NULL" && ghostedExtent != NULL);
586 ghostedExtent[minIdx] = GridExtent[minIdx]-N;
587 ghostedExtent[maxIdx] = GridExtent[maxIdx]+N;
590 ghostedExtent[minIdx] =
591 (ghostedExtent[minIdx] < this->
WholeExtent[minIdx] )?
593 ghostedExtent[maxIdx] =
594 (ghostedExtent[maxIdx] > this->
WholeExtent[maxIdx])?
600 const int gridID,
int ext[6] )
602 assert(
"pre: gridID is out-of-bounds" &&
603 (gridID >= 0) && (gridID < static_cast<int>(this->
NumberOfGrids)));
604 assert(
"pre: ghosted-extents vector has not been allocated" &&
607 for(
int i=0; i < 6; ++i )
615 const int gridID,
int ext[6])
617 assert(
"pre: gridID out-of-bounds!" &&
618 (gridID >= 0 && gridID < static_cast<int>(this->
NumberOfGrids)));
619 for(
int i=0; i < 6; ++i )
627 const int gridID,
int ext[6])
629 assert(
"pre: gridID out-of-bounds!" &&
630 (gridID >= 0 && gridID < static_cast<int>(this->
NumberOfGrids)));
634 ext[0] = ext[2] = ext[4] = -1;
635 ext[1] = ext[3] = ext[5] = 0;
636 vtkErrorMacro(
"No ghosted extents found for registered grid extends!!!" );
640 assert(
"GhostedExtents are not aligned with registered grid extents" &&
642 for(
int i=0; i < 6; ++i )
650 const int i,
const int j,
const int k,
int ext[6] )
661 if( i==ext[0] || i==ext[1] )
667 if( j==ext[2] || j==ext[3] )
673 if( k==ext[4] || k==ext[5] )
679 if( (i==ext[0] || i==ext[1]) ||
680 (j==ext[2] || j==ext[3]) )
686 if( (j==ext[2] || j==ext[3]) ||
687 (k==ext[4] || k==ext[5]) )
693 if( (i==ext[0] || i==ext[1]) ||
694 (k==ext[4] || k==ext[5]) )
700 if( (i==ext[0] || i==ext[1]) ||
701 (j==ext[2] || j==ext[3]) ||
702 (k==ext[4] || k==ext[5]) )
710 assert(
"pre: Undefined data-description!" &&
false );
718 const int i,
const int j,
const int k,
726 if( (GridExtent[0] < i) && (i < GridExtent[1]) )
732 if( (GridExtent[2] < j) && (j < GridExtent[3] ) )
738 if( (GridExtent[4] < k) && (k < GridExtent[5] ) )
744 if( (GridExtent[0] < i) && (i < GridExtent[1]) &&
745 (GridExtent[2] < j) && (j < GridExtent[3]) )
751 if( (GridExtent[2] < j) && (j < GridExtent[3] ) &&
752 (GridExtent[4] < k) && (k < GridExtent[5] ) )
758 if( (GridExtent[0] < i) && (i < GridExtent[1] ) &&
759 (GridExtent[4] < k) && (k < GridExtent[5] ) )
765 if( (GridExtent[0] < i) && (i < GridExtent[1]) &&
766 (GridExtent[2] < j) && (j < GridExtent[3]) &&
767 (GridExtent[4] < k) && (k < GridExtent[5]) )
775 assert(
"pre: Undefined data-description!" &&
false );
783 const int idx,
int A[2],
int B[2],
int overlap[2],
int orient[3] )
785 assert(
"pre: idx is out-of-bounds" && (idx >= 0) && (idx < 3) );
788 if( overlap[0] == overlap[1] )
794 else if( A[0] == B[1] )
801 assert(
"ERROR: Code should not reach here!" &&
false );
807 if( (A[0] == B[0]) && (A[1] == B[1]) )
816 else if( A[0] == B[0] )
820 else if( A[1] == B[1] )
827 assert(
"ERROR: Code should not reach here!" &&
false );
838 if( this->
InBounds( A[0], B[0], B[1] ) )
842 else if( this->
InBounds( A[1], B[0], B[1] ) )
849 assert(
"ERROR: Code should not reach here!" &&
false );
855 assert(
"ERROR: Code should not reach here!" &&
false );
861 const int idx,
const int ExtentLo,
const int ExtentHi,
862 const int OnLo,
const int OnHi,
const int NotOnBoundary )
864 if( idx == ExtentLo )
868 else if( idx == ExtentHi )
872 return NotOnBoundary;
877 const int gridID,
const int blockDirection )
880 assert(
"pre: gridID is out-of-bounds" &&
881 (gridID >=0) && (gridID < static_cast<int>(this->
NumberOfGrids)));
882 assert(
"pre: BlockTopology has not been properly allocated" &&
884 assert(
"pre: blockDirection is out-of-bounds" &&
885 (blockDirection >= 0) && (blockDirection < 6) );
896 const int gridID,
const int blockDirection )
899 assert(
"pre: gridID is out-of-bounds" &&
900 (gridID >=0) && (gridID < static_cast<int>(this->
NumberOfGrids)));
901 assert(
"pre: BlockTopology has not been properly allocated" &&
903 assert(
"pre: blockDirection is out-of-bounds" &&
904 (blockDirection >= 0) && (blockDirection < 6) );
911 const int gridID,
const int blockDirection )
914 assert(
"pre: gridID is out-of-bounds" &&
915 (gridID >=0) && (gridID < static_cast<int>(this->
NumberOfGrids)));
916 assert(
"pre: BlockTopology has not been properly allocated" &&
918 assert(
"pre: blockDirection is out-of-bounds" &&
919 (blockDirection >= 0) && (blockDirection < 6) );
928 assert(
"pre: gridID is out-of-bounds" &&
929 (gridID >=0) && (gridID < static_cast<int>(this->
NumberOfGrids)));
930 assert(
"pre: BlockTopology has not been properly allocated" &&
932 for(
int i=0; i < 6; ++i )
943 assert(
"pre: gridID is out-of-bounds" &&
944 (gridID >=0) && (gridID < static_cast<int>(this->
NumberOfGrids)));
945 assert(
"pre: BlockTopology has not been properly allocated" &&
949 for(
int i=0; i < 6; ++i )
956 assert(
"post: count must be in [0,5]" && (count >=0 && count <= 6) );
962 const unsigned int N )
966 vtkErrorMacro(
"Number of grids cannot be 0.");
int Cardinality(int S[2])
int GetNumberOfConnectingBlockFaces(const int gridID)
int GetNumberOfNodesPerCell(const int dim)
std::map< std::pair< int, int >, int > NeighborPair2NeighborListIndex
bool HasBlockConnection(const int gridID, const int blockDirection)
boost::graph_traits< vtkGraph * >::vertex_descriptor target(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
represent and manipulate point attribute data
void AddBlockConnection(const int gridID, const int blockDirection)
bool IsSubset(int A[2], int B[2])
void SetGhostedGridExtent(const int gridID, int ext[6])
void GetGhostedGridExtent(const int gridID, int ext[6])
virtual void ComputeNeighbors()=0
represent and manipulate cell attribute data
std::vector< unsigned char > BlockTopology
std::vector< std::vector< vtkStructuredNeighbor > > Neighbors
bool InBounds(const int idx, const int Lo, const int Hi)
int GetNeighborIndex(const int gridIdx, const int NeighborGridIdx)
void GetGhostedExtent(int *ghostedExtent, int GridExtent[6], const int minIdx, const int maxIdx, const int N)
void DetermineNeighborOrientation(const int idx, int A[2], int B[2], int overlap[2], int orient[3])
void RemoveBlockConnection(const int gridID, const int blockDirection)
void GetGridExtent(const int gridID, int extent[6])
std::vector< int > GhostedExtents
a simple class to control print indentation
list of point or cell ids
virtual void SetNumberOfGrids(const unsigned int N)=0
void PrintSelf(ostream &os, vtkIndent indent)
bool IsNodeInterior(const int i, const int j, const int k, int GridExtent[6])
bool IsNodeWithinExtent(const int i, const int j, const int k, int GridExtent[6])
dynamic, self-adjusting array of unsigned char
int Get1DOrientation(const int idx, const int ExtentLo, const int ExtentHi, const int OnLo, const int OnHi, const int NotOnBoundary)
unsigned int NumberOfGrids
bool StrictlyInsideBounds(const int idx, const int Lo, const int Hi)
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
int GetNumberOfNeighbors(const int gridID)
bool IsNodeOnBoundaryOfExtent(const int i, const int j, const int k, int ext[6])
void AllocateUserRegisterDataStructures()
virtual void FillGhostArrays(const int gridId, vtkUnsignedCharArray *nodesArray, vtkUnsignedCharArray *cellsArray)=0
#define VTKFILTERSGEOMETRY_EXPORT
virtual void CreateGhostLayers(const int N=1)=0
std::vector< int > GridExtents
represent and manipulate 3D points
virtual void SetNumberOfGrids(const unsigned int N)
void ClearBlockConnections(const int gridID)
represent and manipulate fields of data