removing ArrayHandleExtrude*

This commit is contained in:
Caitlin Ross 2020-12-08 14:38:33 -05:00
parent a9711bffb7
commit 46155daaa2
13 changed files with 46 additions and 944 deletions

@ -1,151 +0,0 @@
//============================================================================
// Copyright (c) Kitware, Inc.
// All rights reserved.
// See LICENSE.txt for details.
//
// This software is distributed WITHOUT ANY WARRANTY; without even
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE. See the above copyright notice for more information.
//============================================================================
#ifndef vtk_m_cont_ArrayHandleExtrudeCoords_h
#define vtk_m_cont_ArrayHandleExtrudeCoords_h
#include <vtkm/cont/StorageExtrude.h>
#include <vtkm/cont/ArrayHandle.h>
#include <vtkm/cont/internal/ArrayHandleDeprecated.h>
namespace vtkm
{
namespace cont
{
template <typename T>
VTKM_ARRAY_HANDLE_DEPRECATED(VTKM_PASS_COMMAS(vtkm::Vec<T, 3>),
vtkm::cont::internal::StorageTagExtrude);
template <typename T>
class VTKM_ALWAYS_EXPORT ArrayHandleExtrudeCoords
: public vtkm::cont::ArrayHandle<vtkm::Vec<T, 3>, internal::StorageTagExtrude>
{
using StorageType = vtkm::cont::internal::Storage<vtkm::Vec<T, 3>, internal::StorageTagExtrude>;
public:
VTKM_ARRAY_HANDLE_SUBCLASS(
ArrayHandleExtrudeCoords,
(ArrayHandleExtrudeCoords<T>),
(vtkm::cont::ArrayHandle<vtkm::Vec<T, 3>, internal::StorageTagExtrude>));
ArrayHandleExtrudeCoords(const StorageType& storage)
: Superclass(storage)
{
}
vtkm::Id GetNumberOfPointsPerPlane() const { return (this->GetStorage().GetLength() / 2); }
vtkm::Int32 GetNumberOfPlanes() const { return this->GetStorage().GetNumberOfPlanes(); }
bool GetUseCylindrical() const { return this->GetStorage().GetUseCylindrical(); }
const vtkm::cont::ArrayHandle<T>& GetArray() const { return this->GetStorage().Array; }
};
template <typename T>
vtkm::cont::ArrayHandleExtrudeCoords<T> make_ArrayHandleExtrudeCoords(
const vtkm::cont::ArrayHandle<T> arrHandle,
vtkm::Int32 numberOfPlanes,
bool cylindrical)
{
using StorageType = vtkm::cont::internal::Storage<vtkm::Vec<T, 3>, internal::StorageTagExtrude>;
auto storage = StorageType(arrHandle, numberOfPlanes, cylindrical);
return ArrayHandleExtrudeCoords<T>(storage);
}
template <typename T>
vtkm::cont::ArrayHandleExtrudeCoords<T> make_ArrayHandleExtrudeCoords(
const T* array,
vtkm::Id length,
vtkm::Int32 numberOfPlanes,
bool cylindrical,
vtkm::CopyFlag copy = vtkm::CopyFlag::Off)
{
using StorageType = vtkm::cont::internal::Storage<vtkm::Vec<T, 3>, internal::StorageTagExtrude>;
return ArrayHandleExtrudeCoords<T>(
StorageType(vtkm::cont::make_ArrayHandle(array, length, copy), numberOfPlanes, cylindrical));
}
template <typename T>
vtkm::cont::ArrayHandleExtrudeCoords<T> make_ArrayHandleExtrudeCoords(
const std::vector<T>& array,
vtkm::Int32 numberOfPlanes,
bool cylindrical,
vtkm::CopyFlag copy = vtkm::CopyFlag::Off)
{
if (!array.empty())
{
return make_ArrayHandleExtrudeCoords(
array.data(), static_cast<vtkm::Id>(array.size()), numberOfPlanes, cylindrical, copy);
}
else
{
// Vector empty. Just return an empty array handle.
return ArrayHandleExtrudeCoords<T>();
}
}
}
} // end namespace vtkm::cont
//=============================================================================
// Specializations of serialization related classes
/// @cond SERIALIZATION
namespace vtkm
{
namespace cont
{
template <typename T>
struct SerializableTypeString<vtkm::cont::ArrayHandleExtrudeCoords<T>>
{
static VTKM_CONT const std::string& Get()
{
static std::string name = "AH_ExtrudeCoords<" + SerializableTypeString<T>::Get() + ">";
return name;
}
};
}
} // vtkm::cont
namespace mangled_diy_namespace
{
template <typename T>
struct Serialization<vtkm::cont::ArrayHandleExtrudeCoords<T>>
{
private:
using Type = vtkm::cont::ArrayHandleExtrudeCoords<T>;
public:
static VTKM_CONT void save(BinaryBuffer& bb, const Type& ah)
{
vtkmdiy::save(bb, ah.GetNumberOfPlanes());
vtkmdiy::save(bb, ah.GetUseCylindrical());
vtkmdiy::save(bb, ah.GetArray());
}
static VTKM_CONT void load(BinaryBuffer& bb, Type& ah)
{
vtkm::Int32 numberOfPlanes;
bool isCylindrical;
vtkm::cont::ArrayHandle<T> array;
vtkmdiy::load(bb, numberOfPlanes);
vtkmdiy::load(bb, isCylindrical);
vtkmdiy::load(bb, array);
ah = vtkm::cont::make_ArrayHandleExtrudeCoords(array, numberOfPlanes, isCylindrical);
}
};
} // diy
/// @endcond SERIALIZATION
#endif

