VTK
vtkmConnectivityExec.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 // This software is distributed WITHOUT ANY WARRANTY; without even
6 // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
7 // PURPOSE. See the above copyright notice for more information.
8 //
9 // Copyright 2015 Sandia Corporation.
10 // Copyright 2015 UT-Battelle, LLC.
11 // Copyright 2015 Los Alamos National Security.
12 //
13 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
14 // the U.S. Government retains certain rights in this software.
15 //
16 // Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National
17 // Laboratory (LANL), the U.S. Government retains certain rights in
18 // this software.
19 //============================================================================
20 #ifndef vtkmConnectivityExec_h
21 #define vtkmConnectivityExec_h
22 #ifndef __VTK_WRAP__
23 #ifndef VTK_WRAPPING_CXX
24 
25 #include "vtkmTags.h"
26 
27 #include <vtkm/CellShape.h>
28 #include <vtkm/TopologyElementTag.h>
29 #include <vtkm/cont/ArrayHandle.h>
30 #include <vtkm/VecFromPortal.h>
31 
32 #include <vtkm/cont/serial/DeviceAdapterSerial.h>
33 #include <vtkm/cont/cuda/DeviceAdapterCuda.h>
34 #include <vtkm/cont/openmp/DeviceAdapterOpenMP.h>
35 #include <vtkm/cont/tbb/DeviceAdapterTBB.h>
36 
37 namespace vtkm {
38 namespace exec {
39 
40 template <typename Device> class VTKM_ALWAYS_EXPORT ConnectivityVTKAOS
41 {
42  typedef vtkm::cont::ArrayHandle<vtkm::UInt8, tovtkm::vtkAOSArrayContainerTag>
43  ShapeHandleType;
44  typedef vtkm::cont::ArrayHandle<vtkm::Id, tovtkm::vtkCellArrayContainerTag>
45  ConnectivityHandleType;
46  typedef vtkm::cont::ArrayHandle<vtkm::Id, tovtkm::vtkAOSArrayContainerTag>
47  OffsetHandleType;
48 
49  typedef typename ShapeHandleType::template ExecutionTypes<Device>::PortalConst
50  ShapePortalType;
51  typedef typename ConnectivityHandleType::template ExecutionTypes<
52  Device>::PortalConst ConnectivityPortalType;
53  typedef
54  typename OffsetHandleType::template ExecutionTypes<Device>::PortalConst
55  IndexOffsetPortalType;
56 
57 public:
58  typedef typename vtkm::Id SchedulingRangeType;
59 
60  VTKM_SUPPRESS_EXEC_WARNINGS
61  VTKM_EXEC_CONT
63 
64  VTKM_EXEC_CONT
65  ConnectivityVTKAOS(const ShapePortalType& shapePortal,
66  const ConnectivityPortalType& connPortal,
67  const IndexOffsetPortalType& indexOffsetPortal);
68 
69  VTKM_SUPPRESS_EXEC_WARNINGS
70  VTKM_EXEC
71  vtkm::Id GetNumberOfElements() const;
72 
73  typedef vtkm::CellShapeTagGeneric CellShapeTag;
74 
75  VTKM_EXEC
76  CellShapeTag GetCellShape(vtkm::Id index) const;
77 
78  typedef vtkm::VecFromPortal<ConnectivityPortalType> IndicesType;
79 
85  VTKM_EXEC
86  IndicesType GetIndices(vtkm::Id index) const;
87 
88 private:
89  ShapePortalType Shapes;
90  ConnectivityPortalType Connectivity;
91  IndexOffsetPortalType IndexOffsets;
92 };
93 
94 
95 template <typename Device> class VTKM_ALWAYS_EXPORT ConnectivityVTKSingleType
96 {
97  typedef vtkm::cont::ArrayHandle<vtkm::Id, tovtkm::vtkCellArrayContainerTag>
98  ConnectivityHandleType;
99  typedef typename ConnectivityHandleType::template ExecutionTypes<
100  Device>::PortalConst ConnectivityPortalType;
101 
102 public:
103  typedef typename vtkm::Id SchedulingRangeType;
104 
105  VTKM_SUPPRESS_EXEC_WARNINGS
106  VTKM_EXEC_CONT
108 
109  VTKM_EXEC_CONT
110  ConnectivityVTKSingleType(const ConnectivityPortalType& connPortal,
111  vtkm::Id numCells,
112  vtkm::IdComponent numPointsPerCell,
113  vtkm::UInt8 shapeType);
114 
115  VTKM_EXEC
116  vtkm::Id GetNumberOfElements() const;
117 
118  typedef vtkm::CellShapeTagGeneric CellShapeTag;
119 
120  VTKM_EXEC
121  CellShapeTag GetCellShape(vtkm::Id index) const;
122 
123  typedef vtkm::VecFromPortal<ConnectivityPortalType> IndicesType;
124 
130  VTKM_EXEC
131  IndicesType GetIndices(vtkm::Id index) const;
132 
133 private:
134  ConnectivityPortalType Connectivity;
135  vtkm::Id NumberOfCells;
136  vtkm::IdComponent NumberOfPointsPerCell;
137  vtkm::UInt8 ShapeType;
138 };
139 
140 
141 template <typename Device> class VTKM_ALWAYS_EXPORT ReverseConnectivityVTK
142 {
143  typedef vtkm::cont::ArrayHandle<vtkm::Id> ConnectivityHandleType;
144  typedef vtkm::cont::ArrayHandle<vtkm::IdComponent> NumIndicesHandleType;
145  typedef vtkm::cont::ArrayHandle<vtkm::Id> OffsetHandleType;
146 
147  typedef typename ConnectivityHandleType::template ExecutionTypes<
148  Device>::PortalConst ConnectivityPortalType;
149 
150  typedef typename OffsetHandleType::template ExecutionTypes<Device>::PortalConst
151  IndexOffsetPortalType;
152 
153  typedef typename NumIndicesHandleType::template ExecutionTypes<Device>::PortalConst
154  NumIndicesPortalType;
155 
156 public:
157  typedef typename vtkm::Id SchedulingRangeType;
158 
159  VTKM_SUPPRESS_EXEC_WARNINGS
160  VTKM_EXEC_CONT
162 
163  VTKM_EXEC_CONT
164  ReverseConnectivityVTK(const ConnectivityPortalType& connPortal,
165  const NumIndicesPortalType& numIndicesPortal,
166  const IndexOffsetPortalType& indexOffsetPortal);
167 
168  VTKM_EXEC
169  vtkm::Id GetNumberOfElements() const;
170 
171  typedef vtkm::CellShapeTagVertex CellShapeTag;
172 
173  VTKM_EXEC
174  CellShapeTag GetCellShape(vtkm::Id) const { return vtkm::CellShapeTagVertex(); }
175 
176  typedef vtkm::VecFromPortal<ConnectivityPortalType> IndicesType;
177 
183  VTKM_EXEC
184  IndicesType GetIndices(vtkm::Id index) const;
185 
186 private:
187  ConnectivityPortalType Connectivity;
188  NumIndicesPortalType NumIndices;
189  IndexOffsetPortalType IndexOffsets;
190 };
191 
192 // template methods we want to compile only once
193 extern template class VTKACCELERATORSVTKM_TEMPLATE_EXPORT ConnectivityVTKAOS<vtkm::cont::DeviceAdapterTagSerial>;
194 extern template class VTKACCELERATORSVTKM_TEMPLATE_EXPORT ConnectivityVTKSingleType<vtkm::cont::DeviceAdapterTagSerial>;
195 extern template class VTKACCELERATORSVTKM_TEMPLATE_EXPORT ReverseConnectivityVTK<vtkm::cont::DeviceAdapterTagSerial>;
196 
197 #ifdef VTKM_ENABLE_TBB
198 extern template class VTKACCELERATORSVTKM_TEMPLATE_EXPORT ConnectivityVTKAOS<vtkm::cont::DeviceAdapterTagTBB>;
199 extern template class VTKACCELERATORSVTKM_TEMPLATE_EXPORT ConnectivityVTKSingleType<vtkm::cont::DeviceAdapterTagTBB>;
200 extern template class VTKACCELERATORSVTKM_TEMPLATE_EXPORT ReverseConnectivityVTK<vtkm::cont::DeviceAdapterTagTBB>;
201 #endif
202 
203 #ifdef VTKM_ENABLE_OPENMP
204 extern template class VTKACCELERATORSVTKM_TEMPLATE_EXPORT ConnectivityVTKAOS<vtkm::cont::DeviceAdapterTagOpenMP>;
205 extern template class VTKACCELERATORSVTKM_TEMPLATE_EXPORT ConnectivityVTKSingleType<vtkm::cont::DeviceAdapterTagOpenMP>;
206 extern template class VTKACCELERATORSVTKM_TEMPLATE_EXPORT ReverseConnectivityVTK<vtkm::cont::DeviceAdapterTagOpenMP>;
207 #endif
208 
209 //only when cuda is enabled, and the compiler is cuda
210 #if defined(VTKM_ENABLE_CUDA) && defined(VTKM_CUDA)
211 extern template class VTKACCELERATORSVTKM_TEMPLATE_EXPORT ConnectivityVTKAOS<vtkm::cont::DeviceAdapterTagCuda>;
212 extern template class VTKACCELERATORSVTKM_TEMPLATE_EXPORT ConnectivityVTKSingleType<vtkm::cont::DeviceAdapterTagCuda>;
213 extern template class VTKACCELERATORSVTKM_TEMPLATE_EXPORT ReverseConnectivityVTK<vtkm::cont::DeviceAdapterTagCuda>;
214 #endif
215 }
216 }
217 
218 
219 #endif
220 #endif
221 #endif
222 // VTK-HeaderTest-Exclude: vtkmConnectivityExec.h
vtkm::CellShapeTagGeneric CellShapeTag
vtkm::VecFromPortal< ConnectivityPortalType > IndicesType
vtkm::VecFromPortal< ConnectivityPortalType > IndicesType
VTKM_EXEC CellShapeTag GetCellShape(vtkm::Id) const
vtkm::VecFromPortal< ConnectivityPortalType > IndicesType