Add vtkm::worklet::connectivity namespace

Created vtkm::worklet::connectivity namespace and worklets in the namespace.
This commit is contained in:
Li-Ta Lo 2018-04-27 11:30:24 -06:00
parent ce27f5fcaa
commit 6f85397192
7 changed files with 65 additions and 6 deletions

@ -25,6 +25,13 @@
#include <vtkm/worklet/connectivities/CellSetDualGraph.h>
#include <vtkm/worklet/connectivities/GraphConnectivity.h>
namespace vtkm
{
namespace worklet
{
namespace connectivity
{
class CellSetConnectivity
{
public:
@ -45,4 +52,8 @@ public:
numIndicesArray, indexOffsetArray, connectivityArray, componentArray);
}
};
}
}
} // vtkm::worklet::connectivity
#endif // vtk_m_worklet_connectivity_CellSetConnectivity_h

@ -28,10 +28,20 @@
#include <vtkm/worklet/ScatterCounting.h>
#include <vtkm/worklet/WorkletMapTopology.h>
namespace vtkm
{
namespace worklet
{
namespace connectivity
{
namespace detail
{
struct EdgeCount : public vtkm::worklet::WorkletMapPointToCell
{
typedef void ControlSignature(CellSetIn, FieldOutCell<> numEdgesInCell);
typedef _2 ExecutionSignature(CellShape, PointCount);
using InputDomain = _1;
template <typename CellShapeTag>
@ -46,6 +56,7 @@ struct EdgeExtract : public vtkm::worklet::WorkletMapPointToCell
typedef void ControlSignature(CellSetIn, FieldOutCell<> cellIndices, FieldOutCell<> edgeIndices);
typedef void ExecutionSignature(CellShape, InputIndex, PointIndices, VisitIndex, _2, _3);
using InputDomain = _1;
using ScatterType = vtkm::worklet::ScatterCounting;
@ -84,6 +95,7 @@ struct CellToCellConnectivity : public vtkm::worklet::WorkletMapField
WholeArrayOut<> to);
typedef void ExecutionSignature(_1, InputIndex, _2, _3, _4);
using InputDomain = _1;
template <typename ConnectivityPortalType, typename CellIdPortalType>
@ -99,6 +111,7 @@ struct CellToCellConnectivity : public vtkm::worklet::WorkletMapField
to.Set(index * 2 + 1, cells.Get(offset));
}
};
} // vtkm::worklet::connectivity::detail
template <typename DeviceAdapter>
class CellSetDualGraph
@ -119,12 +132,14 @@ public:
{
// Get number of edges for each cell and use it as scatter count.
vtkm::cont::ArrayHandle<vtkm::IdComponent> numEdgesPerCell;
vtkm::worklet::DispatcherMapTopology<EdgeCount, DeviceAdapter> edgesPerCellDisp;
vtkm::worklet::DispatcherMapTopology<detail::EdgeCount, DeviceAdapter> edgesPerCellDisp;
edgesPerCellDisp.Invoke(cellSet, numEdgesPerCell);
// Get uncompress Cell to Edge mapping
vtkm::worklet::ScatterCounting scatter{ numEdgesPerCell, DeviceAdapter() };
vtkm::worklet::DispatcherMapTopology<EdgeExtract, DeviceAdapter> edgeExtractDisp{ scatter };
vtkm::worklet::DispatcherMapTopology<detail::EdgeExtract, DeviceAdapter> edgeExtractDisp{
scatter
};
edgeExtractDisp.Invoke(cellSet, cellIds, cellEdges);
}
@ -166,7 +181,7 @@ public:
vtkm::cont::ArrayHandle<vtkm::Id> connTo;
connFrom.Allocate(sharedEdges.GetNumberOfValues() * 2);
connTo.Allocate(sharedEdges.GetNumberOfValues() * 2);
vtkm::worklet::DispatcherMapField<CellToCellConnectivity, DeviceAdapter> c2cDisp;
vtkm::worklet::DispatcherMapField<detail::CellToCellConnectivity, DeviceAdapter> c2cDisp;
c2cDisp.Invoke(lb, cellIds, connFrom, connTo);
// Turn dual graph into Compressed Sparse Row format
@ -183,4 +198,8 @@ public:
Algorithm::ScanExclusive(numIndicesArray, indexOffsetArray);
}
};
}
}
}
#endif //vtk_m_worklet_CellSetDualGraph_h

@ -27,6 +27,14 @@
#include <vtkm/worklet/connectivities/InnerJoin.h>
#include <vtkm/worklet/connectivities/UnionFind.h>
namespace vtkm
{
namespace worklet
{
namespace connectivity
{
namespace detail
{
class Graft : public vtkm::worklet::WorkletMapField
{
public:
@ -37,6 +45,7 @@ public:
WholeArrayInOut<IdType> comp);
typedef void ExecutionSignature(_1, _2, _3, _4, _5);
using InputDomain = _1;
// TODO: Use Scatter?
@ -57,7 +66,7 @@ public:
}
}
};
}
template <typename DeviceAdapter>
class GraphConnectivity
@ -83,7 +92,7 @@ public:
do
{
vtkm::worklet::DispatcherMapField<Graft, DeviceAdapter> graftDispatcher;
vtkm::worklet::DispatcherMapField<detail::Graft, DeviceAdapter> graftDispatcher;
graftDispatcher.Invoke(
cellIds, indexOffsetArray, numIndexArray, connectivityArray, components);
@ -114,4 +123,7 @@ public:
Algorithm::SortByKey(cellIdsOut, componentsOut);
}
};
}
}
}
#endif //vtk_m_worklet_connectivity_graph_connectivity_h

@ -29,6 +29,12 @@
#include <vtkm/worklet/ScatterCounting.h>
#include <vtkm/worklet/WorkletMapField.h>
namespace vtkm
{
namespace worklet
{
namespace connectivity
{
template <typename DeviceAdapter>
class InnerJoin
{
@ -106,4 +112,8 @@ public:
mergeDisp.Invoke(key1, value1, lbs, value2, keyOut, value1Out, value2Out);
}
};
}
}
} // vtkm::worklet::connectivity
#endif //vtk_m_worklet_connectivity_InnerJoin_h

@ -28,6 +28,8 @@
#include <vtkm/cont/testing/MakeTestDataSet.h>
#include <vtkm/cont/testing/Testing.h>
using namespace vtkm::worklet::connectivity;
class TangleField : public vtkm::worklet::WorkletMapField
{
public:

@ -25,10 +25,12 @@
#include <vtkm/worklet/connectivities/CellSetDualGraph.h>
using namespace vtkm::worklet::connectivity;
template <typename DeviceAdapter>
class TestCellSetDualGraph
{
public:
private:
template <typename T, typename Storage>
bool TestArrayHandle(const vtkm::cont::ArrayHandle<T, Storage>& ah,
const T* expected,
@ -50,6 +52,7 @@ public:
return true;
}
public:
void TestTriangleMesh() const
{
std::vector<vtkm::Id> connectivity = { 0, 2, 4, 1, 3, 5, 2, 6, 4, 5, 3, 7, 2, 9, 6, 4, 6, 8 };

@ -23,6 +23,8 @@
#include <vtkm/cont/testing/Testing.h>
#include <vtkm/worklet/connectivities/InnerJoin.h>
using namespace vtkm::worklet::connectivity;
template <typename DeviceAdapter>
class TestInnerJoin
{