Commit e674a6c8 authored by dpugmire's avatar dpugmire
Browse files

Fix issue with PointToCell indices not being computed.

Also, mark them as valid, when valid.
parent 25a1e3c3
......@@ -232,6 +232,7 @@ public:
{
this->PointToCell.Connectivity.Shrink(ConnectivityLength);
this->PointToCell.ElementsValid = true;
this->PointToCell.IndexOffsetsValid = true;
this->NumberOfCells = this->ConnectivityLength = -1;
}
......@@ -364,6 +365,7 @@ public:
NumIndicesStorageTag,
ConnectivityStorageTag,
OffsetsStorageTag> CSE;
CSE *self = const_cast<CSE*>(this);
self->CreateConnectivity(Device(), FromTopology(), ToTopology());
......@@ -420,7 +422,7 @@ public:
//
// PointToCell numIndices array using expansion will be
// transformed into the CellToPoint connectivity array
if (this->CellToPoint.ElementsValid)
{
return;
......@@ -441,6 +443,7 @@ public:
cellIndices.Allocate(connectivityLength);
vtkm::cont::ArrayHandleCounting<vtkm::Id> index(0, 1, numberOfCells);
this->PointToCell.BuildIndexOffsets(Device());
vtkm::worklet::DispatcherMapField<ExpandIndices> expandDispatcher;
expandDispatcher.Invoke(index,
this->PointToCell.IndexOffsets,
......@@ -454,7 +457,7 @@ public:
{
this->NumberOfPoints = pointIndices.GetPortalControl().Get(connectivityLength - 1) + 1;
}
vtkm::Id numberOfPoints = this->GetNumberOfPoints();
vtkm::Id numberOfPoints = this->GetNumberOfPoints();
// CellToPoint numIndices from the now sorted PointToCell connectivity
vtkm::cont::ArrayHandleConstant<vtkm::Id> numArray(1, connectivityLength);
......
......@@ -138,7 +138,7 @@ DataSetBuilderExplicit::Create(const std::vector<T> &xVals,
dataSet.AddCoordinateSystem(
vtkm::cont::CoordinateSystem(coordsNm, 1, coords));
vtkm::cont::CellSetExplicit<> cellSet((vtkm::Id)nPts, cellNm, 3);
vtkm::cont::CellSetExplicit<> cellSet((vtkm::Id)nPts, cellNm, 2);
cellSet.FillViaCopy(shapes, numIndices, connectivity);
dataSet.AddCellSet(cellSet);
......@@ -163,7 +163,7 @@ DataSetBuilderExplicit::Create(const std::vector<vtkm::Vec<T,3> > &coords,
dataSet.AddCoordinateSystem(
vtkm::cont::CoordinateSystem(coordsNm, 1, coordsArray));
vtkm::cont::CellSetExplicit<> cellSet((vtkm::Id)nPts, cellNm, 3);
vtkm::cont::CellSetExplicit<> cellSet(nPts, cellNm, 2);
cellSet.FillViaCopy(shapes, numIndices, connectivity);
dataSet.AddCellSet(cellSet);
......
......@@ -267,6 +267,12 @@ MakeTestDataSet::Make3DExplicitDataSet1()
dataSet.AddCoordinateSystem(
vtkm::cont::CoordinateSystem("coordinates", 1, coordinates, nVerts));
vtkm::cont::CellSetExplicit<> cellSet(nVerts, "cells", 2);
cellSet.PrepareToAddCells(2, 7);
cellSet.AddCell(vtkm::CELL_SHAPE_TRIANGLE, 3, make_Vec<vtkm::Id>(0,1,2));
cellSet.AddCell(vtkm::CELL_SHAPE_QUAD, 4, make_Vec<vtkm::Id>(2,1,3,4));
cellSet.CompleteAddingCells();
dataSet.AddCellSet(cellSet);
//Set point scalar
dataSet.AddField(Field("pointvar", 1, vtkm::cont::Field::ASSOC_POINTS, vars, nVerts));
......@@ -275,15 +281,6 @@ MakeTestDataSet::Make3DExplicitDataSet1()
vtkm::Float32 cellvar[2] = {100.1f, 100.2f};
dataSet.AddField(Field("cellvar", 1, vtkm::cont::Field::ASSOC_CELL_SET, "cells", cellvar, 2));
vtkm::cont::CellSetExplicit<> cellSet(nVerts, "cells", 2);
cellSet.PrepareToAddCells(2, 7);
cellSet.AddCell(vtkm::CELL_SHAPE_TRIANGLE, 3, make_Vec<vtkm::Id>(0,1,2));
cellSet.AddCell(vtkm::CELL_SHAPE_QUAD, 4, make_Vec<vtkm::Id>(2,1,3,4));
cellSet.CompleteAddingCells();
dataSet.AddCellSet(cellSet);
return dataSet;
}
......
......@@ -62,8 +62,8 @@ private:
static void TestDataSet_Explicit()
{
vtkm::cont::testing::MakeTestDataSet tds;
vtkm::cont::DataSet ds = tds.Make3DExplicitDataSet1();
vtkm::cont::DataSet ds = tds.Make3DExplicitDataSet0();
VTKM_TEST_ASSERT(ds.GetNumberOfCellSets() == 1,
"Incorrect number of cell sets");
......@@ -162,7 +162,6 @@ private:
connectivityIndex += numIncidentCells;
}
//verify that GetIndices works properly
vtkm::Id expectedPointIds[4] = {2,1,3,4};
vtkm::Vec<vtkm::Id,4> retrievedPointIds;
......
......@@ -233,7 +233,7 @@ TestAvgCellToPoint()
std::cout<<"Testing AvgCellToPoint worklet"<<std::endl;
vtkm::cont::testing::MakeTestDataSet testDataSet;
vtkm::cont::DataSet dataSet = testDataSet.Make3DExplicitDataSet0();
vtkm::cont::DataSet dataSet = testDataSet.Make3DExplicitDataSet1();
//Run a worklet to populate a point centered field.
//Here, we're filling it with test values.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment