33 #ifndef VTKSTRUCTUREDAMRGRIDCONNECTIVITY_H_
34 #define VTKSTRUCTUREDAMRGRIDCONNECTIVITY_H_
36 #include "vtkFiltersGeometryModule.h"
54 void PrintSelf(ostream& os, vtkIndent indent );
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,
80 vtkUnsignedCharArray* nodesGhostArray,
81 vtkUnsignedCharArray* cellGhostArray,
82 vtkPointData* pointData,
83 vtkCellData* cellData,
84 vtkPoints* gridNodes);
91 virtual void RegisterGrid(
92 const int gridIdx,
const int level,
int extents[6],
93 vtkUnsignedCharArray* nodesGhostArray,
94 vtkUnsignedCharArray* cellGhostArray,
95 vtkPointData* pointData,
96 vtkCellData* cellData,
97 vtkPoints* gridNodes);
105 vtkSetMacro(BalancedRefinement,
bool);
106 vtkGetMacro(BalancedRefinement,
bool);
113 vtkSetMacro(NodeCentered,
bool);
114 vtkGetMacro(NodeCentered,
bool);
120 vtkSetMacro(CellCentered,
bool);
121 vtkGetMacro(CellCentered,
bool);
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(
340 const int gridId, vtkUnsignedCharArray* nodesArray);
345 virtual void FillCellsGhostArray(
346 const int gridId, vtkUnsignedCharArray* cellArray);
353 vtkUnsignedCharArray* nodesArray,
354 vtkUnsignedCharArray* cellsArray );
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(
447 vtkFieldData *
source, vtkIdType *sourceIds,
const int N,
448 vtkFieldData *
target, vtkIdType targetIdx);
458 vtkFieldData *
source, vtkIdType sourceIdx,
459 vtkFieldData *
target, vtkIdType targetIdx);
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())));
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" &&
567 for(
int i=0; i < 6; ++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" &&
587 assert(
"pre: blockDirection is out-of-bounds" &&
588 (blockDirection >= 0) && (blockDirection < 6) );
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" &&
602 assert(
"pre: blockDirection is out-of-bounds" &&
603 (blockDirection >= 0) && (blockDirection < 6) );
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" &&
616 for(
int i=0; i < 6; ++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!" &&
656 assert(
"pre: grid levels vector has not been allocated" &&
664 const int level,
const int r)
666 assert(
"pre: RefinementRatios vector is not propertly allocated" &&
668 assert(
"pre: leve is out-of-bounds!" &&
671 assert(
"pre: invalid refinement ratio" && (r >= 2) );
681 assert(
"pre: RefinementRatios vector is not propertly allocated" &&
683 assert(
"pre: leve is out-of-bounds!" &&
686 assert(
"pre: refinement ratio for level has not been set" &&
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 )
730 const int level,
const int gridID )
739 grids.insert( gridID );
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)
int GetGridLevel(const int gridIdx)
unsigned int NumberOfLevels
std::vector< int > GhostedExtents
void SetRefinementRatioAtLevel(const int level, const int r)
virtual void ComputeNeighbors()=0
std::vector< std::vector< vtkStructuredAMRNeighbor > > Neighbors
int GetRefinementRatioAtLevel(const int level)
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
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
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
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)
std::vector< int > GridExtents
void InsertGridAtLevel(const int level, const int gridID)