mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-09-08 13:23:51 +00:00
Fix divide-by-zero in UnitTestCellInterpolate
This commit is contained in:
parent
e4ae3cee1b
commit
9ce97352d9
@ -59,6 +59,11 @@ struct TestInterpolateFunctor
|
|||||||
void DoTestWithField(CellShapeTag shape, const FieldVecType& fieldValues) const
|
void DoTestWithField(CellShapeTag shape, const FieldVecType& fieldValues) const
|
||||||
{
|
{
|
||||||
vtkm::IdComponent numPoints = fieldValues.GetNumberOfComponents();
|
vtkm::IdComponent numPoints = fieldValues.GetNumberOfComponents();
|
||||||
|
if (numPoints < 1)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
FieldType averageValue = vtkm::TypeTraits<FieldType>::ZeroInitialization();
|
FieldType averageValue = vtkm::TypeTraits<FieldType>::ZeroInitialization();
|
||||||
for (vtkm::IdComponent pointIndex = 0; pointIndex < numPoints; pointIndex++)
|
for (vtkm::IdComponent pointIndex = 0; pointIndex < numPoints; pointIndex++)
|
||||||
{
|
{
|
||||||
@ -77,16 +82,13 @@ struct TestInterpolateFunctor
|
|||||||
"Interpolation at point not point value.");
|
"Interpolation at point not point value.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (numPoints > 0)
|
vtkm::Vec3f pcoord;
|
||||||
{
|
CHECK_CALL(vtkm::exec::ParametricCoordinatesCenter(numPoints, shape, pcoord));
|
||||||
vtkm::Vec3f pcoord;
|
FieldType interpolatedValue;
|
||||||
CHECK_CALL(vtkm::exec::ParametricCoordinatesCenter(numPoints, shape, pcoord));
|
CHECK_CALL(vtkm::exec::CellInterpolate(fieldValues, pcoord, shape, interpolatedValue));
|
||||||
FieldType interpolatedValue;
|
|
||||||
CHECK_CALL(vtkm::exec::CellInterpolate(fieldValues, pcoord, shape, interpolatedValue));
|
|
||||||
|
|
||||||
VTKM_TEST_ASSERT(test_equal(averageValue, interpolatedValue),
|
VTKM_TEST_ASSERT(test_equal(averageValue, interpolatedValue),
|
||||||
"Interpolation at center not average value.");
|
"Interpolation at center not average value.");
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename CellShapeTag>
|
template <typename CellShapeTag>
|
||||||
|
Loading…
Reference in New Issue
Block a user