mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-09-08 13:23:51 +00:00
Get FromIndices as unknown type.
We want to be able to get topological connections where it is difficult to know how many values you get each time. In this change, the type of the vector holding the from indices is determined from the connectivity object, and the worklet does not know the type (it must be templated). Although you do not need to specify the max number for this value set (you still currently do for field values), we still need to change the type for explicit sets that uses something that does not rely on the Vec class. The cell-to-point method also needs a Vec wrapper that allows it to shorten the vector dynamically.
This commit is contained in:
parent
5c3646af70
commit
c847f0b148
@ -89,10 +89,9 @@ TwoDimRegularTest()
|
||||
|
||||
|
||||
vtkm::Id cells[2][4] = {{0,1,3,4}, {1,2,4,5}};
|
||||
vtkm::Vec<vtkm::Id,4> pointIds;
|
||||
for (vtkm::Id cellIndex = 0; cellIndex < 2; cellIndex++)
|
||||
{
|
||||
pointToCell.GetIndices(cellIndex, pointIds);
|
||||
vtkm::Vec<vtkm::Id,4> pointIds = pointToCell.GetIndices(cellIndex);
|
||||
for (vtkm::IdComponent localPointIndex = 0;
|
||||
localPointIndex < 4;
|
||||
localPointIndex++)
|
||||
@ -112,8 +111,8 @@ TwoDimRegularTest()
|
||||
|
||||
for (vtkm::Id pointIndex = 0; pointIndex < 6; pointIndex++)
|
||||
{
|
||||
vtkm::Vec<vtkm::Id,4> retrievedCellIds;
|
||||
cellToPoint.GetIndices(pointIndex, retrievedCellIds);
|
||||
vtkm::Vec<vtkm::Id,4> retrievedCellIds =
|
||||
cellToPoint.GetIndices(pointIndex);
|
||||
for (vtkm::IdComponent cellIndex = 0; cellIndex < 4; cellIndex++)
|
||||
VTKM_TEST_ASSERT(
|
||||
retrievedCellIds[cellIndex] == expectedCellIds[pointIndex][cellIndex],
|
||||
@ -163,8 +162,7 @@ ThreeDimRegularTest()
|
||||
vtkm::TopologyElementTagPoint(),
|
||||
vtkm::TopologyElementTagCell());
|
||||
vtkm::Id expectedPointIds[8] = {0,1,3,4,6,7,9,10};
|
||||
vtkm::Vec<vtkm::Id,8> retrievedPointIds;
|
||||
pointToCell.GetIndices(0, retrievedPointIds);
|
||||
vtkm::Vec<vtkm::Id,8> retrievedPointIds = pointToCell.GetIndices(0);
|
||||
for (vtkm::IdComponent localPointIndex = 0;
|
||||
localPointIndex < 8;
|
||||
localPointIndex++)
|
||||
@ -182,11 +180,10 @@ ThreeDimRegularTest()
|
||||
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};
|
||||
cellToPoint.GetIndices(0, expectedCellIds);
|
||||
vtkm::Id retrievedCellIds[6] = {0,-1,-1,-1,-1,-1};
|
||||
vtkm::Vec<vtkm::Id,6> expectedCellIds = cellToPoint.GetIndices(0);
|
||||
for (vtkm::IdComponent localPointIndex = 0;
|
||||
localPointIndex < 8;
|
||||
localPointIndex < 6;
|
||||
localPointIndex++)
|
||||
{
|
||||
VTKM_TEST_ASSERT(
|
||||
|
@ -51,38 +51,44 @@ public:
|
||||
}
|
||||
|
||||
VTKM_EXEC_EXPORT
|
||||
vtkm::Id GetNumberOfElements()
|
||||
vtkm::Id GetNumberOfElements() const
|
||||
{
|
||||
return Shapes.GetNumberOfValues();
|
||||
}
|
||||
|
||||
VTKM_EXEC_EXPORT
|
||||
vtkm::Id GetNumberOfIndices(vtkm::Id index)
|
||||
vtkm::Id GetNumberOfIndices(vtkm::Id index) const
|
||||
{
|
||||
return NumIndices.Get(index);
|
||||
}
|
||||
|
||||
VTKM_EXEC_EXPORT
|
||||
vtkm::Id GetCellShape(vtkm::Id index)
|
||||
vtkm::Id GetCellShape(vtkm::Id index) const
|
||||
{
|
||||
return Shapes.Get(index);
|
||||
}
|
||||
|
||||
template <vtkm::IdComponent ItemTupleLength>
|
||||
// TODO: This becomes a Vec-like
|
||||
typedef vtkm::Vec<vtkm::Id,8> IndicesType;
|
||||
|
||||
VTKM_EXEC_EXPORT
|
||||
void GetIndices(vtkm::Id index, vtkm::Vec<vtkm::Id,ItemTupleLength> &ids)
|
||||
IndicesType GetIndices(vtkm::Id index) const
|
||||
{
|
||||
vtkm::Id n = GetNumberOfIndices(index);
|
||||
IndicesType ids;
|
||||
vtkm::Id start = IndexOffset.Get(index);
|
||||
for (vtkm::IdComponent i=0; i<n && i<ItemTupleLength; i++)
|
||||
for (vtkm::IdComponent i=0; i<n && i<8; i++)
|
||||
{
|
||||
ids[i] = Connectivity.Get(start+i);
|
||||
}
|
||||
return ids;
|
||||
}
|
||||
|
||||
private:
|
||||
ShapePortalType Shapes;
|
||||
NumIndicesPortalType NumIndices;
|
||||
ConnectivityPortalType Connectivity;
|
||||
IndexOffsetPortalType IndexOffset;
|
||||
ShapePortalType Shapes;
|
||||
NumIndicesPortalType NumIndices;
|
||||
ConnectivityPortalType Connectivity;
|
||||
IndexOffsetPortalType IndexOffset;
|
||||
};
|
||||
|
||||
} // namespace exec
|
||||
|
@ -40,6 +40,8 @@ class ConnectivityStructured
|
||||
typedef vtkm::internal::ConnectivityStructuredInternals<Dimension>
|
||||
InternalsType;
|
||||
|
||||
typedef vtkm::internal::ConnectivityStructuredIndexHelper<
|
||||
FromTopology,ToTopology,Dimension> Helper;
|
||||
public:
|
||||
typedef typename InternalsType::SchedulingRangeType SchedulingRangeType;
|
||||
|
||||
@ -64,8 +66,6 @@ public:
|
||||
|
||||
VTKM_EXEC_EXPORT
|
||||
vtkm::Id GetNumberOfIndices(vtkm::Id index) const {
|
||||
typedef vtkm::internal::ConnectivityStructuredIndexHelper<
|
||||
FromTopology,ToTopology,Dimension> Helper;
|
||||
return Helper::GetNumberOfIndices(this->Internals, index);
|
||||
}
|
||||
// This needs some thought. What does cell shape mean when the to topology
|
||||
@ -75,13 +75,12 @@ public:
|
||||
return Internals.GetCellShape();
|
||||
}
|
||||
|
||||
template <vtkm::IdComponent ItemTupleLength>
|
||||
typedef typename Helper::IndicesType IndicesType;
|
||||
|
||||
VTKM_EXEC_EXPORT
|
||||
void GetIndices(vtkm::Id index, vtkm::Vec<vtkm::Id,ItemTupleLength> &ids)
|
||||
IndicesType GetIndices(vtkm::Id index) const
|
||||
{
|
||||
typedef vtkm::internal::ConnectivityStructuredIndexHelper<
|
||||
FromTopology,ToTopology,Dimension> Helper;
|
||||
Helper::GetIndices(this->Internals,index,ids);
|
||||
return Helper::GetIndices(this->Internals,index);
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -76,8 +76,7 @@ struct Fetch<
|
||||
vtkm::IdComponent nids =
|
||||
static_cast<vtkm::IdComponent>(topology.GetNumberOfIndices(index));
|
||||
|
||||
vtkm::Vec<vtkm::Id,ITEM_TUPLE_LENGTH> ids;
|
||||
topology.GetIndices(index,ids);
|
||||
typename TopologyType::IndicesType ids = topology.GetIndices(index);
|
||||
|
||||
ValueType v;
|
||||
for (vtkm::IdComponent i=0; i<nids && i<ITEM_TUPLE_LENGTH; ++i)
|
||||
|
@ -50,8 +50,11 @@ struct FromIndices : vtkm::exec::arg::ExecutionSignatureTagBase
|
||||
typedef vtkm::exec::arg::AspectTagFromIndices AspectTag;
|
||||
};
|
||||
|
||||
template<typename FetchTag, typename Invocation>
|
||||
struct Fetch<FetchTag, vtkm::exec::arg::AspectTagFromIndices, Invocation, 1>
|
||||
template<typename FetchTag,
|
||||
typename Invocation,
|
||||
vtkm::IdComponent ParameterIndex>
|
||||
struct Fetch<
|
||||
FetchTag, vtkm::exec::arg::AspectTagFromIndices, Invocation, ParameterIndex>
|
||||
{
|
||||
// The parameter for the input domain is stored in the Invocation. (It is
|
||||
// also in the worklet, but it is safer to get it from the Invocation
|
||||
@ -59,37 +62,23 @@ struct Fetch<FetchTag, vtkm::exec::arg::AspectTagFromIndices, Invocation, 1>
|
||||
static const vtkm::IdComponent InputDomainIndex =
|
||||
Invocation::InputDomainIndex;
|
||||
|
||||
typedef typename Invocation::ControlInterface::template
|
||||
ParameterType<InputDomainIndex>::type InputDomainTag;
|
||||
// Assuming that this fetch is used in a topology map, which is its
|
||||
// intention, InputDomainIndex points to a connectivity object. Thus,
|
||||
// ConnectivityType is one of the vtkm::exec::Connectivity* classes.
|
||||
typedef typename Invocation::ParameterInterface::
|
||||
template ParameterType<InputDomainIndex>::type ConnectivityType;
|
||||
|
||||
static const vtkm::IdComponent ITEM_TUPLE_LENGTH =
|
||||
InputDomainTag::ITEM_TUPLE_LENGTH;
|
||||
|
||||
typedef vtkm::exec::TopologyData<vtkm::Id,ITEM_TUPLE_LENGTH> ValueType;
|
||||
typedef typename ConnectivityType::IndicesType ValueType;
|
||||
|
||||
VTKM_EXEC_EXPORT
|
||||
ValueType Load(vtkm::Id index, const Invocation &invocation) const
|
||||
{
|
||||
// ParameterInterface (from Invocation) is a FunctionInterface type
|
||||
// containing types for all objects passed to the Invoke method (with
|
||||
// some dynamic casting performed so objects like DynamicArrayHandle get
|
||||
// cast to ArrayHandle).
|
||||
typedef typename Invocation::ParameterInterface ParameterInterface;
|
||||
|
||||
// This is the type for the input domain (derived from the last two things
|
||||
// we got from the Invocation).
|
||||
typedef typename ParameterInterface::
|
||||
template ParameterType<InputDomainIndex>::type TopologyType;
|
||||
|
||||
// We can pull the input domain parameter (the data specifying the input
|
||||
// domain) from the invocation object.
|
||||
TopologyType topology =
|
||||
const ConnectivityType &connectivity =
|
||||
invocation.Parameters.template GetParameter<InputDomainIndex>();
|
||||
|
||||
ValueType v;
|
||||
topology.GetIndices(index,v.vec);
|
||||
|
||||
return v;
|
||||
return connectivity.GetIndices(index);
|
||||
}
|
||||
|
||||
VTKM_EXEC_EXPORT
|
||||
|
@ -73,39 +73,52 @@ public:
|
||||
return this->GetNumberOfPoints();
|
||||
}
|
||||
|
||||
static const vtkm::IdComponent NUM_POINTS_IN_CELL = 2;
|
||||
static const vtkm::IdComponent MAX_CELL_TO_POINT = 2;
|
||||
|
||||
VTKM_EXEC_CONT_EXPORT
|
||||
vtkm::Id GetNumberOfPoints() const {return this->PointDimensions;}
|
||||
VTKM_EXEC_CONT_EXPORT
|
||||
vtkm::Id GetNumberOfCells() const {return this->PointDimensions-1;}
|
||||
VTKM_EXEC_CONT_EXPORT
|
||||
vtkm::IdComponent GetNumberOfPointsInCell() const {return 2;}
|
||||
vtkm::IdComponent GetNumberOfPointsInCell() const {return NUM_POINTS_IN_CELL;}
|
||||
VTKM_EXEC_CONT_EXPORT
|
||||
vtkm::CellType GetCellShape() const {return VTKM_LINE;}
|
||||
|
||||
template <vtkm::IdComponent IdsLength>
|
||||
VTKM_EXEC_CONT_EXPORT
|
||||
void GetPointsOfCell(vtkm::Id index, vtkm::Vec<vtkm::Id,IdsLength> &ids) const
|
||||
vtkm::Vec<vtkm::Id,NUM_POINTS_IN_CELL> GetPointsOfCell(vtkm::Id index) const
|
||||
{
|
||||
BOOST_STATIC_ASSERT(IdsLength >= 2);
|
||||
ids[0] = index;
|
||||
ids[1] = ids[0] + 1;
|
||||
vtkm::Vec<vtkm::Id,NUM_POINTS_IN_CELL> pointIds;
|
||||
pointIds[0] = index;
|
||||
pointIds[1] = pointIds[0] + 1;
|
||||
return pointIds;
|
||||
}
|
||||
|
||||
template <vtkm::IdComponent IdsLength>
|
||||
VTKM_EXEC_CONT_EXPORT
|
||||
void GetCellsOfPoint(vtkm::Id index, vtkm::Vec<vtkm::Id,IdsLength> &ids) const
|
||||
vtkm::IdComponent GetNumberOfCellsIncidentOnPoint(vtkm::Id pointIndex) const
|
||||
{
|
||||
BOOST_STATIC_ASSERT(IdsLength >= 2);
|
||||
ids[0] = ids[1] = -1;
|
||||
return
|
||||
(static_cast<vtkm::IdComponent>(pointIndex > 0)
|
||||
+ static_cast<vtkm::IdComponent>(pointIndex < this->PointDimensions-1));
|
||||
}
|
||||
|
||||
VTKM_EXEC_CONT_EXPORT
|
||||
vtkm::Vec<vtkm::Id,MAX_CELL_TO_POINT> GetCellsOfPoint(vtkm::Id index) const
|
||||
{
|
||||
vtkm::Vec<vtkm::Id,MAX_CELL_TO_POINT> cellIds;
|
||||
|
||||
cellIds[0] = cellIds[1] = -1;
|
||||
vtkm::IdComponent idx = 0;
|
||||
if (index > 0)
|
||||
{
|
||||
ids[idx++] = index-1;
|
||||
cellIds[idx++] = index-1;
|
||||
}
|
||||
if (index < this->PointDimensions-1)
|
||||
{
|
||||
ids[idx++] = index;
|
||||
cellIds[idx++] = index;
|
||||
}
|
||||
|
||||
return cellIds;
|
||||
}
|
||||
|
||||
VTKM_CONT_EXPORT
|
||||
@ -158,57 +171,73 @@ public:
|
||||
return this->GetPointDimensions();
|
||||
}
|
||||
|
||||
static const vtkm::IdComponent NUM_POINTS_IN_CELL = 4;
|
||||
static const vtkm::IdComponent MAX_CELL_TO_POINT = 4;
|
||||
|
||||
VTKM_EXEC_CONT_EXPORT
|
||||
vtkm::Id GetNumberOfCells() const
|
||||
{
|
||||
return vtkm::internal::VecProduct<2>()(this->GetCellDimensions());
|
||||
}
|
||||
VTKM_EXEC_CONT_EXPORT
|
||||
vtkm::IdComponent GetNumberOfPointsInCell() const { return 4; }
|
||||
vtkm::IdComponent GetNumberOfPointsInCell() const {return NUM_POINTS_IN_CELL;}
|
||||
VTKM_EXEC_CONT_EXPORT
|
||||
vtkm::CellType GetCellShape() const { return VTKM_PIXEL; }
|
||||
|
||||
template <vtkm::IdComponent IdsLength>
|
||||
VTKM_EXEC_CONT_EXPORT
|
||||
void GetPointsOfCell(vtkm::Id index, vtkm::Vec<vtkm::Id,IdsLength> &ids) const
|
||||
vtkm::Vec<vtkm::Id,NUM_POINTS_IN_CELL> GetPointsOfCell(vtkm::Id index) const
|
||||
{
|
||||
BOOST_STATIC_ASSERT(IdsLength >= 4);
|
||||
|
||||
vtkm::Id i, j;
|
||||
this->CalculateLogicalPointIndices(index, i, j);
|
||||
|
||||
ids[0] = j*this->PointDimensions[0] + i;
|
||||
ids[1] = ids[0] + 1;
|
||||
ids[2] = ids[0] + this->PointDimensions[0];
|
||||
ids[3] = ids[2] + 1;
|
||||
vtkm::Vec<vtkm::Id,NUM_POINTS_IN_CELL> pointIds;
|
||||
pointIds[0] = j*this->PointDimensions[0] + i;
|
||||
pointIds[1] = pointIds[0] + 1;
|
||||
pointIds[2] = pointIds[0] + this->PointDimensions[0];
|
||||
pointIds[3] = pointIds[2] + 1;
|
||||
return pointIds;
|
||||
}
|
||||
|
||||
template <vtkm::IdComponent IdsLength>
|
||||
VTKM_EXEC_CONT_EXPORT
|
||||
void GetCellsOfPoint(vtkm::Id index, vtkm::Vec<vtkm::Id,IdsLength> &ids) const
|
||||
vtkm::IdComponent GetNumberOfCellsIncidentOnPoint(vtkm::Id pointIndex) const
|
||||
{
|
||||
BOOST_STATIC_ASSERT(IdsLength >= 4);
|
||||
vtkm::Id i, j;
|
||||
this->CalculateLogicalPointIndices(pointIndex, i, j);
|
||||
return
|
||||
(static_cast<vtkm::IdComponent>((i > 0) && (j > 0))
|
||||
+ static_cast<vtkm::IdComponent>((i < this->PointDimensions[0]-1) && (j > 0))
|
||||
+ static_cast<vtkm::IdComponent>((i > 0) && (j < this->PointDimensions[1]-1))
|
||||
+ static_cast<vtkm::IdComponent>(
|
||||
(i < this->PointDimensions[0]-1) && (j < this->PointDimensions[1]-1)));
|
||||
}
|
||||
|
||||
ids[0] = ids[1] = ids[2] = ids[3] = -1;
|
||||
VTKM_EXEC_CONT_EXPORT
|
||||
vtkm::Vec<vtkm::Id,MAX_CELL_TO_POINT> GetCellsOfPoint(vtkm::Id index) const
|
||||
{
|
||||
vtkm::Vec<vtkm::Id,MAX_CELL_TO_POINT> cellIds;
|
||||
|
||||
cellIds[0] = cellIds[1] = cellIds[2] = cellIds[3] = -1;
|
||||
vtkm::Id i, j;
|
||||
vtkm::IdComponent idx = 0;
|
||||
CalculateLogicalPointIndices(index, i, j);
|
||||
this->CalculateLogicalPointIndices(index, i, j);
|
||||
if ((i > 0) && (j > 0))
|
||||
{
|
||||
ids[idx++] = this->CalculateCellIndex(i-1, j-1);
|
||||
cellIds[idx++] = this->CalculateCellIndex(i-1, j-1);
|
||||
}
|
||||
if ((i < this->PointDimensions[0]-1) && (j > 0))
|
||||
{
|
||||
ids[idx++] = this->CalculateCellIndex(i , j-1);
|
||||
cellIds[idx++] = this->CalculateCellIndex(i , j-1);
|
||||
}
|
||||
if ((i > 0) && (j < this->PointDimensions[1]-1))
|
||||
{
|
||||
ids[idx++] = this->CalculateCellIndex(i-1, j );
|
||||
cellIds[idx++] = this->CalculateCellIndex(i-1, j );
|
||||
}
|
||||
if ((i < this->PointDimensions[0]-1) && (j < this->PointDimensions[1]-1))
|
||||
{
|
||||
ids[idx++] = this->CalculateCellIndex(i , j );
|
||||
cellIds[idx++] = this->CalculateCellIndex(i , j );
|
||||
}
|
||||
|
||||
return cellIds;
|
||||
}
|
||||
|
||||
VTKM_CONT_EXPORT
|
||||
@ -279,22 +308,22 @@ public:
|
||||
return this->GetPointDimensions();
|
||||
}
|
||||
|
||||
static const vtkm::IdComponent NUM_POINTS_IN_CELL = 8;
|
||||
static const vtkm::IdComponent MAX_CELL_TO_POINT = 6;
|
||||
|
||||
VTKM_EXEC_CONT_EXPORT
|
||||
vtkm::Id GetNumberOfCells() const
|
||||
{
|
||||
return vtkm::internal::VecProduct<3>()(this->GetCellDimensions());
|
||||
}
|
||||
VTKM_EXEC_CONT_EXPORT
|
||||
vtkm::IdComponent GetNumberOfPointsInCell() const { return 8; }
|
||||
vtkm::IdComponent GetNumberOfPointsInCell() const {return NUM_POINTS_IN_CELL;}
|
||||
VTKM_EXEC_CONT_EXPORT
|
||||
vtkm::CellType GetCellShape() const { return VTKM_VOXEL; }
|
||||
|
||||
template <vtkm::IdComponent IdsLength>
|
||||
VTKM_EXEC_CONT_EXPORT
|
||||
void GetPointsOfCell(vtkm::Id index, vtkm::Vec<vtkm::Id,IdsLength> &ids) const
|
||||
vtkm::Vec<vtkm::Id,NUM_POINTS_IN_CELL> GetPointsOfCell(vtkm::Id index) const
|
||||
{
|
||||
BOOST_STATIC_ASSERT(IdsLength >= 8);
|
||||
|
||||
vtkm::Id3 cellDimensions = this->GetCellDimensions();
|
||||
|
||||
vtkm::Id cellDims01 = cellDimensions[0] * cellDimensions[1];
|
||||
@ -303,23 +332,25 @@ public:
|
||||
vtkm::Id j = indexij / cellDimensions[0];
|
||||
vtkm::Id i = indexij % cellDimensions[0];
|
||||
|
||||
ids[0] = (k * this->PointDimensions[1] + j) * this->PointDimensions[0] + i;
|
||||
ids[1] = ids[0] + 1;
|
||||
ids[2] = ids[0] + this->PointDimensions[0];
|
||||
ids[3] = ids[2] + 1;
|
||||
ids[4] = ids[0] + this->PointDimensions[0]*this->PointDimensions[1];
|
||||
ids[5] = ids[4] + 1;
|
||||
ids[6] = ids[4] + this->PointDimensions[0];
|
||||
ids[7] = ids[6] + 1;
|
||||
vtkm::Vec<vtkm::Id,NUM_POINTS_IN_CELL> pointIds;
|
||||
pointIds[0] = (k * this->PointDimensions[1] + j) * this->PointDimensions[0] + i;
|
||||
pointIds[1] = pointIds[0] + 1;
|
||||
pointIds[2] = pointIds[0] + this->PointDimensions[0];
|
||||
pointIds[3] = pointIds[2] + 1;
|
||||
pointIds[4] = pointIds[0] + this->PointDimensions[0]*this->PointDimensions[1];
|
||||
pointIds[5] = pointIds[4] + 1;
|
||||
pointIds[6] = pointIds[4] + this->PointDimensions[0];
|
||||
pointIds[7] = pointIds[6] + 1;
|
||||
|
||||
return pointIds;
|
||||
}
|
||||
|
||||
template <vtkm::IdComponent IdsLength>
|
||||
VTKM_EXEC_CONT_EXPORT
|
||||
void GetCellsOfPoint(vtkm::Id index, vtkm::Vec<vtkm::Id,IdsLength> &ids) const
|
||||
vtkm::Vec<vtkm::Id,MAX_CELL_TO_POINT> GetCellsOfPoint(vtkm::Id index) const
|
||||
{
|
||||
BOOST_STATIC_ASSERT(IdsLength >= 8);
|
||||
vtkm::Vec<vtkm::Id,MAX_CELL_TO_POINT> cellIds;
|
||||
|
||||
ids[0]=ids[1]=ids[2]=ids[3]=ids[4]=ids[5]=ids[6]=ids[7]=-1;
|
||||
cellIds[0]=cellIds[1]=cellIds[2]=cellIds[3]=cellIds[4]=cellIds[5]=-1;
|
||||
|
||||
vtkm::Id i, j, k;
|
||||
vtkm::IdComponent idx=0;
|
||||
@ -327,45 +358,47 @@ public:
|
||||
this->CalculateLogicalPointIndices(index, i, j, k);
|
||||
if ((i > 0) && (j > 0) && (k > 0))
|
||||
{
|
||||
ids[idx++] = this->CalculateCellIndex(i-1, j-1, k-1);
|
||||
cellIds[idx++] = this->CalculateCellIndex(i-1, j-1, k-1);
|
||||
}
|
||||
if ((i < this->PointDimensions[0]-1) && (j > 0) && (k > 0))
|
||||
{
|
||||
ids[idx++] = this->CalculateCellIndex(i , j-1, k-1);
|
||||
cellIds[idx++] = this->CalculateCellIndex(i , j-1, k-1);
|
||||
}
|
||||
if ((i > 0) && (j < this->PointDimensions[1]-1) && (k > 0))
|
||||
{
|
||||
ids[idx++] = this->CalculateCellIndex(i-1, j , k-1);
|
||||
cellIds[idx++] = this->CalculateCellIndex(i-1, j , k-1);
|
||||
}
|
||||
if ((i < this->PointDimensions[0]-1) &&
|
||||
(j < this->PointDimensions[1]-1) &&
|
||||
(k > 0))
|
||||
{
|
||||
ids[idx++] = this->CalculateCellIndex(i , j , k-1);
|
||||
cellIds[idx++] = this->CalculateCellIndex(i , j , k-1);
|
||||
}
|
||||
|
||||
if ((i > 0) && (j > 0) && (k < this->PointDimensions[2]-1))
|
||||
{
|
||||
ids[idx++] = this->CalculateCellIndex(i-1, j-1, k);
|
||||
cellIds[idx++] = this->CalculateCellIndex(i-1, j-1, k);
|
||||
}
|
||||
if ((i < this->PointDimensions[0]-1) &&
|
||||
(j > 0) &&
|
||||
(k < this->PointDimensions[2]-1))
|
||||
{
|
||||
ids[idx++] = this->CalculateCellIndex(i , j-1, k);
|
||||
cellIds[idx++] = this->CalculateCellIndex(i , j-1, k);
|
||||
}
|
||||
if ((i > 0) &&
|
||||
(j < this->PointDimensions[1]-1) &&
|
||||
(k < this->PointDimensions[2]-1))
|
||||
{
|
||||
ids[idx++] = this->CalculateCellIndex(i-1, j , k);
|
||||
cellIds[idx++] = this->CalculateCellIndex(i-1, j , k);
|
||||
}
|
||||
if ((i < this->PointDimensions[0]-1) &&
|
||||
(j < this->PointDimensions[1]-1) &&
|
||||
(k < this->PointDimensions[2]-1))
|
||||
{
|
||||
ids[idx++] = this->CalculateCellIndex(i , j , k);
|
||||
cellIds[idx++] = this->CalculateCellIndex(i , j , k);
|
||||
}
|
||||
|
||||
return cellIds;
|
||||
}
|
||||
|
||||
VTKM_CONT_EXPORT
|
||||
@ -417,19 +450,21 @@ template<vtkm::IdComponent Dimension>
|
||||
struct ConnectivityStructuredIndexHelper<
|
||||
vtkm::TopologyElementTagPoint, vtkm::TopologyElementTagCell, Dimension>
|
||||
{
|
||||
template <vtkm::IdComponent ItemTupleLength>
|
||||
typedef vtkm::internal::ConnectivityStructuredInternals<Dimension>
|
||||
ConnectivityType;
|
||||
|
||||
typedef vtkm::Vec<vtkm::Id,ConnectivityType::NUM_POINTS_IN_CELL> IndicesType;
|
||||
|
||||
VTKM_EXEC_CONT_EXPORT
|
||||
static void GetIndices(
|
||||
const vtkm::internal::ConnectivityStructuredInternals<Dimension> &connectivity,
|
||||
vtkm::Id cellIndex,
|
||||
vtkm::Vec<vtkm::Id,ItemTupleLength> &ids)
|
||||
static IndicesType GetIndices(const ConnectivityType &connectivity,
|
||||
vtkm::Id cellIndex)
|
||||
{
|
||||
connectivity.GetPointsOfCell(cellIndex, ids);
|
||||
return connectivity.GetPointsOfCell(cellIndex);
|
||||
}
|
||||
|
||||
VTKM_EXEC_CONT_EXPORT
|
||||
static vtkm::IdComponent GetNumberOfIndices(
|
||||
const vtkm::internal::ConnectivityStructuredInternals<Dimension> &connectivity,
|
||||
const ConnectivityType &connectivity,
|
||||
vtkm::Id vtkmNotUsed(cellIndex))
|
||||
{
|
||||
return connectivity.GetNumberOfPointsInCell();
|
||||
@ -440,18 +475,27 @@ template<vtkm::IdComponent Dimension>
|
||||
struct ConnectivityStructuredIndexHelper<
|
||||
vtkm::TopologyElementTagCell, vtkm::TopologyElementTagPoint, Dimension>
|
||||
{
|
||||
template <vtkm::IdComponent ItemTupleLength>
|
||||
typedef vtkm::internal::ConnectivityStructuredInternals<Dimension>
|
||||
ConnectivityType;
|
||||
|
||||
// TODO: This needs to change to a Vec-like that supports a max size.
|
||||
// Likewise, all the GetCellsOfPoint methods need to use it as well.
|
||||
typedef vtkm::Vec<vtkm::Id,ConnectivityType::MAX_CELL_TO_POINT> IndicesType;
|
||||
|
||||
VTKM_EXEC_CONT_EXPORT
|
||||
static void GetIndices(
|
||||
const vtkm::internal::ConnectivityStructuredInternals<Dimension> &connectivity,
|
||||
vtkm::Id pointIndex,
|
||||
vtkm::Vec<vtkm::Id,ItemTupleLength> &ids)
|
||||
static IndicesType GetIndices(const ConnectivityType &connectivity,
|
||||
vtkm::Id pointIndex)
|
||||
{
|
||||
connectivity.GetCellsOfPoint(pointIndex,ids);
|
||||
return connectivity.GetCellsOfPoint(pointIndex);
|
||||
}
|
||||
|
||||
// TODO: Implement GetNumberOfIndices, which will rely on a
|
||||
// GetNumberOfCellsOnPoint method in ConnectivityStructuredInternals
|
||||
VTKM_EXEC_CONT_EXPORT
|
||||
static vtkm::IdComponent GetNumberOfIndices(
|
||||
const ConnectivityType &connectivity,
|
||||
vtkm::Id pointIndex)
|
||||
{
|
||||
return connectivity.GetNumberOfCellsIncidentOnPoint(pointIndex);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -42,14 +42,14 @@ public:
|
||||
VTKM_CONT_EXPORT
|
||||
MaxPointOrCellValue() { }
|
||||
|
||||
template<typename T>
|
||||
template<typename T, typename FromIndexType>
|
||||
VTKM_EXEC_EXPORT
|
||||
void operator()(const T &cellValue,
|
||||
T& maxValue,
|
||||
const vtkm::exec::TopologyData<T,LEN_IDS> &pointValues,
|
||||
const vtkm::Id &count,
|
||||
const vtkm::Id & vtkmNotUsed(type),
|
||||
const vtkm::exec::TopologyData<vtkm::Id,LEN_IDS> & vtkmNotUsed(pointIDs)) const
|
||||
const FromIndexType& vtkmNotUsed(pointIDs)) const
|
||||
{
|
||||
//simple functor that returns the max of cellValue and pointValue
|
||||
maxValue = cellValue;
|
||||
@ -59,14 +59,14 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T1, typename T2, typename T3>
|
||||
template<typename T1, typename T2, typename T3, typename FromIndexType>
|
||||
VTKM_EXEC_EXPORT
|
||||
void operator()(const T1 &,
|
||||
T2 &,
|
||||
const vtkm::exec::TopologyData<T3,LEN_IDS> &,
|
||||
const vtkm::Id &,
|
||||
const vtkm::Id &,
|
||||
const vtkm::exec::TopologyData<vtkm::Id,LEN_IDS> &) const
|
||||
const FromIndexType &) const
|
||||
{
|
||||
this->RaiseError("Cannot call this worklet with different types.");
|
||||
}
|
||||
|
@ -45,14 +45,14 @@ public:
|
||||
VTKM_CONT_EXPORT
|
||||
MaxPointOrCellValue() { }
|
||||
|
||||
template<typename T>
|
||||
template<typename T, typename FromIndexType>
|
||||
VTKM_EXEC_EXPORT
|
||||
void operator()(const T &cellval,
|
||||
T& max_value,
|
||||
const vtkm::exec::TopologyData<T,LEN_IDS> &pointValues,
|
||||
const vtkm::Id &count,
|
||||
const vtkm::Id & vtkmNotUsed(type),
|
||||
const vtkm::exec::TopologyData<vtkm::Id,LEN_IDS> & vtkmNotUsed(pointIDs)) const
|
||||
const FromIndexType & vtkmNotUsed(pointIDs)) const
|
||||
{
|
||||
//simple functor that returns the max of cellValue and pointValue
|
||||
max_value = cellval;
|
||||
@ -62,14 +62,14 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T1, typename T2, typename T3>
|
||||
template<typename T1, typename T2, typename T3, typename FromIndex>
|
||||
VTKM_EXEC_EXPORT
|
||||
void operator()(const T1 &,
|
||||
T2 &,
|
||||
const vtkm::exec::TopologyData<T3,LEN_IDS> &,
|
||||
const vtkm::Id &,
|
||||
const vtkm::Id &,
|
||||
const vtkm::exec::TopologyData<vtkm::Id,LEN_IDS> &) const
|
||||
const FromIndex &) const
|
||||
{
|
||||
this->RaiseError("Cannot call this worklet with different types.");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user