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
|
||||
Matrix.h
|
||||
Pair.h
|
||||
RegularConnectivity.h
|
||||
TopologyElementTag.h
|
||||
TypeListTag.h
|
||||
Types.h
|
||||
|
@ -37,7 +37,6 @@ set(headers
|
||||
CellSetExplicit.h
|
||||
CellSetListTag.h
|
||||
CellSetStructured.h
|
||||
ConnectivityExplicit.h
|
||||
CoordinateSystem.h
|
||||
DataSet.h
|
||||
DeviceAdapter.h
|
||||
|
@ -56,18 +56,22 @@ public:
|
||||
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;
|
||||
}
|
||||
|
||||
virtual vtkm::Id GetNumEdges() const
|
||||
virtual vtkm::Id GetNumberOfEdges() const
|
||||
{
|
||||
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;
|
||||
|
||||
protected:
|
||||
|
@ -22,68 +22,245 @@
|
||||
|
||||
#include <vtkm/TopologyElementTag.h>
|
||||
#include <vtkm/cont/CellSet.h>
|
||||
#include <vtkm/cont/ConnectivityExplicit.h>
|
||||
#include <vtkm/exec/ConnectivityExplicit.h>
|
||||
|
||||
namespace vtkm {
|
||||
namespace cont {
|
||||
|
||||
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 >
|
||||
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:
|
||||
typedef ConnectivityExplicit<ShapeStorageTag,
|
||||
IndexStorageTag,
|
||||
ConnectivityStorageTag
|
||||
> ExplicitConnectivityType;
|
||||
typedef vtkm::Id SchedulingRangeType;
|
||||
|
||||
VTKM_CONT_EXPORT
|
||||
CellSetExplicit(const std::string &name = std::string(),
|
||||
vtkm::IdComponent dimensionality = 3)
|
||||
: CellSet(name, dimensionality)
|
||||
: CellSet(name, dimensionality),
|
||||
ConnectivityLength(0),
|
||||
NumberOfCells(0)
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_CONT_EXPORT
|
||||
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>
|
||||
struct ConnectivityType {
|
||||
VTKM_CONT_EXPORT
|
||||
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(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 ExplicitConnectivityType Type;
|
||||
|
||||
typedef typename ShapeArrayType::template ExecutionTypes<DeviceAdapter>::PortalConst ShapePortalType;
|
||||
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;
|
||||
}
|
||||
|
||||
ExplicitConnectivityType &GetNodeToCellConnectivity()
|
||||
{
|
||||
return this->NodesOfCellsConnectivity;
|
||||
typedef typename ExecutionTypes<Device,vtkm::TopologyElementTagPoint,vtkm::TopologyElementTagCell>::ExecObjectType ExecObjType;
|
||||
return ExecObjType(this->Shapes.PrepareForInput(Device()),
|
||||
this->NumIndices.PrepareForInput(Device()),
|
||||
this->Connectivity.PrepareForInput(Device()),
|
||||
this->MapCellToConnectivityIndex.PrepareForInput(Device()));
|
||||
}
|
||||
|
||||
virtual void PrintSummary(std::ostream &out) const
|
||||
{
|
||||
out << " ExplicitCellSet: " << this->Name
|
||||
<< " 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:
|
||||
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
|
||||
|
||||
#include <vtkm/cont/CellSet.h>
|
||||
#include <vtkm/RegularConnectivity.h>
|
||||
#include <vtkm/cont/DeviceAdapter.h>
|
||||
#include <vtkm/TopologyElementTag.h>
|
||||
#include <vtkm/internal/ConnectivityStructuredInternals.h>
|
||||
#include <vtkm/exec/ConnectivityStructured.h>
|
||||
|
||||
namespace vtkm {
|
||||
namespace cont {
|
||||
@ -33,9 +34,15 @@ namespace cont {
|
||||
template<vtkm::IdComponent DIMENSION>
|
||||
class CellSetStructured : public CellSet
|
||||
{
|
||||
private:
|
||||
typedef vtkm::internal::ConnectivityStructuredInternals<DIMENSION>
|
||||
InternalsType;
|
||||
|
||||
public:
|
||||
static const vtkm::IdComponent Dimension=DIMENSION;
|
||||
|
||||
typedef typename InternalsType::SchedulingRangeType SchedulingRangeType;
|
||||
|
||||
VTKM_CONT_EXPORT
|
||||
CellSetStructured(const std::string &name = std::string())
|
||||
: CellSet(name,Dimension)
|
||||
@ -43,38 +50,56 @@ public:
|
||||
}
|
||||
|
||||
|
||||
virtual vtkm::Id GetNumCells() const
|
||||
virtual vtkm::Id GetNumberOfCells() const
|
||||
{
|
||||
return this->Structure.GetNumberOfCells();
|
||||
}
|
||||
|
||||
template<typename FromTopology, typename ToTopology>
|
||||
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
|
||||
virtual vtkm::Id GetNumberOfPoints() const
|
||||
{
|
||||
typedef vtkm::RegularConnectivity<vtkm::TopologyElementTagPoint,
|
||||
vtkm::TopologyElementTagCell,
|
||||
Dimension> NodeToCellConnectivity;
|
||||
return NodeToCellConnectivity(this->Structure);
|
||||
return this->Structure.GetNumberOfPoints();
|
||||
}
|
||||
|
||||
void SetPointDimensions(SchedulingRangeType dimensions)
|
||||
{
|
||||
this->Structure.SetPointDimensions(dimensions);
|
||||
}
|
||||
|
||||
VTKM_CONT_EXPORT
|
||||
vtkm::RegularConnectivity<
|
||||
vtkm::TopologyElementTagCell,vtkm::TopologyElementTagPoint,Dimension>
|
||||
GetCellToNodeConnectivity() const
|
||||
vtkm::IdComponent GetNumberOfNodesPerCell() const
|
||||
{
|
||||
typedef vtkm::RegularConnectivity<vtkm::TopologyElementTagCell,
|
||||
vtkm::TopologyElementTagPoint,
|
||||
Dimension> CellToNodeConnectivity;
|
||||
return CellToNodeConnectivity(this->Structure);
|
||||
return this->Structure.GetNumberOfNodesPerCell();
|
||||
}
|
||||
|
||||
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
|
||||
@ -84,8 +109,8 @@ public:
|
||||
this->Structure.PrintSummary(out);
|
||||
}
|
||||
|
||||
public:
|
||||
vtkm::internal::ConnectivityStructuredInternals<Dimension> Structure;
|
||||
private:
|
||||
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);
|
||||
|
||||
typedef typename ContObjectType
|
||||
::template ConnectivityType<
|
||||
vtkm::TopologyElementTagPoint,vtkm::TopologyElementTagCell>::Type
|
||||
::template ExecutionTypes<Device>
|
||||
::template ExecutionTypes<
|
||||
Device,vtkm::TopologyElementTagPoint,vtkm::TopologyElementTagCell>
|
||||
::ExecObjectType ExecObjectType;
|
||||
|
||||
VTKM_CONT_EXPORT
|
||||
ExecObjectType operator()(const ContObjectType &object, vtkm::Id) const
|
||||
{
|
||||
//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
|
||||
MakeTestDataSet::Make2DRegularDataSet0()
|
||||
{
|
||||
vtkm::cont::DataSet ds;
|
||||
vtkm::cont::DataSet dataSet;
|
||||
|
||||
const int nVerts = 6;
|
||||
vtkm::Float32 xVals[nVerts] = {0, 1, 2, 0, 1, 2};
|
||||
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};
|
||||
|
||||
ds.AddField(Field("x", 1, vtkm::cont::Field::ASSOC_POINTS, xVals, nVerts));
|
||||
ds.AddField(Field("y", 1, vtkm::cont::Field::ASSOC_POINTS, yVals, nVerts));
|
||||
ds.AddCoordinateSystem(vtkm::cont::CoordinateSystem("x","y"));
|
||||
dataSet.AddField(Field("x", 1, vtkm::cont::Field::ASSOC_POINTS, xVals, nVerts));
|
||||
dataSet.AddField(Field("y", 1, vtkm::cont::Field::ASSOC_POINTS, yVals, nVerts));
|
||||
dataSet.AddCoordinateSystem(vtkm::cont::CoordinateSystem("x","y"));
|
||||
|
||||
//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.
|
||||
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");
|
||||
//Set regular structure
|
||||
cellSet.Structure.SetPointDimensions( vtkm::make_Vec(3,2) );
|
||||
ds.AddCellSet(cellSet);
|
||||
cellSet.SetPointDimensions( vtkm::make_Vec(3,2) );
|
||||
dataSet.AddCellSet(cellSet);
|
||||
|
||||
return ds;
|
||||
return dataSet;
|
||||
}
|
||||
|
||||
inline vtkm::cont::DataSet
|
||||
MakeTestDataSet::Make3DRegularDataSet0()
|
||||
{
|
||||
vtkm::cont::DataSet ds;
|
||||
vtkm::cont::DataSet dataSet;
|
||||
|
||||
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};
|
||||
@ -87,30 +87,30 @@ MakeTestDataSet::Make3DRegularDataSet0()
|
||||
100.3f, 110.3f, 120.3f, 130.4f, 140.4f, 150.4f, 160.4f, 170.5f,
|
||||
180.5f};
|
||||
|
||||
ds.AddField(Field("x", 1, vtkm::cont::Field::ASSOC_POINTS, xVals, nVerts));
|
||||
ds.AddField(Field("y", 1, vtkm::cont::Field::ASSOC_POINTS, yVals, nVerts));
|
||||
ds.AddField(Field("z", 1, vtkm::cont::Field::ASSOC_POINTS, zVals, nVerts));
|
||||
ds.AddCoordinateSystem(vtkm::cont::CoordinateSystem("x","y","z"));
|
||||
dataSet.AddField(Field("x", 1, vtkm::cont::Field::ASSOC_POINTS, xVals, nVerts));
|
||||
dataSet.AddField(Field("y", 1, vtkm::cont::Field::ASSOC_POINTS, yVals, nVerts));
|
||||
dataSet.AddField(Field("z", 1, vtkm::cont::Field::ASSOC_POINTS, zVals, nVerts));
|
||||
dataSet.AddCoordinateSystem(vtkm::cont::CoordinateSystem("x","y","z"));
|
||||
|
||||
//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
|
||||
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;
|
||||
vtkm::cont::CellSetStructured<dim> cellSet("cells");
|
||||
cellSet.Structure.SetPointDimensions( vtkm::make_Vec(3,2,3) );
|
||||
ds.AddCellSet(cellSet);
|
||||
cellSet.SetPointDimensions( vtkm::make_Vec(3,2,3) );
|
||||
dataSet.AddCellSet(cellSet);
|
||||
|
||||
return ds;
|
||||
return dataSet;
|
||||
}
|
||||
|
||||
inline vtkm::cont::DataSet
|
||||
MakeTestDataSet::Make3DExplicitDataSet0()
|
||||
{
|
||||
vtkm::cont::DataSet ds;
|
||||
vtkm::cont::DataSet dataSet;
|
||||
|
||||
const int nVerts = 5;
|
||||
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 vars[nVerts] = {10.1f, 20.1f, 30.2f, 40.2f, 50.3f};
|
||||
|
||||
ds.AddField(Field("x", 1, vtkm::cont::Field::ASSOC_POINTS, xVals, nVerts));
|
||||
ds.AddField(Field("y", 1, vtkm::cont::Field::ASSOC_POINTS, yVals, nVerts));
|
||||
ds.AddField(Field("z", 1, vtkm::cont::Field::ASSOC_POINTS, zVals, nVerts));
|
||||
ds.AddCoordinateSystem(vtkm::cont::CoordinateSystem("x","y","z"));
|
||||
dataSet.AddField(Field("x", 1, vtkm::cont::Field::ASSOC_POINTS, xVals, nVerts));
|
||||
dataSet.AddField(Field("y", 1, vtkm::cont::Field::ASSOC_POINTS, yVals, nVerts));
|
||||
dataSet.AddField(Field("z", 1, vtkm::cont::Field::ASSOC_POINTS, zVals, nVerts));
|
||||
dataSet.AddCoordinateSystem(vtkm::cont::CoordinateSystem("x","y","z"));
|
||||
|
||||
//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
|
||||
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
|
||||
std::vector<vtkm::Id> shapes;
|
||||
@ -150,19 +150,18 @@ MakeTestDataSet::Make3DExplicitDataSet0()
|
||||
conn.push_back(3);
|
||||
conn.push_back(4);
|
||||
|
||||
vtkm::cont::CellSetExplicit<> cs("cells", 2);
|
||||
vtkm::cont::ConnectivityExplicit<> &ec = cs.NodesOfCellsConnectivity;
|
||||
ec.FillViaCopy(shapes, numindices, conn);
|
||||
vtkm::cont::CellSetExplicit<> cellSet("cells", 2);
|
||||
cellSet.FillViaCopy(shapes, numindices, conn);
|
||||
|
||||
ds.AddCellSet(cs);
|
||||
dataSet.AddCellSet(cellSet);
|
||||
|
||||
return ds;
|
||||
return dataSet;
|
||||
}
|
||||
|
||||
inline vtkm::cont::DataSet
|
||||
MakeTestDataSet::Make3DExplicitDataSet1()
|
||||
{
|
||||
vtkm::cont::DataSet ds;
|
||||
vtkm::cont::DataSet dataSet;
|
||||
|
||||
const int nVerts = 5;
|
||||
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 vars[nVerts] = {10.1f, 20.1f, 30.2f, 40.2f, 50.3f};
|
||||
|
||||
ds.AddField(Field("x", 1, vtkm::cont::Field::ASSOC_POINTS, xVals, nVerts));
|
||||
ds.AddField(Field("y", 1, vtkm::cont::Field::ASSOC_POINTS, yVals, nVerts));
|
||||
ds.AddField(Field("z", 1, vtkm::cont::Field::ASSOC_POINTS, zVals, nVerts));
|
||||
ds.AddCoordinateSystem(vtkm::cont::CoordinateSystem("x","y","z"));
|
||||
dataSet.AddField(Field("x", 1, vtkm::cont::Field::ASSOC_POINTS, xVals, nVerts));
|
||||
dataSet.AddField(Field("y", 1, vtkm::cont::Field::ASSOC_POINTS, yVals, nVerts));
|
||||
dataSet.AddField(Field("z", 1, vtkm::cont::Field::ASSOC_POINTS, zVals, nVerts));
|
||||
dataSet.AddCoordinateSystem(vtkm::cont::CoordinateSystem("x","y","z"));
|
||||
|
||||
//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
|
||||
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::ConnectivityExplicit<> &ec = cellSet.NodesOfCellsConnectivity;
|
||||
|
||||
ec.PrepareToAddCells(2, 7);
|
||||
ec.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));
|
||||
ec.CompleteAddingCells();
|
||||
cellSet.PrepareToAddCells(2, 7);
|
||||
cellSet.AddCell(vtkm::VTKM_TRIANGLE, 3, make_Vec<vtkm::Id>(0,1,2));
|
||||
cellSet.AddCell(vtkm::VTKM_QUAD, 4, make_Vec<vtkm::Id>(2,1,3,4));
|
||||
cellSet.CompleteAddingCells();
|
||||
|
||||
//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
|
||||
@ -217,32 +215,31 @@ MakeTestDataSet::Make3DExplicitDataSetCowNose(double *pBounds)
|
||||
}
|
||||
|
||||
// create DataSet
|
||||
vtkm::cont::DataSet ds;
|
||||
ds.AddField(Field("xyz", 1, vtkm::cont::Field::ASSOC_POINTS, points, nVerts));
|
||||
ds.AddField(Field("x", 1, vtkm::cont::Field::ASSOC_POINTS, xVals, nVerts));
|
||||
ds.AddField(Field("y", 1, vtkm::cont::Field::ASSOC_POINTS, yVals, nVerts));
|
||||
ds.AddField(Field("z", 1, vtkm::cont::Field::ASSOC_POINTS, zVals, nVerts));
|
||||
ds.AddCoordinateSystem(vtkm::cont::CoordinateSystem("x","y","z"));
|
||||
vtkm::cont::DataSet dataSet;
|
||||
dataSet.AddField(Field("xyz", 1, vtkm::cont::Field::ASSOC_POINTS, points, nVerts));
|
||||
dataSet.AddField(Field("x", 1, vtkm::cont::Field::ASSOC_POINTS, xVals, nVerts));
|
||||
dataSet.AddField(Field("y", 1, vtkm::cont::Field::ASSOC_POINTS, yVals, nVerts));
|
||||
dataSet.AddField(Field("z", 1, vtkm::cont::Field::ASSOC_POINTS, zVals, nVerts));
|
||||
dataSet.AddCoordinateSystem(vtkm::cont::CoordinateSystem("x","y","z"));
|
||||
|
||||
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++)
|
||||
{
|
||||
ec.AddCell(vtkm::VTKM_TRIANGLE, 3, make_Vec<vtkm::Id>(pointId[i*3], pointId[i*3+1], pointId[i*3+2]));
|
||||
}
|
||||
ec.CompleteAddingCells();
|
||||
{
|
||||
cellSet.AddCell(vtkm::VTKM_TRIANGLE, 3, make_Vec<vtkm::Id>(pointId[i*3], pointId[i*3+1], pointId[i*3+2]));
|
||||
}
|
||||
cellSet.CompleteAddingCells();
|
||||
|
||||
//todo this need to be a reference/shared_ptr style class
|
||||
ds.AddCellSet(cellSet);
|
||||
dataSet.AddCellSet(cellSet);
|
||||
|
||||
// copy bounds
|
||||
if (pBounds != NULL)
|
||||
for (i=0; i<6; i++)
|
||||
pBounds[i] = _bounds[i];
|
||||
|
||||
return ds;
|
||||
return dataSet;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -18,10 +18,13 @@
|
||||
// this software.
|
||||
//============================================================================
|
||||
|
||||
#include <vtkm/cont/DataSet.h>
|
||||
#include <vtkm/cont/DeviceAdapterAlgorithm.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/MakeTestDataSet.h>
|
||||
@ -53,34 +56,43 @@ TwoDimRegularTest()
|
||||
"Incorrect number of cell sets");
|
||||
VTKM_TEST_ASSERT(dataSet.GetNumberOfFields() == 4,
|
||||
"Incorrect number of fields");
|
||||
VTKM_TEST_ASSERT(cellSet.Structure.GetNumberOfPoints() == 6,
|
||||
VTKM_TEST_ASSERT(cellSet.GetNumberOfPoints() == 6,
|
||||
"Incorrect number of nodes");
|
||||
VTKM_TEST_ASSERT(cellSet.Structure.GetNumberOfCells() == 2,
|
||||
VTKM_TEST_ASSERT(cellSet.GetNumberOfCells() == 2,
|
||||
"Incorrect number of cells");
|
||||
|
||||
vtkm::Id numCells = cellSet.Structure.GetNumberOfCells();
|
||||
vtkm::Id numCells = cellSet.GetNumberOfCells();
|
||||
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");
|
||||
vtkm::CellType shape = cellSet.Structure.GetCellShapeType();
|
||||
vtkm::CellType shape = cellSet.GetCellShapeType();
|
||||
VTKM_TEST_ASSERT(shape == vtkm::VTKM_PIXEL, "Incorrect element type.");
|
||||
}
|
||||
|
||||
vtkm::RegularConnectivity<
|
||||
vtkm::exec::ConnectivityStructured<
|
||||
vtkm::TopologyElementTagPoint,
|
||||
vtkm::TopologyElementTagCell,
|
||||
2> nodeToCell = cellSet.GetNodeToCellConnectivity();
|
||||
vtkm::RegularConnectivity<
|
||||
2> pointToCell =
|
||||
cellSet.PrepareForInput(
|
||||
vtkm::cont::DeviceAdapterTagSerial(),
|
||||
vtkm::TopologyElementTagPoint(),
|
||||
vtkm::TopologyElementTagCell());
|
||||
vtkm::exec::ConnectivityStructured<
|
||||
vtkm::TopologyElementTagCell,
|
||||
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::Vec<vtkm::Id,4> nodeIds;
|
||||
for (vtkm::Id cellIndex = 0; cellIndex < 2; cellIndex++)
|
||||
{
|
||||
nodeToCell.GetIndices(cellIndex, nodeIds);
|
||||
pointToCell.GetIndices(cellIndex, nodeIds);
|
||||
for (vtkm::IdComponent nodeIndex = 0; nodeIndex < 4; nodeIndex++)
|
||||
{
|
||||
VTKM_TEST_ASSERT(nodeIds[nodeIndex] == cells[cellIndex][nodeIndex],
|
||||
@ -98,7 +110,7 @@ TwoDimRegularTest()
|
||||
for (vtkm::Id pointIndex = 0; pointIndex < 6; pointIndex++)
|
||||
{
|
||||
vtkm::Vec<vtkm::Id,4> retrievedCellIds;
|
||||
cellToNode.GetIndices(pointIndex, retrievedCellIds);
|
||||
cellToPoint.GetIndices(pointIndex, retrievedCellIds);
|
||||
for (vtkm::IdComponent cellIndex = 0; cellIndex < 4; cellIndex++)
|
||||
VTKM_TEST_ASSERT(
|
||||
retrievedCellIds[cellIndex] == expectedCellIds[pointIndex][cellIndex],
|
||||
@ -123,29 +135,33 @@ ThreeDimRegularTest()
|
||||
VTKM_TEST_ASSERT(dataSet.GetNumberOfFields() == 5,
|
||||
"Incorrect number of fields");
|
||||
|
||||
VTKM_TEST_ASSERT(cellSet.Structure.GetNumberOfPoints() == 18,
|
||||
VTKM_TEST_ASSERT(cellSet.GetNumberOfPoints() == 18,
|
||||
"Incorrect number of nodes");
|
||||
|
||||
VTKM_TEST_ASSERT(cellSet.Structure.GetNumberOfCells() == 4,
|
||||
VTKM_TEST_ASSERT(cellSet.GetNumberOfCells() == 4,
|
||||
"Incorrect number of cells");
|
||||
|
||||
vtkm::Id numCells = cellSet.Structure.GetNumberOfCells();
|
||||
vtkm::Id numCells = cellSet.GetNumberOfCells();
|
||||
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");
|
||||
vtkm::CellType shape = cellSet.Structure.GetCellShapeType();
|
||||
vtkm::CellType shape = cellSet.GetCellShapeType();
|
||||
VTKM_TEST_ASSERT(shape == vtkm::VTKM_VOXEL, "Incorrect element type.");
|
||||
}
|
||||
|
||||
//Test regular connectivity.
|
||||
vtkm::RegularConnectivity<
|
||||
vtkm::exec::ConnectivityStructured<
|
||||
vtkm::TopologyElementTagPoint,
|
||||
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::Vec<vtkm::Id,8> retrievedPointIds;
|
||||
nodeToCell.GetIndices(0, retrievedPointIds);
|
||||
pointToCell.GetIndices(0, retrievedPointIds);
|
||||
for (vtkm::IdComponent nodeIndex = 0; nodeIndex < 8; nodeIndex++)
|
||||
{
|
||||
VTKM_TEST_ASSERT(
|
||||
@ -153,13 +169,17 @@ ThreeDimRegularTest()
|
||||
"Incorrect node ID for cell");
|
||||
}
|
||||
|
||||
vtkm::RegularConnectivity<
|
||||
vtkm::exec::ConnectivityStructured<
|
||||
vtkm::TopologyElementTagCell,
|
||||
vtkm::TopologyElementTagPoint,
|
||||
3> cellToNode = cellSet.GetCellToNodeConnectivity();
|
||||
3> cellToPoint =
|
||||
cellSet.PrepareForInput(
|
||||
vtkm::cont::DeviceAdapterTagSerial(),
|
||||
vtkm::TopologyElementTagCell(),
|
||||
vtkm::TopologyElementTagPoint());
|
||||
vtkm::Vec<vtkm::Id,8> expectedCellIds;
|
||||
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++)
|
||||
{
|
||||
VTKM_TEST_ASSERT(
|
||||
|
@ -21,6 +21,7 @@
|
||||
set(headers
|
||||
Assert.h
|
||||
ConnectivityExplicit.h
|
||||
ConnectivityStructured.h
|
||||
ExecutionObjectBase.h
|
||||
ExecutionWholeArray.h
|
||||
FunctorBase.h
|
||||
|
@ -19,32 +19,20 @@
|
||||
//============================================================================
|
||||
|
||||
|
||||
#ifndef vtk_m_RegularConnectivity_h
|
||||
#define vtk_m_RegularConnectivity_h
|
||||
#ifndef vtk_m_exec_ConnectivityStructured_h
|
||||
#define vtk_m_exec_ConnectivityStructured_h
|
||||
|
||||
#include <vtkm/TopologyElementTag.h>
|
||||
#include <vtkm/Types.h>
|
||||
#include <vtkm/internal/ConnectivityStructuredInternals.h>
|
||||
#include <vtkm/cont/DeviceAdapterAlgorithm.h>
|
||||
|
||||
namespace vtkm {
|
||||
|
||||
template<vtkm::IdComponent Dimension>
|
||||
struct SchedulingDimension
|
||||
{
|
||||
typedef vtkm::Vec<vtkm::Id, Dimension> ValueType;
|
||||
};
|
||||
|
||||
template<>
|
||||
struct SchedulingDimension<1>
|
||||
{
|
||||
typedef vtkm::Id ValueType;
|
||||
};
|
||||
namespace exec {
|
||||
|
||||
template<typename FromTopology,
|
||||
typename ToTopology,
|
||||
vtkm::IdComponent Dimension>
|
||||
class RegularConnectivity
|
||||
class ConnectivityStructured
|
||||
{
|
||||
VTKM_IS_TOPOLOGY_ELEMENT_TAG(FromTopology);
|
||||
VTKM_IS_TOPOLOGY_ELEMENT_TAG(ToTopology);
|
||||
@ -53,30 +41,28 @@ class RegularConnectivity
|
||||
InternalsType;
|
||||
|
||||
public:
|
||||
typedef typename SchedulingDimension<Dimension>::ValueType SchedulingDimension;
|
||||
typedef typename InternalsType::SchedulingRangeType SchedulingRangeType;
|
||||
|
||||
RegularConnectivity():
|
||||
VTKM_EXEC_CONT_EXPORT
|
||||
ConnectivityStructured():
|
||||
Internals()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
RegularConnectivity(const InternalsType &src):
|
||||
VTKM_EXEC_CONT_EXPORT
|
||||
ConnectivityStructured(const InternalsType &src):
|
||||
Internals(src)
|
||||
{
|
||||
}
|
||||
|
||||
RegularConnectivity(const RegularConnectivity &src):
|
||||
VTKM_EXEC_CONT_EXPORT
|
||||
ConnectivityStructured(const ConnectivityStructured &src):
|
||||
Internals(src.Internals)
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_EXEC_CONT_EXPORT
|
||||
SchedulingDimension GetSchedulingDimensions() const {
|
||||
return Internals.GetSchedulingDimensions();
|
||||
}
|
||||
|
||||
VTKM_EXEC_CONT_EXPORT
|
||||
VTKM_EXEC_EXPORT
|
||||
vtkm::Id GetNumberOfIndices(vtkm::Id index) const {
|
||||
typedef vtkm::internal::ConnectivityStructuredIndexHelper<
|
||||
FromTopology,ToTopology,Dimension> Helper;
|
||||
@ -84,13 +70,13 @@ public:
|
||||
}
|
||||
// This needs some thought. What does cell shape mean when the to topology
|
||||
// is not a cell?
|
||||
VTKM_EXEC_CONT_EXPORT
|
||||
VTKM_EXEC_EXPORT
|
||||
vtkm::CellType GetCellShapeType(vtkm::Id=0) const {
|
||||
return Internals.GetCellShapeType();
|
||||
}
|
||||
|
||||
template <vtkm::IdComponent ItemTupleLength>
|
||||
VTKM_EXEC_CONT_EXPORT
|
||||
VTKM_EXEC_EXPORT
|
||||
void GetIndices(vtkm::Id index, vtkm::Vec<vtkm::Id,ItemTupleLength> &ids)
|
||||
{
|
||||
typedef vtkm::internal::ConnectivityStructuredIndexHelper<
|
||||
@ -98,23 +84,11 @@ public:
|
||||
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:
|
||||
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>
|
||||
{
|
||||
public:
|
||||
typedef vtkm::Id SchedulingRangeType;
|
||||
|
||||
VTKM_EXEC_CONT_EXPORT
|
||||
void SetPointDimensions(vtkm::Vec<vtkm::Id,1> dimensions)
|
||||
void SetPointDimensions(vtkm::Id dimensions)
|
||||
{
|
||||
this->PointDimensions = dimensions;
|
||||
}
|
||||
|
||||
VTKM_EXEC_CONT_EXPORT
|
||||
vtkm::Vec<vtkm::Id,1> GetPointDimensions() const
|
||||
vtkm::Id GetPointDimensions() const
|
||||
{
|
||||
return this->PointDimensions;
|
||||
}
|
||||
|
||||
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::Id GetSchedulingDimensions() const
|
||||
SchedulingRangeType GetSchedulingRange(vtkm::TopologyElementTagCell) const
|
||||
{
|
||||
return this->GetNumberOfCells();
|
||||
}
|
||||
|
||||
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::Id GetNumberOfCells() const {return this->PointDimensions[0]-1;}
|
||||
vtkm::Id GetNumberOfPoints() const {return this->PointDimensions;}
|
||||
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::CellType GetCellShapeType() const {return VTKM_LINE;}
|
||||
|
||||
@ -94,7 +102,7 @@ public:
|
||||
{
|
||||
ids[idx++] = index-1;
|
||||
}
|
||||
if (index < this->PointDimensions[0]-1)
|
||||
if (index < this->PointDimensions-1)
|
||||
{
|
||||
ids[idx++] = index;
|
||||
}
|
||||
@ -104,12 +112,12 @@ public:
|
||||
void PrintSummary(std::ostream &out) const
|
||||
{
|
||||
out<<" RegularConnectivity<1> ";
|
||||
out<<"this->PointDimensions["<<this->PointDimensions[0]<<"] ";
|
||||
out<<"this->PointDimensions["<<this->PointDimensions<<"] ";
|
||||
out<<"\n";
|
||||
}
|
||||
|
||||
private:
|
||||
vtkm::Vec<vtkm::Id,1> PointDimensions;
|
||||
vtkm::Id PointDimensions;
|
||||
};
|
||||
|
||||
//2 D specialization.
|
||||
@ -117,6 +125,8 @@ template<>
|
||||
class ConnectivityStructuredInternals<2>
|
||||
{
|
||||
public:
|
||||
typedef vtkm::Id2 SchedulingRangeType;
|
||||
|
||||
VTKM_EXEC_CONT_EXPORT
|
||||
void SetPointDimensions(vtkm::Id2 dims)
|
||||
{
|
||||
@ -140,9 +150,13 @@ public:
|
||||
|
||||
//returns an id2 to signal what kind of scheduling to use
|
||||
VTKM_EXEC_CONT_EXPORT
|
||||
vtkm::Id2 GetSchedulingDimensions() const {
|
||||
vtkm::Id2 GetSchedulingRange(vtkm::TopologyElementTagCell) const {
|
||||
return this->GetCellDimensions();
|
||||
}
|
||||
VTKM_EXEC_CONT_EXPORT
|
||||
vtkm::Id2 GetSchedulingRange(vtkm::TopologyElementTagPoint) const {
|
||||
return this->GetPointDimensions();
|
||||
}
|
||||
|
||||
VTKM_EXEC_CONT_EXPORT
|
||||
vtkm::Id GetNumberOfCells() const
|
||||
@ -150,7 +164,7 @@ public:
|
||||
return vtkm::internal::VecProduct<2>()(this->GetCellDimensions());
|
||||
}
|
||||
VTKM_EXEC_CONT_EXPORT
|
||||
vtkm::Id GetNumberOfNodesPerCell() const { return 4; }
|
||||
vtkm::IdComponent GetNumberOfNodesPerCell() const { return 4; }
|
||||
VTKM_EXEC_CONT_EXPORT
|
||||
vtkm::CellType GetCellShapeType() const { return VTKM_PIXEL; }
|
||||
|
||||
@ -229,6 +243,8 @@ template<>
|
||||
class ConnectivityStructuredInternals<3>
|
||||
{
|
||||
public:
|
||||
typedef vtkm::Id3 SchedulingRangeType;
|
||||
|
||||
VTKM_EXEC_CONT_EXPORT
|
||||
void SetPointDimensions(vtkm::Id3 dims)
|
||||
{
|
||||
@ -255,9 +271,13 @@ public:
|
||||
|
||||
//returns an id3 to signal what kind of scheduling to use
|
||||
VTKM_EXEC_CONT_EXPORT
|
||||
vtkm::Id3 GetSchedulingDimensions() const {
|
||||
vtkm::Id3 GetSchedulingRange(vtkm::TopologyElementTagCell) const {
|
||||
return this->GetCellDimensions();
|
||||
}
|
||||
VTKM_EXEC_CONT_EXPORT
|
||||
vtkm::Id3 GetSchedulingRange(vtkm::TopologyElementTagPoint) const {
|
||||
return this->GetPointDimensions();
|
||||
}
|
||||
|
||||
VTKM_EXEC_CONT_EXPORT
|
||||
vtkm::Id GetNumberOfCells() const
|
||||
@ -265,7 +285,7 @@ public:
|
||||
return vtkm::internal::VecProduct<3>()(this->GetCellDimensions());
|
||||
}
|
||||
VTKM_EXEC_CONT_EXPORT
|
||||
vtkm::Id GetNumberOfNodesPerCell() const { return 8; }
|
||||
vtkm::IdComponent GetNumberOfNodesPerCell() const { return 8; }
|
||||
VTKM_EXEC_CONT_EXPORT
|
||||
vtkm::CellType GetCellShapeType() const { return VTKM_VOXEL; }
|
||||
|
||||
@ -408,7 +428,7 @@ struct ConnectivityStructuredIndexHelper<
|
||||
}
|
||||
|
||||
VTKM_EXEC_CONT_EXPORT
|
||||
static vtkm::Id GetNumberOfIndices(
|
||||
static vtkm::IdComponent GetNumberOfIndices(
|
||||
const vtkm::internal::ConnectivityStructuredInternals<Dimension> &connectivity,
|
||||
vtkm::Id vtkmNotUsed(cellIndex))
|
||||
{
|
||||
|
@ -20,9 +20,7 @@
|
||||
#ifndef vtk_m_worklet_Dispatcher_MapTopology_h
|
||||
#define vtk_m_worklet_Dispatcher_MapTopology_h
|
||||
|
||||
#include <vtkm/RegularConnectivity.h>
|
||||
|
||||
#include <vtkm/cont/ConnectivityExplicit.h>
|
||||
#include <vtkm/TopologyElementTag.h>
|
||||
#include <vtkm/cont/DeviceAdapter.h>
|
||||
#include <vtkm/worklet/WorkletMapTopology.h>
|
||||
#include <vtkm/worklet/internal/DispatcherBase.h>
|
||||
@ -73,60 +71,21 @@ public:
|
||||
typedef typename ParameterInterface::
|
||||
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
|
||||
// domain) from the invocation object.
|
||||
InputDomainType inputDomain =
|
||||
invocation.Parameters.template GetParameter<InputDomainIndex>();
|
||||
|
||||
//we need to now template based on the input domain type. If the input
|
||||
//domain type is a regular or explicit grid we call GetSchedulingDimensions.
|
||||
//but in theory your input domain could be a permutation array
|
||||
this->InvokeBasedOnDomainType(invocation,
|
||||
inputDomain.GetNodeToCellConnectivity());
|
||||
}
|
||||
|
||||
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());
|
||||
// Now that we have the input domain, we can extract the range of the
|
||||
// scheduling and call BadicInvoke.
|
||||
this->BasicInvoke(invocation,
|
||||
inputDomain.GetSchedulingRange(
|
||||
vtkm::TopologyElementTagCell()));
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -37,7 +37,6 @@
|
||||
#include <vtkm/cont/ArrayHandleConstant.h>
|
||||
#include <vtkm/cont/ArrayHandleCompositeVector.h>
|
||||
|
||||
#include <vtkm/cont/ConnectivityExplicit.h>
|
||||
#include <vtkm/cont/Field.h>
|
||||
#include <vtkm/cont/DataSet.h>
|
||||
|
||||
|
@ -62,21 +62,20 @@ vtkm::cont::DataSet MakePointElevationTestDataSet()
|
||||
dataSet.AddCoordinateSystem(vtkm::cont::CoordinateSystem("x","y","z"));
|
||||
|
||||
vtkm::cont::CellSetExplicit<> cellSet("cells", 3);
|
||||
vtkm::cont::ConnectivityExplicit<> &connectivity = cellSet.NodesOfCellsConnectivity;
|
||||
connectivity.PrepareToAddCells(numCells, numCells * 4);
|
||||
cellSet.PrepareToAddCells(numCells, numCells * 4);
|
||||
for (vtkm::Id j = 0; j < dim - 1; ++j)
|
||||
{
|
||||
for (vtkm::Id i = 0; i < dim - 1; ++i)
|
||||
{
|
||||
connectivity.AddCell(vtkm::VTKM_QUAD,
|
||||
4,
|
||||
vtkm::make_Vec<vtkm::Id>(j * dim + i,
|
||||
j * dim + i + 1,
|
||||
(j + 1) * dim + i + 1,
|
||||
(j + 1) * dim + i));
|
||||
cellSet.AddCell(vtkm::VTKM_QUAD,
|
||||
4,
|
||||
vtkm::make_Vec<vtkm::Id>(j * dim + i,
|
||||
j * dim + i + 1,
|
||||
(j + 1) * dim + i + 1,
|
||||
(j + 1) * dim + i));
|
||||
}
|
||||
}
|
||||
connectivity.CompleteAddingCells();
|
||||
cellSet.CompleteAddingCells();
|
||||
|
||||
dataSet.AddCellSet(cellSet);
|
||||
return dataSet;
|
||||
|
@ -61,8 +61,8 @@ vtkm::cont::DataSet RunVertexClustering(vtkm::cont::DataSet &dataSet,
|
||||
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<vtkm::Id> pointIdArray = cellSet.GetNodeToCellConnectivity().GetConnectivityArray();
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> cellToConnectivityIndexArray = cellSet.GetNodeToCellConnectivity().GetCellToConnectivityIndexArray();
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> pointIdArray = cellSet.GetConnectivityArray();
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> cellToConnectivityIndexArray = cellSet.GetCellToConnectivityIndexArray();
|
||||
|
||||
vtkm::cont::ArrayHandle<PointType> output_pointArray ;
|
||||
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);
|
||||
|
||||
newCellSet.GetNodeToCellConnectivity().Fill(
|
||||
newCellSet.Fill(
|
||||
copyFromImplicit(vtkm::cont::make_ArrayHandleConstant<vtkm::Id>(vtkm::VTKM_TRIANGLE, cells)),
|
||||
copyFromImplicit(vtkm::cont::make_ArrayHandleConstant<vtkm::Id>(3, cells)),
|
||||
copyFromVec(output_pointId3Array)
|
||||
@ -134,11 +134,12 @@ void TestVertexClustering()
|
||||
VTKM_TEST_ASSERT(outDataSet.GetNumberOfCellSets() == 1, "Number of output cellsets mismatch");
|
||||
vtkm::cont::CellSetExplicit<> &cellSet =
|
||||
outDataSet.GetCellSet(0).CastTo<vtkm::cont::CellSetExplicit<> >();
|
||||
vtkm::cont::ConnectivityExplicit<> &conn = cellSet.GetNodeToCellConnectivity();
|
||||
VTKM_TEST_ASSERT(conn.GetConnectivityArray().GetNumberOfValues() == output_pointIds, "Number of connectivity array elements mismatch");
|
||||
for (vtkm::Id i=0; i<conn.GetConnectivityArray().GetNumberOfValues(); i++)
|
||||
VTKM_TEST_ASSERT(
|
||||
cellSet.GetConnectivityArray().GetNumberOfValues() == output_pointIds,
|
||||
"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] ;
|
||||
std::cout << "pointid: " << id1 << " " << id2 << std::endl;
|
||||
//VTKM_TEST_ASSERT( id1 == id2, "Connectivity Array mismatch" ) ;
|
||||
|
Loading…
Reference in New Issue
Block a user