31#ifndef vtkStructuredAMRGridConnectivity_h
32#define vtkStructuredAMRGridConnectivity_h
35#include "vtkFiltersGeometryModule.h"
61 const unsigned int NumberOfLevels,
const unsigned int N,
const int RefinementRatio = -1);
78 virtual void RegisterGrid(
const int gridIdx,
const int level,
const int refinementRatio,
87 virtual void RegisterGrid(
const int gridIdx,
const int level,
int extents[6],
97 vtkSetMacro(BalancedRefinement,
bool);
98 vtkGetMacro(BalancedRefinement,
bool);
107 vtkSetMacro(NodeCentered,
bool);
108 vtkGetMacro(NodeCentered,
bool);
116 vtkSetMacro(CellCentered,
bool);
117 vtkGetMacro(CellCentered,
bool);
124 int GetNumberOfNeighbors(
const int gridID);
173 void RefineExtent(
int orient[3],
int ndim,
int fromLevel,
int toLevel,
int ext[6]);
180 const int fromLevel,
const int toLevel,
int ext[6]);
185 void CoarsenExtent(
int orient[3],
int ndim,
int fromLevel,
int toLevel,
int ext[6]);
190 void GetGridExtent(
const int gridIdx,
int ext[6]);
195 int GetGridLevel(
const int gridIdx);
200 bool LevelExists(
const int level);
216 const int i,
const int j,
const int k,
const int gridId,
int gridExt[6]);
226 void InsertGridAtLevel(
const int level,
const int gridID);
256 const int i,
const int j,
const int k,
int gridExt[6],
int nodeOrientation[3]);
270 bool HasConstantRefinementRatio();
275 void SetRefinementRatioAtLevel(
const int level,
const int r);
280 int GetRefinementRatioAtLevel(
const int level);
285 bool AreExtentsEqual(
int ext1[6],
int ext2[6]);
299 int GetNumberOfConnectingBlockFaces(
const int gridID);
319 assert(
"pre: gridID is out-of-bounds" && (gridID >= 0) &&
320 (gridID <
static_cast<int>(this->NumberOfGrids)));
321 assert(
"pre: BlockTopology has not been properly allocated" &&
322 (this->NumberOfGrids == this->BlockTopology.size()));
323 assert(
"pre: blockDirection is out-of-bounds" && (blockDirection >= 0) && (blockDirection < 6));
325 if (this->BlockTopology[gridID] & (1 << blockDirection))
347 void RemoveBlockConnection(
const int gridID,
const int blockDirection);
363 void AddBlockConnection(
const int gridID,
const int blockDirection);
369 void ClearBlockConnections(
const int gridID);
375 int gridExt[6],
int wholeExt[6],
unsigned char& p);
405 const int jLevel,
int next2[6],
const int normalizedLevel,
const int levelDiff,
415 int gridOverlapExtent[6],
int neiOverlapExtent[6]);
420 int Get1DOrientation(
const int idx,
const int ExtentLo,
const int ExtentHi,
const int OnLo,
421 const int OnHi,
const int NotOnBoundary);
426 void PrintExtent(std::ostream& os,
int ext[6]);
516 std::vector<std::vector<vtkStructuredAMRNeighbor>>
Neighbors;
539 assert(
"pre: grid ID is out-of-bounds" && (gridID >= 0) &&
541 assert(
"pre: neighbors vector has not been properly allocated" &&
542 (this->
Neighbors.size() == this->NumberOfGrids));
543 return (
static_cast<int>(this->
Neighbors[gridID].size()));
548 const int gridID,
const int nei)
550 assert(
"pre: grid ID is out-of-bounds" && (gridID >= 0) &&
552 assert(
"pre: neighbors vector has not been properly allocated" &&
553 (this->
Neighbors.size() == this->NumberOfGrids));
554 assert(
"pre: nei index is out-of-bounds" && (nei >= 0) &&
555 (nei <
static_cast<int>(this->
Neighbors[gridID].size())));
561 const int ExtentHi,
const int OnLo,
const int OnHi,
const int NotOnBoundary)
567 else if (idx == ExtentHi)
571 return NotOnBoundary;
578 assert(
"pre: gridID is out-of-bounds" && (gridID >= 0) &&
580 assert(
"pre: BlockTopology has not been properly allocated" &&
584 for (
int i = 0; i < 6; ++i)
591 assert(
"post: count must be in [0,5]" && (count >= 0 && count <= 6));
597 const int gridID,
const int blockDirection)
600 assert(
"pre: gridID is out-of-bounds" && (gridID >= 0) &&
602 assert(
"pre: BlockTopology has not been properly allocated" &&
604 assert(
"pre: blockDirection is out-of-bounds" && (blockDirection >= 0) && (blockDirection < 6));
611 const int gridID,
const int blockDirection)
614 assert(
"pre: gridID is out-of-bounds" && (gridID >= 0) &&
616 assert(
"pre: BlockTopology has not been properly allocated" &&
618 assert(
"pre: blockDirection is out-of-bounds" && (blockDirection >= 0) && (blockDirection < 6));
626 assert(
"pre: gridID is out-of-bounds" && (gridID >= 0) &&
628 assert(
"pre: BlockTopology has not been properly allocated" &&
630 for (
int i = 0; i < 6; ++i)
639 for (
int i = 0; i < 6; ++i)
641 if (ext1[i] != ext2[i])
652 for (
int i = 0; i < 6; i += 2)
656 os << ext[i + 1] <<
"] ";
663 assert(
"pre: grid Index is out-of-bounds!" && (gridIdx <
static_cast<int>(this->
NumberOfGrids)));
664 assert(
"pre: grid levels vector has not been allocated" &&
665 (this->
GridLevels.size() == this->NumberOfGrids));
671 const int level,
const int r)
673 assert(
"pre: RefinementRatios vector is not properly allocated" &&
675 assert(
"pre: leve is out-of-bounds!" && (level >= 0) &&
677 assert(
"pre: invalid refinement ratio" && (r >= 2));
685 assert(
"pre: RefinementRatios vector is not properly allocated" &&
687 assert(
"pre: leve is out-of-bounds!" && (level >= 0) &&
690 "pre: refinement ratio for level has not been set" && (this->
RefinementRatios[level] >= 2));
708 assert(
"pre: grid index is out-of-bounds" &&
709 ((gridIdx >= 0) && (gridIdx <
static_cast<int>(this->
GridExtents.size()))));
711 for (
int i = 0; i < 6; ++i)
720 if (this->
AMRHierarchy.find(level) != this->AMRHierarchy.end())
737 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
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.
std::vector< int > GridLevels
virtual void RegisterGrid(const int gridIdx, const int level, const int refinementRatio, int extents[6], vtkUnsignedCharArray *nodesGhostArray, vtkUnsignedCharArray *cellGhostArray, vtkPointData *pointData, vtkCellData *cellData, vtkPoints *gridNodes)
Registers the AMR grid with the given global linear grid ID (starting numbering from 0) and level and...
void CreateGhostedExtent(const int gridID, const int N)
Creates the ghosted extent of the given grid.
std::vector< int > RefinementRatios
bool AreExtentsEqual(int ext1[6], int ext2[6])
Checks if the extent ext1 and ext2 are equal.
void GetNodeOrientation(const int i, const int j, const int k, int gridExt[6], int nodeOrientation[3])
Computes the node orientation tuple for the given i,j,k node.
void GetRefinedExtent(const int gridIdx, int fromLevel, int toLevel, int ext[6])
Gets the refined extent for the grid with the given grid index.
virtual void FillCellsGhostArray(const int gridId, vtkUnsignedCharArray *cellsArray)
Fills the cell ghost arrays for the given grid.
void AddBlockConnection(const int gridID, const int blockDirection)
Adds a block connection along the given direction for the block corresponding to the given gridID.
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.
void ComputeNeighborSendAndRcvExtent(const int gridID, const int N)
Loops through the neighbors of this grid and computes the send and rcv extents for the N requested gh...
virtual void FillNodesGhostArray(const int gridId, vtkUnsignedCharArray *nodesArray)
Fills the node ghost arrays for the given grid.
std::vector< std::vector< int > > CellCenteredDonorLevel
void GetCoarsenedExtent(const int gridIdx, int fromLevel, int toLevel, int ext[6])
Gets the coarsened extent for the grid with the given grid index.
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.
bool IsNodeOnBoundaryOfExtent(const int i, const int j, const int k, int ext[6])
Checks if the node is on the boundary of the given extent.
int GetNumberOfNeighbors(const int gridID)
Returns the number of neighbors for the grid corresponding to the given grid ID.
void GetOrientationVector(const int dataDescription, int orient[3], int &ndim)
Establishes the orientation vector and dimension based on the computed data description.
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.
virtual void RegisterGrid(const int gridIdx, const int level, int extents[6], vtkUnsignedCharArray *nodesGhostArray, vtkUnsignedCharArray *cellGhostArray, vtkPointData *pointData, vtkCellData *cellData, vtkPoints *gridNodes)
Registers the AMR grid with the given global linear grid ID (starting numbering from 0) and level.
std::vector< int > GhostedExtents
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.
bool IsNodeInterior(const int i, const int j, const int k, int GridExtent[6])
Checks if the node is an interior node in the given extent.
vtkStructuredAMRGridConnectivity()
void SetRefinementRatioAtLevel(const int level, const int r)
Sets the refinement ratio at the given level.
bool IsNodeWithinExtent(const int i, const int j, const int k, int GridExtent[6])
Checks if the node is within the extent.
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.
std::vector< std::vector< vtkStructuredAMRNeighbor > > Neighbors
void SetNumberOfGrids(const unsigned int N) override
Sets the total number of grids(blocks) in the AMR hierarchy.
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.
std::vector< int > GridExtents
void GetWholeExtentAtLevel(const int level, int ext[6])
Gets the whole extent with respect to the given level.
void CreateGhostLayers(const int N=1) override
Creates ghost layers.
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...
~vtkStructuredAMRGridConnectivity() override
std::map< int, std::set< int > > AMRHierarchy
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 CoarsenExtent(int orient[3], int ndim, int fromLevel, int toLevel, int ext[6])
Coarsens the given extent.
void InsertGridAtLevel(const int level, const int gridID)
Inserts the grid corresponding to the given ID at the prescribed level.
void ComputeWholeExtent()
Computes the whole extent w.r.t.
void TransferLocalCellCenteredNeighborData(const int gridID, vtkStructuredAMRNeighbor &nei)
Transfers local cell-centered neighbor data.
void GetGhostedExtent(const int gridID, int ext[6])
Returns the ghost extend for the grid corresponding to the given grid ID.
void GetCellRefinedExtent(int orient[3], int ndim, const int i, const int j, const int k, const int fromLevel, const int toLevel, int ext[6])
Given the global i,j,k index of a cell at a coarse level, fromLevel, this method computes the range o...
vtkStructuredAMRNeighbor GetNeighbor(const int gridID, const int nei)
Returns the AMR neighbor for the patch with the corresponding grid ID.
void CreateGhostedMaskArrays(const int gridID)
Creates the ghosted mask arrays.
void SetGhostedExtent(const int gridID, int ext[6])
Sets the ghost extent for the grid corresponding to the given grid ID.
void InitializeGhostData(const int gridID)
Initializes the ghost data-structures.
std::vector< unsigned char > BlockTopology
void RefineExtent(int orient[3], int ndim, int fromLevel, int toLevel, int ext[6])
Refines the given extent.
void SetBlockTopology(const int gridID)
Constructs the block topology for the given grid.
static vtkStructuredAMRGridConnectivity * New()
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 EstablishNeighbors(const int i, const int j)
Establishes neighboring relationship between grids i,j wheren i,j are global indices.
void GetLocalCellCentersFromFinerLevel(const int gridID, vtkStructuredAMRNeighbor &nei)
Copy cell center values from a finer level by cell averaging.
bool IsNodeOnSharedBoundary(const int i, const int j, const int k, const int gridId, int gridExt[6])
Checks if the node is on a shared boundary.
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 *)