Viskores  1.0
CellDeepCopy.h
Go to the documentation of this file.
1 //============================================================================
2 // The contents of this file are covered by the Viskores license. See
3 // LICENSE.txt for details.
4 //
5 // By contributing to this file, all contributors agree to the Developer
6 // Certificate of Origin Version 1.1 (DCO 1.1) as stated in DCO.txt.
7 //============================================================================
8 
9 //============================================================================
10 // Copyright (c) Kitware, Inc.
11 // All rights reserved.
12 // See LICENSE.txt for details.
13 //
14 // This software is distributed WITHOUT ANY WARRANTY; without even
15 // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
16 // PURPOSE. See the above copyright notice for more information.
17 //============================================================================
18 #ifndef viskores_worklet_CellDeepCopy_h
19 #define viskores_worklet_CellDeepCopy_h
20 
26 
29 
30 namespace viskores
31 {
32 namespace worklet
33 {
34 
39 {
41  {
42  using ControlSignature = void(CellSetIn inputTopology, FieldOut numPointsInCell);
44 
46  viskores::IdComponent operator()(viskores::IdComponent numPoints) const { return numPoints; }
47  };
48 
50  {
51  using ControlSignature = void(CellSetIn inputTopology, FieldOut shapes, FieldOut pointIndices);
52  using ExecutionSignature = void(CellShape, PointIndices, _2, _3);
53 
54  template <typename CellShape, typename InPointIndexType, typename OutPointIndexType>
55  VISKORES_EXEC void operator()(const CellShape& inShape,
56  const InPointIndexType& inPoints,
57  viskores::UInt8& outShape,
58  OutPointIndexType& outPoints) const
59  {
60  (void)inShape; //C4100 false positive workaround
61  outShape = inShape.Id;
62 
63  viskores::IdComponent numPoints = inPoints.GetNumberOfComponents();
64  VISKORES_ASSERT(numPoints == outPoints.GetNumberOfComponents());
65  for (viskores::IdComponent pointIndex = 0; pointIndex < numPoints; pointIndex++)
66  {
67  outPoints[pointIndex] = inPoints[pointIndex];
68  }
69  }
70  };
71 
72  template <typename InCellSetType,
73  typename ShapeStorage,
74  typename ConnectivityStorage,
75  typename OffsetsStorage>
76  VISKORES_CONT static void Run(
77  const InCellSetType& inCellSet,
79  viskores::Id numberOfPoints)
80  {
82 
84 
86  countDispatcher.Invoke(inCellSet, numIndices);
87 
90 
92  viskores::Id connectivitySize;
93  viskores::cont::ConvertNumComponentsToOffsets(numIndices, offsets, connectivitySize);
94  connectivity.Allocate(connectivitySize);
95 
97  passDispatcher.Invoke(
98  inCellSet, shapes, viskores::cont::make_ArrayHandleGroupVecVariable(connectivity, offsets));
99 
101  newCellSet.Fill(numberOfPoints, shapes, connectivity, offsets);
102  outCellSet = newCellSet;
103  }
104 
105  template <typename InCellSetType,
106  typename ShapeStorage,
107  typename ConnectivityStorage,
108  typename OffsetsStorage>
109  VISKORES_CONT static void Run(
110  const InCellSetType& inCellSet,
112  {
113  Run(inCellSet, outCellSet, inCellSet.GetNumberOfPoints());
114  }
115 
116  template <typename InCellSetType>
117  VISKORES_CONT static viskores::cont::CellSetExplicit<> Run(const InCellSetType& inCellSet)
118  {
120 
122  Run(inCellSet, outCellSet);
123 
124  return outCellSet;
125  }
126 };
127 }
128 } // namespace viskores::worklet
129 
130 #endif //viskores_worklet_CellDeepCopy_h
VISKORES_IS_KNOWN_OR_UNKNOWN_CELL_SET
#define VISKORES_IS_KNOWN_OR_UNKNOWN_CELL_SET(T)
Definition: UnknownCellSet.h:325
viskores::worklet::CellDeepCopy::PassCellStructure::operator()
void operator()(const CellShape &inShape, const InPointIndexType &inPoints, viskores::UInt8 &outShape, OutPointIndexType &outPoints) const
Definition: CellDeepCopy.h:55
viskores::worklet::CellDeepCopy::Run
static viskores::cont::CellSetExplicit Run(const InCellSetType &inCellSet)
Definition: CellDeepCopy.h:117
CellSetExplicit.h
UnknownCellSet.h
viskores::worklet::WorkletVisitCellsWithPoints::CellSetIn
A control signature tag for input connectivity.
Definition: WorkletMapTopology.h:289
viskores::worklet::WorkletVisitCellsWithPoints::CellShape
An execution signature tag to get the shape of the visited cell.
Definition: WorkletMapTopology.h:406
viskores::cont::ArrayHandle< viskores::IdComponent >
ArrayHandleConstant.h
viskores::worklet::WorkletVisitCellsWithPoints::FieldOut
A control signature tag for output fields.
Definition: WorkletMapTopology.h:339
viskores::IdComponent
viskores::Int32 IdComponent
Base type to use to index small lists.
Definition: Types.h:202
viskores::worklet::WorkletVisitCellsWithPoints
Base class for worklets that map from Points to Cells.
Definition: WorkletMapTopology.h:265
viskores::worklet::WorkletVisitCellsWithPoints::PointCount
An execution signature tag to get the number of incident points.
Definition: WorkletMapTopology.h:416
viskores::worklet::WorkletVisitCellsWithPoints::PointIndices
An execution signature tag to get the indices of the incident points.
Definition: WorkletMapTopology.h:426
viskores::Id
viskores::Int64 Id
Base type to use to index arrays.
Definition: Types.h:235
VISKORES_CONT
#define VISKORES_CONT
Definition: ExportMacros.h:65
viskores::worklet::CellDeepCopy::PassCellStructure::ControlSignature
void(CellSetIn inputTopology, FieldOut shapes, FieldOut pointIndices) ControlSignature
Definition: CellDeepCopy.h:51
viskores::worklet::CellDeepCopy::PassCellStructure::ExecutionSignature
void(CellShape, PointIndices, _2, _3) ExecutionSignature
Definition: CellDeepCopy.h:52
viskores
Groups connected points that have the same field value.
Definition: Atomic.h:27
viskores::worklet::DispatcherMapTopology
Dispatcher for worklets that inherit from WorkletMapTopology.
Definition: DispatcherMapTopology.h:39
viskores::worklet::CellDeepCopy::CountCellPoints
Definition: CellDeepCopy.h:40
viskores::cont::ArrayHandle::Allocate
void Allocate(viskores::Id numberOfValues, viskores::CopyFlag preserve, viskores::cont::Token &token) const
Allocates an array large enough to hold the given number of values.
Definition: ArrayHandle.h:504
viskores::cont::CellSetExplicit
Defines an irregular collection of cells.
Definition: CastAndCall.h:44
VISKORES_ASSERT
#define VISKORES_ASSERT(condition)
Definition: Assert.h:51
viskores::cont::CellSetExplicit::Fill
void Fill(viskores::Id numPoints, const viskores::cont::ArrayHandle< viskores::UInt8, ShapesStorageTag > &cellTypes, const viskores::cont::ArrayHandle< viskores::Id, ConnectivityStorageTag > &connectivity, const viskores::cont::ArrayHandle< viskores::Id, OffsetsStorageTag > &offsets)
Set all the cells of the mesh.
viskores::cont::ConvertNumComponentsToOffsets
void ConvertNumComponentsToOffsets(const viskores::cont::UnknownArrayHandle &numComponentsArray, viskores::cont::ArrayHandle< viskores::Id > &offsetsArray, viskores::Id &componentsArraySize, viskores::cont::DeviceAdapterId device=viskores::cont::DeviceAdapterTagAny{})
ConvertNumComponentsToOffsets takes an array of Vec sizes (i.e.
viskores::UInt8
uint8_t UInt8
Base type to use for 8-bit unsigned integer numbers.
Definition: Types.h:177
viskores::cont::CellSetExplicit::GetNumberOfPoints
viskores::Id GetNumberOfPoints() const override
ConvertNumComponentsToOffsets.h
viskores::worklet::CellDeepCopy::CountCellPoints::ExecutionSignature
_2(PointCount) ExecutionSignature
Definition: CellDeepCopy.h:43
viskores::worklet::CellDeepCopy::PassCellStructure
Definition: CellDeepCopy.h:49
viskores::cont::make_ArrayHandleGroupVecVariable
viskores::cont::ArrayHandleGroupVecVariable< ComponentsArrayHandleType, OffsetsArrayHandleType > make_ArrayHandleGroupVecVariable(const ComponentsArrayHandleType &componentsArray, const OffsetsArrayHandleType &offsetsArray)
make_ArrayHandleGroupVecVariable is convenience function to generate an ArrayHandleGroupVecVariable.
Definition: ArrayHandleGroupVecVariable.h:332
viskores::worklet::CellDeepCopy::Run
static void Run(const InCellSetType &inCellSet, viskores::cont::CellSetExplicit< ShapeStorage, ConnectivityStorage, OffsetsStorage > &outCellSet)
Definition: CellDeepCopy.h:109
viskores::worklet::CellDeepCopy::CountCellPoints::operator()
viskores::IdComponent operator()(viskores::IdComponent numPoints) const
Definition: CellDeepCopy.h:46
ArrayHandleGroupVecVariable.h
viskores::worklet::CellDeepCopy
Container for worklets and helper methods to copy a cell set to a new CellSetExplicit structure.
Definition: CellDeepCopy.h:38
DispatcherMapTopology.h
WorkletMapTopology.h
viskores::worklet::CellDeepCopy::CountCellPoints::ControlSignature
void(CellSetIn inputTopology, FieldOut numPointsInCell) ControlSignature
Definition: CellDeepCopy.h:42
VISKORES_EXEC
#define VISKORES_EXEC
Definition: ExportMacros.h:59
viskores::worklet::CellDeepCopy::Run
static void Run(const InCellSetType &inCellSet, viskores::cont::CellSetExplicit< ShapeStorage, ConnectivityStorage, OffsetsStorage > &outCellSet, viskores::Id numberOfPoints)
Definition: CellDeepCopy.h:76