|  | VTK
    9.0.1
    | 
 
 
 
Go to the documentation of this file.
   29 #ifndef vtkStructuredGridConnectivity_h 
   30 #define vtkStructuredGridConnectivity_h 
   32 #define VTK_NO_OVERLAP 0 
   33 #define VTK_NODE_OVERLAP 1 
   34 #define VTK_EDGE_OVERLAP 2 
   35 #define VTK_PARTIAL_OVERLAP 3 
   39 #include "vtkFiltersGeometryModule.h"  
   68   vtkSetVector6Macro(WholeExtent, 
int);
 
   69   vtkGetVector6Macro(WholeExtent, 
int);
 
   76   vtkGetMacro(DataDimension, 
int);
 
   88   virtual void RegisterGrid(
const int gridID, 
int extents[6], 
vtkUnsignedCharArray* nodesGhostArray,
 
   95   void GetGridExtent(
const int gridID, 
int extent[6]);
 
  101   void SetGhostedGridExtent(
const int gridID, 
int ext[6]);
 
  106   void GetGhostedGridExtent(
const int gridID, 
int ext[6]);
 
  119     return (
static_cast<int>(this->Neighbors[gridID].
size()));
 
  135   vtkIdList* GetNeighbors(
const int gridID, 
int* extents);
 
  157   bool InBounds(
const int idx, 
const int Lo, 
const int Hi) { 
return ((idx >= Lo) && (idx <= Hi)); }
 
  164     return ((idx > Lo) && (idx < Hi));
 
  172     return (this->InBounds(A[0], B[0], B[1]) && this->InBounds(A[1], B[0], B[1]));
 
  199         assert(
"ERROR: code should not reach here!" && 
false);
 
  208   void FillNodesGhostArray(
const int gridID, 
const int dataDescription, 
int GridExtent[6],
 
  214   void FillCellsGhostArray(
const int dataDescription, 
const int numNodesPerCell, 
int dims[3],
 
  222   void SearchNeighbors(
const int gridID, 
const int i, 
const int j, 
const int k, 
vtkIdList* neiList);
 
  228   void MarkNodeProperty(
const int gridID, 
const int i, 
const int j, 
const int k, 
int ext[6],
 
  229     int RealExtent[6], 
unsigned char& pfield);
 
  235   void MarkCellProperty(
unsigned char& pfield, 
unsigned char* nodeGhostFields, 
const int numNodes);
 
  240   void GetRealExtent(
const int gridID, 
int GridExtent[6], 
int RealExtent[6]);
 
  246   bool IsGhostNode(
int GridExtent[6], 
int RealExtent[6], 
const int i, 
const int j, 
const int k);
 
  252   bool IsNodeOnBoundaryOfExtent(
const int i, 
const int j, 
const int k, 
int ext[6]);
 
  259   bool IsNodeOnSharedBoundary(
 
  260     const int gridID, 
int RealExtent[6], 
const int i, 
const int j, 
const int k);
 
  266   bool IsNodeOnBoundary(
const int i, 
const int j, 
const int k);
 
  272   bool IsNodeInterior(
const int i, 
const int j, 
const int k, 
int GridExtent[6]);
 
  282     switch (this->DataDescription)
 
  285         if ((GridExtent[0] <= i) && (i <= GridExtent[1]))
 
  291         if ((GridExtent[2] <= j) && (j <= GridExtent[3]))
 
  297         if ((GridExtent[4] <= k) && (k <= GridExtent[5]))
 
  303         if ((GridExtent[0] <= i) && (i <= GridExtent[1]) && (GridExtent[2] <= j) &&
 
  304           (j <= GridExtent[3]))
 
  310         if ((GridExtent[2] <= j) && (j <= GridExtent[3]) && (GridExtent[4] <= k) &&
 
  311           (k <= GridExtent[5]))
 
  317         if ((GridExtent[0] <= i) && (i <= GridExtent[1]) && (GridExtent[4] <= k) &&
 
  318           (k <= GridExtent[5]))
 
  324         if ((GridExtent[0] <= i) && (i <= GridExtent[1]) && (GridExtent[2] <= j) &&
 
  325           (j <= GridExtent[3]) && (GridExtent[4] <= k) && (k <= GridExtent[5]))
 
  331         std::cout << 
"Data description is: " << this->DataDescription << 
"\n";
 
  333         assert(
"pre: Undefined data-description!" && 
false);
 
  343     const int i, 
const int j, 
int i2jOrientation[3], 
int j2iOrientation[3], 
int overlapExtent[6]);
 
  353   void DetermineNeighborOrientation(
 
  354     const int idx, 
int A[2], 
int B[2], 
int overlap[2], 
int orient[3]);
 
  361   void DetectNeighbors(
 
  362     const int i, 
const int j, 
int ex1[6], 
int ex2[6], 
int orientation[3], 
int ndim);
 
  373   int IntervalOverlap(
int A[2], 
int B[2], 
int overlap[2]);
 
  384   int DoPartialOverlap(
int s[2], 
int S[2], 
int overlap[2]);
 
  395   int PartialOverlap(
int A[2], 
const int CofA, 
int B[2], 
const int CofB, 
int overlap[2]);
 
  401   void EstablishNeighbors(
const int i, 
const int j);
 
  407   void AcquireDataDescription();
 
  423   bool HasBlockConnection(
const int gridID, 
const int blockDirection);
 
  439   void RemoveBlockConnection(
const int gridID, 
const int blockDirection);
 
  455   void AddBlockConnection(
const int gridID, 
const int blockDirection);
 
  461   void ClearBlockConnections(
const int gridID);
 
  470   int GetNumberOfConnectingBlockFaces(
const int gridID);
 
  475   void SetBlockTopology(
const int gridID);
 
  483   void GetIJKBlockOrientation(
 
  484     const int i, 
const int j, 
const int k, 
int ext[6], 
int orientation[3]);
 
  490   int Get1DOrientation(
const int idx, 
const int ExtentLo, 
const int ExtentHi, 
const int OnLo,
 
  491     const int OnHi, 
const int NotOnBoundary);
 
  497   void CreateGhostedExtent(
const int gridID, 
const int N);
 
  504   void GetGhostedExtent(
 
  505     int* ghostedExtent, 
int GridExtent[6], 
const int minIdx, 
const int maxIdx, 
const int N);
 
  511   void CreateGhostedMaskArrays(
const int gridID);
 
  519   void InitializeGhostData(
const int gridID);
 
  539   void TransferRegisteredDataToGhostedData(
const int gridID);
 
  545   void ComputeNeighborSendAndRcvExtent(
const int gridID, 
const int N);
 
  552   virtual void TransferGhostDataFromNeighbors(
const int gridID);
 
  562   void CopyCoordinates(
 
  579   int GetNeighborIndex(
const int gridIdx, 
const int NeighborGridIdx);
 
  584   void PrintExtent(
int extent[6]);
 
  593   std::vector<std::vector<vtkStructuredNeighbor> > 
Neighbors;
 
  607   const int gridIdx, 
const int NeighborGridIdx)
 
  609   assert(
"pre: Grid index is out-of-bounds!" && (gridIdx >= 0) &&
 
  611   assert(
"pre: Neighbor grid index is out-of-bounds!" && (NeighborGridIdx >= 0) &&
 
  614   std::pair<int, int> gridPair = std::make_pair(gridIdx, NeighborGridIdx);
 
  615   assert(
"pre: Neighboring grid pair does not exist in hash!" &&
 
  617       this->NeighborPair2NeighborListIndex.end()));
 
  624   int* ghostedExtent, 
int GridExtent[6], 
const int minIdx, 
const int maxIdx, 
const int N)
 
  626   assert(
"pre: Number of ghost layers must be N >= 1" && (N >= 1));
 
  627   assert(
"pre: ghosted extent pointer is nullptr" && ghostedExtent != 
nullptr);
 
  629   ghostedExtent[minIdx] = GridExtent[minIdx] - N;
 
  630   ghostedExtent[maxIdx] = GridExtent[maxIdx] + N;
 
  633   ghostedExtent[minIdx] = (ghostedExtent[minIdx] < this->
WholeExtent[minIdx])
 
  635     : ghostedExtent[minIdx];
 
  636   ghostedExtent[maxIdx] = (ghostedExtent[maxIdx] > this->
WholeExtent[maxIdx])
 
  638     : ghostedExtent[maxIdx];
 
  644   assert(
"pre: gridID is out-of-bounds" && (gridID >= 0) &&
 
  646   assert(
"pre: ghosted-extents vector has not been allocated" &&
 
  649   for (
int i = 0; i < 6; ++i)
 
  658   assert(
"pre: gridID out-of-bounds!" &&
 
  659     (gridID >= 0 && gridID < 
static_cast<int>(this->
NumberOfGrids)));
 
  660   for (
int i = 0; i < 6; ++i)
 
  669   assert(
"pre: gridID out-of-bounds!" &&
 
  670     (gridID >= 0 && gridID < 
static_cast<int>(this->
NumberOfGrids)));
 
  674     ext[0] = ext[2] = ext[4] = -1;
 
  675     ext[1] = ext[3] = ext[5] = 0;
 
  676     vtkErrorMacro(
"No ghosted extents found for registered grid extends!!!");
 
  680   assert(
"GhostedExtents are not aligned with registered grid extents" &&
 
  682   for (
int i = 0; i < 6; ++i)
 
  690   const int i, 
const int j, 
const int k, 
int ext[6])
 
  701       if (i == ext[0] || i == ext[1])
 
  707       if (j == ext[2] || j == ext[3])
 
  713       if (k == ext[4] || k == ext[5])
 
  719       if ((i == ext[0] || i == ext[1]) || (j == ext[2] || j == ext[3]))
 
  725       if ((j == ext[2] || j == ext[3]) || (k == ext[4] || k == ext[5]))
 
  731       if ((i == ext[0] || i == ext[1]) || (k == ext[4] || k == ext[5]))
 
  737       if ((i == ext[0] || i == ext[1]) || (j == ext[2] || j == ext[3]) ||
 
  738         (k == ext[4] || k == ext[5]))
 
  746       assert(
"pre: Undefined data-description!" && 
false);
 
  754   const int i, 
const int j, 
const int k, 
int GridExtent[6])
 
  761       if ((GridExtent[0] < i) && (i < GridExtent[1]))
 
  767       if ((GridExtent[2] < j) && (j < GridExtent[3]))
 
  773       if ((GridExtent[4] < k) && (k < GridExtent[5]))
 
  779       if ((GridExtent[0] < i) && (i < GridExtent[1]) && (GridExtent[2] < j) && (j < GridExtent[3]))
 
  785       if ((GridExtent[2] < j) && (j < GridExtent[3]) && (GridExtent[4] < k) && (k < GridExtent[5]))
 
  791       if ((GridExtent[0] < i) && (i < GridExtent[1]) && (GridExtent[4] < k) && (k < GridExtent[5]))
 
  797       if ((GridExtent[0] < i) && (i < GridExtent[1]) && (GridExtent[2] < j) &&
 
  798         (j < GridExtent[3]) && (GridExtent[4] < k) && (k < GridExtent[5]))
 
  806       assert(
"pre: Undefined data-description!" && 
false);
 
  814   const int idx, 
int A[2], 
int B[2], 
int overlap[2], 
int orient[3])
 
  816   assert(
"pre: idx is out-of-bounds" && (idx >= 0) && (idx < 3));
 
  819   if (overlap[0] == overlap[1])
 
  825     else if (A[0] == B[1])
 
  832       assert(
"ERROR: Code should not reach here!" && 
false);
 
  838     if ((A[0] == B[0]) && (A[1] == B[1]))
 
  847     else if (A[0] == B[0])
 
  851     else if (A[1] == B[1])
 
  858       assert(
"ERROR: Code should not reach here!" && 
false);
 
  869     if (this->
InBounds(A[0], B[0], B[1]))
 
  873     else if (this->
InBounds(A[1], B[0], B[1]))
 
  880       assert(
"ERROR: Code should not reach here!" && 
false);
 
  886     assert(
"ERROR: Code should not reach here!" && 
false);
 
  892   const int ExtentHi, 
const int OnLo, 
const int OnHi, 
const int NotOnBoundary)
 
  898   else if (idx == ExtentHi)
 
  902   return NotOnBoundary;
 
  907   const int gridID, 
const int blockDirection)
 
  910   assert(
"pre: gridID is out-of-bounds" && (gridID >= 0) &&
 
  912   assert(
"pre: BlockTopology has not been properly allocated" &&
 
  914   assert(
"pre: blockDirection is out-of-bounds" && (blockDirection >= 0) && (blockDirection < 6));
 
  925   const int gridID, 
const int blockDirection)
 
  928   assert(
"pre: gridID is out-of-bounds" && (gridID >= 0) &&
 
  930   assert(
"pre: BlockTopology has not been properly allocated" &&
 
  932   assert(
"pre: blockDirection is out-of-bounds" && (blockDirection >= 0) && (blockDirection < 6));
 
  939   const int gridID, 
const int blockDirection)
 
  942   assert(
"pre: gridID is out-of-bounds" && (gridID >= 0) &&
 
  944   assert(
"pre: BlockTopology has not been properly allocated" &&
 
  946   assert(
"pre: blockDirection is out-of-bounds" && (blockDirection >= 0) && (blockDirection < 6));
 
  954   assert(
"pre: gridID is out-of-bounds" && (gridID >= 0) &&
 
  956   assert(
"pre: BlockTopology has not been properly allocated" &&
 
  958   for (
int i = 0; i < 6; ++i)
 
  968   assert(
"pre: gridID is out-of-bounds" && (gridID >= 0) &&
 
  970   assert(
"pre: BlockTopology has not been properly allocated" &&
 
  974   for (
int i = 0; i < 6; ++i)
 
  981   assert(
"post: count must be in [0,5]" && (count >= 0 && count <= 6));
 
  990     vtkErrorMacro(
"Number of grids cannot be 0.");
 
  
represent and manipulate 3D points
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.
represent and manipulate point attribute data
void SetNumberOfGrids(const unsigned int N) override
Set/Get the total number of domains distributed among processors.
void ClearBlockConnections(const int gridID)
Clears all block connections for the block corresponding to the given grid ID.
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on.
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 ...
dynamic, self-adjusting array of unsigned char
std::vector< int > GhostedExtents
virtual void FillGhostArrays(const int gridId, vtkUnsignedCharArray *nodesArray, vtkUnsignedCharArray *cellsArray)=0
Fills the ghost arrays for the given grid.
int GetNumberOfNodesPerCell(const int dim)
Returns the number of nodes per cell according to the given dimension.
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.
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 AddBlockConnection(const int gridID, const int blockDirection)
Adds a block connection along the given direction for the block corresponding to the given gridID.
represent and manipulate fields of data
virtual void SetNumberOfGrids(const unsigned int N)=0
Sets the total number of grids in the domain.
boost::graph_traits< vtkGraph * >::vertex_descriptor target(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
std::vector< int > GridExtents
void AllocateUserRegisterDataStructures()
Allocate/De-allocate the data-structures where the user-supplied grids will be registered.
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,...
int GetNumberOfNeighbors(const int gridID)
Returns the number of neighbors for the grid corresponding to the given grid ID.
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
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...
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.
a simple class to control print indentation
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.
list of point or cell ids
std::vector< unsigned char > BlockTopology
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 PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
std::vector< std::vector< vtkStructuredNeighbor > > Neighbors
virtual void ComputeNeighbors()=0
Computes the grid neighboring topology for the domain.
bool StrictlyInsideBounds(const int idx, const int Lo, const int Hi)
Returns true iff Lo < idx < Hi, otherwise false.
int Cardinality(int S[2])
Returns the cardinality of a range S.
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
bool IsSubset(int A[2], int B[2])
Returns true iff A is a subset of B, otherwise false.
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 GetGhostedGridExtent(const int gridID, int ext[6])
Returns the ghosted grid extent for the block corresponding the.