VTK-m  2.0
SetInteriorForestWorklet.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_set_interior_forest_worklet_h
54 #define vtk_m_worklet_contourtree_distributed_bract_maker_set_interior_forest_worklet_h
55 
58 
59 namespace vtkm
60 {
61 namespace worklet
62 {
63 namespace contourtree_distributed
64 {
65 namespace bract_maker
66 {
67 
71 {
72 public:
73  using ControlSignature = void(FieldIn contourTreeSupernodes, // input
74  FieldIn interiorForestIsNecessary, // input
75  FieldIn boundaryTreeMakerTree2Superset, // input
76  WholeArrayIn meshGlobalIdsFromMeshIndices, // input
77  WholeArrayIn boundaryTreeMakerUpNeighbour, // input
78  WholeArrayIn boundaryTreeMakerDownNeighbour, // input
79  FieldInOut interiorForestAbove, // output
80  FieldInOut interiorForestBelow // output
81  );
82  using ExecutionSignature = void(_1, _2, _3, _4, _5, _6, _7, _8);
83  using InputDomain = _1;
84 
85  // Default Constructor
88 
89  // Allow for different portal type for the meshGlobalIds as they may be a fancy
90  // array handle rather than a portal direclty to a IdArrayType
91  template <typename InFieldPortalType, typename GlobalIdFieldPortalType>
92  VTKM_EXEC void operator()(const vtkm::Id& sortId,
93  const vtkm::Id& isNecessary,
94  const vtkm::Id& supersetId,
95  const GlobalIdFieldPortalType& meshGlobalIdsPortal,
96  const InFieldPortalType& upNeighbourPortal,
97  const InFieldPortalType& downNeighbourPortal,
98  vtkm::Id& interiorForestAbove,
99  vtkm::Id& interiorForestBelow) const
100  {
101  (void)
102  sortId; // TODO: Remove if not needed. This was included in original code but seems unused. Avoid compiler warning.
103  // per supernode
104  // ignore supernodes that weren't marked necessary, since they will never be searched for
105  // all nodes to be searched for are necessary, but not all necessary nodes will be searched for
106  if (isNecessary)
107  { // necessary supernode
108  // first, convert it to a sort ID: Asignement of sortId from contourTreeSupernodes done on input
109  // now find it in the superset: Assignment of supersetId from boundaryTreeMakerTree2Superset done on input
110 
111  // find the up neighbour and convert it to a global ID: note that we may have a leaf
112  // in which case this may be NO_SUCH_ELEMENT. This will not be searched for, but for safety,
113  // we will test for it explicitly
114  vtkm::Id upSupersetId = upNeighbourPortal.Get(supersetId);
116  { // no up neighbour
118  } // no up neighbour
119  else
120  { // up neighbour exists
121  // mask it to get a superset ID
122  upSupersetId = vtkm::worklet::contourtree_augmented::MaskedIndex(upSupersetId);
123  // look up the mesh ID. NOTE: meshGlobalIdsPortal is already indexed by bractVertexSuperset
124  // so we no longer need to do the bractVertexSupersetPortal.Get(upSupersetId); lookup here
125  vtkm::Id upMeshId = upSupersetId;
126  // then store the global ID in the "above" array
127  interiorForestAbove = meshGlobalIdsPortal.Get(upMeshId);
128  } // up neighbour exists
129 
130  // do the same for the down neighbour
131  vtkm::Id downSupersetId = downNeighbourPortal.Get(supersetId);
133  { // no down neighbour
135  } // no down neighbour
136  else
137  { // down neighbour exists
138  // mask it to get a superset ID
139  downSupersetId = vtkm::worklet::contourtree_augmented::MaskedIndex(downSupersetId);
140  // look up the mesh ID. NOTE: meshGlobalIdsPortal is already indexed by bractVertexSuperset
141  // so we no longer need to do the bractVertexSupersetPortal.Get(downSupersetId); lookup here
142  vtkm::Id downMeshId = downSupersetId;
143  // then store the global ID in the "above" array
144  interiorForestBelow = meshGlobalIdsPortal.Get(downMeshId);
145  } // up neighbour exists
146  } // necessary supernode
147 
148  // In serial this worklet implements the following operation
149  /*
150  for (indexType supernode = 0; supernode < contourTree->supernodes.size(); supernode++)
151  { // per supernode
152  // ignore supernodes that weren't marked necessary, since they will never be searched for
153  // all nodes to be searched for are necessary, but not all necessary nodes will be searched for
154  if (residue->isNecessary[supernode])
155  { // necessary supernode
156  // first, convert it to a sort ID
157  indexType sortID = contourTree->supernodes[supernode];
158  // now find it in the superset
159  indexType supersetID = tree2Superset[supernode];
160 
161  // find the up neighbour and convert it to a global ID: note that we may have a leaf
162  // in which case this may be NO_SUCH_ELEMENT. This will not be searched for, but for safety,
163  // we will test for it explicitly
164  indexType upSupersetID = upNeighbour[supersetID];
165  if (noSuchElement(upSupersetID))
166  { // no up neighbour
167  residue->above[supernode] = NO_SUCH_ELEMENT;
168  } // no up neighbour
169  else
170  { // up neighbour exists
171  // mask it to get a superset ID
172  upSupersetID = maskedIndex(upSupersetID);
173  // look up the mesh ID
174  indexType upMeshID = bractVertexSuperset[upSupersetID];
175  // then store the global ID in the "above" array
176  residue->above[supernode] = mesh->GetGlobalIDFromMeshIndex(upMeshID);
177  } // up neighbour exists
178 
179  // do the same for the down neighbour
180  indexType downSupersetID = downNeighbour[supersetID];
181  if (noSuchElement(downSupersetID))
182  { // no down neighbour
183  residue->below[supernode] = NO_SUCH_ELEMENT;
184  } // no down neighbour
185  else
186  { // down neighbour exists
187  // mask it to get a superset ID
188  downSupersetID = maskedIndex(downSupersetID);
189  // look up the mesh ID
190  indexType downMeshID = bractVertexSuperset[downSupersetID];
191  // then store the global ID in the "above" array
192  residue->below[supernode] = mesh->GetGlobalIDFromMeshIndex(downMeshID);
193  } // up neighbour exists
194  } // necessary supernode
195  } // per supernode
196  */
197  }
198 
199 }; // SetInteriorForestWorklet
200 
201 
202 } // namespace bract_maker
203 } // namespace contourtree_distributed
204 } // namespace worklet
205 } // namespace vtkm
206 
207 #endif
vtkm::worklet::contourtree_distributed::bract_maker::SetInteriorForestWorklet::operator()
VTKM_EXEC void operator()(const vtkm::Id &sortId, const vtkm::Id &isNecessary, const vtkm::Id &supersetId, const GlobalIdFieldPortalType &meshGlobalIdsPortal, const InFieldPortalType &upNeighbourPortal, const InFieldPortalType &downNeighbourPortal, vtkm::Id &interiorForestAbove, vtkm::Id &interiorForestBelow) const
Definition: SetInteriorForestWorklet.h:92
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::worklet::contourtree_distributed::bract_maker::SetInteriorForestWorklet::InputDomain
_1 InputDomain
Definition: SetInteriorForestWorklet.h:83
VTKM_EXEC_CONT
#define VTKM_EXEC_CONT
Definition: ExportMacros.h:52
vtkm::worklet::contourtree_distributed::bract_maker::SetInteriorForestWorklet::ControlSignature
void(FieldIn contourTreeSupernodes, FieldIn interiorForestIsNecessary, FieldIn boundaryTreeMakerTree2Superset, WholeArrayIn meshGlobalIdsFromMeshIndices, WholeArrayIn boundaryTreeMakerUpNeighbour, WholeArrayIn boundaryTreeMakerDownNeighbour, FieldInOut interiorForestAbove, FieldInOut interiorForestBelow) ControlSignature
Definition: SetInteriorForestWorklet.h:81
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::worklet::contourtree_distributed::bract_maker::SetInteriorForestWorklet::SetInteriorForestWorklet
VTKM_EXEC_CONT SetInteriorForestWorklet()
Definition: SetInteriorForestWorklet.h:87
vtkm::Id
vtkm::Int32 Id
Represents an ID (index into arrays).
Definition: Types.h:191
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::WorkletMapField::FieldInOut
A control signature tag for input-output (in-place) fields.
Definition: WorkletMapField.h:71
vtkm::worklet::contourtree_distributed::bract_maker::SetInteriorForestWorklet
Worklet to transfer the dependent counts for hyperarcs Part of the BoundaryRestrictedAugmentedContour...
Definition: SetInteriorForestWorklet.h:70
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::WorkletMapField
Base class for worklets that do a simple mapping of field arrays.
Definition: WorkletMapField.h:38
vtkm::worklet::contourtree_distributed::bract_maker::SetInteriorForestWorklet::ExecutionSignature
void(_1, _2, _3, _4, _5, _6, _7, _8) ExecutionSignature
Definition: SetInteriorForestWorklet.h:82