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