33 #ifndef VTKSTRUCTUREDAMRGRIDCONNECTIVITY_H_ 34 #define VTKSTRUCTUREDAMRGRIDCONNECTIVITY_H_ 63 const unsigned int NumberOfLevels,
64 const unsigned int N,
const int RefinementRatio=-1);
77 virtual void RegisterGrid(
78 const int gridIdx,
const int level,
const int refinementRatio,
91 virtual void RegisterGrid(
92 const int gridIdx,
const int level,
int extents[6],
126 int GetNumberOfNeighbors(
const int gridID);
130 void GetGhostedExtent(
const int gridID,
int ext[6]);
144 void CreateGhostedMaskArrays(
const int gridID);
147 void CreateGhostedExtent(
const int gridID,
const int N);
151 void SetGhostedExtent(
const int gridID,
int ext[6]);
155 void GetCoarsenedExtent(
156 const int gridIdx,
int fromLevel,
int toLevel,
int ext[6]);
161 void GetRefinedExtent(
162 const int gridIdx,
int fromLevel,
int toLevel,
int ext[6]);
168 int orient[3],
int ndim,
int fromLevel,
int toLevel,
int ext[6]);
174 void GetCellRefinedExtent(
175 int orient[3],
int ndim,
176 const int i,
const int j,
const int k,
177 const int fromLevel,
const int toLevel,
184 int orient[3],
int ndim,
int fromLevel,
int toLevel,
int ext[6]);
188 void GetGridExtent(
const int gridIdx,
int ext[6] );
191 int GetGridLevel(
const int gridIdx );
194 bool LevelExists(
const int level );
199 const int i,
const int j,
const int k,
int ext[6]);
204 bool IsNodeWithinExtent(
205 const int i,
const int j,
const int k,
int ext[6]);
210 bool IsNodeOnSharedBoundary(
211 const int i,
const int j,
const int k,
212 const int gridId,
int gridExt[6]);
217 bool IsNodeOnBoundaryOfExtent(
218 const int i,
const int j,
const int k,
int ext[6] );
223 void InsertGridAtLevel(
const int level,
const int gridID);
227 void ComputeNeighborSendAndRcvExtent(
const int gridID,
const int N);
231 void ComputeWholeExtent();
235 void GetWholeExtentAtLevel(
const int level,
int ext[6]);
239 void EstablishNeighbors(
const int i,
const int j);
243 void GetNodeOrientation(
244 const int i,
const int j,
const int k,
245 int gridExt[6],
int nodeOrientation[3]);
255 void GetOrientationVector(
256 const int dataDescription,
int orient[3],
int &ndim);
260 bool HasConstantRefinementRatio( );
263 void SetRefinementRatioAtLevel(
const int level,
const int r);
266 int GetRefinementRatioAtLevel(
const int level);
269 bool AreExtentsEqual(
int ext1[6],
int ext2[6] );
272 void SetBlockTopology(
const int gridID);
279 int GetNumberOfConnectingBlockFaces(
const int gridID );
292 assert(
"pre: gridID is out-of-bounds" &&
293 (gridID >=0) && (gridID < static_cast<int>(this->NumberOfGrids)));
294 assert(
"pre: BlockTopology has not been properly allocated" &&
295 (this->NumberOfGrids == this->BlockTopology.size()));
296 assert(
"pre: blockDirection is out-of-bounds" &&
297 (blockDirection >= 0) && (blockDirection < 6) );
299 if( this->BlockTopology[ gridID ] & (1 << blockDirection) )
314 void RemoveBlockConnection(
const int gridID,
const int blockDirection);
323 void AddBlockConnection(
const int gridID,
const int blockDirection);
327 void ClearBlockConnections(
const int gridID );
331 virtual void MarkNodeProperty(
332 const int gridId,
const int i,
const int j,
const int k,
333 int gridExt[6],
int wholeExt[6],
339 virtual void FillNodesGhostArray(
345 virtual void FillCellsGhostArray(
365 const int i,
const int iLevel,
int next1[6],
366 const int j,
const int jLevel,
int next2[6],
367 const int normalizedLevel,
377 void ComputeAMRNeighborOverlapExtents(
378 const int iLevel,
const int jLevel,
const int normalizedLevel,
380 int orient[3],
int ndim,
381 int gridOverlapExtent[6],
382 int neiOverlapExtent[6]);
387 int Get1DOrientation(
388 const int idx,
const int ExtentLo,
const int ExtentHi,
389 const int OnLo,
const int OnHi,
const int NotOnBoundary);
393 void PrintExtent(std::ostream& os,
int ext[6]);
396 void InitializeGhostData(
const int gridID );
400 void TransferRegisteredDataToGhostedData(
const int gridID );
404 void TransferLocalNodeCenteredNeighborData(
411 void GetLocalCellCentersFromCoarserLevel(
417 void GetLocalCellCentersFromFinerLevel(
424 void GetLocalCellCentersAtSameLevel(
430 void TransferLocalCellCenteredNeighborData(
436 void TransferLocalNeighborData(
441 virtual void TransferGhostDataFromNeighbors(
const int gridID);
446 void AverageFieldData(
489 std::vector< std::vector<vtkStructuredAMRNeighbor> >
Neighbors;
516 assert(
"pre: grid ID is out-of-bounds" &&
517 (gridID >= 0) && (gridID < static_cast<int>(this->NumberOfGrids)));
518 assert(
"pre: neighbors vector has not been properly allocated" &&
520 return( static_cast<int>(this->Neighbors[gridID].
size()) );
526 const int gridID,
const int nei)
528 assert(
"pre: grid ID is out-of-bounds" &&
529 (gridID >= 0) && (gridID < static_cast<int>(this->NumberOfGrids)));
530 assert(
"pre: neighbors vector has not been properly allocated" &&
532 assert(
"pre: nei index is out-of-bounds" &&
534 (nei < static_cast<int>(this->Neighbors[gridID].
size())));
535 return( this->Neighbors[gridID][nei] );
541 const int idx,
const int ExtentLo,
const int ExtentHi,
542 const int OnLo,
const int OnHi,
const int NotOnBoundary)
544 if( idx == ExtentLo )
548 else if( idx == ExtentHi )
552 return NotOnBoundary;
561 assert(
"pre: gridID is out-of-bounds" &&
562 (gridID >=0) && (gridID < static_cast<int>(this->NumberOfGrids)));
563 assert(
"pre: BlockTopology has not been properly allocated" &&
564 (this->NumberOfGrids == this->BlockTopology.size()));
567 for(
int i=0; i < 6; ++i )
569 if( this->HasBlockConnection( gridID, i ) )
574 assert(
"post: count must be in [0,5]" && (count >=0 && count <= 6) );
580 const int gridID,
const int blockDirection )
583 assert(
"pre: gridID is out-of-bounds" &&
584 (gridID >=0) && (gridID < static_cast<int>(this->NumberOfGrids)));
585 assert(
"pre: BlockTopology has not been properly allocated" &&
586 (this->NumberOfGrids == this->BlockTopology.size()));
587 assert(
"pre: blockDirection is out-of-bounds" &&
588 (blockDirection >= 0) && (blockDirection < 6) );
590 this->BlockTopology[ gridID ] &= ~(1 << blockDirection);
595 const int gridID,
const int blockDirection )
598 assert(
"pre: gridID is out-of-bounds" &&
599 (gridID >=0) && (gridID < static_cast<int>(this->NumberOfGrids)));
600 assert(
"pre: BlockTopology has not been properly allocated" &&
601 (this->NumberOfGrids == this->BlockTopology.size()));
602 assert(
"pre: blockDirection is out-of-bounds" &&
603 (blockDirection >= 0) && (blockDirection < 6) );
604 this->BlockTopology[ gridID ] |= (1 << blockDirection);
612 assert(
"pre: gridID is out-of-bounds" &&
613 (gridID >=0) && (gridID < static_cast<int>(this->NumberOfGrids)));
614 assert(
"pre: BlockTopology has not been properly allocated" &&
615 (this->NumberOfGrids == this->BlockTopology.size()));
616 for(
int i=0; i < 6; ++i )
618 this->RemoveBlockConnection( gridID, i );
625 int ext1[6],
int ext2[6])
627 for(
int i=0; i < 6; ++i )
629 if( ext1[i] != ext2[i] )
640 std::ostream& os,
int ext[6])
642 for(
int i=0; i < 6; i+=2 )
646 os << ext[i+1] <<
"] ";
654 assert(
"pre: grid Index is out-of-bounds!" &&
655 (gridIdx < static_cast<int>(this->NumberOfGrids)));
656 assert(
"pre: grid levels vector has not been allocated" &&
658 return( this->GridLevels[gridIdx] );
664 const int level,
const int r)
666 assert(
"pre: RefinementRatios vector is not propertly allocated" &&
667 this->RefinementRatios.size()==this->NumberOfLevels);
668 assert(
"pre: leve is out-of-bounds!" &&
670 (level < static_cast<int>(this->RefinementRatios.size())) );
671 assert(
"pre: invalid refinement ratio" && (r >= 2) );
673 this->RefinementRatios[
level ] =
r;
681 assert(
"pre: RefinementRatios vector is not propertly allocated" &&
682 this->RefinementRatios.size()==this->NumberOfLevels);
683 assert(
"pre: leve is out-of-bounds!" &&
685 (level < static_cast<int>(this->RefinementRatios.size())));
686 assert(
"pre: refinement ratio for level has not been set" &&
687 (this->RefinementRatios[ level ] >= 2) );
689 return(this->RefinementRatios[level]);
696 if( this->RefinementRatio < 2 )
705 const int gridIdx,
int ext[6])
707 assert(
"pre: grid index is out-of-bounds" &&
709 (gridIdx < static_cast<int>(this->GridExtents.size()) ) ) );
711 for(
int i=0; i < 6; ++i )
713 ext[ i ] = this->GridExtents[ gridIdx*6+i ];
721 if( this->AMRHierarchy.find(level) != this->AMRHierarchy.end() )
730 const int level,
const int gridID )
732 if( this->LevelExists( level ) )
734 this->AMRHierarchy[
level ].insert( gridID );
739 grids.insert( gridID );
740 this->AMRHierarchy[
level ] = grids;
void RemoveBlockConnection(const int gridID, const int blockDirection)
std::vector< unsigned char > BlockTopology
int GetNumberOfConnectingBlockFaces(const int gridID)
bool LevelExists(const int level)
boost::graph_traits< vtkGraph *>::vertex_descriptor target(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
bool HasBlockConnection(const int gridID, const int blockDirection)
represent and manipulate point attribute data
int GetGridLevel(const int gridIdx)
unsigned int NumberOfLevels
std::vector< int > GhostedExtents
void SetRefinementRatioAtLevel(const int level, const int r)
virtual void ComputeNeighbors()=0
#define vtkGetMacro(name, type)
std::vector< std::vector< vtkStructuredAMRNeighbor > > Neighbors
represent and manipulate cell attribute data
int GetRefinementRatioAtLevel(const int level)
GLuint GLuint GLsizei count
GLdouble GLdouble GLdouble r
#define vtkTypeMacro(thisClass, superclass)
int Get1DOrientation(const int idx, const int ExtentLo, const int ExtentHi, const int OnLo, const int OnHi, const int NotOnBoundary)
std::vector< std::vector< int > > CellCenteredDonorLevel
a simple class to control print indentation
void GetGridExtent(const int gridIdx, int ext[6])
virtual void SetNumberOfGrids(const unsigned int N)=0
void PrintSelf(ostream &os, vtkIndent indent)
std::vector< int > RefinementRatios
dynamic, self-adjusting array of unsigned char
unsigned int NumberOfGrids
int GetNumberOfNeighbors(const int gridID)
boost::graph_traits< vtkGraph *>::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
void PrintExtent(std::ostream &os, int ext[6])
std::map< int, std::set< int > > AMRHierarchy
void ClearBlockConnections(const int gridID)
std::vector< int > GridLevels
vtkStructuredAMRNeighbor GetNeighbor(const int gridID, const int nei)
virtual void FillGhostArrays(const int gridId, vtkUnsignedCharArray *nodesArray, vtkUnsignedCharArray *cellsArray)=0
#define VTKFILTERSGEOMETRY_EXPORT
bool AreExtentsEqual(int ext1[6], int ext2[6])
virtual void CreateGhostLayers(const int N=1)=0
bool HasConstantRefinementRatio()
void AddBlockConnection(const int gridID, const int blockDirection)
represent and manipulate 3D points
std::vector< int > GridExtents
represent and manipulate fields of data
void InsertGridAtLevel(const int level, const int gridID)
#define vtkSetMacro(name, type)