Add method for getting a cononical edge id

The cononical edge id is stored in a vtkm::Id2.
This commit is contained in:
Kenneth Moreland 2017-08-17 16:07:41 -06:00
parent 8e72dc738a
commit b1e6c1e34b
3 changed files with 52 additions and 7 deletions

@ -354,6 +354,35 @@ static inline VTKM_EXEC vtkm::Vec<vtkm::IdComponent, 2> CellEdgeLocalIndices(
detail::PointsInEdge[shape.Id][edgeIndex][1]);
}
}
/// \brief Returns a cononical identifier for a cell edge
///
/// Given information about a cell edge and the global point indices for that cell, returns a
/// vtkm::Id2 that contains values that are unique to that edge. The values for two edges will be
/// the same if and only if the edges contain the same points.
///
template <typename CellShapeTag, typename GlobalPointIndicesVecType>
static inline VTKM_EXEC vtkm::Id2 CellEdgeCononicalId(
vtkm::IdComponent numPoints,
vtkm::IdComponent edgeIndex,
CellShapeTag shape,
const GlobalPointIndicesVecType& globalPointIndicesVec,
const vtkm::exec::FunctorBase& worklet)
{
vtkm::Vec<vtkm::IdComponent, 2> localPointIndices =
vtkm::exec::CellEdgeLocalIndices(numPoints, edgeIndex, shape, worklet);
vtkm::Id pointIndex0 = globalPointIndicesVec[localPointIndices[0]];
vtkm::Id pointIndex1 = globalPointIndicesVec[localPointIndices[1]];
if (pointIndex0 < pointIndex1)
{
return vtkm::Id2(pointIndex0, pointIndex1);
}
else
{
return vtkm::Id2(pointIndex1, pointIndex0);
}
}
}
} // namespace vtkm::exec

@ -248,14 +248,13 @@ static inline VTKM_EXEC vtkm::VecCConst<vtkm::IdComponent> CellFaceLocalIndices(
/// \brief Returns a cononical identifer for a cell face
///
/// Given information about a cell face and the global point indices for that cell,
/// returns a vtkm::Id3 that contains values that are unique to that face. The
/// values for two faces will be the same if and only if the faces contain the same
/// points.
/// Given information about a cell face and the global point indices for that cell, returns a
/// vtkm::Id3 that contains values that are unique to that face. The values for two faces will be
/// the same if and only if the faces contain the same points.
///
/// Note that this property is only try if the mesh is conforming. That is, any two
/// neighboring cells that share a face have the same points on that face. This
/// preculdes to faces sharing more than a single point or single edge.
/// Note that this property is only true if the mesh is conforming. That is, any two neighboring
/// cells that share a face have the same points on that face. This preculdes 2 faces sharing more
/// than a single point or single edge.
///
template <typename CellShapeTag, typename GlobalPointIndicesVecType>
static inline VTKM_EXEC vtkm::Id3 CellFaceCononicalId(

@ -81,6 +81,11 @@ struct TestCellFacesFunctor
VTKM_TEST_ASSERT(edge[0] < edge[1], "Internal test error: MakeEdgeCononical failed");
VTKM_TEST_ASSERT(edgeSet.find(edge) == edgeSet.end(), "Found duplicate edge");
edgeSet.insert(edge);
vtkm::Id2 cononicalEdgeId =
vtkm::exec::CellEdgeCononicalId(numPoints, edgeIndex, shape, pointIndexProxy, workletProxy);
VTKM_TEST_ASSERT(cononicalEdgeId[0] > 0, "Not using global ids?");
VTKM_TEST_ASSERT(cononicalEdgeId[0] < cononicalEdgeId[1], "Bad order.");
}
vtkm::IdComponent numFaces = vtkm::exec::CellFaceNumberOfFaces(shape, workletProxy);
@ -135,6 +140,13 @@ struct TestCellFacesFunctor
vtkm::exec::FunctorBase workletProxy;
workletProxy.SetErrorMessageBuffer(errorMessage);
std::vector<vtkm::Id> pointIndexProxyBuffer(static_cast<std::size_t>(numPoints));
for (std::size_t index = 0; index < pointIndexProxyBuffer.size(); ++index)
{
pointIndexProxyBuffer[index] = static_cast<vtkm::Id>(1000000 - index);
}
vtkm::VecCConst<vtkm::Id> pointIndexProxy(&pointIndexProxyBuffer.at(0), numPoints);
vtkm::IdComponent numEdges = vtkm::exec::CellEdgeNumberOfEdges(numPoints, shape, workletProxy);
VTKM_TEST_ASSERT(numEdges == numPoints, "Polygons should have same number of points and edges");
@ -151,6 +163,11 @@ struct TestCellFacesFunctor
VTKM_TEST_ASSERT(edge[0] < edge[1], "Internal test error: MakeEdgeCononical failed");
VTKM_TEST_ASSERT(edgeSet.find(edge) == edgeSet.end(), "Found duplicate edge");
edgeSet.insert(edge);
vtkm::Id2 cononicalEdgeId =
vtkm::exec::CellEdgeCononicalId(numPoints, edgeIndex, shape, pointIndexProxy, workletProxy);
VTKM_TEST_ASSERT(cononicalEdgeId[0] > 0, "Not using global ids?");
VTKM_TEST_ASSERT(cononicalEdgeId[0] < cononicalEdgeId[1], "Bad order.");
}
vtkm::IdComponent numFaces = vtkm::exec::CellFaceNumberOfFaces(shape, workletProxy);