Test and fix issues with WholeCellSetIn with structured grids

This commit is contained in:
Kenneth Moreland 2017-07-28 15:02:05 -06:00
parent 03b6f62d05
commit 897ec9ff5e
3 changed files with 183 additions and 3 deletions

@ -62,12 +62,19 @@ public:
{
}
// This needs some thought. What does cell shape mean when the to topology
// is not a cell?
typedef typename InternalsType::CellShapeTag CellShapeTag;
VTKM_EXEC
vtkm::Id GetNumberOfElements() const { return Helper::GetNumberOfElements(this->Internals); }
typedef typename Helper::CellShapeTag CellShapeTag;
VTKM_EXEC
CellShapeTag GetCellShape(vtkm::Id) const { return CellShapeTag(); }
template <typename IndexType>
VTKM_EXEC vtkm::IdComponent GetNumberOfIndices(const IndexType& index) const
{
return Helper::GetNumberOfIndices(this->Internals, index);
}
typedef typename Helper::IndicesType IndicesType;
template <typename IndexType>

@ -86,6 +86,19 @@ public:
return pointIds;
}
VTKM_EXEC_CONT
vtkm::IdComponent GetNumberOfCellsOnPoint(vtkm::Id pointIndex) const
{
if ((pointIndex > 0) && (pointIndex < this->PointDimensions - 1))
{
return 2;
}
else
{
return 1;
}
}
VTKM_EXEC_CONT
vtkm::VecVariable<vtkm::Id, MAX_CELL_TO_POINT> GetCellsOfPoint(vtkm::Id index) const
{
@ -188,6 +201,27 @@ public:
return this->GetPointsOfCell(this->FlatToLogicalCellIndex(cellIndex));
}
VTKM_EXEC_CONT vtkm::IdComponent GetNumberOfCellsOnPoint(const SchedulingRangeType& ij) const
{
vtkm::IdComponent numCells = 1;
for (vtkm::IdComponent dim = 0; dim < 2; dim++)
{
if ((ij[dim] > 0) && (ij[dim] < this->PointDimensions[dim] - 1))
{
numCells *= 2;
}
}
return numCells;
}
VTKM_EXEC_CONT
vtkm::IdComponent GetNumberOfCellsOnPoint(vtkm::Id pointIndex) const
{
return this->GetNumberOfCellsOnPoint(this->FlatToLogicalPointIndex(pointIndex));
}
VTKM_EXEC_CONT
vtkm::VecVariable<vtkm::Id, MAX_CELL_TO_POINT> GetCellsOfPoint(
const SchedulingRangeType& ij) const
@ -334,6 +368,27 @@ public:
return this->GetPointsOfCell(this->FlatToLogicalCellIndex(cellIndex));
}
VTKM_EXEC_CONT vtkm::IdComponent GetNumberOfCellsOnPoint(const SchedulingRangeType& ijk) const
{
vtkm::IdComponent numCells = 1;
for (vtkm::IdComponent dim = 0; dim < 3; dim++)
{
if ((ijk[dim] > 0) && (ijk[dim] < this->PointDimensions[dim] - 1))
{
numCells *= 2;
}
}
return numCells;
}
VTKM_EXEC_CONT
vtkm::IdComponent GetNumberOfCellsOnPoint(vtkm::Id pointIndex) const
{
return this->GetNumberOfCellsOnPoint(this->FlatToLogicalPointIndex(pointIndex));
}
VTKM_EXEC_CONT
vtkm::VecVariable<vtkm::Id, MAX_CELL_TO_POINT> GetCellsOfPoint(
const SchedulingRangeType& ijk) const
@ -460,8 +515,23 @@ struct ConnectivityStructuredIndexHelper<vtkm::TopologyElementTagPoint,
typedef vtkm::internal::ConnectivityStructuredInternals<Dimension> ConnectivityType;
typedef typename ConnectivityType::SchedulingRangeType LogicalIndexType;
using CellShapeTag = typename ConnectivityType::CellShapeTag;
typedef vtkm::Vec<vtkm::Id, ConnectivityType::NUM_POINTS_IN_CELL> IndicesType;
VTKM_EXEC_CONT static vtkm::Id GetNumberOfElements(const ConnectivityType& connectivity)
{
return connectivity.GetNumberOfCells();
}
template <typename IndexType>
VTKM_EXEC_CONT static vtkm::IdComponent GetNumberOfIndices(
const ConnectivityType& vtkmNotUsed(connectivity),
const IndexType& vtkmNotUsed(cellIndex))
{
return ConnectivityType::NUM_POINTS_IN_CELL;
}
template <typename IndexType>
VTKM_EXEC_CONT static IndicesType GetIndices(const ConnectivityType& connectivity,
const IndexType& cellIndex)
@ -506,8 +576,22 @@ struct ConnectivityStructuredIndexHelper<vtkm::TopologyElementTagCell,
typedef vtkm::internal::ConnectivityStructuredInternals<Dimension> ConnectivityType;
typedef typename ConnectivityType::SchedulingRangeType LogicalIndexType;
using CellShapeTag = vtkm::CellShapeTagVertex;
typedef vtkm::VecVariable<vtkm::Id, ConnectivityType::MAX_CELL_TO_POINT> IndicesType;
VTKM_EXEC_CONT static vtkm::Id GetNumberOfElements(const ConnectivityType& connectivity)
{
return connectivity.GetNumberOfPoints();
}
template <typename IndexType>
VTKM_EXEC_CONT static vtkm::IdComponent GetNumberOfIndices(const ConnectivityType& connectivity,
const IndexType& pointIndex)
{
return connectivity.GetNumberOfCellsOnPoint(pointIndex);
}
template <typename IndexType>
VTKM_EXEC_CONT static IndicesType GetIndices(const ConnectivityType& connectivity,
const IndexType& pointIndex)

