mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-09-16 17:22:55 +00:00
Merge topic 'deprecate_read_portal_get'
9aa350ee3 Fix bad whitespace. 9991179e6 Do not use auto return type; it's not supported until C++14. f1ee3f51f Merge branch 'master' into deprecate_read_portal_get 947104148 Merge branch 'master' into deprecate_read_portal_get d961c185a Deprecate ReadPortal().Get pattern. Acked-by: Kitware Robot <kwrobot@kitware.com> Acked-by: Allison Vacanti <alliepiper16@gmail.com> Merge-request: !2085
This commit is contained in:
commit
e5097aa314
@ -54,9 +54,10 @@ void CellLocatorUniformGrid::Build()
|
|||||||
}
|
}
|
||||||
|
|
||||||
UniformType uniformCoords = coords.GetData().Cast<UniformType>();
|
UniformType uniformCoords = coords.GetData().Cast<UniformType>();
|
||||||
this->Origin = uniformCoords.ReadPortal().GetOrigin();
|
auto coordsPortal = uniformCoords.ReadPortal();
|
||||||
|
this->Origin = coordsPortal.GetOrigin();
|
||||||
|
|
||||||
vtkm::Vec3f spacing = uniformCoords.ReadPortal().GetSpacing();
|
vtkm::Vec3f spacing = coordsPortal.GetSpacing();
|
||||||
vtkm::Vec3f unitLength;
|
vtkm::Vec3f unitLength;
|
||||||
unitLength[0] = static_cast<vtkm::FloatDefault>(this->PointDims[0] - 1);
|
unitLength[0] = static_cast<vtkm::FloatDefault>(this->PointDims[0] - 1);
|
||||||
unitLength[1] = static_cast<vtkm::FloatDefault>(this->PointDims[1] - 1);
|
unitLength[1] = static_cast<vtkm::FloatDefault>(this->PointDims[1] - 1);
|
||||||
|
@ -186,6 +186,9 @@ public:
|
|||||||
VTKM_CONT vtkm::IdComponent GetNumberOfPointsInCell(vtkm::Id cellid) const override;
|
VTKM_CONT vtkm::IdComponent GetNumberOfPointsInCell(vtkm::Id cellid) const override;
|
||||||
VTKM_CONT void GetCellPointIds(vtkm::Id id, vtkm::Id* ptids) const override;
|
VTKM_CONT void GetCellPointIds(vtkm::Id id, vtkm::Id* ptids) const override;
|
||||||
|
|
||||||
|
VTKM_CONT typename vtkm::cont::ArrayHandle<vtkm::UInt8, ShapesStorageTag>::ReadPortalType
|
||||||
|
ShapesReadPortal() const;
|
||||||
|
|
||||||
VTKM_CONT vtkm::UInt8 GetCellShape(vtkm::Id cellid) const override;
|
VTKM_CONT vtkm::UInt8 GetCellShape(vtkm::Id cellid) const override;
|
||||||
|
|
||||||
template <vtkm::IdComponent NumIndices>
|
template <vtkm::IdComponent NumIndices>
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
//============================================================================
|
//============================================================================
|
||||||
#ifndef vtk_m_cont_CellSetExplicit_hxx
|
#ifndef vtk_m_cont_CellSetExplicit_hxx
|
||||||
#define vtk_m_cont_CellSetExplicit_hxx
|
#define vtk_m_cont_CellSetExplicit_hxx
|
||||||
|
#include <vtkm/Deprecated.h>
|
||||||
#include <vtkm/cont/CellSetExplicit.h>
|
#include <vtkm/cont/CellSetExplicit.h>
|
||||||
|
|
||||||
#include <vtkm/cont/ArrayCopy.h>
|
#include <vtkm/cont/ArrayCopy.h>
|
||||||
@ -176,14 +176,22 @@ vtkm::IdComponent CellSetExplicit<SST, CST, OST>
|
|||||||
|
|
||||||
template <typename SST, typename CST, typename OST>
|
template <typename SST, typename CST, typename OST>
|
||||||
VTKM_CONT
|
VTKM_CONT
|
||||||
|
typename vtkm::cont::ArrayHandle<vtkm::UInt8, SST>::ReadPortalType
|
||||||
|
CellSetExplicit<SST, CST, OST>::ShapesReadPortal() const
|
||||||
|
{
|
||||||
|
return this->Data->CellPointIds.Shapes.ReadPortal();
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename SST, typename CST, typename OST>
|
||||||
|
VTKM_CONT
|
||||||
|
VTKM_DEPRECATED(1.6, "Calling GetCellShape(cellid) is a performance bug. Call ShapesReadPortal() and loop over the .Get.")
|
||||||
vtkm::UInt8 CellSetExplicit<SST, CST, OST>
|
vtkm::UInt8 CellSetExplicit<SST, CST, OST>
|
||||||
::GetCellShape(vtkm::Id cellid) const
|
::GetCellShape(vtkm::Id cellid) const
|
||||||
{
|
{
|
||||||
// Looping over GetCellShape(cellid) is a performance bug.
|
return this->ShapesReadPortal().Get(cellid);
|
||||||
// Don't know quite what to do about it right now.
|
|
||||||
return this->Data->CellPointIds.Shapes.ReadPortal().Get(cellid);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template <typename SST, typename CST, typename OST>
|
template <typename SST, typename CST, typename OST>
|
||||||
template <vtkm::IdComponent NumVecIndices>
|
template <vtkm::IdComponent NumVecIndices>
|
||||||
VTKM_CONT
|
VTKM_CONT
|
||||||
|
@ -204,11 +204,14 @@ void TestCellLocator(const vtkm::Vec<vtkm::Id, DIMENSIONS>& dim, vtkm::Id number
|
|||||||
vtkm::worklet::DispatcherMapField<FindCellWorklet> dispatcher;
|
vtkm::worklet::DispatcherMapField<FindCellWorklet> dispatcher;
|
||||||
dispatcher.Invoke(points, locator, cellIds, pcoords);
|
dispatcher.Invoke(points, locator, cellIds, pcoords);
|
||||||
|
|
||||||
|
auto cellIdsPortal = cellIds.ReadPortal();
|
||||||
|
auto expCellIdsPortal = expCellIds.ReadPortal();
|
||||||
|
auto pcoordsPortal = pcoords.ReadPortal();
|
||||||
|
auto expPCoordsPortal = expPCoords.ReadPortal();
|
||||||
for (vtkm::Id i = 0; i < numberOfPoints; ++i)
|
for (vtkm::Id i = 0; i < numberOfPoints; ++i)
|
||||||
{
|
{
|
||||||
VTKM_TEST_ASSERT(cellIds.ReadPortal().Get(i) == expCellIds.ReadPortal().Get(i),
|
VTKM_TEST_ASSERT(cellIdsPortal.Get(i) == expCellIdsPortal.Get(i), "Incorrect cell ids");
|
||||||
"Incorrect cell ids");
|
VTKM_TEST_ASSERT(test_equal(pcoordsPortal.Get(i), expPCoordsPortal.Get(i), 1e-3),
|
||||||
VTKM_TEST_ASSERT(test_equal(pcoords.ReadPortal().Get(i), expPCoords.ReadPortal().Get(i), 1e-3),
|
|
||||||
"Incorrect parameteric coordinates");
|
"Incorrect parameteric coordinates");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,9 +42,10 @@ private:
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto ahPortal = ah.ReadPortal();
|
||||||
for (vtkm::Id i = 0; i < size; ++i)
|
for (vtkm::Id i = 0; i < size; ++i)
|
||||||
{
|
{
|
||||||
if (ah.ReadPortal().Get(i) != expected[i])
|
if (ahPortal.Get(i) != expected[i])
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -115,6 +116,7 @@ private:
|
|||||||
VTKM_TEST_ASSERT(conn.GetNumberOfValues() == connectivitySize,
|
VTKM_TEST_ASSERT(conn.GetNumberOfValues() == connectivitySize,
|
||||||
"Connectivity array wrong size.");
|
"Connectivity array wrong size.");
|
||||||
vtkm::Id connectivityIndex = 0;
|
vtkm::Id connectivityIndex = 0;
|
||||||
|
auto connPortal = conn.ReadPortal();
|
||||||
for (vtkm::Id pointIndex = 0; pointIndex < numPoints; pointIndex++)
|
for (vtkm::Id pointIndex = 0; pointIndex < numPoints; pointIndex++)
|
||||||
{
|
{
|
||||||
vtkm::IdComponent numIncidentCells = correctNumIndices[pointIndex];
|
vtkm::IdComponent numIncidentCells = correctNumIndices[pointIndex];
|
||||||
@ -125,7 +127,7 @@ private:
|
|||||||
}
|
}
|
||||||
for (vtkm::IdComponent cellIndex = 0; cellIndex < numIncidentCells; cellIndex++)
|
for (vtkm::IdComponent cellIndex = 0; cellIndex < numIncidentCells; cellIndex++)
|
||||||
{
|
{
|
||||||
vtkm::Id expectedCell = conn.ReadPortal().Get(connectivityIndex + cellIndex);
|
vtkm::Id expectedCell = connPortal.Get(connectivityIndex + cellIndex);
|
||||||
std::set<vtkm::Id>::iterator foundCell = correctIncidentCells.find(expectedCell);
|
std::set<vtkm::Id>::iterator foundCell = correctIncidentCells.find(expectedCell);
|
||||||
VTKM_TEST_ASSERT(foundCell != correctIncidentCells.end(),
|
VTKM_TEST_ASSERT(foundCell != correctIncidentCells.end(),
|
||||||
"An incident cell in the connectivity list is wrong or repeated.");
|
"An incident cell in the connectivity list is wrong or repeated.");
|
||||||
|
@ -36,9 +36,10 @@ void TestArrayHandleConcatenate()
|
|||||||
array5 = vtkm::cont::make_ArrayHandleConcatenate(array3, array4);
|
array5 = vtkm::cont::make_ArrayHandleConcatenate(array3, array4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto array5Portal = array5.ReadPortal();
|
||||||
for (vtkm::Id index = 0; index < array5.GetNumberOfValues(); index++)
|
for (vtkm::Id index = 0; index < array5.GetNumberOfValues(); index++)
|
||||||
{
|
{
|
||||||
std::cout << array5.ReadPortal().Get(index) << std::endl;
|
std::cout << array5Portal.Get(index) << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,8 +60,9 @@ void TestConcatenateEmptyArray()
|
|||||||
ArrayConcat arrConc(arr2, arr1);
|
ArrayConcat arrConc(arr2, arr1);
|
||||||
ArrayConcat2 arrConc2(arrConc, arr3);
|
ArrayConcat2 arrConc2(arrConc, arr3);
|
||||||
|
|
||||||
|
auto arrConc2Portal = arrConc2.ReadPortal();
|
||||||
for (vtkm::Id i = 0; i < arrConc2.GetNumberOfValues(); i++)
|
for (vtkm::Id i = 0; i < arrConc2.GetNumberOfValues(); i++)
|
||||||
std::cout << arrConc2.ReadPortal().Get(i) << std::endl;
|
std::cout << arrConc2Portal.Get(i) << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace UnitTestArrayHandleIndexNamespace
|
} // namespace UnitTestArrayHandleIndexNamespace
|
||||||
|
@ -102,14 +102,17 @@ struct TemplatedTests
|
|||||||
"Counting array using raw array handle + tag has wrong size.");
|
"Counting array using raw array handle + tag has wrong size.");
|
||||||
|
|
||||||
ValueType properValue = startingValue;
|
ValueType properValue = startingValue;
|
||||||
|
auto arrayConstPortal = arrayConst.ReadPortal();
|
||||||
|
auto arrayMakePortal = arrayMake.ReadPortal();
|
||||||
|
auto arrayHandlePortal = arrayHandle.ReadPortal();
|
||||||
for (vtkm::Id index = 0; index < ARRAY_SIZE; index++)
|
for (vtkm::Id index = 0; index < ARRAY_SIZE; index++)
|
||||||
{
|
{
|
||||||
VTKM_TEST_ASSERT(arrayConst.ReadPortal().Get(index) == properValue,
|
VTKM_TEST_ASSERT(arrayConstPortal.Get(index) == properValue,
|
||||||
"Counting array using constructor has unexpected value.");
|
"Counting array using constructor has unexpected value.");
|
||||||
VTKM_TEST_ASSERT(arrayMake.ReadPortal().Get(index) == properValue,
|
VTKM_TEST_ASSERT(arrayMakePortal.Get(index) == properValue,
|
||||||
"Counting array using make has unexpected value.");
|
"Counting array using make has unexpected value.");
|
||||||
|
|
||||||
VTKM_TEST_ASSERT(arrayHandle.ReadPortal().Get(index) == properValue,
|
VTKM_TEST_ASSERT(arrayHandlePortal.Get(index) == properValue,
|
||||||
"Counting array using raw array handle + tag has unexpected value.");
|
"Counting array using raw array handle + tag has unexpected value.");
|
||||||
properValue = properValue + step;
|
properValue = properValue + step;
|
||||||
}
|
}
|
||||||
@ -128,6 +131,7 @@ void TestArrayHandleCounting()
|
|||||||
TemplatedTests<StringInt>()(StringInt(10), StringInt(2));
|
TemplatedTests<StringInt>()(StringInt(10), StringInt(2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace UnitTestArrayHandleCountingNamespace
|
} // namespace UnitTestArrayHandleCountingNamespace
|
||||||
|
|
||||||
int UnitTestArrayHandleCounting(int argc, char* argv[])
|
int UnitTestArrayHandleCounting(int argc, char* argv[])
|
||||||
|
@ -42,12 +42,13 @@ struct ImplicitTests
|
|||||||
|
|
||||||
using ImplicitHandle = vtkm::cont::ArrayHandleImplicit<FunctorType>;
|
using ImplicitHandle = vtkm::cont::ArrayHandleImplicit<FunctorType>;
|
||||||
|
|
||||||
ImplicitHandle implict = vtkm::cont::make_ArrayHandleImplicit(functor, ARRAY_SIZE);
|
ImplicitHandle implicit = vtkm::cont::make_ArrayHandleImplicit(functor, ARRAY_SIZE);
|
||||||
|
|
||||||
//verify that the control portal works
|
//verify that the control portal works
|
||||||
|
auto implicitPortal = implicit.ReadPortal();
|
||||||
for (int i = 0; i < ARRAY_SIZE; ++i)
|
for (int i = 0; i < ARRAY_SIZE; ++i)
|
||||||
{
|
{
|
||||||
const ValueType v = implict.ReadPortal().Get(i);
|
const ValueType v = implicitPortal.Get(i);
|
||||||
const ValueType correct_value = functor(i);
|
const ValueType correct_value = functor(i);
|
||||||
VTKM_TEST_ASSERT(v == correct_value, "Implicit Handle Failed");
|
VTKM_TEST_ASSERT(v == correct_value, "Implicit Handle Failed");
|
||||||
}
|
}
|
||||||
@ -56,7 +57,7 @@ struct ImplicitTests
|
|||||||
vtkm::cont::Token token;
|
vtkm::cont::Token token;
|
||||||
using Device = vtkm::cont::DeviceAdapterTagSerial;
|
using Device = vtkm::cont::DeviceAdapterTagSerial;
|
||||||
using CEPortal = typename ImplicitHandle::template ExecutionTypes<Device>::PortalConst;
|
using CEPortal = typename ImplicitHandle::template ExecutionTypes<Device>::PortalConst;
|
||||||
CEPortal execPortal = implict.PrepareForInput(Device(), token);
|
CEPortal execPortal = implicit.PrepareForInput(Device(), token);
|
||||||
for (int i = 0; i < ARRAY_SIZE; ++i)
|
for (int i = 0; i < ARRAY_SIZE; ++i)
|
||||||
{
|
{
|
||||||
const ValueType v = execPortal.Get(i);
|
const ValueType v = execPortal.Get(i);
|
||||||
|
@ -188,11 +188,14 @@ void TestWithDataSet(vtkm::cont::CellLocatorGeneral& locator, const vtkm::cont::
|
|||||||
// CellLocatorGeneral is non-copyable. Pass it via a pointer.
|
// CellLocatorGeneral is non-copyable. Pass it via a pointer.
|
||||||
dispatcher.Invoke(points, &locator, cellIds, pcoords);
|
dispatcher.Invoke(points, &locator, cellIds, pcoords);
|
||||||
|
|
||||||
|
auto cellIdPortal = cellIds.ReadPortal();
|
||||||
|
auto expCellIdsPortal = expCellIds.ReadPortal();
|
||||||
|
auto pcoordsPortal = pcoords.ReadPortal();
|
||||||
|
auto expPCoordsPortal = expPCoords.ReadPortal();
|
||||||
for (vtkm::Id i = 0; i < 128; ++i)
|
for (vtkm::Id i = 0; i < 128; ++i)
|
||||||
{
|
{
|
||||||
VTKM_TEST_ASSERT(cellIds.ReadPortal().Get(i) == expCellIds.ReadPortal().Get(i),
|
VTKM_TEST_ASSERT(cellIdPortal.Get(i) == expCellIdsPortal.Get(i), "Incorrect cell ids");
|
||||||
"Incorrect cell ids");
|
VTKM_TEST_ASSERT(test_equal(pcoordsPortal.Get(i), expPCoordsPortal.Get(i), 1e-3),
|
||||||
VTKM_TEST_ASSERT(test_equal(pcoords.ReadPortal().Get(i), expPCoords.ReadPortal().Get(i), 1e-3),
|
|
||||||
"Incorrect parameteric coordinates");
|
"Incorrect parameteric coordinates");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,13 +117,13 @@ void TestAgainstBaseLine(const vtkm::cont::CellSet& cellset,
|
|||||||
: PermutationArray.GetNumberOfValues();
|
: PermutationArray.GetNumberOfValues();
|
||||||
VTKM_TEST_ASSERT(numCells == expectedNumCell, "Wrong number of cells");
|
VTKM_TEST_ASSERT(numCells == expectedNumCell, "Wrong number of cells");
|
||||||
|
|
||||||
|
auto permutationPortal = PermutationArray.ReadPortal();
|
||||||
for (vtkm::Id i = 0; i < numCells; ++i)
|
for (vtkm::Id i = 0; i < numCells; ++i)
|
||||||
{
|
{
|
||||||
VTKM_TEST_ASSERT(cellset.GetCellShape(i) == vtkm::CELL_SHAPE_HEXAHEDRON, "Wrong shape");
|
VTKM_TEST_ASSERT(cellset.GetCellShape(i) == vtkm::CELL_SHAPE_HEXAHEDRON, "Wrong shape");
|
||||||
VTKM_TEST_ASSERT(cellset.GetNumberOfPointsInCell(i) == 8, "Wrong number of points-of-cell");
|
VTKM_TEST_ASSERT(cellset.GetNumberOfPointsInCell(i) == 8, "Wrong number of points-of-cell");
|
||||||
|
|
||||||
vtkm::Id baseLineCellId =
|
vtkm::Id baseLineCellId = (flag == IsPermutationCellSet::YES) ? permutationPortal.Get(i) : i;
|
||||||
(flag == IsPermutationCellSet::YES) ? PermutationArray.ReadPortal().Get(i) : i;
|
|
||||||
auto baseLinePointIds = baseLineStructure.GetPointsOfCell(baseLineCellId);
|
auto baseLinePointIds = baseLineStructure.GetPointsOfCell(baseLineCellId);
|
||||||
|
|
||||||
vtkm::Id pointIds[8];
|
vtkm::Id pointIds[8];
|
||||||
|
@ -32,9 +32,10 @@ bool TestArrayHandle(const vtkm::cont::ArrayHandle<T, Storage>& ah,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto ahPortal = ah.ReadPortal();
|
||||||
for (vtkm::Id i = 0; i < size; ++i)
|
for (vtkm::Id i = 0; i < size; ++i)
|
||||||
{
|
{
|
||||||
if (ah.ReadPortal().Get(i) != expected[i])
|
if (ahPortal.Get(i) != expected[i])
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -110,9 +111,10 @@ void TestDataSet_Explicit()
|
|||||||
|
|
||||||
//iterate same cell 4 times
|
//iterate same cell 4 times
|
||||||
vtkm::Float32 expected[4] = { 30.1667f, 30.1667f, 30.1667f, 30.1667f };
|
vtkm::Float32 expected[4] = { 30.1667f, 30.1667f, 30.1667f, 30.1667f };
|
||||||
|
auto resultPortal = result.ReadPortal();
|
||||||
for (int i = 0; i < 4; ++i)
|
for (int i = 0; i < 4; ++i)
|
||||||
{
|
{
|
||||||
VTKM_TEST_ASSERT(test_equal(result.ReadPortal().Get(i), expected[i]),
|
VTKM_TEST_ASSERT(test_equal(resultPortal.Get(i), expected[i]),
|
||||||
"Wrong result for CellAverage worklet on explicit subset data");
|
"Wrong result for CellAverage worklet on explicit subset data");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -145,9 +147,10 @@ void TestDataSet_Structured2D()
|
|||||||
dispatcher.Invoke(subset, dataSet.GetField("pointvar"), result);
|
dispatcher.Invoke(subset, dataSet.GetField("pointvar"), result);
|
||||||
|
|
||||||
vtkm::Float32 expected[4] = { 40.1f, 40.1f, 40.1f, 40.1f };
|
vtkm::Float32 expected[4] = { 40.1f, 40.1f, 40.1f, 40.1f };
|
||||||
|
auto resultPortal = result.ReadPortal();
|
||||||
for (int i = 0; i < 4; ++i)
|
for (int i = 0; i < 4; ++i)
|
||||||
{
|
{
|
||||||
VTKM_TEST_ASSERT(test_equal(result.ReadPortal().Get(i), expected[i]),
|
VTKM_TEST_ASSERT(test_equal(resultPortal.Get(i), expected[i]),
|
||||||
"Wrong result for CellAverage worklet on 2d structured subset data");
|
"Wrong result for CellAverage worklet on 2d structured subset data");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -180,9 +183,10 @@ void TestDataSet_Structured3D()
|
|||||||
dispatcher.Invoke(subset, dataSet.GetField("pointvar"), result);
|
dispatcher.Invoke(subset, dataSet.GetField("pointvar"), result);
|
||||||
|
|
||||||
vtkm::Float32 expected[4] = { 70.2125f, 70.2125f, 70.2125f, 70.2125f };
|
vtkm::Float32 expected[4] = { 70.2125f, 70.2125f, 70.2125f, 70.2125f };
|
||||||
|
auto resultPortal = result.ReadPortal();
|
||||||
for (int i = 0; i < 4; ++i)
|
for (int i = 0; i < 4; ++i)
|
||||||
{
|
{
|
||||||
VTKM_TEST_ASSERT(test_equal(result.ReadPortal().Get(i), expected[i]),
|
VTKM_TEST_ASSERT(test_equal(resultPortal.Get(i), expected[i]),
|
||||||
"Wrong result for CellAverage worklet on 2d structured subset data");
|
"Wrong result for CellAverage worklet on 2d structured subset data");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -97,11 +97,12 @@ void TestNormals(const vtkm::cont::DataSet& dataset, bool structured)
|
|||||||
result.GetField("normals").GetData().CopyTo(normals);
|
result.GetField("normals").GetData().CopyTo(normals);
|
||||||
VTKM_TEST_ASSERT(normals.GetNumberOfValues() == numVerts,
|
VTKM_TEST_ASSERT(normals.GetNumberOfValues() == numVerts,
|
||||||
"Wrong number of values in normals field");
|
"Wrong number of values in normals field");
|
||||||
|
auto normalsPortal = normals.ReadPortal();
|
||||||
for (vtkm::Id i = 0; i < numVerts; ++i)
|
for (vtkm::Id i = 0; i < numVerts; ++i)
|
||||||
{
|
{
|
||||||
VTKM_TEST_ASSERT(test_equal(normals.ReadPortal().Get(i), expected[i], 0.001),
|
VTKM_TEST_ASSERT(test_equal(normalsPortal.Get(i), expected[i], 0.001),
|
||||||
"Result (",
|
"Result (",
|
||||||
normals.ReadPortal().Get(i),
|
normalsPortal.Get(i),
|
||||||
") does not match expected value (",
|
") does not match expected value (",
|
||||||
expected[i],
|
expected[i],
|
||||||
") vert ",
|
") vert ",
|
||||||
@ -124,9 +125,10 @@ void TestNormals(const vtkm::cont::DataSet& dataset, bool structured)
|
|||||||
result.GetField("normals").GetData().CopyTo(normals);
|
result.GetField("normals").GetData().CopyTo(normals);
|
||||||
VTKM_TEST_ASSERT(normals.GetNumberOfValues() == numVerts,
|
VTKM_TEST_ASSERT(normals.GetNumberOfValues() == numVerts,
|
||||||
"Wrong number of values in normals field");
|
"Wrong number of values in normals field");
|
||||||
|
normalsPortal = normals.ReadPortal();
|
||||||
for (vtkm::Id i = 0; i < numVerts; ++i)
|
for (vtkm::Id i = 0; i < numVerts; ++i)
|
||||||
{
|
{
|
||||||
VTKM_TEST_ASSERT(test_equal(normals.ReadPortal().Get(i), expected[i], 0.001),
|
VTKM_TEST_ASSERT(test_equal(normalsPortal.Get(i), expected[i], 0.001),
|
||||||
"Result does not match expected values");
|
"Result does not match expected values");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -73,9 +73,10 @@ void TestVertexClustering()
|
|||||||
auto pointArray = output.GetCoordinateSystem(0).GetData();
|
auto pointArray = output.GetCoordinateSystem(0).GetData();
|
||||||
VTKM_TEST_ASSERT(pointArray.GetNumberOfValues() == output_points,
|
VTKM_TEST_ASSERT(pointArray.GetNumberOfValues() == output_points,
|
||||||
"Number of output points mismatch");
|
"Number of output points mismatch");
|
||||||
|
auto pointArrayPortal = pointArray.ReadPortal();
|
||||||
for (vtkm::Id i = 0; i < pointArray.GetNumberOfValues(); ++i)
|
for (vtkm::Id i = 0; i < pointArray.GetNumberOfValues(); ++i)
|
||||||
{
|
{
|
||||||
const PointType& p1 = pointArray.ReadPortal().Get(i);
|
const PointType& p1 = pointArrayPortal.Get(i);
|
||||||
PointType p2 = vtkm::make_Vec(output_point[i][0], output_point[i][1], output_point[i][2]);
|
PointType p2 = vtkm::make_Vec(output_point[i][0], output_point[i][1], output_point[i][2]);
|
||||||
VTKM_TEST_ASSERT(test_equal(p1, p2), "Point Array mismatch");
|
VTKM_TEST_ASSERT(test_equal(p1, p2), "Point Array mismatch");
|
||||||
}
|
}
|
||||||
|
@ -88,8 +88,6 @@
|
|||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
//#define DEBUG_PRINT 1
|
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -103,9 +101,10 @@ void DebugPrint(const char* msg, vtkm::cont::ArrayHandle<U>& array)
|
|||||||
{
|
{
|
||||||
vtkm::Id count = 20;
|
vtkm::Id count = 20;
|
||||||
count = std::min(count, array.GetNumberOfValues());
|
count = std::min(count, array.GetNumberOfValues());
|
||||||
|
auto portal = array.ReadPortal();
|
||||||
std::cout << std::setw(15) << msg << ": ";
|
std::cout << std::setw(15) << msg << ": ";
|
||||||
for (vtkm::Id i = 0; i < count; i++)
|
for (vtkm::Id i = 0; i < count; i++)
|
||||||
std::cout << std::setprecision(3) << std::setw(5) << array.ReadPortal().Get(i) << " ";
|
std::cout << std::setprecision(3) << std::setw(5) << portal.Get(i) << " ";
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,9 +113,10 @@ void DebugPrint(const char* msg, vtkm::cont::ArrayHandleReverse<vtkm::cont::Arra
|
|||||||
{
|
{
|
||||||
vtkm::Id count = 20;
|
vtkm::Id count = 20;
|
||||||
count = std::min(count, array.GetNumberOfValues());
|
count = std::min(count, array.GetNumberOfValues());
|
||||||
|
auto portal = array.ReadPortal();
|
||||||
std::cout << std::setw(15) << msg << ": ";
|
std::cout << std::setw(15) << msg << ": ";
|
||||||
for (vtkm::Id i = 0; i < count; i++)
|
for (vtkm::Id i = 0; i < count; i++)
|
||||||
std::cout << std::setw(5) << array.ReadPortal().Get(i) << " ";
|
std::cout << std::setw(5) << portal.Get(i) << " ";
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -191,16 +191,18 @@ void TestCellGradientUniform3DWithVectorField2()
|
|||||||
{ { 10.025, 10.025, 10.025 }, { 30.075, 30.075, 30.075 }, { 60.175, 60.175, 60.175 } }
|
{ { 10.025, 10.025, 10.025 }, { 30.075, 30.075, 30.075 }, { 60.175, 60.175, 60.175 } }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
auto vorticityPortal = extraOutput.Vorticity.ReadPortal();
|
||||||
|
auto divergencePortal = extraOutput.Divergence.ReadPortal();
|
||||||
for (int i = 0; i < 4; ++i)
|
for (int i = 0; i < 4; ++i)
|
||||||
{
|
{
|
||||||
vtkm::Vec<vtkm::Vec3f_64, 3> eg = expected_gradients[i];
|
vtkm::Vec<vtkm::Vec3f_64, 3> eg = expected_gradients[i];
|
||||||
|
|
||||||
vtkm::Float64 d = extraOutput.Divergence.ReadPortal().Get(i);
|
vtkm::Float64 d = divergencePortal.Get(i);
|
||||||
VTKM_TEST_ASSERT(test_equal((eg[0][0] + eg[1][1] + eg[2][2]), d),
|
VTKM_TEST_ASSERT(test_equal((eg[0][0] + eg[1][1] + eg[2][2]), d),
|
||||||
"Wrong result for Divergence on 3D uniform data");
|
"Wrong result for Divergence on 3D uniform data");
|
||||||
|
|
||||||
vtkm::Vec3f_64 ev(eg[1][2] - eg[2][1], eg[2][0] - eg[0][2], eg[0][1] - eg[1][0]);
|
vtkm::Vec3f_64 ev(eg[1][2] - eg[2][1], eg[2][0] - eg[0][2], eg[0][1] - eg[1][0]);
|
||||||
vtkm::Vec3f_64 v = extraOutput.Vorticity.ReadPortal().Get(i);
|
vtkm::Vec3f_64 v = vorticityPortal.Get(i);
|
||||||
VTKM_TEST_ASSERT(test_equal(ev, v), "Wrong result for Vorticity on 3D uniform data");
|
VTKM_TEST_ASSERT(test_equal(ev, v), "Wrong result for Vorticity on 3D uniform data");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -220,9 +222,10 @@ void TestCellGradientExplicit()
|
|||||||
result = gradient.Run(dataSet.GetCellSet(), dataSet.GetCoordinateSystem(), input);
|
result = gradient.Run(dataSet.GetCellSet(), dataSet.GetCoordinateSystem(), input);
|
||||||
|
|
||||||
vtkm::Vec3f_32 expected[2] = { { 10.f, 10.1f, 0.0f }, { 10.f, 10.1f, -0.0f } };
|
vtkm::Vec3f_32 expected[2] = { { 10.f, 10.1f, 0.0f }, { 10.f, 10.1f, -0.0f } };
|
||||||
|
auto resultPortal = result.ReadPortal();
|
||||||
for (int i = 0; i < 2; ++i)
|
for (int i = 0; i < 2; ++i)
|
||||||
{
|
{
|
||||||
VTKM_TEST_ASSERT(test_equal(result.ReadPortal().Get(i), expected[i]),
|
VTKM_TEST_ASSERT(test_equal(resultPortal.Get(i), expected[i]),
|
||||||
"Wrong result for CellGradient worklet on 3D explicit data");
|
"Wrong result for CellGradient worklet on 3D explicit data");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,9 +36,11 @@ bool TestArrayHandle(const vtkm::cont::ArrayHandle<T, Storage>& ah,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto ahPortal = ah.ReadPortal();
|
||||||
|
auto expectedPortal = expected.ReadPortal();
|
||||||
for (vtkm::Id i = 0; i < size; ++i)
|
for (vtkm::Id i = 0; i < size; ++i)
|
||||||
{
|
{
|
||||||
if (ah.ReadPortal().Get(i) != expected.ReadPortal().Get(i))
|
if (ahPortal.Get(i) != expectedPortal.Get(i))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user