diff --git a/vtkm/ErrorCode.h b/vtkm/ErrorCode.h index 94636d05a..267704883 100644 --- a/vtkm/ErrorCode.h +++ b/vtkm/ErrorCode.h @@ -21,6 +21,7 @@ enum class ErrorCode Success, InvalidShapeId, InvalidNumberOfPoints, + InvalidCellMetric, WrongShapeIdForTagType, InvalidPointId, InvalidEdgeId, @@ -46,6 +47,8 @@ inline const char* ErrorString(vtkm::ErrorCode code) noexcept return "Invalid shape id"; case vtkm::ErrorCode::InvalidNumberOfPoints: return "Invalid number of points"; + case vtkm::ErrorCode::InvalidCellMetric: + return "Invalid cell metric"; case vtkm::ErrorCode::WrongShapeIdForTagType: return "Wrong shape id for tag type"; case vtkm::ErrorCode::InvalidPointId: diff --git a/vtkm/exec/CellMeasure.h b/vtkm/exec/CellMeasure.h index 8807e9c39..f5022175a 100644 --- a/vtkm/exec/CellMeasure.h +++ b/vtkm/exec/CellMeasure.h @@ -15,6 +15,7 @@ #include #include +#include #include #include #include @@ -29,7 +30,7 @@ template VTKM_EXEC OutType CellMeasure(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, CellShapeType shape, - const vtkm::exec::FunctorBase&) + vtkm::ErrorCode&) { (void)numPts; (void)pts; @@ -43,12 +44,12 @@ template VTKM_EXEC OutType CellMeasure(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, vtkm::CellShapeTagLine, - const vtkm::exec::FunctorBase& worklet) + vtkm::ErrorCode& ec) { OutType arcLength(0.0); if (numPts < 2) { - worklet.RaiseError("Degenerate line has no arc length."); + ec = vtkm::ErrorCode::InvalidCellMetric; } else { @@ -67,11 +68,11 @@ template VTKM_EXEC OutType CellMeasure(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, vtkm::CellShapeTagTriangle, - const vtkm::exec::FunctorBase& worklet) + vtkm::ErrorCode& ec) { if (numPts != 3) { - worklet.RaiseError("Area(triangle) requires 3 points."); + ec = vtkm::ErrorCode::InvalidNumberOfPoints; return OutType(0.0); } typename PointCoordVecType::ComponentType v1 = pts[1] - pts[0]; @@ -85,11 +86,11 @@ template VTKM_EXEC OutType CellMeasure(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, vtkm::CellShapeTagQuad, - const vtkm::exec::FunctorBase& worklet) + vtkm::ErrorCode& ec) { if (numPts != 4) { - worklet.RaiseError("Area(quad) requires 4 points."); + ec = vtkm::ErrorCode::InvalidNumberOfPoints; return OutType(0.0); } @@ -125,9 +126,9 @@ template VTKM_EXEC OutType ComputeMeasure(const vtkm::IdComponent&, const PointCoordVecType&, vtkm::CellShapeTagPolygon, - const vtkm::exec::FunctorBase& worklet) + vtkm::ErrorCode& ec) { - worklet.RaiseError("CellMeasure does not support area computation for polygons."); + ec = vtkm::ErrorCode::InvalidCellMetric; return OutType(0.0); } @@ -138,11 +139,11 @@ template VTKM_EXEC OutType CellMeasure(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, vtkm::CellShapeTagTetra, - const vtkm::exec::FunctorBase& worklet) + vtkm::ErrorCode& ec) { if (numPts != 4) { - worklet.RaiseError("Volume(tetrahedron) requires 4 points."); + ec = vtkm::ErrorCode::InvalidNumberOfPoints; return OutType(0.0); } @@ -158,11 +159,11 @@ template VTKM_EXEC OutType CellMeasure(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, vtkm::CellShapeTagHexahedron, - const vtkm::exec::FunctorBase& worklet) + vtkm::ErrorCode& ec) { if (numPts != 8) { - worklet.RaiseError("Volume(hexahedron) requires 8 points."); + ec = vtkm::ErrorCode::InvalidNumberOfPoints; return OutType(0.0); } @@ -202,11 +203,11 @@ template VTKM_EXEC OutType CellMeasure(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, vtkm::CellShapeTagWedge, - const vtkm::exec::FunctorBase& worklet) + vtkm::ErrorCode& ec) { if (numPts != 6) { - worklet.RaiseError("Volume(wedge) requires 6 points."); + ec = vtkm::ErrorCode::InvalidNumberOfPoints; return OutType(0.0); } @@ -233,11 +234,11 @@ template VTKM_EXEC OutType CellMeasure(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, vtkm::CellShapeTagPyramid, - const vtkm::exec::FunctorBase& worklet) + vtkm::ErrorCode& ec) { if (numPts != 5) { - worklet.RaiseError("Volume(pyramid) requires 5 points."); + ec = vtkm::ErrorCode::InvalidNumberOfPoints; return OutType(0.0); } diff --git a/vtkm/worklet/CellMeasure.h b/vtkm/worklet/CellMeasure.h index aefa460e4..9018484d5 100644 --- a/vtkm/worklet/CellMeasure.h +++ b/vtkm/worklet/CellMeasure.h @@ -91,6 +91,8 @@ protected: #pragma push #pragma diag_suppress = code_is_unreachable #endif + + vtkm::ErrorCode ec; switch (vtkm::CellTraits::TOPOLOGICAL_DIMENSIONS) { case 0: @@ -99,19 +101,19 @@ protected: case 1: if (vtkm::ListHas::value) { - return vtkm::exec::CellMeasure(numPts, pts, CellShapeType(), *this); + return vtkm::exec::CellMeasure(numPts, pts, CellShapeType(), ec); } break; case 2: if (vtkm::ListHas::value) { - return vtkm::exec::CellMeasure(numPts, pts, CellShapeType(), *this); + return vtkm::exec::CellMeasure(numPts, pts, CellShapeType(), ec); } break; case 3: if (vtkm::ListHas::value) { - return vtkm::exec::CellMeasure(numPts, pts, CellShapeType(), *this); + return vtkm::exec::CellMeasure(numPts, pts, CellShapeType(), ec); } break; default: diff --git a/vtkm/worklet/MeshQuality.h b/vtkm/worklet/MeshQuality.h index 233bdb589..0affa645d 100644 --- a/vtkm/worklet/MeshQuality.h +++ b/vtkm/worklet/MeshQuality.h @@ -21,6 +21,7 @@ #ifndef vtk_m_worklet_MeshQuality_h #define vtk_m_worklet_MeshQuality_h +#include "vtkm/ErrorCode.h" #include "vtkm/worklet/CellMeasure.h" #include "vtkm/worklet/WorkletMapTopology.h" #include "vtkm/worklet/cellmetrics/CellAspectGammaMetric.h" @@ -91,7 +92,7 @@ public: vtkmGenericCellShapeMacro(metricValue = this->ComputeMetric(numPoints, pts, CellShapeTag())); default: - this->RaiseError("Asked for metric of unknown cell type."); + this->RaiseError(vtkm::ErrorString(vtkm::ErrorCode::CellNotFound)); metricValue = OutType(0.0); } } @@ -115,103 +116,104 @@ protected: if (dims > 0) { + vtkm::ErrorCode ec{ vtkm::ErrorCode::Success }; switch (this->Metric) { case MetricTagType::AREA: - metricValue = vtkm::exec::CellMeasure(numPts, pts, tag, *this); + metricValue = vtkm::exec::CellMeasure(numPts, pts, tag, ec); if (dims != 2) metricValue = 0.; break; case MetricTagType::ASPECT_GAMMA: metricValue = - vtkm::worklet::cellmetrics::CellAspectGammaMetric(numPts, pts, tag, *this); + vtkm::worklet::cellmetrics::CellAspectGammaMetric(numPts, pts, tag, ec); break; case MetricTagType::ASPECT_RATIO: metricValue = - vtkm::worklet::cellmetrics::CellAspectRatioMetric(numPts, pts, tag, *this); + vtkm::worklet::cellmetrics::CellAspectRatioMetric(numPts, pts, tag, ec); break; case MetricTagType::CONDITION: metricValue = - vtkm::worklet::cellmetrics::CellConditionMetric(numPts, pts, tag, *this); + vtkm::worklet::cellmetrics::CellConditionMetric(numPts, pts, tag, ec); break; case MetricTagType::DIAGONAL_RATIO: metricValue = - vtkm::worklet::cellmetrics::CellDiagonalRatioMetric(numPts, pts, tag, *this); + vtkm::worklet::cellmetrics::CellDiagonalRatioMetric(numPts, pts, tag, ec); break; case MetricTagType::DIMENSION: metricValue = - vtkm::worklet::cellmetrics::CellDimensionMetric(numPts, pts, tag, *this); + vtkm::worklet::cellmetrics::CellDimensionMetric(numPts, pts, tag, ec); break; case MetricTagType::JACOBIAN: metricValue = - vtkm::worklet::cellmetrics::CellJacobianMetric(numPts, pts, tag, *this); + vtkm::worklet::cellmetrics::CellJacobianMetric(numPts, pts, tag, ec); break; case MetricTagType::MAX_ANGLE: metricValue = - vtkm::worklet::cellmetrics::CellMaxAngleMetric(numPts, pts, tag, *this); + vtkm::worklet::cellmetrics::CellMaxAngleMetric(numPts, pts, tag, ec); break; case MetricTagType::MAX_DIAGONAL: metricValue = - vtkm::worklet::cellmetrics::CellMaxDiagonalMetric(numPts, pts, tag, *this); + vtkm::worklet::cellmetrics::CellMaxDiagonalMetric(numPts, pts, tag, ec); break; case MetricTagType::MIN_ANGLE: metricValue = - vtkm::worklet::cellmetrics::CellMinAngleMetric(numPts, pts, tag, *this); + vtkm::worklet::cellmetrics::CellMinAngleMetric(numPts, pts, tag, ec); break; case MetricTagType::MIN_DIAGONAL: metricValue = - vtkm::worklet::cellmetrics::CellMinDiagonalMetric(numPts, pts, tag, *this); + vtkm::worklet::cellmetrics::CellMinDiagonalMetric(numPts, pts, tag, ec); break; case MetricTagType::ODDY: - metricValue = - vtkm::worklet::cellmetrics::CellOddyMetric(numPts, pts, tag, *this); + metricValue = vtkm::worklet::cellmetrics::CellOddyMetric(numPts, pts, tag, ec); break; case MetricTagType::RELATIVE_SIZE_SQUARED: metricValue = vtkm::worklet::cellmetrics::CellRelativeSizeSquaredMetric( - numPts, pts, static_cast(average), tag, *this); + numPts, pts, static_cast(average), tag, ec); break; case MetricTagType::SHAPE_AND_SIZE: metricValue = vtkm::worklet::cellmetrics::CellShapeAndSizeMetric( - numPts, pts, static_cast(average), tag, *this); + numPts, pts, static_cast(average), tag, ec); break; case MetricTagType::SCALED_JACOBIAN: metricValue = - vtkm::worklet::cellmetrics::CellScaledJacobianMetric(numPts, pts, tag, *this); + vtkm::worklet::cellmetrics::CellScaledJacobianMetric(numPts, pts, tag, ec); break; case MetricTagType::SHAPE: - metricValue = - vtkm::worklet::cellmetrics::CellShapeMetric(numPts, pts, tag, *this); + metricValue = vtkm::worklet::cellmetrics::CellShapeMetric(numPts, pts, tag, ec); break; case MetricTagType::SHEAR: - metricValue = - vtkm::worklet::cellmetrics::CellShearMetric(numPts, pts, tag, *this); + metricValue = vtkm::worklet::cellmetrics::CellShearMetric(numPts, pts, tag, ec); break; case MetricTagType::SKEW: - metricValue = - vtkm::worklet::cellmetrics::CellSkewMetric(numPts, pts, tag, *this); + metricValue = vtkm::worklet::cellmetrics::CellSkewMetric(numPts, pts, tag, ec); break; case MetricTagType::STRETCH: metricValue = - vtkm::worklet::cellmetrics::CellStretchMetric(numPts, pts, tag, *this); + vtkm::worklet::cellmetrics::CellStretchMetric(numPts, pts, tag, ec); break; case MetricTagType::TAPER: - metricValue = - vtkm::worklet::cellmetrics::CellTaperMetric(numPts, pts, tag, *this); + metricValue = vtkm::worklet::cellmetrics::CellTaperMetric(numPts, pts, tag, ec); break; case MetricTagType::VOLUME: - metricValue = vtkm::exec::CellMeasure(numPts, pts, tag, *this); + metricValue = vtkm::exec::CellMeasure(numPts, pts, tag, ec); if (dims != 3) metricValue = 0.; break; case MetricTagType::WARPAGE: metricValue = - vtkm::worklet::cellmetrics::CellWarpageMetric(numPts, pts, tag, *this); + vtkm::worklet::cellmetrics::CellWarpageMetric(numPts, pts, tag, ec); break; case MetricTagType::EMPTY: break; default: //Only call metric function if a metric is specified for this shape type - this->RaiseError("Asked for unknown metric."); + ec = vtkm::ErrorCode::InvalidCellMetric; + } + + if (ec != vtkm::ErrorCode::Success) + { + this->RaiseError(vtkm::ErrorString(ec)); } } diff --git a/vtkm/worklet/cellmetrics/CellAspectFrobeniusMetric.h b/vtkm/worklet/cellmetrics/CellAspectFrobeniusMetric.h index 987cec475..4daa17739 100644 --- a/vtkm/worklet/cellmetrics/CellAspectFrobeniusMetric.h +++ b/vtkm/worklet/cellmetrics/CellAspectFrobeniusMetric.h @@ -56,15 +56,16 @@ template VTKM_EXEC OutType CellAspectFrobeniusMetric(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, CellShapeType shape, - const vtkm::exec::FunctorBase& worklet) + vtkm::ErrorCode& ec) { UNUSED(numPts); UNUSED(pts); UNUSED(shape); - worklet.RaiseError( - "Shape type template must be specialized to compute the aspect frobenius metric."); + ec = vtkm::ErrorCode::InvalidCellMetric; return OutType(0.0); -} //If the polygon has 3 vertices or 4 vertices, then just call +} + +//If the polygon has 3 vertices or 4 vertices, then just call //the functions for Triangle and Quad cell types. Otherwise, //this metric is not supported for (n>4)-vertex polygons, such //as pentagons or hexagons, or (n<3)-vertex polygons, such as lines or points. @@ -72,80 +73,91 @@ template VTKM_EXEC OutType CellAspectFrobeniusMetric(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, vtkm::CellShapeTagPolygon, - const vtkm::exec::FunctorBase& worklet) + vtkm::ErrorCode& ec) { if (numPts == 3) - return CellAspectFrobeniusMetric(numPts, pts, vtkm::CellShapeTagTriangle(), worklet); + return CellAspectFrobeniusMetric(numPts, pts, vtkm::CellShapeTagTriangle(), ec); else { - worklet.RaiseError( - "Aspect frobenius metric is not supported for (n<3)- or (n>4)-vertex polygons."); + ec = vtkm::ErrorCode::InvalidCellMetric; return OutType(0.0); } -} //The aspect frobenius metric is not supported for lines/edges. +} + +//The aspect frobenius metric is not supported for lines/edges. template VTKM_EXEC OutType CellAspectFrobeniusMetric(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, vtkm::CellShapeTagLine, - const vtkm::exec::FunctorBase& worklet) + vtkm::ErrorCode& ec) { UNUSED(numPts); UNUSED(pts); - worklet.RaiseError("Aspect frobenius metric is not supported for lines/edges."); + ec = vtkm::ErrorCode::InvalidCellMetric; return OutType(0.0); -} //The aspect frobenius metric is not uniquely defined for quads. +} + +//The aspect frobenius metric is not uniquely defined for quads. //Instead, use either the mean or max aspect frobenius metrics, which are //defined in terms of the aspect frobenius of triangles. template VTKM_EXEC OutType CellAspectFrobeniusMetric(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, vtkm::CellShapeTagQuad, - const vtkm::exec::FunctorBase& worklet) + vtkm::ErrorCode& ec) { UNUSED(numPts); UNUSED(pts); - worklet.RaiseError("Aspect frobenius metric is not supported for quads."); + ec = vtkm::ErrorCode::InvalidCellMetric; return OutType(0.0); -} //The aspect frobenius metric is not uniquely defined for hexahedrons. +} + +//The aspect frobenius metric is not uniquely defined for hexahedrons. //Instead, use either the mean or max aspect frobenius metrics, which are //defined in terms of the aspect frobenius of tetrahedrons. template VTKM_EXEC OutType CellAspectFrobeniusMetric(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, vtkm::CellShapeTagHexahedron, - const vtkm::exec::FunctorBase& worklet) + vtkm::ErrorCode& ec) { UNUSED(numPts); UNUSED(pts); - worklet.RaiseError("Aspect frobenius metric is not supported for hexahedrons."); + ec = vtkm::ErrorCode::InvalidCellMetric; return OutType(0.0); -} //The aspect frobenius metric is not uniquely defined for pyramids. +} + +//The aspect frobenius metric is not uniquely defined for pyramids. //Instead, use either the mean or max aspect frobenius metrics, which are //defined in terms of the aspect frobenius of tetrahedrons. template VTKM_EXEC OutType CellAspectFrobeniusMetric(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, vtkm::CellShapeTagPyramid, - const vtkm::exec::FunctorBase& worklet) + vtkm::ErrorCode& ec) { UNUSED(numPts); UNUSED(pts); - worklet.RaiseError("Aspect frobenius metric is not supported for pyramids."); + ec = vtkm::ErrorCode::InvalidCellMetric; return OutType(0.0); -} //The aspect frobenius metric is not uniquely defined for wedges. +} + +//The aspect frobenius metric is not uniquely defined for wedges. //Instead, use either the mean or max aspect frobenius metrics, which are //defined in terms of the aspect frobenius of tetrahedrons. template VTKM_EXEC OutType CellAspectFrobeniusMetric(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, vtkm::CellShapeTagWedge, - const vtkm::exec::FunctorBase& worklet) + vtkm::ErrorCode& ec) { UNUSED(numPts); UNUSED(pts); - worklet.RaiseError("Aspect frobenius metric is not supported for wedges."); + ec = vtkm::ErrorCode::InvalidCellMetric; return OutType(0.0); -} // ========================= 2D cells ================================== +} + +// ========================= 2D cells ================================== // Computes the aspect frobenius of a triangle. // Formula: Sum of lengths of 3 edges, divided by a multiple of the triangle area. @@ -156,11 +168,11 @@ template VTKM_EXEC OutType CellAspectFrobeniusMetric(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, vtkm::CellShapeTagTriangle, - const vtkm::exec::FunctorBase& worklet) + vtkm::ErrorCode& ec) { if (numPts != 3) { - worklet.RaiseError("Aspect frobenius metric(triangle) requires 3 points."); + ec = vtkm::ErrorCode::InvalidNumberOfPoints; return OutType(0.0); } @@ -196,11 +208,11 @@ template VTKM_EXEC OutType CellAspectFrobeniusMetric(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, vtkm::CellShapeTagTetra, - const vtkm::exec::FunctorBase& worklet) + vtkm::ErrorCode& ec) { if (numPts != 4) { - worklet.RaiseError("Aspect frobenius metric(tetrahedron) requires 4 points."); + ec = vtkm::ErrorCode::InvalidNumberOfPoints; return OutType(0.0); } diff --git a/vtkm/worklet/cellmetrics/CellAspectGammaMetric.h b/vtkm/worklet/cellmetrics/CellAspectGammaMetric.h index 3a7b174a8..9aa05f4c9 100644 --- a/vtkm/worklet/cellmetrics/CellAspectGammaMetric.h +++ b/vtkm/worklet/cellmetrics/CellAspectGammaMetric.h @@ -53,7 +53,7 @@ template VTKM_EXEC OutType CellAspectGammaMetric(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, CellShapeType shape, - const vtkm::exec::FunctorBase&) + vtkm::ErrorCode&) { UNUSED(numPts); UNUSED(pts); @@ -67,11 +67,11 @@ template VTKM_EXEC OutType CellAspectGammaMetric(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, vtkm::CellShapeTagTetra, - const vtkm::exec::FunctorBase& worklet) + vtkm::ErrorCode& ec) { if (numPts != 4) { - worklet.RaiseError("Aspect gamma metric (tetrahedron) requires 4 points."); + ec = vtkm::ErrorCode::InvalidNumberOfPoints; return OutType(0.0); } diff --git a/vtkm/worklet/cellmetrics/CellAspectRatioMetric.h b/vtkm/worklet/cellmetrics/CellAspectRatioMetric.h index aef6fb43d..15854ca67 100644 --- a/vtkm/worklet/cellmetrics/CellAspectRatioMetric.h +++ b/vtkm/worklet/cellmetrics/CellAspectRatioMetric.h @@ -56,7 +56,7 @@ template VTKM_EXEC OutType CellAspectRatioMetric(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, CellShapeType shape, - const vtkm::exec::FunctorBase&) + vtkm::ErrorCode&) { UNUSED(numPts); UNUSED(pts); @@ -71,11 +71,11 @@ template VTKM_EXEC OutType CellAspectRatioMetric(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, vtkm::CellShapeTagTriangle, - const vtkm::exec::FunctorBase& worklet) + vtkm::ErrorCode& ec) { if (numPts != 3) { - worklet.RaiseError("Aspect ratio metric (triangle) requires 3 points."); + ec = vtkm::ErrorCode::InvalidNumberOfPoints; return OutType(0.0); } @@ -95,11 +95,11 @@ template VTKM_EXEC OutType CellAspectRatioMetric(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, vtkm::CellShapeTagQuad, - const vtkm::exec::FunctorBase& worklet) + vtkm::ErrorCode& ec) { if (numPts != 4) { - worklet.RaiseError("Aspect ratio metric (quad) requires 4 points."); + ec = vtkm::ErrorCode::InvalidNumberOfPoints; return OutType(0.0); } @@ -126,11 +126,11 @@ template VTKM_EXEC OutType CellAspectRatioMetric(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, vtkm::CellShapeTagHexahedron, - const vtkm::exec::FunctorBase& worklet) + vtkm::ErrorCode& ec) { if (numPts != 8) { - worklet.RaiseError("Aspect ratio metric (hex) requires 4 points."); + ec = vtkm::ErrorCode::InvalidNumberOfPoints; return OutType(0.0); } @@ -162,11 +162,11 @@ template VTKM_EXEC OutType CellAspectRatioMetric(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, vtkm::CellShapeTagTetra, - const vtkm::exec::FunctorBase& worklet) + vtkm::ErrorCode& ec) { if (numPts != 4) { - worklet.RaiseError("Aspect ratio metric (tetrahedron) requires 4 points."); + ec = vtkm::ErrorCode::InvalidNumberOfPoints; return OutType(0.0); } diff --git a/vtkm/worklet/cellmetrics/CellConditionMetric.h b/vtkm/worklet/cellmetrics/CellConditionMetric.h index 65973a18b..79848b912 100644 --- a/vtkm/worklet/cellmetrics/CellConditionMetric.h +++ b/vtkm/worklet/cellmetrics/CellConditionMetric.h @@ -54,7 +54,7 @@ template VTKM_EXEC OutType CellConditionMetric(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, CellShapeType shape, - const vtkm::exec::FunctorBase&) + vtkm::ErrorCode&) { UNUSED(numPts); UNUSED(pts); @@ -69,11 +69,11 @@ template VTKM_EXEC OutType CellConditionMetric(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, vtkm::CellShapeTagTriangle, - const vtkm::exec::FunctorBase& worklet) + vtkm::ErrorCode& ec) { if (numPts != 3) { - worklet.RaiseError("Condition metric(triangle) requires 3 points."); + ec = vtkm::ErrorCode::InvalidNumberOfPoints; return OutType(0.0); } @@ -101,10 +101,10 @@ template VTKM_EXEC OutType CellConditionMetric(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, vtkm::CellShapeTagQuad, - const vtkm::exec::FunctorBase& worklet) + vtkm::ErrorCode& ec) { UNUSED(numPts); - UNUSED(worklet); + UNUSED(ec); using Scalar = OutType; using CollectionOfPoints = PointCoordVecType; using Vector = typename PointCoordVecType::ComponentType; @@ -141,11 +141,11 @@ template VTKM_EXEC OutType CellConditionMetric(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, vtkm::CellShapeTagTetra, - const vtkm::exec::FunctorBase& worklet) + vtkm::ErrorCode& ec) { if (numPts != 4) { - worklet.RaiseError("Condition metric(tetrahedron) requires 4 points."); + ec = vtkm::ErrorCode::InvalidNumberOfPoints; return OutType(0.0); } using Scalar = OutType; @@ -187,10 +187,10 @@ template VTKM_EXEC OutType CellConditionMetric(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, vtkm::CellShapeTagHexahedron, - const vtkm::exec::FunctorBase& worklet) + vtkm::ErrorCode& ec) { return CellMaxAspectFrobeniusMetric( - numPts, pts, vtkm::CellShapeTagHexahedron(), worklet); + numPts, pts, vtkm::CellShapeTagHexahedron(), ec); } } } diff --git a/vtkm/worklet/cellmetrics/CellDiagonalRatioMetric.h b/vtkm/worklet/cellmetrics/CellDiagonalRatioMetric.h index f3fa5b28e..1b1d75077 100644 --- a/vtkm/worklet/cellmetrics/CellDiagonalRatioMetric.h +++ b/vtkm/worklet/cellmetrics/CellDiagonalRatioMetric.h @@ -82,7 +82,7 @@ template VTKM_EXEC OutType CellDiagonalRatioMetric(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, CellShapeType shape, - const vtkm::exec::FunctorBase&) + vtkm::ErrorCode&) { UNUSED(numPts); UNUSED(pts); @@ -99,11 +99,11 @@ template VTKM_EXEC OutType CellDiagonalRatioMetric(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, vtkm::CellShapeTagQuad, - const vtkm::exec::FunctorBase& worklet) + vtkm::ErrorCode& ec) { if (numPts != 4) { - worklet.RaiseError("Diagonal ratio metric(quad) requires 4 points."); + ec = vtkm::ErrorCode::InvalidNumberOfPoints; return OutType(0.0); } @@ -128,11 +128,11 @@ template VTKM_EXEC OutType CellDiagonalRatioMetric(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, vtkm::CellShapeTagHexahedron, - const vtkm::exec::FunctorBase& worklet) + vtkm::ErrorCode& ec) { if (numPts != 8) { - worklet.RaiseError("Diagonal ratio metric(hexahedron) requires 8 points."); + ec = vtkm::ErrorCode::InvalidNumberOfPoints; return OutType(0.0); } diff --git a/vtkm/worklet/cellmetrics/CellDimensionMetric.h b/vtkm/worklet/cellmetrics/CellDimensionMetric.h index 8c85cd760..b7b1ca786 100644 --- a/vtkm/worklet/cellmetrics/CellDimensionMetric.h +++ b/vtkm/worklet/cellmetrics/CellDimensionMetric.h @@ -62,7 +62,7 @@ template VTKM_EXEC OutType CellDimensionMetric(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, CellShapeType shape, - const vtkm::exec::FunctorBase&) + vtkm::ErrorCode&) { UNUSED(numPts); UNUSED(pts); @@ -74,10 +74,10 @@ template VTKM_EXEC OutType CellDimensionMetric(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, vtkm::CellShapeTagHexahedron, - const vtkm::exec::FunctorBase& worklet) + vtkm::ErrorCode& ec) { UNUSED(numPts); - UNUSED(worklet); + UNUSED(ec); OutType gradop[8][3]; OutType x1 = pts[0][0]; diff --git a/vtkm/worklet/cellmetrics/CellEdgeRatioMetric.h b/vtkm/worklet/cellmetrics/CellEdgeRatioMetric.h index d700f4fb4..1ae16ece5 100644 --- a/vtkm/worklet/cellmetrics/CellEdgeRatioMetric.h +++ b/vtkm/worklet/cellmetrics/CellEdgeRatioMetric.h @@ -92,7 +92,7 @@ template VTKM_EXEC OutType CellEdgeRatioMetric(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, CellShapeType shape, - const vtkm::exec::FunctorBase&) + vtkm::ErrorCode&) { UNUSED(numPts); UNUSED(pts); @@ -110,12 +110,12 @@ template VTKM_EXEC OutType CellEdgeRatioMetric(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, vtkm::CellShapeTagLine, - const vtkm::exec::FunctorBase& worklet) + vtkm::ErrorCode& ec) { UNUSED(pts); if (numPts < 2) { - worklet.RaiseError("Degenerate line has no edge ratio."); + ec = vtkm::ErrorCode::InvalidCellMetric; return OutType(0.0); } return OutType(1.0); @@ -130,11 +130,11 @@ template VTKM_EXEC OutType CellEdgeRatioMetric(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, vtkm::CellShapeTagTriangle, - const vtkm::exec::FunctorBase& worklet) + vtkm::ErrorCode& ec) { if (numPts != 3) { - worklet.RaiseError("Edge ratio metric(triangle) requires 3 points."); + ec = vtkm::ErrorCode::InvalidNumberOfPoints; return OutType(0.0); } @@ -156,11 +156,11 @@ template VTKM_EXEC OutType CellEdgeRatioMetric(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, vtkm::CellShapeTagQuad, - const vtkm::exec::FunctorBase& worklet) + vtkm::ErrorCode& ec) { if (numPts != 4) { - worklet.RaiseError("Edge ratio metric(quad) requires 4 points."); + ec = vtkm::ErrorCode::InvalidNumberOfPoints; return OutType(0.0); } @@ -187,11 +187,11 @@ template VTKM_EXEC OutType CellEdgeRatioMetric(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, vtkm::CellShapeTagTetra, - const vtkm::exec::FunctorBase& worklet) + vtkm::ErrorCode& ec) { if (numPts != 4) { - worklet.RaiseError("Edge ratio metric(tetrahedron) requires 4 points."); + ec = vtkm::ErrorCode::InvalidNumberOfPoints; return OutType(0.0); } @@ -214,11 +214,11 @@ template VTKM_EXEC OutType CellEdgeRatioMetric(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, vtkm::CellShapeTagHexahedron, - const vtkm::exec::FunctorBase& worklet) + vtkm::ErrorCode& ec) { if (numPts != 8) { - worklet.RaiseError("Edge ratio metric(hexahedron) requires 8 points."); + ec = vtkm::ErrorCode::InvalidNumberOfPoints; return OutType(0.0); } @@ -242,11 +242,11 @@ template VTKM_EXEC OutType CellEdgeRatioMetric(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, vtkm::CellShapeTagWedge, - const vtkm::exec::FunctorBase& worklet) + vtkm::ErrorCode& ec) { if (numPts != 6) { - worklet.RaiseError("Edge ratio metric(wedge) requires 6 points."); + ec = vtkm::ErrorCode::InvalidNumberOfPoints; return OutType(0.0); } @@ -271,11 +271,11 @@ template VTKM_EXEC OutType CellEdgeRatioMetric(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, vtkm::CellShapeTagPyramid, - const vtkm::exec::FunctorBase& worklet) + vtkm::ErrorCode& ec) { if (numPts != 5) { - worklet.RaiseError("Edge ratio metric(pyramid) requires 5 points."); + ec = vtkm::ErrorCode::InvalidNumberOfPoints; return OutType(0.0); } diff --git a/vtkm/worklet/cellmetrics/CellJacobianMetric.h b/vtkm/worklet/cellmetrics/CellJacobianMetric.h index 58721ba56..8f2c43791 100644 --- a/vtkm/worklet/cellmetrics/CellJacobianMetric.h +++ b/vtkm/worklet/cellmetrics/CellJacobianMetric.h @@ -58,7 +58,7 @@ template VTKM_EXEC OutType CellJacobianMetric(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, CellShapeType shape, - const vtkm::exec::FunctorBase&) + vtkm::ErrorCode&) { UNUSED(numPts); UNUSED(pts); @@ -78,11 +78,11 @@ template VTKM_EXEC OutType CellJacobianMetric(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, vtkm::CellShapeTagQuad, - const vtkm::exec::FunctorBase& worklet) + vtkm::ErrorCode& ec) { if (numPts != 4) { - worklet.RaiseError("Jacobian metric(quad) requires 4 points."); + ec = vtkm::ErrorCode::InvalidNumberOfPoints; return OutType(0.0); } @@ -113,11 +113,11 @@ template VTKM_EXEC OutType CellJacobianMetric(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, vtkm::CellShapeTagHexahedron, - const vtkm::exec::FunctorBase& worklet) + vtkm::ErrorCode& ec) { if (numPts != 8) { - worklet.RaiseError("Jacobian metric(hexahedron) requires 8 points."); + ec = vtkm::ErrorCode::InvalidNumberOfPoints; return OutType(0.0); } @@ -160,11 +160,11 @@ template VTKM_EXEC OutType CellJacobianMetric(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, vtkm::CellShapeTagTetra, - const vtkm::exec::FunctorBase& worklet) + vtkm::ErrorCode& ec) { if (numPts != 4) { - worklet.RaiseError("Jacobian metric (tetra) requires 4 points"); + ec = vtkm::ErrorCode::InvalidNumberOfPoints; return OutType(0.0); } diff --git a/vtkm/worklet/cellmetrics/CellMaxAngleMetric.h b/vtkm/worklet/cellmetrics/CellMaxAngleMetric.h index 0d72b3f77..4e7a6f7d3 100644 --- a/vtkm/worklet/cellmetrics/CellMaxAngleMetric.h +++ b/vtkm/worklet/cellmetrics/CellMaxAngleMetric.h @@ -54,7 +54,7 @@ template VTKM_EXEC OutType CellMaxAngleMetric(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, CellShapeType shape, - const vtkm::exec::FunctorBase&) + vtkm::ErrorCode&) { UNUSED(numPts); UNUSED(pts); @@ -75,11 +75,11 @@ template VTKM_EXEC OutType CellMaxAngleMetric(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, vtkm::CellShapeTagTriangle, - const vtkm::exec::FunctorBase& worklet) + vtkm::ErrorCode& ec) { if (numPts != 3) { - worklet.RaiseError("Minimum angle metric (triangle) requires 3 points."); + ec = vtkm::ErrorCode::InvalidNumberOfPoints; return OutType(0.0); } @@ -121,11 +121,11 @@ template VTKM_EXEC OutType CellMaxAngleMetric(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, vtkm::CellShapeTagQuad, - const vtkm::exec::FunctorBase& worklet) + vtkm::ErrorCode& ec) { if (numPts != 4) { - worklet.RaiseError("Minimum angle metric(quad) requires 4 points."); + ec = vtkm::ErrorCode::InvalidNumberOfPoints; return OutType(0.0); } diff --git a/vtkm/worklet/cellmetrics/CellMaxAspectFrobeniusMetric.h b/vtkm/worklet/cellmetrics/CellMaxAspectFrobeniusMetric.h index 1bf3a6082..16788c2dd 100644 --- a/vtkm/worklet/cellmetrics/CellMaxAspectFrobeniusMetric.h +++ b/vtkm/worklet/cellmetrics/CellMaxAspectFrobeniusMetric.h @@ -91,13 +91,12 @@ template VTKM_EXEC OutType CellMaxAspectFrobeniusMetric(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, CellShapeType shape, - const vtkm::exec::FunctorBase& worklet) + vtkm::ErrorCode& ec) { UNUSED(numPts); UNUSED(pts); UNUSED(shape); - worklet.RaiseError( - "Shape type template must be specialized to compute the max aspect frobenius metric."); + ec = vtkm::ErrorCode::InvalidCellMetric; return OutType(0.0); } @@ -109,17 +108,16 @@ template VTKM_EXEC OutType CellMaxAspectFrobeniusMetric(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, vtkm::CellShapeTagPolygon, - const vtkm::exec::FunctorBase& worklet) + vtkm::ErrorCode& ec) { if (numPts == 3) return vtkm::worklet::cellmetrics::CellAspectFrobeniusMetric( - numPts, pts, vtkm::CellShapeTagTriangle(), worklet); + numPts, pts, vtkm::CellShapeTagTriangle(), ec); if (numPts == 4) - return CellMaxAspectFrobeniusMetric(numPts, pts, vtkm::CellShapeTagQuad(), worklet); + return CellMaxAspectFrobeniusMetric(numPts, pts, vtkm::CellShapeTagQuad(), ec); else { - worklet.RaiseError( - "Max aspect frobenius metric is not supported for (n<3)- or (n>4)-vertex polygons."); + ec = vtkm::ErrorCode::InvalidCellMetric; return OutType(0.0); } } @@ -129,11 +127,11 @@ template VTKM_EXEC OutType CellMaxAspectFrobeniusMetric(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, vtkm::CellShapeTagLine, - const vtkm::exec::FunctorBase& worklet) + vtkm::ErrorCode& ec) { UNUSED(numPts); UNUSED(pts); - worklet.RaiseError("Max aspect frobenius metric is not supported for lines/edges."); + ec = vtkm::ErrorCode::InvalidCellMetric; return OutType(0.0); } @@ -144,15 +142,15 @@ template VTKM_EXEC OutType CellMaxAspectFrobeniusMetric(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, vtkm::CellShapeTagTriangle, - const vtkm::exec::FunctorBase& worklet) + vtkm::ErrorCode& ec) { if (numPts != 3) { - worklet.RaiseError("Max aspect frobenius metric(triangle) requires 3 points."); + ec = vtkm::ErrorCode::InvalidNumberOfPoints; return OutType(0.0); } return vtkm::worklet::cellmetrics::CellAspectFrobeniusMetric( - numPts, pts, vtkm::CellShapeTagTriangle(), worklet); + numPts, pts, vtkm::CellShapeTagTriangle(), ec); } //The max aspect frobenius metric is not supported for pyramids. @@ -160,11 +158,11 @@ template VTKM_EXEC OutType CellMaxAspectFrobeniusMetric(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, vtkm::CellShapeTagPyramid, - const vtkm::exec::FunctorBase& worklet) + vtkm::ErrorCode& ec) { UNUSED(numPts); UNUSED(pts); - worklet.RaiseError("Max aspect frobenius metric is not supported for pyramids."); + ec = vtkm::ErrorCode::InvalidCellMetric; return OutType(0.0); } @@ -183,11 +181,11 @@ template VTKM_EXEC OutType CellMaxAspectFrobeniusMetric(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, vtkm::CellShapeTagQuad, - const vtkm::exec::FunctorBase& worklet) + vtkm::ErrorCode& ec) { if (numPts != 4) { - worklet.RaiseError("Max aspect frobenius metric(quad) requires 4 points."); + ec = vtkm::ErrorCode::InvalidNumberOfPoints; return OutType(0.0); } //The 4 edges of a quad @@ -240,16 +238,16 @@ template VTKM_EXEC OutType CellMaxAspectFrobeniusMetric(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, vtkm::CellShapeTagTetra, - const vtkm::exec::FunctorBase& worklet) + vtkm::ErrorCode& ec) { if (numPts != 4) { - worklet.RaiseError("Max aspect frobenius metric(tetrahedron) requires 4 points."); + ec = vtkm::ErrorCode::InvalidNumberOfPoints; return OutType(0.0); } return vtkm::worklet::cellmetrics::CellAspectFrobeniusMetric( - numPts, pts, vtkm::CellShapeTagTetra(), worklet); + numPts, pts, vtkm::CellShapeTagTetra(), ec); } // Computes the maximum aspect frobenius of a hexahedron. @@ -265,11 +263,11 @@ template VTKM_EXEC OutType CellMaxAspectFrobeniusMetric(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, vtkm::CellShapeTagHexahedron, - const vtkm::exec::FunctorBase& worklet) + vtkm::ErrorCode& ec) { if (numPts != 8) { - worklet.RaiseError("Max aspect frobenius metric(hexahedron) requires 8 points."); + ec = vtkm::ErrorCode::InvalidNumberOfPoints; return OutType(0.0); } @@ -334,11 +332,11 @@ template VTKM_EXEC OutType CellMaxAspectFrobeniusMetric(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, vtkm::CellShapeTagWedge, - const vtkm::exec::FunctorBase& worklet) + vtkm::ErrorCode& ec) { if (numPts != 6) { - worklet.RaiseError("Max aspect frobenius metric(wedge) requires 6 points."); + ec = vtkm::ErrorCode::InvalidNumberOfPoints; return OutType(0.0); } @@ -358,12 +356,12 @@ VTKM_EXEC OutType CellMaxAspectFrobeniusMetric(const vtkm::IdComponent& numPts, //Return the maximum metric value among all 6 tets as the maximum aspect frobenius. const vtkm::IdComponent tetPts = 4; OutType max_aspect_frobenius = vtkm::worklet::cellmetrics::CellAspectFrobeniusMetric( - tetPts, tetras[0], vtkm::CellShapeTagTetra(), worklet); + tetPts, tetras[0], vtkm::CellShapeTagTetra(), ec); OutType curr; for (vtkm::Id i = 1; i < 6; i++) { curr = vtkm::worklet::cellmetrics::CellAspectFrobeniusMetric( - tetPts, tetras[i], vtkm::CellShapeTagTetra(), worklet); + tetPts, tetras[i], vtkm::CellShapeTagTetra(), ec); if (curr > max_aspect_frobenius) max_aspect_frobenius = curr; } diff --git a/vtkm/worklet/cellmetrics/CellMaxDiagonalMetric.h b/vtkm/worklet/cellmetrics/CellMaxDiagonalMetric.h index 47b0adae5..f094f1760 100644 --- a/vtkm/worklet/cellmetrics/CellMaxDiagonalMetric.h +++ b/vtkm/worklet/cellmetrics/CellMaxDiagonalMetric.h @@ -54,7 +54,7 @@ template VTKM_EXEC OutType CellMaxDiagonalMetric(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, CellShapeType shape, - const vtkm::exec::FunctorBase&) + vtkm::ErrorCode&) { UNUSED(numPts); UNUSED(pts); @@ -66,11 +66,11 @@ template VTKM_EXEC OutType CellMaxDiagonalMetric(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, vtkm::CellShapeTagHexahedron, - const vtkm::exec::FunctorBase& worklet) + vtkm::ErrorCode& ec) { if (numPts != 8) { - worklet.RaiseError("Max diagonal metric(hexahedron) requires 8 points."); + ec = vtkm::ErrorCode::InvalidNumberOfPoints; return OutType(0.0); } diff --git a/vtkm/worklet/cellmetrics/CellMinAngleMetric.h b/vtkm/worklet/cellmetrics/CellMinAngleMetric.h index ef8fa5f91..539509180 100644 --- a/vtkm/worklet/cellmetrics/CellMinAngleMetric.h +++ b/vtkm/worklet/cellmetrics/CellMinAngleMetric.h @@ -51,7 +51,7 @@ template VTKM_EXEC OutType CellMinAngleMetric(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, CellShapeType shape, - const vtkm::exec::FunctorBase&) + vtkm::ErrorCode&) { UNUSED(numPts); UNUSED(pts); @@ -73,11 +73,11 @@ template VTKM_EXEC OutType CellMinAngleMetric(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, vtkm::CellShapeTagTriangle, - const vtkm::exec::FunctorBase& worklet) + vtkm::ErrorCode& ec) { if (numPts != 3) { - worklet.RaiseError("Minimum angle metric(quad) requires 3 points."); + ec = vtkm::ErrorCode::InvalidNumberOfPoints; return OutType(0.0); } @@ -119,11 +119,11 @@ template VTKM_EXEC OutType CellMinAngleMetric(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, vtkm::CellShapeTagQuad, - const vtkm::exec::FunctorBase& worklet) + vtkm::ErrorCode& ec) { if (numPts != 4) { - worklet.RaiseError("Minimum angle metric(quad) requires 4 points."); + ec = vtkm::ErrorCode::InvalidNumberOfPoints; return OutType(0.0); } using Scalar = OutType; diff --git a/vtkm/worklet/cellmetrics/CellMinDiagonalMetric.h b/vtkm/worklet/cellmetrics/CellMinDiagonalMetric.h index b31064b90..d85663f98 100644 --- a/vtkm/worklet/cellmetrics/CellMinDiagonalMetric.h +++ b/vtkm/worklet/cellmetrics/CellMinDiagonalMetric.h @@ -54,7 +54,7 @@ template VTKM_EXEC OutType CellMinDiagonalMetric(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, CellShapeType shape, - const vtkm::exec::FunctorBase&) + vtkm::ErrorCode&) { UNUSED(numPts); UNUSED(pts); @@ -66,11 +66,11 @@ template VTKM_EXEC OutType CellMinDiagonalMetric(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, vtkm::CellShapeTagHexahedron, - const vtkm::exec::FunctorBase& worklet) + vtkm::ErrorCode& ec) { if (numPts != 8) { - worklet.RaiseError("Min diagonal metric(hexahedron) requires 8 points."); + ec = vtkm::ErrorCode::InvalidNumberOfPoints; return OutType(0.0); } diff --git a/vtkm/worklet/cellmetrics/CellOddyMetric.h b/vtkm/worklet/cellmetrics/CellOddyMetric.h index f348c73d7..d5d769cf8 100644 --- a/vtkm/worklet/cellmetrics/CellOddyMetric.h +++ b/vtkm/worklet/cellmetrics/CellOddyMetric.h @@ -54,7 +54,7 @@ template VTKM_EXEC OutType CellOddyMetric(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, CellShapeType shape, - const vtkm::exec::FunctorBase&) + vtkm::ErrorCode&) { UNUSED(numPts); UNUSED(pts); @@ -92,11 +92,11 @@ template VTKM_EXEC OutType CellOddyMetric(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, vtkm::CellShapeTagQuad, - const vtkm::exec::FunctorBase& worklet) + vtkm::ErrorCode& ec) { if (numPts != 4) { - worklet.RaiseError("Oddy metric(quad) requires 4 points."); + ec = vtkm::ErrorCode::InvalidNumberOfPoints; return OutType(0.0); } @@ -139,11 +139,11 @@ template VTKM_EXEC OutType CellOddyMetric(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, vtkm::CellShapeTagHexahedron, - const vtkm::exec::FunctorBase& worklet) + vtkm::ErrorCode& ec) { if (numPts != 8) { - worklet.RaiseError("Oddy metric(hexahedron) requires 8 points."); + ec = vtkm::ErrorCode::InvalidNumberOfPoints; return OutType(0.0); } diff --git a/vtkm/worklet/cellmetrics/CellRelativeSizeSquaredMetric.h b/vtkm/worklet/cellmetrics/CellRelativeSizeSquaredMetric.h index 02d86ad5d..7516d6035 100644 --- a/vtkm/worklet/cellmetrics/CellRelativeSizeSquaredMetric.h +++ b/vtkm/worklet/cellmetrics/CellRelativeSizeSquaredMetric.h @@ -61,7 +61,7 @@ VTKM_EXEC OutType CellRelativeSizeSquaredMetric(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, const OutType& avgArea, CellShapeType shape, - const vtkm::exec::FunctorBase&) + vtkm::ErrorCode&) { UNUSED(numPts); UNUSED(pts); @@ -77,15 +77,15 @@ VTKM_EXEC OutType CellRelativeSizeSquaredMetric(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, const OutType& avgArea, vtkm::CellShapeTagTriangle tag, - const vtkm::exec::FunctorBase& worklet) + vtkm::ErrorCode& ec) { - UNUSED(worklet); + UNUSED(ec); if (numPts != 3) { - worklet.RaiseError("Edge ratio metric(triangle) requires 3 points."); + ec = vtkm::ErrorCode::InvalidNumberOfPoints; return OutType(-1.); } - OutType A = vtkm::exec::CellMeasure(numPts, pts, tag, worklet); + OutType A = vtkm::exec::CellMeasure(numPts, pts, tag, ec); OutType R = A / avgArea; if (R == OutType(0.)) return OutType(0.); @@ -98,15 +98,15 @@ VTKM_EXEC OutType CellRelativeSizeSquaredMetric(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, const OutType& avgArea, vtkm::CellShapeTagQuad tag, - const vtkm::exec::FunctorBase& worklet) + vtkm::ErrorCode& ec) { - UNUSED(worklet); + UNUSED(ec); if (numPts != 4) { - worklet.RaiseError("Edge ratio metric(quadrilateral) requires 4 points."); + ec = vtkm::ErrorCode::InvalidNumberOfPoints; return OutType(-1.); } - OutType A = vtkm::exec::CellMeasure(numPts, pts, tag, worklet); + OutType A = vtkm::exec::CellMeasure(numPts, pts, tag, ec); OutType R = A / avgArea; if (R == OutType(0.)) return OutType(0.); @@ -121,15 +121,15 @@ VTKM_EXEC OutType CellRelativeSizeSquaredMetric(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, const OutType& avgVolume, vtkm::CellShapeTagTetra tag, - const vtkm::exec::FunctorBase& worklet) + vtkm::ErrorCode& ec) { - UNUSED(worklet); + UNUSED(ec); if (numPts != 4) { - worklet.RaiseError("Edge ratio metric(tetrahedral) requires 4 points."); + ec = vtkm::ErrorCode::InvalidNumberOfPoints; return OutType(-1.); } - OutType V = vtkm::exec::CellMeasure(numPts, pts, tag, worklet); + OutType V = vtkm::exec::CellMeasure(numPts, pts, tag, ec); OutType R = V / avgVolume; if (R == OutType(0.)) return OutType(0.); @@ -142,13 +142,13 @@ VTKM_EXEC OutType CellRelativeSizeSquaredMetric(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, const OutType& avgVolume, vtkm::CellShapeTagHexahedron tag, - const vtkm::exec::FunctorBase& worklet) + vtkm::ErrorCode& ec) { UNUSED(tag); - UNUSED(worklet); + UNUSED(ec); if (numPts != 8) { - worklet.RaiseError("Edge ratio metric(hexahedral) requires 8 points."); + ec = vtkm::ErrorCode::InvalidNumberOfPoints; return OutType(-1.); } OutType X1x = (pts[1][0] - pts[0][0]) + (pts[2][0] - pts[3][0]) + (pts[5][0] - pts[4][0]) + diff --git a/vtkm/worklet/cellmetrics/CellScaledJacobianMetric.h b/vtkm/worklet/cellmetrics/CellScaledJacobianMetric.h index 2305a00e1..b314cc2bc 100644 --- a/vtkm/worklet/cellmetrics/CellScaledJacobianMetric.h +++ b/vtkm/worklet/cellmetrics/CellScaledJacobianMetric.h @@ -56,7 +56,7 @@ template VTKM_EXEC OutType CellScaledJacobianMetric(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, CellShapeType shape, - const vtkm::exec::FunctorBase&) + vtkm::ErrorCode&) { UNUSED(numPts); UNUSED(pts); @@ -78,11 +78,11 @@ template VTKM_EXEC OutType CellScaledJacobianMetric(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, vtkm::CellShapeTagTriangle, - const vtkm::exec::FunctorBase& worklet) + vtkm::ErrorCode& ec) { if (numPts != 3) { - worklet.RaiseError("ScaledJacobian metric(tri) requires 3 points."); + ec = vtkm::ErrorCode::InvalidNumberOfPoints; return OutType(0.0); } using Scalar = OutType; @@ -135,11 +135,11 @@ template VTKM_EXEC OutType CellScaledJacobianMetric(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, vtkm::CellShapeTagQuad, - const vtkm::exec::FunctorBase& worklet) + vtkm::ErrorCode& ec) { if (numPts != 4) { - worklet.RaiseError("ScaledJacobian metric(quad) requires 4 points."); + ec = vtkm::ErrorCode::InvalidNumberOfPoints; return OutType(0.0); } using Scalar = OutType; @@ -195,11 +195,11 @@ template VTKM_EXEC OutType CellScaledJacobianMetric(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, vtkm::CellShapeTagHexahedron, - const vtkm::exec::FunctorBase& worklet) + vtkm::ErrorCode& ec) { if (numPts != 8) { - worklet.RaiseError("ScaledJacobian metric(hexahedron) requires 8 points."); + ec = vtkm::ErrorCode::InvalidNumberOfPoints; return OutType(0.0); } @@ -266,11 +266,11 @@ template VTKM_EXEC OutType CellScaledJacobianMetric(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, vtkm::CellShapeTagTetra, - const vtkm::exec::FunctorBase& worklet) + vtkm::ErrorCode& ec) { if (numPts != 4) { - worklet.RaiseError("ScaledJacobian metric requires 4 points"); + ec = vtkm::ErrorCode::InvalidNumberOfPoints; return OutType(0.0); } diff --git a/vtkm/worklet/cellmetrics/CellShapeAndSizeMetric.h b/vtkm/worklet/cellmetrics/CellShapeAndSizeMetric.h index 5cdc58dae..0ae2677b3 100644 --- a/vtkm/worklet/cellmetrics/CellShapeAndSizeMetric.h +++ b/vtkm/worklet/cellmetrics/CellShapeAndSizeMetric.h @@ -57,7 +57,7 @@ VTKM_EXEC OutType CellShapeAndSizeMetric(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, const OutType& avgArea, CellShapeType shape, - const vtkm::exec::FunctorBase&) + vtkm::ErrorCode&) { UNUSED(numPts); UNUSED(pts); @@ -73,11 +73,11 @@ VTKM_EXEC OutType CellShapeAndSizeMetric(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, const OutType& avgArea, vtkm::CellShapeTagTriangle tag, - const vtkm::exec::FunctorBase& worklet) + vtkm::ErrorCode& ec) { OutType rss = vtkm::worklet::cellmetrics::CellRelativeSizeSquaredMetric( - numPts, pts, avgArea, tag, worklet); - OutType shape = vtkm::worklet::cellmetrics::CellShapeMetric(numPts, pts, tag, worklet); + numPts, pts, avgArea, tag, ec); + OutType shape = vtkm::worklet::cellmetrics::CellShapeMetric(numPts, pts, tag, ec); OutType q = rss * shape; return OutType(q); } @@ -87,11 +87,11 @@ VTKM_EXEC OutType CellShapeAndSizeMetric(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, const OutType& avgArea, vtkm::CellShapeTagQuad tag, - const vtkm::exec::FunctorBase& worklet) + vtkm::ErrorCode& ec) { OutType rss = vtkm::worklet::cellmetrics::CellRelativeSizeSquaredMetric( - numPts, pts, avgArea, tag, worklet); - OutType shape = vtkm::worklet::cellmetrics::CellShapeMetric(numPts, pts, tag, worklet); + numPts, pts, avgArea, tag, ec); + OutType shape = vtkm::worklet::cellmetrics::CellShapeMetric(numPts, pts, tag, ec); OutType q = rss * shape; return OutType(q); } @@ -103,11 +103,11 @@ VTKM_EXEC OutType CellShapeAndSizeMetric(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, const OutType& avgVolume, vtkm::CellShapeTagTetra tag, - const vtkm::exec::FunctorBase& worklet) + vtkm::ErrorCode& ec) { OutType rss = vtkm::worklet::cellmetrics::CellRelativeSizeSquaredMetric( - numPts, pts, avgVolume, tag, worklet); - OutType shape = vtkm::worklet::cellmetrics::CellShapeMetric(numPts, pts, tag, worklet); + numPts, pts, avgVolume, tag, ec); + OutType shape = vtkm::worklet::cellmetrics::CellShapeMetric(numPts, pts, tag, ec); OutType q = rss * shape; return OutType(q); } @@ -117,11 +117,11 @@ VTKM_EXEC OutType CellShapeAndSizeMetric(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, const OutType& avgVolume, vtkm::CellShapeTagHexahedron tag, - const vtkm::exec::FunctorBase& worklet) + vtkm::ErrorCode& ec) { OutType rss = vtkm::worklet::cellmetrics::CellRelativeSizeSquaredMetric( - numPts, pts, avgVolume, tag, worklet); - OutType shape = vtkm::worklet::cellmetrics::CellShapeMetric(numPts, pts, tag, worklet); + numPts, pts, avgVolume, tag, ec); + OutType shape = vtkm::worklet::cellmetrics::CellShapeMetric(numPts, pts, tag, ec); OutType q = rss * shape; return OutType(q); } diff --git a/vtkm/worklet/cellmetrics/CellShapeMetric.h b/vtkm/worklet/cellmetrics/CellShapeMetric.h index 65bc23a95..e732d4c19 100644 --- a/vtkm/worklet/cellmetrics/CellShapeMetric.h +++ b/vtkm/worklet/cellmetrics/CellShapeMetric.h @@ -52,7 +52,7 @@ template VTKM_EXEC OutType CellShapeMetric(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, CellShapeType shape, - const vtkm::exec::FunctorBase&) + vtkm::ErrorCode&) { UNUSED(numPts); UNUSED(pts); @@ -67,11 +67,11 @@ template VTKM_EXEC OutType CellShapeMetric(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, vtkm::CellShapeTagTriangle, - const vtkm::exec::FunctorBase& worklet) + vtkm::ErrorCode& ec) { if (numPts != 3) { - worklet.RaiseError("Shape metric(triangle) requires 3 points."); + ec = vtkm::ErrorCode::InvalidNumberOfPoints; return OutType(0.0); } using Scalar = OutType; @@ -79,7 +79,7 @@ VTKM_EXEC OutType CellShapeMetric(const vtkm::IdComponent& numPts, const Scalar condition = vtkm::worklet::cellmetrics::CellConditionMetric( - numPts, pts, vtkm::CellShapeTagTriangle(), worklet); + numPts, pts, vtkm::CellShapeTagTriangle(), ec); const Scalar q(1 / condition); return q; @@ -90,11 +90,11 @@ template VTKM_EXEC OutType CellShapeMetric(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, vtkm::CellShapeTagQuad, - const vtkm::exec::FunctorBase& worklet) + vtkm::ErrorCode& ec) { if (numPts != 4) { - worklet.RaiseError("Area(quad) requires 4 points."); + ec = vtkm::ErrorCode::InvalidNumberOfPoints; return OutType(0.0); } @@ -130,11 +130,11 @@ template VTKM_EXEC OutType CellShapeMetric(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, vtkm::CellShapeTagTetra, - const vtkm::exec::FunctorBase& worklet) + vtkm::ErrorCode& ec) { if (numPts != 4) { - worklet.RaiseError("Shape metric(tetrahedron) requires 4 points."); + ec = vtkm::ErrorCode::InvalidNumberOfPoints; return OutType(0.0); } using Scalar = OutType; @@ -148,7 +148,7 @@ VTKM_EXEC OutType CellShapeMetric(const vtkm::IdComponent& numPts, const Scalar three(3.0); const Scalar jacobian = vtkm::worklet::cellmetrics::CellJacobianMetric( - numPts, pts, vtkm::CellShapeTagTetra(), worklet); + numPts, pts, vtkm::CellShapeTagTetra(), ec); if (jacobian <= zero) { @@ -182,11 +182,11 @@ template VTKM_EXEC OutType CellShapeMetric(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, vtkm::CellShapeTagHexahedron, - const vtkm::exec::FunctorBase& worklet) + vtkm::ErrorCode& ec) { if (numPts != 8) { - worklet.RaiseError("Volume(hexahedron) requires 8 points."); + ec = vtkm::ErrorCode::InvalidNumberOfPoints; return OutType(0.0); } using Scalar = OutType; diff --git a/vtkm/worklet/cellmetrics/CellShearMetric.h b/vtkm/worklet/cellmetrics/CellShearMetric.h index eea57384d..6276d8eca 100644 --- a/vtkm/worklet/cellmetrics/CellShearMetric.h +++ b/vtkm/worklet/cellmetrics/CellShearMetric.h @@ -59,7 +59,7 @@ template VTKM_EXEC OutType CellShearMetric(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, CellShapeType shape, - const vtkm::exec::FunctorBase&) + vtkm::ErrorCode&) { UNUSED(numPts); UNUSED(pts); @@ -73,11 +73,11 @@ template VTKM_EXEC OutType CellShearMetric(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, vtkm::CellShapeTagQuad, - const vtkm::exec::FunctorBase& worklet) + vtkm::ErrorCode& ec) { if (numPts != 4) { - worklet.RaiseError("Diagonal ratio metric(quad) requires 4 points."); + ec = vtkm::ErrorCode::InvalidNumberOfPoints; return OutType(0.0); } using Scalar = OutType; @@ -110,11 +110,11 @@ template VTKM_EXEC OutType CellShearMetric(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, vtkm::CellShapeTagHexahedron, - const vtkm::exec::FunctorBase& worklet) + vtkm::ErrorCode& ec) { if (numPts != 8) { - worklet.RaiseError("Diagonal ratio metric(hex) requires 8 points."); + ec = vtkm::ErrorCode::InvalidNumberOfPoints; return OutType(-1.0); } using Scalar = OutType; diff --git a/vtkm/worklet/cellmetrics/CellSkewMetric.h b/vtkm/worklet/cellmetrics/CellSkewMetric.h index 09c50b0a2..38b73b91f 100644 --- a/vtkm/worklet/cellmetrics/CellSkewMetric.h +++ b/vtkm/worklet/cellmetrics/CellSkewMetric.h @@ -43,12 +43,12 @@ template VTKM_EXEC OutType CellSkewMetric(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, CellShapeType shape, - const vtkm::exec::FunctorBase& worklet) + vtkm::ErrorCode& ec) { UNUSED(numPts); UNUSED(pts); UNUSED(shape); - UNUSED(worklet); + UNUSED(ec); return OutType(-1.0); } @@ -56,10 +56,10 @@ template VTKM_EXEC OutType CellSkewMetric(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, vtkm::CellShapeTagHexahedron, - const vtkm::exec::FunctorBase& worklet) + vtkm::ErrorCode& ec) { UNUSED(numPts); - UNUSED(worklet); + UNUSED(ec); using Scalar = OutType; using Vector = typename PointCoordVecType::ComponentType; Vector X1 = (pts[1] - pts[0]) + (pts[2] - pts[3]) + (pts[5] - pts[4]) + (pts[6] - pts[7]); @@ -84,10 +84,10 @@ template VTKM_EXEC OutType CellSkewMetric(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, vtkm::CellShapeTagQuad, - const vtkm::exec::FunctorBase& worklet) + vtkm::ErrorCode& ec) { UNUSED(numPts); - UNUSED(worklet); + UNUSED(ec); using Scalar = OutType; using CollectionOfPoints = PointCoordVecType; using Vector = typename PointCoordVecType::ComponentType; diff --git a/vtkm/worklet/cellmetrics/CellStretchMetric.h b/vtkm/worklet/cellmetrics/CellStretchMetric.h index 5d1f0df08..7d33e0246 100644 --- a/vtkm/worklet/cellmetrics/CellStretchMetric.h +++ b/vtkm/worklet/cellmetrics/CellStretchMetric.h @@ -52,12 +52,12 @@ template VTKM_EXEC OutType CellStretchMetric(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, CellShapeType shape, - const vtkm::exec::FunctorBase& worklet) + vtkm::ErrorCode& ec) { UNUSED(numPts); UNUSED(pts); UNUSED(shape); - UNUSED(worklet); + UNUSED(ec); return OutType(-1.0); } @@ -65,10 +65,10 @@ template VTKM_EXEC OutType CellStretchMetric(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, vtkm::CellShapeTagQuad, - const vtkm::exec::FunctorBase& worklet) + vtkm::ErrorCode& ec) { UNUSED(numPts); - UNUSED(worklet); + UNUSED(ec); using Scalar = OutType; using CollectionOfPoints = PointCoordVecType; using Vector = typename PointCoordVecType::ComponentType; @@ -91,10 +91,10 @@ template VTKM_EXEC OutType CellStretchMetric(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, vtkm::CellShapeTagHexahedron, - const vtkm::exec::FunctorBase& worklet) + vtkm::ErrorCode& ec) { UNUSED(numPts); - UNUSED(worklet); + UNUSED(ec); using Scalar = OutType; using CollectionOfPoints = PointCoordVecType; using Vector = typename PointCoordVecType::ComponentType; diff --git a/vtkm/worklet/cellmetrics/CellTaperMetric.h b/vtkm/worklet/cellmetrics/CellTaperMetric.h index 0e700a1fa..2d72c8a9a 100644 --- a/vtkm/worklet/cellmetrics/CellTaperMetric.h +++ b/vtkm/worklet/cellmetrics/CellTaperMetric.h @@ -51,12 +51,12 @@ template VTKM_EXEC OutType CellTaperMetric(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, CellShapeType shape, - const vtkm::exec::FunctorBase& worklet) + vtkm::ErrorCode& ec) { UNUSED(numPts); UNUSED(pts); UNUSED(shape); - UNUSED(worklet); + UNUSED(ec); return OutType(-1.0); } // ========================= 2D cells ================================== @@ -64,10 +64,10 @@ template VTKM_EXEC OutType CellTaperMetric(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, vtkm::CellShapeTagQuad, - const vtkm::exec::FunctorBase& worklet) + vtkm::ErrorCode& ec) { UNUSED(numPts); - UNUSED(worklet); + UNUSED(ec); using Scalar = OutType; using CollectionOfPoints = PointCoordVecType; using Vector = typename PointCoordVecType::ComponentType; @@ -96,10 +96,10 @@ template VTKM_EXEC OutType CellTaperMetric(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, vtkm::CellShapeTagHexahedron, - const vtkm::exec::FunctorBase& worklet) + vtkm::ErrorCode& ec) { UNUSED(numPts); - UNUSED(worklet); + UNUSED(ec); using Scalar = OutType; Scalar X1 = vtkm::Sqrt(vtkm::MagnitudeSquared((pts[1] - pts[0]) + (pts[2] - pts[3]) + diff --git a/vtkm/worklet/cellmetrics/CellWarpageMetric.h b/vtkm/worklet/cellmetrics/CellWarpageMetric.h index 5fd7e6d29..0e87446f5 100644 --- a/vtkm/worklet/cellmetrics/CellWarpageMetric.h +++ b/vtkm/worklet/cellmetrics/CellWarpageMetric.h @@ -22,6 +22,7 @@ #include "vtkm/CellShape.h" #include "vtkm/CellTraits.h" +#include "vtkm/ErrorCode.h" #include "vtkm/VecTraits.h" #include "vtkm/VectorAnalysis.h" #include "vtkm/exec/FunctorBase.h" @@ -37,13 +38,13 @@ template VTKM_EXEC OutType CellWarpageMetric(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, CellShapeType shape, - const vtkm::exec::FunctorBase& worklet) + vtkm::ErrorCode& ec) { UNUSED(numPts); UNUSED(pts); UNUSED(shape); - UNUSED(worklet); - //worklet.RaiseError("Shape type template must be Quad to compute warpage"); + UNUSED(ec); + //ec = vtkm::ErrorCode::InvalidCellMetric; return OutType(-1.0); } @@ -51,10 +52,10 @@ template VTKM_EXEC OutType CellWarpageMetric(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, vtkm::CellShapeTagQuad, - const vtkm::exec::FunctorBase& worklet) + vtkm::ErrorCode& ec) { UNUSED(numPts); - UNUSED(worklet); + UNUSED(ec); using Scalar = OutType; using CollectionOfPoints = PointCoordVecType; using Vector = typename PointCoordVecType::ComponentType;