@ -265,11 +265,100 @@ void TryCellSetPermutation()
// Permutation cell set does not support cell to point connectivity.
}
VTKM_CONT
void TryStructuredGrid3D()
{
std::cout << "Testing 3D structured grid." << std::endl;
vtkm::cont::DataSet dataSet = vtkm::cont::testing::MakeTestDataSet().Make3DUniformDataSet0();
vtkm::cont::CellSetStructured<3> cellSet;
dataSet.GetCellSet().CopyTo(cellSet);
vtkm::Id expectedCellIndexSum[4] = { 40, 48, 88, 96 };
vtkm::Id numCells = cellSet.GetNumberOfCells();
TryCellConnectivity(
cellSet,
vtkm::cont::ArrayHandleConstant<vtkm::UInt8>(vtkm::CELL_SHAPE_HEXAHEDRON, numCells),
vtkm::cont::ArrayHandleConstant<vtkm::IdComponent>(8, numCells),
vtkm::cont::make_ArrayHandle(expectedCellIndexSum, numCells));
vtkm::IdComponent expectedPointNumIndices[18] = { 1, 2, 1, 1, 2, 1, 2, 4, 2,
2, 4, 2, 1, 2, 1, 1, 2, 1 };
vtkm::Id expectedPointIndexSum[18] = { 0, 1, 1, 0, 1, 1, 2, 6, 4, 2, 6, 4, 2, 5, 3, 2, 5, 3 };
vtkm::Id numPoints = cellSet.GetNumberOfPoints();
TryPointConnectivity(
cellSet,
vtkm::cont::ArrayHandleConstant<vtkm::UInt8>(vtkm::CELL_SHAPE_VERTEX, numPoints),
vtkm::cont::make_ArrayHandle(expectedPointNumIndices, numPoints),
vtkm::cont::make_ArrayHandle(expectedPointIndexSum, numPoints));
}
VTKM_CONT
void TryStructuredGrid2D()
{
std::cout << "Testing 2D structured grid." << std::endl;
vtkm::cont::DataSet dataSet = vtkm::cont::testing::MakeTestDataSet().Make2DUniformDataSet0();
vtkm::cont::CellSetStructured<2> cellSet;
dataSet.GetCellSet().CopyTo(cellSet);
vtkm::Id expectedCellIndexSum[2] = { 8, 12 };
vtkm::Id numCells = cellSet.GetNumberOfCells();
TryCellConnectivity(cellSet,
vtkm::cont::ArrayHandleConstant<vtkm::UInt8>(vtkm::CELL_SHAPE_QUAD, numCells),
vtkm::cont::ArrayHandleConstant<vtkm::IdComponent>(4, numCells),
vtkm::cont::make_ArrayHandle(expectedCellIndexSum, numCells));
vtkm::IdComponent expectedPointNumIndices[6] = { 1, 2, 1, 1, 2, 1 };
vtkm::Id expectedPointIndexSum[6] = { 0, 1, 1, 0, 1, 1 };
vtkm::Id numPoints = cellSet.GetNumberOfPoints();
TryPointConnectivity(
cellSet,
vtkm::cont::ArrayHandleConstant<vtkm::UInt8>(vtkm::CELL_SHAPE_VERTEX, numPoints),
vtkm::cont::make_ArrayHandle(expectedPointNumIndices, numPoints),
vtkm::cont::make_ArrayHandle(expectedPointIndexSum, numPoints));
}
VTKM_CONT
void TryStructuredGrid1D()
{
std::cout << "Testing 1D structured grid." << std::endl;
vtkm::cont::DataSet dataSet = vtkm::cont::testing::MakeTestDataSet().Make1DUniformDataSet0();
vtkm::cont::CellSetStructured<1> cellSet;
dataSet.GetCellSet().CopyTo(cellSet);
vtkm::Id expectedCellIndexSum[5] = { 1, 3, 5, 7, 9 };
vtkm::Id numCells = cellSet.GetNumberOfCells();
TryCellConnectivity(cellSet,
vtkm::cont::ArrayHandleConstant<vtkm::UInt8>(vtkm::CELL_SHAPE_LINE, numCells),
vtkm::cont::ArrayHandleConstant<vtkm::IdComponent>(2, numCells),
vtkm::cont::make_ArrayHandle(expectedCellIndexSum, numCells));
vtkm::IdComponent expectedPointNumIndices[6] = { 1, 2, 2, 2, 2, 1 };
vtkm::Id expectedPointIndexSum[6] = { 0, 1, 3, 5, 7, 4 };
vtkm::Id numPoints = cellSet.GetNumberOfPoints();
TryPointConnectivity(
cellSet,
vtkm::cont::ArrayHandleConstant<vtkm::UInt8>(vtkm::CELL_SHAPE_VERTEX, numPoints),
vtkm::cont::make_ArrayHandle(expectedPointNumIndices, numPoints),
vtkm::cont::make_ArrayHandle(expectedPointIndexSum, numPoints));
}
VTKM_CONT
void RunWholeCellSetInTests()
{
TryExplicitGrid();
TryCellSetPermutation();
TryStructuredGrid3D();
TryStructuredGrid2D();
TryStructuredGrid1D();
}
int UnitTestWholeCellSetIn(int, char* [])