Make it easier to construct ThreadIndices by hand.

In some cases it is necessary to construct ThreadIndices to manually
use vtkm::exec::Fetch. This now makes it possible.
This commit is contained in:
Robert Maynard 2016-11-28 13:10:37 -05:00
parent 60843cbab8
commit 06af2fbcbf
2 changed files with 39 additions and 3 deletions

@ -43,7 +43,7 @@ class ThreadIndicesBasic
{
public:
VTKM_EXEC
ThreadIndicesBasic(vtkm::Id threadIndex, vtkm::Id inIndex,
ThreadIndicesBasic(vtkm::Id threadIndex, vtkm::Id inIndex,
vtkm::IdComponent visitIndex, vtkm::Id globalThreadIndexOffset=0)
: InputIndex(inIndex),
OutputIndex(threadIndex),

@ -79,7 +79,7 @@ public:
const OutToInArrayType& inToOut,
const VisitArrayType& visit,
const ConnectivityType& connectivity,
vtkm::Id globalThreadIndexOffset)
vtkm::Id globalThreadIndexOffset=0)
: Superclass(threadIndex, inToOut.Get(threadIndex), visit.Get(threadIndex),
globalThreadIndexOffset),
CellShape(detail::CellShapeInitializer<CellShapeTag>::GetDefault())
@ -93,6 +93,25 @@ public:
this->CellShape = connectivity.GetCellShape(this->GetInputIndex());
}
VTKM_SUPPRESS_EXEC_WARNINGS
VTKM_EXEC
ThreadIndicesTopologyMap(vtkm::Id threadIndex,
vtkm::Id inIndex,
vtkm::IdComponent visitIndex,
const ConnectivityType& connectivity,
vtkm::Id globalThreadIndexOffset=0)
: Superclass(threadIndex, inIndex, visitIndex, globalThreadIndexOffset),
CellShape(detail::CellShapeInitializer<CellShapeTag>::GetDefault())
{
// The connectivity is stored in the invocation parameter at the given
// input domain index. If this class is being used correctly, the type
// of the domain will match the connectivity type used here. If there is
// a compile error here about a type mismatch, chances are a worklet has
// set its input domain incorrectly.
this->IndicesFrom = connectivity.GetIndices(this->GetInputIndex());
this->CellShape = connectivity.GetCellShape(this->GetInputIndex());
}
/// \brief The input indices of the "from" elements.
///
/// A topology map has "from" and "to" elements (for example from points to
@ -193,7 +212,7 @@ public:
const OutToInArrayType& inToOut,
const VisitArrayType& visit,
const ConnectivityType& connectivity,
vtkm::Id globalThreadIndexOffset=0)
vtkm::Id globalThreadIndexOffset=0)
{
this->InputIndex = inToOut.Get(threadIndex);
@ -229,6 +248,23 @@ public:
this->GlobalThreadIndexOffset = globalThreadIndexOffset;
}
VTKM_SUPPRESS_EXEC_WARNINGS
VTKM_EXEC
ThreadIndicesTopologyMap(vtkm::Id threadIndex,
vtkm::Id inIndex,
vtkm::IdComponent visitIndex,
const ConnectivityType& connectivity,
vtkm::Id globalThreadIndexOffset=0)
{
this->InputIndex = threadIndex;
this->OutputIndex = threadIndex;
this->VisitIndex = visitIndex;
this->LogicalIndex = connectivity.FlatToLogicalToIndex(this->InputIndex);
this->IndicesFrom = connectivity.GetIndices(this->LogicalIndex);
this->CellShape = connectivity.GetCellShape(this->InputIndex);
this->GlobalThreadIndexOffset = globalThreadIndexOffset;
}
/// \brief The logical index into the input domain.
///
/// This is similar to \c GetIndex3D except the Vec size matches the actual