Roll connectivity information into CellSet in control environment
Previously there was a Connectivity* structure for both the control environment and the execution environment. This was necessary before because the connectivity is explicit to the from and to topology elements, so you would get this structure from the appropriate call to CellSet*. However, the symantics are changed so that the type of connectivity is selected in the worklet's dispatcher. Thus, it is now much cleaner to manage the CellSet structure in the CellSet class itself and just have a single set of Connectivity* classes in the execution environment.
This commit is contained in:
parent
b392dc509e
commit
7212469d04
@ -27,7 +27,6 @@ set(headers
|
|||||||
Math.h
|
Math.h
|
||||||
Matrix.h
|
Matrix.h
|
||||||
Pair.h
|
Pair.h
|
||||||
RegularConnectivity.h
|
|
||||||
TopologyElementTag.h
|
TopologyElementTag.h
|
||||||
TypeListTag.h
|
TypeListTag.h
|
||||||
Types.h
|
Types.h
|
||||||
|
@ -37,7 +37,6 @@ set(headers
|
|||||||
CellSetExplicit.h
|
CellSetExplicit.h
|
||||||
CellSetListTag.h
|
CellSetListTag.h
|
||||||
CellSetStructured.h
|
CellSetStructured.h
|
||||||
ConnectivityExplicit.h
|
|
||||||
CoordinateSystem.h
|
CoordinateSystem.h
|
||||||
DataSet.h
|
DataSet.h
|
||||||
DeviceAdapter.h
|
DeviceAdapter.h
|
||||||
|
@ -56,18 +56,22 @@ public:
|
|||||||
return this->Dimensionality;
|
return this->Dimensionality;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual vtkm::Id GetNumCells() const = 0;
|
virtual vtkm::Id GetNumberOfCells() const = 0;
|
||||||
|
|
||||||
virtual vtkm::Id GetNumFaces() const
|
virtual vtkm::Id GetNumberOfFaces() const
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual vtkm::Id GetNumEdges() const
|
virtual vtkm::Id GetNumberOfEdges() const
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// A cell set does not (necessarily) know the number of points. Nor does a
|
||||||
|
// DataSet. Shouldn't someone know?
|
||||||
|
// virtual vtkm::Id GetNumberOfPoints() const = 0;
|
||||||
|
|
||||||
virtual void PrintSummary(std::ostream&) const = 0;
|
virtual void PrintSummary(std::ostream&) const = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -22,68 +22,245 @@
|
|||||||
|
|
||||||
#include <vtkm/TopologyElementTag.h>
|
#include <vtkm/TopologyElementTag.h>
|
||||||
#include <vtkm/cont/CellSet.h>
|
#include <vtkm/cont/CellSet.h>
|
||||||
#include <vtkm/cont/ConnectivityExplicit.h>
|
#include <vtkm/exec/ConnectivityExplicit.h>
|
||||||
|
|
||||||
namespace vtkm {
|
namespace vtkm {
|
||||||
namespace cont {
|
namespace cont {
|
||||||
|
|
||||||
template<typename ShapeStorageTag = VTKM_DEFAULT_STORAGE_TAG,
|
template<typename ShapeStorageTag = VTKM_DEFAULT_STORAGE_TAG,
|
||||||
typename IndexStorageTag = VTKM_DEFAULT_STORAGE_TAG,
|
typename NumIndicesStorageTag = VTKM_DEFAULT_STORAGE_TAG,
|
||||||
typename ConnectivityStorageTag = VTKM_DEFAULT_STORAGE_TAG >
|
typename ConnectivityStorageTag = VTKM_DEFAULT_STORAGE_TAG >
|
||||||
class CellSetExplicit : public CellSet
|
class CellSetExplicit : public CellSet
|
||||||
{
|
{
|
||||||
|
typedef vtkm::cont::ArrayHandle<vtkm::Id, ShapeStorageTag> ShapeArrayType;
|
||||||
|
typedef vtkm::cont::ArrayHandle<vtkm::Id, NumIndicesStorageTag> NumIndicesArrayType;
|
||||||
|
typedef vtkm::cont::ArrayHandle<vtkm::Id, ConnectivityStorageTag> ConnectivityArrayType;
|
||||||
|
typedef vtkm::cont::ArrayHandle<vtkm::Id> MapCellToConnectivityIndexArrayType;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef ConnectivityExplicit<ShapeStorageTag,
|
typedef vtkm::Id SchedulingRangeType;
|
||||||
IndexStorageTag,
|
|
||||||
ConnectivityStorageTag
|
|
||||||
> ExplicitConnectivityType;
|
|
||||||
|
|
||||||
VTKM_CONT_EXPORT
|
VTKM_CONT_EXPORT
|
||||||
CellSetExplicit(const std::string &name = std::string(),
|
CellSetExplicit(const std::string &name = std::string(),
|
||||||
vtkm::IdComponent dimensionality = 3)
|
vtkm::IdComponent dimensionality = 3)
|
||||||
: CellSet(name, dimensionality)
|
: CellSet(name, dimensionality),
|
||||||
|
ConnectivityLength(0),
|
||||||
|
NumberOfCells(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
VTKM_CONT_EXPORT
|
VTKM_CONT_EXPORT
|
||||||
CellSetExplicit(int dimensionality)
|
CellSetExplicit(int dimensionality)
|
||||||
: CellSet(std::string(), dimensionality)
|
: CellSet(std::string(), dimensionality),
|
||||||
|
ConnectivityLength(0),
|
||||||
|
NumberOfCells(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual vtkm::Id GetNumCells() const
|
virtual vtkm::Id GetNumberOfCells() const
|
||||||
{
|
{
|
||||||
return this->NodesOfCellsConnectivity.GetNumberOfElements();
|
return this->Shapes.GetNumberOfValues();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename FromTopology, typename ToTopology>
|
VTKM_CONT_EXPORT
|
||||||
struct ConnectivityType {
|
vtkm::Id GetSchedulingRange(vtkm::TopologyElementTagCell) const
|
||||||
|
{
|
||||||
|
return this->GetNumberOfCells();
|
||||||
|
}
|
||||||
|
|
||||||
|
VTKM_CONT_EXPORT
|
||||||
|
vtkm::Id GetNumberOfNodesInCell(vtkm::Id cellIndex) const
|
||||||
|
{
|
||||||
|
return this->NumIndices.GetPortalConstControl().Get(cellIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
VTKM_CONT_EXPORT
|
||||||
|
vtkm::Id GetCellShapeType(vtkm::Id cellIndex) const
|
||||||
|
{
|
||||||
|
return this->Shapes.GetPortalConstControl().Get(cellIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <vtkm::IdComponent ItemTupleLength>
|
||||||
|
VTKM_CONT_EXPORT
|
||||||
|
void GetIndices(vtkm::Id index,
|
||||||
|
vtkm::Vec<vtkm::Id,ItemTupleLength> &ids) const
|
||||||
|
{
|
||||||
|
vtkm::Id numIndices = this->GetNumberOfIndices(index);
|
||||||
|
vtkm::Id start =
|
||||||
|
this->MapCellToConnectivityIndex.GetPortalConstControl().Get(index);
|
||||||
|
for (vtkm::IdComponent i=0; i<numIndices && i<ItemTupleLength; i++)
|
||||||
|
ids[i] = this->Connectivity.GetPortalConstControl().Get(start+i);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// First method to add cells -- one at a time.
|
||||||
|
VTKM_CONT_EXPORT
|
||||||
|
void PrepareToAddCells(vtkm::Id numShapes, vtkm::Id connectivityMaxLen)
|
||||||
|
{
|
||||||
|
this->Shapes.Allocate(numShapes);
|
||||||
|
this->NumIndices.Allocate(numShapes);
|
||||||
|
this->Connectivity.Allocate(connectivityMaxLen);
|
||||||
|
this->MapCellToConnectivityIndex.Allocate(numShapes);
|
||||||
|
this->NumberOfCells = 0;
|
||||||
|
this->ConnectivityLength = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <vtkm::IdComponent ItemTupleLength>
|
||||||
|
VTKM_CONT_EXPORT
|
||||||
|
void AddCell(vtkm::CellType cellType,
|
||||||
|
int numVertices,
|
||||||
|
const vtkm::Vec<vtkm::Id,ItemTupleLength> &ids)
|
||||||
|
{
|
||||||
|
this->Shapes.GetPortalControl().Set(this->NumberOfCells, cellType);
|
||||||
|
this->NumIndices.GetPortalControl().Set(this->NumberOfCells, numVertices);
|
||||||
|
for (vtkm::IdComponent i=0; i < numVertices; ++i)
|
||||||
|
{
|
||||||
|
this->Connectivity.GetPortalControl().Set(
|
||||||
|
this->ConnectivityLength+i,ids[i]);
|
||||||
|
}
|
||||||
|
this->MapCellToConnectivityIndex.GetPortalControl().Set(
|
||||||
|
this->NumberOfCells, this->ConnectivityLength);
|
||||||
|
this->NumberOfCells++;
|
||||||
|
this->ConnectivityLength += numVertices;
|
||||||
|
}
|
||||||
|
|
||||||
|
VTKM_CONT_EXPORT
|
||||||
|
void CompleteAddingCells()
|
||||||
|
{
|
||||||
|
Connectivity.Shrink(ConnectivityLength);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Second method to add cells -- all at once.
|
||||||
|
/// Copies the data from the vectors, so they can be released.
|
||||||
|
VTKM_CONT_EXPORT
|
||||||
|
void FillViaCopy(const std::vector<vtkm::Id> &cellTypes,
|
||||||
|
const std::vector<vtkm::Id> &numIndices,
|
||||||
|
const std::vector<vtkm::Id> &connectivity)
|
||||||
|
{
|
||||||
|
|
||||||
|
this->Shapes.Allocate( static_cast<vtkm::Id>(cellTypes.size()) );
|
||||||
|
std::copy(cellTypes.begin(), cellTypes.end(),
|
||||||
|
vtkm::cont::ArrayPortalToIteratorBegin(this->Shapes.GetPortalControl()));
|
||||||
|
|
||||||
|
this->NumIndices.Allocate( static_cast<vtkm::Id>(numIndices.size()) );
|
||||||
|
std::copy(numIndices.begin(), numIndices.end(),
|
||||||
|
vtkm::cont::ArrayPortalToIteratorBegin(this->NumIndices.GetPortalControl()));
|
||||||
|
|
||||||
|
this->Connectivity.Allocate( static_cast<vtkm::Id>(connectivity.size()) );
|
||||||
|
std::copy(connectivity.begin(), connectivity.end(),
|
||||||
|
vtkm::cont::ArrayPortalToIteratorBegin(this->Connectivity.GetPortalControl()));
|
||||||
|
|
||||||
|
this->NumberOfCells = this->Shapes.GetNumberOfValues();
|
||||||
|
this->ConnectivityLength = this->Connectivity.GetNumberOfValues();
|
||||||
|
|
||||||
|
// allocate and build reverse index
|
||||||
|
this->MapCellToConnectivityIndex.Allocate(this->NumberOfCells);
|
||||||
|
vtkm::Id counter = 0;
|
||||||
|
for (vtkm::Id i=0; i<this->NumberOfCells; ++i)
|
||||||
|
{
|
||||||
|
this->MapCellToConnectivityIndex.GetPortalControl().Set(i, counter);
|
||||||
|
counter += this->NumIndices.GetPortalConstControl().Get(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Second method to add cells -- all at once.
|
||||||
|
/// Assigns the array handles to the explicit connectivity. This is
|
||||||
|
/// the way you can fill the memory from another system without copying
|
||||||
|
void Fill(const vtkm::cont::ArrayHandle<vtkm::Id, ShapeStorageTag> &cellTypes,
|
||||||
|
const vtkm::cont::ArrayHandle<vtkm::Id, NumIndicesStorageTag> &numIndices,
|
||||||
|
const vtkm::cont::ArrayHandle<vtkm::Id, ConnectivityStorageTag> &connectivity)
|
||||||
|
{
|
||||||
|
this->Shapes = cellTypes;
|
||||||
|
this->NumIndices = numIndices;
|
||||||
|
this->Connectivity = connectivity;
|
||||||
|
|
||||||
|
this->NumberOfCells = this->Shapes.GetNumberOfValues();
|
||||||
|
this->ConnectivityLength = this->Connectivity.GetNumberOfValues();
|
||||||
|
|
||||||
|
// allocate and build reverse index
|
||||||
|
this->MapCellToConnectivityIndex.Allocate(this->NumberOfCells);
|
||||||
|
vtkm::Id counter = 0;
|
||||||
|
for (vtkm::Id i=0; i<this->NumberOfCells; ++i)
|
||||||
|
{
|
||||||
|
this->MapCellToConnectivityIndex.GetPortalControl().Set(i, counter);
|
||||||
|
counter += this->NumIndices.GetPortalConstControl().Get(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename DeviceAdapter, typename FromTopology, typename ToTopology>
|
||||||
|
struct ExecutionTypes
|
||||||
|
{
|
||||||
|
VTKM_IS_DEVICE_ADAPTER_TAG(DeviceAdapter);
|
||||||
VTKM_IS_TOPOLOGY_ELEMENT_TAG(FromTopology);
|
VTKM_IS_TOPOLOGY_ELEMENT_TAG(FromTopology);
|
||||||
VTKM_IS_TOPOLOGY_ELEMENT_TAG(ToTopology);
|
VTKM_IS_TOPOLOGY_ELEMENT_TAG(ToTopology);
|
||||||
// This type is really only valid for Point to Cell connectivity. When
|
|
||||||
// other connectivity types are supported, these will need to be added.
|
typedef typename ShapeArrayType::template ExecutionTypes<DeviceAdapter>::PortalConst ShapePortalType;
|
||||||
typedef ExplicitConnectivityType Type;
|
typedef typename NumIndicesArrayType::template ExecutionTypes<DeviceAdapter>::PortalConst IndicePortalType;
|
||||||
|
typedef typename ConnectivityArrayType::template ExecutionTypes<DeviceAdapter>::PortalConst ConnectivityPortalType;
|
||||||
|
typedef typename MapCellToConnectivityIndexArrayType::template ExecutionTypes<DeviceAdapter>::PortalConst MapConnectivityPortalType;
|
||||||
|
|
||||||
|
typedef vtkm::exec::ConnectivityExplicit<ShapePortalType,
|
||||||
|
IndicePortalType,
|
||||||
|
ConnectivityPortalType,
|
||||||
|
MapConnectivityPortalType
|
||||||
|
> ExecObjectType;
|
||||||
};
|
};
|
||||||
|
|
||||||
const ExplicitConnectivityType &GetNodeToCellConnectivity() const
|
template<typename Device>
|
||||||
|
typename ExecutionTypes<Device,vtkm::TopologyElementTagPoint,vtkm::TopologyElementTagCell>::ExecObjectType
|
||||||
|
PrepareForInput(Device,
|
||||||
|
vtkm::TopologyElementTagPoint,
|
||||||
|
vtkm::TopologyElementTagCell) const
|
||||||
{
|
{
|
||||||
return this->NodesOfCellsConnectivity;
|
typedef typename ExecutionTypes<Device,vtkm::TopologyElementTagPoint,vtkm::TopologyElementTagCell>::ExecObjectType ExecObjType;
|
||||||
}
|
return ExecObjType(this->Shapes.PrepareForInput(Device()),
|
||||||
|
this->NumIndices.PrepareForInput(Device()),
|
||||||
ExplicitConnectivityType &GetNodeToCellConnectivity()
|
this->Connectivity.PrepareForInput(Device()),
|
||||||
{
|
this->MapCellToConnectivityIndex.PrepareForInput(Device()));
|
||||||
return this->NodesOfCellsConnectivity;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void PrintSummary(std::ostream &out) const
|
virtual void PrintSummary(std::ostream &out) const
|
||||||
{
|
{
|
||||||
out << " ExplicitCellSet: " << this->Name
|
out << " ExplicitCellSet: " << this->Name
|
||||||
<< " dim= " << this->Dimensionality << std::endl;
|
<< " dim= " << this->Dimensionality << std::endl;
|
||||||
this->NodesOfCellsConnectivity.PrintSummary(out);
|
out <<" Shapes: ";
|
||||||
|
vtkm::cont::printSummary_ArrayHandle(this->Shapes, out);
|
||||||
|
out << std::endl;
|
||||||
|
out << " NumIndices: ";
|
||||||
|
vtkm::cont::printSummary_ArrayHandle(this->NumIndices, out);
|
||||||
|
out << std::endl;
|
||||||
|
out << " Connectivity: ";
|
||||||
|
vtkm::cont::printSummary_ArrayHandle(this->Connectivity, out);
|
||||||
|
out << std::endl;
|
||||||
|
out << " MapCellToConnectivityIndex: ";
|
||||||
|
vtkm::cont::printSummary_ArrayHandle(
|
||||||
|
this->MapCellToConnectivityIndex, out);
|
||||||
|
}
|
||||||
|
|
||||||
|
VTKM_CONT_EXPORT
|
||||||
|
vtkm::cont::ArrayHandle<vtkm::Id, ShapeStorageTag> &
|
||||||
|
GetShapesArray() const { return this->Shapes; }
|
||||||
|
|
||||||
|
VTKM_CONT_EXPORT
|
||||||
|
vtkm::cont::ArrayHandle<vtkm::Id, NumIndicesStorageTag> &
|
||||||
|
GetNumIndicesArray() const { return this->NumIndices; }
|
||||||
|
|
||||||
|
VTKM_CONT_EXPORT
|
||||||
|
const vtkm::cont::ArrayHandle<vtkm::Id, ConnectivityStorageTag> &
|
||||||
|
GetConnectivityArray() const { return this->Connectivity; }
|
||||||
|
|
||||||
|
VTKM_CONT_EXPORT
|
||||||
|
const vtkm::cont::ArrayHandle<vtkm::Id> &
|
||||||
|
GetCellToConnectivityIndexArray() const {
|
||||||
|
return this->MapCellToConnectivityIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ExplicitConnectivityType NodesOfCellsConnectivity;
|
vtkm::Id ConnectivityLength;
|
||||||
|
vtkm::Id NumberOfCells;
|
||||||
|
ShapeArrayType Shapes;
|
||||||
|
NumIndicesArrayType NumIndices;
|
||||||
|
ConnectivityArrayType Connectivity;
|
||||||
|
MapCellToConnectivityIndexArrayType MapCellToConnectivityIndex;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -21,9 +21,10 @@
|
|||||||
#define vtk_m_cont_CellSetStructured_h
|
#define vtk_m_cont_CellSetStructured_h
|
||||||
|
|
||||||
#include <vtkm/cont/CellSet.h>
|
#include <vtkm/cont/CellSet.h>
|
||||||
#include <vtkm/RegularConnectivity.h>
|
#include <vtkm/cont/DeviceAdapter.h>
|
||||||
#include <vtkm/TopologyElementTag.h>
|
#include <vtkm/TopologyElementTag.h>
|
||||||
#include <vtkm/internal/ConnectivityStructuredInternals.h>
|
#include <vtkm/internal/ConnectivityStructuredInternals.h>
|
||||||
|
#include <vtkm/exec/ConnectivityStructured.h>
|
||||||
|
|
||||||
namespace vtkm {
|
namespace vtkm {
|
||||||
namespace cont {
|
namespace cont {
|
||||||
@ -33,9 +34,15 @@ namespace cont {
|
|||||||
template<vtkm::IdComponent DIMENSION>
|
template<vtkm::IdComponent DIMENSION>
|
||||||
class CellSetStructured : public CellSet
|
class CellSetStructured : public CellSet
|
||||||
{
|
{
|
||||||
|
private:
|
||||||
|
typedef vtkm::internal::ConnectivityStructuredInternals<DIMENSION>
|
||||||
|
InternalsType;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static const vtkm::IdComponent Dimension=DIMENSION;
|
static const vtkm::IdComponent Dimension=DIMENSION;
|
||||||
|
|
||||||
|
typedef typename InternalsType::SchedulingRangeType SchedulingRangeType;
|
||||||
|
|
||||||
VTKM_CONT_EXPORT
|
VTKM_CONT_EXPORT
|
||||||
CellSetStructured(const std::string &name = std::string())
|
CellSetStructured(const std::string &name = std::string())
|
||||||
: CellSet(name,Dimension)
|
: CellSet(name,Dimension)
|
||||||
@ -43,38 +50,56 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
virtual vtkm::Id GetNumCells() const
|
virtual vtkm::Id GetNumberOfCells() const
|
||||||
{
|
{
|
||||||
return this->Structure.GetNumberOfCells();
|
return this->Structure.GetNumberOfCells();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename FromTopology, typename ToTopology>
|
virtual vtkm::Id GetNumberOfPoints() const
|
||||||
struct ConnectivityType {
|
|
||||||
VTKM_IS_TOPOLOGY_ELEMENT_TAG(FromTopology);
|
|
||||||
VTKM_IS_TOPOLOGY_ELEMENT_TAG(ToTopology);
|
|
||||||
typedef vtkm::RegularConnectivity<FromTopology,ToTopology,Dimension> Type;
|
|
||||||
};
|
|
||||||
|
|
||||||
VTKM_CONT_EXPORT
|
|
||||||
vtkm::RegularConnectivity<
|
|
||||||
vtkm::TopologyElementTagPoint,vtkm::TopologyElementTagCell,Dimension>
|
|
||||||
GetNodeToCellConnectivity() const
|
|
||||||
{
|
{
|
||||||
typedef vtkm::RegularConnectivity<vtkm::TopologyElementTagPoint,
|
return this->Structure.GetNumberOfPoints();
|
||||||
vtkm::TopologyElementTagCell,
|
}
|
||||||
Dimension> NodeToCellConnectivity;
|
|
||||||
return NodeToCellConnectivity(this->Structure);
|
void SetPointDimensions(SchedulingRangeType dimensions)
|
||||||
|
{
|
||||||
|
this->Structure.SetPointDimensions(dimensions);
|
||||||
}
|
}
|
||||||
|
|
||||||
VTKM_CONT_EXPORT
|
VTKM_CONT_EXPORT
|
||||||
vtkm::RegularConnectivity<
|
vtkm::IdComponent GetNumberOfNodesPerCell() const
|
||||||
vtkm::TopologyElementTagCell,vtkm::TopologyElementTagPoint,Dimension>
|
|
||||||
GetCellToNodeConnectivity() const
|
|
||||||
{
|
{
|
||||||
typedef vtkm::RegularConnectivity<vtkm::TopologyElementTagCell,
|
return this->Structure.GetNumberOfNodesPerCell();
|
||||||
vtkm::TopologyElementTagPoint,
|
}
|
||||||
Dimension> CellToNodeConnectivity;
|
|
||||||
return CellToNodeConnectivity(this->Structure);
|
VTKM_CONT_EXPORT
|
||||||
|
vtkm::CellType GetCellShapeType() const
|
||||||
|
{
|
||||||
|
return this->Structure.GetCellShapeType();
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename TopologyElement>
|
||||||
|
VTKM_CONT_EXPORT
|
||||||
|
SchedulingRangeType GetSchedulingRange(TopologyElement) const {
|
||||||
|
VTKM_IS_TOPOLOGY_ELEMENT_TAG(TopologyElement);
|
||||||
|
return this->Structure.GetSchedulingRange(TopologyElement());
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename DeviceAdapter, typename FromTopology, typename ToTopology>
|
||||||
|
struct ExecutionTypes {
|
||||||
|
VTKM_IS_DEVICE_ADAPTER_TAG(DeviceAdapter);
|
||||||
|
VTKM_IS_TOPOLOGY_ELEMENT_TAG(FromTopology);
|
||||||
|
VTKM_IS_TOPOLOGY_ELEMENT_TAG(ToTopology);
|
||||||
|
typedef vtkm::exec::ConnectivityStructured<FromTopology,ToTopology,Dimension> ExecObjectType;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename DeviceAdapter, typename FromTopology, typename ToTopology>
|
||||||
|
typename ExecutionTypes<DeviceAdapter,FromTopology,ToTopology>::ExecObjectType
|
||||||
|
PrepareForInput(DeviceAdapter, FromTopology, ToTopology) const
|
||||||
|
{
|
||||||
|
typedef typename
|
||||||
|
ExecutionTypes<DeviceAdapter,FromTopology,ToTopology>::ExecObjectType
|
||||||
|
ConnectivityType;
|
||||||
|
return ConnectivityType(this->Structure);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void PrintSummary(std::ostream &out) const
|
virtual void PrintSummary(std::ostream &out) const
|
||||||
@ -84,8 +109,8 @@ public:
|
|||||||
this->Structure.PrintSummary(out);
|
this->Structure.PrintSummary(out);
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
private:
|
||||||
vtkm::internal::ConnectivityStructuredInternals<Dimension> Structure;
|
InternalsType Structure;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,251 +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 2015 Sandia Corporation.
|
|
||||||
// Copyright 2015 UT-Battelle, LLC.
|
|
||||||
// Copyright 2015 Los Alamos National Security.
|
|
||||||
//
|
|
||||||
// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
|
|
||||||
// the U.S. Government retains certain rights in this software.
|
|
||||||
//
|
|
||||||
// Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National
|
|
||||||
// Laboratory (LANL), the U.S. Government retains certain rights in
|
|
||||||
// this software.
|
|
||||||
//============================================================================
|
|
||||||
#ifndef vtk_m_cont_ConnectivityExplicit_h
|
|
||||||
#define vtk_m_cont_ConnectivityExplicit_h
|
|
||||||
|
|
||||||
#include <vtkm/CellType.h>
|
|
||||||
#include <vtkm/exec/ConnectivityExplicit.h>
|
|
||||||
#include <vtkm/cont/ArrayHandle.h>
|
|
||||||
#include <vtkm/cont/Field.h>
|
|
||||||
#include <vtkm/cont/DynamicArrayHandle.h>
|
|
||||||
#include <vtkm/cont/internal/ArrayPortalFromIterators.h>
|
|
||||||
|
|
||||||
namespace vtkm {
|
|
||||||
namespace cont {
|
|
||||||
|
|
||||||
template<typename ShapeStorageTag = VTKM_DEFAULT_STORAGE_TAG,
|
|
||||||
typename NumIndicesStorageTag = VTKM_DEFAULT_STORAGE_TAG,
|
|
||||||
typename ConnectivityStorageTag = VTKM_DEFAULT_STORAGE_TAG >
|
|
||||||
class ConnectivityExplicit
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
VTKM_CONT_EXPORT
|
|
||||||
ConnectivityExplicit()
|
|
||||||
{
|
|
||||||
this->NumShapes = 0;
|
|
||||||
this->ConnectivityLength = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
VTKM_CONT_EXPORT
|
|
||||||
vtkm::Id GetSchedulingDimensions() const
|
|
||||||
{
|
|
||||||
return this->Shapes.GetNumberOfValues();
|
|
||||||
}
|
|
||||||
|
|
||||||
VTKM_CONT_EXPORT
|
|
||||||
vtkm::Id GetNumberOfElements() const
|
|
||||||
{
|
|
||||||
return this->Shapes.GetNumberOfValues();
|
|
||||||
}
|
|
||||||
VTKM_CONT_EXPORT
|
|
||||||
vtkm::Id GetNumberOfIndices(vtkm::Id index) const
|
|
||||||
{
|
|
||||||
return this->NumIndices.GetPortalConstControl().Get(index);
|
|
||||||
}
|
|
||||||
VTKM_CONT_EXPORT
|
|
||||||
vtkm::Id GetElementShapeType(vtkm::Id index) const
|
|
||||||
{
|
|
||||||
return this->Shapes.GetPortalConstControl().Get(index);
|
|
||||||
}
|
|
||||||
template <vtkm::IdComponent ItemTupleLength>
|
|
||||||
VTKM_CONT_EXPORT
|
|
||||||
void GetIndices(vtkm::Id index,
|
|
||||||
vtkm::Vec<vtkm::Id,ItemTupleLength> &ids) const
|
|
||||||
{
|
|
||||||
vtkm::Id numIndices = this->GetNumberOfIndices(index);
|
|
||||||
vtkm::Id start =
|
|
||||||
this->MapCellToConnectivityIndex.GetPortalConstControl().Get(index);
|
|
||||||
for (vtkm::IdComponent i=0; i<numIndices && i<ItemTupleLength; i++)
|
|
||||||
ids[i] = this->Connectivity.GetPortalConstControl().Get(start+i);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// First method to add cells -- one at a time.
|
|
||||||
VTKM_CONT_EXPORT
|
|
||||||
void PrepareToAddCells(vtkm::Id numShapes, vtkm::Id connectivityMaxLen)
|
|
||||||
{
|
|
||||||
this->Shapes.Allocate(numShapes);
|
|
||||||
this->NumIndices.Allocate(numShapes);
|
|
||||||
this->Connectivity.Allocate(connectivityMaxLen);
|
|
||||||
this->MapCellToConnectivityIndex.Allocate(numShapes);
|
|
||||||
this->NumShapes = 0;
|
|
||||||
this->ConnectivityLength = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <vtkm::IdComponent ItemTupleLength>
|
|
||||||
VTKM_CONT_EXPORT
|
|
||||||
void AddCell(vtkm::CellType cellType,
|
|
||||||
int numVertices,
|
|
||||||
const vtkm::Vec<vtkm::Id,ItemTupleLength> &ids)
|
|
||||||
{
|
|
||||||
this->Shapes.GetPortalControl().Set(this->NumShapes, cellType);
|
|
||||||
this->NumIndices.GetPortalControl().Set(this->NumShapes, numVertices);
|
|
||||||
for (vtkm::IdComponent i=0; i < numVertices; ++i)
|
|
||||||
{
|
|
||||||
this->Connectivity.GetPortalControl().Set(
|
|
||||||
this->ConnectivityLength+i,ids[i]);
|
|
||||||
}
|
|
||||||
this->MapCellToConnectivityIndex.GetPortalControl().Set(
|
|
||||||
this->NumShapes, this->ConnectivityLength);
|
|
||||||
this->NumShapes++;
|
|
||||||
this->ConnectivityLength += numVertices;
|
|
||||||
}
|
|
||||||
|
|
||||||
VTKM_CONT_EXPORT
|
|
||||||
void CompleteAddingCells()
|
|
||||||
{
|
|
||||||
Connectivity.Shrink(ConnectivityLength);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Second method to add cells -- all at once.
|
|
||||||
/// Copies the data from the vectors, so they can be released.
|
|
||||||
VTKM_CONT_EXPORT
|
|
||||||
void FillViaCopy(const std::vector<vtkm::Id> &cellTypes,
|
|
||||||
const std::vector<vtkm::Id> &numIndices,
|
|
||||||
const std::vector<vtkm::Id> &connectivity)
|
|
||||||
{
|
|
||||||
|
|
||||||
this->Shapes.Allocate( static_cast<vtkm::Id>(cellTypes.size()) );
|
|
||||||
std::copy(cellTypes.begin(), cellTypes.end(),
|
|
||||||
vtkm::cont::ArrayPortalToIteratorBegin(this->Shapes.GetPortalControl()));
|
|
||||||
|
|
||||||
this->NumIndices.Allocate( static_cast<vtkm::Id>(numIndices.size()) );
|
|
||||||
std::copy(numIndices.begin(), numIndices.end(),
|
|
||||||
vtkm::cont::ArrayPortalToIteratorBegin(this->NumIndices.GetPortalControl()));
|
|
||||||
|
|
||||||
this->Connectivity.Allocate( static_cast<vtkm::Id>(connectivity.size()) );
|
|
||||||
std::copy(connectivity.begin(), connectivity.end(),
|
|
||||||
vtkm::cont::ArrayPortalToIteratorBegin(this->Connectivity.GetPortalControl()));
|
|
||||||
|
|
||||||
this->NumShapes = this->Shapes.GetNumberOfValues();
|
|
||||||
this->ConnectivityLength = this->Connectivity.GetNumberOfValues();
|
|
||||||
|
|
||||||
// allocate and build reverse index
|
|
||||||
this->MapCellToConnectivityIndex.Allocate(NumShapes);
|
|
||||||
vtkm::Id counter = 0;
|
|
||||||
for (vtkm::Id i=0; i<this->NumShapes; ++i)
|
|
||||||
{
|
|
||||||
this->MapCellToConnectivityIndex.GetPortalControl().Set(i, counter);
|
|
||||||
counter += this->NumIndices.GetPortalConstControl().Get(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Second method to add cells -- all at once.
|
|
||||||
/// Assigns the array handles to the explicit connectivity. This is
|
|
||||||
/// the way you can fill the memory from another system without copying
|
|
||||||
void Fill(const vtkm::cont::ArrayHandle<vtkm::Id, ShapeStorageTag> &cellTypes,
|
|
||||||
const vtkm::cont::ArrayHandle<vtkm::Id, NumIndicesStorageTag> &numIndices,
|
|
||||||
const vtkm::cont::ArrayHandle<vtkm::Id, ConnectivityStorageTag> &connectivity)
|
|
||||||
{
|
|
||||||
this->Shapes = cellTypes;
|
|
||||||
this->NumIndices = numIndices;
|
|
||||||
this->Connectivity = connectivity;
|
|
||||||
|
|
||||||
this->NumShapes = this->Shapes.GetNumberOfValues();
|
|
||||||
this->ConnectivityLength = this->Connectivity.GetNumberOfValues();
|
|
||||||
|
|
||||||
// allocate and build reverse index
|
|
||||||
this->MapCellToConnectivityIndex.Allocate(this->NumShapes);
|
|
||||||
vtkm::Id counter = 0;
|
|
||||||
for (vtkm::Id i=0; i<this->NumShapes; ++i)
|
|
||||||
{
|
|
||||||
this->MapCellToConnectivityIndex.GetPortalControl().Set(i, counter);
|
|
||||||
counter += this->NumIndices.GetPortalConstControl().Get(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename DeviceAdapterTag>
|
|
||||||
struct ExecutionTypes
|
|
||||||
{
|
|
||||||
typedef typename vtkm::cont::ArrayHandle<vtkm::Id, ShapeStorageTag> ShapeHandle;
|
|
||||||
typedef typename vtkm::cont::ArrayHandle<vtkm::Id, NumIndicesStorageTag> IndiceHandle;
|
|
||||||
typedef typename vtkm::cont::ArrayHandle<vtkm::Id, ConnectivityStorageTag> ConnectivityHandle;
|
|
||||||
typedef vtkm::cont::ArrayHandle<vtkm::Id> MapCellToConnectivityHandle;
|
|
||||||
|
|
||||||
typedef typename ShapeHandle::template ExecutionTypes<DeviceAdapterTag>::PortalConst ShapePortalType;
|
|
||||||
typedef typename IndiceHandle::template ExecutionTypes<DeviceAdapterTag>::PortalConst IndicePortalType;
|
|
||||||
typedef typename ConnectivityHandle::template ExecutionTypes<DeviceAdapterTag>::PortalConst ConnectivityPortalType;
|
|
||||||
typedef typename MapCellToConnectivityHandle::template ExecutionTypes<DeviceAdapterTag>::PortalConst MapConnectivityPortalType;
|
|
||||||
|
|
||||||
typedef vtkm::exec::ConnectivityExplicit<ShapePortalType,
|
|
||||||
IndicePortalType,
|
|
||||||
ConnectivityPortalType,
|
|
||||||
MapConnectivityPortalType
|
|
||||||
> ExecObjectType;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename DeviceAdapterTag>
|
|
||||||
typename ExecutionTypes<DeviceAdapterTag>::ExecObjectType
|
|
||||||
PrepareForInput(DeviceAdapterTag tag) const
|
|
||||||
{
|
|
||||||
typedef typename ExecutionTypes<DeviceAdapterTag>::ExecObjectType ExecObjType;
|
|
||||||
return ExecObjType(this->Shapes.PrepareForInput(tag),
|
|
||||||
this->NumIndices.PrepareForInput(tag),
|
|
||||||
this->Connectivity.PrepareForInput(tag),
|
|
||||||
this->MapCellToConnectivityIndex.PrepareForInput(tag));
|
|
||||||
}
|
|
||||||
|
|
||||||
VTKM_CONT_EXPORT
|
|
||||||
virtual void PrintSummary(std::ostream &out) const
|
|
||||||
{
|
|
||||||
out << " ConnectivityExplicit: #shapes= " << this->NumShapes
|
|
||||||
<< " #connectivity= " << ConnectivityLength << std::endl;
|
|
||||||
out <<" Shapes: ";
|
|
||||||
printSummary_ArrayHandle(Shapes, out);
|
|
||||||
out << std::endl;
|
|
||||||
out << " NumIndices: ";
|
|
||||||
printSummary_ArrayHandle(NumIndices, out);
|
|
||||||
out << std::endl;
|
|
||||||
out << " Connectivity: ";
|
|
||||||
printSummary_ArrayHandle(Connectivity, out);
|
|
||||||
out << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
VTKM_CONT_EXPORT
|
|
||||||
vtkm::cont::ArrayHandle<vtkm::Id, ShapeStorageTag> &
|
|
||||||
GetShapesArray() const { return this->Shapes; }
|
|
||||||
|
|
||||||
VTKM_CONT_EXPORT
|
|
||||||
vtkm::cont::ArrayHandle<vtkm::Id, NumIndicesStorageTag> &
|
|
||||||
GetNumIndicesArray() const { return this->NumIndices; }
|
|
||||||
|
|
||||||
VTKM_CONT_EXPORT
|
|
||||||
const vtkm::cont::ArrayHandle<vtkm::Id, ConnectivityStorageTag> &
|
|
||||||
GetConnectivityArray() const { return this->Connectivity; }
|
|
||||||
|
|
||||||
VTKM_CONT_EXPORT
|
|
||||||
const vtkm::cont::ArrayHandle<vtkm::Id> &
|
|
||||||
GetCellToConnectivityIndexArray() const {
|
|
||||||
return this->MapCellToConnectivityIndex;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
vtkm::Id ConnectivityLength;
|
|
||||||
vtkm::Id NumShapes;
|
|
||||||
vtkm::cont::ArrayHandle<vtkm::Id, ShapeStorageTag> Shapes;
|
|
||||||
vtkm::cont::ArrayHandle<vtkm::Id, NumIndicesStorageTag> NumIndices;
|
|
||||||
vtkm::cont::ArrayHandle<vtkm::Id, ConnectivityStorageTag> Connectivity;
|
|
||||||
vtkm::cont::ArrayHandle<vtkm::Id> MapCellToConnectivityIndex;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
} // namespace vtkm::cont
|
|
||||||
|
|
||||||
#endif //vtk_m_cont_ConnectivityExplicit_h
|
|
@ -44,16 +44,17 @@ struct Transport<vtkm::cont::arg::TransportTagTopologyIn, ContObjectType, Device
|
|||||||
VTKM_IS_CELL_SET(ContObjectType);
|
VTKM_IS_CELL_SET(ContObjectType);
|
||||||
|
|
||||||
typedef typename ContObjectType
|
typedef typename ContObjectType
|
||||||
::template ConnectivityType<
|
::template ExecutionTypes<
|
||||||
vtkm::TopologyElementTagPoint,vtkm::TopologyElementTagCell>::Type
|
Device,vtkm::TopologyElementTagPoint,vtkm::TopologyElementTagCell>
|
||||||
::template ExecutionTypes<Device>
|
|
||||||
::ExecObjectType ExecObjectType;
|
::ExecObjectType ExecObjectType;
|
||||||
|
|
||||||
VTKM_CONT_EXPORT
|
VTKM_CONT_EXPORT
|
||||||
ExecObjectType operator()(const ContObjectType &object, vtkm::Id) const
|
ExecObjectType operator()(const ContObjectType &object, vtkm::Id) const
|
||||||
{
|
{
|
||||||
//create CUDA version of connectivity array.
|
//create CUDA version of connectivity array.
|
||||||
return object.GetNodeToCellConnectivity().PrepareForInput(Device());
|
return object.PrepareForInput(Device(),
|
||||||
|
vtkm::TopologyElementTagPoint(),
|
||||||
|
vtkm::TopologyElementTagCell());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -48,36 +48,36 @@ public:
|
|||||||
inline vtkm::cont::DataSet
|
inline vtkm::cont::DataSet
|
||||||
MakeTestDataSet::Make2DRegularDataSet0()
|
MakeTestDataSet::Make2DRegularDataSet0()
|
||||||
{
|
{
|
||||||
vtkm::cont::DataSet ds;
|
vtkm::cont::DataSet dataSet;
|
||||||
|
|
||||||
const int nVerts = 6;
|
const int nVerts = 6;
|
||||||
vtkm::Float32 xVals[nVerts] = {0, 1, 2, 0, 1, 2};
|
vtkm::Float32 xVals[nVerts] = {0, 1, 2, 0, 1, 2};
|
||||||
vtkm::Float32 yVals[nVerts] = {0, 0, 0, 1, 1, 1};
|
vtkm::Float32 yVals[nVerts] = {0, 0, 0, 1, 1, 1};
|
||||||
vtkm::Float32 vars[nVerts] = {10.1f, 20.1f, 30.1f, 40.1f, 50.1f, 60.1f};
|
vtkm::Float32 vars[nVerts] = {10.1f, 20.1f, 30.1f, 40.1f, 50.1f, 60.1f};
|
||||||
|
|
||||||
ds.AddField(Field("x", 1, vtkm::cont::Field::ASSOC_POINTS, xVals, nVerts));
|
dataSet.AddField(Field("x", 1, vtkm::cont::Field::ASSOC_POINTS, xVals, nVerts));
|
||||||
ds.AddField(Field("y", 1, vtkm::cont::Field::ASSOC_POINTS, yVals, nVerts));
|
dataSet.AddField(Field("y", 1, vtkm::cont::Field::ASSOC_POINTS, yVals, nVerts));
|
||||||
ds.AddCoordinateSystem(vtkm::cont::CoordinateSystem("x","y"));
|
dataSet.AddCoordinateSystem(vtkm::cont::CoordinateSystem("x","y"));
|
||||||
|
|
||||||
//set node scalar.
|
//set node scalar.
|
||||||
ds.AddField(Field("nodevar", 1, vtkm::cont::Field::ASSOC_POINTS, vars, nVerts));
|
dataSet.AddField(Field("nodevar", 1, vtkm::cont::Field::ASSOC_POINTS, vars, nVerts));
|
||||||
|
|
||||||
//create scalar.
|
//create scalar.
|
||||||
vtkm::Float32 cellvar[2] = {100.1f, 200.1f};
|
vtkm::Float32 cellvar[2] = {100.1f, 200.1f};
|
||||||
ds.AddField(Field("cellvar", 1, vtkm::cont::Field::ASSOC_CELL_SET, "cells", cellvar, 2));
|
dataSet.AddField(Field("cellvar", 1, vtkm::cont::Field::ASSOC_CELL_SET, "cells", cellvar, 2));
|
||||||
|
|
||||||
vtkm::cont::CellSetStructured<2> cellSet("cells");
|
vtkm::cont::CellSetStructured<2> cellSet("cells");
|
||||||
//Set regular structure
|
//Set regular structure
|
||||||
cellSet.Structure.SetPointDimensions( vtkm::make_Vec(3,2) );
|
cellSet.SetPointDimensions( vtkm::make_Vec(3,2) );
|
||||||
ds.AddCellSet(cellSet);
|
dataSet.AddCellSet(cellSet);
|
||||||
|
|
||||||
return ds;
|
return dataSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline vtkm::cont::DataSet
|
inline vtkm::cont::DataSet
|
||||||
MakeTestDataSet::Make3DRegularDataSet0()
|
MakeTestDataSet::Make3DRegularDataSet0()
|
||||||
{
|
{
|
||||||
vtkm::cont::DataSet ds;
|
vtkm::cont::DataSet dataSet;
|
||||||
|
|
||||||
const int nVerts = 18;
|
const int nVerts = 18;
|
||||||
vtkm::Float32 xVals[nVerts] = {0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2};
|
vtkm::Float32 xVals[nVerts] = {0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2};
|
||||||
@ -87,30 +87,30 @@ MakeTestDataSet::Make3DRegularDataSet0()
|
|||||||
100.3f, 110.3f, 120.3f, 130.4f, 140.4f, 150.4f, 160.4f, 170.5f,
|
100.3f, 110.3f, 120.3f, 130.4f, 140.4f, 150.4f, 160.4f, 170.5f,
|
||||||
180.5f};
|
180.5f};
|
||||||
|
|
||||||
ds.AddField(Field("x", 1, vtkm::cont::Field::ASSOC_POINTS, xVals, nVerts));
|
dataSet.AddField(Field("x", 1, vtkm::cont::Field::ASSOC_POINTS, xVals, nVerts));
|
||||||
ds.AddField(Field("y", 1, vtkm::cont::Field::ASSOC_POINTS, yVals, nVerts));
|
dataSet.AddField(Field("y", 1, vtkm::cont::Field::ASSOC_POINTS, yVals, nVerts));
|
||||||
ds.AddField(Field("z", 1, vtkm::cont::Field::ASSOC_POINTS, zVals, nVerts));
|
dataSet.AddField(Field("z", 1, vtkm::cont::Field::ASSOC_POINTS, zVals, nVerts));
|
||||||
ds.AddCoordinateSystem(vtkm::cont::CoordinateSystem("x","y","z"));
|
dataSet.AddCoordinateSystem(vtkm::cont::CoordinateSystem("x","y","z"));
|
||||||
|
|
||||||
//Set node scalar
|
//Set node scalar
|
||||||
ds.AddField(Field("nodevar", 1, vtkm::cont::Field::ASSOC_POINTS, vars, nVerts));
|
dataSet.AddField(Field("nodevar", 1, vtkm::cont::Field::ASSOC_POINTS, vars, nVerts));
|
||||||
|
|
||||||
//Set cell scalar
|
//Set cell scalar
|
||||||
vtkm::Float32 cellvar[4] = {100.1f, 100.2f, 100.3f, 100.4f};
|
vtkm::Float32 cellvar[4] = {100.1f, 100.2f, 100.3f, 100.4f};
|
||||||
ds.AddField(Field("cellvar", 1, vtkm::cont::Field::ASSOC_CELL_SET, "cells", cellvar, 4));
|
dataSet.AddField(Field("cellvar", 1, vtkm::cont::Field::ASSOC_CELL_SET, "cells", cellvar, 4));
|
||||||
|
|
||||||
static const vtkm::IdComponent dim = 3;
|
static const vtkm::IdComponent dim = 3;
|
||||||
vtkm::cont::CellSetStructured<dim> cellSet("cells");
|
vtkm::cont::CellSetStructured<dim> cellSet("cells");
|
||||||
cellSet.Structure.SetPointDimensions( vtkm::make_Vec(3,2,3) );
|
cellSet.SetPointDimensions( vtkm::make_Vec(3,2,3) );
|
||||||
ds.AddCellSet(cellSet);
|
dataSet.AddCellSet(cellSet);
|
||||||
|
|
||||||
return ds;
|
return dataSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline vtkm::cont::DataSet
|
inline vtkm::cont::DataSet
|
||||||
MakeTestDataSet::Make3DExplicitDataSet0()
|
MakeTestDataSet::Make3DExplicitDataSet0()
|
||||||
{
|
{
|
||||||
vtkm::cont::DataSet ds;
|
vtkm::cont::DataSet dataSet;
|
||||||
|
|
||||||
const int nVerts = 5;
|
const int nVerts = 5;
|
||||||
vtkm::Float32 xVals[nVerts] = {0, 1, 1, 2, 2};
|
vtkm::Float32 xVals[nVerts] = {0, 1, 1, 2, 2};
|
||||||
@ -118,17 +118,17 @@ MakeTestDataSet::Make3DExplicitDataSet0()
|
|||||||
vtkm::Float32 zVals[nVerts] = {0, 0, 0, 0, 0};
|
vtkm::Float32 zVals[nVerts] = {0, 0, 0, 0, 0};
|
||||||
vtkm::Float32 vars[nVerts] = {10.1f, 20.1f, 30.2f, 40.2f, 50.3f};
|
vtkm::Float32 vars[nVerts] = {10.1f, 20.1f, 30.2f, 40.2f, 50.3f};
|
||||||
|
|
||||||
ds.AddField(Field("x", 1, vtkm::cont::Field::ASSOC_POINTS, xVals, nVerts));
|
dataSet.AddField(Field("x", 1, vtkm::cont::Field::ASSOC_POINTS, xVals, nVerts));
|
||||||
ds.AddField(Field("y", 1, vtkm::cont::Field::ASSOC_POINTS, yVals, nVerts));
|
dataSet.AddField(Field("y", 1, vtkm::cont::Field::ASSOC_POINTS, yVals, nVerts));
|
||||||
ds.AddField(Field("z", 1, vtkm::cont::Field::ASSOC_POINTS, zVals, nVerts));
|
dataSet.AddField(Field("z", 1, vtkm::cont::Field::ASSOC_POINTS, zVals, nVerts));
|
||||||
ds.AddCoordinateSystem(vtkm::cont::CoordinateSystem("x","y","z"));
|
dataSet.AddCoordinateSystem(vtkm::cont::CoordinateSystem("x","y","z"));
|
||||||
|
|
||||||
//Set node scalar
|
//Set node scalar
|
||||||
ds.AddField(Field("nodevar", 1, vtkm::cont::Field::ASSOC_POINTS, vars, nVerts));
|
dataSet.AddField(Field("nodevar", 1, vtkm::cont::Field::ASSOC_POINTS, vars, nVerts));
|
||||||
|
|
||||||
//Set cell scalar
|
//Set cell scalar
|
||||||
vtkm::Float32 cellvar[2] = {100.1f, 100.2f};
|
vtkm::Float32 cellvar[2] = {100.1f, 100.2f};
|
||||||
ds.AddField(Field("cellvar", 1, vtkm::cont::Field::ASSOC_CELL_SET, "cells", cellvar, 2));
|
dataSet.AddField(Field("cellvar", 1, vtkm::cont::Field::ASSOC_CELL_SET, "cells", cellvar, 2));
|
||||||
|
|
||||||
//Add connectivity
|
//Add connectivity
|
||||||
std::vector<vtkm::Id> shapes;
|
std::vector<vtkm::Id> shapes;
|
||||||
@ -150,19 +150,18 @@ MakeTestDataSet::Make3DExplicitDataSet0()
|
|||||||
conn.push_back(3);
|
conn.push_back(3);
|
||||||
conn.push_back(4);
|
conn.push_back(4);
|
||||||
|
|
||||||
vtkm::cont::CellSetExplicit<> cs("cells", 2);
|
vtkm::cont::CellSetExplicit<> cellSet("cells", 2);
|
||||||
vtkm::cont::ConnectivityExplicit<> &ec = cs.NodesOfCellsConnectivity;
|
cellSet.FillViaCopy(shapes, numindices, conn);
|
||||||
ec.FillViaCopy(shapes, numindices, conn);
|
|
||||||
|
|
||||||
ds.AddCellSet(cs);
|
dataSet.AddCellSet(cellSet);
|
||||||
|
|
||||||
return ds;
|
return dataSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline vtkm::cont::DataSet
|
inline vtkm::cont::DataSet
|
||||||
MakeTestDataSet::Make3DExplicitDataSet1()
|
MakeTestDataSet::Make3DExplicitDataSet1()
|
||||||
{
|
{
|
||||||
vtkm::cont::DataSet ds;
|
vtkm::cont::DataSet dataSet;
|
||||||
|
|
||||||
const int nVerts = 5;
|
const int nVerts = 5;
|
||||||
vtkm::Float32 xVals[nVerts] = {0, 1, 1, 2, 2};
|
vtkm::Float32 xVals[nVerts] = {0, 1, 1, 2, 2};
|
||||||
@ -170,30 +169,29 @@ MakeTestDataSet::Make3DExplicitDataSet1()
|
|||||||
vtkm::Float32 zVals[nVerts] = {0, 0, 0, 0, 0};
|
vtkm::Float32 zVals[nVerts] = {0, 0, 0, 0, 0};
|
||||||
vtkm::Float32 vars[nVerts] = {10.1f, 20.1f, 30.2f, 40.2f, 50.3f};
|
vtkm::Float32 vars[nVerts] = {10.1f, 20.1f, 30.2f, 40.2f, 50.3f};
|
||||||
|
|
||||||
ds.AddField(Field("x", 1, vtkm::cont::Field::ASSOC_POINTS, xVals, nVerts));
|
dataSet.AddField(Field("x", 1, vtkm::cont::Field::ASSOC_POINTS, xVals, nVerts));
|
||||||
ds.AddField(Field("y", 1, vtkm::cont::Field::ASSOC_POINTS, yVals, nVerts));
|
dataSet.AddField(Field("y", 1, vtkm::cont::Field::ASSOC_POINTS, yVals, nVerts));
|
||||||
ds.AddField(Field("z", 1, vtkm::cont::Field::ASSOC_POINTS, zVals, nVerts));
|
dataSet.AddField(Field("z", 1, vtkm::cont::Field::ASSOC_POINTS, zVals, nVerts));
|
||||||
ds.AddCoordinateSystem(vtkm::cont::CoordinateSystem("x","y","z"));
|
dataSet.AddCoordinateSystem(vtkm::cont::CoordinateSystem("x","y","z"));
|
||||||
|
|
||||||
//Set node scalar
|
//Set node scalar
|
||||||
ds.AddField(Field("nodevar", 1, vtkm::cont::Field::ASSOC_POINTS, vars, nVerts));
|
dataSet.AddField(Field("nodevar", 1, vtkm::cont::Field::ASSOC_POINTS, vars, nVerts));
|
||||||
|
|
||||||
//Set cell scalar
|
//Set cell scalar
|
||||||
vtkm::Float32 cellvar[2] = {100.1f, 100.2f};
|
vtkm::Float32 cellvar[2] = {100.1f, 100.2f};
|
||||||
ds.AddField(Field("cellvar", 1, vtkm::cont::Field::ASSOC_CELL_SET, "cells", cellvar, 2));
|
dataSet.AddField(Field("cellvar", 1, vtkm::cont::Field::ASSOC_CELL_SET, "cells", cellvar, 2));
|
||||||
|
|
||||||
vtkm::cont::CellSetExplicit<> cellSet("cells", 2);
|
vtkm::cont::CellSetExplicit<> cellSet("cells", 2);
|
||||||
vtkm::cont::ConnectivityExplicit<> &ec = cellSet.NodesOfCellsConnectivity;
|
|
||||||
|
|
||||||
ec.PrepareToAddCells(2, 7);
|
cellSet.PrepareToAddCells(2, 7);
|
||||||
ec.AddCell(vtkm::VTKM_TRIANGLE, 3, make_Vec<vtkm::Id>(0,1,2));
|
cellSet.AddCell(vtkm::VTKM_TRIANGLE, 3, make_Vec<vtkm::Id>(0,1,2));
|
||||||
ec.AddCell(vtkm::VTKM_QUAD, 4, make_Vec<vtkm::Id>(2,1,3,4));
|
cellSet.AddCell(vtkm::VTKM_QUAD, 4, make_Vec<vtkm::Id>(2,1,3,4));
|
||||||
ec.CompleteAddingCells();
|
cellSet.CompleteAddingCells();
|
||||||
|
|
||||||
//todo this need to be a reference/shared_ptr style class
|
//todo this need to be a reference/shared_ptr style class
|
||||||
ds.AddCellSet(cellSet);
|
dataSet.AddCellSet(cellSet);
|
||||||
|
|
||||||
return ds;
|
return dataSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline vtkm::cont::DataSet
|
inline vtkm::cont::DataSet
|
||||||
@ -217,32 +215,31 @@ MakeTestDataSet::Make3DExplicitDataSetCowNose(double *pBounds)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// create DataSet
|
// create DataSet
|
||||||
vtkm::cont::DataSet ds;
|
vtkm::cont::DataSet dataSet;
|
||||||
ds.AddField(Field("xyz", 1, vtkm::cont::Field::ASSOC_POINTS, points, nVerts));
|
dataSet.AddField(Field("xyz", 1, vtkm::cont::Field::ASSOC_POINTS, points, nVerts));
|
||||||
ds.AddField(Field("x", 1, vtkm::cont::Field::ASSOC_POINTS, xVals, nVerts));
|
dataSet.AddField(Field("x", 1, vtkm::cont::Field::ASSOC_POINTS, xVals, nVerts));
|
||||||
ds.AddField(Field("y", 1, vtkm::cont::Field::ASSOC_POINTS, yVals, nVerts));
|
dataSet.AddField(Field("y", 1, vtkm::cont::Field::ASSOC_POINTS, yVals, nVerts));
|
||||||
ds.AddField(Field("z", 1, vtkm::cont::Field::ASSOC_POINTS, zVals, nVerts));
|
dataSet.AddField(Field("z", 1, vtkm::cont::Field::ASSOC_POINTS, zVals, nVerts));
|
||||||
ds.AddCoordinateSystem(vtkm::cont::CoordinateSystem("x","y","z"));
|
dataSet.AddCoordinateSystem(vtkm::cont::CoordinateSystem("x","y","z"));
|
||||||
|
|
||||||
vtkm::cont::CellSetExplicit<> cellSet("cells", 2);
|
vtkm::cont::CellSetExplicit<> cellSet("cells", 2);
|
||||||
vtkm::cont::ConnectivityExplicit<> &ec = cellSet.NodesOfCellsConnectivity;
|
|
||||||
|
|
||||||
ec.PrepareToAddCells(nPointIds/3, nPointIds);
|
cellSet.PrepareToAddCells(nPointIds/3, nPointIds);
|
||||||
for (i=0; i<nPointIds/3; i++)
|
for (i=0; i<nPointIds/3; i++)
|
||||||
{
|
{
|
||||||
ec.AddCell(vtkm::VTKM_TRIANGLE, 3, make_Vec<vtkm::Id>(pointId[i*3], pointId[i*3+1], pointId[i*3+2]));
|
cellSet.AddCell(vtkm::VTKM_TRIANGLE, 3, make_Vec<vtkm::Id>(pointId[i*3], pointId[i*3+1], pointId[i*3+2]));
|
||||||
}
|
}
|
||||||
ec.CompleteAddingCells();
|
cellSet.CompleteAddingCells();
|
||||||
|
|
||||||
//todo this need to be a reference/shared_ptr style class
|
//todo this need to be a reference/shared_ptr style class
|
||||||
ds.AddCellSet(cellSet);
|
dataSet.AddCellSet(cellSet);
|
||||||
|
|
||||||
// copy bounds
|
// copy bounds
|
||||||
if (pBounds != NULL)
|
if (pBounds != NULL)
|
||||||
for (i=0; i<6; i++)
|
for (i=0; i<6; i++)
|
||||||
pBounds[i] = _bounds[i];
|
pBounds[i] = _bounds[i];
|
||||||
|
|
||||||
return ds;
|
return dataSet;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,10 +18,13 @@
|
|||||||
// this software.
|
// this software.
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
#include <vtkm/cont/DataSet.h>
|
|
||||||
#include <vtkm/cont/DeviceAdapterAlgorithm.h>
|
|
||||||
#include <vtkm/CellType.h>
|
#include <vtkm/CellType.h>
|
||||||
#include <vtkm/RegularConnectivity.h>
|
|
||||||
|
#include <vtkm/cont/CellSetStructured.h>
|
||||||
|
#include <vtkm/cont/DataSet.h>
|
||||||
|
#include <vtkm/cont/DeviceAdapterSerial.h>
|
||||||
|
|
||||||
|
#include <vtkm/exec/ConnectivityStructured.h>
|
||||||
|
|
||||||
#include <vtkm/cont/testing/Testing.h>
|
#include <vtkm/cont/testing/Testing.h>
|
||||||
#include <vtkm/cont/testing/MakeTestDataSet.h>
|
#include <vtkm/cont/testing/MakeTestDataSet.h>
|
||||||
@ -53,34 +56,43 @@ TwoDimRegularTest()
|
|||||||
"Incorrect number of cell sets");
|
"Incorrect number of cell sets");
|
||||||
VTKM_TEST_ASSERT(dataSet.GetNumberOfFields() == 4,
|
VTKM_TEST_ASSERT(dataSet.GetNumberOfFields() == 4,
|
||||||
"Incorrect number of fields");
|
"Incorrect number of fields");
|
||||||
VTKM_TEST_ASSERT(cellSet.Structure.GetNumberOfPoints() == 6,
|
VTKM_TEST_ASSERT(cellSet.GetNumberOfPoints() == 6,
|
||||||
"Incorrect number of nodes");
|
"Incorrect number of nodes");
|
||||||
VTKM_TEST_ASSERT(cellSet.Structure.GetNumberOfCells() == 2,
|
VTKM_TEST_ASSERT(cellSet.GetNumberOfCells() == 2,
|
||||||
"Incorrect number of cells");
|
"Incorrect number of cells");
|
||||||
|
|
||||||
vtkm::Id numCells = cellSet.Structure.GetNumberOfCells();
|
vtkm::Id numCells = cellSet.GetNumberOfCells();
|
||||||
for (vtkm::Id cellIndex = 0; cellIndex < numCells; cellIndex++)
|
for (vtkm::Id cellIndex = 0; cellIndex < numCells; cellIndex++)
|
||||||
{
|
{
|
||||||
VTKM_TEST_ASSERT(cellSet.Structure.GetNumberOfNodesPerCell() == 4,
|
VTKM_TEST_ASSERT(cellSet.GetNumberOfNodesPerCell() == 4,
|
||||||
"Incorrect number of cell indices");
|
"Incorrect number of cell indices");
|
||||||
vtkm::CellType shape = cellSet.Structure.GetCellShapeType();
|
vtkm::CellType shape = cellSet.GetCellShapeType();
|
||||||
VTKM_TEST_ASSERT(shape == vtkm::VTKM_PIXEL, "Incorrect element type.");
|
VTKM_TEST_ASSERT(shape == vtkm::VTKM_PIXEL, "Incorrect element type.");
|
||||||
}
|
}
|
||||||
|
|
||||||
vtkm::RegularConnectivity<
|
vtkm::exec::ConnectivityStructured<
|
||||||
vtkm::TopologyElementTagPoint,
|
vtkm::TopologyElementTagPoint,
|
||||||
vtkm::TopologyElementTagCell,
|
vtkm::TopologyElementTagCell,
|
||||||
2> nodeToCell = cellSet.GetNodeToCellConnectivity();
|
2> pointToCell =
|
||||||
vtkm::RegularConnectivity<
|
cellSet.PrepareForInput(
|
||||||
|
vtkm::cont::DeviceAdapterTagSerial(),
|
||||||
|
vtkm::TopologyElementTagPoint(),
|
||||||
|
vtkm::TopologyElementTagCell());
|
||||||
|
vtkm::exec::ConnectivityStructured<
|
||||||
vtkm::TopologyElementTagCell,
|
vtkm::TopologyElementTagCell,
|
||||||
vtkm::TopologyElementTagPoint,
|
vtkm::TopologyElementTagPoint,
|
||||||
2> cellToNode = cellSet.GetCellToNodeConnectivity();
|
2> cellToPoint =
|
||||||
|
cellSet.PrepareForInput(
|
||||||
|
vtkm::cont::DeviceAdapterTagSerial(),
|
||||||
|
vtkm::TopologyElementTagCell(),
|
||||||
|
vtkm::TopologyElementTagPoint());
|
||||||
|
|
||||||
|
|
||||||
vtkm::Id cells[2][4] = {{0,1,3,4}, {1,2,4,5}};
|
vtkm::Id cells[2][4] = {{0,1,3,4}, {1,2,4,5}};
|
||||||
vtkm::Vec<vtkm::Id,4> nodeIds;
|
vtkm::Vec<vtkm::Id,4> nodeIds;
|
||||||
for (vtkm::Id cellIndex = 0; cellIndex < 2; cellIndex++)
|
for (vtkm::Id cellIndex = 0; cellIndex < 2; cellIndex++)
|
||||||
{
|
{
|
||||||
nodeToCell.GetIndices(cellIndex, nodeIds);
|
pointToCell.GetIndices(cellIndex, nodeIds);
|
||||||
for (vtkm::IdComponent nodeIndex = 0; nodeIndex < 4; nodeIndex++)
|
for (vtkm::IdComponent nodeIndex = 0; nodeIndex < 4; nodeIndex++)
|
||||||
{
|
{
|
||||||
VTKM_TEST_ASSERT(nodeIds[nodeIndex] == cells[cellIndex][nodeIndex],
|
VTKM_TEST_ASSERT(nodeIds[nodeIndex] == cells[cellIndex][nodeIndex],
|
||||||
@ -98,7 +110,7 @@ TwoDimRegularTest()
|
|||||||
for (vtkm::Id pointIndex = 0; pointIndex < 6; pointIndex++)
|
for (vtkm::Id pointIndex = 0; pointIndex < 6; pointIndex++)
|
||||||
{
|
{
|
||||||
vtkm::Vec<vtkm::Id,4> retrievedCellIds;
|
vtkm::Vec<vtkm::Id,4> retrievedCellIds;
|
||||||
cellToNode.GetIndices(pointIndex, retrievedCellIds);
|
cellToPoint.GetIndices(pointIndex, retrievedCellIds);
|
||||||
for (vtkm::IdComponent cellIndex = 0; cellIndex < 4; cellIndex++)
|
for (vtkm::IdComponent cellIndex = 0; cellIndex < 4; cellIndex++)
|
||||||
VTKM_TEST_ASSERT(
|
VTKM_TEST_ASSERT(
|
||||||
retrievedCellIds[cellIndex] == expectedCellIds[pointIndex][cellIndex],
|
retrievedCellIds[cellIndex] == expectedCellIds[pointIndex][cellIndex],
|
||||||
@ -123,29 +135,33 @@ ThreeDimRegularTest()
|
|||||||
VTKM_TEST_ASSERT(dataSet.GetNumberOfFields() == 5,
|
VTKM_TEST_ASSERT(dataSet.GetNumberOfFields() == 5,
|
||||||
"Incorrect number of fields");
|
"Incorrect number of fields");
|
||||||
|
|
||||||
VTKM_TEST_ASSERT(cellSet.Structure.GetNumberOfPoints() == 18,
|
VTKM_TEST_ASSERT(cellSet.GetNumberOfPoints() == 18,
|
||||||
"Incorrect number of nodes");
|
"Incorrect number of nodes");
|
||||||
|
|
||||||
VTKM_TEST_ASSERT(cellSet.Structure.GetNumberOfCells() == 4,
|
VTKM_TEST_ASSERT(cellSet.GetNumberOfCells() == 4,
|
||||||
"Incorrect number of cells");
|
"Incorrect number of cells");
|
||||||
|
|
||||||
vtkm::Id numCells = cellSet.Structure.GetNumberOfCells();
|
vtkm::Id numCells = cellSet.GetNumberOfCells();
|
||||||
for (vtkm::Id cellIndex = 0; cellIndex < numCells; cellIndex++)
|
for (vtkm::Id cellIndex = 0; cellIndex < numCells; cellIndex++)
|
||||||
{
|
{
|
||||||
VTKM_TEST_ASSERT(cellSet.Structure.GetNumberOfNodesPerCell() == 8,
|
VTKM_TEST_ASSERT(cellSet.GetNumberOfNodesPerCell() == 8,
|
||||||
"Incorrect number of cell indices");
|
"Incorrect number of cell indices");
|
||||||
vtkm::CellType shape = cellSet.Structure.GetCellShapeType();
|
vtkm::CellType shape = cellSet.GetCellShapeType();
|
||||||
VTKM_TEST_ASSERT(shape == vtkm::VTKM_VOXEL, "Incorrect element type.");
|
VTKM_TEST_ASSERT(shape == vtkm::VTKM_VOXEL, "Incorrect element type.");
|
||||||
}
|
}
|
||||||
|
|
||||||
//Test regular connectivity.
|
//Test regular connectivity.
|
||||||
vtkm::RegularConnectivity<
|
vtkm::exec::ConnectivityStructured<
|
||||||
vtkm::TopologyElementTagPoint,
|
vtkm::TopologyElementTagPoint,
|
||||||
vtkm::TopologyElementTagCell,
|
vtkm::TopologyElementTagCell,
|
||||||
3> nodeToCell = cellSet.GetNodeToCellConnectivity();
|
3> pointToCell =
|
||||||
|
cellSet.PrepareForInput(
|
||||||
|
vtkm::cont::DeviceAdapterTagSerial(),
|
||||||
|
vtkm::TopologyElementTagPoint(),
|
||||||
|
vtkm::TopologyElementTagCell());
|
||||||
vtkm::Id expectedPointIds[8] = {0,1,3,4,6,7,9,10};
|
vtkm::Id expectedPointIds[8] = {0,1,3,4,6,7,9,10};
|
||||||
vtkm::Vec<vtkm::Id,8> retrievedPointIds;
|
vtkm::Vec<vtkm::Id,8> retrievedPointIds;
|
||||||
nodeToCell.GetIndices(0, retrievedPointIds);
|
pointToCell.GetIndices(0, retrievedPointIds);
|
||||||
for (vtkm::IdComponent nodeIndex = 0; nodeIndex < 8; nodeIndex++)
|
for (vtkm::IdComponent nodeIndex = 0; nodeIndex < 8; nodeIndex++)
|
||||||
{
|
{
|
||||||
VTKM_TEST_ASSERT(
|
VTKM_TEST_ASSERT(
|
||||||
@ -153,13 +169,17 @@ ThreeDimRegularTest()
|
|||||||
"Incorrect node ID for cell");
|
"Incorrect node ID for cell");
|
||||||
}
|
}
|
||||||
|
|
||||||
vtkm::RegularConnectivity<
|
vtkm::exec::ConnectivityStructured<
|
||||||
vtkm::TopologyElementTagCell,
|
vtkm::TopologyElementTagCell,
|
||||||
vtkm::TopologyElementTagPoint,
|
vtkm::TopologyElementTagPoint,
|
||||||
3> cellToNode = cellSet.GetCellToNodeConnectivity();
|
3> cellToPoint =
|
||||||
|
cellSet.PrepareForInput(
|
||||||
|
vtkm::cont::DeviceAdapterTagSerial(),
|
||||||
|
vtkm::TopologyElementTagCell(),
|
||||||
|
vtkm::TopologyElementTagPoint());
|
||||||
vtkm::Vec<vtkm::Id,8> expectedCellIds;
|
vtkm::Vec<vtkm::Id,8> expectedCellIds;
|
||||||
vtkm::Id retrievedCellIds[8] = {0,-1,-1,-1,-1,-1,-1,-1};
|
vtkm::Id retrievedCellIds[8] = {0,-1,-1,-1,-1,-1,-1,-1};
|
||||||
cellToNode.GetIndices(0, expectedCellIds);
|
cellToPoint.GetIndices(0, expectedCellIds);
|
||||||
for (vtkm::IdComponent nodeIndex = 0; nodeIndex < 8; nodeIndex++)
|
for (vtkm::IdComponent nodeIndex = 0; nodeIndex < 8; nodeIndex++)
|
||||||
{
|
{
|
||||||
VTKM_TEST_ASSERT(
|
VTKM_TEST_ASSERT(
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
set(headers
|
set(headers
|
||||||
Assert.h
|
Assert.h
|
||||||
ConnectivityExplicit.h
|
ConnectivityExplicit.h
|
||||||
|
ConnectivityStructured.h
|
||||||
ExecutionObjectBase.h
|
ExecutionObjectBase.h
|
||||||
ExecutionWholeArray.h
|
ExecutionWholeArray.h
|
||||||
FunctorBase.h
|
FunctorBase.h
|
||||||
|
@ -19,32 +19,20 @@
|
|||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
|
|
||||||
#ifndef vtk_m_RegularConnectivity_h
|
#ifndef vtk_m_exec_ConnectivityStructured_h
|
||||||
#define vtk_m_RegularConnectivity_h
|
#define vtk_m_exec_ConnectivityStructured_h
|
||||||
|
|
||||||
#include <vtkm/TopologyElementTag.h>
|
#include <vtkm/TopologyElementTag.h>
|
||||||
#include <vtkm/Types.h>
|
#include <vtkm/Types.h>
|
||||||
#include <vtkm/internal/ConnectivityStructuredInternals.h>
|
#include <vtkm/internal/ConnectivityStructuredInternals.h>
|
||||||
#include <vtkm/cont/DeviceAdapterAlgorithm.h>
|
|
||||||
|
|
||||||
namespace vtkm {
|
namespace vtkm {
|
||||||
|
namespace exec {
|
||||||
template<vtkm::IdComponent Dimension>
|
|
||||||
struct SchedulingDimension
|
|
||||||
{
|
|
||||||
typedef vtkm::Vec<vtkm::Id, Dimension> ValueType;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<>
|
|
||||||
struct SchedulingDimension<1>
|
|
||||||
{
|
|
||||||
typedef vtkm::Id ValueType;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename FromTopology,
|
template<typename FromTopology,
|
||||||
typename ToTopology,
|
typename ToTopology,
|
||||||
vtkm::IdComponent Dimension>
|
vtkm::IdComponent Dimension>
|
||||||
class RegularConnectivity
|
class ConnectivityStructured
|
||||||
{
|
{
|
||||||
VTKM_IS_TOPOLOGY_ELEMENT_TAG(FromTopology);
|
VTKM_IS_TOPOLOGY_ELEMENT_TAG(FromTopology);
|
||||||
VTKM_IS_TOPOLOGY_ELEMENT_TAG(ToTopology);
|
VTKM_IS_TOPOLOGY_ELEMENT_TAG(ToTopology);
|
||||||
@ -53,30 +41,28 @@ class RegularConnectivity
|
|||||||
InternalsType;
|
InternalsType;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef typename SchedulingDimension<Dimension>::ValueType SchedulingDimension;
|
typedef typename InternalsType::SchedulingRangeType SchedulingRangeType;
|
||||||
|
|
||||||
RegularConnectivity():
|
VTKM_EXEC_CONT_EXPORT
|
||||||
|
ConnectivityStructured():
|
||||||
Internals()
|
Internals()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RegularConnectivity(const InternalsType &src):
|
VTKM_EXEC_CONT_EXPORT
|
||||||
|
ConnectivityStructured(const InternalsType &src):
|
||||||
Internals(src)
|
Internals(src)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
RegularConnectivity(const RegularConnectivity &src):
|
VTKM_EXEC_CONT_EXPORT
|
||||||
|
ConnectivityStructured(const ConnectivityStructured &src):
|
||||||
Internals(src.Internals)
|
Internals(src.Internals)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
VTKM_EXEC_CONT_EXPORT
|
VTKM_EXEC_EXPORT
|
||||||
SchedulingDimension GetSchedulingDimensions() const {
|
|
||||||
return Internals.GetSchedulingDimensions();
|
|
||||||
}
|
|
||||||
|
|
||||||
VTKM_EXEC_CONT_EXPORT
|
|
||||||
vtkm::Id GetNumberOfIndices(vtkm::Id index) const {
|
vtkm::Id GetNumberOfIndices(vtkm::Id index) const {
|
||||||
typedef vtkm::internal::ConnectivityStructuredIndexHelper<
|
typedef vtkm::internal::ConnectivityStructuredIndexHelper<
|
||||||
FromTopology,ToTopology,Dimension> Helper;
|
FromTopology,ToTopology,Dimension> Helper;
|
||||||
@ -84,13 +70,13 @@ public:
|
|||||||
}
|
}
|
||||||
// This needs some thought. What does cell shape mean when the to topology
|
// This needs some thought. What does cell shape mean when the to topology
|
||||||
// is not a cell?
|
// is not a cell?
|
||||||
VTKM_EXEC_CONT_EXPORT
|
VTKM_EXEC_EXPORT
|
||||||
vtkm::CellType GetCellShapeType(vtkm::Id=0) const {
|
vtkm::CellType GetCellShapeType(vtkm::Id=0) const {
|
||||||
return Internals.GetCellShapeType();
|
return Internals.GetCellShapeType();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <vtkm::IdComponent ItemTupleLength>
|
template <vtkm::IdComponent ItemTupleLength>
|
||||||
VTKM_EXEC_CONT_EXPORT
|
VTKM_EXEC_EXPORT
|
||||||
void GetIndices(vtkm::Id index, vtkm::Vec<vtkm::Id,ItemTupleLength> &ids)
|
void GetIndices(vtkm::Id index, vtkm::Vec<vtkm::Id,ItemTupleLength> &ids)
|
||||||
{
|
{
|
||||||
typedef vtkm::internal::ConnectivityStructuredIndexHelper<
|
typedef vtkm::internal::ConnectivityStructuredIndexHelper<
|
||||||
@ -98,23 +84,11 @@ public:
|
|||||||
Helper::GetIndices(this->Internals,index,ids);
|
Helper::GetIndices(this->Internals,index,ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename DeviceAdapterTag>
|
|
||||||
struct ExecutionTypes
|
|
||||||
{
|
|
||||||
typedef vtkm::RegularConnectivity<FromTopology,ToTopology,Dimension> ExecObjectType;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename DeviceAdapterTag>
|
|
||||||
typename ExecutionTypes<DeviceAdapterTag>::ExecObjectType
|
|
||||||
PrepareForInput(DeviceAdapterTag) const
|
|
||||||
{
|
|
||||||
return typename ExecutionTypes<DeviceAdapterTag>::ExecObjectType(*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
InternalsType Internals;
|
InternalsType Internals;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace vtkm
|
}
|
||||||
|
} // namespace vtkm::exec
|
||||||
|
|
||||||
#endif //vtk_m_RegularConnectivity_h
|
#endif //vtk_m_exec_ConnectivityStructured_h
|
@ -41,36 +41,44 @@ template<>
|
|||||||
class ConnectivityStructuredInternals<1>
|
class ConnectivityStructuredInternals<1>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
typedef vtkm::Id SchedulingRangeType;
|
||||||
|
|
||||||
VTKM_EXEC_CONT_EXPORT
|
VTKM_EXEC_CONT_EXPORT
|
||||||
void SetPointDimensions(vtkm::Vec<vtkm::Id,1> dimensions)
|
void SetPointDimensions(vtkm::Id dimensions)
|
||||||
{
|
{
|
||||||
this->PointDimensions = dimensions;
|
this->PointDimensions = dimensions;
|
||||||
}
|
}
|
||||||
|
|
||||||
VTKM_EXEC_CONT_EXPORT
|
VTKM_EXEC_CONT_EXPORT
|
||||||
vtkm::Vec<vtkm::Id,1> GetPointDimensions() const
|
vtkm::Id GetPointDimensions() const
|
||||||
{
|
{
|
||||||
return this->PointDimensions;
|
return this->PointDimensions;
|
||||||
}
|
}
|
||||||
|
|
||||||
VTKM_EXEC_CONT_EXPORT
|
VTKM_EXEC_CONT_EXPORT
|
||||||
vtkm::Vec<vtkm::Id,1> GetCellDimensions() const
|
vtkm::Id GetCellDimensions() const
|
||||||
{
|
{
|
||||||
return this->PointDimensions - vtkm::Vec<vtkm::Id,1>(1);
|
return this->PointDimensions - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
VTKM_EXEC_CONT_EXPORT
|
VTKM_EXEC_CONT_EXPORT
|
||||||
vtkm::Id GetSchedulingDimensions() const
|
SchedulingRangeType GetSchedulingRange(vtkm::TopologyElementTagCell) const
|
||||||
{
|
{
|
||||||
return this->GetNumberOfCells();
|
return this->GetNumberOfCells();
|
||||||
}
|
}
|
||||||
|
|
||||||
VTKM_EXEC_CONT_EXPORT
|
VTKM_EXEC_CONT_EXPORT
|
||||||
vtkm::Id GetNumberOfPoints() const {return this->PointDimensions[0];}
|
SchedulingRangeType GetSchedulingRange(vtkm::TopologyElementTagPoint) const
|
||||||
|
{
|
||||||
|
return this->GetNumberOfPoints();
|
||||||
|
}
|
||||||
|
|
||||||
VTKM_EXEC_CONT_EXPORT
|
VTKM_EXEC_CONT_EXPORT
|
||||||
vtkm::Id GetNumberOfCells() const {return this->PointDimensions[0]-1;}
|
vtkm::Id GetNumberOfPoints() const {return this->PointDimensions;}
|
||||||
VTKM_EXEC_CONT_EXPORT
|
VTKM_EXEC_CONT_EXPORT
|
||||||
vtkm::Id GetNumberOfNodesPerCell() const {return 2;}
|
vtkm::Id GetNumberOfCells() const {return this->PointDimensions-1;}
|
||||||
|
VTKM_EXEC_CONT_EXPORT
|
||||||
|
vtkm::IdComponent GetNumberOfNodesPerCell() const {return 2;}
|
||||||
VTKM_EXEC_CONT_EXPORT
|
VTKM_EXEC_CONT_EXPORT
|
||||||
vtkm::CellType GetCellShapeType() const {return VTKM_LINE;}
|
vtkm::CellType GetCellShapeType() const {return VTKM_LINE;}
|
||||||
|
|
||||||
@ -94,7 +102,7 @@ public:
|
|||||||
{
|
{
|
||||||
ids[idx++] = index-1;
|
ids[idx++] = index-1;
|
||||||
}
|
}
|
||||||
if (index < this->PointDimensions[0]-1)
|
if (index < this->PointDimensions-1)
|
||||||
{
|
{
|
||||||
ids[idx++] = index;
|
ids[idx++] = index;
|
||||||
}
|
}
|
||||||
@ -104,12 +112,12 @@ public:
|
|||||||
void PrintSummary(std::ostream &out) const
|
void PrintSummary(std::ostream &out) const
|
||||||
{
|
{
|
||||||
out<<" RegularConnectivity<1> ";
|
out<<" RegularConnectivity<1> ";
|
||||||
out<<"this->PointDimensions["<<this->PointDimensions[0]<<"] ";
|
out<<"this->PointDimensions["<<this->PointDimensions<<"] ";
|
||||||
out<<"\n";
|
out<<"\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
vtkm::Vec<vtkm::Id,1> PointDimensions;
|
vtkm::Id PointDimensions;
|
||||||
};
|
};
|
||||||
|
|
||||||
//2 D specialization.
|
//2 D specialization.
|
||||||
@ -117,6 +125,8 @@ template<>
|
|||||||
class ConnectivityStructuredInternals<2>
|
class ConnectivityStructuredInternals<2>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
typedef vtkm::Id2 SchedulingRangeType;
|
||||||
|
|
||||||
VTKM_EXEC_CONT_EXPORT
|
VTKM_EXEC_CONT_EXPORT
|
||||||
void SetPointDimensions(vtkm::Id2 dims)
|
void SetPointDimensions(vtkm::Id2 dims)
|
||||||
{
|
{
|
||||||
@ -140,9 +150,13 @@ public:
|
|||||||
|
|
||||||
//returns an id2 to signal what kind of scheduling to use
|
//returns an id2 to signal what kind of scheduling to use
|
||||||
VTKM_EXEC_CONT_EXPORT
|
VTKM_EXEC_CONT_EXPORT
|
||||||
vtkm::Id2 GetSchedulingDimensions() const {
|
vtkm::Id2 GetSchedulingRange(vtkm::TopologyElementTagCell) const {
|
||||||
return this->GetCellDimensions();
|
return this->GetCellDimensions();
|
||||||
}
|
}
|
||||||
|
VTKM_EXEC_CONT_EXPORT
|
||||||
|
vtkm::Id2 GetSchedulingRange(vtkm::TopologyElementTagPoint) const {
|
||||||
|
return this->GetPointDimensions();
|
||||||
|
}
|
||||||
|
|
||||||
VTKM_EXEC_CONT_EXPORT
|
VTKM_EXEC_CONT_EXPORT
|
||||||
vtkm::Id GetNumberOfCells() const
|
vtkm::Id GetNumberOfCells() const
|
||||||
@ -150,7 +164,7 @@ public:
|
|||||||
return vtkm::internal::VecProduct<2>()(this->GetCellDimensions());
|
return vtkm::internal::VecProduct<2>()(this->GetCellDimensions());
|
||||||
}
|
}
|
||||||
VTKM_EXEC_CONT_EXPORT
|
VTKM_EXEC_CONT_EXPORT
|
||||||
vtkm::Id GetNumberOfNodesPerCell() const { return 4; }
|
vtkm::IdComponent GetNumberOfNodesPerCell() const { return 4; }
|
||||||
VTKM_EXEC_CONT_EXPORT
|
VTKM_EXEC_CONT_EXPORT
|
||||||
vtkm::CellType GetCellShapeType() const { return VTKM_PIXEL; }
|
vtkm::CellType GetCellShapeType() const { return VTKM_PIXEL; }
|
||||||
|
|
||||||
@ -229,6 +243,8 @@ template<>
|
|||||||
class ConnectivityStructuredInternals<3>
|
class ConnectivityStructuredInternals<3>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
typedef vtkm::Id3 SchedulingRangeType;
|
||||||
|
|
||||||
VTKM_EXEC_CONT_EXPORT
|
VTKM_EXEC_CONT_EXPORT
|
||||||
void SetPointDimensions(vtkm::Id3 dims)
|
void SetPointDimensions(vtkm::Id3 dims)
|
||||||
{
|
{
|
||||||
@ -255,9 +271,13 @@ public:
|
|||||||
|
|
||||||
//returns an id3 to signal what kind of scheduling to use
|
//returns an id3 to signal what kind of scheduling to use
|
||||||
VTKM_EXEC_CONT_EXPORT
|
VTKM_EXEC_CONT_EXPORT
|
||||||
vtkm::Id3 GetSchedulingDimensions() const {
|
vtkm::Id3 GetSchedulingRange(vtkm::TopologyElementTagCell) const {
|
||||||
return this->GetCellDimensions();
|
return this->GetCellDimensions();
|
||||||
}
|
}
|
||||||
|
VTKM_EXEC_CONT_EXPORT
|
||||||
|
vtkm::Id3 GetSchedulingRange(vtkm::TopologyElementTagPoint) const {
|
||||||
|
return this->GetPointDimensions();
|
||||||
|
}
|
||||||
|
|
||||||
VTKM_EXEC_CONT_EXPORT
|
VTKM_EXEC_CONT_EXPORT
|
||||||
vtkm::Id GetNumberOfCells() const
|
vtkm::Id GetNumberOfCells() const
|
||||||
@ -265,7 +285,7 @@ public:
|
|||||||
return vtkm::internal::VecProduct<3>()(this->GetCellDimensions());
|
return vtkm::internal::VecProduct<3>()(this->GetCellDimensions());
|
||||||
}
|
}
|
||||||
VTKM_EXEC_CONT_EXPORT
|
VTKM_EXEC_CONT_EXPORT
|
||||||
vtkm::Id GetNumberOfNodesPerCell() const { return 8; }
|
vtkm::IdComponent GetNumberOfNodesPerCell() const { return 8; }
|
||||||
VTKM_EXEC_CONT_EXPORT
|
VTKM_EXEC_CONT_EXPORT
|
||||||
vtkm::CellType GetCellShapeType() const { return VTKM_VOXEL; }
|
vtkm::CellType GetCellShapeType() const { return VTKM_VOXEL; }
|
||||||
|
|
||||||
@ -408,7 +428,7 @@ struct ConnectivityStructuredIndexHelper<
|
|||||||
}
|
}
|
||||||
|
|
||||||
VTKM_EXEC_CONT_EXPORT
|
VTKM_EXEC_CONT_EXPORT
|
||||||
static vtkm::Id GetNumberOfIndices(
|
static vtkm::IdComponent GetNumberOfIndices(
|
||||||
const vtkm::internal::ConnectivityStructuredInternals<Dimension> &connectivity,
|
const vtkm::internal::ConnectivityStructuredInternals<Dimension> &connectivity,
|
||||||
vtkm::Id vtkmNotUsed(cellIndex))
|
vtkm::Id vtkmNotUsed(cellIndex))
|
||||||
{
|
{
|
||||||
|
@ -20,9 +20,7 @@
|
|||||||
#ifndef vtk_m_worklet_Dispatcher_MapTopology_h
|
#ifndef vtk_m_worklet_Dispatcher_MapTopology_h
|
||||||
#define vtk_m_worklet_Dispatcher_MapTopology_h
|
#define vtk_m_worklet_Dispatcher_MapTopology_h
|
||||||
|
|
||||||
#include <vtkm/RegularConnectivity.h>
|
#include <vtkm/TopologyElementTag.h>
|
||||||
|
|
||||||
#include <vtkm/cont/ConnectivityExplicit.h>
|
|
||||||
#include <vtkm/cont/DeviceAdapter.h>
|
#include <vtkm/cont/DeviceAdapter.h>
|
||||||
#include <vtkm/worklet/WorkletMapTopology.h>
|
#include <vtkm/worklet/WorkletMapTopology.h>
|
||||||
#include <vtkm/worklet/internal/DispatcherBase.h>
|
#include <vtkm/worklet/internal/DispatcherBase.h>
|
||||||
@ -73,60 +71,21 @@ public:
|
|||||||
typedef typename ParameterInterface::
|
typedef typename ParameterInterface::
|
||||||
template ParameterType<InputDomainIndex>::type InputDomainType;
|
template ParameterType<InputDomainIndex>::type InputDomainType;
|
||||||
|
|
||||||
|
// If you get a compile error on this line, then you have tried to use
|
||||||
|
// something that is not a vtkm::cont::CellSet as the input domain to a
|
||||||
|
// topology operation (that operates on a cell set connection domain).
|
||||||
|
VTKM_IS_CELL_SET(InputDomainType);
|
||||||
|
|
||||||
// We can pull the input domain parameter (the data specifying the input
|
// We can pull the input domain parameter (the data specifying the input
|
||||||
// domain) from the invocation object.
|
// domain) from the invocation object.
|
||||||
InputDomainType inputDomain =
|
InputDomainType inputDomain =
|
||||||
invocation.Parameters.template GetParameter<InputDomainIndex>();
|
invocation.Parameters.template GetParameter<InputDomainIndex>();
|
||||||
|
|
||||||
//we need to now template based on the input domain type. If the input
|
// Now that we have the input domain, we can extract the range of the
|
||||||
//domain type is a regular or explicit grid we call GetSchedulingDimensions.
|
// scheduling and call BadicInvoke.
|
||||||
//but in theory your input domain could be a permutation array
|
this->BasicInvoke(invocation,
|
||||||
this->InvokeBasedOnDomainType(invocation,
|
inputDomain.GetSchedulingRange(
|
||||||
inputDomain.GetNodeToCellConnectivity());
|
vtkm::TopologyElementTagCell()));
|
||||||
}
|
|
||||||
|
|
||||||
template<typename Invocation, typename InputDomainType>
|
|
||||||
VTKM_CONT_EXPORT
|
|
||||||
void InvokeBasedOnDomainType(const Invocation &invocation,
|
|
||||||
const InputDomainType& domain) const
|
|
||||||
{
|
|
||||||
//presume that the input domain isn't a grid, so call GetNumberOfValues()
|
|
||||||
//this code path is currently not exercised as the InputDomain currently
|
|
||||||
//is required to be Explicit or Regular Connectivity. In the future if
|
|
||||||
//we ever allow the InputDomain and the TopologyDomain to differ, this
|
|
||||||
//invocation will be used
|
|
||||||
this->BasicInvoke(invocation, domain.GetNumberOfValues());
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename Invocation,
|
|
||||||
typename T,
|
|
||||||
typename U,
|
|
||||||
typename V>
|
|
||||||
VTKM_CONT_EXPORT
|
|
||||||
void InvokeBasedOnDomainType(const Invocation &invocation,
|
|
||||||
const vtkm::cont::ConnectivityExplicit<T,U,V>& domain) const
|
|
||||||
{
|
|
||||||
|
|
||||||
// For a DispatcherMapTopology, when the inputDomain is some for of
|
|
||||||
// explicit connectivity we call GetSchedulingDimensions which will return
|
|
||||||
// a linear value representing the number of cells to schedule
|
|
||||||
this->BasicInvoke(invocation, domain.GetSchedulingDimensions());
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename Invocation,
|
|
||||||
typename From,
|
|
||||||
typename To,
|
|
||||||
vtkm::IdComponent Domain>
|
|
||||||
VTKM_CONT_EXPORT
|
|
||||||
void InvokeBasedOnDomainType(
|
|
||||||
const Invocation &invocation,
|
|
||||||
const vtkm::RegularConnectivity<From,To,Domain>& domain) const
|
|
||||||
{
|
|
||||||
|
|
||||||
// For a DispatcherMapTopology, the inputDomain is some for of connectivity
|
|
||||||
// so the GetSchedulingDimensions can return a vtkm::Id for linear scheduling,
|
|
||||||
// or a vtkm::Id2 or vtkm::Id3 for 3d block scheduling
|
|
||||||
this->BasicInvoke(invocation, domain.GetSchedulingDimensions());
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -37,7 +37,6 @@
|
|||||||
#include <vtkm/cont/ArrayHandleConstant.h>
|
#include <vtkm/cont/ArrayHandleConstant.h>
|
||||||
#include <vtkm/cont/ArrayHandleCompositeVector.h>
|
#include <vtkm/cont/ArrayHandleCompositeVector.h>
|
||||||
|
|
||||||
#include <vtkm/cont/ConnectivityExplicit.h>
|
|
||||||
#include <vtkm/cont/Field.h>
|
#include <vtkm/cont/Field.h>
|
||||||
#include <vtkm/cont/DataSet.h>
|
#include <vtkm/cont/DataSet.h>
|
||||||
|
|
||||||
|
@ -62,13 +62,12 @@ vtkm::cont::DataSet MakePointElevationTestDataSet()
|
|||||||
dataSet.AddCoordinateSystem(vtkm::cont::CoordinateSystem("x","y","z"));
|
dataSet.AddCoordinateSystem(vtkm::cont::CoordinateSystem("x","y","z"));
|
||||||
|
|
||||||
vtkm::cont::CellSetExplicit<> cellSet("cells", 3);
|
vtkm::cont::CellSetExplicit<> cellSet("cells", 3);
|
||||||
vtkm::cont::ConnectivityExplicit<> &connectivity = cellSet.NodesOfCellsConnectivity;
|
cellSet.PrepareToAddCells(numCells, numCells * 4);
|
||||||
connectivity.PrepareToAddCells(numCells, numCells * 4);
|
|
||||||
for (vtkm::Id j = 0; j < dim - 1; ++j)
|
for (vtkm::Id j = 0; j < dim - 1; ++j)
|
||||||
{
|
{
|
||||||
for (vtkm::Id i = 0; i < dim - 1; ++i)
|
for (vtkm::Id i = 0; i < dim - 1; ++i)
|
||||||
{
|
{
|
||||||
connectivity.AddCell(vtkm::VTKM_QUAD,
|
cellSet.AddCell(vtkm::VTKM_QUAD,
|
||||||
4,
|
4,
|
||||||
vtkm::make_Vec<vtkm::Id>(j * dim + i,
|
vtkm::make_Vec<vtkm::Id>(j * dim + i,
|
||||||
j * dim + i + 1,
|
j * dim + i + 1,
|
||||||
@ -76,7 +75,7 @@ vtkm::cont::DataSet MakePointElevationTestDataSet()
|
|||||||
(j + 1) * dim + i));
|
(j + 1) * dim + i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
connectivity.CompleteAddingCells();
|
cellSet.CompleteAddingCells();
|
||||||
|
|
||||||
dataSet.AddCellSet(cellSet);
|
dataSet.AddCellSet(cellSet);
|
||||||
return dataSet;
|
return dataSet;
|
||||||
|
@ -61,8 +61,8 @@ vtkm::cont::DataSet RunVertexClustering(vtkm::cont::DataSet &dataSet,
|
|||||||
dataSet.GetCellSet(0).CastTo<vtkm::cont::CellSetExplicit<> >();
|
dataSet.GetCellSet(0).CastTo<vtkm::cont::CellSetExplicit<> >();
|
||||||
|
|
||||||
vtkm::cont::ArrayHandle<PointType> pointArray = dataSet.GetField("xyz").GetData().CastToArrayHandle<PointType, VTKM_DEFAULT_STORAGE_TAG>();
|
vtkm::cont::ArrayHandle<PointType> pointArray = dataSet.GetField("xyz").GetData().CastToArrayHandle<PointType, VTKM_DEFAULT_STORAGE_TAG>();
|
||||||
vtkm::cont::ArrayHandle<vtkm::Id> pointIdArray = cellSet.GetNodeToCellConnectivity().GetConnectivityArray();
|
vtkm::cont::ArrayHandle<vtkm::Id> pointIdArray = cellSet.GetConnectivityArray();
|
||||||
vtkm::cont::ArrayHandle<vtkm::Id> cellToConnectivityIndexArray = cellSet.GetNodeToCellConnectivity().GetCellToConnectivityIndexArray();
|
vtkm::cont::ArrayHandle<vtkm::Id> cellToConnectivityIndexArray = cellSet.GetCellToConnectivityIndexArray();
|
||||||
|
|
||||||
vtkm::cont::ArrayHandle<PointType> output_pointArray ;
|
vtkm::cont::ArrayHandle<PointType> output_pointArray ;
|
||||||
vtkm::cont::ArrayHandle<vtkm::Id3> output_pointId3Array ;
|
vtkm::cont::ArrayHandle<vtkm::Id3> output_pointId3Array ;
|
||||||
@ -90,7 +90,7 @@ vtkm::cont::DataSet RunVertexClustering(vtkm::cont::DataSet &dataSet,
|
|||||||
|
|
||||||
vtkm::cont::CellSetExplicit<> newCellSet("cells", 0);
|
vtkm::cont::CellSetExplicit<> newCellSet("cells", 0);
|
||||||
|
|
||||||
newCellSet.GetNodeToCellConnectivity().Fill(
|
newCellSet.Fill(
|
||||||
copyFromImplicit(vtkm::cont::make_ArrayHandleConstant<vtkm::Id>(vtkm::VTKM_TRIANGLE, cells)),
|
copyFromImplicit(vtkm::cont::make_ArrayHandleConstant<vtkm::Id>(vtkm::VTKM_TRIANGLE, cells)),
|
||||||
copyFromImplicit(vtkm::cont::make_ArrayHandleConstant<vtkm::Id>(3, cells)),
|
copyFromImplicit(vtkm::cont::make_ArrayHandleConstant<vtkm::Id>(3, cells)),
|
||||||
copyFromVec(output_pointId3Array)
|
copyFromVec(output_pointId3Array)
|
||||||
@ -134,11 +134,12 @@ void TestVertexClustering()
|
|||||||
VTKM_TEST_ASSERT(outDataSet.GetNumberOfCellSets() == 1, "Number of output cellsets mismatch");
|
VTKM_TEST_ASSERT(outDataSet.GetNumberOfCellSets() == 1, "Number of output cellsets mismatch");
|
||||||
vtkm::cont::CellSetExplicit<> &cellSet =
|
vtkm::cont::CellSetExplicit<> &cellSet =
|
||||||
outDataSet.GetCellSet(0).CastTo<vtkm::cont::CellSetExplicit<> >();
|
outDataSet.GetCellSet(0).CastTo<vtkm::cont::CellSetExplicit<> >();
|
||||||
vtkm::cont::ConnectivityExplicit<> &conn = cellSet.GetNodeToCellConnectivity();
|
VTKM_TEST_ASSERT(
|
||||||
VTKM_TEST_ASSERT(conn.GetConnectivityArray().GetNumberOfValues() == output_pointIds, "Number of connectivity array elements mismatch");
|
cellSet.GetConnectivityArray().GetNumberOfValues() == output_pointIds,
|
||||||
for (vtkm::Id i=0; i<conn.GetConnectivityArray().GetNumberOfValues(); i++)
|
"Number of connectivity array elements mismatch");
|
||||||
|
for (vtkm::Id i=0; i<cellSet.GetConnectivityArray().GetNumberOfValues(); i++)
|
||||||
{
|
{
|
||||||
vtkm::Id id1 = conn.GetConnectivityArray().GetPortalConstControl().Get(i) ;
|
vtkm::Id id1 = cellSet.GetConnectivityArray().GetPortalConstControl().Get(i) ;
|
||||||
vtkm::Id id2 = output_pointId[i] ;
|
vtkm::Id id2 = output_pointId[i] ;
|
||||||
std::cout << "pointid: " << id1 << " " << id2 << std::endl;
|
std::cout << "pointid: " << id1 << " " << id2 << std::endl;
|
||||||
//VTKM_TEST_ASSERT( id1 == id2, "Connectivity Array mismatch" ) ;
|
//VTKM_TEST_ASSERT( id1 == id2, "Connectivity Array mismatch" ) ;
|
||||||
|
Loading…
Reference in New Issue
Block a user