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