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/tbb/DeviceAdapterTBB.h>
35 
36 namespace vtkm {
37 namespace exec {
38 
39 template <typename Device> class VTKM_ALWAYS_EXPORT ConnectivityVTKAOS
40 {
41  typedef vtkm::cont::ArrayHandle<vtkm::UInt8, tovtkm::vtkAOSArrayContainerTag>
42  ShapeHandleType;
43  typedef vtkm::cont::ArrayHandle<vtkm::Id, tovtkm::vtkCellArrayContainerTag>
44  ConnectivityHandleType;
45  typedef vtkm::cont::ArrayHandle<vtkm::Id, tovtkm::vtkAOSArrayContainerTag>
46  OffsetHandleType;
47 
48  typedef typename ShapeHandleType::template ExecutionTypes<Device>::PortalConst
49  ShapePortalType;
50  typedef typename ConnectivityHandleType::template ExecutionTypes<
51  Device>::PortalConst ConnectivityPortalType;
52  typedef
53  typename OffsetHandleType::template ExecutionTypes<Device>::PortalConst
54  IndexOffsetPortalType;
55 
56 public:
57  typedef typename vtkm::Id SchedulingRangeType;
58 
59  VTKM_SUPPRESS_EXEC_WARNINGS
60  VTKM_EXEC_CONT
62 
63  VTKM_EXEC_CONT
64  ConnectivityVTKAOS(const ShapePortalType& shapePortal,
65  const ConnectivityPortalType& connPortal,
66  const IndexOffsetPortalType& indexOffsetPortal);
67 
68  VTKM_SUPPRESS_EXEC_WARNINGS
69  VTKM_EXEC
70  vtkm::Id GetNumberOfElements() const;
71 
72  typedef vtkm::CellShapeTagGeneric CellShapeTag;
73 
74  VTKM_EXEC
75  CellShapeTag GetCellShape(vtkm::Id index) const;
76 
77  typedef vtkm::VecFromPortal<ConnectivityPortalType> IndicesType;
78 
84  VTKM_EXEC
85  IndicesType GetIndices(vtkm::Id index) const;
86 
87 private:
88  ShapePortalType Shapes;
89  ConnectivityPortalType Connectivity;
90  IndexOffsetPortalType IndexOffsets;
91 };
92 
93 
94 template <typename Device> class VTKM_ALWAYS_EXPORT ConnectivityVTKSingleType
95 {
96  typedef vtkm::cont::ArrayHandle<vtkm::Id, tovtkm::vtkCellArrayContainerTag>
97  ConnectivityHandleType;
98  typedef typename ConnectivityHandleType::template ExecutionTypes<
99  Device>::PortalConst ConnectivityPortalType;
100 
101 public:
102  typedef typename vtkm::Id SchedulingRangeType;
103 
104  VTKM_SUPPRESS_EXEC_WARNINGS
105  VTKM_EXEC_CONT
107 
108  VTKM_EXEC_CONT
109  ConnectivityVTKSingleType(const ConnectivityPortalType& connPortal,
110  vtkm::Id numCells,
111  vtkm::IdComponent numPointsPerCell,
112  vtkm::UInt8 shapeType);
113 
114  VTKM_EXEC
115  vtkm::Id GetNumberOfElements() const;
116 
117  typedef vtkm::CellShapeTagGeneric CellShapeTag;
118 
119  VTKM_EXEC
120  CellShapeTag GetCellShape(vtkm::Id index) const;
121 
122  typedef vtkm::VecFromPortal<ConnectivityPortalType> IndicesType;
123 
129  VTKM_EXEC
130  IndicesType GetIndices(vtkm::Id index) const;
131 
132 private:
133  ConnectivityPortalType Connectivity;
134  vtkm::Id NumberOfCells;
135  vtkm::IdComponent NumberOfPointsPerCell;
136  vtkm::UInt8 ShapeType;
137 };
138 
139 
140 template <typename Device> class VTKM_ALWAYS_EXPORT ReverseConnectivityVTK
141 {
142  typedef vtkm::cont::ArrayHandle<vtkm::Id> ConnectivityHandleType;
143  typedef vtkm::cont::ArrayHandle<vtkm::IdComponent> NumIndicesHandleType;
144  typedef vtkm::cont::ArrayHandle<vtkm::Id> OffsetHandleType;
145 
146  typedef typename ConnectivityHandleType::template ExecutionTypes<
147  Device>::PortalConst ConnectivityPortalType;
148 
149  typedef typename OffsetHandleType::template ExecutionTypes<Device>::PortalConst
150  IndexOffsetPortalType;
151 
152  typedef typename NumIndicesHandleType::template ExecutionTypes<Device>::PortalConst
153  NumIndicesPortalType;
154 
155 public:
156  typedef typename vtkm::Id SchedulingRangeType;
157 
158  VTKM_SUPPRESS_EXEC_WARNINGS
159  VTKM_EXEC_CONT
161 
162  VTKM_EXEC_CONT
163  ReverseConnectivityVTK(const ConnectivityPortalType& connPortal,
164  const NumIndicesPortalType& numIndicesPortal,
165  const IndexOffsetPortalType& indexOffsetPortal);
166 
167  VTKM_EXEC
168  vtkm::Id GetNumberOfElements() const;
169 
170  typedef vtkm::CellShapeTagVertex CellShapeTag;
171 
172  VTKM_EXEC
173  CellShapeTag GetCellShape(vtkm::Id) const { return vtkm::CellShapeTagVertex(); }
174 
175  typedef vtkm::VecFromPortal<ConnectivityPortalType> IndicesType;
176 
182  VTKM_EXEC
183  IndicesType GetIndices(vtkm::Id index) const;
184 
185 private:
186  ConnectivityPortalType Connectivity;
187  NumIndicesPortalType NumIndices;
188  IndexOffsetPortalType IndexOffsets;
189 };
190 
191 // template methods we want to compile only once
192 extern template class VTKACCELERATORSVTKM_TEMPLATE_EXPORT ConnectivityVTKAOS<vtkm::cont::DeviceAdapterTagSerial>;
193 extern template class VTKACCELERATORSVTKM_TEMPLATE_EXPORT ConnectivityVTKSingleType<vtkm::cont::DeviceAdapterTagSerial>;
194 extern template class VTKACCELERATORSVTKM_TEMPLATE_EXPORT ReverseConnectivityVTK<vtkm::cont::DeviceAdapterTagSerial>;
195 
196 #ifdef VTKM_ENABLE_TBB
197 extern template class VTKACCELERATORSVTKM_TEMPLATE_EXPORT ConnectivityVTKAOS<vtkm::cont::DeviceAdapterTagTBB>;
198 extern template class VTKACCELERATORSVTKM_TEMPLATE_EXPORT ConnectivityVTKSingleType<vtkm::cont::DeviceAdapterTagTBB>;
199 extern template class VTKACCELERATORSVTKM_TEMPLATE_EXPORT ReverseConnectivityVTK<vtkm::cont::DeviceAdapterTagTBB>;
200 #endif
201 
202 //only when cuda is enabled, and the compiler is cuda
203 #if defined(VTKM_ENABLE_CUDA) && defined(VTKM_CUDA)
204 extern template class VTKACCELERATORSVTKM_TEMPLATE_EXPORT ConnectivityVTKAOS<vtkm::cont::DeviceAdapterTagCuda>;
205 extern template class VTKACCELERATORSVTKM_TEMPLATE_EXPORT ConnectivityVTKSingleType<vtkm::cont::DeviceAdapterTagCuda>;
206 extern template class VTKACCELERATORSVTKM_TEMPLATE_EXPORT ReverseConnectivityVTK<vtkm::cont::DeviceAdapterTagCuda>;
207 #endif
208 }
209 }
210 
211 
212 #endif
213 #endif
214 #endif
215 // 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