@ -1,152 +0,0 @@
//============================================================================
// Copyright (c) Kitware, Inc.
// All rights reserved.
// See LICENSE.txt for details.
//
// This software is distributed WITHOUT ANY WARRANTY; without even
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE. See the above copyright notice for more information.
//============================================================================
#ifndef vtk_m_cont_ArrayHandleExtrudeField_h
#define vtk_m_cont_ArrayHandleExtrudeField_h
#include <vtkm/cont/ArrayHandle.h>
#include <vtkm/cont/StorageExtrude.h>
#include <vtkm/cont/internal/ArrayHandleDeprecated.h>
namespace vtkm
{
namespace cont
{
template <typename T>
VTKM_ARRAY_HANDLE_DEPRECATED(T, vtkm::cont::internal::StorageTagExtrude);
template <typename T>
class VTKM_ALWAYS_EXPORT ArrayHandleExtrudeField
: public vtkm::cont::ArrayHandle<T, internal::StorageTagExtrude>
{
using StorageType = vtkm::cont::internal::Storage<T, internal::StorageTagExtrude>;
public:
VTKM_ARRAY_HANDLE_SUBCLASS(ArrayHandleExtrudeField,
(ArrayHandleExtrudeField<T>),
(vtkm::cont::ArrayHandle<T, internal::StorageTagExtrude>));
ArrayHandleExtrudeField(const StorageType& storage)
: Superclass(storage)
{
}
vtkm::Int32 GetNumberOfValuesPerPlane() const
{
return this->GetStorage().GetNumberOfValuesPerPlane();
}
vtkm::Int32 GetNumberOfPlanes() const { return this->GetStorage().GetNumberOfPlanes(); }
bool GetUseCylindrical() const { return this->GetStorage().GetUseCylindrical(); }
const vtkm::cont::ArrayHandle<T>& GetArray() const { return this->GetStorage().Array; }
};
template <typename T>
vtkm::cont::ArrayHandleExtrudeField<T> make_ArrayHandleExtrudeField(
const vtkm::cont::ArrayHandle<T>& array,
vtkm::Int32 numberOfPlanes,
bool cylindrical)
{
using StorageType = vtkm::cont::internal::Storage<T, internal::StorageTagExtrude>;
auto storage = StorageType{ array, numberOfPlanes, cylindrical };
return ArrayHandleExtrudeField<T>(storage);
}
template <typename T>
vtkm::cont::ArrayHandleExtrudeField<T> make_ArrayHandleExtrudeField(
const T* array,
vtkm::Id length,
vtkm::Int32 numberOfPlanes,
bool cylindrical,
vtkm::CopyFlag copy = vtkm::CopyFlag::Off)
{
using StorageType = vtkm::cont::internal::Storage<T, internal::StorageTagExtrude>;
auto storage =
StorageType(vtkm::cont::make_ArrayHandle(array, length, copy), numberOfPlanes, cylindrical);
return ArrayHandleExtrudeField<T>(storage);
}
template <typename T>
vtkm::cont::ArrayHandleExtrudeField<T> make_ArrayHandleExtrudeField(
const std::vector<T>& array,
vtkm::Int32 numberOfPlanes,
bool cylindrical,
vtkm::CopyFlag copy = vtkm::CopyFlag::Off)
{
if (!array.empty())
{
return make_ArrayHandleExtrudeField(
array.data(), static_cast<vtkm::Id>(array.size()), numberOfPlanes, cylindrical, copy);
}
else
{
// Vector empty. Just return an empty array handle.
return ArrayHandleExtrudeField<T>();
}
}
}
} // vtkm::cont
//=============================================================================
// Specializations of serialization related classes
/// @cond SERIALIZATION
namespace vtkm
{
namespace cont
{
template <typename T>
struct SerializableTypeString<vtkm::cont::ArrayHandleExtrudeField<T>>
{
static VTKM_CONT const std::string& Get()
{
static std::string name = "AH_ExtrudeField<" + SerializableTypeString<T>::Get() + ">";
return name;
}
};
}
} // vtkm::cont
namespace mangled_diy_namespace
{
template <typename T>
struct Serialization<vtkm::cont::ArrayHandleExtrudeField<T>>
{
private:
using Type = vtkm::cont::ArrayHandleExtrudeField<T>;
public:
static VTKM_CONT void save(BinaryBuffer& bb, const Type& ah)
{
vtkmdiy::save(bb, ah.GetNumberOfPlanes());
vtkmdiy::save(bb, ah.GetUseCylindrical());
vtkmdiy::save(bb, ah.GetArray());
}
static VTKM_CONT void load(BinaryBuffer& bb, Type& ah)
{
vtkm::Int32 numberOfPlanes;
bool isCylindrical;
vtkm::cont::ArrayHandle<T> array;
vtkmdiy::load(bb, numberOfPlanes);
vtkmdiy::load(bb, isCylindrical);
vtkmdiy::load(bb, array);
ah = vtkm::cont::make_ArrayHandleExtrudeField(array, numberOfPlanes, isCylindrical);
}
};
} // diy
/// @endcond SERIALIZATION
#endif

