Commit 03b6f62d authored by Kenneth Moreland's avatar Kenneth Moreland

Add a test for the WholeCellSetIn argument

All types of cell sets should have a consistent interface. This is
tested (and fixed) for explicit and permutation cell sets. However, an
unfixed bug that has been identified is that permutation cell sets only
work for point to cell topologies. All others are not supported
correctly.
parent 938db09a
......@@ -103,10 +103,32 @@ public:
template <typename Device, typename FromTopology, typename ToTopology>
typename ExecutionTypes<Device, FromTopology, ToTopology>::ExecObjectType
PrepareForInput(Device d, FromTopology f, ToTopology t) const
PrepareForInput(Device, FromTopology, ToTopology) const
{
typedef
typename ExecutionTypes<Device, FromTopology, ToTopology>::ExecObjectType ConnectivityType;
// Developer's note: I looked into supporting cell to point connectivity in a permutation cell
// set and found it to be complex. It is not straightforward to implement this on top of the
// original cell set's cell to point because points could be attached to cells that do not
// exist in the permuted topology. Ultimately, you will probably have to rebuild these
// connections in a way very similar to how CellSetExplicit already does it. In fact, the
// easiest implementation will probably be to just convert to a CellSetExplicit and use that.
// In fact, it may be possible to change this whole implementation to just be a subclass of
// CellSetExplicit with some fancy arrays for its point to cell arrays.
throw vtkm::cont::ErrorBadType(
"CellSetPermutation currently only supports point to cell connectivity. "
"To support other connectivity, convert to an explicit grid with the CellDeepCopy "
"worklet or the CleanGrid filter.");
}
template <typename Device>
typename ExecutionTypes<Device,
vtkm::TopologyElementTagPoint,
vtkm::TopologyElementTagCell>::ExecObjectType
PrepareForInput(Device d, vtkm::TopologyElementTagPoint f, vtkm::TopologyElementTagCell t) const
{
using FromTopology = vtkm::TopologyElementTagPoint;
using ToTopology = vtkm::TopologyElementTagCell;
using ConnectivityType =
typename ExecutionTypes<Device, FromTopology, ToTopology>::ExecObjectType;
return ConnectivityType(this->ValidCellIds.PrepareForInput(d),
this->FullCellSet.PrepareForInput(d, f, t));
}
......
......@@ -60,6 +60,9 @@ public:
VTKM_EXEC
CellShapeTag GetCellShape(vtkm::Id index) const { return CellShapeTag(this->Shapes.Get(index)); }
VTKM_EXEC
vtkm::IdComponent GetNumberOfIndices(vtkm::Id index) const { return this->NumIndices.Get(index); }
using IndicesType = vtkm::VecFromPortal<ConnectivityPortalType>;
/// Returns a Vec-like object containing the indices for the given index.
......
......@@ -58,6 +58,9 @@ public:
{
}
VTKM_EXEC
vtkm::Id GetNumberOfElements() const { return this->Portal.GetNumberOfValues(); }
typedef typename OriginalConnectivity::CellShapeTag CellShapeTag;
VTKM_EXEC
......@@ -67,6 +70,12 @@ public:
return this->Connectivity.GetCellShape(pIndex);
}
VTKM_EXEC
vtkm::IdComponent GetNumberOfIndices(vtkm::Id index) const
{
return this->Connectivity.GetNumberOfIndices(this->Portal.Get(index));
}
typedef typename OriginalConnectivity::IndicesType IndicesType;
template <typename IndexType>
......
......@@ -592,4 +592,26 @@ static inline VTKM_CONT void SetPortal(const PortalType& portal)
}
}
/// Verifies that the contents of the two portals are the same.
///
template <typename PortalType1, typename PortalType2>
static inline VTKM_CONT bool test_equal_portals(const PortalType1& portal1,
const PortalType2& portal2)
{
if (portal1.GetNumberOfValues() != portal2.GetNumberOfValues())
{
return false;
}
for (vtkm::Id index = 0; index < portal1.GetNumberOfValues(); index++)
{
if (!test_equal(portal1.Get(index), portal2.Get(index)))
{
return false;
}
}
return true;
}
#endif //vtk_m_testing_Testing_h
......@@ -50,6 +50,7 @@ set(unit_tests
UnitTestThreshold.cxx
UnitTestThresholdPoints.cxx
UnitTestTriangulate.cxx
UnitTestWholeCellSetIn.cxx
UnitTestWorkletMapField.cxx
UnitTestWorkletMapFieldExecArg.cxx
UnitTestWorkletMapFieldWholeArray.cxx
......
This diff is collapsed.
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