VTK-m  2.0
WorkletMapTopology.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_WorkletMapTopology_h
11 #define vtk_m_worklet_WorkletMapTopology_h
12 
14 
16 
26 
36 
38 
39 namespace vtkm
40 {
41 namespace worklet
42 {
43 
44 template <typename WorkletType>
45 class DispatcherMapTopology;
46 
47 namespace detail
48 {
49 
50 struct WorkletMapTopologyBase : vtkm::worklet::internal::WorkletBase
51 {
52  template <typename Worklet>
54 };
55 
56 } // namespace detail
57 
70 template <typename VisitTopology, typename IncidentTopology>
71 class WorkletMapTopology : public detail::WorkletMapTopologyBase
72 {
73 public:
74  using VisitTopologyType = VisitTopology;
75  using IncidentTopologyType = IncidentTopology;
76 
81  {
85  };
86 
91  {
95  };
96 
103  {
107  };
108 
113  {
117  };
118 
122  {
124  using TransportTag =
127  };
128 
133  {
134  };
135 
146  {
147  };
148 
159  {
160  };
161 
165  template <typename OutToInArrayType,
166  typename VisitArrayType,
167  typename ThreadToOutArrayType,
168  typename InputDomainType>
172  const OutToInArrayType& outToIn,
173  const VisitArrayType& visit,
174  const ThreadToOutArrayType& threadToOut,
175  const InputDomainType& connectivity) const
176  {
177  const vtkm::Id outIndex = threadToOut.Get(threadIndex);
178  return vtkm::exec::arg::ThreadIndicesTopologyMap<InputDomainType,
180  threadIndex, outToIn.Get(outIndex), visit.Get(outIndex), outIndex, connectivity);
181  }
182 
189 private:
190  static constexpr bool IsScatterIdentity =
191  std::is_same<ScatterType, vtkm::worklet::ScatterIdentity>::value;
192  static constexpr bool IsMaskNone = std::is_same<MaskType, vtkm::worklet::MaskNone>::value;
193 
194  template <bool Cond, typename ReturnType>
195  using EnableFnWhen = typename std::enable_if<Cond, ReturnType>::type;
196 
197 public:
200  template <typename OutToInArrayType,
201  typename VisitArrayType,
202  typename ThreadToOutArrayType,
203  typename InputDomainType,
204  bool S = IsScatterIdentity,
205  bool M = IsMaskNone>
207  S && M,
210  GetThreadIndices(vtkm::Id threadIndex1D,
211  const vtkm::Id3& threadIndex3D,
212  const OutToInArrayType& vtkmNotUsed(outToIn),
213  const VisitArrayType& vtkmNotUsed(visit),
214  const ThreadToOutArrayType& vtkmNotUsed(threadToOut),
215  const InputDomainType& connectivity) const
216  {
217  return vtkm::exec::arg::ThreadIndicesTopologyMap<InputDomainType,
219  threadIndex3D, threadIndex1D, connectivity);
220  }
221 
224  template <typename OutToInArrayType,
225  typename VisitArrayType,
226  typename ThreadToOutArrayType,
227  typename InputDomainType,
228  bool S = IsScatterIdentity,
229  bool M = IsMaskNone>
230  VTKM_EXEC
231  EnableFnWhen<!(S && M),
234  GetThreadIndices(vtkm::Id threadIndex1D,
235  const vtkm::Id3& threadIndex3D,
236  const OutToInArrayType& outToIn,
237  const VisitArrayType& visit,
238  const ThreadToOutArrayType& threadToOut,
239  const InputDomainType& connectivity) const
240  {
241  const vtkm::Id outIndex = threadToOut.Get(threadIndex1D);
242  return vtkm::exec::arg::ThreadIndicesTopologyMap<InputDomainType,
244  threadIndex3D,
245  threadIndex1D,
246  outToIn.Get(outIndex),
247  visit.Get(outIndex),
248  outIndex,
249  connectivity);
250  }
251 };
252 
256  : public WorkletMapTopology<vtkm::TopologyElementTagCell, vtkm::TopologyElementTagPoint>
257 {
258 public:
259  using FieldInPoint = FieldInIncident;
260 
261  using FieldInCell = FieldInVisit;
262 
263  using FieldOutCell = FieldOut;
264 
265  using FieldInOutCell = FieldInOut;
266 
267  using PointCount = IncidentElementCount;
268 
269  using PointIndices = IncidentElementIndices;
270 };
271 
275  : public WorkletMapTopology<vtkm::TopologyElementTagPoint, vtkm::TopologyElementTagCell>
276 {
277 public:
278  using FieldInCell = FieldInIncident;
279 
280  using FieldInPoint = FieldInVisit;
281 
282  using FieldOutPoint = FieldOut;
283 
284  using FieldInOutPoint = FieldInOut;
285 
286  using CellCount = IncidentElementCount;
287 
288  using CellIndices = IncidentElementIndices;
289 };
290 
291 }
292 } // namespace vtkm::worklet
293 
294 #endif //vtk_m_worklet_WorkletMapTopology_h
vtkm::worklet::WorkletMapTopology::FieldOut
A control signature tag for output fields.
Definition: WorkletMapTopology.h:102
vtkm::TopologyElementTagPoint
A tag used to identify the point elements in a topology.
Definition: TopologyElementTag.h:34
vtkm::worklet::WorkletMapTopology::CellSetIn
A control signature tag for input connectivity.
Definition: WorkletMapTopology.h:121
VTKM_EXEC
#define VTKM_EXEC
Definition: ExportMacros.h:51
vtkm
Groups connected points that have the same field value.
Definition: Atomic.h:19
vtkm::worklet::WorkletMapTopology::IsScatterIdentity
static constexpr bool IsScatterIdentity
In the remaining methods and constexpr we determine at compilation time which method definition will ...
Definition: WorkletMapTopology.h:190
TransportTagCellSetIn.h
IncidentElementIndices.h
TypeCheckTagArrayOut.h
vtkm::worklet::WorkletMapTopology::FieldInIncident
A control signature tag for input fields from the incident topology.
Definition: WorkletMapTopology.h:90
vtkm::worklet::WorkletVisitPointsWithCells::FieldInCell
FieldInIncident FieldInCell
Definition: WorkletMapTopology.h:278
vtkm::worklet::WorkletVisitCellsWithPoints::PointCount
IncidentElementCount PointCount
Definition: WorkletMapTopology.h:267
ControlSignatureTagBase.h
vtkm::exec::arg::FetchTagArrayTopologyMapIn
Fetch tag for getting array values determined by topology connections.
Definition: FetchTagArrayTopologyMapIn.h:40
vtkm::exec::arg::FetchTagCellSetIn
Fetch tag for getting topology information.
Definition: FetchTagCellSetIn.h:29
vtkm::exec::arg::FetchTagArrayDirectOut
Fetch tag for setting array values with direct indexing.
Definition: FetchTagArrayDirectOut.h:29
vtkm::cont::arg::TransportTagTopologyFieldIn
Transport tag for input arrays in topology maps.
Definition: TransportTagTopologyFieldIn.h:36
TransportTagArrayOut.h
CellShape.h
ThreadIndicesTopologyMap.h
vtkm::cont::arg::TypeCheckTagArrayOut
The Array type check passes for any object that behaves like an ArrayHandle class and can be passed t...
Definition: TypeCheckTagArrayOut.h:31
vtkm::cont::arg::TransportTagArrayInOut
Transport tag for in-place arrays.
Definition: TransportTagArrayInOut.h:33
vtkm::cont::arg::TransportTagArrayOut
Transport tag for output arrays.
Definition: TransportTagArrayOut.h:32
vtkm::worklet::WorkletVisitCellsWithPoints::PointIndices
IncidentElementIndices PointIndices
Definition: WorkletMapTopology.h:269
vtkm::cont::arg::TransportTagCellSetIn
Transport tag for input arrays.
Definition: TransportTagCellSetIn.h:32
vtkm::worklet::WorkletMapTopology::FieldInVisit
A control signature tag for input fields from the visited topology.
Definition: WorkletMapTopology.h:80
vtkm::Id
vtkm::Int32 Id
Represents an ID (index into arrays).
Definition: Types.h:191
vtkm::worklet::WorkletMapTopology::CellShape
An execution signature tag for getting the cell shape.
Definition: WorkletMapTopology.h:132
vtkm::worklet::WorkletMapTopology::IncidentElementIndices
An execution signature tag to get the indices of from elements.
Definition: WorkletMapTopology.h:158
vtkm::cont::arg::TypeCheckTagArrayInOut
The Array type check passes for any object that behaves like an ArrayHandle class and can be passed t...
Definition: TypeCheckTagArrayInOut.h:31
TypeCheckTagArrayInOut.h
vtkm::exec::arg::IncidentElementCount
The ExecutionSignature tag to get the number of incident elements.
Definition: IncidentElementCount.h:40
TransportTagArrayInOut.h
vtkm::cont::arg::TypeCheckTagArrayIn
The Array type check passes for any object that behaves like an ArrayHandle class and can be passed t...
Definition: TypeCheckTagArrayIn.h:31
vtkm::worklet::WorkletMapTopology::FieldInOut
A control signature tag for input-output (in-place) fields from the visited topology.
Definition: WorkletMapTopology.h:112
vtkm::worklet::WorkletMapTopology::IncidentElementCount
An execution signature tag to get the number of incident elements.
Definition: WorkletMapTopology.h:145
vtkm::worklet::WorkletVisitPointsWithCells::CellCount
IncidentElementCount CellCount
Definition: WorkletMapTopology.h:286
vtkm::worklet::WorkletMapTopology::GetThreadIndices
VTKM_SUPPRESS_EXEC_WARNINGS VTKM_EXEC vtkm::exec::arg::ThreadIndicesTopologyMap< InputDomainType, vtkm::exec::arg::CustomScatterOrMaskTag > GetThreadIndices(vtkm::Id threadIndex, const OutToInArrayType &outToIn, const VisitArrayType &visit, const ThreadToOutArrayType &threadToOut, const InputDomainType &connectivity) const
Topology map worklets use topology map indices.
Definition: WorkletMapTopology.h:171
vtkm::worklet::WorkletVisitPointsWithCells
Base class for worklets that map from Cells to Points.
Definition: WorkletMapTopology.h:274
vtkm::exec::arg::FetchTagArrayDirectIn
Fetch tag for getting array values with direct indexing.
Definition: FetchTagArrayDirectIn.h:29
vtkm::worklet::WorkletMapTopology::IsMaskNone
static constexpr bool IsMaskNone
Definition: WorkletMapTopology.h:192
vtkm::worklet::DispatcherMapTopology
Dispatcher for worklets that inherit from WorkletMapTopology.
Definition: DispatcherMapTopology.h:31
TypeCheckTagArrayIn.h
WorkletBase.h
vtkm::worklet::WorkletVisitCellsWithPoints
Base class for worklets that map from Points to Cells.
Definition: WorkletMapTopology.h:255
vtkm::worklet::WorkletVisitCellsWithPoints::FieldInPoint
FieldInIncident FieldInPoint
Definition: WorkletMapTopology.h:259
vtkm::exec::arg::IncidentElementIndices
The ExecutionSignature tag to get the indices of visited elements.
Definition: IncidentElementIndices.h:33
vtkm::worklet::WorkletMapTopology::GetThreadIndices
VTKM_SUPPRESS_EXEC_WARNINGS VTKM_EXEC EnableFnWhen< S &&M, vtkm::exec::arg::ThreadIndicesTopologyMap< InputDomainType, vtkm::exec::arg::DefaultScatterAndMaskTag > > GetThreadIndices(vtkm::Id threadIndex1D, const vtkm::Id3 &threadIndex3D, const OutToInArrayType &vtkmNotUsed(outToIn), const VisitArrayType &vtkmNotUsed(visit), const ThreadToOutArrayType &vtkmNotUsed(threadToOut), const InputDomainType &connectivity) const
Optimized for ScatterIdentity and MaskNone.
Definition: WorkletMapTopology.h:210
vtkm::worklet::WorkletMapTopology< vtkm::TopologyElementTagCell, vtkm::TopologyElementTagPoint >::EnableFnWhen
typename std::enable_if< Cond, ReturnType >::type EnableFnWhen
Definition: WorkletMapTopology.h:195
FetchTagCellSetIn.h
IncidentElementCount.h
vtkmNotUsed
#define vtkmNotUsed(parameter_name)
Simple macro to identify a parameter as unused.
Definition: ExportMacros.h:128
TransportTagTopologyFieldIn.h
FetchTagArrayTopologyMapIn.h
FetchTagArrayDirectIn.h
vtkm::worklet::WorkletVisitPointsWithCells::CellIndices
IncidentElementIndices CellIndices
Definition: WorkletMapTopology.h:288
vtkm::worklet::WorkletVisitPointsWithCells::FieldInPoint
FieldInVisit FieldInPoint
Definition: WorkletMapTopology.h:280
vtkm::cont::arg::ControlSignatureTagBase
The base class for all tags used in a ControlSignature.
Definition: ControlSignatureTagBase.h:36
vtkm::Vec< vtkm::Id, 3 >
vtkm::exec::arg::CustomScatterOrMaskTag
Used for when not using MaskNone and ScatterIdentity.
Definition: ThreadIndicesTopologyMap.h:80
vtkm::exec::arg::CellShape
The ExecutionSignature tag to use to get the cell shape.
Definition: exec/arg/CellShape.h:34
FetchTagArrayDirectInOut.h
vtkm::worklet::WorkletVisitPointsWithCells::FieldOutPoint
FieldOut FieldOutPoint
Definition: WorkletMapTopology.h:282
FetchTagArrayDirectOut.h
vtkm::TopologyElementTagCell
A tag used to identify the cell elements in a topology.
Definition: TopologyElementTag.h:24
TypeCheckTagCellSet.h
vtkm::exec::arg::FetchTagArrayDirectInOut
Fetch tag for in-place modifying array values with direct indexing.
Definition: FetchTagArrayDirectInOut.h:39
vtkm::worklet::WorkletMapTopology::GetThreadIndices
VTKM_SUPPRESS_EXEC_WARNINGS VTKM_EXEC EnableFnWhen<!(S &&M), vtkm::exec::arg::ThreadIndicesTopologyMap< InputDomainType, vtkm::exec::arg::CustomScatterOrMaskTag > > GetThreadIndices(vtkm::Id threadIndex1D, const vtkm::Id3 &threadIndex3D, const OutToInArrayType &outToIn, const VisitArrayType &visit, const ThreadToOutArrayType &threadToOut, const InputDomainType &connectivity) const
Default version.
Definition: WorkletMapTopology.h:234
DispatcherMapTopology.h
vtkm::worklet::WorkletVisitPointsWithCells::FieldInOutPoint
FieldInOut FieldInOutPoint
Definition: WorkletMapTopology.h:284
VTKM_SUPPRESS_EXEC_WARNINGS
#define VTKM_SUPPRESS_EXEC_WARNINGS
Definition: ExportMacros.h:53
vtkm::exec::arg::ThreadIndicesTopologyMap
Container for thread indices in a topology map.
Definition: ThreadIndicesTopologyMap.h:95
vtkm::exec::arg::DefaultScatterAndMaskTag
Uses spaces optimizations when using MaskNone and ScatterIdentity.
Definition: ThreadIndicesTopologyMap.h:74
vtkm::cont::arg::TypeCheckTagCellSet
Check for a CellSet-like object.
Definition: TypeCheckTagCellSet.h:26
vtkm::worklet::WorkletVisitCellsWithPoints::FieldInCell
FieldInVisit FieldInCell
Definition: WorkletMapTopology.h:261
vtkm::worklet::WorkletVisitCellsWithPoints::FieldOutCell
FieldOut FieldOutCell
Definition: WorkletMapTopology.h:263
TopologyElementTag.h
vtkm::worklet::WorkletVisitCellsWithPoints::FieldInOutCell
FieldInOut FieldInOutCell
Definition: WorkletMapTopology.h:265
vtkm::worklet::WorkletMapTopology
Base class for worklets that map topology elements onto each other.
Definition: WorkletMapTopology.h:71