@ -25,8 +25,6 @@ set(headers
ArrayHandleDecorator.h
ArrayHandleDiscard.h
ArrayHandleExtractComponent.h
ArrayHandleExtrudeCoords.h
ArrayHandleExtrudeField.h
ArrayHandleGroupVec.h
ArrayHandleGroupVecVariable.h
ArrayHandleImplicit.h
@ -113,7 +111,6 @@ set(headers
RuntimeDeviceTracker.h
Serialization.h
Storage.h
StorageExtrude.h
StorageImplicit.h # Deprecated, rolled into ArrayHandleImplicit.h
StorageList.h
StorageListTag.h

@ -13,7 +13,7 @@
#include <vtkm/TopologyElementTag.h>
#include <vtkm/cont/ArrayHandle.h>
#include <vtkm/cont/ArrayHandleCounting.h>
#include <vtkm/cont/ArrayHandleExtrudeCoords.h>
#include <vtkm/cont/ArrayHandleXGCCoordinates.h>
#include <vtkm/cont/CellSet.h>
#include <vtkm/cont/Invoker.h>
#include <vtkm/exec/ConnectivityExtrude.h>
@ -164,7 +164,7 @@ private:
template <typename T>
CellSetExtrude make_CellSetExtrude(const vtkm::cont::ArrayHandle<vtkm::Int32>& conn,
const vtkm::cont::ArrayHandleExtrudeCoords<T>& coords,
const vtkm::cont::ArrayHandleXGCCoordinates<T>& coords,
const vtkm::cont::ArrayHandle<vtkm::Int32>& nextNode,
bool periodic = true)
{
@ -175,26 +175,26 @@ CellSetExtrude make_CellSetExtrude(const vtkm::cont::ArrayHandle<vtkm::Int32>& c
template <typename T>
CellSetExtrude make_CellSetExtrude(const std::vector<vtkm::Int32>& conn,
const vtkm::cont::ArrayHandleExtrudeCoords<T>& coords,
const vtkm::cont::ArrayHandleXGCCoordinates<T>& coords,
const std::vector<vtkm::Int32>& nextNode,
bool periodic = true)
{
return CellSetExtrude{ vtkm::cont::make_ArrayHandle(conn, vtkm::CopyFlag::On),
static_cast<vtkm::Int32>(coords.GetNumberOfPointsPerPlane()),
coords.GetNumberOfPlanes(),
static_cast<vtkm::Int32>(coords.GetNumberOfPlanes()),
vtkm::cont::make_ArrayHandle(nextNode, vtkm::CopyFlag::On),
periodic };
}
template <typename T>
CellSetExtrude make_CellSetExtrude(std::vector<vtkm::Int32>&& conn,
const vtkm::cont::ArrayHandleExtrudeCoords<T>& coords,
const vtkm::cont::ArrayHandleXGCCoordinates<T>& coords,
std::vector<vtkm::Int32>&& nextNode,
bool periodic = true)
{
return CellSetExtrude{ vtkm::cont::make_ArrayHandleMove(std::move(conn)),
static_cast<vtkm::Int32>(coords.GetNumberOfPointsPerPlane()),
coords.GetNumberOfPlanes(),
static_cast<vtkm::Int32>(coords.GetNumberOfPlanes()),
vtkm::cont::make_ArrayHandleMove(std::move(nextNode)),
periodic };
}

@ -1,541 +0,0 @@
//============================================================================
// Copyright (c) Kitware, Inc.
// All rights reserved.
// See LICENSE.txt for details.
//
// This software is distributed WITHOUT ANY WARRANTY; without even
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE. See the above copyright notice for more information.
//============================================================================
#ifndef vtkm_internal_StorageExtrude_h
#define vtkm_internal_StorageExtrude_h
#include <vtkm/internal/IndicesExtrude.h>
#include <vtkm/VecTraits.h>
#include <vtkm/cont/ErrorBadType.h>
#include <vtkm/cont/internal/ArrayTransfer.h>
#include <vtkm/cont/internal/StorageDeprecated.h>
#include <vtkm/cont/serial/DeviceAdapterSerial.h>
#include <vtkm/cont/tbb/DeviceAdapterTBB.h>
namespace vtkm
{
namespace exec
{
template <typename PortalType>
struct VTKM_ALWAYS_EXPORT ArrayPortalExtrudePlane
{
using ValueType = typename PortalType::ValueType;
VTKM_SUPPRESS_EXEC_WARNINGS
VTKM_EXEC_CONT
ArrayPortalExtrudePlane()
: Portal()
, NumberOfPlanes(0)
{
}
ArrayPortalExtrudePlane(const PortalType& p, vtkm::Int32 numOfPlanes)
: Portal(p)
, NumberOfPlanes(numOfPlanes)
{
}
VTKM_SUPPRESS_EXEC_WARNINGS
VTKM_EXEC_CONT
vtkm::Id GetNumberOfValues() const
{
return this->Portal.GetNumberOfValues() * static_cast<vtkm::Id>(NumberOfPlanes);
}
VTKM_SUPPRESS_EXEC_WARNINGS
VTKM_EXEC_CONT
ValueType Get(vtkm::Id index) const { return this->Portal.Get(index % this->NumberOfPlanes); }
VTKM_SUPPRESS_EXEC_WARNINGS
VTKM_EXEC_CONT
ValueType Get(vtkm::Id2 index) const { return this->Portal.Get(index[0]); }
VTKM_SUPPRESS_EXEC_WARNINGS
VTKM_EXEC_CONT
vtkm::Vec<ValueType, 6> GetWedge(const IndicesExtrude& index) const
{
vtkm::Vec<ValueType, 6> result;
result[0] = this->Portal.Get(index.PointIds[0][0]);
result[1] = this->Portal.Get(index.PointIds[0][1]);
result[2] = this->Portal.Get(index.PointIds[0][2]);
result[3] = this->Portal.Get(index.PointIds[1][0]);
result[4] = this->Portal.Get(index.PointIds[1][1]);
result[5] = this->Portal.Get(index.PointIds[1][2]);
return result;
}
PortalType Portal;
vtkm::Int32 NumberOfPlanes;
};
}
} // vtkm::exec
namespace vtkm
{
namespace cont
{
namespace internal
{
struct VTKM_ALWAYS_EXPORT StorageTagExtrudePlane
{
};
template <typename T>
class VTKM_ALWAYS_EXPORT Storage<T, internal::StorageTagExtrudePlane>
{
using HandleType = vtkm::cont::ArrayHandle<T>;
public:
using ValueType = T;
using PortalConstType = vtkm::exec::ArrayPortalExtrudePlane<typename HandleType::ReadPortalType>;
// Note that this array is read only, so you really should only be getting the const
// version of the portal. If you actually try to write to this portal, you will
// get an error.
using PortalType = PortalConstType;
Storage()
: Array()
, NumberOfPlanes(0)
{
}
Storage(const HandleType& array, vtkm::Int32 numberOfPlanes)
: Array(array)
, NumberOfPlanes(numberOfPlanes)
{
}
PortalType GetPortal()
{
throw vtkm::cont::ErrorBadType(
"Extrude ArrayHandles are read only. Cannot get writable portal.");
}
PortalConstType GetPortalConst() const
{
return PortalConstType(this->Array.ReadPortal(), this->NumberOfPlanes);
}
vtkm::Id GetNumberOfValues() const
{
return this->Array.GetNumberOfValues() * static_cast<vtkm::Id>(this->NumberOfPlanes);
}
vtkm::Int32 GetNumberOfValuesPerPlane() const
{
return static_cast<vtkm::Int32>(this->Array->GetNumberOfValues());
}
vtkm::Int32 GetNumberOfPlanes() const { return this->NumberOfPlanes; }
void Allocate(vtkm::Id vtkmNotUsed(numberOfValues))
{
throw vtkm::cont::ErrorBadType("ArrayPortalExtrudePlane is read only. It cannot be allocated.");
}
void Shrink(vtkm::Id vtkmNotUsed(numberOfValues))
{
throw vtkm::cont::ErrorBadType("ArrayPortalExtrudePlane is read only. It cannot shrink.");
}
void ReleaseResources()
{
// This request is ignored since we don't own the memory that was past
// to us
}
private:
vtkm::cont::ArrayHandle<T> Array;
vtkm::Int32 NumberOfPlanes;
VTKM_STORAGE_OLD_STYLE;
};
template <typename T, typename Device>
class VTKM_ALWAYS_EXPORT ArrayTransfer<T, internal::StorageTagExtrudePlane, Device>
{
public:
using ValueType = T;
using StorageType = vtkm::cont::internal::Storage<T, internal::StorageTagExtrudePlane>;
using PortalControl = typename StorageType::PortalType;
using PortalConstControl = typename StorageType::PortalConstType;
//meant to be an invalid writeable execution portal
using PortalExecution = typename StorageType::PortalType;
using PortalConstExecution = vtkm::exec::ArrayPortalExtrudePlane<decltype(
vtkm::cont::ArrayHandle<T>{}.PrepareForInput(Device{}))>;
VTKM_CONT
ArrayTransfer(StorageType* storage)
: ControlData(storage)
{
}
vtkm::Id GetNumberOfValues() const { return this->ControlData->GetNumberOfValues(); }
VTKM_CONT
PortalConstExecution PrepareForInput(bool vtkmNotUsed(updateData))
{
return PortalConstExecution(this->ControlData->Array.PrepareForInput(Device()),
this->ControlData->NumberOfPlanes);
}
VTKM_CONT
PortalExecution PrepareForInPlace(bool& vtkmNotUsed(updateData))
{
throw vtkm::cont::ErrorBadType("ArrayPortalExtrudePlane read only. "
"Cannot be used for in-place operations.");
}
VTKM_CONT
PortalExecution PrepareForOutput(vtkm::Id vtkmNotUsed(numberOfValues))
{
throw vtkm::cont::ErrorBadType("ArrayPortalExtrudePlane read only. Cannot be used as output.");
}
VTKM_CONT
void RetrieveOutputData(StorageType* vtkmNotUsed(storage)) const
{
throw vtkm::cont::ErrorInternal(
"ArrayPortalExtrudePlane read only. "
"There should be no occurance of the ArrayHandle trying to pull "
"data from the execution environment.");
}
VTKM_CONT
void Shrink(vtkm::Id vtkmNotUsed(numberOfValues))
{
throw vtkm::cont::ErrorBadType("ArrayPortalExtrudePlane read only. Cannot shrink.");
}
VTKM_CONT
void ReleaseResources()
{
// This request is ignored since we don't own the memory that was past
// to us
}
private:
const StorageType* const ControlData;
};
}
}
} // vtkm::cont::internal
namespace vtkm
{
namespace exec
{
template <typename PortalType>
struct VTKM_ALWAYS_EXPORT ArrayPortalExtrude
{
using ValueType = vtkm::Vec<typename PortalType::ValueType, 3>;
VTKM_SUPPRESS_EXEC_WARNINGS
VTKM_EXEC_CONT
ArrayPortalExtrude()
: Portal()
, NumberOfValues(0)
, NumberOfPlanes(0)
, UseCylindrical(false)
{
}
VTKM_SUPPRESS_EXEC_WARNINGS
VTKM_EXEC_CONT
ArrayPortalExtrude(const PortalType& p,
vtkm::Int32 numOfValues,
vtkm::Int32 numOfPlanes,
bool cylindrical = false)
: Portal(p)
, NumberOfValues(numOfValues)
, NumberOfPlanes(numOfPlanes)
, UseCylindrical(cylindrical)
{
}
VTKM_SUPPRESS_EXEC_WARNINGS
VTKM_EXEC_CONT
vtkm::Id GetNumberOfValues() const
{
return ((NumberOfValues / 2) * static_cast<vtkm::Id>(NumberOfPlanes));
}
VTKM_SUPPRESS_EXEC_WARNINGS
VTKM_EXEC_CONT
ValueType Get(vtkm::Id index) const;
VTKM_SUPPRESS_EXEC_WARNINGS
VTKM_EXEC_CONT
ValueType Get(vtkm::Id2 index) const;
VTKM_SUPPRESS_EXEC_WARNINGS
VTKM_EXEC_CONT
vtkm::Vec<ValueType, 6> GetWedge(const IndicesExtrude& index) const;
PortalType Portal;
vtkm::Int32 NumberOfValues;
vtkm::Int32 NumberOfPlanes;
bool UseCylindrical;
};
template <typename PortalType>
VTKM_EXEC_CONT typename ArrayPortalExtrude<PortalType>::ValueType
ArrayPortalExtrude<PortalType>::Get(vtkm::Id index) const
{
using CompType = typename ValueType::ComponentType;
const vtkm::Id realIdx = (index * 2) % this->NumberOfValues;
const vtkm::Id whichPlane = (index * 2) / this->NumberOfValues;
const auto phi = static_cast<CompType>(whichPlane * (vtkm::TwoPi() / this->NumberOfPlanes));
auto r = this->Portal.Get(realIdx);
auto z = this->Portal.Get(realIdx + 1);
if (this->UseCylindrical)
{
return ValueType(r, phi, z);
}
else
{
return ValueType(r * vtkm::Cos(phi), r * vtkm::Sin(phi), z);
}
}
template <typename PortalType>
VTKM_EXEC_CONT typename ArrayPortalExtrude<PortalType>::ValueType
ArrayPortalExtrude<PortalType>::Get(vtkm::Id2 index) const
{
using CompType = typename ValueType::ComponentType;
const vtkm::Id realIdx = (index[0] * 2);
const vtkm::Id whichPlane = index[1];
const auto phi = static_cast<CompType>(whichPlane * (vtkm::TwoPi() / this->NumberOfPlanes));
auto r = this->Portal.Get(realIdx);
auto z = this->Portal.Get(realIdx + 1);
if (this->UseCylindrical)
{
return ValueType(r, phi, z);
}
else
{
return ValueType(r * vtkm::Cos(phi), r * vtkm::Sin(phi), z);
}
}
template <typename PortalType>
VTKM_EXEC_CONT vtkm::Vec<typename ArrayPortalExtrude<PortalType>::ValueType, 6>
ArrayPortalExtrude<PortalType>::GetWedge(const IndicesExtrude& index) const
{
using CompType = typename ValueType::ComponentType;
vtkm::Vec<ValueType, 6> result;
for (int j = 0; j < 2; ++j)
{
const auto phi =
static_cast<CompType>(index.Planes[j] * (vtkm::TwoPi() / this->NumberOfPlanes));
for (int i = 0; i < 3; ++i)
{
const vtkm::Id realIdx = index.PointIds[j][i] * 2;
auto r = this->Portal.Get(realIdx);
auto z = this->Portal.Get(realIdx + 1);
result[3 * j + i] = this->UseCylindrical
? ValueType(r, phi, z)
: ValueType(r * vtkm::Cos(phi), r * vtkm::Sin(phi), z);
}
}
return result;
}
}
}
namespace vtkm
{
namespace cont
{
namespace internal
{
struct VTKM_ALWAYS_EXPORT StorageTagExtrude
{
};
template <typename T>
class Storage<T, internal::StorageTagExtrude>
{
using BaseT = typename VecTraits<T>::BaseComponentType;
using HandleType = vtkm::cont::ArrayHandle<BaseT>;
using TPortalType = typename HandleType::ReadPortalType;
public:
using ValueType = T;
using PortalConstType = exec::ArrayPortalExtrude<TPortalType>;
// Note that this array is read only, so you really should only be getting the const
// version of the portal. If you actually try to write to this portal, you will
// get an error.
using PortalType = PortalConstType;
Storage()
: Array()
, NumberOfPlanes(0)
{
}
Storage(const HandleType& array, vtkm::Int32 numberOfPlanes, bool cylindrical)
: Array(array)
, NumberOfPlanes(numberOfPlanes)
, UseCylindrical(cylindrical)
{
VTKM_ASSERT(this->Array.GetNumberOfValues() >= 0);
}
PortalType GetPortal()
{
throw vtkm::cont::ErrorBadType(
"Extrude ArrayHandles are read only. Cannot get writable portal.");
}
PortalConstType GetPortalConst() const
{
VTKM_ASSERT(this->Array.GetNumberOfValues() >= 0);
return PortalConstType(this->Array.ReadPortal(),
static_cast<vtkm::Int32>(this->Array.GetNumberOfValues()),
this->NumberOfPlanes,
this->UseCylindrical);
}
vtkm::Id GetNumberOfValues() const
{
VTKM_ASSERT(this->Array.GetNumberOfValues() >= 0);
return (this->Array.GetNumberOfValues() / 2) * static_cast<vtkm::Id>(this->NumberOfPlanes);
}
vtkm::Id GetLength() const { return this->Array.GetNumberOfValues(); }
vtkm::Int32 GetNumberOfPlanes() const { return NumberOfPlanes; }
bool GetUseCylindrical() const { return UseCylindrical; }
void Allocate(vtkm::Id vtkmNotUsed(numberOfValues))
{
throw vtkm::cont::ErrorBadType("StorageTagExtrude is read only. It cannot be allocated.");
}
void Shrink(vtkm::Id vtkmNotUsed(numberOfValues))
{
throw vtkm::cont::ErrorBadType("StoraageTagExtrue is read only. It cannot shrink.");
}
void ReleaseResources()
{
// This request is ignored since we don't own the memory that was past
// to us
}
vtkm::cont::ArrayHandle<BaseT> Array;
private:
vtkm::Int32 NumberOfPlanes;
bool UseCylindrical;
VTKM_STORAGE_OLD_STYLE;
};
template <typename T, typename Device>
class VTKM_ALWAYS_EXPORT ArrayTransfer<T, internal::StorageTagExtrude, Device>
{
using BaseT = typename VecTraits<T>::BaseComponentType;
using TPortalType = decltype(
vtkm::cont::ArrayHandle<BaseT>{}.PrepareForInput(Device{}, std::declval<vtkm::cont::Token&>()));
public:
using ValueType = T;
using StorageType = vtkm::cont::internal::Storage<T, internal::StorageTagExtrude>;
using PortalControl = typename StorageType::PortalType;
using PortalConstControl = typename StorageType::PortalConstType;
//meant to be an invalid writeable execution portal
using PortalExecution = vtkm::exec::ArrayPortalExtrude<TPortalType>;
using PortalConstExecution = vtkm::exec::ArrayPortalExtrude<TPortalType>;
VTKM_CONT
ArrayTransfer(StorageType* storage)
: ControlData(storage)
{
}
vtkm::Id GetNumberOfValues() const { return this->ControlData->GetNumberOfValues(); }
VTKM_CONT
PortalConstExecution PrepareForInput(bool vtkmNotUsed(updateData), vtkm::cont::Token& token)
{
return PortalConstExecution(
this->ControlData->Array.PrepareForInput(Device(), token),
static_cast<vtkm::Int32>(this->ControlData->Array.GetNumberOfValues()),
this->ControlData->GetNumberOfPlanes(),
this->ControlData->GetUseCylindrical());
}
VTKM_CONT
PortalExecution PrepareForInPlace(bool& vtkmNotUsed(updateData), vtkm::cont::Token&)
{
throw vtkm::cont::ErrorBadType("StorageExtrude read only. "
"Cannot be used for in-place operations.");
}
VTKM_CONT
PortalExecution PrepareForOutput(vtkm::Id vtkmNotUsed(numberOfValues), vtkm::cont::Token&)
{
throw vtkm::cont::ErrorBadType("StorageExtrude read only. Cannot be used as output.");
}
VTKM_CONT
void RetrieveOutputData(StorageType* vtkmNotUsed(storage)) const
{
throw vtkm::cont::ErrorInternal(
"ArrayHandleExrPointCoordinates read only. "
"There should be no occurance of the ArrayHandle trying to pull "
"data from the execution environment.");
}
VTKM_CONT
void Shrink(vtkm::Id vtkmNotUsed(numberOfValues))
{
throw vtkm::cont::ErrorBadType("StorageExtrude read only. Cannot shrink.");
}
VTKM_CONT
void ReleaseResources()
{
// This request is ignored since we don't own the memory that was past
// to us
}
private:
const StorageType* const ControlData;
};
}
}
}
#endif

@ -41,7 +41,6 @@ set(unit_tests
UnitTestArrayHandleDecorator.cxx
UnitTestArrayHandleDiscard.cxx
UnitTestArrayHandleExtractComponent.cxx
UnitTestArrayHandleExtrude.cxx
UnitTestArrayHandleImplicit.cxx
UnitTestArrayHandleIndex.cxx
UnitTestArrayHandleReverse.cxx
@ -54,6 +53,7 @@ set(unit_tests
UnitTestArrayHandleTransform.cxx
UnitTestArrayHandleUniformPointCoordinates.cxx
UnitTestArrayHandleVirtual.cxx
UnitTestArrayHandleXGCCoordinates.cxx
UnitTestArrayPortalToIterators.cxx
UnitTestCellLocatorGeneral.cxx
UnitTestCellSet.cxx

@ -13,7 +13,7 @@
#include <vtkm/worklet/DispatcherMapField.h>
#include <vtkm/worklet/WorkletMapField.h>
#include <vtkm/cont/ArrayHandleExtrudeCoords.h>
#include <vtkm/cont/ArrayHandleXGCCoordinates.h>
#include <vtkm/cont/testing/Testing.h>
@ -91,11 +91,11 @@ void verify_results(vtkm::cont::ArrayHandle<vtkm::Vec<T, 3>, S> const& handle)
}
int TestArrayHandleExtrude()
int TestArrayHandleXGCCoordinates()
{
const int numPlanes = 8;
auto coords = vtkm::cont::make_ArrayHandleExtrudeCoords(
auto coords = vtkm::cont::make_ArrayHandleXGCCoordinates(
vtkm::cont::make_ArrayHandle(points_rz, vtkm::CopyFlag::Off), numPlanes, false);
VTKM_TEST_ASSERT(coords.GetNumberOfValues() ==
@ -116,8 +116,8 @@ int TestArrayHandleExtrude()
} // end namespace anonymous
int UnitTestArrayHandleExtrude(int argc, char* argv[])
int UnitTestArrayHandleXGCCoordinates(int argc, char* argv[])
{
vtkm::cont::GetRuntimeDeviceTracker().ForceDevice(vtkm::cont::DeviceAdapterTagSerial{});
return vtkm::cont::testing::Testing::Run(TestArrayHandleExtrude, argc, argv);
return vtkm::cont::testing::Testing::Run(TestArrayHandleXGCCoordinates, argc, argv);
}

@ -10,7 +10,7 @@
#include <vtkm/worklet/DispatcherMapTopology.h>
#include <vtkm/worklet/WorkletMapTopology.h>
#include <vtkm/cont/ArrayHandleExtrudeCoords.h>
#include <vtkm/cont/ArrayHandleXGCCoordinates.h>
#include <vtkm/cont/CellSetExtrude.h>
#include <vtkm/cont/testing/Testing.h>
@ -112,7 +112,7 @@ int TestCellSetExtrude()
{
const std::size_t numPlanes = 8;
auto coords = vtkm::cont::make_ArrayHandleExtrudeCoords(points_rz, numPlanes, false);
auto coords = vtkm::cont::make_ArrayHandleXGCCoordinates(points_rz, numPlanes, false);
auto cells = vtkm::cont::make_CellSetExtrude(topology, coords, nextNode);
VTKM_TEST_ASSERT(cells.GetNumberOfPoints() == coords.GetNumberOfValues(),
"number of points don't match between cells and coordinates");

@ -15,7 +15,7 @@
#include <vtkm/exec/arg/FetchTagArrayTopologyMapIn.h>
#include <vtkm/exec/arg/IncidentElementIndices.h>
//optimized fetches for ArrayPortalExtrude for
//optimized fetches for ArrayPortalXGCCoordinates for
// - 3D Scheduling
// - WorkletNeighboorhood
namespace vtkm
@ -70,47 +70,40 @@ struct Fetch<FetchType, vtkm::exec::arg::AspectTagIncidentElementIndices, ExecOb
template <typename T>
struct Fetch<vtkm::exec::arg::FetchTagArrayTopologyMapIn,
vtkm::exec::arg::AspectTagDefault,
vtkm::exec::ArrayPortalExtrude<T>>
vtkm::internal::ArrayPortalXGCCoordinates<T>>
{
//Optimized fetch for point arrays when iterating the cells ConnectivityExtrude
VTKM_SUPPRESS_EXEC_WARNINGS
template <typename ThreadIndicesType>
VTKM_EXEC auto Load(const ThreadIndicesType& indices,
const vtkm::exec::ArrayPortalExtrude<T>& points)
-> decltype(points.GetWedge(indices.GetIndicesIncident()))
{
// std::cout << "opimized fetch for point coordinates" << std::endl;
return points.GetWedge(indices.GetIndicesIncident());
}
template <typename ThreadIndicesType, typename ValueType>
VTKM_EXEC void Store(const ThreadIndicesType&,
const vtkm::exec::ArrayPortalExtrude<T>&,
const ValueType&) const
{
// Store is a no-op for this fetch.
}
};
//Optimized fetch for point coordinates when iterating the cells of ConnectivityExtrude
template <typename T>
struct Fetch<vtkm::exec::arg::FetchTagArrayTopologyMapIn,
vtkm::exec::arg::AspectTagDefault,
vtkm::exec::ArrayPortalExtrudePlane<T>>
{
VTKM_SUPPRESS_EXEC_WARNINGS
template <typename ThreadIndicesType>
VTKM_EXEC auto Load(const ThreadIndicesType& indices,
const vtkm::exec::ArrayPortalExtrudePlane<T>& portal)
template <typename ScatterAndMaskMode>
VTKM_EXEC auto Load(
const vtkm::exec::arg::ThreadIndicesTopologyMap<vtkm::exec::ConnectivityExtrude,
ScatterAndMaskMode>& indices,
const vtkm::internal::ArrayPortalXGCCoordinates<T>& portal)
-> decltype(portal.GetWedge(indices.GetIndicesIncident()))
{
// std::cout << "opimized fetch for point coordinates" << std::endl;
return portal.GetWedge(indices.GetIndicesIncident());
}
VTKM_SUPPRESS_EXEC_WARNINGS
template <typename ThreadIndicesType>
VTKM_EXEC auto Load(const ThreadIndicesType& indices,
const vtkm::internal::ArrayPortalXGCCoordinates<T>& field) const
-> decltype(
detail::FetchArrayTopologyMapInImplementation<typename ThreadIndicesType::Connectivity,
vtkm::internal::ArrayPortalXGCCoordinates<T>,
ThreadIndicesType>::Load(indices, field))
{
using Implementation =
detail::FetchArrayTopologyMapInImplementation<typename ThreadIndicesType::Connectivity,
vtkm::internal::ArrayPortalXGCCoordinates<T>,
ThreadIndicesType>;
return Implementation::Load(indices, field);
}
template <typename ThreadIndicesType, typename ValueType>
VTKM_EXEC void Store(const ThreadIndicesType&,
const vtkm::exec::ArrayPortalExtrudePlane<T>&,
const vtkm::internal::ArrayPortalXGCCoordinates<T>&,
const ValueType&) const
{
// Store is a no-op for this fetch.
@ -121,13 +114,13 @@ struct Fetch<vtkm::exec::arg::FetchTagArrayTopologyMapIn,
template <typename T>
struct Fetch<vtkm::exec::arg::FetchTagArrayDirectIn,
vtkm::exec::arg::AspectTagDefault,
vtkm::exec::ArrayPortalExtrude<T>>
vtkm::internal::ArrayPortalXGCCoordinates<T>>
{
VTKM_SUPPRESS_EXEC_WARNINGS
template <typename ThreadIndicesType>
VTKM_EXEC auto Load(const ThreadIndicesType& indices,
const vtkm::exec::ArrayPortalExtrude<T>& points)
const vtkm::internal::ArrayPortalXGCCoordinates<T>& points)
-> decltype(points.Get(indices.GetInputIndex()))
{
// std::cout << "optimized fetch for point coordinates" << std::endl;
@ -139,7 +132,7 @@ struct Fetch<vtkm::exec::arg::FetchTagArrayDirectIn,
VTKM_EXEC auto Load(
const vtkm::exec::arg::ThreadIndicesTopologyMap<vtkm::exec::ReverseConnectivityExtrude,
ScatterAndMaskMode>& indices,
const vtkm::exec::ArrayPortalExtrude<T>& points)
const vtkm::internal::ArrayPortalXGCCoordinates<T>& points)
-> decltype(points.Get(indices.GetIndexLogical()))
{
// std::cout << "optimized fetch for point coordinates" << std::endl;
@ -148,7 +141,7 @@ struct Fetch<vtkm::exec::arg::FetchTagArrayDirectIn,
template <typename ThreadIndicesType, typename ValueType>
VTKM_EXEC void Store(const ThreadIndicesType&,
const vtkm::exec::ArrayPortalExtrude<T>&,
const vtkm::internal::ArrayPortalXGCCoordinates<T>&,
const ValueType&) const
{
// Store is a no-op for this fetch.

@ -26,7 +26,6 @@ set(common_headers
MapFieldPermutation.h
PolicyBase.h
PolicyDefault.h
PolicyExtrude.h
Threshold.h
ThresholdPoints.h
)

@ -38,7 +38,7 @@ public:
vtkm::filter::PolicyBase<DerivedPolicy> policy);
// PointAverage is a simple filter that is used to test custom filter types.
using AdditionalFieldStorage = vtkm::List<vtkm::cont::internal::StorageTagExtrude>;
using AdditionalFieldStorage = vtkm::List<vtkm::cont::StorageTagXGCCoordinates>;
using SupportedCellSets =
vtkm::ListAppend<vtkm::List<vtkm::cont::CellSetExtrude>, VTKM_DEFAULT_CELL_SET_LIST>;

@ -1,43 +0,0 @@
//=============================================================================
//
// Copyright (c) Kitware, Inc.
// All rights reserved.
// See LICENSE.txt for details.
//
// This software is distributed WITHOUT ANY WARRANTY; without even
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE. See the above copyright notice for more information.
//
// Copyright 2012 Sandia Corporation.
// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
// the U.S. Government retains certain rights in this software.
//
//=============================================================================
#ifndef vtk_m_filter_PolicyExtrude_h
#define vtk_m_filter_PolicyExtrude_h
#include <vtkm/cont/ArrayHandleExtrudeCoords.h>
#include <vtkm/cont/CellSetExtrude.h>
#include <vtkm/List.h>
#include <vtkm/filter/PolicyDefault.h>
namespace vtkm
{
namespace filter
{
struct VTKM_ALWAYS_EXPORT PolicyExtrude : vtkm::filter::PolicyBase<PolicyExtrude>
{
public:
using UnstructuredCellSetList = vtkm::List<vtkm::cont::CellSetExtrude>;
using AllCellSetList = vtkm::List<vtkm::cont::CellSetExtrude>;
//Todo: add in Cylinder storage tag when it is written
using CoordinateStorageList =
vtkm::List<vtkm::cont::StorageTagBasic, vtkm::cont::internal::StorageTagExtrude>;
};
}
}
#endif

@ -10,7 +10,7 @@
#include <vtkm/worklet/DispatcherMapTopology.h>
#include <vtkm/worklet/WorkletMapTopology.h>
#include <vtkm/cont/ArrayHandleExtrudeCoords.h>
#include <vtkm/cont/ArrayHandleXGCCoordinates.h>
#include <vtkm/cont/CellSetExtrude.h>
#include <vtkm/cont/testing/Testing.h>
@ -27,7 +27,7 @@ int TestCellSetExtrude()
{
const std::size_t numPlanes = 8;
auto coords = vtkm::cont::make_ArrayHandleExtrudeCoords(points_rz, numPlanes, false);
auto coords = vtkm::cont::make_ArrayHandleXGCCoordinates(points_rz, numPlanes, false);
auto cells = vtkm::cont::make_CellSetExtrude(topology, coords, nextNode);
VTKM_TEST_ASSERT(cells.GetNumberOfPoints() == coords.GetNumberOfValues(),
"number of points don't match between cells and coordinates");