VTK
vtkStructuredGridConnectivity.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkStructuredGridConnectivity.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14  =========================================================================*/
29 #ifndef vtkStructuredGridConnectivity_h
30 #define vtkStructuredGridConnectivity_h
31 
32 #define VTK_NO_OVERLAP 0
33 #define VTK_NODE_OVERLAP 1
34 #define VTK_EDGE_OVERLAP 2
35 #define VTK_PARTIAL_OVERLAP 3
36 
37 // VTK include directives
38 #include "vtkFiltersGeometryModule.h" // For export macro
40 #include "vtkStructuredNeighbor.h" // For Structured Neighbor object definition
41 #include "vtkStructuredData.h" // For data description definitions
42 
43 // C++ include directives
44 #include <iostream> // For cout
45 #include <vector> // For STL vector
46 #include <map> // For STL map
47 #include <utility> // For STL pair and overloaded relational operators
48 #include <cassert> // For assert()
49 
50 // Forward Declarations
51 class vtkIdList;
53 class vtkPointData;
54 class vtkCellData;
55 class vtkPoints;
56 
57 class VTKFILTERSGEOMETRY_EXPORT vtkStructuredGridConnectivity :
59 {
60 public:
63  void PrintSelf(ostream& os, vtkIndent indent ) VTK_OVERRIDE;
64 
66 
69  vtkSetVector6Macro(WholeExtent,int);
70  vtkGetVector6Macro(WholeExtent,int);
72 
74 
77  vtkGetMacro(DataDimension,int);
79 
83  void SetNumberOfGrids( const unsigned int N ) VTK_OVERRIDE;
84 
89  virtual void RegisterGrid( const int gridID, int extents[6],
90  vtkUnsignedCharArray* nodesGhostArray,
91  vtkUnsignedCharArray* cellGhostArray,
92  vtkPointData* pointData,
93  vtkCellData* cellData,
94  vtkPoints* gridNodes );
95 
99  void GetGridExtent( const int gridID, int extent[6] );
100 
105  void SetGhostedGridExtent( const int gridID, int ext[6] );
106 
110  void GetGhostedGridExtent( const int gridID, int ext[6] );
111 
115  void ComputeNeighbors() VTK_OVERRIDE;
116 
121  int GetNumberOfNeighbors( const int gridID )
122  { return( static_cast<int>(this->Neighbors[ gridID ].size() )); };
123 
128  vtkStructuredNeighbor GetGridNeighbor(const int gridID, const int nei);
129 
137  vtkIdList* GetNeighbors( const int gridID, int *extents );
138 
144  void FillGhostArrays(
145  const int gridID,
146  vtkUnsignedCharArray *nodesArray,
147  vtkUnsignedCharArray *cellsArray ) VTK_OVERRIDE;
148 
152  void CreateGhostLayers( const int N=1 ) VTK_OVERRIDE;
153 
154 protected:
156  ~vtkStructuredGridConnectivity() VTK_OVERRIDE;
157 
161  bool InBounds( const int idx, const int Lo, const int Hi )
162  { return( (idx>=Lo) && (idx<=Hi) ); };
163 
167  bool StrictlyInsideBounds( const int idx, const int Lo, const int Hi )
168  { return( (idx > Lo) && (idx < Hi) ); };
169 
173  bool IsSubset( int A[2], int B[2] )
174  { return( this->InBounds(A[0], B[0], B[1]) &&
175  this->InBounds(A[1], B[0], B[1]) ); };
176 
180  int Cardinality( int S[2] ) { return( S[1]-S[0]+1 ); };
181 
183 
186  int GetNumberOfNodesPerCell( const int dim )
187  {
188  int numNodes = 0;
189  switch( dim )
190  {
191  case 1:
192  numNodes = 2; // line cell
193  break;
194  case 2:
195  numNodes = 4; // quad cell
196  break;
197  case 3:
198  numNodes = 8; // hex cell
199  break;
200  default:
201  assert( "ERROR: code should not reach here!" && false );
202  } // END switch
203  return( numNodes );
204  }
206 
210  void FillNodesGhostArray(
211  const int gridID, const int dataDescription,
212  int GridExtent[6], int RealExtent[6], vtkUnsignedCharArray *nodeArray );
213 
217  void FillCellsGhostArray(
218  const int dataDescription, const int numNodesPerCell,
219  int dims[3], int CellExtent[6], vtkUnsignedCharArray *nodesArray,
220  vtkUnsignedCharArray *cellsArray );
221 
227  void SearchNeighbors(
228  const int gridID,
229  const int i, const int j, const int k,
230  vtkIdList *neiList );
231 
236  void MarkNodeProperty(
237  const int gridID,
238  const int i, const int j, const int k,
239  int ext[6], int RealExtent[6], unsigned char &pfield );
240 
245  void MarkCellProperty(
246  unsigned char &pfield,
247  unsigned char *nodeGhostFields, const int numNodes );
248 
252  void GetRealExtent( const int gridID, int GridExtent[6],int RealExtent[6] );
253 
258  bool IsGhostNode(
259  int GridExtent[6], int RealExtent[6],
260  const int i, const int j, const int k );
261 
266  bool IsNodeOnBoundaryOfExtent(
267  const int i, const int j, const int k, int ext[6] );
268 
274  bool IsNodeOnSharedBoundary(
275  const int gridID, int RealExtent[6],
276  const int i, const int j, const int k );
277 
282  bool IsNodeOnBoundary( const int i, const int j, const int k );
283 
288  bool IsNodeInterior(
289  const int i, const int j, const int k,
290  int GridExtent[6] );
291 
297  const int i, const int j, const int k,
298  int GridExtent[6] )
299  {
300  bool status = false;
301 
302  switch( this->DataDescription )
303  {
304  case VTK_X_LINE:
305  if( (GridExtent[0] <= i) && (i <= GridExtent[1]) )
306  {
307  status = true;
308  }
309  break;
310  case VTK_Y_LINE:
311  if( (GridExtent[2] <= j) && (j <= GridExtent[3] ) )
312  {
313  status = true;
314  }
315  break;
316  case VTK_Z_LINE:
317  if( (GridExtent[4] <= k) && (k <= GridExtent[5] ) )
318  {
319  status = true;
320  }
321  break;
322  case VTK_XY_PLANE:
323  if( (GridExtent[0] <= i) && (i <= GridExtent[1]) &&
324  (GridExtent[2] <= j) && (j <= GridExtent[3]) )
325  {
326  status = true;
327  }
328  break;
329  case VTK_YZ_PLANE:
330  if( (GridExtent[2] <= j) && (j <= GridExtent[3] ) &&
331  (GridExtent[4] <= k) && (k <= GridExtent[5] ) )
332  {
333  status = true;
334  }
335  break;
336  case VTK_XZ_PLANE:
337  if( (GridExtent[0] <= i) && (i <= GridExtent[1] ) &&
338  (GridExtent[4] <= k) && (k <= GridExtent[5] ) )
339  {
340  status = true;
341  }
342  break;
343  case VTK_XYZ_GRID:
344  if( (GridExtent[0] <= i) && (i <= GridExtent[1]) &&
345  (GridExtent[2] <= j) && (j <= GridExtent[3]) &&
346  (GridExtent[4] <= k) && (k <= GridExtent[5]) )
347  {
348  status = true;
349  }
350  break;
351  default:
352  std::cout << "Data description is: " << this->DataDescription << "\n";
353  std::cout.flush();
354  assert( "pre: Undefined data-description!" && false );
355  } // END switch
356 
357  return( status );
358  }
359 
363  void SetNeighbors(
364  const int i, const int j,
365  int i2jOrientation[3], int j2iOrientation[3],
366  int overlapExtent[6] );
367 
376  void DetermineNeighborOrientation(
377  const int idx, int A[2], int B[2], int overlap[2], int orient[3] );
378 
384  void DetectNeighbors(
385  const int i, const int j, int ex1[6], int ex2[6],
386  int orientation[3], int ndim);
387 
397  int IntervalOverlap( int A[2], int B[2], int overlap[2] );
398 
408  int DoPartialOverlap( int s[2], int S[2], int overlap[2] );
409 
419  int PartialOverlap(
420  int A[2], const int CofA,
421  int B[2], const int CofB,
422  int overlap[2] );
423 
428  void EstablishNeighbors( const int i, const int j );
429 
434  void AcquireDataDescription();
435 
450  bool HasBlockConnection( const int gridID, const int blockDirection );
451 
466  void RemoveBlockConnection( const int gridID, const int blockDirection );
467 
482  void AddBlockConnection( const int gridID, const int blockDirection );
483 
488  void ClearBlockConnections( const int gridID );
489 
497  int GetNumberOfConnectingBlockFaces( const int gridID );
498 
502  void SetBlockTopology( const int gridID );
503 
510  void GetIJKBlockOrientation(
511  const int i, const int j, const int k, int ext[6], int orientation[3] );
512 
517  int Get1DOrientation(
518  const int idx, const int ExtentLo, const int ExtentHi,
519  const int OnLo, const int OnHi, const int NotOnBoundary );
520 
525  void CreateGhostedExtent( const int gridID, const int N );
526 
532  void GetGhostedExtent(
533  int *ghostedExtent, int GridExtent[6],
534  const int minIdx, const int maxIdx, const int N);
535 
540  void CreateGhostedMaskArrays(const int gridID);
541 
548  void InitializeGhostData( const int gridID );
549 
555  void AllocatePointData( vtkPointData *RPD, const int N, vtkPointData *PD );
556 
562  void AllocateCellData( vtkCellData *RCD, const int N, vtkCellData *CD );
563 
568  void TransferRegisteredDataToGhostedData( const int gridID );
569 
574  void ComputeNeighborSendAndRcvExtent( const int gridID, const int N );
575 
581  virtual void TransferGhostDataFromNeighbors( const int gridID );
582 
586  void TransferLocalNeighborData(
587  const int gridID, const vtkStructuredNeighbor& Neighor);
588 
592  void CopyCoordinates(
593  vtkPoints *source, vtkIdType sourceIdx,
594  vtkPoints *target, vtkIdType targetIdx );
595 
602  void CopyFieldData(
603  vtkFieldData *source, vtkIdType sourceIdx,
604  vtkFieldData *target, vtkIdType targetIdx );
605 
611  int GetNeighborIndex( const int gridIdx, const int NeighborGridIdx );
612 
616  void PrintExtent( int extent[6] );
617 
620  int WholeExtent[6];
621 
622  std::vector< int > GridExtents;
623  std::vector< int > GhostedExtents;
624  std::vector< unsigned char > BlockTopology;
625  std::vector< std::vector<vtkStructuredNeighbor> > Neighbors;
626  std::map< std::pair< int,int >, int > NeighborPair2NeighborListIndex;
627 
628 private:
629  vtkStructuredGridConnectivity( const vtkStructuredGridConnectivity& ) VTK_DELETE_FUNCTION;
630  void operator=(const vtkStructuredGridConnectivity& ) VTK_DELETE_FUNCTION;
631 };
632 
633 //=============================================================================
634 // INLINE METHODS
635 //=============================================================================
636 
637 //------------------------------------------------------------------------------
639  const int gridIdx, const int NeighborGridIdx )
640 {
641  assert("pre: Grid index is out-of-bounds!" &&
642  (gridIdx >= 0) &&
643  (gridIdx < static_cast<int>(this->NumberOfGrids)));
644  assert("pre: Neighbor grid index is out-of-bounds!" &&
645  (NeighborGridIdx >= 0) &&
646  (NeighborGridIdx < static_cast<int>(this->NumberOfGrids) ) );
647 
648  std::pair<int,int> gridPair = std::make_pair(gridIdx,NeighborGridIdx);
649  assert("pre: Neighboring grid pair does not exist in hash!" &&
650  (this->NeighborPair2NeighborListIndex.find(gridPair) !=
651  this->NeighborPair2NeighborListIndex.end() ) );
652 
653  return(this->NeighborPair2NeighborListIndex[gridPair]);
654 }
655 
656 //------------------------------------------------------------------------------
658  int *ghostedExtent, int GridExtent[6],
659  const int minIdx, const int maxIdx, const int N )
660 {
661  assert( "pre: Number of ghost layers must be N >= 1" && (N >= 1) );
662  assert( "pre: ghosted extent pointer is NULL" && ghostedExtent != NULL);
663 
664  ghostedExtent[minIdx] = GridExtent[minIdx]-N;
665  ghostedExtent[maxIdx] = GridExtent[maxIdx]+N;
666 
667  // Clamp the ghosted extent to be within the WholeExtent
668  ghostedExtent[minIdx] =
669  (ghostedExtent[minIdx] < this->WholeExtent[minIdx] )?
670  this->WholeExtent[minIdx] : ghostedExtent[minIdx];
671  ghostedExtent[maxIdx] =
672  (ghostedExtent[maxIdx] > this->WholeExtent[maxIdx])?
673  this->WholeExtent[maxIdx] : ghostedExtent[maxIdx];
674 }
675 
676 //------------------------------------------------------------------------------
678  const int gridID, int ext[6] )
679 {
680  assert( "pre: gridID is out-of-bounds" &&
681  (gridID >= 0) && (gridID < static_cast<int>(this->NumberOfGrids)));
682  assert( "pre: ghosted-extents vector has not been allocated" &&
683  (this->NumberOfGrids == this->GhostedExtents.size()/6 ) );
684 
685  for( int i=0; i < 6; ++i )
686  {
687  this->GhostedExtents[ gridID*6+i ] = ext[i];
688  }
689 }
690 
691 //------------------------------------------------------------------------------
693  const int gridID, int ext[6])
694 {
695  assert( "pre: gridID out-of-bounds!" &&
696  (gridID >= 0 && gridID < static_cast<int>(this->NumberOfGrids)));
697  for( int i=0; i < 6; ++i )
698  {
699  ext[i] = this->GridExtents[ gridID*6+i ];
700  }
701 }
702 
703 //------------------------------------------------------------------------------
705  const int gridID, int ext[6])
706 {
707  assert( "pre: gridID out-of-bounds!" &&
708  (gridID >= 0 && gridID < static_cast<int>(this->NumberOfGrids)));
709 
710  if( this->GhostedExtents.size() == 0 )
711  {
712  ext[0] = ext[2] = ext[4] = -1;
713  ext[1] = ext[3] = ext[5] = 0;
714  vtkErrorMacro( "No ghosted extents found for registered grid extends!!!" );
715  return;
716  }
717 
718  assert( "GhostedExtents are not aligned with registered grid extents" &&
719  ( this->GhostedExtents.size() == this->GridExtents.size() ) );
720  for( int i=0; i < 6; ++i )
721  {
722  ext[i] = this->GhostedExtents[ gridID*6+i ];
723  }
724 }
725 
726 //------------------------------------------------------------------------------
728  const int i, const int j, const int k, int ext[6] )
729 {
730  if( !this->IsNodeWithinExtent( i,j,k, ext) )
731  {
732  return false;
733  }
734 
735  bool status = false;
736  switch( this->DataDescription )
737  {
738  case VTK_X_LINE:
739  if( i==ext[0] || i==ext[1] )
740  {
741  status = true;
742  }
743  break;
744  case VTK_Y_LINE:
745  if( j==ext[2] || j==ext[3] )
746  {
747  status = true;
748  }
749  break;
750  case VTK_Z_LINE:
751  if( k==ext[4] || k==ext[5] )
752  {
753  status = true;
754  }
755  break;
756  case VTK_XY_PLANE:
757  if( (i==ext[0] || i==ext[1]) ||
758  (j==ext[2] || j==ext[3]) )
759  {
760  status = true;
761  }
762  break;
763  case VTK_YZ_PLANE:
764  if( (j==ext[2] || j==ext[3]) ||
765  (k==ext[4] || k==ext[5]) )
766  {
767  status = true;
768  }
769  break;
770  case VTK_XZ_PLANE:
771  if( (i==ext[0] || i==ext[1]) ||
772  (k==ext[4] || k==ext[5]) )
773  {
774  status = true;
775  }
776  break;
777  case VTK_XYZ_GRID:
778  if( (i==ext[0] || i==ext[1]) ||
779  (j==ext[2] || j==ext[3]) ||
780  (k==ext[4] || k==ext[5]) )
781  {
782  status = true;
783  }
784  break;
785  default:
786  std::cout << "Data description is: " << this->DataDescription << "\n";
787  std::cout.flush();
788  assert( "pre: Undefined data-description!" && false );
789  } // END switch
790 
791  return( status );
792 }
793 
794 //------------------------------------------------------------------------------
796  const int i, const int j, const int k,
797  int GridExtent[6] )
798 {
799  bool status = false;
800 
801  switch( this->DataDescription )
802  {
803  case VTK_X_LINE:
804  if( (GridExtent[0] < i) && (i < GridExtent[1]) )
805  {
806  status = true;
807  }
808  break;
809  case VTK_Y_LINE:
810  if( (GridExtent[2] < j) && (j < GridExtent[3] ) )
811  {
812  status = true;
813  }
814  break;
815  case VTK_Z_LINE:
816  if( (GridExtent[4] < k) && (k < GridExtent[5] ) )
817  {
818  status = true;
819  }
820  break;
821  case VTK_XY_PLANE:
822  if( (GridExtent[0] < i) && (i < GridExtent[1]) &&
823  (GridExtent[2] < j) && (j < GridExtent[3]) )
824  {
825  status = true;
826  }
827  break;
828  case VTK_YZ_PLANE:
829  if( (GridExtent[2] < j) && (j < GridExtent[3] ) &&
830  (GridExtent[4] < k) && (k < GridExtent[5] ) )
831  {
832  status = true;
833  }
834  break;
835  case VTK_XZ_PLANE:
836  if( (GridExtent[0] < i) && (i < GridExtent[1] ) &&
837  (GridExtent[4] < k) && (k < GridExtent[5] ) )
838  {
839  status = true;
840  }
841  break;
842  case VTK_XYZ_GRID:
843  if( (GridExtent[0] < i) && (i < GridExtent[1]) &&
844  (GridExtent[2] < j) && (j < GridExtent[3]) &&
845  (GridExtent[4] < k) && (k < GridExtent[5]) )
846  {
847  status = true;
848  }
849  break;
850  default:
851  std::cout << "Data description is: " << this->DataDescription << "\n";
852  std::cout.flush();
853  assert( "pre: Undefined data-description!" && false );
854  } // END switch
855 
856  return( status );
857 }
858 
859 //------------------------------------------------------------------------------
861  const int idx, int A[2], int B[2], int overlap[2], int orient[3] )
862 {
863  assert( "pre: idx is out-of-bounds" && (idx >= 0) && (idx < 3) );
864 
865  // A. Non-overlapping cases
866  if( overlap[0] == overlap[1] )
867  {
868  if( A[1] == B[0] )
869  {
870  orient[ idx ] = vtkStructuredNeighbor::HI;
871  }
872  else if( A[0] == B[1] )
873  {
874  orient[ idx ] = vtkStructuredNeighbor::LO;
875  }
876  else
877  {
878  orient[ idx ] = vtkStructuredNeighbor::UNDEFINED;
879  assert( "ERROR: Code should not reach here!" && false );
880  }
881  } // END non-overlapping cases
882  // B. Sub-set cases
883  else if( this->IsSubset( A, B) )
884  {
885  if( (A[0] == B[0]) && (A[1] == B[1]) )
886  {
887  orient[ idx ] = vtkStructuredNeighbor::ONE_TO_ONE;
888  }
889  else if( this->StrictlyInsideBounds( A[0], B[0], B[1] ) &&
890  this->StrictlyInsideBounds( A[1], B[0], B[1] ) )
891  {
892  orient[ idx ] = vtkStructuredNeighbor::SUBSET_BOTH;
893  }
894  else if( A[0] == B[0] )
895  {
896  orient[ idx ] = vtkStructuredNeighbor::SUBSET_HI;
897  }
898  else if( A[1] == B[1] )
899  {
900  orient[ idx ] = vtkStructuredNeighbor::SUBSET_LO;
901  }
902  else
903  {
904  orient[ idx ] = vtkStructuredNeighbor::UNDEFINED;
905  assert( "ERROR: Code should not reach here!" && false );
906  }
907  }
908  // C. Super-set cases
909  else if( this->IsSubset( B, A ) )
910  {
911  orient[ idx ] = vtkStructuredNeighbor::SUPERSET;
912  }
913  // D. Partially-overlapping (non-subset) cases
914  else if( !(this->IsSubset(A,B) || this->IsSubset(A,B)) )
915  {
916  if( this->InBounds( A[0], B[0], B[1] ) )
917  {
918  orient[ idx ] = vtkStructuredNeighbor::LO;
919  }
920  else if( this->InBounds( A[1], B[0], B[1] ) )
921  {
922  orient[ idx ] = vtkStructuredNeighbor::HI;
923  }
924  else
925  {
926  orient[ idx ] = vtkStructuredNeighbor::UNDEFINED;
927  assert( "ERROR: Code should not reach here!" && false );
928  }
929  }
930  else
931  {
932  orient[ idx ] = vtkStructuredNeighbor::UNDEFINED;
933  assert( "ERROR: Code should not reach here!" && false );
934  }
935 }
936 
937 //------------------------------------------------------------------------------
939  const int idx, const int ExtentLo, const int ExtentHi,
940  const int OnLo, const int OnHi, const int NotOnBoundary )
941 {
942  if( idx == ExtentLo )
943  {
944  return OnLo;
945  }
946  else if( idx == ExtentHi )
947  {
948  return OnHi;
949  }
950  return NotOnBoundary;
951 }
952 
953 //------------------------------------------------------------------------------
955  const int gridID, const int blockDirection )
956 {
957  // Sanity check
958  assert("pre: gridID is out-of-bounds" &&
959  (gridID >=0) && (gridID < static_cast<int>(this->NumberOfGrids)));
960  assert("pre: BlockTopology has not been properly allocated" &&
961  (this->NumberOfGrids == this->BlockTopology.size()));
962  assert("pre: blockDirection is out-of-bounds" &&
963  (blockDirection >= 0) && (blockDirection < 6) );
964  bool status = false;
965  if( this->BlockTopology[ gridID ] & (1 << blockDirection) )
966  {
967  status = true;
968  }
969  return( status );
970 }
971 
972 //------------------------------------------------------------------------------
974  const int gridID, const int blockDirection )
975 {
976  // Sanity check
977  assert("pre: gridID is out-of-bounds" &&
978  (gridID >=0) && (gridID < static_cast<int>(this->NumberOfGrids)));
979  assert("pre: BlockTopology has not been properly allocated" &&
980  (this->NumberOfGrids == this->BlockTopology.size()));
981  assert("pre: blockDirection is out-of-bounds" &&
982  (blockDirection >= 0) && (blockDirection < 6) );
983 
984  this->BlockTopology[ gridID ] &= ~(1 << blockDirection);
985 }
986 
987 //------------------------------------------------------------------------------
989  const int gridID, const int blockDirection )
990 {
991  // Sanity check
992  assert("pre: gridID is out-of-bounds" &&
993  (gridID >=0) && (gridID < static_cast<int>(this->NumberOfGrids)));
994  assert("pre: BlockTopology has not been properly allocated" &&
995  (this->NumberOfGrids == this->BlockTopology.size()));
996  assert("pre: blockDirection is out-of-bounds" &&
997  (blockDirection >= 0) && (blockDirection < 6) );
998  this->BlockTopology[ gridID ] |= (1 << blockDirection);
999 }
1000 
1001 //------------------------------------------------------------------------------
1003  const int gridID )
1004 {
1005  // Sanity check
1006  assert("pre: gridID is out-of-bounds" &&
1007  (gridID >=0) && (gridID < static_cast<int>(this->NumberOfGrids)));
1008  assert("pre: BlockTopology has not been properly allocated" &&
1009  (this->NumberOfGrids == this->BlockTopology.size()));
1010  for( int i=0; i < 6; ++i )
1011  {
1012  this->RemoveBlockConnection( gridID, i );
1013  } // END for all block directions
1014 }
1015 
1016 //------------------------------------------------------------------------------
1018  const int gridID )
1019 {
1020  // Sanity check
1021  assert("pre: gridID is out-of-bounds" &&
1022  (gridID >=0) && (gridID < static_cast<int>(this->NumberOfGrids)));
1023  assert("pre: BlockTopology has not been properly allocated" &&
1024  (this->NumberOfGrids == this->BlockTopology.size()));
1025 
1026  int count = 0;
1027  for( int i=0; i < 6; ++i )
1028  {
1029  if( this->HasBlockConnection( gridID, i ) )
1030  {
1031  ++count;
1032  }
1033  }
1034  assert( "post: count must be in [0,5]" && (count >=0 && count <= 6) );
1035  return( count );
1036 }
1037 
1038 //------------------------------------------------------------------------------
1040  const unsigned int N )
1041 {
1042  if (N == 0)
1043  {
1044  vtkErrorMacro("Number of grids cannot be 0.");
1045  return;
1046  }
1047 
1048  this->NumberOfGrids = N;
1050 
1051  this->GridExtents.resize( 6*N,-1);
1052  this->Neighbors.resize( N );
1053  this->BlockTopology.resize( N );
1054 }
1055 #endif /* vtkStructuredGridConnectivity_h */
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::map< std::pair< int, int >, int > NeighborPair2NeighborListIndex
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 ...
boost::graph_traits< vtkGraph *>::vertex_descriptor target(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
represent and manipulate point attribute data
Definition: vtkPointData.h:31
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.
represent and manipulate cell attribute data
Definition: vtkCellData.h:32
std::vector< unsigned char > BlockTopology
std::vector< std::vector< vtkStructuredNeighbor > > Neighbors
#define VTK_XZ_PLANE
bool InBounds(const int idx, const int Lo, const int Hi)
Returns true iff Lo <= idx <= Hi, otherwise false.
int vtkIdType
Definition: vtkType.h:345
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&#39;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...
a simple class to control print indentation
Definition: vtkIndent.h:33
list of point or cell ids
Definition: vtkIdList.h:30
#define VTK_XY_PLANE
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...
#define VTK_XYZ_GRID
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)
A helper method that computes the 1-D i-j-k orientation to facilitate the implementation of GetNodeBl...
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.
boost::graph_traits< vtkGraph *>::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
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.
#define VTK_YZ_PLANE
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...
#define VTK_X_LINE
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...
#define VTK_Z_LINE
represent and manipulate 3D points
Definition: vtkPoints.h:33
void ClearBlockConnections(const int gridID)
Clears all block connections for the block corresponding to the given grid ID.
represent and manipulate fields of data
Definition: vtkFieldData.h:53
#define VTK_Y_LINE