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
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 vtkErrorMacro(
"No ghosted extents found for registered grid extends!!!" );
638 assert(
"GhostedExtents are not aligned with registered grid extents" &&
640 for(
int i=0; i < 6; ++i )
648 const int i,
const int j,
const int k,
int ext[6] )
659 if( i==ext[0] || i==ext[1] )
665 if( j==ext[2] || j==ext[3] )
671 if( k==ext[4] || k==ext[5] )
677 if( (i==ext[0] || i==ext[1]) ||
678 (j==ext[2] || j==ext[3]) )
684 if( (j==ext[2] || j==ext[3]) ||
685 (k==ext[4] || k==ext[5]) )
691 if( (i==ext[0] || i==ext[1]) ||
692 (k==ext[4] || k==ext[5]) )
698 if( (i==ext[0] || i==ext[1]) ||
699 (j==ext[2] || j==ext[3]) ||
700 (k==ext[4] || k==ext[5]) )
708 assert(
"pre: Undefined data-description!" &&
false );
716 const int i,
const int j,
const int k,
724 if( (GridExtent[0] < i) && (i < GridExtent[1]) )
730 if( (GridExtent[2] < j) && (j < GridExtent[3] ) )
736 if( (GridExtent[4] < k) && (k < GridExtent[5] ) )
742 if( (GridExtent[0] < i) && (i < GridExtent[1]) &&
743 (GridExtent[2] < j) && (j < GridExtent[3]) )
749 if( (GridExtent[2] < j) && (j < GridExtent[3] ) &&
750 (GridExtent[4] < k) && (k < GridExtent[5] ) )
756 if( (GridExtent[0] < i) && (i < GridExtent[1] ) &&
757 (GridExtent[4] < k) && (k < GridExtent[5] ) )
763 if( (GridExtent[0] < i) && (i < GridExtent[1]) &&
764 (GridExtent[2] < j) && (j < GridExtent[3]) &&
765 (GridExtent[4] < k) && (k < GridExtent[5]) )
773 assert(
"pre: Undefined data-description!" &&
false );
781 const int idx,
int A[2],
int B[2],
int overlap[2],
int orient[3] )
783 assert(
"pre: idx is out-of-bounds" && (idx >= 0) && (idx < 3) );
786 if( overlap[0] == overlap[1] )
792 else if( A[0] == B[1] )
799 assert(
"ERROR: Code should not reach here!" &&
false );
805 if( (A[0] == B[0]) && (A[1] == B[1]) )
814 else if( A[0] == B[0] )
818 else if( A[1] == B[1] )
825 assert(
"ERROR: Code should not reach here!" &&
false );
836 if( this->
InBounds( A[0], B[0], B[1] ) )
840 else if( this->
InBounds( A[1], B[0], B[1] ) )
847 assert(
"ERROR: Code should not reach here!" &&
false );
853 assert(
"ERROR: Code should not reach here!" &&
false );
859 const int idx,
const int ExtentLo,
const int ExtentHi,
860 const int OnLo,
const int OnHi,
const int NotOnBoundary )
862 if( idx == ExtentLo )
866 else if( idx == ExtentHi )
870 return NotOnBoundary;
875 const int gridID,
const int blockDirection )
878 assert(
"pre: gridID is out-of-bounds" &&
879 (gridID >=0) && (gridID < static_cast<int>(this->
NumberOfGrids)));
880 assert(
"pre: BlockTopology has not been properly allocated" &&
882 assert(
"pre: blockDirection is out-of-bounds" &&
883 (blockDirection >= 0) && (blockDirection < 6) );
894 const int gridID,
const int blockDirection )
897 assert(
"pre: gridID is out-of-bounds" &&
898 (gridID >=0) && (gridID < static_cast<int>(this->
NumberOfGrids)));
899 assert(
"pre: BlockTopology has not been properly allocated" &&
901 assert(
"pre: blockDirection is out-of-bounds" &&
902 (blockDirection >= 0) && (blockDirection < 6) );
909 const int gridID,
const int blockDirection )
912 assert(
"pre: gridID is out-of-bounds" &&
913 (gridID >=0) && (gridID < static_cast<int>(this->
NumberOfGrids)));
914 assert(
"pre: BlockTopology has not been properly allocated" &&
916 assert(
"pre: blockDirection is out-of-bounds" &&
917 (blockDirection >= 0) && (blockDirection < 6) );
926 assert(
"pre: gridID is out-of-bounds" &&
927 (gridID >=0) && (gridID < static_cast<int>(this->
NumberOfGrids)));
928 assert(
"pre: BlockTopology has not been properly allocated" &&
930 for(
int i=0; i < 6; ++i )
941 assert(
"pre: gridID is out-of-bounds" &&
942 (gridID >=0) && (gridID < static_cast<int>(this->
NumberOfGrids)));
943 assert(
"pre: BlockTopology has not been properly allocated" &&
947 for(
int i=0; i < 6; ++i )
954 assert(
"post: count must be in [0,5]" && (count >=0 && count <= 6) );
960 const unsigned int N )
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
#define vtkGetMacro(name, type)
represent and manipulate cell attribute data
std::vector< unsigned char > BlockTopology
std::vector< std::vector< vtkStructuredNeighbor > > Neighbors
GLuint GLuint GLsizei count
bool InBounds(const int idx, const int Lo, const int Hi)
int GetNeighborIndex(const int gridIdx, const int NeighborGridIdx)
#define vtkTypeMacro(thisClass, superclass)
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])
#define vtkSetVector6Macro(name, type)
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
#define vtkGetVector6Macro(name, type)
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