Commit 9fd821ed authored by Dave Pugmire's avatar Dave Pugmire

Template on DeviceAdapter.

parent 961f6a58
......@@ -84,9 +84,10 @@ public:
VTKM_CONT void SetCartesianToCylindrical() { cartesianToCylindrical = true; }
VTKM_CONT void SetCylindricalToCartesian() { cartesianToCylindrical = false; }
template <typename CoordsStorageType>
template <typename CoordsStorageType, typename DeviceAdapterTag>
void Run(const vtkm::cont::ArrayHandle<vtkm::Vec<T, 3>, CoordsStorageType>& inPoints,
vtkm::cont::ArrayHandle<vtkm::Vec<T, 3>, CoordsStorageType>& outPoints)
vtkm::cont::ArrayHandle<vtkm::Vec<T, 3>, CoordsStorageType>& outPoints,
DeviceAdapterTag) const
{
if (cartesianToCylindrical)
{
......@@ -100,9 +101,10 @@ public:
}
}
template <typename CoordsStorageType>
template <typename CoordsStorageType, typename DeviceAdapterTag>
void Run(const vtkm::cont::CoordinateSystem& inPoints,
vtkm::cont::ArrayHandle<vtkm::Vec<T, 3>, CoordsStorageType>& outPoints)
vtkm::cont::ArrayHandle<vtkm::Vec<T, 3>, CoordsStorageType>& outPoints,
DeviceAdapterTag) const
{
if (cartesianToCylindrical)
{
......@@ -183,34 +185,36 @@ public:
VTKM_CONT void SetCartesianToSpherical() { CartesianToSpherical = true; }
VTKM_CONT void SetSphericalToCartesian() { CartesianToSpherical = false; }
template <typename CoordsStorageType>
template <typename CoordsStorageType, typename DeviceAdapterTag>
void Run(const vtkm::cont::ArrayHandle<vtkm::Vec<T, 3>, CoordsStorageType>& inPoints,
vtkm::cont::ArrayHandle<vtkm::Vec<T, 3>, CoordsStorageType>& outPoints)
vtkm::cont::ArrayHandle<vtkm::Vec<T, 3>, CoordsStorageType>& outPoints,
DeviceAdapterTag) const
{
if (CartesianToSpherical)
{
vtkm::worklet::DispatcherMapField<CarToSphere> dispatcher;
vtkm::worklet::DispatcherMapField<CarToSphere, DeviceAdapterTag> dispatcher;
dispatcher.Invoke(inPoints, outPoints);
}
else
{
vtkm::worklet::DispatcherMapField<SphereToCar> dispatcher;
vtkm::worklet::DispatcherMapField<SphereToCar, DeviceAdapterTag> dispatcher;
dispatcher.Invoke(inPoints, outPoints);
}
}
template <typename CoordsStorageType>
template <typename CoordsStorageType, typename DeviceAdapterTag>
void Run(const vtkm::cont::CoordinateSystem& inPoints,
vtkm::cont::ArrayHandle<vtkm::Vec<T, 3>, CoordsStorageType>& outPoints)
vtkm::cont::ArrayHandle<vtkm::Vec<T, 3>, CoordsStorageType>& outPoints,
DeviceAdapterTag) const
{
if (CartesianToSpherical)
{
vtkm::worklet::DispatcherMapField<CarToSphere> dispatcher;
vtkm::worklet::DispatcherMapField<CarToSphere, DeviceAdapterTag> dispatcher;
dispatcher.Invoke(inPoints, outPoints);
}
else
{
vtkm::worklet::DispatcherMapField<SphereToCar> dispatcher;
vtkm::worklet::DispatcherMapField<SphereToCar, DeviceAdapterTag> dispatcher;
dispatcher.Invoke(inPoints, outPoints);
}
}
......
......@@ -149,6 +149,8 @@ void TestCoordinateSystemTransform()
{
std::cout << "Testing CylindricalCoordinateTransform Worklet" << std::endl;
using DeviceAdapter = VTKM_DEFAULT_DEVICE_ADAPTER_TAG;
//Test cartesian to cyl
vtkm::cont::DataSet dsCart = MakeTestDataSet(CART);
vtkm::worklet::CylindricalCoordinateTransform<vtkm::FloatDefault> cylTrn;
......@@ -157,10 +159,10 @@ void TestCoordinateSystemTransform()
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::FloatDefault, 3>> revResult;
cylTrn.SetCartesianToCylindrical();
cylTrn.Run(dsCart.GetCoordinateSystem(), carToCylPts);
cylTrn.Run(dsCart.GetCoordinateSystem(), carToCylPts, DeviceAdapter());
cylTrn.SetCylindricalToCartesian();
cylTrn.Run(carToCylPts, revResult);
cylTrn.Run(carToCylPts, revResult, DeviceAdapter());
ValidateCoordTransform(
dsCart.GetCoordinateSystem(), carToCylPts, revResult, { false, false, false });
......@@ -168,10 +170,10 @@ void TestCoordinateSystemTransform()
vtkm::cont::DataSet dsCyl = MakeTestDataSet(CYL);
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::FloatDefault, 3>> cylToCarPts;
cylTrn.SetCylindricalToCartesian();
cylTrn.Run(dsCyl.GetCoordinateSystem(), cylToCarPts);
cylTrn.Run(dsCyl.GetCoordinateSystem(), cylToCarPts, DeviceAdapter());
cylTrn.SetCartesianToCylindrical();
cylTrn.Run(cylToCarPts, revResult);
cylTrn.Run(cylToCarPts, revResult, DeviceAdapter());
ValidateCoordTransform(
dsCyl.GetCoordinateSystem(), cylToCarPts, revResult, { false, true, false });
......@@ -181,10 +183,10 @@ void TestCoordinateSystemTransform()
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::FloatDefault, 3>> carToSphPts;
sphTrn.SetCartesianToSpherical();
sphTrn.Run(dsCart.GetCoordinateSystem(), carToSphPts);
sphTrn.Run(dsCart.GetCoordinateSystem(), carToSphPts, DeviceAdapter());
sphTrn.SetSphericalToCartesian();
sphTrn.Run(carToSphPts, revResult);
sphTrn.Run(carToSphPts, revResult, DeviceAdapter());
ValidateCoordTransform(
dsCart.GetCoordinateSystem(), carToSphPts, revResult, { false, true, true });
......@@ -193,17 +195,17 @@ void TestCoordinateSystemTransform()
vtkm::cont::DataSet dsSph = MakeTestDataSet(SPH);
sphTrn.SetSphericalToCartesian();
sphTrn.Run(dsSph.GetCoordinateSystem(), sphToCarPts);
sphTrn.Run(dsSph.GetCoordinateSystem(), sphToCarPts, DeviceAdapter());
sphTrn.SetCartesianToSpherical();
sphTrn.Run(sphToCarPts, revResult);
sphTrn.Run(sphToCarPts, revResult, DeviceAdapter());
ValidateCoordTransform(
dsSph.GetCoordinateSystem(), sphToCarPts, revResult, { false, true, true });
sphTrn.SetSphericalToCartesian();
sphTrn.Run(dsSph.GetCoordinateSystem(), sphToCarPts);
sphTrn.Run(dsSph.GetCoordinateSystem(), sphToCarPts, DeviceAdapter());
sphTrn.SetCartesianToSpherical();
sphTrn.Run(sphToCarPts, revResult);
sphTrn.Run(sphToCarPts, revResult, DeviceAdapter());
ValidateCoordTransform(
dsSph.GetCoordinateSystem(), sphToCarPts, revResult, { false, true, true });
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment