VTK-m  2.0
filter/mesh_info/worklet/CellMeasure.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_CellMeasure_h
12 #define vtk_m_worklet_CellMeasure_h
13 
14 #include <vtkm/exec/CellMeasure.h>
17 
18 namespace vtkm
19 {
20 
21 namespace worklet
22 {
23 
35 {
36 public:
37  using ControlSignature = void(CellSetIn cellset,
38  FieldInPoint pointCoords,
39  FieldOutCell volumesOut);
40  using ExecutionSignature = void(CellShape, PointCount, _2, _3);
41  using InputDomain = _1;
42 
44  : measure(m)
45  {
46  }
47 
48  template <typename CellShape, typename PointCoordVecType, typename OutType>
49  VTKM_EXEC void operator()(CellShape shape,
50  const vtkm::IdComponent& numPoints,
51  const PointCoordVecType& pts,
52  OutType& volume) const
53  {
54  switch (shape.Id)
55  {
57  this->ComputeMeasure<OutType>(numPoints, pts, CellShapeTag()));
58  default:
59  this->RaiseError("Asked for volume of unknown cell shape.");
60  volume = OutType(0.0);
61  }
62  }
63 
64 private:
65  template <typename OutType, typename PointCoordVecType, typename CellShapeType>
67  const PointCoordVecType& pts,
68  CellShapeType) const
69  {
70 #if defined(VTKM_MSVC)
71 #pragma warning(push)
72 #pragma warning(disable : 4068) //unknown pragma
73 #endif
74 #ifdef __NVCC__
75 
76 #pragma push
77 #if (CUDART_VERSION >= 11050)
78 #pragma nv_diag_suppress = code_is_unreachable
79 #else
80 #pragma diag_suppress = code_is_unreachable
81 #endif
82 #endif
84 
85  vtkm::ErrorCode ec;
87  {
88  case 0:
89  // Fall through to return 0 measure.
90  break;
91  case 1:
92  if ((this->measure & IntegrationType::ArcLength) == IntegrationType::ArcLength)
93  {
94  return vtkm::exec::CellMeasure<OutType>(numPts, pts, CellShapeType(), ec);
95  }
96  break;
97  case 2:
98  if ((this->measure & IntegrationType::Area) == IntegrationType::Area)
99  {
100  return vtkm::exec::CellMeasure<OutType>(numPts, pts, CellShapeType(), ec);
101  }
102  break;
103  case 3:
104  if ((this->measure & IntegrationType::Volume) == IntegrationType::Volume)
105  {
106  return vtkm::exec::CellMeasure<OutType>(numPts, pts, CellShapeType(), ec);
107  }
108  break;
109  default:
110  // Fall through to return 0 measure.
111  break;
112  }
113  return OutType(0.0);
114 #ifdef __NVCC__
115 #pragma pop
116 #endif
117 #if defined(VTKM_MSVC)
118 #pragma warning(pop)
119 #endif
120  }
121 
123 };
124 }
125 } // namespace vtkm::worklet
126 
127 #endif // vtk_m_worklet_CellMeasure_h
vtkm::worklet::CellMeasure
Simple functor that returns the spatial integral of each cell as a cell field.
Definition: filter/mesh_info/worklet/CellMeasure.h:34
vtkm::ErrorCode
ErrorCode
Definition: ErrorCode.h:19
VTKM_EXEC
#define VTKM_EXEC
Definition: ExportMacros.h:51
vtkm
Groups connected points that have the same field value.
Definition: Atomic.h:19
CellMeasures.h
vtkm::worklet::WorkletVisitCellsWithPoints::PointCount
IncidentElementCount PointCount
Definition: WorkletMapTopology.h:267
vtkm::IdComponent
vtkm::Int32 IdComponent
Represents a component ID (index of component in a vector).
Definition: Types.h:168
vtkm::worklet::CellMeasure::measure
vtkm::filter::mesh_info::IntegrationType measure
Definition: filter/mesh_info/worklet/CellMeasure.h:122
vtkm::worklet::CellMeasure::InputDomain
_1 InputDomain
Definition: filter/mesh_info/worklet/CellMeasure.h:41
CellMeasure.h
vtkm::worklet::CellMeasure::ComputeMeasure
VTKM_EXEC OutType ComputeMeasure(const vtkm::IdComponent &numPts, const PointCoordVecType &pts, CellShapeType) const
Definition: filter/mesh_info/worklet/CellMeasure.h:66
vtkm::worklet::CellMeasure::operator()
VTKM_EXEC void operator()(CellShape shape, const vtkm::IdComponent &numPoints, const PointCoordVecType &pts, OutType &volume) const
Definition: filter/mesh_info/worklet/CellMeasure.h:49
vtkmGenericCellShapeMacro
#define vtkmGenericCellShapeMacro(call)
A macro used in a switch statement to determine cell shape.
Definition: CellShape.h:230
vtkm::worklet::CellMeasure::ExecutionSignature
void(CellShape, PointCount, _2, _3) ExecutionSignature
Definition: filter/mesh_info/worklet/CellMeasure.h:40
vtkm::worklet::WorkletVisitCellsWithPoints
Base class for worklets that map from Points to Cells.
Definition: WorkletMapTopology.h:255
vtkm::worklet::WorkletVisitCellsWithPoints::FieldInPoint
FieldInIncident FieldInPoint
Definition: WorkletMapTopology.h:259
vtkm::worklet::CellMeasure::CellMeasure
CellMeasure(vtkm::filter::mesh_info::IntegrationType m)
Definition: filter/mesh_info/worklet/CellMeasure.h:43
vtkm::worklet::CellMeasure::ControlSignature
void(CellSetIn cellset, FieldInPoint pointCoords, FieldOutCell volumesOut) ControlSignature
Definition: filter/mesh_info/worklet/CellMeasure.h:39
WorkletMapTopology.h
vtkm::CellTraits
Information about a cell based on its tag.
Definition: CellTraits.h:46
vtkm::exec::FunctorBase::RaiseError
VTKM_EXEC void RaiseError(const char *message) const
Definition: FunctorBase.h:40
vtkm::worklet::WorkletVisitCellsWithPoints::FieldOutCell
FieldOut FieldOutCell
Definition: WorkletMapTopology.h:263
vtkm::filter::mesh_info::IntegrationType
IntegrationType
Specifies over what types of mesh elements CellMeasures will operate.
Definition: CellMeasures.h:25