VTK-m  2.0
CopyBaseRegularStructureWorklet.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_copy_base_regular_structure_worklet_h
47 #define vtk_m_worklet_contourtree_distributed_hierarchical_augmenter_copy_base_regular_structure_worklet_h
48 
51 
52 namespace vtkm
53 {
54 namespace worklet
55 {
56 namespace contourtree_distributed
57 {
58 namespace hierarchical_augmenter
59 {
60 
64 {
65 public:
71  using ControlSignature = void(
72  FieldIn
73  regularNodesNeededRange, // input domain ArrayHandleIndex of [0, regularNodesNeeded.GetNumberOfValues()]
74  FieldIn
75  baseTreeRegularNodeGlobalIdsPermuted, // input baseTree->regularNodeGlobalIds permuted by regularNodesNeeded
76  FieldIn baseTreeDataValuesPermuted, // input baseTree->dataValues permuted by regularNodesNeeded
77  FieldIn regularSuperparentsPermuted, // input regularSuperparents permuted by regularNodesNeeded
78  FieldOut
79  augmentedTreeRegularNodeGlobalIdsView, // output view of augmentedTree->regularNodeGlobalIds[numExistingRegular:]
80  FieldOut
81  augmentedTreeDataValuesView, // output view of augmentedTree->dataValues[numExistingRegular:]
82  FieldOut
83  augmentedTreeSuperparentsView, // output view of augmentedTree->superparents[numExistingRegular:]
84  FieldOut
85  augmentedTreeRegularNodeSortOrderView // output view of augmentedTree->regularNodeSortOrder[numExistingRegular:]
86  );
87  using ExecutionSignature = void(_1, _2, _3, _4, _5, _6, _7, _8);
88  using InputDomain = _1;
89 
92  CopyBaseRegularStructureWorklet(const vtkm::Id& numExistingRegular)
93  : NumExistingRegular(numExistingRegular)
94  {
95  }
96 
98  template <typename FieldType>
100  const vtkm::Id& neededRegNode, // InputIndex in [0, regularNodesNeeded.GetNumberOfValues()]
101  const vtkm::Id&
102  baseTreeRegularNodeGlobalId, // same as baseTree->regularNodeGlobalIds[oldRegularID]
103  const FieldType& baseTreeDataValue, // same as baseTree->dataValues[oldRegularID]
104  const vtkm::Id& regularSuperparentsValue, // same regularSuperparents[oldRegularID]
105  vtkm::Id&
106  augmentedTreeRegularNodeGlobalIdValue, // same as augmentedTree->regularNodeGlobalIDs[NumExistingRegular + neededRegNode] = ...
107  FieldType&
108  augmentedTreeDataValue, // same as augmentedTree->dataValues[NumExistingRegular + neededRegNode] = ...
109  vtkm::Id&
110  augmentedTreeSuperparentsValue, // same as augmentedTree->superparents[NumExistingRegular + neededRegNode] = ...
111  vtkm::Id&
112  augmentedTreeRegularNodeSortOrderValue // same as augmentedTree->regularNodeSortOrder [NumExistingRegular + neededRegNode] = ...
113  ) const
114  {
115  // per regular node needing addition
116  // retrieve the existing index. oldRegularID is set on input
117  vtkm::Id newRegularId = this->NumExistingRegular +
118  neededRegNode; // not needed since we do ArrayHandleViews on the outside
119 
120  // now use them to copy data
121  augmentedTreeRegularNodeGlobalIdValue = baseTreeRegularNodeGlobalId;
122  augmentedTreeDataValue = baseTreeDataValue;
123  augmentedTreeSuperparentsValue = regularSuperparentsValue;
124 
125  // this one is special since we need to resort - set it to identity, leaving the sort order of old vertices alone
126  // this *MAY* make certain sorts run faster
127  augmentedTreeRegularNodeSortOrderValue = newRegularId;
128 
129  // NOTE: we can skip this step since Regular2supernode is already initalized with NO_SUCH_ELEMENT
130  // since these are *ALL* only regular nodes, this one's easy:
131  // augmentedTree->regular2supernode [newRegularID] = NO_SUCH_ELEMENT;
132 
133  // In serial this worklet implements the following operation
134  /*
135  for (vtkm::Id neededRegNode = 0; neededRegNode < nRegNeeded; neededRegNode++)
136  { // per regular node needing addition
137  // retrieve the existing index
138  vtkm::Id oldRegularID = regularNodesNeeded[neededRegNode];
139  // and compute the new index
140  vtkm::Id newRegularID = nExistingRegular + neededRegNode;
141 
142  // now use them to copy data
143  augmentedTree->regularNodeGlobalIDs [newRegularID] = baseTree->regularNodeGlobalIDs [oldRegularID];
144  augmentedTree->dataValues [newRegularID] = baseTree->dataValues [oldRegularID];
145  augmentedTree->superparents [newRegularID] = regularSuperparents [oldRegularID];
146 
147  // this one is special since we need to resort - set it to identity, leaving the sort order of old vertices alone
148  // this *MAY* make certain sorts run faster
149  augmentedTree->regularNodeSortOrder [newRegularID] = newRegularID;
150 
151  // since these are *ALL* only regular nodes, this one's easy:
152  augmentedTree->regular2supernode [newRegularID] = NO_SUCH_ELEMENT;
153  } // per regular node needing addition
154  */
155  } // operator()()
156 private:
158 
159 }; // CopyBaseRegularStructureWorklet
160 
161 } // namespace hierarchical_augmenter
162 } // namespace contourtree_distributed
163 } // namespace worklet
164 } // namespace vtkm
165 
166 #endif
vtkm::worklet::contourtree_distributed::hierarchical_augmenter::CopyBaseRegularStructureWorklet::CopyBaseRegularStructureWorklet
VTKM_EXEC_CONT CopyBaseRegularStructureWorklet(const vtkm::Id &numExistingRegular)
Default Constructor.
Definition: CopyBaseRegularStructureWorklet.h:92
vtkm::worklet::contourtree_distributed::hierarchical_augmenter::CopyBaseRegularStructureWorklet::NumExistingRegular
const vtkm::Id NumExistingRegular
Definition: CopyBaseRegularStructureWorklet.h:157
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::CopyBaseRegularStructureWorklet::ControlSignature
void(FieldIn regularNodesNeededRange, FieldIn baseTreeRegularNodeGlobalIdsPermuted, FieldIn baseTreeDataValuesPermuted, FieldIn regularSuperparentsPermuted, FieldOut augmentedTreeRegularNodeGlobalIdsView, FieldOut augmentedTreeDataValuesView, FieldOut augmentedTreeSuperparentsView, FieldOut augmentedTreeRegularNodeSortOrderView) ControlSignature
Control signature for the worklet NOTE: We require the input arrays (aside form the input domain) to ...
Definition: CopyBaseRegularStructureWorklet.h:86
vtkm::Id
vtkm::Int32 Id
Represents an ID (index into arrays).
Definition: Types.h:191
vtkm::worklet::WorkletMapField::FieldIn
A control signature tag for input fields.
Definition: WorkletMapField.h:49
vtkm::worklet::contourtree_distributed::hierarchical_augmenter::CopyBaseRegularStructureWorklet::operator()
VTKM_EXEC void operator()(const vtkm::Id &neededRegNode, const vtkm::Id &baseTreeRegularNodeGlobalId, const FieldType &baseTreeDataValue, const vtkm::Id &regularSuperparentsValue, vtkm::Id &augmentedTreeRegularNodeGlobalIdValue, FieldType &augmentedTreeDataValue, vtkm::Id &augmentedTreeSuperparentsValue, vtkm::Id &augmentedTreeRegularNodeSortOrderValue) const
operator() of the workelt
Definition: CopyBaseRegularStructureWorklet.h:99
vtkm::worklet::contourtree_distributed::hierarchical_augmenter::CopyBaseRegularStructureWorklet::InputDomain
_1 InputDomain
Definition: CopyBaseRegularStructureWorklet.h:88
Types.h
vtkm::worklet::contourtree_distributed::hierarchical_augmenter::CopyBaseRegularStructureWorklet::ExecutionSignature
void(_1, _2, _3, _4, _5, _6, _7, _8) ExecutionSignature
Definition: CopyBaseRegularStructureWorklet.h:87
vtkm::worklet::contourtree_distributed::hierarchical_augmenter::CopyBaseRegularStructureWorklet
Worklet used in HierarchicalAugmenter::CopyBaseRegularStructure for finding the superparent for each ...
Definition: CopyBaseRegularStructureWorklet.h:63
vtkm::worklet::WorkletMapField
Base class for worklets that do a simple mapping of field arrays.
Definition: WorkletMapField.h:38