20 #ifndef vtk_m_worklet_cellmetrics_CellAspectFrobeniusMetric_h
21 #define vtk_m_worklet_cellmetrics_CellAspectFrobeniusMetric_h
42 #define UNUSED(expr) (void)(expr);
55 template <
typename OutType,
typename Po
intCoordVecType,
typename CellShapeType>
57 const PointCoordVecType& pts,
72 template <
typename OutType,
typename Po
intCoordVecType>
74 const PointCoordVecType& pts,
75 vtkm::CellShapeTagPolygon,
79 return CellAspectFrobeniusMetric<OutType>(numPts, pts, vtkm::CellShapeTagTriangle(), ec);
88 template <
typename OutType,
typename Po
intCoordVecType>
90 const PointCoordVecType& pts,
91 vtkm::CellShapeTagLine,
103 template <
typename OutType,
typename Po
intCoordVecType>
105 const PointCoordVecType& pts,
106 vtkm::CellShapeTagQuad,
118 template <
typename OutType,
typename Po
intCoordVecType>
120 const PointCoordVecType& pts,
121 vtkm::CellShapeTagHexahedron,
133 template <
typename OutType,
typename Po
intCoordVecType>
135 const PointCoordVecType& pts,
136 vtkm::CellShapeTagPyramid,
148 template <
typename OutType,
typename Po
intCoordVecType>
150 const PointCoordVecType& pts,
151 vtkm::CellShapeTagWedge,
167 template <
typename OutType,
typename Po
intCoordVecType>
169 const PointCoordVecType& pts,
170 vtkm::CellShapeTagTriangle,
180 using Edge =
typename PointCoordVecType::ComponentType;
181 const Edge TriEdges[3] = { pts[1] - pts[0], pts[2] - pts[1], pts[0] - pts[2] };
192 return vtkm::Infinity<OutType>();
194 OutType aspect_frobenius = (OutType)(sum / (
vtkm::Sqrt(3.0) * 2 * crossLen));
196 if (aspect_frobenius > 0.0)
197 return vtkm::Min(aspect_frobenius, vtkm::Infinity<OutType>());
199 return vtkm::Max(aspect_frobenius, vtkm::NegativeInfinity<OutType>());
207 template <
typename OutType,
typename Po
intCoordVecType>
209 const PointCoordVecType& pts,
210 vtkm::CellShapeTagTetra,
220 using Edge =
typename PointCoordVecType::ComponentType;
222 const Edge TetEdges[3] = {
230 denominator *= denominator;
232 const FloatType normal_exp = 1.0f / 3.0f;
233 denominator = 3.0f * vtkm::Pow(denominator, normal_exp);
235 if (denominator < vtkm::NegativeInfinity<FloatType>())
236 return vtkm::Infinity<OutType>();
239 numerator += (
FloatType)vtkm::Dot(TetEdges[1], TetEdges[1]);
240 numerator += (
FloatType)vtkm::Dot(TetEdges[2], TetEdges[2]);
242 numerator -= (
FloatType)vtkm::Dot(TetEdges[0], TetEdges[1]);
243 numerator -= (
FloatType)vtkm::Dot(TetEdges[0], TetEdges[2]);
244 numerator -= (
FloatType)vtkm::Dot(TetEdges[1], TetEdges[2]);
246 OutType aspect_frobenius = (OutType)(numerator / denominator);
248 if (aspect_frobenius > 0.0)
249 return vtkm::Min(aspect_frobenius, vtkm::Infinity<OutType>());
251 return vtkm::Max(aspect_frobenius, vtkm::NegativeInfinity<OutType>());
256 #endif // vtk_m_worklet_cellmetrics_CellAspectFrobeniusMetric_h