diff --git a/vtkm/filter/connected_components/CellSetConnectivity.cxx b/vtkm/filter/connected_components/CellSetConnectivity.cxx index 00e3a31d95f28d1fdb98bb44cf1bb600d955b857..ad9a3007d323ab77620dbe60c10c21c053fbed8f 100644 --- a/vtkm/filter/connected_components/CellSetConnectivity.cxx +++ b/vtkm/filter/connected_components/CellSetConnectivity.cxx @@ -21,7 +21,7 @@ VTKM_CONT vtkm::cont::DataSet CellSetConnectivity::DoExecute(const vtkm::cont::D { vtkm::cont::ArrayHandle component; - vtkm::worklet::connectivity::CellSetConnectivity().Run(input.GetCellSet(), component); + vtkm::worklet::connectivity::CellSetConnectivity::Run(input.GetCellSet(), component); return this->CreateResultFieldCell(input, this->GetOutputFieldName(), component); } diff --git a/vtkm/filter/connected_components/testing/UnitTestGraphConnectivityWorklet.cxx b/vtkm/filter/connected_components/testing/UnitTestGraphConnectivityWorklet.cxx index 975a7022cbe931c01bb9a3c55abf893b48a4004b..d2f803c403663f8a26a0994b0866733cd23d827e 100644 --- a/vtkm/filter/connected_components/testing/UnitTestGraphConnectivityWorklet.cxx +++ b/vtkm/filter/connected_components/testing/UnitTestGraphConnectivityWorklet.cxx @@ -93,7 +93,7 @@ public: vtkm::cont::ArrayHandle conns_h = vtkm::cont::make_ArrayHandle(conns, vtkm::CopyFlag::Off); vtkm::cont::ArrayHandle comps_h; - vtkm::worklet::connectivity::GraphConnectivity().Run(counts_h, offsets_h, conns_h, comps_h); + vtkm::worklet::connectivity::GraphConnectivity::Run(counts_h, offsets_h, conns_h, comps_h); VTKM_TEST_ASSERT(vtkm::cont::Algorithm::Reduce(comps_h, vtkm::Id(0), vtkm::Maximum{}) == ncomps - 1, diff --git a/vtkm/filter/connected_components/worklet/CellSetConnectivity.h b/vtkm/filter/connected_components/worklet/CellSetConnectivity.h index f97dc15b492fafceb953b5aa2ccad28cbb310db4..f65ab808faf6990923bc1c92a08cb123df89bd20 100644 --- a/vtkm/filter/connected_components/worklet/CellSetConnectivity.h +++ b/vtkm/filter/connected_components/worklet/CellSetConnectivity.h @@ -23,17 +23,17 @@ namespace connectivity class CellSetConnectivity { public: - template - void Run(const CellSetType& cellSet, vtkm::cont::ArrayHandle& componentArray) const + static void Run(const vtkm::cont::UnknownCellSet& cellSet, + vtkm::cont::ArrayHandle& componentArray) { vtkm::cont::ArrayHandle numIndicesArray; vtkm::cont::ArrayHandle indexOffsetsArray; vtkm::cont::ArrayHandle connectivityArray; // create cell to cell connectivity graph (dual graph) - CellSetDualGraph().Run(cellSet, numIndicesArray, indexOffsetsArray, connectivityArray); + CellSetDualGraph::Run(cellSet, numIndicesArray, indexOffsetsArray, connectivityArray); // find the connected component of the dual graph - GraphConnectivity().Run(numIndicesArray, indexOffsetsArray, connectivityArray, componentArray); + GraphConnectivity::Run(numIndicesArray, indexOffsetsArray, connectivityArray, componentArray); } }; } diff --git a/vtkm/filter/connected_components/worklet/CellSetDualGraph.h b/vtkm/filter/connected_components/worklet/CellSetDualGraph.h index c5063b35e28fd8e43aa2ab3e170ceaca2a565ea4..bb414f1c10c61a2877323de74293a1198ee1fd72 100644 --- a/vtkm/filter/connected_components/worklet/CellSetDualGraph.h +++ b/vtkm/filter/connected_components/worklet/CellSetDualGraph.h @@ -99,19 +99,11 @@ struct CellToCellConnectivity : public vtkm::worklet::WorkletMapField class CellSetDualGraph { -public: using Algorithm = vtkm::cont::Algorithm; - struct degree2 - { - VTKM_EXEC - bool operator()(vtkm::Id degree) const { return degree >= 2; } - }; - - template - void EdgeToCellConnectivity(const CellSet& cellSet, - vtkm::cont::ArrayHandle& cellIds, - vtkm::cont::ArrayHandle& cellEdges) const + static void EdgeToCellConnectivity(const vtkm::cont::UnknownCellSet& cellSet, + vtkm::cont::ArrayHandle& cellIds, + vtkm::cont::ArrayHandle& cellEdges) { // Get number of edges for each cell and use it as scatter count. vtkm::cont::ArrayHandle numEdgesPerCell; @@ -124,11 +116,17 @@ public: edgeExtractDisp.Invoke(cellSet, cellIds, cellEdges); } - template - void Run(const CellSetType& cellSet, - vtkm::cont::ArrayHandle& numIndicesArray, - vtkm::cont::ArrayHandle& indexOffsetArray, - vtkm::cont::ArrayHandle& connectivityArray) const +public: + struct degree2 + { + VTKM_EXEC + bool operator()(vtkm::Id degree) const { return degree >= 2; } + }; + + static void Run(const vtkm::cont::UnknownCellSet& cellSet, + vtkm::cont::ArrayHandle& numIndicesArray, + vtkm::cont::ArrayHandle& indexOffsetArray, + vtkm::cont::ArrayHandle& connectivityArray) { // calculate the uncompressed Edge to Cell connectivity from Point to Cell connectivity // in the CellSet diff --git a/vtkm/filter/connected_components/worklet/GraphConnectivity.h b/vtkm/filter/connected_components/worklet/GraphConnectivity.h index 0e676d154b55aa8cf586f9d61ae298eff373c936..fe349763cc6e7fea816a0ea9bb62c5eff4f4ad94 100644 --- a/vtkm/filter/connected_components/worklet/GraphConnectivity.h +++ b/vtkm/filter/connected_components/worklet/GraphConnectivity.h @@ -69,10 +69,10 @@ class GraphConnectivity { public: template - void Run(const InputArrayType& numIndicesArray, - const InputArrayType& indexOffsetsArray, - const InputArrayType& connectivityArray, - OutputArrayType& componentsOut) const + static void Run(const InputArrayType& numIndicesArray, + const InputArrayType& indexOffsetsArray, + const InputArrayType& connectivityArray, + OutputArrayType& componentsOut) { VTKM_IS_ARRAY_HANDLE(InputArrayType); VTKM_IS_ARRAY_HANDLE(OutputArrayType); diff --git a/vtkm/filter/entity_extraction/GhostCellRemove.cxx b/vtkm/filter/entity_extraction/GhostCellRemove.cxx index 576d0cf510a04ab58a1974a9b6c31c6606f6b334..d1ffd6dea0fefe1bfb5909e4ff46483963e5a42c 100644 --- a/vtkm/filter/entity_extraction/GhostCellRemove.cxx +++ b/vtkm/filter/entity_extraction/GhostCellRemove.cxx @@ -352,17 +352,12 @@ VTKM_CONT vtkm::cont::DataSet GhostCellRemove::DoExecute(const vtkm::cont::DataS if (this->GetRemoveAllGhost()) { - cellOut = worklet.Run(cells.ResetCellSetList(), - fieldArray, - field.GetAssociation(), - RemoveAllGhosts()); + cellOut = worklet.Run(cells, fieldArray, field.GetAssociation(), RemoveAllGhosts()); } else if (this->GetRemoveByType()) { - cellOut = worklet.Run(cells.ResetCellSetList(), - fieldArray, - field.GetAssociation(), - RemoveGhostByType(this->GetRemoveType())); + cellOut = worklet.Run( + cells, fieldArray, field.GetAssociation(), RemoveGhostByType(this->GetRemoveType())); } else { diff --git a/vtkm/filter/entity_extraction/Threshold.cxx b/vtkm/filter/entity_extraction/Threshold.cxx index 1de6f31325053aea4724c1eba3611eddc3ea1ec0..2bc9f29b4977be9969fd031d2cae1ded632859cc 100644 --- a/vtkm/filter/entity_extraction/Threshold.cxx +++ b/vtkm/filter/entity_extraction/Threshold.cxx @@ -83,15 +83,8 @@ vtkm::cont::DataSet Threshold::DoExecute(const vtkm::cont::DataSet& input) vtkm::cont::UnknownCellSet cellOut; auto resolveArrayType = [&](const auto& concrete) { - // Note: there are two overloads of .Run, the first one taking an UncertainCellSet, which is - // the desired entry point in the following call. The other is a function template on the input - // CellSet. Without the call to .ResetCellSetList to turn an UnknownCellSet to an UncertainCellSet, - // the compiler will pick the function template (i.e. wrong overload). - cellOut = worklet.Run(cells.ResetCellSetList(), - concrete, - field.GetAssociation(), - predicate, - this->GetAllInRange()); + cellOut = + worklet.Run(cells, concrete, field.GetAssociation(), predicate, this->GetAllInRange()); }; field.GetData().CastAndCallForTypes( diff --git a/vtkm/filter/entity_extraction/worklet/Threshold.h b/vtkm/filter/entity_extraction/worklet/Threshold.h index f62a7b328891bd6c0959c22f99d1724cb2209694..ddbb30918a10e8d8dbf0658284210f2836e3b97b 100644 --- a/vtkm/filter/entity_extraction/worklet/Threshold.h +++ b/vtkm/filter/entity_extraction/worklet/Threshold.h @@ -30,12 +30,6 @@ namespace worklet class Threshold { public: - enum class FieldType - { - Point, - Cell - }; - template class ThresholdByPointField : public vtkm::worklet::WorkletVisitCellsWithPoints { @@ -84,22 +78,8 @@ public: bool ReturnAllInRange; }; - struct ThresholdCopy : public vtkm::worklet::WorkletMapField - { - using ControlSignature = void(FieldIn, FieldOut, WholeArrayIn); - - template - VTKM_EXEC void operator()(vtkm::Id& index, - ScalarType& output, - const WholeFieldIn& inputField) const - { - output = inputField.Get(index); - } - }; - - template - vtkm::cont::CellSetPermutation Run( + vtkm::cont::CellSetPermutation RunImpl( const CellSetType& cellSet, const vtkm::cont::ArrayHandle& field, const vtkm::cont::Field::Association fieldType, @@ -141,53 +121,18 @@ public: return OutputType(this->ValidCellIds, cellSet); } - template - struct CallWorklet - { - vtkm::cont::UnknownCellSet& Output; - vtkm::worklet::Threshold& Worklet; - const FieldArrayType& Field; - const vtkm::cont::Field::Association FieldType; - const UnaryPredicate& Predicate; - const bool ReturnAllInRange; - - CallWorklet(vtkm::cont::UnknownCellSet& output, - vtkm::worklet::Threshold& worklet, - const FieldArrayType& field, - const vtkm::cont::Field::Association fieldType, - const UnaryPredicate& predicate, - const bool returnAllInRange) - : Output(output) - , Worklet(worklet) - , Field(field) - , FieldType(fieldType) - , Predicate(predicate) - , ReturnAllInRange(returnAllInRange) - { - } - - template - void operator()(const CellSetType& cellSet) const - { - // Copy output to an explicit grid so that other units can guess what this is. - this->Output = vtkm::worklet::CellDeepCopy::Run(this->Worklet.Run( - cellSet, this->Field, this->FieldType, this->Predicate, this->ReturnAllInRange)); - } - }; - - template - vtkm::cont::UnknownCellSet Run(const vtkm::cont::UncertainCellSet& cellSet, + template + vtkm::cont::UnknownCellSet Run(const vtkm::cont::UnknownCellSet& cellSet, const vtkm::cont::ArrayHandle& field, const vtkm::cont::Field::Association fieldType, const UnaryPredicate& predicate, const bool returnAllInRange = false) { - using Worker = CallWorklet, UnaryPredicate>; - vtkm::cont::UnknownCellSet output; - Worker worker(output, *this, field, fieldType, predicate, returnAllInRange); - cellSet.CastAndCall(worker); - + CastAndCall(cellSet, [&](auto concrete) { + output = vtkm::worklet::CellDeepCopy::Run( + this->template RunImpl(concrete, field, fieldType, predicate, returnAllInRange)); + }); return output; }