10 #ifndef vtk_m_cont_CellSetPermutation_h
11 #define vtk_m_cont_CellSetPermutation_h
31 #ifndef VTKM_DEFAULT_CELLSET_PERMUTATION_STORAGE_TAG
32 #define VTKM_DEFAULT_CELLSET_PERMUTATION_STORAGE_TAG VTKM_DEFAULT_STORAGE_TAG
48 class RConnTableHelpers
53 using ControlSignature = void(CellSetIn cellset, FieldOutCell numIndices);
54 using ExecutionSignature = void(PointCount, _2);
55 using InputDomain = _1;
59 numIndices = pointCount;
65 using ControlSignature = void(CellSetIn cellset, FieldOutCell connectivity);
66 using ExecutionSignature = void(PointCount, PointIndices, _2);
67 using InputDomain = _1;
69 template <
typename Po
intIndicesType,
typename OutConnectivityType>
71 const PointIndicesType& pointIndices,
72 OutConnectivityType& connectivity)
const
76 connectivity[i] = pointIndices[i];
81 template <
typename CellSetPermutationType>
83 const CellSetPermutationType& cs,
91 template <
typename NumIndicesStorageType>
97 return vtkm::cont::internal::ConvertNumComponentsToOffsetsTemplate(numIndices,
101 template <
typename CellSetPermutationType,
typename OffsetsStorageType>
103 const CellSetPermutationType& cs,
109 connectivity.
Allocate(connectivityLength);
118 template <
typename ConnectivityStorageTag = VTKM_DEFAULT_STORAGE_TAG,
119 typename OffsetsStorageTag = VTKM_DEFAULT_STORAGE_TAG,
120 typename NumIndicesStorageTag = VTKM_DEFAULT_STORAGE_TAG>
121 struct RConnBuilderInputData
127 ConnectivityArrayType Connectivity;
128 OffsetsArrayType Offsets;
129 NumIndicesArrayType NumIndices;
133 template <
typename CellSetPermutationType>
134 class RConnBuilderInput
137 using ConnectivityArrays = vtkm::cont::internal::RConnBuilderInputData<>;
139 static ConnectivityArrays
Get(
const CellSetPermutationType& cellset,
142 using Helper = RConnTableHelpers;
143 ConnectivityArrays conn;
146 conn.NumIndices = Helper::GetNumIndicesArray(cellset, device);
147 conn.Offsets = Helper::GetOffsetsArray(conn.NumIndices, connectivityLength, device);
149 Helper::GetConnectivityArray(cellset, conn.Offsets, connectivityLength, device);
156 template <
typename InShapesST,
158 typename InOffsetsST,
159 typename PermutationArrayHandleType>
160 class RConnBuilderInput<CellSetPermutation<CellSetExplicit<InShapesST, InConnST, InOffsetsST>,
161 PermutationArrayHandleType>>
164 using BaseCellSetType = CellSetExplicit<InShapesST, InConnST, InOffsetsST>;
165 using CellSetPermutationType = CellSetPermutation<BaseCellSetType, PermutationArrayHandleType>;
167 using InShapesArrayType =
typename BaseCellSetType::ShapesArrayType;
168 using InNumIndicesArrayType =
typename BaseCellSetType::NumIndicesArrayType;
172 using NumIndicesStorageTag =
174 InNumIndicesArrayType>::StorageTag;
178 using ConnectivityArrays = vtkm::cont::internal::
179 RConnBuilderInputData<ConnectivityStorageTag, OffsetsStorageTag, NumIndicesStorageTag>;
181 static ConnectivityArrays
Get(
const CellSetPermutationType& cellset,
184 using Helper = RConnTableHelpers;
189 auto fullCellSet = cellset.GetFullCellSet();
192 ConnectivityArrays conn;
194 fullCellSet.GetOffsetsArray(cell, point);
199 cellset.GetValidCellIds(), fullCellSet.GetNumIndicesArray(cell, point));
203 conn.Offsets = Helper::GetOffsetsArray(conn.NumIndices, connectivityLength, device);
210 Helper::GetConnectivityArray(cellset, conn.Offsets, connectivityLength, device);
217 template <vtkm::IdComponent DIMENSION,
typename PermutationArrayHandleType>
218 class RConnBuilderInput<
219 CellSetPermutation<CellSetStructured<DIMENSION>, PermutationArrayHandleType>>
222 using CellSetPermutationType =
223 CellSetPermutation<CellSetStructured<DIMENSION>, PermutationArrayHandleType>;
226 using ConnectivityArrays = vtkm::cont::internal::RConnBuilderInputData<
227 VTKM_DEFAULT_STORAGE_TAG,
231 static ConnectivityArrays
Get(
const CellSetPermutationType& cellset,
234 vtkm::Id numberOfCells = cellset.GetNumberOfCells();
236 vtkm::internal::ConnectivityStructuredInternals<DIMENSION>::NUM_POINTS_IN_CELL;
237 vtkm::Id connectivityLength = numberOfCells * numPointsInCell;
239 ConnectivityArrays conn;
241 conn.Offsets = ArrayHandleCounting<vtkm::Id>(0, numPointsInCell, numberOfCells + 1);
243 RConnTableHelpers::GetConnectivityArray(cellset, conn.Offsets, connectivityLength, device);
249 template <
typename CellSetPermutationType>
250 struct CellSetPermutationTraits;
252 template <
typename OriginalCellSet_,
typename PermutationArrayHandleType_>
253 struct CellSetPermutationTraits<CellSetPermutation<OriginalCellSet_, PermutationArrayHandleType_>>
255 using OriginalCellSet = OriginalCellSet_;
256 using PermutationArrayHandleType = PermutationArrayHandleType_;
259 template <
typename OriginalCellSet_,
260 typename OriginalPermutationArrayHandleType,
261 typename PermutationArrayHandleType_>
262 struct CellSetPermutationTraits<
263 CellSetPermutation<CellSetPermutation<OriginalCellSet_, OriginalPermutationArrayHandleType>,
264 PermutationArrayHandleType_>>
266 using PreviousCellSet = CellSetPermutation<OriginalCellSet_, OriginalPermutationArrayHandleType>;
268 PermutationArrayHandleType_,
269 typename CellSetPermutationTraits<PreviousCellSet>::PermutationArrayHandleType>;
270 using OriginalCellSet =
typename CellSetPermutationTraits<PreviousCellSet>::OriginalCellSet;
271 using Superclass = CellSetPermutation<OriginalCellSet, PermutationArrayHandleType>;
274 template <
typename VisitTopology,
275 typename IncidentTopology,
276 typename OriginalCellSetType,
277 typename PermutationArrayHandleType>
278 struct CellSetPermutationConnectivityChooser;
280 template <
typename OriginalCellSetType,
typename PermutationArrayHandleType>
281 struct CellSetPermutationConnectivityChooser<
vtkm::TopologyElementTagCell,
284 PermutationArrayHandleType>
286 using ExecPortalType =
typename PermutationArrayHandleType::ReadPortalType;
287 using OrigExecObjectType =
291 using ExecConnectivityType =
295 template <
typename OriginalCellSetType,
typename PermutationArrayHandleType>
296 struct CellSetPermutationConnectivityChooser<
vtkm::TopologyElementTagPoint,
299 PermutationArrayHandleType>
305 using ExecConnectivityType =
321 template <
typename OriginalCellSetType_,
322 typename PermutationArrayHandleType_ =
324 class CellSetPermutation :
public CellSet
329 (std::is_same<vtkm::Id, typename PermutationArrayHandleType_::ValueType>::value),
330 "Must use ArrayHandle with value type of Id for permutation array.");
411 "Calling GetCellShape(cellid) is a performance bug. Call ShapesReadPortal() "
412 "and loop over the Get.")
429 return std::make_shared<CellSetPermutation>();
440 this->
FullCellSet.DeepCopy(&(other->GetFullCellSet()));
467 template <
typename VisitTopology,
typename Inc
identTopology>
494 using ConnectivityType =
496 return ConnectivityType(
498 this->FullCellSet.PrepareForInput(device, visitTopology, incidentTopology, token));
502 VTKM_CONT ExecConnectivityType<vtkm::TopologyElementTagPoint, vtkm::TopologyElementTagCell>
509 (void)incidentTopology;
513 internal::ComputeRConnTable(
517 using ConnectivityType =
520 this->VisitPointsWithCells.Offsets.PrepareForInput(device, token));
526 out <<
"CellSetPermutation of: " << std::endl;
528 out <<
"Permutation Array: " << std::endl;
541 template <
typename CellSetType,
542 typename PermutationArrayHandleType1,
543 typename PermutationArrayHandleType2>
545 PermutationArrayHandleType2>
546 :
public internal::CellSetPermutationTraits<
547 CellSetPermutation<CellSetPermutation<CellSetType, PermutationArrayHandleType1>,
551 using Superclass =
typename internal::CellSetPermutationTraits<CellSetPermutation>::Superclass;
571 void Fill(
const PermutationArrayHandleType2& validCellIds,
580 return std::make_shared<CellSetPermutation>();
584 template <
typename OriginalCellSet,
typename PermutationArrayHandleType>
586 const PermutationArrayHandleType& cellIndexMap,
587 const OriginalCellSet& cellSet)
606 template <
typename CSType,
typename AHVal
idCellIds>
607 struct SerializableTypeString<
vtkm::cont::CellSetPermutation<CSType, AHValidCellIds>>
622 template <
typename CSType,
typename AHVal
idCellIds>
623 struct Serialization<
vtkm::cont::CellSetPermutation<CSType, AHValidCellIds>>
629 static VTKM_CONT void save(BinaryBuffer& bb,
const Type& cs)
631 vtkmdiy::save(bb, cs.GetFullCellSet());
632 vtkmdiy::save(bb, cs.GetValidCellIds());
639 AHValidCellIds validCellIds;
649 #endif //vtk_m_cont_CellSetPermutation_h