Fix copy predictate for compressing arcs and fix init of arrays for FindCriticalPoints

This commit is contained in:
Oliver Ruebel 2020-09-17 05:39:34 -07:00 committed by Gunther H. Weber
parent 5cebd3b0dc
commit c4de6ba6e0
4 changed files with 31 additions and 39 deletions

@ -88,7 +88,7 @@
#include <vtkm/worklet/contourtree_distributed/tree_grafter/NewNodePredicate.h>
#include <vtkm/worklet/contourtree_distributed/tree_grafter/PermuteComparator.h>
#include <vtkm/worklet/contourtree_distributed/tree_grafter/SuperNodeWhenComparator.h>
#include <vtkm/worklet/contourtree_distributed/tree_grafter/SuperarcWasTransferredPredicate.h>
#include <vtkm/worklet/contourtree_distributed/tree_grafter/SuperarcWasNotTransferredPredicate.h>
#include <sstream>
#include <string>
@ -342,11 +342,7 @@ void TreeGrafter<MeshType, FieldType>::GraftInteriorForests(
// whether it is already present, saving the regular and super IDs if it is, NO_SUCH_ELEMENT otherwise
#ifdef DEBUG_PRINT
{
std::stringstream tempResultStream;
tempResultStream << "theRound: " << theRound << std::endl;
VTKM_LOG_S(vtkm::cont::LogLevel::Info, tempResultStream.str());
}
VTKM_LOG_S(vtkm::cont::LogLevel::Info, "theRound: " << theRound);
VTKM_LOG_S(vtkm::cont::LogLevel::Info,
this->DebugPrint("Before GraftResidue()", __FILE__, __LINE__));
VTKM_LOG_S(
@ -390,7 +386,6 @@ void TreeGrafter<MeshType, FieldType>::GraftInteriorForests(
this->NumTransferIterations++;
} // loop to transfer
#ifdef DEBUG_PRINT
VTKM_LOG_S(vtkm::cont::LogLevel::Info,
DebugPrint("Finished Transfer Iterations", __FILE__, __LINE__));
@ -647,22 +642,18 @@ template <typename MeshType, typename FieldType>
void TreeGrafter<MeshType, FieldType>::FindCriticalPoints()
{ // FindCriticalPoints()
// allocate memory for type of supernode
this->resizeIndexVector(this->SupernodeType,
this->ContourTree.Supernodes.GetNumberOfValues(),
vtkm::worklet::contourtree_augmented::NO_SUCH_ELEMENT);
// Reset the UpNeighbour and DownNeighbour array
vtkm::cont::Algorithm::Copy(
vtkm::cont::make_ArrayHandleConstant(vtkm::worklet::contourtree_augmented::NO_SUCH_ELEMENT,
this->ContourTree.Supernodes.GetNumberOfValues()),
this->SupernodeType);
// TODO: Hamish: I removed the code below to set UpNeighbour and DownNeighbour. According to the orginal code,
// this could be removed later for performance, since we always reset the ones we use. Also
// UpNeighbour and DownNeighbour are already initalized in InitializeActiveSuperarcs() so we
// should not need to do this again here.
/*vtkm::cont::Algorithm::Copy(
vtkm::cont::make_ArrayHandleConstant(vtkm::worklet::contourtree_augmented::NO_SUCH_ELEMENT,
this->UpNeighbour.GetNumberOfValues()),
this->UpNeighbour);
this->UpNeighbour.GetNumberOfValues()),
this->UpNeighbour);
vtkm::cont::Algorithm::Copy(
vtkm::cont::make_ArrayHandleConstant(vtkm::worklet::contourtree_augmented::NO_SUCH_ELEMENT,
this->DownNeighbour.GetNumberOfValues()),
this->DownNeighbour);*/
vtkm::cont::make_ArrayHandleConstant(vtkm::worklet::contourtree_augmented::NO_SUCH_ELEMENT,
this->DownNeighbour.GetNumberOfValues()),
this->DownNeighbour);
#ifdef DEBUG_PRINT
// TODO: Hamish: I don't think we need this DebugPrint here.
@ -828,8 +819,10 @@ void TreeGrafter<MeshType, FieldType>::CompressActiveArrays()
// create an array where we can put the compressed array
vtkm::worklet::contourtree_augmented::EdgePairArray compressedActiveSuperarcs;
// prediate for deciding which active superarcs to keep
// NOTE: The original PPP used std::remove_if instead of CopyIf so the predicate inverts the logic, i.e, the predicate indictes
// which values to keep rather than which ones to remove
auto superarcWasTransferredPredicate =
vtkm::worklet::contourtree_distributed::tree_grafter::SuperarcWasTransferredPredicate(
vtkm::worklet::contourtree_distributed::tree_grafter::SuperarcWasNotTransferredPredicate(
this->WhenTransferred);
// compress the array
vtkm::cont::Algorithm::CopyIf(
@ -846,7 +839,6 @@ void TreeGrafter<MeshType, FieldType>::CompressActiveArrays()
VTKM_LOG_S(vtkm::cont::LogLevel::Info,
DebugPrint("CompressActiveArrays() Complete", __FILE__, __LINE__));
#endif
} // CompressActiveArrays()

@ -19,7 +19,7 @@ set(headers
FindCriticalPointsFindTerminalElementsWorklet.h
CollapseRegularChainsWorklet.h
IdentifyLeafHyperarcsWorklet.h
SuperarcWasTransferredPredicate.h
SuperarcWasNotTransferredPredicate.h
NewHypernodePredicate.h
HyperNodeWhenComparator.h
SuperNodeWhenComparator.h

@ -74,9 +74,9 @@ public:
FieldIn
activeSuperarcs, // input iteration index. loop to one less than ContourTree->Supernodes.GetNumberOfValues()
WholeArrayIn interiorForstIsNecessary, // input
WholeArrayOut upNeighbour, // output
WholeArrayOut downNeighbour, // output
WholeArrayOut supernodeType // output
WholeArrayInOut upNeighbour, // output (Need In/Out to prevent overwrite?)
WholeArrayInOut downNeighbour, // output (Need In/Out to prevent overwrite?)
WholeArrayInOut supernodeType // output (Need In/Out to prevent overwrite?)
);
using ExecutionSignature = void(_1, _2, _3, _4, _5);

@ -50,8 +50,8 @@
// Oliver Ruebel (LBNL)
//==============================================================================
#ifndef vtk_m_worklet_contourtree_distributed_tree_grafter_superarc_was_transferred_predicate_h
#define vtk_m_worklet_contourtree_distributed_tree_grafter_superarc_was_transferred_predicate_h
#ifndef vtk_m_worklet_contourtree_distributed_tree_grafter_superarc_was_not_transferred_predicate_h
#define vtk_m_worklet_contourtree_distributed_tree_grafter_superarc_was_not_transferred_predicate_h
#include <vtkm/cont/ExecutionObjectBase.h>
@ -68,7 +68,7 @@ namespace tree_grafter
// Uniary predicate used in TreeGrafter.CompressActiveArrays to decide which active superarcs to keep
template <typename DeviceAdapter>
class SuperarcWasTransferredPredicateImpl : public vtkm::worklet::WorkletMapField
class SuperarcWasNotTransferredPredicateImpl : public vtkm::worklet::WorkletMapField
{
public:
using IdArrayPortalType =
@ -77,7 +77,7 @@ public:
// Default Constructor
VTKM_EXEC_CONT
SuperarcWasTransferredPredicateImpl(const IdArrayPortalType& whenTransferredPortal)
SuperarcWasNotTransferredPredicateImpl(const IdArrayPortalType& whenTransferredPortal)
: WhenTransferredPortal(whenTransferredPortal)
{
}
@ -85,10 +85,10 @@ public:
VTKM_EXEC bool operator()(const vtkm::worklet::contourtree_augmented::EdgePair& superarc) const
{ // operator ()
// if either end is marked as transferred, the arc must be gone already
return ((!vtkm::worklet::contourtree_augmented::NoSuchElement(
this->WhenTransferredPortal.Get(superarc.first))) ||
(!vtkm::worklet::contourtree_augmented::NoSuchElement(
this->WhenTransferredPortal.Get(superarc.second))));
return !((!vtkm::worklet::contourtree_augmented::NoSuchElement(
this->WhenTransferredPortal.Get(superarc.first))) ||
(!vtkm::worklet::contourtree_augmented::NoSuchElement(
this->WhenTransferredPortal.Get(superarc.second))));
} // operator ()
@ -96,25 +96,25 @@ private:
IdArrayPortalType WhenTransferredPortal;
}; // SuperarcWasTransferredPredicate
}; // SuperarcWasNotTransferredPredicate
class SuperarcWasTransferredPredicate : public vtkm::cont::ExecutionObjectBase
class SuperarcWasNotTransferredPredicate : public vtkm::cont::ExecutionObjectBase
{
public:
VTKM_CONT
SuperarcWasTransferredPredicate(
SuperarcWasNotTransferredPredicate(
const vtkm::worklet::contourtree_augmented::IdArrayType& whenTransferred)
: WhenTransferred(whenTransferred)
{
}
template <typename DeviceAdapter>
VTKM_CONT SuperarcWasTransferredPredicateImpl<DeviceAdapter> PrepareForExecution(
VTKM_CONT SuperarcWasNotTransferredPredicateImpl<DeviceAdapter> PrepareForExecution(
DeviceAdapter device,
vtkm::cont::Token& token) const
{
return SuperarcWasTransferredPredicateImpl<DeviceAdapter>(
return SuperarcWasNotTransferredPredicateImpl<DeviceAdapter>(
this->WhenTransferred.PrepareForInput(device, token));
}