mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-09-18 18:15:44 +00:00
Merge topic 'move_invoker_to_cont'
7e04b0511 Move Invoker into vtkm/cont Acked-by: Kitware Robot <kwrobot@kitware.com> Acked-by: Kenneth Moreland <kmorel@sandia.gov> Merge-request: !1745
This commit is contained in:
commit
2eeeafc1f5
@ -17,11 +17,9 @@
|
||||
#include <vtkm/cont/CellSetStructured.h>
|
||||
#include <vtkm/cont/ImplicitFunctionHandle.h>
|
||||
#include <vtkm/cont/Initialize.h>
|
||||
#include <vtkm/cont/Invoker.h>
|
||||
#include <vtkm/cont/Timer.h>
|
||||
|
||||
#include <vtkm/worklet/DispatcherMapField.h>
|
||||
#include <vtkm/worklet/DispatcherMapTopology.h>
|
||||
#include <vtkm/worklet/Invoker.h>
|
||||
#include <vtkm/worklet/WorkletMapField.h>
|
||||
#include <vtkm/worklet/WorkletMapTopology.h>
|
||||
|
||||
@ -529,7 +527,7 @@ private:
|
||||
Timer timer{ DeviceAdapter() };
|
||||
timer.Start();
|
||||
|
||||
vtkm::worklet::Invoker invoke(DeviceAdapter{});
|
||||
vtkm::cont::Invoker invoke(DeviceAdapter{});
|
||||
invoke(Mag{}, this->InputHandle, tempHandle1);
|
||||
invoke(Sin{}, tempHandle1, tempHandle2);
|
||||
invoke(Square{}, tempHandle2, tempHandle1);
|
||||
@ -567,7 +565,7 @@ private:
|
||||
Timer timer{ DeviceAdapter() };
|
||||
timer.Start();
|
||||
|
||||
vtkm::worklet::Invoker invoke(DeviceAdapter{});
|
||||
vtkm::cont::Invoker invoke(DeviceAdapter{});
|
||||
invoke(Mag{}, dinput, dtemp1);
|
||||
invoke(Sin{}, dtemp1, dtemp2);
|
||||
invoke(Square{}, dtemp2, dtemp1);
|
||||
@ -595,7 +593,7 @@ private:
|
||||
Timer timer{ DeviceAdapter() };
|
||||
timer.Start();
|
||||
|
||||
vtkm::worklet::Invoker invoke(DeviceAdapter{});
|
||||
vtkm::cont::Invoker invoke(DeviceAdapter{});
|
||||
invoke(Mag{}, mInput, mTemp1);
|
||||
invoke(Sin{}, mTemp1, mTemp2);
|
||||
invoke(Square{}, mTemp2, mTemp1);
|
||||
@ -632,7 +630,7 @@ private:
|
||||
Timer timer{ DeviceAdapter() };
|
||||
timer.Start();
|
||||
|
||||
vtkm::worklet::Invoker invoke(DeviceAdapter{});
|
||||
vtkm::cont::Invoker invoke(DeviceAdapter{});
|
||||
invoke(Mag{}, mInput, mTemp1);
|
||||
invoke(Sin{}, mTemp1, mTemp2);
|
||||
invoke(Square{}, mTemp2, mTemp1);
|
||||
|
6
docs/changelog/invoker-vtkm-cont.md
Normal file
6
docs/changelog/invoker-vtkm-cont.md
Normal file
@ -0,0 +1,6 @@
|
||||
# Invoker moved to vtkm::cont
|
||||
|
||||
Previously, `Invoker` was located in the `vtkm::worklet` namespace to convey
|
||||
it was a replacement for using `vtkm::worklet::Dispatcher*`. In actuality
|
||||
it should be in `vtkm::cont` as it is the proper way to launch worklets
|
||||
for execution, and that shouldn't exist inside the `worklet` namespace.
|
@ -89,6 +89,7 @@ set(headers
|
||||
FieldRangeGlobalCompute.h
|
||||
ImplicitFunctionHandle.h
|
||||
Initialize.h
|
||||
Invoker.h
|
||||
Logging.h
|
||||
MultiBlock.h
|
||||
PointLocator.h
|
||||
|
@ -22,9 +22,8 @@
|
||||
#include <vtkm/cont/DeviceAdapterAlgorithm.h>
|
||||
#include <vtkm/cont/ErrorBadDevice.h>
|
||||
#include <vtkm/exec/CellLocatorBoundingIntervalHierarchyExec.h>
|
||||
#include <vtkm/worklet/DispatcherMapField.h>
|
||||
#include <vtkm/worklet/DispatcherMapTopology.h>
|
||||
#include <vtkm/worklet/Invoker.h>
|
||||
|
||||
#include <vtkm/cont/Invoker.h>
|
||||
#include <vtkm/worklet/WorkletMapField.h>
|
||||
#include <vtkm/worklet/WorkletMapTopology.h>
|
||||
|
||||
@ -87,7 +86,7 @@ void CalculatePlaneSplitCost(vtkm::IdComponent planeIndex,
|
||||
vtkm::IdComponent index,
|
||||
vtkm::IdComponent numTotalPlanes)
|
||||
{
|
||||
vtkm::worklet::Invoker invoker;
|
||||
vtkm::cont::Invoker invoker;
|
||||
|
||||
// Make candidate split plane array
|
||||
vtkm::cont::ArrayHandle<vtkm::FloatDefault> splitPlanes;
|
||||
@ -182,7 +181,7 @@ IdArrayHandle CalculateSplitScatterIndices(const IdArrayHandle& cellIds,
|
||||
const IdArrayHandle& leqFlags,
|
||||
const IdArrayHandle& segmentIds)
|
||||
{
|
||||
vtkm::worklet::Invoker invoker;
|
||||
vtkm::cont::Invoker invoker;
|
||||
|
||||
// Count total number of true flags preceding in segment
|
||||
IdArrayHandle trueFlagCounts;
|
||||
@ -230,7 +229,7 @@ CellLocatorBoundingIntervalHierarchy::~CellLocatorBoundingIntervalHierarchy() =
|
||||
|
||||
void CellLocatorBoundingIntervalHierarchy::Build()
|
||||
{
|
||||
vtkm::worklet::Invoker invoker;
|
||||
vtkm::cont::Invoker invoker;
|
||||
|
||||
vtkm::cont::DynamicCellSet cellSet = this->GetCellSet();
|
||||
vtkm::Id numCells = cellSet.GetNumberOfCells();
|
||||
|
@ -14,7 +14,7 @@
|
||||
#include <vtkm/cont/ArrayHandleConstant.h>
|
||||
#include <vtkm/cont/ArrayHandleTransform.h>
|
||||
|
||||
#include <vtkm/worklet/Invoker.h>
|
||||
#include <vtkm/cont/Invoker.h>
|
||||
#include <vtkm/worklet/WorkletMapField.h>
|
||||
#include <vtkm/worklet/WorkletMapTopology.h>
|
||||
|
||||
@ -346,7 +346,7 @@ namespace cont
|
||||
///
|
||||
VTKM_CONT void CellLocatorUniformBins::Build()
|
||||
{
|
||||
vtkm::worklet::Invoker invoke;
|
||||
vtkm::cont::Invoker invoke;
|
||||
|
||||
auto cellset = this->GetCellSet();
|
||||
const auto& coords = this->GetCoordinates();
|
||||
|
@ -16,9 +16,9 @@
|
||||
#include <vtkm/cont/ArrayHandleCounting.h>
|
||||
#include <vtkm/cont/ArrayHandleExtrudeCoords.h>
|
||||
#include <vtkm/cont/CellSet.h>
|
||||
#include <vtkm/cont/Invoker.h>
|
||||
#include <vtkm/exec/ConnectivityExtrude.h>
|
||||
#include <vtkm/exec/arg/ThreadIndicesExtrude.h>
|
||||
#include <vtkm/worklet/Invoker.h>
|
||||
#include <vtkm/worklet/WorkletMapField.h>
|
||||
|
||||
namespace vtkm
|
||||
|
@ -50,7 +50,7 @@ namespace cont
|
||||
template <typename Device>
|
||||
VTKM_CONT void CellSetExtrude::BuildReverseConnectivity(Device)
|
||||
{
|
||||
vtkm::worklet::Invoker invoke(Device{});
|
||||
vtkm::cont::Invoker invoke(Device{});
|
||||
|
||||
// create a mapping of where each key is the point id and the value
|
||||
// is the cell id. We
|
||||
|
@ -15,7 +15,7 @@
|
||||
#include <vtkm/cont/TryExecute.h>
|
||||
#include <vtkm/cont/VirtualObjectHandle.h>
|
||||
|
||||
#include <vtkm/worklet/Invoker.h>
|
||||
#include <vtkm/cont/Invoker.h>
|
||||
#include <vtkm/worklet/colorconversion/LookupTable.h>
|
||||
#include <vtkm/worklet/colorconversion/Portals.h>
|
||||
#include <vtkm/worklet/colorconversion/TransferFunction.h>
|
||||
@ -79,7 +79,7 @@ struct map_color_table
|
||||
inline bool operator()(DeviceAdapter device, ColorTable&& colors, Args&&... args) const
|
||||
{
|
||||
vtkm::worklet::colorconversion::TransferFunction transfer(colors->PrepareForExecution(device));
|
||||
vtkm::worklet::Invoker invoke(device);
|
||||
vtkm::cont::Invoker invoke(device);
|
||||
invoke(transfer, std::forward<Args>(args)...);
|
||||
return true;
|
||||
}
|
||||
@ -97,7 +97,7 @@ bool ColorTable::Map(const vtkm::cont::ArrayHandle<T, S>& values,
|
||||
return false;
|
||||
}
|
||||
vtkm::worklet::colorconversion::LookupTable lookupTable(samples);
|
||||
vtkm::worklet::Invoker invoke(vtkm::cont::DeviceAdapterTagAny{});
|
||||
vtkm::cont::Invoker invoke(vtkm::cont::DeviceAdapterTagAny{});
|
||||
invoke(lookupTable, values, samples.Samples, rgbaOut);
|
||||
return true;
|
||||
}
|
||||
@ -112,7 +112,7 @@ bool ColorTable::Map(const vtkm::cont::ArrayHandle<T, S>& values,
|
||||
return false;
|
||||
}
|
||||
vtkm::worklet::colorconversion::LookupTable lookupTable(samples);
|
||||
vtkm::worklet::Invoker invoke(vtkm::cont::DeviceAdapterTagAny{});
|
||||
vtkm::cont::Invoker invoke(vtkm::cont::DeviceAdapterTagAny{});
|
||||
invoke(lookupTable, values, samples.Samples, rgbOut);
|
||||
return true;
|
||||
}
|
||||
|
@ -7,8 +7,8 @@
|
||||
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
// PURPOSE. See the above copyright notice for more information.
|
||||
//============================================================================
|
||||
#ifndef vtk_m_worklet_Invoker_h
|
||||
#define vtk_m_worklet_Invoker_h
|
||||
#ifndef vtk_m_cont_Invoker_h
|
||||
#define vtk_m_cont_Invoker_h
|
||||
|
||||
#include <vtkm/worklet/DispatcherMapField.h>
|
||||
#include <vtkm/worklet/DispatcherMapTopology.h>
|
||||
@ -19,7 +19,7 @@
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace worklet
|
||||
namespace cont
|
||||
{
|
||||
|
||||
|
||||
@ -56,15 +56,16 @@ struct Invoker
|
||||
/// Optional second parameter is the scatter type associated with the worklet.
|
||||
/// Any additional parameters are the ControlSignature arguments for the worklet.
|
||||
///
|
||||
template <typename Worklet,
|
||||
template <
|
||||
typename Worklet,
|
||||
typename T,
|
||||
typename... Args,
|
||||
typename std::enable_if<
|
||||
std::is_base_of<internal::ScatterBase, internal::detail::remove_cvref<T>>::value,
|
||||
typename std::enable_if<std::is_base_of<worklet::internal::ScatterBase,
|
||||
worklet::internal::detail::remove_cvref<T>>::value,
|
||||
int>::type* = nullptr>
|
||||
inline void operator()(Worklet&& worklet, T&& scatter, Args&&... args) const
|
||||
{
|
||||
using WorkletType = internal::detail::remove_cvref<Worklet>;
|
||||
using WorkletType = worklet::internal::detail::remove_cvref<Worklet>;
|
||||
using DispatcherType = typename WorkletType::template Dispatcher<WorkletType>;
|
||||
|
||||
DispatcherType dispatcher(worklet, scatter);
|
||||
@ -76,15 +77,16 @@ struct Invoker
|
||||
/// Optional second parameter is the scatter type associated with the worklet.
|
||||
/// Any additional parameters are the ControlSignature arguments for the worklet.
|
||||
///
|
||||
template <typename Worklet,
|
||||
template <
|
||||
typename Worklet,
|
||||
typename T,
|
||||
typename... Args,
|
||||
typename std::enable_if<
|
||||
!std::is_base_of<internal::ScatterBase, internal::detail::remove_cvref<T>>::value,
|
||||
typename std::enable_if<!std::is_base_of<worklet::internal::ScatterBase,
|
||||
worklet::internal::detail::remove_cvref<T>>::value,
|
||||
int>::type* = nullptr>
|
||||
inline void operator()(Worklet&& worklet, T&& t, Args&&... args) const
|
||||
{
|
||||
using WorkletType = internal::detail::remove_cvref<Worklet>;
|
||||
using WorkletType = worklet::internal::detail::remove_cvref<Worklet>;
|
||||
using DispatcherType = typename WorkletType::template Dispatcher<WorkletType>;
|
||||
|
||||
DispatcherType dispatcher(worklet);
|
@ -14,14 +14,13 @@
|
||||
#include <vtkm/cont/ArrayHandleCounting.h>
|
||||
#include <vtkm/cont/BitField.h>
|
||||
#include <vtkm/cont/DeviceAdapterAlgorithm.h>
|
||||
#include <vtkm/cont/Invoker.h>
|
||||
#include <vtkm/cont/RuntimeDeviceTracker.h>
|
||||
|
||||
#include <vtkm/cont/testing/Testing.h>
|
||||
|
||||
#include <vtkm/exec/FunctorBase.h>
|
||||
|
||||
#include <vtkm/worklet/Invoker.h>
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
#define DEVICE_ASSERT_MSG(cond, message) \
|
||||
@ -599,7 +598,7 @@ struct TestingBitField
|
||||
auto falseArray = vtkm::cont::make_ArrayHandleCounting<vtkm::Id>(13, 2, NUM_BITS);
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> output;
|
||||
|
||||
vtkm::worklet::Invoker invoke;
|
||||
vtkm::cont::Invoker invoke;
|
||||
invoke(ConditionalMergeWorklet{}, condArray, trueArray, falseArray, output);
|
||||
|
||||
auto condVals = condArray.GetPortalConstControl();
|
||||
@ -625,7 +624,7 @@ struct TestingBitField
|
||||
auto falseArray = vtkm::cont::make_ArrayHandleCounting<vtkm::Id>(13, 2, NUM_BITS);
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> output;
|
||||
|
||||
vtkm::worklet::Invoker invoke;
|
||||
vtkm::cont::Invoker invoke;
|
||||
invoke(ConditionalMergeWorklet2{}, condBits, trueArray, falseArray, output);
|
||||
|
||||
auto condVals = condBits.GetPortalConstControl();
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include <vtkm/cont/Algorithm.h>
|
||||
#include <vtkm/cont/DeviceAdapter.h>
|
||||
#include <vtkm/cont/DeviceAdapterAlgorithm.h>
|
||||
#include <vtkm/cont/Invoker.h>
|
||||
#include <vtkm/cont/RuntimeDeviceTracker.h>
|
||||
#include <vtkm/cont/TryExecute.h>
|
||||
|
||||
@ -27,7 +28,6 @@
|
||||
#include <vtkm/rendering/raytracing/RayTracingTypeDefs.h>
|
||||
#include <vtkm/rendering/raytracing/Worklets.h>
|
||||
|
||||
#include <vtkm/worklet/Invoker.h>
|
||||
#include <vtkm/worklet/WorkletMapField.h>
|
||||
|
||||
#define AABB_EPSILON 0.00001f
|
||||
|
@ -33,7 +33,6 @@ set(headers
|
||||
FieldHistogram.h
|
||||
FieldStatistics.h
|
||||
Gradient.h
|
||||
Invoker.h
|
||||
KdTree3D.h
|
||||
KernelSplatter.h
|
||||
Keys.h
|
||||
|
@ -13,7 +13,6 @@
|
||||
#include <vtkm/worklet/AverageByKey.h>
|
||||
#include <vtkm/worklet/DispatcherMapField.h>
|
||||
#include <vtkm/worklet/DispatcherReduceByKey.h>
|
||||
#include <vtkm/worklet/Invoker.h>
|
||||
#include <vtkm/worklet/Keys.h>
|
||||
#include <vtkm/worklet/RemoveUnusedPoints.h>
|
||||
#include <vtkm/worklet/WorkletMapField.h>
|
||||
@ -25,6 +24,7 @@
|
||||
#include <vtkm/cont/ArrayHandleVirtual.h>
|
||||
#include <vtkm/cont/CellSetExplicit.h>
|
||||
#include <vtkm/cont/ExecutionAndControlObjectBase.h>
|
||||
#include <vtkm/cont/Invoker.h>
|
||||
|
||||
#include <vtkm/Bounds.h>
|
||||
#include <vtkm/Hash.h>
|
||||
@ -335,7 +335,7 @@ private:
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec<T, 3>>& points, // coordinates, modified to merge close
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> indexNeighborMap) // identifies each neighbor group, updated
|
||||
{
|
||||
Invoker invoker;
|
||||
vtkm::cont::Invoker invoker;
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::HashType> hashes;
|
||||
invoker(CoordsToHash(), points, binLocator, hashes);
|
||||
@ -357,7 +357,7 @@ public:
|
||||
const vtkm::Bounds& bounds, // Bounds of points
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec<T, 3>>& points) // coordinates, modified to merge close
|
||||
{
|
||||
Invoker invoker;
|
||||
vtkm::cont::Invoker invoker;
|
||||
|
||||
BinLocator binLocator(bounds, delta);
|
||||
|
||||
|
@ -11,12 +11,12 @@
|
||||
#define vtk_m_worklet_SplitSharpEdges_h
|
||||
|
||||
#include <vtkm/worklet/CellDeepCopy.h>
|
||||
#include <vtkm/worklet/Invoker.h>
|
||||
|
||||
#include <vtkm/cont/Algorithm.h>
|
||||
#include <vtkm/cont/ArrayCopy.h>
|
||||
#include <vtkm/cont/ArrayHandleCounting.h>
|
||||
#include <vtkm/cont/ArrayHandlePermutation.h>
|
||||
#include <vtkm/cont/Invoker.h>
|
||||
#include <vtkm/exec/CellEdge.h>
|
||||
|
||||
#include <vtkm/Bitset.h>
|
||||
@ -400,7 +400,7 @@ public:
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec<CoordsComType, 3>, CoordsOutStorageType>& newCoords,
|
||||
NewCellSetType& newCellset)
|
||||
{
|
||||
vtkm::worklet::Invoker invoke;
|
||||
vtkm::cont::Invoker invoke;
|
||||
|
||||
const vtkm::FloatDefault featureAngleR =
|
||||
featureAngle / static_cast<vtkm::FloatDefault>(180.0) * vtkm::Pi<vtkm::FloatDefault>();
|
||||
|
@ -19,8 +19,8 @@
|
||||
#include <vtkm/cont/DataSet.h>
|
||||
#include <vtkm/cont/DeviceAdapter.h>
|
||||
#include <vtkm/cont/Field.h>
|
||||
#include <vtkm/cont/Invoker.h>
|
||||
|
||||
#include <vtkm/worklet/Invoker.h>
|
||||
#include <vtkm/worklet/ScatterUniform.h>
|
||||
#include <vtkm/worklet/WorkletMapField.h>
|
||||
|
||||
@ -375,7 +375,7 @@ public:
|
||||
// Worklet to make the streamlines
|
||||
streamline::MakeStreamLines<FieldType> makeStreamLines(timeStep, streamMode, maxSteps, vdims);
|
||||
|
||||
vtkm::worklet::Invoker{}(
|
||||
vtkm::cont::Invoker{}(
|
||||
makeStreamLines, fieldArray, seedIdArray, seedPosArray, numIndices, validPoint, streamArray);
|
||||
|
||||
// Size of connectivity based on size of returned streamlines
|
||||
|
@ -97,7 +97,7 @@
|
||||
#include <vtkm/cont/ArrayHandlePermutation.h>
|
||||
#include <vtkm/cont/ArrayHandleTransform.h>
|
||||
#include <vtkm/cont/ArrayPortalToIterators.h>
|
||||
#include <vtkm/worklet/Invoker.h>
|
||||
#include <vtkm/cont/Invoker.h>
|
||||
|
||||
|
||||
namespace active_graph_inc_ns = vtkm::worklet::contourtree_augmented::active_graph_inc;
|
||||
@ -114,7 +114,7 @@ namespace contourtree_augmented
|
||||
class ActiveGraph
|
||||
{ // class ActiveGraph
|
||||
public:
|
||||
vtkm::worklet::Invoker Invoke;
|
||||
vtkm::cont::Invoker Invoke;
|
||||
|
||||
// we also need the orientation of the edges (i.e. is it join or split)
|
||||
bool isJoinGraph;
|
||||
|
@ -95,7 +95,7 @@
|
||||
#include <vtkm/cont/ArrayHandleIndex.h>
|
||||
#include <vtkm/cont/ArrayHandlePermutation.h>
|
||||
#include <vtkm/cont/ArrayHandleTransform.h>
|
||||
#include <vtkm/worklet/Invoker.h>
|
||||
#include <vtkm/cont/Invoker.h>
|
||||
|
||||
|
||||
|
||||
@ -113,7 +113,7 @@ namespace contourtree_augmented
|
||||
class ContourTreeMaker
|
||||
{ // class MergeTree
|
||||
public:
|
||||
vtkm::worklet::Invoker Invoke;
|
||||
vtkm::cont::Invoker Invoke;
|
||||
|
||||
// the contour tree, join tree & split tree to use
|
||||
ContourTree& contourTree;
|
||||
|
@ -58,7 +58,7 @@
|
||||
// local includes
|
||||
#include <vtkm/cont/Algorithm.h>
|
||||
#include <vtkm/cont/ArrayHandleConstant.h>
|
||||
#include <vtkm/worklet/Invoker.h>
|
||||
#include <vtkm/cont/Invoker.h>
|
||||
#include <vtkm/worklet/contourtree_augmented/PointerDoubling.h>
|
||||
#include <vtkm/worklet/contourtree_augmented/PrintVectors.h>
|
||||
#include <vtkm/worklet/contourtree_augmented/Types.h>
|
||||
@ -79,7 +79,7 @@ namespace contourtree_augmented
|
||||
class MeshExtrema
|
||||
{ // MeshExtrema
|
||||
public:
|
||||
vtkm::worklet::Invoker Invoke;
|
||||
vtkm::cont::Invoker Invoke;
|
||||
// arrays for peaks & pits
|
||||
IdArrayType peaks;
|
||||
IdArrayType pits;
|
||||
|
@ -78,7 +78,7 @@
|
||||
#include <vtkm/cont/ArrayHandle.h>
|
||||
#include <vtkm/cont/ArrayHandleIndex.h>
|
||||
#include <vtkm/cont/ArrayHandlePermutation.h>
|
||||
#include <vtkm/worklet/Invoker.h>
|
||||
#include <vtkm/cont/Invoker.h>
|
||||
|
||||
#include <vtkm/worklet/contourtree_augmented/PrintVectors.h>
|
||||
#include <vtkm/worklet/contourtree_augmented/Types.h>
|
||||
@ -244,7 +244,7 @@ void Mesh_DEM_Triangulation<T, StorageType>::SortData(
|
||||
// for (indexType vertex = 0; vertex < nVertices; vertex++)
|
||||
// sortIndices[sortOrder[vertex]] = vertex;
|
||||
mesh_dem_worklets::SortIndices sortIndicesWorklet;
|
||||
vtkm::worklet::Invoker invoke;
|
||||
vtkm::cont::Invoker invoke;
|
||||
invoke(sortIndicesWorklet, sortOrder, sortIndices);
|
||||
|
||||
// Debug print statement
|
||||
|
@ -76,7 +76,7 @@
|
||||
#include <vtkm/cont/ArrayHandleIndex.h>
|
||||
#include <vtkm/cont/ArrayHandleReverse.h>
|
||||
#include <vtkm/cont/ArrayHandleTransform.h>
|
||||
#include <vtkm/worklet/Invoker.h>
|
||||
#include <vtkm/cont/Invoker.h>
|
||||
#include <vtkm/worklet/ScatterCounting.h>
|
||||
|
||||
#include <vtkm/BinaryPredicates.h>
|
||||
|
@ -316,7 +316,7 @@ void CosmoTools<T, StorageType>::MBPCenterFindingByHalo(vtkm::cont::ArrayHandle<
|
||||
|
||||
// Setup the ScatterCounting worklets needed to expand the ReduceByKeyResults
|
||||
vtkm::worklet::ScatterCounting scatter(particlesPerHalo);
|
||||
vtkm::worklet::Invoker invoke;
|
||||
vtkm::cont::Invoker invoke;
|
||||
|
||||
// Calculate the minimum particle index per halo id and scatter
|
||||
DeviceAlgorithm::ScanExclusive(particlesPerHalo, tempI);
|
||||
|
@ -12,12 +12,12 @@
|
||||
#include <vtkm/cont/ArrayHandleConcatenate.h>
|
||||
#include <vtkm/cont/CellLocatorBoundingIntervalHierarchy.h>
|
||||
#include <vtkm/cont/DataSetBuilderUniform.h>
|
||||
#include <vtkm/cont/Invoker.h>
|
||||
#include <vtkm/cont/Timer.h>
|
||||
#include <vtkm/cont/testing/Testing.h>
|
||||
#include <vtkm/exec/CellInterpolate.h>
|
||||
#include <vtkm/exec/ParametricCoordinates.h>
|
||||
#include <vtkm/io/reader/VTKDataSetReader.h>
|
||||
#include <vtkm/worklet/Invoker.h>
|
||||
|
||||
namespace
|
||||
{
|
||||
|
354
vtkm/worklet/testing/UnitTestClippingWithFunction.cxx
Normal file
354
vtkm/worklet/testing/UnitTestClippingWithFunction.cxx
Normal file
@ -0,0 +1,354 @@
|
||||
//============================================================================
|
||||
// Copyright (c) Kitware, Inc.
|
||||
// All rights reserved.
|
||||
// See LICENSE.txt for details.
|
||||
//
|
||||
// This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
// PURPOSE. See the above copyright notice for more information.
|
||||
//============================================================================
|
||||
|
||||
#include <vtkm/worklet/Clip.h>
|
||||
|
||||
#include <vtkm/cont/CellSet.h>
|
||||
#include <vtkm/cont/CellSetExplicit.h>
|
||||
#include <vtkm/cont/CellSetStructured.h>
|
||||
#include <vtkm/cont/CoordinateSystem.h>
|
||||
#include <vtkm/cont/DataSet.h>
|
||||
#include <vtkm/cont/DataSetBuilderExplicit.h>
|
||||
#include <vtkm/cont/DataSetBuilderUniform.h>
|
||||
#include <vtkm/cont/DataSetFieldAdd.h>
|
||||
#include <vtkm/cont/Field.h>
|
||||
#include <vtkm/cont/ImplicitFunctionHandle.h>
|
||||
#include <vtkm/cont/testing/Testing.h>
|
||||
|
||||
|
||||
#include <vector>
|
||||
|
||||
using Coord3D = vtkm::Vec<vtkm::FloatDefault, 3>;
|
||||
|
||||
const vtkm::Float32 clipValue = 0.5;
|
||||
|
||||
template <typename T, typename Storage>
|
||||
bool TestArrayHandle(const vtkm::cont::ArrayHandle<T, Storage>& ah,
|
||||
const T* expected,
|
||||
vtkm::Id size)
|
||||
{
|
||||
if (size != ah.GetNumberOfValues())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
for (vtkm::Id i = 0; i < size; ++i)
|
||||
{
|
||||
if (ah.GetPortalConstControl().Get(i) != expected[i])
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
vtkm::cont::DataSet MakeTestDatasetExplicit()
|
||||
{
|
||||
std::vector<Coord3D> coords;
|
||||
coords.push_back(Coord3D(0.0f, 0.0f, 0.0f));
|
||||
coords.push_back(Coord3D(1.0f, 0.0f, 0.0f));
|
||||
coords.push_back(Coord3D(1.0f, 1.0f, 0.0f));
|
||||
coords.push_back(Coord3D(0.0f, 1.0f, 0.0f));
|
||||
|
||||
std::vector<vtkm::Id> connectivity;
|
||||
connectivity.push_back(0);
|
||||
connectivity.push_back(1);
|
||||
connectivity.push_back(3);
|
||||
connectivity.push_back(3);
|
||||
connectivity.push_back(1);
|
||||
connectivity.push_back(2);
|
||||
|
||||
vtkm::cont::DataSet ds;
|
||||
vtkm::cont::DataSetBuilderExplicit builder;
|
||||
ds = builder.Create(coords, vtkm::CellShapeTagTriangle(), 3, connectivity, "coords");
|
||||
|
||||
vtkm::cont::DataSetFieldAdd fieldAdder;
|
||||
|
||||
std::vector<vtkm::Float32> values;
|
||||
values.push_back(1.0);
|
||||
values.push_back(2.0);
|
||||
values.push_back(1.0);
|
||||
values.push_back(0.0);
|
||||
fieldAdder.AddPointField(ds, "scalars", values);
|
||||
|
||||
values.clear();
|
||||
values.push_back(100.f);
|
||||
values.push_back(-100.f);
|
||||
fieldAdder.AddCellField(ds, "cellvar", values);
|
||||
|
||||
return ds;
|
||||
}
|
||||
|
||||
vtkm::cont::DataSet MakeTestDatasetStructured()
|
||||
{
|
||||
static constexpr vtkm::Id xdim = 3, ydim = 3;
|
||||
static const vtkm::Id2 dim(xdim, ydim);
|
||||
static constexpr vtkm::Id numVerts = xdim * ydim;
|
||||
|
||||
vtkm::Float32 scalars[numVerts];
|
||||
for (vtkm::Id i = 0; i < numVerts; ++i)
|
||||
{
|
||||
scalars[i] = 1.0f;
|
||||
}
|
||||
scalars[4] = 0.0f;
|
||||
|
||||
vtkm::cont::DataSet ds;
|
||||
vtkm::cont::DataSetBuilderUniform builder;
|
||||
ds = builder.Create(dim);
|
||||
|
||||
vtkm::cont::DataSetFieldAdd fieldAdder;
|
||||
fieldAdder.AddPointField(ds, "scalars", scalars, numVerts);
|
||||
|
||||
std::vector<vtkm::Float32> cellvar = { -100.f, 100.f, 30.f, -30.f };
|
||||
fieldAdder.AddCellField(ds, "cellvar", cellvar);
|
||||
|
||||
return ds;
|
||||
}
|
||||
|
||||
void TestClippingExplicit()
|
||||
{
|
||||
vtkm::cont::DataSet ds = MakeTestDatasetExplicit();
|
||||
vtkm::worklet::Clip clip;
|
||||
bool invertClip = false;
|
||||
vtkm::cont::CellSetExplicit<> outputCellSet =
|
||||
clip.Run(ds.GetCellSet(0),
|
||||
ds.GetField("scalars").GetData().ResetTypes(vtkm::TypeListTagFieldScalar()),
|
||||
clipValue,
|
||||
invertClip);
|
||||
|
||||
auto coordsIn = ds.GetCoordinateSystem("coords").GetData();
|
||||
vtkm::cont::ArrayHandle<Coord3D> coords = clip.ProcessPointField(coordsIn);
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> scalarsIn;
|
||||
ds.GetField("scalars").GetData().CopyTo(scalarsIn);
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> scalars = clip.ProcessPointField(scalarsIn);
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> cellvarIn;
|
||||
ds.GetField("cellvar").GetData().CopyTo(cellvarIn);
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> cellvar = clip.ProcessCellField(cellvarIn);
|
||||
|
||||
vtkm::Id connectivitySize = 8;
|
||||
vtkm::Id fieldSize = 7;
|
||||
vtkm::Id expectedConnectivity[] = { 0, 1, 5, 4, 1, 2, 6, 5 };
|
||||
const Coord3D expectedCoords[] = {
|
||||
Coord3D(0.00f, 0.00f, 0.0f), Coord3D(1.00f, 0.00f, 0.0f), Coord3D(1.00f, 1.00f, 0.0f),
|
||||
Coord3D(0.00f, 1.00f, 0.0f), Coord3D(0.00f, 0.50f, 0.0f), Coord3D(0.25f, 0.75f, 0.0f),
|
||||
Coord3D(0.50f, 1.00f, 0.0f),
|
||||
};
|
||||
const vtkm::Float32 expectedScalars[] = { 1, 2, 1, 0, 0.5, 0.5, 0.5 };
|
||||
std::vector<vtkm::Float32> expectedCellvar = { 100.f, -100.f };
|
||||
|
||||
VTKM_TEST_ASSERT(outputCellSet.GetNumberOfPoints() == fieldSize,
|
||||
"Wrong number of points in cell set.");
|
||||
|
||||
VTKM_TEST_ASSERT(
|
||||
TestArrayHandle(outputCellSet.GetConnectivityArray(vtkm::TopologyElementTagPoint(),
|
||||
vtkm::TopologyElementTagCell()),
|
||||
expectedConnectivity,
|
||||
connectivitySize),
|
||||
"Got incorrect conectivity");
|
||||
|
||||
VTKM_TEST_ASSERT(TestArrayHandle(coords, expectedCoords, fieldSize), "Got incorrect coordinates");
|
||||
|
||||
VTKM_TEST_ASSERT(TestArrayHandle(scalars, expectedScalars, fieldSize), "Got incorrect scalars");
|
||||
|
||||
VTKM_TEST_ASSERT(
|
||||
TestArrayHandle(cellvar, expectedCellvar.data(), static_cast<vtkm::Id>(expectedCellvar.size())),
|
||||
"Got incorrect cellvar");
|
||||
}
|
||||
|
||||
void TestClippingStructured()
|
||||
{
|
||||
using CoordsValueType = vtkm::cont::ArrayHandleUniformPointCoordinates::ValueType;
|
||||
using CoordsOutType = vtkm::cont::ArrayHandle<CoordsValueType>;
|
||||
|
||||
vtkm::cont::DataSet ds = MakeTestDatasetStructured();
|
||||
|
||||
bool invertClip = false;
|
||||
vtkm::worklet::Clip clip;
|
||||
vtkm::cont::CellSetExplicit<> outputCellSet =
|
||||
clip.Run(ds.GetCellSet(0),
|
||||
ds.GetField("scalars").GetData().ResetTypes(vtkm::TypeListTagFieldScalar()),
|
||||
clipValue,
|
||||
invertClip);
|
||||
|
||||
auto coordsIn = ds.GetCoordinateSystem("coords").GetData();
|
||||
CoordsOutType coords = clip.ProcessPointField(coordsIn);
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> scalarsIn;
|
||||
ds.GetField("scalars").GetData().CopyTo(scalarsIn);
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> scalars = clip.ProcessPointField(scalarsIn);
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> cellvarIn;
|
||||
ds.GetField("cellvar").GetData().CopyTo(cellvarIn);
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> cellvar = clip.ProcessCellField(cellvarIn);
|
||||
|
||||
|
||||
vtkm::Id connectivitySize = 28;
|
||||
vtkm::Id fieldSize = 13;
|
||||
const vtkm::Id expectedConnectivity[] = { 9, 10, 3, 1, 1, 3, 0, 11, 9, 1, 5, 5, 1, 2,
|
||||
10, 12, 7, 3, 3, 7, 6, 12, 11, 5, 7, 7, 5, 8 };
|
||||
|
||||
const Coord3D expectedCoords[] = {
|
||||
Coord3D(0.0f, 0.0f, 0.0f), Coord3D(1.0f, 0.0f, 0.0f), Coord3D(2.0f, 0.0f, 0.0f),
|
||||
Coord3D(0.0f, 1.0f, 0.0f), Coord3D(1.0f, 1.0f, 0.0f), Coord3D(2.0f, 1.0f, 0.0f),
|
||||
Coord3D(0.0f, 2.0f, 0.0f), Coord3D(1.0f, 2.0f, 0.0f), Coord3D(2.0f, 2.0f, 0.0f),
|
||||
Coord3D(1.0f, 0.5f, 0.0f), Coord3D(0.5f, 1.0f, 0.0f), Coord3D(1.5f, 1.0f, 0.0f),
|
||||
Coord3D(1.0f, 1.5f, 0.0f),
|
||||
};
|
||||
const vtkm::Float32 expectedScalars[] = { 1, 1, 1, 1, 0, 1, 1, 1, 1, 0.5, 0.5, 0.5, 0.5 };
|
||||
std::vector<vtkm::Float32> expectedCellvar = { -100.f, -100.f, 100.f, 100.f,
|
||||
30.f, 30.f, -30.f, -30.f };
|
||||
|
||||
VTKM_TEST_ASSERT(outputCellSet.GetNumberOfPoints() == fieldSize,
|
||||
"Wrong number of points in cell set.");
|
||||
|
||||
VTKM_TEST_ASSERT(
|
||||
TestArrayHandle(outputCellSet.GetConnectivityArray(vtkm::TopologyElementTagPoint(),
|
||||
vtkm::TopologyElementTagCell()),
|
||||
expectedConnectivity,
|
||||
connectivitySize),
|
||||
"Got incorrect conectivity");
|
||||
|
||||
VTKM_TEST_ASSERT(TestArrayHandle(coords, expectedCoords, fieldSize), "Got incorrect coordinates");
|
||||
|
||||
VTKM_TEST_ASSERT(TestArrayHandle(scalars, expectedScalars, fieldSize), "Got incorrect scalars");
|
||||
|
||||
VTKM_TEST_ASSERT(
|
||||
TestArrayHandle(cellvar, expectedCellvar.data(), static_cast<vtkm::Id>(expectedCellvar.size())),
|
||||
"Got incorrect cellvar");
|
||||
}
|
||||
|
||||
void TestClippingWithImplicitFunction()
|
||||
{
|
||||
vtkm::Vec<vtkm::FloatDefault, 3> center(1, 1, 0);
|
||||
vtkm::FloatDefault radius(0.5);
|
||||
|
||||
vtkm::cont::DataSet ds = MakeTestDatasetStructured();
|
||||
|
||||
bool invertClip = false;
|
||||
vtkm::worklet::Clip clip;
|
||||
vtkm::cont::CellSetExplicit<> outputCellSet =
|
||||
clip.Run(ds.GetCellSet(0),
|
||||
vtkm::cont::make_ImplicitFunctionHandle<vtkm::Sphere>(center, radius),
|
||||
ds.GetCoordinateSystem("coords"),
|
||||
invertClip);
|
||||
|
||||
auto coordsIn = ds.GetCoordinateSystem("coords").GetData();
|
||||
vtkm::cont::ArrayHandle<Coord3D> coords = clip.ProcessPointField(coordsIn);
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> scalarsIn;
|
||||
ds.GetField("scalars").GetData().CopyTo(scalarsIn);
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> scalars = clip.ProcessPointField(scalarsIn);
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> cellvarIn;
|
||||
ds.GetField("cellvar").GetData().CopyTo(cellvarIn);
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> cellvar = clip.ProcessCellField(cellvarIn);
|
||||
|
||||
vtkm::Id connectivitySize = 28;
|
||||
vtkm::Id fieldSize = 13;
|
||||
|
||||
const vtkm::Id expectedConnectivity[] = { 9, 10, 3, 1, 1, 3, 0, 11, 9, 1, 5, 5, 1, 2,
|
||||
10, 12, 7, 3, 3, 7, 6, 12, 11, 5, 7, 7, 5, 8 };
|
||||
|
||||
const Coord3D expectedCoords[] = {
|
||||
Coord3D(0.0f, 0.0f, 0.0f), Coord3D(1.0f, 0.0f, 0.0f), Coord3D(2.0f, 0.0f, 0.0f),
|
||||
Coord3D(0.0f, 1.0f, 0.0f), Coord3D(1.0f, 1.0f, 0.0f), Coord3D(2.0f, 1.0f, 0.0f),
|
||||
Coord3D(0.0f, 2.0f, 0.0f), Coord3D(1.0f, 2.0f, 0.0f), Coord3D(2.0f, 2.0f, 0.0f),
|
||||
Coord3D(1.0f, 0.75f, 0.0f), Coord3D(0.75f, 1.0f, 0.0f), Coord3D(1.25f, 1.0f, 0.0f),
|
||||
Coord3D(1.0f, 1.25f, 0.0f),
|
||||
};
|
||||
const vtkm::Float32 expectedScalars[] = { 1, 1, 1, 1, 0, 1, 1, 1, 1, 0.25, 0.25, 0.25, 0.25 };
|
||||
std::vector<vtkm::Float32> expectedCellvar = { -100.f, -100.f, 100.f, 100.f,
|
||||
30.f, 30.f, -30.f, -30.f };
|
||||
|
||||
VTKM_TEST_ASSERT(
|
||||
TestArrayHandle(outputCellSet.GetConnectivityArray(vtkm::TopologyElementTagPoint(),
|
||||
vtkm::TopologyElementTagCell()),
|
||||
expectedConnectivity,
|
||||
connectivitySize),
|
||||
"Got incorrect conectivity");
|
||||
|
||||
VTKM_TEST_ASSERT(TestArrayHandle(coords, expectedCoords, fieldSize), "Got incorrect coordinates");
|
||||
|
||||
VTKM_TEST_ASSERT(TestArrayHandle(scalars, expectedScalars, fieldSize), "Got incorrect scalars");
|
||||
|
||||
VTKM_TEST_ASSERT(
|
||||
TestArrayHandle(cellvar, expectedCellvar.data(), static_cast<vtkm::Id>(expectedCellvar.size())),
|
||||
"Got incorrect cellvar");
|
||||
}
|
||||
|
||||
void TestClippingWithImplicitFunctionInverted()
|
||||
{
|
||||
vtkm::Vec<vtkm::FloatDefault, 3> center(1, 1, 0);
|
||||
vtkm::FloatDefault radius(0.5);
|
||||
|
||||
vtkm::cont::DataSet ds = MakeTestDatasetStructured();
|
||||
|
||||
bool invertClip = true;
|
||||
vtkm::worklet::Clip clip;
|
||||
vtkm::cont::CellSetExplicit<> outputCellSet =
|
||||
clip.Run(ds.GetCellSet(0),
|
||||
vtkm::cont::make_ImplicitFunctionHandle<vtkm::Sphere>(center, radius),
|
||||
ds.GetCoordinateSystem("coords"),
|
||||
invertClip);
|
||||
|
||||
auto coordsIn = ds.GetCoordinateSystem("coords").GetData();
|
||||
vtkm::cont::ArrayHandle<Coord3D> coords = clip.ProcessPointField(coordsIn);
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> scalarsIn;
|
||||
ds.GetField("scalars").GetData().CopyTo(scalarsIn);
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> scalars = clip.ProcessPointField(scalarsIn);
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> cellvarIn;
|
||||
ds.GetField("cellvar").GetData().CopyTo(cellvarIn);
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> cellvar = clip.ProcessCellField(cellvarIn);
|
||||
|
||||
vtkm::Id connectivitySize = 12;
|
||||
vtkm::Id fieldSize = 13;
|
||||
vtkm::Id expectedConnectivity[] = { 10, 9, 4, 9, 11, 4, 12, 10, 4, 11, 12, 4 };
|
||||
const Coord3D expectedCoords[] = {
|
||||
Coord3D(0.0f, 0.0f, 0.0f), Coord3D(1.0f, 0.0f, 0.0f), Coord3D(2.0f, 0.0f, 0.0f),
|
||||
Coord3D(0.0f, 1.0f, 0.0f), Coord3D(1.0f, 1.0f, 0.0f), Coord3D(2.0f, 1.0f, 0.0f),
|
||||
Coord3D(0.0f, 2.0f, 0.0f), Coord3D(1.0f, 2.0f, 0.0f), Coord3D(2.0f, 2.0f, 0.0f),
|
||||
Coord3D(1.0f, 0.75f, 0.0f), Coord3D(0.75f, 1.0f, 0.0f), Coord3D(1.25f, 1.0f, 0.0f),
|
||||
Coord3D(1.0f, 1.25f, 0.0f),
|
||||
};
|
||||
vtkm::Float32 expectedScalars[] = { 1, 1, 1, 1, 0, 1, 1, 1, 1, 0.25, 0.25, 0.25, 0.25 };
|
||||
std::vector<vtkm::Float32> expectedCellvar = { -100.f, 100.f, 30.f, -30.f };
|
||||
|
||||
VTKM_TEST_ASSERT(
|
||||
TestArrayHandle(outputCellSet.GetConnectivityArray(vtkm::TopologyElementTagPoint(),
|
||||
vtkm::TopologyElementTagCell()),
|
||||
expectedConnectivity,
|
||||
connectivitySize),
|
||||
"Got incorrect conectivity");
|
||||
|
||||
VTKM_TEST_ASSERT(TestArrayHandle(coords, expectedCoords, fieldSize), "Got incorrect coordinates");
|
||||
|
||||
VTKM_TEST_ASSERT(TestArrayHandle(scalars, expectedScalars, fieldSize), "Got incorrect scalars");
|
||||
|
||||
VTKM_TEST_ASSERT(
|
||||
TestArrayHandle(cellvar, expectedCellvar.data(), static_cast<vtkm::Id>(expectedCellvar.size())),
|
||||
"Got incorrect cellvar");
|
||||
}
|
||||
|
||||
void TestClippingWithFunction()
|
||||
{
|
||||
std::cout << "Testing clipping with implicit function (sphere):" << std::endl;
|
||||
TestClippingWithImplicitFunction();
|
||||
TestClippingWithImplicitFunctionInverted();
|
||||
}
|
||||
|
||||
int UnitTestClippingWithFunction(int argc, char* argv[])
|
||||
{
|
||||
return vtkm::cont::testing::Testing::Run(TestClippingWithFunction, argc, argv);
|
||||
}
|
Loading…
Reference in New Issue
Block a user