VTK-m  2.0
DispatcherMapField.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_Dispatcher_MapField_h
11 #define vtk_m_worklet_Dispatcher_MapField_h
12 
14 
15 namespace vtkm
16 {
17 namespace worklet
18 {
19 
20 class WorkletMapField;
21 
24 template <typename WorkletType>
26  : public vtkm::worklet::internal::
27  DispatcherBase<DispatcherMapField<WorkletType>, WorkletType, vtkm::worklet::WorkletMapField>
28 {
29  using Superclass = vtkm::worklet::internal::
30  DispatcherBase<DispatcherMapField<WorkletType>, WorkletType, vtkm::worklet::WorkletMapField>;
31  using ScatterType = typename Superclass::ScatterType;
32 
33 public:
34  template <typename... T>
36  : Superclass(std::forward<T>(args)...)
37  {
38  }
39 
40  template <typename Invocation>
41  VTKM_CONT void DoInvoke(Invocation& invocation) const
42  {
43  using namespace vtkm::worklet::internal;
44 
45  // This is the type for the input domain
46  using InputDomainType = typename Invocation::InputDomainType;
47 
48  // We can pull the input domain parameter (the data specifying the input
49  // domain) from the invocation object.
50  const InputDomainType& inputDomain = invocation.GetInputDomain();
51 
52  // For a DispatcherMapField, the inputDomain must be an ArrayHandle (or
53  // an UnknownArrayHandle that gets cast to one). The size of the domain
54  // (number of threads/worklet instances) is equal to the size of the
55  // array.
56  auto numInstances = SchedulingRange(inputDomain);
57 
58  // A MapField is a pretty straightforward dispatch. Once we know the number
59  // of invocations, the superclass can take care of the rest.
60  this->BasicInvoke(invocation, numInstances);
61  }
62 };
63 }
64 } // namespace vtkm::worklet
65 
66 #endif //vtk_m_worklet_Dispatcher_MapField_h
vtkm
Groups connected points that have the same field value.
Definition: Atomic.h:19
DispatcherBase.h
vtkm::worklet::DispatcherMapField
Dispatcher for worklets that inherit from WorkletMapField.
Definition: DispatcherMapField.h:25
vtkm::worklet::DispatcherMapField::DoInvoke
VTKM_CONT void DoInvoke(Invocation &invocation) const
Definition: DispatcherMapField.h:41
vtkm::worklet::DispatcherMapField::Superclass
vtkm::worklet::internal::DispatcherBase< DispatcherMapField< WorkletType >, WorkletType, vtkm::worklet::WorkletMapField > Superclass
Definition: DispatcherMapField.h:30
vtkm::worklet::DispatcherMapField::ScatterType
typename Superclass::ScatterType ScatterType
Definition: DispatcherMapField.h:31
VTKM_CONT
#define VTKM_CONT
Definition: ExportMacros.h:57
vtkm::worklet::DispatcherMapField::DispatcherMapField
VTKM_CONT DispatcherMapField(T &&... args)
Definition: DispatcherMapField.h:35
vtkm::worklet::WorkletMapField
Base class for worklets that do a simple mapping of field arrays.
Definition: WorkletMapField.h:38