Go to the documentation of this file.
71 #ifndef vtkm_worklet_contourtree_chaingraph_h
72 #define vtkm_worklet_contourtree_chaingraph_h
100 namespace contourtree
103 #define DEBUG_STRING_TRANSFER_GOVERNING_SADDLES "Extrema should now be assigned"
104 #define DEBUG_STRING_TRANSFER_SADDLE_STARTS "Transfer Saddle Starts "
105 #define DEBUG_STRING_TRANSFERRED_SADDLE_STARTS "Saddle Starts Transferred"
106 #define DEBUG_STRING_TRANSFER_TO_MERGE_TREE "Transfer to Merge Tree"
107 #define DEBUG_STRING_OUTDEGREE "Outdegree"
108 #define DEBUG_STRING_CHAINEXT "Chain Ext"
109 #define DEBUG_STRING_ACTIVE_OUTDEGREE "Active Outdegree"
110 #define DEBUG_STRING_ACTIVE_CHAINEXT "Active Chain Ext"
111 #define DEBUG_STRING_FAR_ID "Far"
112 #define DEBUG_STRING_FAR_INDEX "Far Index"
113 #define DEBUG_STRING_FAR_VALUE "Far Value"
114 #define DEBUG_STRING_NEAR_ID "Near"
115 #define DEBUG_STRING_NEAR_INDEX "Near Index"
116 #define DEBUG_STRING_NEAR_VALUE "Near Value"
117 #define DEBUG_STRING_EDGE_FAR_ID "Edge Far"
118 #define DEBUG_STRING_EDGE_NEAR_ID "Edge Near"
119 #define DEBUG_STRING_EDGE_NEAR_INDEX "Edge Near Index"
120 #define DEBUG_STRING_EDGE_NEAR_VALUE "Edge Near Value"
121 #define DEBUG_STRING_SORTED_NEAR_ID "Sorted Near"
122 #define DEBUG_STRING_SORTED_NEAR_INDEX "Sorted Near Index"
123 #define DEBUG_STRING_SORTED_NEAR_VALUE "Sorted Near Value"
124 #define DEBUG_STRING_SORTED_FAR_ID "Sorted Far"
126 template <
typename T,
typename StorageType>
218 template <
typename T,
typename StorageType>
221 valueIndex.Allocate(Size);
222 prunesTo.Allocate(Size);
223 firstEdge.Allocate(Size);
224 outdegree.Allocate(Size);
225 chainExtremum.Allocate(Size);
226 activeVertices.Allocate(Size);
230 template <
typename T,
typename StorageType>
233 edgeFar.Allocate(Size);
234 edgeNear.Allocate(Size);
235 activeEdges.Allocate(Size);
239 template <
typename T,
typename StorageType>
242 #ifdef DEBUG_FUNCTION_ENTRY
243 std::cout << std::endl;
244 std::cout <<
"===================" << std::endl;
245 std::cout <<
"Compute Chain Graph" << std::endl;
246 std::cout <<
"===================" << std::endl;
247 std::cout << std::endl;
251 DebugPrint(
"Chain Graph Computation Starting");
256 while (edgeSorter.GetNumberOfValues() > 0)
259 FindGoverningSaddles();
262 TransferRegularPoints();
265 CompactActiveVertices();
266 CompactActiveEdges();
272 TransferSaddleStarts();
282 firstEdge.ReleaseResources();
283 outdegree.ReleaseResources();
284 edgeNear.ReleaseResources();
285 edgeFar.ReleaseResources();
286 activeEdges.ReleaseResources();
287 activeVertices.ReleaseResources();
288 edgeSorter.ReleaseResources();
291 TransferToMergeTree(saddles);
294 chainExtremum.ReleaseResources();
295 prunesTo.ReleaseResources();
298 DebugPrint(
"Chain Graph Computed");
303 template <
typename T,
typename StorageType>
306 #ifdef DEBUG_FUNCTION_ENTRY
307 std::cout << std::endl;
308 std::cout <<
"======================" << std::endl;
309 std::cout <<
"Find Governing Saddles" << std::endl;
310 std::cout <<
"======================" << std::endl;
311 std::cout << std::endl;
317 values, valueIndex, edgeFar, edgeNear, arcArray, isJoinGraph));
320 DebugPrint(
"After Sorting");
326 governingSaddleFinder);
327 vtkm::Id nEdges = edgeSorter.GetNumberOfValues();
330 governingSaddleFinderDispatcher.Invoke(edgeIndexArray,
342 template <
typename T,
typename StorageType>
345 #ifdef DEBUG_FUNCTION_ENTRY
346 std::cout << std::endl;
347 std::cout <<
"=======================" << std::endl;
348 std::cout <<
"Transfer Regular Points" << std::endl;
349 std::cout <<
"=======================" << std::endl;
350 std::cout << std::endl;
354 regularPointTransferrer);
356 regularPointTransferrerDispatcher.Invoke(activeVertices,
363 DebugPrint(
"Regular Points Should Now Be Labelled");
368 template <
typename T,
typename StorageType>
371 #ifdef DEBUG_FUNCTION_ENTRY
372 std::cout << std::endl;
373 std::cout <<
"=======================" << std::endl;
374 std::cout <<
"Compact Active Vertices" << std::endl;
375 std::cout <<
"=======================" << std::endl;
376 std::cout << std::endl;
391 activeVertices.ReleaseResources();
395 DebugPrint(
"Active Vertex List Compacted");
400 template <
typename T,
typename StorageType>
403 #ifdef DEBUG_FUNCTION_ENTRY
404 std::cout << std::endl;
405 std::cout <<
"====================" << std::endl;
406 std::cout <<
"Compact Active Edges" << std::endl;
407 std::cout <<
"====================" << std::endl;
408 std::cout << std::endl;
411 vtkm::Id nActiveVertices = activeVertices.GetNumberOfValues();
416 newOutdegree.
Allocate(nActiveVertices);
423 vertexDegreeUpdater);
425 vertexDegreeUpdaterDispatcher.Invoke(activeVertices,
463 DebugPrint(
"Active Edges Now Compacted");
468 template <
typename T,
typename StorageType>
471 #ifdef DEBUG_FUNCTION_ENTRY
472 std::cout << std::endl;
473 std::cout <<
"============" << std::endl;
474 std::cout <<
"Build Chains" << std::endl;
475 std::cout <<
"============" << std::endl;
476 std::cout << std::endl;
480 tempChainExtremum.
Allocate(edgeNear.GetNumberOfValues());
483 vtkm::Id nActiveVertices = activeVertices.GetNumberOfValues();
485 for (
vtkm::Id shifter = nActiveVertices; shifter != 0; shifter >>= 1)
494 for (
vtkm::Id logStep = 0; logStep < nLogSteps; logStep++)
496 chainDoublerDispatcher.Invoke(activeVertices,
501 DebugPrint(
"Chains Built");
506 template <
typename T,
typename StorageType>
509 #ifdef DEBUG_FUNCTION_ENTRY
510 std::cout << std::endl;
511 std::cout <<
"=======================" << std::endl;
513 std::cout <<
"=======================" << std::endl;
514 std::cout << std::endl;
518 vtkm::Id nActiveVertices = activeVertices.GetNumberOfValues();
526 newFirstEdge.
Allocate(nActiveVertices);
527 newOutdegree.
Allocate(nActiveVertices);
532 saddleAscentFunctor);
534 saddleAscentFunctorDispatcher.Invoke(activeVertices,
547 edgeSorter.ReleaseResources();
548 edgeSorter.Allocate(nEdgesToSort);
552 saddleAscentTransferrer);
554 saddleAscentTransferrerDispatcher.Invoke(activeVertices,
567 template <
typename T,
typename StorageType>
570 #ifdef DEBUG_FUNCTION_ENTRY
571 std::cout << std::endl;
572 std::cout <<
"===========" << std::endl;
573 std::cout <<
"Build Trunk" << std::endl;
574 std::cout <<
"============" << std::endl;
575 std::cout << std::endl;
581 trunkBuilderDispatcher.Invoke(activeVertices,
585 DebugPrint(
"Trunk Built");
590 template <
typename T,
typename StorageType>
593 #ifdef DEBUG_FUNCTION_ENTRY
594 std::cout << std::endl;
595 std::cout <<
"=====================" << std::endl;
597 std::cout <<
"=====================" << std::endl;
598 std::cout << std::endl;
609 joinTreeTransferrer);
612 joinTreeTransferrerDispatcher.Invoke(valueIndexArray,
621 template <
typename T,
typename StorageType>
624 std::cout <<
"---------------------------" << std::endl;
625 std::cout << std::string(message) << std::endl;
626 std::cout <<
"---------------------------" << std::endl;
627 std::cout << std::endl;
638 std::cout <<
"Full Vertex Arrays - Size: " << nValues << std::endl;
647 std::cout << std::endl;
650 vtkm::Id nActiveVertices = activeVertices.GetNumberOfValues();
651 std::cout <<
"Active Vertex Arrays - Size: " << nActiveVertices << std::endl;
652 if (nActiveVertices > 0)
671 std::cout << std::endl;
675 vtkm::Id nEdges = edgeNear.GetNumberOfValues();
676 std::cout <<
"Full Edge Arrays - Size: " << nEdges << std::endl;
699 vtkm::Id nActiveEdges = activeEdges.GetNumberOfValues();
700 std::cout <<
"Active Edge Arrays - Size: " << nActiveEdges << std::endl;
701 if (nActiveEdges > 0)
719 std::cout << std::endl;
723 vtkm::Id nEdgeSorter = edgeSorter.GetNumberOfValues();
724 std::cout <<
"Edge Sorter - Size: " << nEdgeSorter << std::endl;
740 std::cout << std::endl;
743 std::cout <<
"---------------------------" << std::endl;
744 std::cout << std::endl;
void PrintHeader(vtkm::Id howMany)
Definition: PrintVectors.h:155
VTKM_CONT vtkm::Id GetNumberOfValues() const
Returns the number of entries in the array.
Definition: ArrayHandle.h:448
Definition: ChainGraph.h:127
vtkm::cont::ArrayHandle< vtkm::Id > prunesTo
Definition: ChainGraph.h:148
Definition: SaddleAscentTransferrer.h:83
void TransferSaddleStarts()
Definition: ChainGraph.h:507
void AllocateEdgeArrays(vtkm::Id Size)
Definition: ChainGraph.h:231
Definition: EdgePeakComparator.h:87
vtkm::cont::ArrayHandle< vtkm::Id > activeVertices
Definition: ChainGraph.h:164
Groups connected points that have the same field value.
Definition: Atomic.h:19
bool isJoinGraph
Definition: ChainGraph.h:140
const vtkm::cont::ArrayHandle< T, StorageType > & values
Definition: ChainGraph.h:131
VTKM_CONT void Allocate(vtkm::Id numberOfValues, vtkm::CopyFlag preserve, vtkm::cont::Token &token) const
Allocates an array large enough to hold the given number of values.
Definition: ArrayHandle.h:465
#define DEBUG_STRING_TRANSFER_TO_MERGE_TREE
Definition: ChainGraph.h:106
vtkm::cont::ArrayHandle< vtkm::Id > chainExtremum
Definition: ChainGraph.h:157
void CompactActiveEdges()
Definition: ChainGraph.h:401
static VTKM_CONT void Sort(vtkm::cont::DeviceAdapterId devId, vtkm::cont::ArrayHandle< T, Storage > &values)
Definition: Algorithm.h:965
VTKM_CONT T ArrayGetValue(vtkm::Id id, const vtkm::cont::ArrayHandle< T, S > &data)
Obtain a small set of values from an ArrayHandle with minimal device transfers.
Definition: ArrayGetValues.h:264
static VTKM_CONT bool Copy(vtkm::cont::DeviceAdapterId devId, const vtkm::cont::ArrayHandle< T, CIn > &input, vtkm::cont::ArrayHandle< U, COut > &output)
Definition: Algorithm.h:410
vtkm::Int32 Id
Represents an ID (index into arrays).
Definition: Types.h:191
vtkm::cont::ArrayHandle< vtkm::Id > outdegree
Definition: ChainGraph.h:154
void BuildTrunk()
Definition: ChainGraph.h:568
vtkm::Id nIterations
Definition: ChainGraph.h:143
void PrintValues(std::string label, vtkm::cont::ArrayHandle< T, StorageType > &dVec, vtkm::Id nValues=-1)
Definition: PrintVectors.h:174
void TransferToMergeTree(vtkm::cont::ArrayHandle< vtkm::Id > &saddles)
Definition: ChainGraph.h:591
void AllocateVertexArrays(vtkm::Id Size)
Definition: ChainGraph.h:219
Dispatcher for worklets that inherit from WorkletMapField.
Definition: DispatcherMapField.h:25
vtkm::cont::ArrayHandle< vtkm::Id > edgeFar
Definition: ChainGraph.h:160
void Compute(vtkm::cont::ArrayHandle< vtkm::Id > &saddles)
Definition: ChainGraph.h:240
Definition: JoinTreeTransferrer.h:88
vtkm::cont::ArrayHandle< vtkm::Id > edgeSorter
Definition: ChainGraph.h:168
static VTKM_CONT T ScanExclusive(vtkm::cont::DeviceAdapterId devId, const vtkm::cont::ArrayHandle< T, CIn > &input, vtkm::cont::ArrayHandle< T, COut > &output)
Definition: Algorithm.h:816
Implicitly permutes the values in an array.
Definition: ArrayHandlePermutation.h:227
void ArrayCopy(const SourceArrayType &source, DestArrayType &destination)
Does a deep copy from one array to another array.
Definition: ArrayCopy.h:142
vtkm::cont::ArrayHandle< vtkm::Id > IdArrayType
Definition: filter/scalar_topology/worklet/contourtree_augmented/Types.h:90
static VTKM_CONT void CopyIf(vtkm::cont::DeviceAdapterId devId, const vtkm::cont::ArrayHandle< T, CIn > &input, const vtkm::cont::ArrayHandle< U, CStencil > &stencil, vtkm::cont::ArrayHandle< T, COut > &output)
Definition: Algorithm.h:435
void CompactActiveVertices()
Definition: ChainGraph.h:369
#define DEBUG_STRING_TRANSFER_GOVERNING_SADDLES
Definition: ChainGraph.h:103
void DebugPrint(const char *message)
Definition: ChainGraph.h:622
ChainGraph(const vtkm::cont::ArrayHandle< T, StorageType > &Values, vtkm::cont::ArrayHandle< vtkm::Id > &ArcArray, bool IsJoinGraph)
Definition: ChainGraph.h:171
vtkm::cont::ArrayHandle< vtkm::Id > valueIndex
Definition: ChainGraph.h:137
vtkm::cont::ArrayHandle< vtkm::Id > & arcArray
Definition: ChainGraph.h:134
vtkm::cont::ArrayHandle< vtkm::Id > firstEdge
Definition: ChainGraph.h:151
vtkm::cont::ArrayHandle< vtkm::Id > activeEdges
Definition: ChainGraph.h:165
Definition: GoverningSaddleFinder.h:86
void BuildChains()
Definition: ChainGraph.h:469
Definition: ChainDoubler.h:91
vtkm::cont::ArrayHandle< vtkm::Id > edgeNear
Definition: ChainGraph.h:161
void FindGoverningSaddles()
Definition: ChainGraph.h:304
void PrintIndices(std::string label, vtkm::cont::ArrayHandle< vtkm::Id > &iVec, vtkm::Id nIndices=-1)
Definition: PrintVectors.h:202
#define DEBUG_STRING_TRANSFER_SADDLE_STARTS
Definition: ChainGraph.h:104
void TransferRegularPoints()
Definition: ChainGraph.h:343
#define DEBUG_STRING_TRANSFERRED_SADDLE_STARTS
Definition: ChainGraph.h:105
Definition: SaddleAscentFunctor.h:84
VTKM_CONT void ReleaseResources() const
Releases all resources in both the control and execution environments.
Definition: ArrayHandle.h:559
Definition: RegularPointTransferrer.h:90
Definition: TrunkBuilder.h:88
An implicit array handle containing the its own indices.
Definition: ArrayHandleIndex.h:54
Definition: VertexDegreeUpdater.h:87