20 #ifndef vtk_m_worklet_CellSkewMetric_h
21 #define vtk_m_worklet_CellSkewMetric_h
42 template <
typename OutType,
typename Po
intCoordVecType,
typename CellShapeType>
44 const PointCoordVecType& pts,
55 template <
typename OutType,
typename Po
intCoordVecType>
57 const PointCoordVecType& pts,
58 vtkm::CellShapeTagHexahedron,
63 using Scalar = OutType;
64 using Vector =
typename PointCoordVecType::ComponentType;
65 Vector X1 = (pts[1] - pts[0]) + (pts[2] - pts[3]) + (pts[5] - pts[4]) + (pts[6] - pts[7]);
67 if (Scalar(X1_mag) <= Scalar(0.0))
68 return vtkm::Infinity<Scalar>();
69 Vector x1 = X1 / X1_mag;
70 Vector X2 = (pts[3] - pts[0]) + (pts[2] - pts[1]) + (pts[7] - pts[4]) + (pts[6] - pts[5]);
72 if (Scalar(X2_mag) <= Scalar(0.0))
73 return vtkm::Infinity<Scalar>();
74 Vector x2 = X2 / X2_mag;
75 Vector X3 = (pts[4] - pts[0]) + (pts[5] - pts[1]) + (pts[6] - pts[2]) + (pts[7] - pts[3]);
77 if (Scalar(X3_mag) <= Scalar(0.0))
78 return vtkm::Infinity<Scalar>();
79 Vector x3 = X3 / X3_mag;
80 return static_cast<Scalar
>(
81 vtkm::Max(vtkm::Dot(x1, x2), vtkm::Max(vtkm::Dot(x1, x3), vtkm::Dot(x2, x3))));
84 template <
typename OutType,
typename Po
intCoordVecType>
86 const PointCoordVecType& pts,
87 vtkm::CellShapeTagQuad,
92 using Scalar = OutType;
93 using CollectionOfPoints = PointCoordVecType;
94 using Vector =
typename PointCoordVecType::ComponentType;
95 const Vector X0 = GetQuadX0<Scalar, Vector, CollectionOfPoints>(pts);
96 const Vector X1 = GetQuadX1<Scalar, Vector, CollectionOfPoints>(pts);
100 if (Scalar(X0Mag) < Scalar(0.0) || Scalar(X1Mag) < Scalar(0.0))
102 const Vector x0Normalized = X0 / X0Mag;
103 const Vector x1Normalized = X1 / X1Mag;
104 const Scalar dot =
static_cast<Scalar
>(vtkm::Dot(x0Normalized, x1Normalized));
105 return vtkm::Abs(dot);