VTK-m  2.0
BoundaryVerticesPerSuperArcWorklets.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 //
42 // This code is an extension of the algorithm presented in the paper:
43 // Parallel Peak Pruning for Scalable SMP Contour Tree Computation.
44 // Hamish Carr, Gunther Weber, Christopher Sewell, and James Ahrens.
45 // Proceedings of the IEEE Symposium on Large Data Analysis and Visualization
46 // (LDAV), October 2016, Baltimore, Maryland.
47 //
48 // The PPP2 algorithm and software were jointly developed by
49 // Hamish Carr (University of Leeds), Gunther H. Weber (LBNL), and
50 // Oliver Ruebel (LBNL)
51 //==============================================================================
52 
53 #ifndef vtk_m_worklet_contourtree_distributed_bract_maker_boundary_vertices_per_superarc_worklets_h
54 #define vtk_m_worklet_contourtree_distributed_bract_maker_boundary_vertices_per_superarc_worklets_h
55 
58 
59 namespace vtkm
60 {
61 namespace worklet
62 {
63 namespace contourtree_distributed
64 {
65 namespace bract_maker
66 {
67 
68 // Step 1of2 for BoundaryRestrictedAugmentedContourTreeMaker<MeshType>::ComputeDependentBoundaryCounts
70 {
71 public:
72  using ControlSignature = void(WholeArrayIn boundarySuperparents, // (input)
73  WholeArrayOut superarcIntrinsicBoundaryCount); // (output) hyperarcs
74  using ExecutionSignature = void(_1, InputIndex, _2);
75  using InputDomain = _1;
76 
77  // Default Constructor
80  : NumBoundary(numBoundary)
81  {
82  }
83 
84  template <typename InFieldPortalType, typename OutFieldPortalType>
85  VTKM_EXEC void operator()(const InFieldPortalType& boundarySuperparentsPortal,
86  const vtkm::Id& boundaryVertex,
87  const OutFieldPortalType& superarcIntrinsicBoundaryCountPortal) const
88  {
89  if (boundaryVertex == 0)
90  {
91  return;
92  }
93 
94  vtkm::Id superarcId = boundarySuperparentsPortal.Get(boundaryVertex);
95  vtkm::Id prevSuperarcId = boundarySuperparentsPortal.Get(boundaryVertex - 1);
96 
97  // i. Start by detecting the high end of the range
98  // if they don't match, we're at the beginning of a segment - set the *LOWER* segment's value
99  if (superarcId != prevSuperarcId)
100  {
101  superarcIntrinsicBoundaryCountPortal.Set(prevSuperarcId, boundaryVertex);
102  }
103  // ii. Now set the last one explicitly
104  if (boundaryVertex == (this->NumBoundary - 1))
105  {
106  superarcIntrinsicBoundaryCountPortal.Set(superarcId, this->NumBoundary);
107  }
108  // In serial this worklet implements the following operation
109  /*
110  for (indexType boundaryVertex = 1; boundaryVertex < nBoundary; boundaryVertex++)
111  { // per boundary vertex
112  indexType superarcID = boundarySuperparents[boundaryVertex];
113  indexType prevSuperarcID = boundarySuperparents[boundaryVertex-1];
114  // if they don't match, we're at the beginning of a segment - set the *LOWER* segment's value
115  if (superarcID != prevSuperarcID)
116  superarcIntrinsicBoundaryCount[prevSuperarcID] = boundaryVertex;
117  } // per boundary vertex
118  superarcIntrinsicBoundaryCount[boundarySuperparents[nBoundary-1]] = nBoundary;
119 
120  */
121  }
122 
123 private:
125 
126 }; // BoundaryVerticiesPerSuperArcStepOneWorklet
127 
128 
129 
130 // Step 1of2 for BoundaryRestrictedAugmentedContourTreeMaker<MeshType>::ComputeDependentBoundaryCounts
132 {
133 public:
134  using ControlSignature = void(WholeArrayIn boundarySuperparents, // (input)
135  WholeArrayOut superarcIntrinsicBoundaryCount); // (output) hyperarcs
136  using ExecutionSignature = void(_1, InputIndex, _2);
137  using InputDomain = _1;
138 
139  // Default Constructor
142 
143  template <typename InFieldPortalType, typename OutFieldPortalType>
144  VTKM_EXEC void operator()(const InFieldPortalType& boundarySuperparentsPortal,
145  const vtkm::Id& boundaryVertex,
146  const OutFieldPortalType& superarcIntrinsicBoundaryCountPortal) const
147  {
148  if (boundaryVertex == 0)
149  {
150  return;
151  }
152 
153  vtkm::Id superarcId = boundarySuperparentsPortal.Get(boundaryVertex);
154  vtkm::Id prevSuperarcId = boundarySuperparentsPortal.Get(boundaryVertex - 1);
155 
156  // i. Start by detecting the high end of the range
157  // if they don't match, we're at the beginning of a segment - set the *LOWER* segment's value
158  if (superarcId != prevSuperarcId)
159  {
160  superarcIntrinsicBoundaryCountPortal.Set(
161  superarcId, superarcIntrinsicBoundaryCountPortal.Get(superarcId) - boundaryVertex);
162  }
163 
164  // In serial this worklet implements the following operation
165  /*
166  for (indexType boundaryVertex = 1; boundaryVertex < nBoundary; boundaryVertex++)
167  { // per boundary vertex
168  indexType superarcID = boundarySuperparents[boundaryVertex];
169  indexType prevSuperarcID = boundarySuperparents[boundaryVertex-1];
170  // if they don't match, we're at the beginning of a segment - set the *LOWER* segment's value
171  if (superarcID != prevSuperarcID)
172  superarcIntrinsicBoundaryCount[superarcID] -= boundaryVertex;
173  } // per boundary vertex
174 
175  */
176  }
177 }; // BoundaryVerticiesPerSuperArcStepTwoWorklet
178 
179 } // namespace bract_maker
180 } // namespace contourtree_distributed
181 } // namespace worklet
182 } // namespace vtkm
183 
184 #endif
vtkm::worklet::contourtree_distributed::bract_maker::BoundaryVerticiesPerSuperArcStepOneWorklet::InputDomain
_1 InputDomain
Definition: BoundaryVerticesPerSuperArcWorklets.h:75
vtkm::worklet::contourtree_distributed::bract_maker::BoundaryVerticiesPerSuperArcStepTwoWorklet::operator()
VTKM_EXEC void operator()(const InFieldPortalType &boundarySuperparentsPortal, const vtkm::Id &boundaryVertex, const OutFieldPortalType &superarcIntrinsicBoundaryCountPortal) const
Definition: BoundaryVerticesPerSuperArcWorklets.h:144
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::contourtree_distributed::bract_maker::BoundaryVerticiesPerSuperArcStepTwoWorklet::ControlSignature
void(WholeArrayIn boundarySuperparents, WholeArrayOut superarcIntrinsicBoundaryCount) ControlSignature
Definition: BoundaryVerticesPerSuperArcWorklets.h:135
vtkm::worklet::contourtree_distributed::bract_maker::BoundaryVerticiesPerSuperArcStepTwoWorklet
Definition: BoundaryVerticesPerSuperArcWorklets.h:131
vtkm::Id
vtkm::Int32 Id
Represents an ID (index into arrays).
Definition: Types.h:191
vtkm::worklet::contourtree_distributed::bract_maker::BoundaryVerticiesPerSuperArcStepTwoWorklet::ExecutionSignature
void(_1, InputIndex, _2) ExecutionSignature
Definition: BoundaryVerticesPerSuperArcWorklets.h:136
vtkm::worklet::contourtree_distributed::bract_maker::BoundaryVerticiesPerSuperArcStepOneWorklet::ExecutionSignature
void(_1, InputIndex, _2) ExecutionSignature
Definition: BoundaryVerticesPerSuperArcWorklets.h:74
vtkm::worklet::contourtree_distributed::bract_maker::BoundaryVerticiesPerSuperArcStepOneWorklet::operator()
VTKM_EXEC void operator()(const InFieldPortalType &boundarySuperparentsPortal, const vtkm::Id &boundaryVertex, const OutFieldPortalType &superarcIntrinsicBoundaryCountPortal) const
Definition: BoundaryVerticesPerSuperArcWorklets.h:85
vtkm::worklet::contourtree_distributed::bract_maker::BoundaryVerticiesPerSuperArcStepOneWorklet::BoundaryVerticiesPerSuperArcStepOneWorklet
VTKM_EXEC_CONT BoundaryVerticiesPerSuperArcStepOneWorklet(vtkm::Id numBoundary)
Definition: BoundaryVerticesPerSuperArcWorklets.h:79
vtkm::worklet::contourtree_distributed::bract_maker::BoundaryVerticiesPerSuperArcStepOneWorklet::ControlSignature
void(WholeArrayIn boundarySuperparents, WholeArrayOut superarcIntrinsicBoundaryCount) ControlSignature
Definition: BoundaryVerticesPerSuperArcWorklets.h:73
Types.h
vtkm::worklet::contourtree_distributed::bract_maker::BoundaryVerticiesPerSuperArcStepOneWorklet
Definition: BoundaryVerticesPerSuperArcWorklets.h:69
vtkm::worklet::contourtree_distributed::bract_maker::BoundaryVerticiesPerSuperArcStepTwoWorklet::InputDomain
_1 InputDomain
Definition: BoundaryVerticesPerSuperArcWorklets.h:137
vtkm::exec::arg::InputIndex
The ExecutionSignature tag to use to get the input index.
Definition: InputIndex.h:42
vtkm::worklet::contourtree_distributed::bract_maker::BoundaryVerticiesPerSuperArcStepOneWorklet::NumBoundary
vtkm::Id NumBoundary
Definition: BoundaryVerticesPerSuperArcWorklets.h:124
vtkm::worklet::WorkletMapField
Base class for worklets that do a simple mapping of field arrays.
Definition: WorkletMapField.h:38
vtkm::worklet::contourtree_distributed::bract_maker::BoundaryVerticiesPerSuperArcStepTwoWorklet::BoundaryVerticiesPerSuperArcStepTwoWorklet
VTKM_EXEC_CONT BoundaryVerticiesPerSuperArcStepTwoWorklet()
Definition: BoundaryVerticesPerSuperArcWorklets.h:141