VTK-m  2.2
CellDeepCopy.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 //
6 // This software is distributed WITHOUT ANY WARRANTY; without even
7 // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
8 // PURPOSE. See the above copyright notice for more information.
9 //============================================================================
10 #ifndef vtk_m_worklet_CellDeepCopy_h
11 #define vtk_m_worklet_CellDeepCopy_h
12 
18 
21 
22 namespace vtkm
23 {
24 namespace worklet
25 {
26 
31 {
33  {
34  using ControlSignature = void(CellSetIn inputTopology, FieldOut numPointsInCell);
36 
37  VTKM_EXEC
38  vtkm::IdComponent operator()(vtkm::IdComponent numPoints) const { return numPoints; }
39  };
40 
42  {
43  using ControlSignature = void(CellSetIn inputTopology, FieldOut shapes, FieldOut pointIndices);
44  using ExecutionSignature = void(CellShape, PointIndices, _2, _3);
45 
46  template <typename CellShape, typename InPointIndexType, typename OutPointIndexType>
47  VTKM_EXEC void operator()(const CellShape& inShape,
48  const InPointIndexType& inPoints,
49  vtkm::UInt8& outShape,
50  OutPointIndexType& outPoints) const
51  {
52  (void)inShape; //C4100 false positive workaround
53  outShape = inShape.Id;
54 
55  vtkm::IdComponent numPoints = inPoints.GetNumberOfComponents();
56  VTKM_ASSERT(numPoints == outPoints.GetNumberOfComponents());
57  for (vtkm::IdComponent pointIndex = 0; pointIndex < numPoints; pointIndex++)
58  {
59  outPoints[pointIndex] = inPoints[pointIndex];
60  }
61  }
62  };
63 
64  template <typename InCellSetType,
65  typename ShapeStorage,
66  typename ConnectivityStorage,
67  typename OffsetsStorage>
68  VTKM_CONT static void Run(
69  const InCellSetType& inCellSet,
71  vtkm::Id numberOfPoints)
72  {
73  VTKM_IS_KNOWN_OR_UNKNOWN_CELL_SET(InCellSetType);
74 
76 
78  countDispatcher.Invoke(inCellSet, numIndices);
79 
82 
84  vtkm::Id connectivitySize;
85  vtkm::cont::ConvertNumComponentsToOffsets(numIndices, offsets, connectivitySize);
86  connectivity.Allocate(connectivitySize);
87 
89  passDispatcher.Invoke(
90  inCellSet, shapes, vtkm::cont::make_ArrayHandleGroupVecVariable(connectivity, offsets));
91 
93  newCellSet.Fill(numberOfPoints, shapes, connectivity, offsets);
94  outCellSet = newCellSet;
95  }
96 
97  template <typename InCellSetType,
98  typename ShapeStorage,
99  typename ConnectivityStorage,
100  typename OffsetsStorage>
101  VTKM_CONT static void Run(
102  const InCellSetType& inCellSet,
104  {
105  Run(inCellSet, outCellSet, inCellSet.GetNumberOfPoints());
106  }
107 
108  template <typename InCellSetType>
109  VTKM_CONT static vtkm::cont::CellSetExplicit<> Run(const InCellSetType& inCellSet)
110  {
111  VTKM_IS_KNOWN_OR_UNKNOWN_CELL_SET(InCellSetType);
112 
114  Run(inCellSet, outCellSet);
115 
116  return outCellSet;
117  }
118 };
119 }
120 } // namespace vtkm::worklet
121 
122 #endif //vtk_m_worklet_CellDeepCopy_h
vtkm::worklet::WorkletVisitCellsWithPoints::CellShape
An execution signature tag to get the shape of the visited cell.
Definition: WorkletMapTopology.h:396
vtkm::cont::ArrayHandle< vtkm::IdComponent >
VTKM_EXEC
#define VTKM_EXEC
Definition: ExportMacros.h:51
vtkm
Groups connected points that have the same field value.
Definition: Atomic.h:19
VTKM_ASSERT
#define VTKM_ASSERT(condition)
Definition: Assert.h:43
CellSetExplicit.h
VTKM_IS_KNOWN_OR_UNKNOWN_CELL_SET
#define VTKM_IS_KNOWN_OR_UNKNOWN_CELL_SET(T)
Definition: UnknownCellSet.h:313
UnknownCellSet.h
vtkm::worklet::CellDeepCopy::CountCellPoints::ControlSignature
void(CellSetIn inputTopology, FieldOut numPointsInCell) ControlSignature
Definition: CellDeepCopy.h:34
vtkm::IdComponent
vtkm::Int32 IdComponent
Base type to use to index small lists.
Definition: Types.h:194
ArrayHandleConstant.h
vtkm::cont::CellSetExplicit::GetNumberOfPoints
vtkm::Id GetNumberOfPoints() const override
vtkm::worklet::CellDeepCopy::Run
static void Run(const InCellSetType &inCellSet, vtkm::cont::CellSetExplicit< ShapeStorage, ConnectivityStorage, OffsetsStorage > &outCellSet, vtkm::Id numberOfPoints)
Definition: CellDeepCopy.h:68
vtkm::worklet::WorkletVisitCellsWithPoints::CellSetIn
A control signature tag for input connectivity.
Definition: WorkletMapTopology.h:280
vtkm::cont::CellSetExplicit::Fill
void Fill(vtkm::Id numPoints, const vtkm::cont::ArrayHandle< vtkm::UInt8, ShapesStorageTag > &cellTypes, const vtkm::cont::ArrayHandle< vtkm::Id, ConnectivityStorageTag > &connectivity, const vtkm::cont::ArrayHandle< vtkm::Id, OffsetsStorageTag > &offsets)
Set all the cells of the mesh.
vtkm::worklet::CellDeepCopy::PassCellStructure::ExecutionSignature
void(CellShape, PointIndices, _2, _3) ExecutionSignature
Definition: CellDeepCopy.h:44
vtkm::worklet::CellDeepCopy::CountCellPoints
Definition: CellDeepCopy.h:32
vtkm::cont::ConvertNumComponentsToOffsets
void ConvertNumComponentsToOffsets(const vtkm::cont::UnknownArrayHandle &numComponentsArray, vtkm::cont::ArrayHandle< vtkm::Id > &offsetsArray, vtkm::Id &componentsArraySize, vtkm::cont::DeviceAdapterId device=vtkm::cont::DeviceAdapterTagAny{})
ConvertNumComponentsToOffsets takes an array of Vec sizes (i.e.
vtkm::worklet::CellDeepCopy::Run
static void Run(const InCellSetType &inCellSet, vtkm::cont::CellSetExplicit< ShapeStorage, ConnectivityStorage, OffsetsStorage > &outCellSet)
Definition: CellDeepCopy.h:101
vtkm::worklet::DispatcherMapTopology
Dispatcher for worklets that inherit from WorkletMapTopology.
Definition: DispatcherMapTopology.h:31
vtkm::worklet::WorkletVisitCellsWithPoints
Base class for worklets that map from Points to Cells.
Definition: WorkletMapTopology.h:256
vtkm::worklet::WorkletVisitCellsWithPoints::FieldOut
A control signature tag for output fields.
Definition: WorkletMapTopology.h:329
vtkm::worklet::CellDeepCopy::CountCellPoints::operator()
vtkm::IdComponent operator()(vtkm::IdComponent numPoints) const
Definition: CellDeepCopy.h:38
VTKM_CONT
#define VTKM_CONT
Definition: ExportMacros.h:57
vtkm::Id
vtkm::Int64 Id
Base type to use to index arrays.
Definition: Types.h:227
vtkm::worklet::CellDeepCopy::Run
static vtkm::cont::CellSetExplicit Run(const InCellSetType &inCellSet)
Definition: CellDeepCopy.h:109
vtkm::UInt8
uint8_t UInt8
Base type to use for 8-bit unsigned integer numbers.
Definition: Types.h:169
vtkm::worklet::CellDeepCopy::CountCellPoints::ExecutionSignature
_2(PointCount) ExecutionSignature
Definition: CellDeepCopy.h:35
vtkm::worklet::CellDeepCopy::PassCellStructure
Definition: CellDeepCopy.h:41
vtkm::worklet::CellDeepCopy
Container for worklets and helper methods to copy a cell set to a new CellSetExplicit structure.
Definition: CellDeepCopy.h:30
ConvertNumComponentsToOffsets.h
vtkm::cont::CellSetExplicit
Defines an irregular collection of cells.
Definition: CastAndCall.h:36
vtkm::worklet::WorkletVisitCellsWithPoints::PointCount
An execution signature tag to get the number of incident points.
Definition: WorkletMapTopology.h:406
vtkm::worklet::CellDeepCopy::PassCellStructure::operator()
void operator()(const CellShape &inShape, const InPointIndexType &inPoints, vtkm::UInt8 &outShape, OutPointIndexType &outPoints) const
Definition: CellDeepCopy.h:47
ArrayHandleGroupVecVariable.h
vtkm::cont::ArrayHandle::Allocate
void Allocate(vtkm::Id numberOfValues, vtkm::CopyFlag preserve, vtkm::cont::Token &token) const
Allocates an array large enough to hold the given number of values.
Definition: ArrayHandle.h:490
vtkm::cont::make_ArrayHandleGroupVecVariable
vtkm::cont::ArrayHandleGroupVecVariable< ComponentsArrayHandleType, OffsetsArrayHandleType > make_ArrayHandleGroupVecVariable(const ComponentsArrayHandleType &componentsArray, const OffsetsArrayHandleType &offsetsArray)
make_ArrayHandleGroupVecVariable is convenience function to generate an ArrayHandleGroupVecVariable.
Definition: ArrayHandleGroupVecVariable.h:323
DispatcherMapTopology.h
WorkletMapTopology.h
vtkm::worklet::CellDeepCopy::PassCellStructure::ControlSignature
void(CellSetIn inputTopology, FieldOut shapes, FieldOut pointIndices) ControlSignature
Definition: CellDeepCopy.h:43
vtkm::worklet::WorkletVisitCellsWithPoints::PointIndices
An execution signature tag to get the indices of the incident points.
Definition: WorkletMapTopology.h:416