VTK-m  2.0
TetrahedralizeExplicit.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 
11 #ifndef vtk_m_worklet_TetrahedralizeExplicit_h
12 #define vtk_m_worklet_TetrahedralizeExplicit_h
13 
14 #include <vtkm/cont/ArrayHandle.h>
17 #include <vtkm/cont/DataSet.h>
18 #include <vtkm/cont/Field.h>
19 
25 
27 
28 namespace vtkm
29 {
30 namespace worklet
31 {
32 
35 {
36 public:
38 
39  //
40  // Worklet to count the number of tetrahedra generated per cell
41  //
43  {
44  public:
45  using ControlSignature = void(CellSetIn cells, ExecObject tables, FieldOut tetrahedronCount);
46  using ExecutionSignature = _3(CellShape, _2);
47  using InputDomain = _1;
48 
49  VTKM_CONT
51 
52  template <typename CellShapeTag>
54  CellShapeTag shape,
55  const vtkm::worklet::internal::TetrahedralizeTablesExecutionObject& tables) const
56  {
57  return tables.GetCount(shape);
58  }
59  };
60 
61  //
62  // Worklet to turn cells into tetrahedra
63  // Vertices remain the same and each cell is processed with needing topology
64  //
66  {
67  public:
68  using ControlSignature = void(CellSetIn cellset,
69  ExecObject tables,
70  FieldOutCell connectivityOut);
71  using ExecutionSignature = void(CellShape, PointIndices, _2, _3, VisitIndex);
72  using InputDomain = _1;
73 
75 
76  template <typename CellArrayType>
77  VTKM_CONT static ScatterType MakeScatter(const CellArrayType& cellArray)
78  {
79  return ScatterType(cellArray);
80  }
81 
82  // Each cell produces tetrahedra and write result at the offset
83  template <typename CellShapeTag, typename ConnectivityInVec, typename ConnectivityOutVec>
85  CellShapeTag shape,
86  const ConnectivityInVec& connectivityIn,
87  const vtkm::worklet::internal::TetrahedralizeTablesExecutionObject& tables,
88  ConnectivityOutVec& connectivityOut,
89  vtkm::IdComponent visitIndex) const
90  {
91  vtkm::IdComponent4 tetIndices = tables.GetIndices(shape, visitIndex);
92  connectivityOut[0] = connectivityIn[tetIndices[0]];
93  connectivityOut[1] = connectivityIn[tetIndices[1]];
94  connectivityOut[2] = connectivityIn[tetIndices[2]];
95  connectivityOut[3] = connectivityIn[tetIndices[3]];
96  }
97  };
98 
99  template <typename CellSetType>
100  vtkm::cont::CellSetSingleType<> Run(const CellSetType& cellSet,
102  {
104 
105  vtkm::cont::Invoker invoke;
106 
107  // Output topology
108  vtkm::cont::ArrayHandle<vtkm::Id> outConnectivity;
109 
110  vtkm::worklet::internal::TetrahedralizeTables tables;
111 
112  // Determine the number of output cells each input cell will generate
113  invoke(TetrahedraPerCell{}, cellSet, tables, outCellsPerCell);
114 
115  // Build new cells
116  invoke(TetrahedralizeCell{},
117  TetrahedralizeCell::MakeScatter(outCellsPerCell),
118  cellSet,
119  tables,
120  vtkm::cont::make_ArrayHandleGroupVec<4>(outConnectivity));
121 
122  // Add cells to output cellset
123  outCellSet.Fill(cellSet.GetNumberOfPoints(), vtkm::CellShapeTagTetra::Id, 4, outConnectivity);
124  return outCellSet;
125  }
126 };
127 }
128 } // namespace vtkm::worklet
129 
130 #endif // vtk_m_worklet_TetrahedralizeExplicit_h
vtkm::worklet::TetrahedralizeExplicit::TetrahedraPerCell::TetrahedraPerCell
VTKM_CONT TetrahedraPerCell()
Definition: TetrahedralizeExplicit.h:50
vtkm::cont::ArrayHandle< vtkm::IdComponent >
ArrayHandle.h
VTKM_EXEC
#define VTKM_EXEC
Definition: ExportMacros.h:51
vtkm
Groups connected points that have the same field value.
Definition: Atomic.h:19
WorkletMapField.h
CellSetExplicit.h
vtkm::worklet::TetrahedralizeExplicit::TetrahedraPerCell::ControlSignature
void(CellSetIn cells, ExecObject tables, FieldOut tetrahedronCount) ControlSignature
Definition: TetrahedralizeExplicit.h:45
vtkm::worklet::TetrahedralizeExplicit::TetrahedralizeCell::InputDomain
_1 InputDomain
Definition: TetrahedralizeExplicit.h:72
vtkm::IdComponent
vtkm::Int32 IdComponent
Represents a component ID (index of component in a vector).
Definition: Types.h:168
vtkm::cont::CellSetSingleType
Definition: CastAndCall.h:34
vtkm::worklet::TetrahedralizeExplicit::TetrahedraPerCell::operator()
VTKM_EXEC vtkm::IdComponent operator()(CellShapeTag shape, const vtkm::worklet::internal::TetrahedralizeTablesExecutionObject &tables) const
Definition: TetrahedralizeExplicit.h:53
vtkm::worklet::WorkletVisitCellsWithPoints::PointIndices
IncidentElementIndices PointIndices
Definition: WorkletMapTopology.h:269
vtkm::Id
vtkm::Int32 Id
Represents an ID (index into arrays).
Definition: Types.h:191
DispatcherMapField.h
ScatterCounting.h
vtkm::worklet::ScatterCounting
A scatter that maps input to some numbers of output.
Definition: ScatterCounting.h:44
vtkm::worklet::TetrahedralizeExplicit::TetrahedralizeExplicit
TetrahedralizeExplicit()
Definition: TetrahedralizeExplicit.h:37
vtkm::worklet::TetrahedralizeExplicit
Compute the tetrahedralize cells for an explicit grid data set.
Definition: TetrahedralizeExplicit.h:34
vtkm::worklet::TetrahedralizeExplicit::TetrahedralizeCell
Definition: TetrahedralizeExplicit.h:65
vtkm::cont::Invoker
Allows launching any worklet without a dispatcher.
Definition: Invoker.h:41
vtkm::worklet::WorkletVisitCellsWithPoints
Base class for worklets that map from Points to Cells.
Definition: WorkletMapTopology.h:255
VTKM_CONT
#define VTKM_CONT
Definition: ExportMacros.h:57
ArrayHandleGroupVec.h
vtkm::worklet::TetrahedralizeExplicit::TetrahedralizeCell::ControlSignature
void(CellSetIn cellset, ExecObject tables, FieldOutCell connectivityOut) ControlSignature
Definition: TetrahedralizeExplicit.h:70
vtkm::worklet::TetrahedralizeExplicit::TetrahedralizeCell::ExecutionSignature
void(CellShape, PointIndices, _2, _3, VisitIndex) ExecutionSignature
Definition: TetrahedralizeExplicit.h:71
vtkm::worklet::TetrahedralizeExplicit::TetrahedralizeCell::operator()
VTKM_EXEC void operator()(CellShapeTag shape, const ConnectivityInVec &connectivityIn, const vtkm::worklet::internal::TetrahedralizeTablesExecutionObject &tables, ConnectivityOutVec &connectivityOut, vtkm::IdComponent visitIndex) const
Definition: TetrahedralizeExplicit.h:84
vtkm::worklet::TetrahedralizeExplicit::TetrahedralizeCell::ScatterType
vtkm::worklet::ScatterCounting ScatterType
Definition: TetrahedralizeExplicit.h:74
vtkm::worklet::TetrahedralizeExplicit::TetrahedraPerCell::ExecutionSignature
_3(CellShape, _2) ExecutionSignature
Definition: TetrahedralizeExplicit.h:46
vtkm::Vec
A short fixed-length array.
Definition: Types.h:767
vtkm::worklet::TetrahedralizeExplicit::Run
vtkm::cont::CellSetSingleType Run(const CellSetType &cellSet, vtkm::cont::ArrayHandle< vtkm::IdComponent > &outCellsPerCell)
Definition: TetrahedralizeExplicit.h:100
Field.h
vtkm::worklet::TetrahedralizeExplicit::TetrahedraPerCell::InputDomain
_1 InputDomain
Definition: TetrahedralizeExplicit.h:47
TriangulateTables.h
vtkm::cont::CellSetSingleType::Fill
VTKM_CONT void Fill(vtkm::Id numPoints, vtkm::UInt8 shapeId, vtkm::IdComponent numberOfPointsPerCell, const vtkm::cont::ArrayHandle< vtkm::Id, ConnectivityStorageTag > &connectivity)
Definition: CellSetSingleType.h:186
vtkm::exec::arg::VisitIndex
The ExecutionSignature tag to use to get the visit index.
Definition: VisitIndex.h:43
DispatcherMapTopology.h
WorkletMapTopology.h
vtkm::worklet::TetrahedralizeExplicit::TetrahedraPerCell
Definition: TetrahedralizeExplicit.h:42
DataSet.h
vtkm::worklet::WorkletVisitCellsWithPoints::FieldOutCell
FieldOut FieldOutCell
Definition: WorkletMapTopology.h:263
vtkm::worklet::TetrahedralizeExplicit::TetrahedralizeCell::MakeScatter
static VTKM_CONT ScatterType MakeScatter(const CellArrayType &cellArray)
Definition: TetrahedralizeExplicit.h:77