31 #ifndef vtkStructuredAMRGridConnectivity_h 32 #define vtkStructuredAMRGridConnectivity_h 34 #include "vtkFiltersGeometryModule.h" 62 const unsigned int NumberOfLevels,
63 const unsigned int N,
const int RefinementRatio=-1);
80 virtual void RegisterGrid(
81 const int gridIdx,
const int level,
const int refinementRatio,
94 virtual void RegisterGrid(
95 const int gridIdx,
const int level,
int extents[6],
108 vtkSetMacro(BalancedRefinement,
bool);
109 vtkGetMacro(BalancedRefinement,
bool);
118 vtkSetMacro(NodeCentered,
bool);
119 vtkGetMacro(NodeCentered,
bool);
127 vtkSetMacro(CellCentered,
bool);
128 vtkGetMacro(CellCentered,
bool);
135 int GetNumberOfNeighbors(
const int gridID);
140 void GetGhostedExtent(
const int gridID,
int ext[6]);
159 void CreateGhostedMaskArrays(
const int gridID);
164 void CreateGhostedExtent(
const int gridID,
const int N);
169 void SetGhostedExtent(
const int gridID,
int ext[6]);
174 void GetCoarsenedExtent(
175 const int gridIdx,
int fromLevel,
int toLevel,
int ext[6]);
180 void GetRefinedExtent(
181 const int gridIdx,
int fromLevel,
int toLevel,
int ext[6]);
187 int orient[3],
int ndim,
int fromLevel,
int toLevel,
int ext[6]);
193 void GetCellRefinedExtent(
194 int orient[3],
int ndim,
195 const int i,
const int j,
const int k,
196 const int fromLevel,
const int toLevel,
203 int orient[3],
int ndim,
int fromLevel,
int toLevel,
int ext[6]);
208 void GetGridExtent(
const int gridIdx,
int ext[6] );
213 int GetGridLevel(
const int gridIdx );
218 bool LevelExists(
const int level );
224 const int i,
const int j,
const int k,
int ext[6]);
229 bool IsNodeWithinExtent(
230 const int i,
const int j,
const int k,
int ext[6]);
235 bool IsNodeOnSharedBoundary(
236 const int i,
const int j,
const int k,
237 const int gridId,
int gridExt[6]);
242 bool IsNodeOnBoundaryOfExtent(
243 const int i,
const int j,
const int k,
int ext[6] );
248 void InsertGridAtLevel(
const int level,
const int gridID);
254 void ComputeNeighborSendAndRcvExtent(
const int gridID,
const int N);
260 void ComputeWholeExtent();
266 void GetWholeExtentAtLevel(
const int level,
int ext[6]);
272 void EstablishNeighbors(
const int i,
const int j);
277 void GetNodeOrientation(
278 const int i,
const int j,
const int k,
279 int gridExt[6],
int nodeOrientation[3]);
288 void GetOrientationVector(
289 const int dataDescription,
int orient[3],
int &ndim);
294 bool HasConstantRefinementRatio( );
299 void SetRefinementRatioAtLevel(
const int level,
const int r);
304 int GetRefinementRatioAtLevel(
const int level);
309 bool AreExtentsEqual(
int ext1[6],
int ext2[6] );
314 void SetBlockTopology(
const int gridID);
323 int GetNumberOfConnectingBlockFaces(
const int gridID );
343 assert(
"pre: gridID is out-of-bounds" &&
344 (gridID >=0) && (gridID < static_cast<int>(this->NumberOfGrids)));
345 assert(
"pre: BlockTopology has not been properly allocated" &&
346 (this->NumberOfGrids == this->BlockTopology.size()));
347 assert(
"pre: blockDirection is out-of-bounds" &&
348 (blockDirection >= 0) && (blockDirection < 6) );
350 if( this->BlockTopology[ gridID ] & (1 << blockDirection) )
372 void RemoveBlockConnection(
const int gridID,
const int blockDirection);
388 void AddBlockConnection(
const int gridID,
const int blockDirection);
394 void ClearBlockConnections(
const int gridID );
399 virtual void MarkNodeProperty(
400 const int gridId,
const int i,
const int j,
const int k,
401 int gridExt[6],
int wholeExt[6],
407 virtual void FillNodesGhostArray(
413 virtual void FillCellsGhostArray(
436 const int i,
const int iLevel,
int next1[6],
437 const int j,
const int jLevel,
int next2[6],
438 const int normalizedLevel,
447 void ComputeAMRNeighborOverlapExtents(
448 const int iLevel,
const int jLevel,
const int normalizedLevel,
450 int orient[3],
int ndim,
451 int gridOverlapExtent[6],
452 int neiOverlapExtent[6]);
457 int Get1DOrientation(
458 const int idx,
const int ExtentLo,
const int ExtentHi,
459 const int OnLo,
const int OnHi,
const int NotOnBoundary);
464 void PrintExtent(std::ostream& os,
int ext[6]);
469 void InitializeGhostData(
const int gridID );
474 void TransferRegisteredDataToGhostedData(
const int gridID );
479 void TransferLocalNodeCenteredNeighborData(
486 void GetLocalCellCentersFromCoarserLevel(
492 void GetLocalCellCentersFromFinerLevel(
499 void GetLocalCellCentersAtSameLevel(
505 void TransferLocalCellCenteredNeighborData(
511 void TransferLocalNeighborData(
517 virtual void TransferGhostDataFromNeighbors(
const int gridID);
523 void AverageFieldData(
563 std::vector< std::vector<vtkStructuredAMRNeighbor> >
Neighbors;
589 assert(
"pre: grid ID is out-of-bounds" &&
590 (gridID >= 0) && (gridID < static_cast<int>(this->
NumberOfGrids)));
591 assert(
"pre: neighbors vector has not been properly allocated" &&
599 const int gridID,
const int nei)
601 assert(
"pre: grid ID is out-of-bounds" &&
602 (gridID >= 0) && (gridID < static_cast<int>(this->
NumberOfGrids)));
603 assert(
"pre: neighbors vector has not been properly allocated" &&
605 assert(
"pre: nei index is out-of-bounds" &&
614 const int idx,
const int ExtentLo,
const int ExtentHi,
615 const int OnLo,
const int OnHi,
const int NotOnBoundary)
617 if( idx == ExtentLo )
621 else if( idx == ExtentHi )
625 return NotOnBoundary;
634 assert(
"pre: gridID is out-of-bounds" &&
635 (gridID >=0) && (gridID < static_cast<int>(this->
NumberOfGrids)));
636 assert(
"pre: BlockTopology has not been properly allocated" &&
640 for(
int i=0; i < 6; ++i )
647 assert(
"post: count must be in [0,5]" && (count >=0 && count <= 6) );
653 const int gridID,
const int blockDirection )
656 assert(
"pre: gridID is out-of-bounds" &&
657 (gridID >=0) && (gridID < static_cast<int>(this->
NumberOfGrids)));
658 assert(
"pre: BlockTopology has not been properly allocated" &&
660 assert(
"pre: blockDirection is out-of-bounds" &&
661 (blockDirection >= 0) && (blockDirection < 6) );
668 const int gridID,
const int blockDirection )
671 assert(
"pre: gridID is out-of-bounds" &&
672 (gridID >=0) && (gridID < static_cast<int>(this->
NumberOfGrids)));
673 assert(
"pre: BlockTopology has not been properly allocated" &&
675 assert(
"pre: blockDirection is out-of-bounds" &&
676 (blockDirection >= 0) && (blockDirection < 6) );
685 assert(
"pre: gridID is out-of-bounds" &&
686 (gridID >=0) && (gridID < static_cast<int>(this->
NumberOfGrids)));
687 assert(
"pre: BlockTopology has not been properly allocated" &&
689 for(
int i=0; i < 6; ++i )
698 int ext1[6],
int ext2[6])
700 for(
int i=0; i < 6; ++i )
702 if( ext1[i] != ext2[i] )
713 std::ostream& os,
int ext[6])
715 for(
int i=0; i < 6; i+=2 )
719 os << ext[i+1] <<
"] ";
727 assert(
"pre: grid Index is out-of-bounds!" &&
729 assert(
"pre: grid levels vector has not been allocated" &&
737 const int level,
const int r)
739 assert(
"pre: RefinementRatios vector is not propertly allocated" &&
741 assert(
"pre: leve is out-of-bounds!" &&
744 assert(
"pre: invalid refinement ratio" && (r >= 2) );
754 assert(
"pre: RefinementRatios vector is not propertly allocated" &&
756 assert(
"pre: leve is out-of-bounds!" &&
759 assert(
"pre: refinement ratio for level has not been set" &&
778 const int gridIdx,
int ext[6])
780 assert(
"pre: grid index is out-of-bounds" &&
782 (gridIdx < static_cast<int>(this->
GridExtents.size()) ) ) );
784 for(
int i=0; i < 6; ++i )
803 const int level,
const int gridID )
812 grids.insert( gridID );
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void RemoveBlockConnection(const int gridID, const int blockDirection)
Removes a block connection along the given direction for the block corresponding to the given gridID.
std::vector< unsigned char > BlockTopology
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...
bool LevelExists(const int level)
Checks if the given level has been registered.
boost::graph_traits< vtkGraph * >::vertex_descriptor target(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
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 ...
represent and manipulate point attribute data
int GetGridLevel(const int gridIdx)
Returns the level of the grid with the corresponding grid ID.
unsigned int NumberOfLevels
std::vector< int > GhostedExtents
void SetRefinementRatioAtLevel(const int level, const int r)
Sets the refinement ratio at the given level.
virtual void ComputeNeighbors()=0
Computes the grid neighboring topology for the domain.
std::vector< std::vector< vtkStructuredAMRNeighbor > > Neighbors
represent and manipulate cell attribute data
int GetRefinementRatioAtLevel(const int level)
Returns the refinement ratio at the given level.
int Get1DOrientation(const int idx, const int ExtentLo, const int ExtentHi, const int OnLo, const int OnHi, const int NotOnBoundary)
Get 1-D orientation.
std::vector< std::vector< int > > CellCenteredDonorLevel
a simple class to control print indentation
void GetGridExtent(const int gridIdx, int ext[6])
Gets the grid extent for the grid with the given grid ID.
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.
std::vector< int > RefinementRatios
dynamic, self-adjusting array of unsigned char
unsigned int NumberOfGrids
An internal, light-weight class used to store neighbor information.
int GetNumberOfNeighbors(const int gridID)
Returns the number of neighbors for the grid corresponding to the given grid ID.
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
void PrintExtent(std::ostream &os, int ext[6])
Prints the extent.
std::map< int, std::set< int > > AMRHierarchy
void ClearBlockConnections(const int gridID)
Clears all block connections for the block corresponding to the given grid ID.
An internal, light-weight object used to store neighbor information for AMR grids.
std::vector< int > GridLevels
vtkStructuredAMRNeighbor GetNeighbor(const int gridID, const int nei)
Returns the AMR neighbor for the patch with the corresponding grid ID.
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.
bool AreExtentsEqual(int ext1[6], int ext2[6])
Checks if the extent ext1 and ext2 are equal.
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.
bool HasConstantRefinementRatio()
Checks if a constant refinement ratio has been specified.
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 3D points
std::vector< int > GridExtents
represent and manipulate fields of data
void InsertGridAtLevel(const int level, const int gridID)
Inserts the grid corresponding to the given ID at the prescribed level.