VTK-m  2.0
UpdateHyperstructureSetHyperarcsAndNodesWorklet.h
Go to the documentation of this file.
1 //============================================================================
2 // Copyright (c) Kitware, Inc.
3 // All rights reserved.
4 // See LICENSE.txt for details.
5 //
6 // This software is distributed WITHOUT ANY WARRANTY; without even
7 // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
8 // PURPOSE. See the above copyright notice for more information.
9 //============================================================================
10 // Copyright (c) 2018, The Regents of the University of California, through
11 // Lawrence Berkeley National Laboratory (subject to receipt of any required approvals
12 // from the U.S. Dept. of Energy). All rights reserved.
13 //
14 // Redistribution and use in source and binary forms, with or without modification,
15 // are permitted provided that the following conditions are met:
16 //
17 // (1) Redistributions of source code must retain the above copyright notice, this
18 // list of conditions and the following disclaimer.
19 //
20 // (2) Redistributions in binary form must reproduce the above copyright notice,
21 // this list of conditions and the following disclaimer in the documentation
22 // and/or other materials provided with the distribution.
23 //
24 // (3) Neither the name of the University of California, Lawrence Berkeley National
25 // Laboratory, U.S. Dept. of Energy nor the names of its contributors may be
26 // used to endorse or promote products derived from this software without
27 // specific prior written permission.
28 //
29 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
30 // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
31 // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
32 // IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
33 // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
34 // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
36 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
37 // OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
38 // OF THE POSSIBILITY OF SUCH DAMAGE.
39 //
40 //=============================================================================
41 // The PPP2 algorithm and software were jointly developed by
42 // Hamish Carr (University of Leeds), Gunther H. Weber (LBNL), and
43 // Oliver Ruebel (LBNL)
44 //==============================================================================
45 
46 #ifndef vtk_m_worklet_contourtree_distributed_hierarchical_augmenter_update_hyperstructure_set_hyperarcs_and_nodes_worklet_h
47 #define vtk_m_worklet_contourtree_distributed_hierarchical_augmenter_update_hyperstructure_set_hyperarcs_and_nodes_worklet_h
48 
51 
52 namespace vtkm
53 {
54 namespace worklet
55 {
56 namespace contourtree_distributed
57 {
58 namespace hierarchical_augmenter
59 {
60 
63 {
64 public:
66  using ControlSignature = void(FieldIn baseTreeHypernodes, // input
67  FieldIn baseTreeHyperarcs, // input
68  WholeArrayIn newSupernodeIds, // input
69  FieldOut augmentedTreeHypernodes, // output
70  FieldOut augmentedTreeHyperarcs // output
71  );
72  using ExecutionSignature = void(_1, _2, _3, _4, _5);
73  using InputDomain = _1;
74 
75  // Default Constructor
78 
79  template <typename InFieldPortalType>
81  const vtkm::Id& oldHypernodeSuperId, // same as baseTree->hypernodes[hypernode]
82  const vtkm::Id& oldTargetSuperIdMasked, // same as baseTree->hyperarcs[hypernode]
83  const InFieldPortalType& newSupernodeIdsPortal,
84  vtkm::Id& outAugmentedTreeHypernodesValue, // same as augmentedTree->hypernodes[hypernode] = ...
85  vtkm::Id& outAugmentedTreeHyperarcsValue // same as augmentedTree->hyperarcs[hypernode] = ...
86  ) const
87  {
88  // per hypernode
89  // retrieve existing values which are in old supernode Ids
90  // oldHypernodeSuperId and oldTargetSuperIdMasked are set by the worklt
91  // strip out the ascending flag & the flag for root hyperarc
92  bool isRootHyperarc =
94  bool hyperarcAscends =
96  vtkm::Id oldTargetSuperId =
98 
99  // lookup new values
100  vtkm::Id newHypernodeSuperId = newSupernodeIdsPortal.Get(oldHypernodeSuperId);
102  if (!isRootHyperarc)
103  { // not the root
104  // lookup the new ID
105  newTargetSuperId = newSupernodeIdsPortal.Get(oldTargetSuperId);
106  if (hyperarcAscends)
107  {
109  }
110  } // not the root
111 
112  // now store them
113  outAugmentedTreeHypernodesValue = newHypernodeSuperId;
114  outAugmentedTreeHyperarcsValue = newTargetSuperId;
115 
116  // In serial this worklet implements the following operation
117  /*
118  for (vtkm::Id hypernode = 0; hypernode < augmentedTree->hypernodes.size(); hypernode++)
119  { // per hypernode
120  // retrieve existing values which are in old supernode IDs
121  vtkm::Id oldHypernodeSuperID = baseTree->hypernodes[hypernode];
122  vtkm::Id oldTargetSuperID = baseTree->hyperarcs[hypernode];
123  // strip out the ascending flag & the flag for root hyperarc
124  bool isRootHyperarc = noSuchElement(oldTargetSuperID);
125  bool hyperarcAscends = isAscending(oldTargetSuperID);
126  oldTargetSuperID = maskedIndex(oldTargetSuperID);
127 
128  // lookup new values
129  vtkm::Id newHypernodeSuperID = newSupernodeIDs[oldHypernodeSuperID];
130  vtkm::Id newTargetSuperID = NO_SUCH_ELEMENT;
131  if (!isRootHyperarc)
132  { // not the root
133  // lookup the new ID
134  newTargetSuperID = newSupernodeIDs[oldTargetSuperID];
135  if (hyperarcAscends)
136  newTargetSuperID |= IS_ASCENDING;
137  } // not the root
138 
139  // now store them
140  augmentedTree->hypernodes[hypernode] = newHypernodeSuperID;
141  augmentedTree->hyperarcs[hypernode] = newTargetSuperID;
142  } // per hypernode
143 
144  */
145  } // operator()()
146 }; // UpdateHyperstructureSetHyperarcsAndNodesWorklet
147 
148 } // namespace hierarchical_augmenter
149 } // namespace contourtree_distributed
150 } // namespace worklet
151 } // namespace vtkm
152 
153 #endif
vtkm::worklet::contourtree_distributed::hierarchical_augmenter::UpdateHyperstructureSetHyperarcsAndNodesWorklet::ExecutionSignature
void(_1, _2, _3, _4, _5) ExecutionSignature
Definition: UpdateHyperstructureSetHyperarcsAndNodesWorklet.h:72
vtkm::worklet::contourtree_augmented::IsAscending
VTKM_EXEC_CONT bool IsAscending(vtkm::Id flaggedIndex)
Definition: filter/scalar_topology/worklet/contourtree_augmented/Types.h:121
VTKM_EXEC
#define VTKM_EXEC
Definition: ExportMacros.h:51
vtkm
Groups connected points that have the same field value.
Definition: Atomic.h:19
WorkletMapField.h
VTKM_EXEC_CONT
#define VTKM_EXEC_CONT
Definition: ExportMacros.h:52
vtkm::worklet::WorkletMapField::FieldOut
A control signature tag for output fields.
Definition: WorkletMapField.h:60
vtkm::worklet::contourtree_distributed::hierarchical_augmenter::UpdateHyperstructureSetHyperarcsAndNodesWorklet::ControlSignature
void(FieldIn baseTreeHypernodes, FieldIn baseTreeHyperarcs, WholeArrayIn newSupernodeIds, FieldOut augmentedTreeHypernodes, FieldOut augmentedTreeHyperarcs) ControlSignature
Control signature for the worklet.
Definition: UpdateHyperstructureSetHyperarcsAndNodesWorklet.h:71
vtkm::worklet::contourtree_augmented::MaskedIndex
VTKM_EXEC_CONT vtkm::Id MaskedIndex(vtkm::Id flaggedIndex)
Definition: filter/scalar_topology/worklet/contourtree_augmented/Types.h:127
vtkm::Id
vtkm::Int32 Id
Represents an ID (index into arrays).
Definition: Types.h:191
vtkm::worklet::contourtree_distributed::hierarchical_augmenter::UpdateHyperstructureSetHyperarcsAndNodesWorklet
Worklet used in HierarchicalAugmenter::UpdateHyperstructure to set the hyperarcs and hypernodes.
Definition: UpdateHyperstructureSetHyperarcsAndNodesWorklet.h:62
vtkm::worklet::contourtree_augmented::NoSuchElement
VTKM_EXEC_CONT bool NoSuchElement(vtkm::Id flaggedIndex)
Definition: filter/scalar_topology/worklet/contourtree_augmented/Types.h:97
vtkm::worklet::WorkletMapField::FieldIn
A control signature tag for input fields.
Definition: WorkletMapField.h:49
Types.h
vtkm::worklet::contourtree_augmented::IS_ASCENDING
constexpr vtkm::Id IS_ASCENDING
Definition: filter/scalar_topology/worklet/contourtree_augmented/Types.h:77
vtkm::worklet::contourtree_distributed::hierarchical_augmenter::UpdateHyperstructureSetHyperarcsAndNodesWorklet::InputDomain
_1 InputDomain
Definition: UpdateHyperstructureSetHyperarcsAndNodesWorklet.h:73
vtkm::worklet::contourtree_augmented::NO_SUCH_ELEMENT
constexpr vtkm::Id NO_SUCH_ELEMENT
Definition: filter/scalar_topology/worklet/contourtree_augmented/Types.h:73
vtkm::worklet::contourtree_distributed::hierarchical_augmenter::UpdateHyperstructureSetHyperarcsAndNodesWorklet::operator()
VTKM_EXEC void operator()(const vtkm::Id &oldHypernodeSuperId, const vtkm::Id &oldTargetSuperIdMasked, const InFieldPortalType &newSupernodeIdsPortal, vtkm::Id &outAugmentedTreeHypernodesValue, vtkm::Id &outAugmentedTreeHyperarcsValue) const
Definition: UpdateHyperstructureSetHyperarcsAndNodesWorklet.h:80
vtkm::worklet::contourtree_distributed::hierarchical_augmenter::UpdateHyperstructureSetHyperarcsAndNodesWorklet::UpdateHyperstructureSetHyperarcsAndNodesWorklet
VTKM_EXEC_CONT UpdateHyperstructureSetHyperarcsAndNodesWorklet()
Definition: UpdateHyperstructureSetHyperarcsAndNodesWorklet.h:77
vtkm::worklet::WorkletMapField
Base class for worklets that do a simple mapping of field arrays.
Definition: WorkletMapField.h:38