34#ifndef vtkStructuredAMRGridConnectivity_h
35#define vtkStructuredAMRGridConnectivity_h
37#include "vtkFiltersGeometryModule.h"
65 const unsigned int NumberOfLevels,
66 const unsigned int N,
const int RefinementRatio=-1);
76 void CreateGhostLayers(const
int N=1) VTK_OVERRIDE;
83 virtual
void RegisterGrid(
84 const
int gridIdx, const
int level, const
int refinementRatio,
97 virtual
void RegisterGrid(
98 const
int gridIdx, const
int level,
int extents[6],
112 vtkGetMacro(BalancedRefinement,
bool);
122 vtkGetMacro(NodeCentered,
bool);
131 vtkGetMacro(CellCentered,
bool);
138 int GetNumberOfNeighbors(const
int gridID);
143 void GetGhostedExtent(const
int gridID,
int ext[6]);
157 void SetNumberOfGrids( const
unsigned int N ) VTK_OVERRIDE;
162 void CreateGhostedMaskArrays(const
int gridID);
167 void CreateGhostedExtent(const
int gridID, const
int N);
172 void SetGhostedExtent(const
int gridID,
int ext[6]);
177 void GetCoarsenedExtent(
178 const
int gridIdx,
int fromLevel,
int toLevel,
int ext[6]);
183 void GetRefinedExtent(
184 const
int gridIdx,
int fromLevel,
int toLevel,
int ext[6]);
190 int orient[3],
int ndim,
int fromLevel,
int toLevel,
int ext[6]);
196 void GetCellRefinedExtent(
197 int orient[3],
int ndim,
198 const
int i, const
int j, const
int k,
199 const
int fromLevel, const
int toLevel,
206 int orient[3],
int ndim,
int fromLevel,
int toLevel,
int ext[6]);
211 void GetGridExtent( const
int gridIdx,
int ext[6] );
216 int GetGridLevel( const
int gridIdx );
221 bool LevelExists( const
int level );
227 const
int i, const
int j, const
int k,
int ext[6]);
232 bool IsNodeWithinExtent(
233 const
int i, const
int j, const
int k,
int ext[6]);
238 bool IsNodeOnSharedBoundary(
239 const
int i, const
int j, const
int k,
240 const
int gridId,
int gridExt[6]);
245 bool IsNodeOnBoundaryOfExtent(
246 const
int i, const
int j, const
int k,
int ext[6] );
251 void InsertGridAtLevel( const
int level, const
int gridID);
257 void ComputeNeighborSendAndRcvExtent(const
int gridID, const
int N);
263 void ComputeWholeExtent();
269 void GetWholeExtentAtLevel(const
int level,
int ext[6]);
275 void EstablishNeighbors(const
int i, const
int j);
280 void GetNodeOrientation(
281 const
int i, const
int j, const
int k,
282 int gridExt[6],
int nodeOrientation[3]);
291 void GetOrientationVector(
292 const
int dataDescription,
int orient[3],
int &ndim);
297 bool HasConstantRefinementRatio( );
302 void SetRefinementRatioAtLevel( const
int level, const
int r);
307 int GetRefinementRatioAtLevel(const
int level);
312 bool AreExtentsEqual(
int ext1[6],
int ext2[6] );
317 void SetBlockTopology(const
int gridID);
326 int GetNumberOfConnectingBlockFaces( const
int gridID );
343 bool HasBlockConnection(const
int gridID, const
int blockDirection)
346 assert(
"pre: gridID is out-of-bounds" &&
347 (gridID >=0) && (gridID <
static_cast<int>(this->NumberOfGrids)));
348 assert(
"pre: BlockTopology has not been properly allocated" &&
349 (this->NumberOfGrids == this->BlockTopology.size()));
350 assert(
"pre: blockDirection is out-of-bounds" &&
351 (blockDirection >= 0) && (blockDirection < 6) );
353 if( this->BlockTopology[ gridID ] & (1 << blockDirection) )
375 void RemoveBlockConnection(
const int gridID,
const int blockDirection);
391 void AddBlockConnection(
const int gridID,
const int blockDirection);
397 void ClearBlockConnections(
const int gridID );
403 const int gridId,
const int i,
const int j,
const int k,
404 int gridExt[6],
int wholeExt[6],
439 const int i,
const int iLevel,
int next1[6],
440 const int j,
const int jLevel,
int next2[6],
441 const int normalizedLevel,
451 const int iLevel,
const int jLevel,
const int normalizedLevel,
453 int orient[3],
int ndim,
454 int gridOverlapExtent[6],
455 int neiOverlapExtent[6]);
460 int Get1DOrientation(
461 const int idx,
const int ExtentLo,
const int ExtentHi,
462 const int OnLo,
const int OnHi,
const int NotOnBoundary);
467 void PrintExtent(std::ostream& os,
int ext[6]);
566 std::vector< std::vector<vtkStructuredAMRNeighbor> >
Neighbors;
592 assert(
"pre: grid ID is out-of-bounds" &&
593 (gridID >= 0) && (gridID <
static_cast<int>(this->
NumberOfGrids)));
594 assert(
"pre: neighbors vector has not been properly allocated" &&
595 (this->
Neighbors.size()==this->NumberOfGrids));
602 const int gridID,
const int nei)
604 assert(
"pre: grid ID is out-of-bounds" &&
605 (gridID >= 0) && (gridID <
static_cast<int>(this->
NumberOfGrids)));
606 assert(
"pre: neighbors vector has not been properly allocated" &&
607 (this->
Neighbors.size()==this->NumberOfGrids));
608 assert(
"pre: nei index is out-of-bounds" &&
617 const int idx,
const int ExtentLo,
const int ExtentHi,
618 const int OnLo,
const int OnHi,
const int NotOnBoundary)
620 if( idx == ExtentLo )
624 else if( idx == ExtentHi )
628 return NotOnBoundary;
637 assert(
"pre: gridID is out-of-bounds" &&
638 (gridID >=0) && (gridID <
static_cast<int>(this->
NumberOfGrids)));
639 assert(
"pre: BlockTopology has not been properly allocated" &&
643 for(
int i=0; i < 6; ++i )
650 assert(
"post: count must be in [0,5]" && (count >=0 && count <= 6) );
656 const int gridID,
const int blockDirection )
659 assert(
"pre: gridID is out-of-bounds" &&
660 (gridID >=0) && (gridID <
static_cast<int>(this->
NumberOfGrids)));
661 assert(
"pre: BlockTopology has not been properly allocated" &&
663 assert(
"pre: blockDirection is out-of-bounds" &&
664 (blockDirection >= 0) && (blockDirection < 6) );
671 const int gridID,
const int blockDirection )
674 assert(
"pre: gridID is out-of-bounds" &&
675 (gridID >=0) && (gridID <
static_cast<int>(this->
NumberOfGrids)));
676 assert(
"pre: BlockTopology has not been properly allocated" &&
678 assert(
"pre: blockDirection is out-of-bounds" &&
679 (blockDirection >= 0) && (blockDirection < 6) );
688 assert(
"pre: gridID is out-of-bounds" &&
689 (gridID >=0) && (gridID <
static_cast<int>(this->
NumberOfGrids)));
690 assert(
"pre: BlockTopology has not been properly allocated" &&
692 for(
int i=0; i < 6; ++i )
701 int ext1[6],
int ext2[6])
703 for(
int i=0; i < 6; ++i )
705 if( ext1[i] != ext2[i] )
716 std::ostream& os,
int ext[6])
718 for(
int i=0; i < 6; i+=2 )
722 os << ext[i+1] <<
"] ";
730 assert(
"pre: grid Index is out-of-bounds!" &&
732 assert(
"pre: grid levels vector has not been allocated" &&
733 (this->
GridLevels.size()==this->NumberOfGrids) );
740 const int level,
const int r)
742 assert(
"pre: RefinementRatios vector is not propertly allocated" &&
744 assert(
"pre: leve is out-of-bounds!" &&
747 assert(
"pre: invalid refinement ratio" && (r >= 2) );
757 assert(
"pre: RefinementRatios vector is not propertly allocated" &&
759 assert(
"pre: leve is out-of-bounds!" &&
762 assert(
"pre: refinement ratio for level has not been set" &&
781 const int gridIdx,
int ext[6])
783 assert(
"pre: grid index is out-of-bounds" &&
785 (gridIdx <
static_cast<int>(this->
GridExtents.size()) ) ) );
787 for(
int i=0; i < 6; ++i )
797 if( this->
AMRHierarchy.find(level) != this->AMRHierarchy.end() )
806 const int level,
const int gridID )
815 grids.insert( gridID );
A superclass that defines the interface to be implemented by all concrete grid connectivity classes.
unsigned int NumberOfGrids
represent and manipulate cell attribute data
represent and manipulate fields of data
a simple class to control print indentation
represent and manipulate point attribute data
represent and manipulate 3D points
unsigned int NumberOfLevels
std::vector< int > GhostedExtents
void GetLocalCellCentersAtSameLevel(const int gridID, vtkStructuredAMRNeighbor &nei)
Copy cell center values to fill in the ghost levels from a neighbor at the same level as the grid cor...
void RemoveBlockConnection(const int gridID, const int blockDirection)
Removes a block connection along the given direction for the block corresponding to the given gridID.
virtual void MarkNodeProperty(const int gridId, const int i, const int j, const int k, int gridExt[6], int wholeExt[6], unsigned char &p)
Marks the ghost property for the given node.
void TransferRegisteredDataToGhostedData(const int gridID)
Transfers the data of the registered grid, to the ghosted data-structures.
bool AreExtentsEqual(int ext1[6], int ext2[6])
Checks if the extent ext1 and ext2 are equal.
void AddBlockConnection(const int gridID, const int blockDirection)
Adds a block connection along the given direction for the block corresponding to the given gridID.
std::vector< std::vector< vtkStructuredAMRNeighbor > > Neighbors
bool LevelExists(const int level)
Checks if the given level has been registered.
void ComputeAMRNeighborOverlapExtents(const int iLevel, const int jLevel, const int normalizedLevel, const vtkStructuredNeighbor &nei, int orient[3], int ndim, int gridOverlapExtent[6], int neiOverlapExtent[6])
A Helper method to compute the AMR neighbor overlap extents.
virtual void FillNodesGhostArray(const int gridId, vtkUnsignedCharArray *nodesArray)
Fills the node ghost arrays for the given grid.
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...
int GetGridLevel(const int gridIdx)
Returns the level of the grid with the corresponding grid ID.
int GetNumberOfNeighbors(const int gridID)
Returns the number of neighbors for the grid corresponding to the given grid ID.
void TransferLocalNeighborData(const int gridID, vtkStructuredAMRNeighbor &nei)
Transfers local neighbor data.
void TransferLocalNodeCenteredNeighborData(const int gridID, vtkStructuredAMRNeighbor &nei)
Transfers local node-centered neighbor data.
int GetRefinementRatioAtLevel(const int level)
Returns the refinement ratio at the given level.
std::map< int, std::set< int > > AMRHierarchy
std::vector< std::vector< int > > CellCenteredDonorLevel
void AverageFieldData(vtkFieldData *source, vtkIdType *sourceIds, const int N, vtkFieldData *target, vtkIdType targetIdx)
Loops through all arrays and computes the average of the supplied source indices and stores the corre...
virtual void TransferGhostDataFromNeighbors(const int gridID)
Fills in the ghost data from the neighbors.
void SetRefinementRatioAtLevel(const int level, const int r)
Sets the refinement ratio at the given level.
void ClearBlockConnections(const int gridID)
Clears all block connections for the block corresponding to the given grid ID.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
virtual void FillCellsGhostArray(const int gridId, vtkUnsignedCharArray *cellArray)
Fills the cell ghost arrays for the given grid.
std::vector< int > RefinementRatios
std::vector< int > GridLevels
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 ...
int Get1DOrientation(const int idx, const int ExtentLo, const int ExtentHi, const int OnLo, const int OnHi, const int NotOnBoundary)
Get 1-D orientation.
void GetGridExtent(const int gridIdx, int ext[6])
Gets the grid extent for the grid with the given grid ID.
void ComputeNeighbors() override
Computes neighboring information.
void CopyFieldData(vtkFieldData *source, vtkIdType sourceIdx, vtkFieldData *target, vtkIdType targetIdx)
Loops through all arrays in the source and for each array, it copies the tuples from sourceIdx to the...
void GetLocalCellCentersFromCoarserLevel(const int gridID, vtkStructuredAMRNeighbor &nei)
Copy cell center value from a coarser level by direct-injection, i.e., the values within the coarse c...
void Initialize(const unsigned int NumberOfLevels, const unsigned int N, const int RefinementRatio=-1)
Initializes this instance of vtkStructuredAMRGridConnectivity where N is the total number of grids in...
void InsertGridAtLevel(const int level, const int gridID)
Inserts the grid corresponding to the given ID at the prescribed level.
void TransferLocalCellCenteredNeighborData(const int gridID, vtkStructuredAMRNeighbor &nei)
Transfers local cell-centered neighbor data.
vtkStructuredAMRNeighbor GetNeighbor(const int gridID, const int nei)
Returns the AMR neighbor for the patch with the corresponding grid ID.
void InitializeGhostData(const int gridID)
Initializes the ghost data-structures.
std::vector< int > GridExtents
static vtkStructuredAMRGridConnectivity * New()
std::vector< unsigned char > BlockTopology
void FillGhostArrays(const int gridId, vtkUnsignedCharArray *nodesArray, vtkUnsignedCharArray *cellsArray) override
Fills ghost arrays.
vtkStructuredAMRNeighbor GetAMRNeighbor(const int i, const int iLevel, int next1[6], const int j, const int jLevel, int next2[6], const int normalizedLevel, const int levelDiff, vtkStructuredNeighbor &nei)
Compute the AMR neighbor of grid "i" and its neighbor grid "j".
void PrintExtent(std::ostream &os, int ext[6])
Prints the extent.
bool HasConstantRefinementRatio()
Checks if a constant refinement ratio has been specified.
void GetLocalCellCentersFromFinerLevel(const int gridID, vtkStructuredAMRNeighbor &nei)
Copy cell center values from a finer level by cell averaging.
An internal, light-weight object used to store neighbor information for AMR grids.
An internal, light-weight class used to store neighbor information.
dynamic, self-adjusting array of unsigned char
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
boost::graph_traits< vtkGraph * >::vertex_descriptor target(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
vtkSetMacro(IgnoreDriverBugs, bool)
Updates the extensions string.