mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-09-08 13:23:51 +00:00
throws an exception if Gradient input is scalar
Signed-off-by: Vicente Adolfo Bolea Sanchez <vicente.bolea@kitware.com>
This commit is contained in:
parent
4fef71c646
commit
df2dba3467
@ -52,6 +52,19 @@ inline vtkm::cont::DataSet Gradient::DoExecute(
|
||||
throw vtkm::cont::ErrorFilterExecution("Point field expected.");
|
||||
}
|
||||
|
||||
constexpr bool isVector = std::is_same<typename vtkm::VecTraits<T>::HasMultipleComponents,
|
||||
vtkm::VecTraitsTagMultipleComponents>::value;
|
||||
|
||||
if (GetComputeQCriterion() && !isVector)
|
||||
{
|
||||
throw vtkm::cont::ErrorFilterExecution("scalar gradients can't generate qcriterion");
|
||||
}
|
||||
|
||||
if (GetComputeVorticity() && !isVector)
|
||||
{
|
||||
throw vtkm::cont::ErrorFilterExecution("scalar gradients can't generate vorticity");
|
||||
}
|
||||
|
||||
const vtkm::cont::DynamicCellSet& cells = input.GetCellSet();
|
||||
const vtkm::cont::CoordinateSystem& coords =
|
||||
input.GetCoordinateSystem(this->GetActiveCoordinateSystemIndex());
|
||||
@ -86,9 +99,6 @@ inline vtkm::cont::DataSet Gradient::DoExecute(
|
||||
transpose_3x3(outArray);
|
||||
}
|
||||
|
||||
constexpr bool isVector = std::is_same<typename vtkm::VecTraits<T>::HasMultipleComponents,
|
||||
vtkm::VecTraitsTagMultipleComponents>::value;
|
||||
|
||||
vtkm::cont::Field::Association fieldAssociation(this->ComputePointGradient
|
||||
? vtkm::cont::Field::Association::POINTS
|
||||
: vtkm::cont::Field::Association::CELL_SET);
|
||||
|
@ -31,28 +31,17 @@ void TestCellGradientUniform3D()
|
||||
|
||||
gradient.SetActiveField("pointvar");
|
||||
|
||||
vtkm::cont::DataSet result = gradient.Execute(dataSet);
|
||||
vtkm::cont::DataSet result;
|
||||
|
||||
VTKM_TEST_ASSERT(result.HasCellField("Gradient"), "Field missing.");
|
||||
|
||||
//verify that the vorticity and qcriterion fields don't exist
|
||||
VTKM_TEST_ASSERT(result.HasField("Vorticity") == false,
|
||||
"scalar gradients can't generate vorticity");
|
||||
VTKM_TEST_ASSERT(result.HasField("QCriterion") == false,
|
||||
"scalar gradients can't generate qcriterion");
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec3f_32> resultArrayHandle;
|
||||
result.GetField("Gradient").GetData().CopyTo(resultArrayHandle);
|
||||
vtkm::Vec3f_64 expected[4] = {
|
||||
{ 10.025, 30.075, 60.125 },
|
||||
{ 10.025, 30.075, 60.125 },
|
||||
{ 10.025, 30.075, 60.175 },
|
||||
{ 10.025, 30.075, 60.175 },
|
||||
};
|
||||
for (int i = 0; i < 4; ++i)
|
||||
// We provocate this exception
|
||||
try
|
||||
{
|
||||
VTKM_TEST_ASSERT(test_equal(resultArrayHandle.ReadPortal().Get(i), expected[i]),
|
||||
"Wrong result for CellGradient filter on 3D uniform data");
|
||||
result = gradient.Execute(dataSet);
|
||||
VTKM_TEST_FAIL("Gradient attempted to compute Vorticity or QCriterion with scalars");
|
||||
}
|
||||
catch (vtkm::cont::ErrorFilterExecution&)
|
||||
{
|
||||
// We should exit in this catch
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user