VTK-m  2.0
worklet/VertexClustering.h
Go to the documentation of this file.
1 //============================================================================
2 // Copyright (c) Kitware, Inc.
3 // All rights reserved.
4 // See LICENSE.txt for details.
5 //
6 // This software is distributed WITHOUT ANY WARRANTY; without even
7 // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
8 // PURPOSE. See the above copyright notice for more information.
9 //============================================================================
10 #ifndef vtk_m_worklet_VertexClustering_h
11 #define vtk_m_worklet_VertexClustering_h
12 
13 #include <vtkm/BinaryOperators.h>
14 #include <vtkm/BinaryPredicates.h>
15 #include <vtkm/Types.h>
16 
17 #include <vtkm/cont/Algorithm.h>
18 #include <vtkm/cont/ArrayCopy.h>
19 #include <vtkm/cont/ArrayHandle.h>
24 #include <vtkm/cont/DataSet.h>
25 #include <vtkm/cont/Logging.h>
27 
31 #include <vtkm/worklet/Keys.h>
36 
37 //#define __VTKM_VERTEX_CLUSTERING_BENCHMARK
38 
39 #ifdef __VTKM_VERTEX_CLUSTERING_BENCHMARK
40 #include <vtkm/cont/Timer.h>
41 #endif
42 
43 namespace vtkm
44 {
45 namespace worklet
46 {
47 
48 namespace internal
49 {
50 
53 struct SelectRepresentativePoint : public vtkm::worklet::WorkletReduceByKey
54 {
55  using ControlSignature = void(KeysIn clusterIds, ValuesIn points, ReducedValuesOut repPoints);
56  using ExecutionSignature = _3(_2);
57  using InputDomain = _1;
58 
59  template <typename PointsInVecType>
60  VTKM_EXEC typename PointsInVecType::ComponentType operator()(
61  const PointsInVecType& pointsIn) const
62  {
63  // Grab the point from the middle of the set. This usually does a decent
64  // job of selecting a representative point that won't emphasize the cluster
65  // partitions.
66  //
67  // Note that we must use the stable sorting with the worklet::Keys for this
68  // to be reproducible across backends.
69  return pointsIn[pointsIn.GetNumberOfComponents() / 2];
70  }
71 
72  struct RunTrampoline
73  {
74  template <typename InputPointsArrayType, typename KeyType>
75  VTKM_CONT void operator()(const InputPointsArrayType& points,
76  const vtkm::worklet::Keys<KeyType>& keys,
77  vtkm::cont::UnknownArrayHandle& output) const
78  {
79 
82  dispatcher.Invoke(keys, points, out);
83 
84  output = out;
85  }
86  };
87 
88  template <typename KeyType, typename InputDynamicPointsArrayType>
90  const vtkm::worklet::Keys<KeyType>& keys,
91  const InputDynamicPointsArrayType& inputPoints)
92  {
94  RunTrampoline trampoline;
95  vtkm::cont::CastAndCall(inputPoints, trampoline, keys, output);
96  return output;
97  }
98 };
99 
100 template <typename ValueType, typename StorageType, typename IndexArrayType>
101 VTKM_CONT vtkm::cont::ArrayHandle<ValueType> ConcretePermutationArray(
102  const IndexArrayType& indices,
104 {
106  auto tmp = vtkm::cont::make_ArrayHandlePermutation(indices, values);
107  vtkm::cont::ArrayCopy(tmp, result);
108  return result;
109 }
110 
111 template <typename T, vtkm::IdComponent N>
113 {
114  const T* vmem = reinterpret_cast<const T*>(&*other.ReadPortal().GetIteratorBegin());
116  vtkm::cont::make_ArrayHandle(vmem, other.GetNumberOfValues() * N, vtkm::CopyFlag::On);
117  return result;
118 }
119 
120 } // namespace internal
121 
123 {
124  struct GridInfo
125  {
130  };
131 
132  // input: points output: cid of the points
134  {
135  private:
137 
138  public:
140  using ExecutionSignature = void(_1, _2);
141 
142  VTKM_CONT
144  : Grid(grid)
145  {
146  }
147 
149  template <typename PointType>
150  VTKM_EXEC vtkm::Id GetClusterId(const PointType& p) const
151  {
152  using ComponentType = typename PointType::ComponentType;
153  PointType gridOrigin(static_cast<ComponentType>(this->Grid.origin[0]),
154  static_cast<ComponentType>(this->Grid.origin[1]),
155  static_cast<ComponentType>(this->Grid.origin[2]));
156 
157  PointType p_rel = (p - gridOrigin) * this->Grid.inv_bin_size;
158 
159  vtkm::Id x = vtkm::Min(static_cast<vtkm::Id>(p_rel[0]), this->Grid.dim[0] - 1);
160  vtkm::Id y = vtkm::Min(static_cast<vtkm::Id>(p_rel[1]), this->Grid.dim[1] - 1);
161  vtkm::Id z = vtkm::Min(static_cast<vtkm::Id>(p_rel[2]), this->Grid.dim[2] - 1);
162 
163  return x + this->Grid.dim[0] * (y + this->Grid.dim[1] * z); // get a unique hash value
164  }
165 
166  template <typename PointType>
167  VTKM_EXEC void operator()(const PointType& point, vtkm::Id& cid) const
168  {
169  cid = this->GetClusterId(point);
170  VTKM_ASSERT(cid >= 0); // the id could overflow if too many cells
171  }
172  };
173 
175  {
176  public:
177  using ControlSignature = void(CellSetIn cellset,
178  FieldInPoint pointClusterIds,
179  FieldOutCell cellClusterIds);
180  using ExecutionSignature = void(_2, _3);
181 
182  VTKM_CONT
184 
185  // TODO: Currently only works with Triangle cell types
186  template <typename ClusterIdsVecType>
187  VTKM_EXEC void operator()(const ClusterIdsVecType& pointClusterIds,
188  vtkm::Id3& cellClusterId) const
189  {
190  cellClusterId[0] = pointClusterIds[0];
191  cellClusterId[1] = pointClusterIds[1];
192  cellClusterId[2] = pointClusterIds[2];
193  }
194  };
195 
198  {
199  public:
200  using ControlSignature = void(FieldIn, WholeArrayOut);
201  using ExecutionSignature = void(WorkIndex, _1, _2); // WorkIndex: use vtkm indexing
202 
203  template <typename OutPortalType>
204  VTKM_EXEC void operator()(const vtkm::Id& counter,
205  const vtkm::Id& cid,
206  const OutPortalType& outPortal) const
207  {
208  outPortal.Set(cid, counter);
209  }
210  };
211 
213  {
215 
216  VTKM_EXEC
217  void rotate(vtkm::Id3& ids) const
218  {
219  vtkm::Id temp = ids[0];
220  ids[0] = ids[1];
221  ids[1] = ids[2];
222  ids[2] = temp;
223  }
224 
225  public:
226  using ControlSignature = void(FieldIn, FieldOut, WholeArrayIn);
227  using ExecutionSignature = void(_1, _2, _3);
228 
229  VTKM_CONT
231  : NPoints(nPoints)
232  {
233  }
234 
235  template <typename InPortalType>
236  VTKM_EXEC void operator()(const vtkm::Id3& cid3,
237  vtkm::Id3& pointId3,
238  const InPortalType& inPortal) const
239  {
240  if (cid3[0] == cid3[1] || cid3[0] == cid3[2] || cid3[1] == cid3[2])
241  {
242  pointId3[0] = pointId3[1] = pointId3[2] = this->NPoints; // invalid cell to be removed
243  }
244  else
245  {
246  pointId3[0] = inPortal.Get(cid3[0]);
247  pointId3[1] = inPortal.Get(cid3[1]);
248  pointId3[2] = inPortal.Get(cid3[2]);
249 
250  // Sort triangle point ids so that the same triangle will have the same signature
251  // Rotate these ids making the first one the smallest
252  if (pointId3[0] > pointId3[1] || pointId3[0] > pointId3[2])
253  {
254  rotate(pointId3);
255  if (pointId3[0] > pointId3[1] || pointId3[0] > pointId3[2])
256  {
257  rotate(pointId3);
258  }
259  }
260  }
261  }
262  };
263 
265 
267  {
268  private:
269  vtkm::Int64 NPoints;
270 
271  public:
273  using ExecutionSignature = void(_1, _2);
274 
275  VTKM_CONT
277  : NPoints(nPoints)
278  {
279  }
280 
281  VTKM_EXEC
282  void operator()(const vtkm::Id3& cid, vtkm::Int64& cidHash) const
283  {
284  cidHash =
285  cid[0] + this->NPoints * (cid[1] + this->NPoints * cid[2]); // get a unique hash value
286  }
287  };
288 
290  {
291  private:
292  vtkm::Int64 NPoints;
293 
294  public:
296  using ExecutionSignature = void(_1, _2);
297 
298  VTKM_CONT
300  : NPoints(nPoints)
301  {
302  }
303 
304  VTKM_EXEC
305  void operator()(const vtkm::Int64& cidHash, vtkm::Id3& cid) const
306  {
307  cid[0] = static_cast<vtkm::Id>(cidHash % this->NPoints);
308  vtkm::Int64 t = cidHash / this->NPoints;
309  cid[1] = static_cast<vtkm::Id>(t % this->NPoints);
310  cid[2] = static_cast<vtkm::Id>(t / this->NPoints);
311  }
312  };
313 
314 public:
318  template <typename UnknownCellSetType, typename DynamicCoordinateHandleType>
319  void Run(const UnknownCellSetType& cellSet,
320  const DynamicCoordinateHandleType& coordinates,
321  const vtkm::Bounds& bounds,
322  const vtkm::Id3& nDivisions,
323  vtkm::cont::UnknownCellSet& outCellSet,
325  {
326  VTKM_LOG_SCOPE(vtkm::cont::LogLevel::Perf, "VertexClustering Worklet");
327 
329  GridInfo gridInfo;
330  {
331  gridInfo.origin[0] = bounds.X.Min;
332  gridInfo.origin[1] = bounds.Y.Min;
333  gridInfo.origin[2] = bounds.Z.Min;
334  gridInfo.dim[0] = nDivisions[0];
335  gridInfo.dim[1] = nDivisions[1];
336  gridInfo.dim[2] = nDivisions[2];
337  gridInfo.bin_size[0] = bounds.X.Length() / static_cast<vtkm::Float64>(nDivisions[0]);
338  gridInfo.bin_size[1] = bounds.Y.Length() / static_cast<vtkm::Float64>(nDivisions[1]);
339  gridInfo.bin_size[2] = bounds.Z.Length() / static_cast<vtkm::Float64>(nDivisions[2]);
340  gridInfo.inv_bin_size[0] = 1. / gridInfo.bin_size[0];
341  gridInfo.inv_bin_size[1] = 1. / gridInfo.bin_size[1];
342  gridInfo.inv_bin_size[2] = 1. / gridInfo.bin_size[2];
343  }
344 
345 #ifdef __VTKM_VERTEX_CLUSTERING_BENCHMARK
346  vtkm::cont::Timer totalTimer;
347  totalTimer.Start();
348  vtkm::cont::Timer timer;
349  timer.Start();
350 #endif
351 
354 
358  vtkm::cont::ArrayHandle<vtkm::Id> pointCidArray;
359 
361  (MapPointsWorklet(gridInfo)));
362  mapPointsDispatcher.Invoke(coordinates, pointCidArray);
363 
364 #ifdef __VTKM_VERTEX_CLUSTERING_BENCHMARK
365  timer.stop();
366  std::cout << "Time map points (s): " << timer.GetElapsedTime() << std::endl;
367  timer.Start();
368 #endif
369 
371  vtkm::cont::UnknownArrayHandle repPointArray;
372  {
375 
376  // Create a View with all the keys offsets but the last element since
377  // BuildArrays uses ScanExtended
378  auto keysView = vtkm::cont::make_ArrayHandleView(
379  keys.GetOffsets(), 0, keys.GetOffsets().GetNumberOfValues() - 1);
380 
381  // For mapping properties, this map will select an arbitrary point from
382  // the cluster:
383  this->PointIdMap = internal::ConcretePermutationArray(keysView, keys.GetSortedValuesMap());
384 
385  // Compute representative points from each cluster (may not match the
386  // PointIdMap indexing)
387  repPointArray = internal::SelectRepresentativePoint::Run(keys, coordinates);
388  }
389 
390  auto repPointCidArray =
392 
393 #ifdef __VTKM_VERTEX_CLUSTERING_BENCHMARK
394  std::cout << "Time after reducing points (s): " << timer.GetElapsedTime() << std::endl;
395  timer.Start();
396 #endif
397 
401 
405 
407  mapCellsDispatcher.Invoke(cellSet, pointCidArray, cid3Array);
408 
409 #ifdef __VTKM_VERTEX_CLUSTERING_BENCHMARK
410  std::cout << "Time after clustering cells (s): " << timer.GetElapsedTime() << std::endl;
411  timer.Start();
412 #endif
413 
415  vtkm::cont::ArrayHandle<vtkm::Id> cidIndexArray;
416  cidIndexArray.Allocate(gridInfo.dim[0] * gridInfo.dim[1] * gridInfo.dim[2]);
417 
419  indexingDispatcher.Invoke(repPointCidArray, cidIndexArray);
420 
421  pointCidArray.ReleaseResources();
422  repPointCidArray.ReleaseResources();
423 
429  vtkm::Id nPoints = repPointArray.GetNumberOfValues();
430 
432 
434  (Cid2PointIdWorklet(nPoints)));
435  cid2PointIdDispatcher.Invoke(cid3Array, pointId3Array, cidIndexArray);
436 
437  cid3Array.ReleaseResources();
438  cidIndexArray.ReleaseResources();
439 
440  bool doHashing = (nPoints < (1 << 21)); // Check whether we can hash Id3 into 64-bit integers
441 
442  if (doHashing)
443  {
445  vtkm::cont::ArrayHandle<vtkm::Int64> pointId3HashArray;
446 
448  (Cid3HashWorklet(nPoints)));
449  cid3HashDispatcher.Invoke(pointId3Array, pointId3HashArray);
450 
451  pointId3Array.ReleaseResources();
452 
453 #ifdef __VTKM_VERTEX_CLUSTERING_BENCHMARK
454  std::cout << "Time before sort and unique with hashing (s): " << timer.GetElapsedTime()
455  << std::endl;
456  timer.Start();
457 #endif
458 
459  this->CellIdMap = vtkm::worklet::StableSortIndices::Sort(pointId3HashArray);
460  vtkm::worklet::StableSortIndices::Unique(pointId3HashArray, this->CellIdMap);
461 
462 #ifdef __VTKM_VERTEX_CLUSTERING_BENCHMARK
463  std::cout << "Time after sort and unique with hashing (s): " << timer.GetElapsedTime()
464  << std::endl;
465  timer.Start();
466 #endif
467 
468  // Create a temporary permutation array and use that for unhashing.
469  auto tmpPerm = vtkm::cont::make_ArrayHandlePermutation(this->CellIdMap, pointId3HashArray);
470 
471  // decode
473  (Cid3UnhashWorklet(nPoints)));
474  cid3UnhashDispatcher.Invoke(tmpPerm, pointId3Array);
475  }
476  else
477  {
478 #ifdef __VTKM_VERTEX_CLUSTERING_BENCHMARK
479  std::cout << "Time before sort and unique [no hashing] (s): " << timer.GetElapsedTime()
480  << std::endl;
481  timer.Start();
482 #endif
483 
484  this->CellIdMap = vtkm::worklet::StableSortIndices::Sort(pointId3Array);
486 
487 #ifdef __VTKM_VERTEX_CLUSTERING_BENCHMARK
488  std::cout << "Time after sort and unique [no hashing] (s): " << timer.GetElapsedTime()
489  << std::endl;
490  timer.Start();
491 #endif
492 
493  // Permute the connectivity array into a basic array handle. Use a
494  // temporary array handle to avoid memory aliasing.
495  {
497  tmp = internal::ConcretePermutationArray(this->CellIdMap, pointId3Array);
498  pointId3Array = tmp;
499  }
500  }
501 
502  // remove the last element if invalid
503  vtkm::Id cells = pointId3Array.GetNumberOfValues();
504  if (cells > 0 && pointId3Array.ReadPortal().Get(cells - 1)[2] >= nPoints)
505  {
506  cells--;
507  pointId3Array.Allocate(cells, vtkm::CopyFlag::On);
508  this->CellIdMap.Allocate(cells, vtkm::CopyFlag::On);
509  }
510 
512  outCoords = repPointArray;
513 
515  triangles.Fill(repPointArray.GetNumberOfValues(),
517  3,
518  internal::copyFromVec(pointId3Array));
519  outCellSet = triangles;
520 
521 #ifdef __VTKM_VERTEX_CLUSTERING_BENCHMARK
522  std::cout << "Wrap-up (s): " << timer.GetElapsedTime() << std::endl;
523  vtkm::Float64 t = totalTimer.GetElapsedTime();
524  std::cout << "Time (s): " << t << std::endl;
525  std::cout << "number of output points: " << repPointArray.GetNumberOfValues() << std::endl;
526  std::cout << "number of output cells: " << pointId3Array.GetNumberOfValues() << std::endl;
527 #endif
528  }
529 
532 
533 private:
536 }; // struct VertexClustering
537 }
538 } // namespace vtkm::worklet
539 
540 #endif // vtk_m_worklet_VertexClustering_h
VTKM_LOG_SCOPE
#define VTKM_LOG_SCOPE(level,...)
Definition: Logging.h:265
vtkm::cont::ArrayHandle::GetNumberOfValues
VTKM_CONT vtkm::Id GetNumberOfValues() const
Returns the number of entries in the array.
Definition: ArrayHandle.h:448
vtkm::cont::make_ArrayHandle
VTKM_CONT vtkm::cont::ArrayHandleBasic< T > make_ArrayHandle(const T *array, vtkm::Id numberOfValues, vtkm::CopyFlag copy)
A convenience function for creating an ArrayHandle from a standard C array.
Definition: ArrayHandleBasic.h:217
vtkm::cont::ArrayHandle
Manages an array-worth of data.
Definition: ArrayHandle.h:283
ArrayHandle.h
vtkm::worklet::VertexClustering::Cid3UnhashWorklet::Cid3UnhashWorklet
VTKM_CONT Cid3UnhashWorklet(vtkm::Id nPoints)
Definition: worklet/VertexClustering.h:299
vtkm::worklet::VertexClustering::MapCellsWorklet
Definition: worklet/VertexClustering.h:174
VTKM_EXEC
#define VTKM_EXEC
Definition: ExportMacros.h:51
vtkm
Groups connected points that have the same field value.
Definition: Atomic.h:19
StableSortIndices.h
vtkm::cont::make_ArrayHandleView
ArrayHandleView< ArrayHandleType > make_ArrayHandleView(const ArrayHandleType &array, vtkm::Id startIndex, vtkm::Id numValues)
Definition: ArrayHandleView.h:222
Types.h
WorkletMapField.h
VTKM_ASSERT
#define VTKM_ASSERT(condition)
Definition: Assert.h:43
vtkm::cont::ArrayHandle::Allocate
VTKM_CONT void Allocate(vtkm::Id numberOfValues, vtkm::CopyFlag preserve, vtkm::cont::Token &token) const
Allocates an array large enough to hold the given number of values.
Definition: ArrayHandle.h:465
vtkm::worklet::WorkletMapField::FieldOut
A control signature tag for output fields.
Definition: WorkletMapField.h:60
vtkm::cont::Timer::Start
VTKM_CONT void Start()
vtkm::worklet::VertexClustering::PointIdMap
vtkm::cont::ArrayHandle< vtkm::Id > PointIdMap
Definition: worklet/VertexClustering.h:534
vtkm::worklet::VertexClustering::GridInfo::inv_bin_size
vtkm::Vec3f_64 inv_bin_size
Definition: worklet/VertexClustering.h:129
vtkm::worklet::VertexClustering::Cid3UnhashWorklet::ExecutionSignature
void(_1, _2) ExecutionSignature
Definition: worklet/VertexClustering.h:296
vtkm::worklet::VertexClustering::GetPointIdMap
vtkm::cont::ArrayHandle< vtkm::Id > GetPointIdMap() const
Definition: worklet/VertexClustering.h:530
vtkm::cont::UnknownArrayHandle
An ArrayHandle of an unknown value type and storage.
Definition: UnknownArrayHandle.h:406
Keys.h
vtkm::worklet::VertexClustering::IndexingWorklet::ExecutionSignature
void(WorkIndex, _1, _2) ExecutionSignature
Definition: worklet/VertexClustering.h:201
vtkm::worklet::VertexClustering::MapPointsWorklet::MapPointsWorklet
VTKM_CONT MapPointsWorklet(const GridInfo &grid)
Definition: worklet/VertexClustering.h:143
vtkm::cont::CellSetSingleType
Definition: CastAndCall.h:34
ArrayHandleConstant.h
vtkm::worklet::VertexClustering::Cid3HashWorklet::ExecutionSignature
void(_1, _2) ExecutionSignature
Definition: worklet/VertexClustering.h:273
vtkm::worklet::VertexClustering::GridInfo::dim
vtkm::Id3 dim
Definition: worklet/VertexClustering.h:126
vtkm::worklet::VertexClustering::Cid3HashWorklet::Cid3HashWorklet
VTKM_CONT Cid3HashWorklet(vtkm::Id nPoints)
Definition: worklet/VertexClustering.h:276
vtkm::worklet::VertexClustering::Cid3HashWorklet
Definition: worklet/VertexClustering.h:266
vtkm::worklet::VertexClustering::MapCellsWorklet::MapCellsWorklet
VTKM_CONT MapCellsWorklet()
Definition: worklet/VertexClustering.h:183
vtkm::cont::UnknownCellSet
A CellSet of an unknown type.
Definition: UnknownCellSet.h:48
vtkm::cont::CastAndCall
void CastAndCall(const DynamicObject &dynamicObject, Functor &&f, Args &&... args)
A Generic interface to CastAndCall.
Definition: CastAndCall.h:47
vtkm::worklet::StableSortIndices::Unique
static VTKM_CONT void Unique(vtkm::cont::DeviceAdapterId device, const vtkm::cont::ArrayHandle< KeyType, Storage > &keys, IndexArrayType &indices)
Reduces the array returned by Sort so that the mapped keys are unique.
Definition: StableSortIndices.h:204
vtkm::worklet::VertexClustering::IndexingWorklet
pass 3
Definition: worklet/VertexClustering.h:197
vtkm::Id
vtkm::Int32 Id
Represents an ID (index into arrays).
Definition: Types.h:191
ArrayCopy.h
DispatcherMapField.h
vtkm::worklet::VertexClustering::IndexingWorklet::ControlSignature
void(FieldIn, WholeArrayOut) ControlSignature
Definition: worklet/VertexClustering.h:200
vtkm::worklet::VertexClustering::Cid2PointIdWorklet::Cid2PointIdWorklet
VTKM_CONT Cid2PointIdWorklet(vtkm::Id nPoints)
Definition: worklet/VertexClustering.h:230
vtkm::worklet::VertexClustering::Cid3HashWorklet::NPoints
vtkm::Int64 NPoints
Definition: worklet/VertexClustering.h:269
vtkm::worklet::VertexClustering::Cid3UnhashWorklet::operator()
VTKM_EXEC void operator()(const vtkm::Int64 &cidHash, vtkm::Id3 &cid) const
Definition: worklet/VertexClustering.h:305
vtkm::worklet::VertexClustering::GridInfo
Definition: worklet/VertexClustering.h:124
vtkm::Range::Length
VTKM_EXEC_CONT vtkm::Float64 Length() const
Returns the length of the range.
Definition: Range.h:87
vtkm::worklet::VertexClustering::Cid2PointIdWorklet::NPoints
vtkm::Id NPoints
Definition: worklet/VertexClustering.h:214
vtkm::worklet::VertexClustering::MapCellsWorklet::operator()
VTKM_EXEC void operator()(const ClusterIdsVecType &pointClusterIds, vtkm::Id3 &cellClusterId) const
Definition: worklet/VertexClustering.h:187
UnknownArrayHandle.h
vtkm::worklet::DispatcherMapField
Dispatcher for worklets that inherit from WorkletMapField.
Definition: DispatcherMapField.h:25
WorkletReduceByKey.h
vtkm::worklet::VertexClustering::IndexingWorklet::operator()
VTKM_EXEC void operator()(const vtkm::Id &counter, const vtkm::Id &cid, const OutPortalType &outPortal) const
Definition: worklet/VertexClustering.h:204
ArrayHandlePermutation.h
Timer.h
Algorithm.h
vtkm::worklet::DispatcherMapTopology
Dispatcher for worklets that inherit from WorkletMapTopology.
Definition: DispatcherMapTopology.h:31
vtkm::worklet::WorkletMapField::FieldIn
A control signature tag for input fields.
Definition: WorkletMapField.h:49
ArrayHandleIndex.h
vtkm::worklet::WorkletReduceByKey
Definition: WorkletReduceByKey.h:42
vtkm::worklet::VertexClustering::Cid3UnhashWorklet::ControlSignature
void(FieldIn, FieldOut) ControlSignature
Definition: worklet/VertexClustering.h:295
vtkm::worklet::WorkletVisitCellsWithPoints
Base class for worklets that map from Points to Cells.
Definition: WorkletMapTopology.h:255
vtkm::cont::ArrayCopy
void ArrayCopy(const SourceArrayType &source, DestArrayType &destination)
Does a deep copy from one array to another array.
Definition: ArrayCopy.h:142
vtkm::worklet::VertexClustering::GridInfo::bin_size
vtkm::Vec3f_64 bin_size
Definition: worklet/VertexClustering.h:128
vtkm::worklet::VertexClustering::Cid2PointIdWorklet
Definition: worklet/VertexClustering.h:212
vtkm::worklet::VertexClustering::Cid3UnhashWorklet
Definition: worklet/VertexClustering.h:289
vtkm::Bounds::Z
vtkm::Range Z
Definition: Bounds.h:33
vtkm::worklet::KeysSortType::Stable
@ Stable
vtkm::worklet::WorkletVisitCellsWithPoints::FieldInPoint
FieldInIncident FieldInPoint
Definition: WorkletMapTopology.h:259
VTKM_CONT
#define VTKM_CONT
Definition: ExportMacros.h:57
vtkm::worklet::Keys::BuildArrays
VTKM_CONT void BuildArrays(const KeyArrayType &keys, KeysSortType sort, vtkm::cont::DeviceAdapterId device=vtkm::cont::DeviceAdapterTagAny())
Build the internal arrays without modifying the input.
vtkm::worklet::VertexClustering::MapPointsWorklet
Definition: worklet/VertexClustering.h:133
vtkm::worklet::VertexClustering::MapCellsWorklet::ExecutionSignature
void(_2, _3) ExecutionSignature
Definition: worklet/VertexClustering.h:180
vtkm::worklet::VertexClustering::Cid3HashWorklet::ControlSignature
void(FieldIn, FieldOut) ControlSignature
Definition: worklet/VertexClustering.h:272
vtkm::cont::Timer
A class that can be used to time operations in VTK-m that might be occuring in parallel.
Definition: Timer.h:43
vtkm::Bounds
Represent an axis-aligned 3D bounds in space.
Definition: Bounds.h:29
vtkm::CopyFlag::On
@ On
vtkm::worklet::VertexClustering::Cid2PointIdWorklet::ExecutionSignature
void(_1, _2, _3) ExecutionSignature
Definition: worklet/VertexClustering.h:227
DispatcherReduceByKey.h
BinaryOperators.h
vtkm::worklet::StableSortIndices::Sort
static VTKM_CONT void Sort(vtkm::cont::DeviceAdapterId device, const vtkm::cont::ArrayHandle< KeyType, Storage > &keys, IndexArrayType &indices)
Permutes the indices array so that it will map keys into a stable sorted order.
Definition: StableSortIndices.h:140
vtkm::cont::make_ArrayHandlePermutation
VTKM_CONT vtkm::cont::ArrayHandlePermutation< IndexArrayHandleType, ValueArrayHandleType > make_ArrayHandlePermutation(IndexArrayHandleType indexArray, ValueArrayHandleType valueArray)
make_ArrayHandleTransform is convenience function to generate an ArrayHandleTransform.
Definition: ArrayHandlePermutation.h:279
vtkm::worklet::VertexClustering::Cid2PointIdWorklet::rotate
VTKM_EXEC void rotate(vtkm::Id3 &ids) const
Definition: worklet/VertexClustering.h:217
vtkm::worklet::VertexClustering::GridInfo::origin
vtkm::Vec3f_64 origin
Definition: worklet/VertexClustering.h:127
vtkm::worklet::VertexClustering::Cid2PointIdWorklet::ControlSignature
void(FieldIn, FieldOut, WholeArrayIn) ControlSignature
Definition: worklet/VertexClustering.h:226
vtkm::Vec< T, N >
vtkm::Range::Min
vtkm::Float64 Min
Definition: Range.h:33
vtkm::worklet::DispatcherReduceByKey
Dispatcher for worklets that inherit from WorkletReduceByKey.
Definition: DispatcherReduceByKey.h:27
vtkm::cont::ArrayHandle::ReadPortal
VTKM_CONT ReadPortalType ReadPortal() const
Get an array portal that can be used in the control environment.
Definition: ArrayHandle.h:414
vtkm::worklet::Keys
Manage keys for a WorkletReduceByKey.
Definition: Keys.h:131
vtkm::worklet::VertexClustering::GetCellIdMap
vtkm::cont::ArrayHandle< vtkm::Id > GetCellIdMap() const
Definition: worklet/VertexClustering.h:531
BinaryPredicates.h
vtkm::List
Definition: List.h:34
ArrayHandleDiscard.h
vtkm::Float64
double Float64
Definition: Types.h:155
vtkm::worklet::VertexClustering::MapPointsWorklet::ExecutionSignature
void(_1, _2) ExecutionSignature
Definition: worklet/VertexClustering.h:140
vtkm::Bounds::X
vtkm::Range X
Definition: Bounds.h:31
vtkm::Bounds::Y
vtkm::Range Y
Definition: Bounds.h:32
vtkm::cont::UnknownArrayHandle::GetNumberOfValues
VTKM_CONT vtkm::Id GetNumberOfValues() const
Returns the number of values in the array.
vtkm::worklet::VertexClustering::Cid3HashWorklet::operator()
VTKM_EXEC void operator()(const vtkm::Id3 &cid, vtkm::Int64 &cidHash) const
Definition: worklet/VertexClustering.h:282
vtkm::worklet::VertexClustering::MapPointsWorklet::ControlSignature
void(FieldIn, FieldOut) ControlSignature
Definition: worklet/VertexClustering.h:139
vtkm::worklet::VertexClustering::CellIdMap
vtkm::cont::ArrayHandle< vtkm::Id > CellIdMap
Definition: worklet/VertexClustering.h:535
vtkm::worklet::VertexClustering
Definition: worklet/VertexClustering.h:122
Logging.h
Logging utilities.
vtkm::worklet::VertexClustering::Cid3UnhashWorklet::NPoints
vtkm::Int64 NPoints
Definition: worklet/VertexClustering.h:292
vtkm::cont::CellSetSingleType::Fill
VTKM_CONT void Fill(vtkm::Id numPoints, vtkm::UInt8 shapeId, vtkm::IdComponent numberOfPointsPerCell, const vtkm::cont::ArrayHandle< vtkm::Id, ConnectivityStorageTag > &connectivity)
Definition: CellSetSingleType.h:186
vtkm::worklet::VertexClustering::MapPointsWorklet::Grid
GridInfo Grid
Definition: worklet/VertexClustering.h:136
vtkm::worklet::VertexClustering::Run
void Run(const UnknownCellSetType &cellSet, const DynamicCoordinateHandleType &coordinates, const vtkm::Bounds &bounds, const vtkm::Id3 &nDivisions, vtkm::cont::UnknownCellSet &outCellSet, vtkm::cont::UnknownArrayHandle &outCoords)
VertexClustering: Mesh simplification.
Definition: worklet/VertexClustering.h:319
DispatcherMapTopology.h
WorkletMapTopology.h
vtkm::worklet::VertexClustering::MapPointsWorklet::GetClusterId
VTKM_EXEC vtkm::Id GetClusterId(const PointType &p) const
determine grid resolution for clustering
Definition: worklet/VertexClustering.h:150
vtkm::cont::ArrayHandle::ReleaseResources
VTKM_CONT void ReleaseResources() const
Releases all resources in both the control and execution environments.
Definition: ArrayHandle.h:559
vtkm::cont::Timer::GetElapsedTime
VTKM_CONT vtkm::Float64 GetElapsedTime() const
Get the elapsed time measured by the given device adapter.
DataSet.h
vtkm::cont::LogLevel::Perf
@ Perf
General timing data and algorithm flow information, such as filter execution, worklet dispatches,...
vtkm::worklet::VertexClustering::MapPointsWorklet::operator()
VTKM_EXEC void operator()(const PointType &point, vtkm::Id &cid) const
Definition: worklet/VertexClustering.h:167
vtkm::worklet::WorkletMapField
Base class for worklets that do a simple mapping of field arrays.
Definition: WorkletMapField.h:38
vtkm::worklet::WorkletVisitCellsWithPoints::FieldOutCell
FieldOut FieldOutCell
Definition: WorkletMapTopology.h:263
vtkm::exec::arg::WorkIndex
The ExecutionSignature tag to use to get the work index.
Definition: WorkIndex.h:39
vtkm::worklet::VertexClustering::Cid2PointIdWorklet::operator()
VTKM_EXEC void operator()(const vtkm::Id3 &cid3, vtkm::Id3 &pointId3, const InPortalType &inPortal) const
Definition: worklet/VertexClustering.h:236
vtkm::worklet::VertexClustering::MapCellsWorklet::ControlSignature
void(CellSetIn cellset, FieldInPoint pointClusterIds, FieldOutCell cellClusterIds) ControlSignature
Definition: worklet/VertexClustering.h:179