VTK-m  2.0
CombinedSimulatedSimplicityIndexComparator.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 // This software is distributed WITHOUT ANY WARRANTY; without even
6 // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
7 // PURPOSE. See the above copyright notice for more information.
8 //
9 // Copyright 2014 National Technology & Engineering Solutions of Sandia, LLC (NTESS).
10 // Copyright 2014 UT-Battelle, LLC.
11 // Copyright 2014 Los Alamos National Security.
12 //
13 // Under the terms of Contract DE-NA0003525 with NTESS,
14 // the U.S. Government retains certain rights in this software.
15 //
16 // Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National
17 // Laboratory (LANL), the U.S. Government retains certain rights in
18 // this software.
19 //============================================================================
20 // Copyright (c) 2018, The Regents of the University of California, through
21 // Lawrence Berkeley National Laboratory (subject to receipt of any required approvals
22 // from the U.S. Dept. of Energy). All rights reserved.
23 //
24 // Redistribution and use in source and binary forms, with or without modification,
25 // are permitted provided that the following conditions are met:
26 //
27 // (1) Redistributions of source code must retain the above copyright notice, this
28 // list of conditions and the following disclaimer.
29 //
30 // (2) Redistributions in binary form must reproduce the above copyright notice,
31 // this list of conditions and the following disclaimer in the documentation
32 // and/or other materials provided with the distribution.
33 //
34 // (3) Neither the name of the University of California, Lawrence Berkeley National
35 // Laboratory, U.S. Dept. of Energy nor the names of its contributors may be
36 // used to endorse or promote products derived from this software without
37 // specific prior written permission.
38 //
39 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
40 // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
41 // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
42 // IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
43 // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
44 // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
45 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
46 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
47 // OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
48 // OF THE POSSIBILITY OF SUCH DAMAGE.
49 //
50 //=============================================================================
51 //
52 // This code is an extension of the algorithm presented in the paper:
53 // Parallel Peak Pruning for Scalable SMP Contour Tree Computation.
54 // Hamish Carr, Gunther Weber, Christopher Sewell, and James Ahrens.
55 // Proceedings of the IEEE Symposium on Large Data Analysis and Visualization
56 // (LDAV), October 2016, Baltimore, Maryland.
57 //
58 // The PPP2 algorithm and software were jointly developed by
59 // Hamish Carr (University of Leeds), Gunther H. Weber (LBNL), and
60 // Oliver Ruebel (LBNL)
61 //==============================================================================
62 
63 #ifndef vtk_m_worklet_contourtree_augmented_contourtree_mesh_inc_combined_simulated_simplicity_index_comparator_h
64 #define vtk_m_worklet_contourtree_augmented_contourtree_mesh_inc_combined_simulated_simplicity_index_comparator_h
65 
66 #include <vtkm/cont/ArrayHandle.h>
68 
69 namespace vtkm
70 {
71 namespace worklet
72 {
73 namespace contourtree_augmented
74 {
75 namespace mesh_dem_contourtree_mesh_inc
76 {
77 
78 
80 template <typename FieldType>
82 {
83 public:
86 
87  VTKM_CONT
89  const IdArrayType& thisGlobalMeshIndex,
90  const IdArrayType& otherGlobalMeshIndex,
91  const vtkm::cont::ArrayHandle<FieldType>& thisSortedValues,
92  const vtkm::cont::ArrayHandle<FieldType>& otherSortedValues,
94  vtkm::cont::Token& token)
95  {
96  this->ThisGlobalMeshIndex = thisGlobalMeshIndex.PrepareForInput(device, token);
97  this->OtherGlobalMeshIndex = otherGlobalMeshIndex.PrepareForInput(device, token);
98  ;
99  this->ThisSortedValues = thisSortedValues.PrepareForInput(device, token);
100  this->OtherSortedValues = otherSortedValues.PrepareForInput(device, token);
101  }
102 
105  {
107  ? this->ThisGlobalMeshIndex.Get(MaskedIndex(idx))
108  : this->OtherGlobalMeshIndex.Get(MaskedIndex(idx));
109  }
110 
112  inline FieldType GetSortedValue(vtkm::Id idx) const
113  {
115  ? this->ThisSortedValues.Get(MaskedIndex(idx))
116  : this->OtherSortedValues.Get(MaskedIndex(idx));
117  }
118 
120  bool operator()(vtkm::Id i, vtkm::Id j) const
121  { // operator()
122  // get values
123  FieldType val_i = this->GetSortedValue(i);
124  FieldType val_j = this->GetSortedValue(j);
125 
126  // value comparison
127  if (val_i < val_j)
128  {
129  return true;
130  }
131  if (val_j < val_i)
132  {
133  return false;
134  }
135 
136  // get indices
137  vtkm::Id idx_i = this->GetGlobalMeshIndex(i);
138  vtkm::Id idx_j = this->GetGlobalMeshIndex(j);
139  // index comparison for simulated simplicity
140  if (idx_i < idx_j)
141  {
142  return true;
143  }
144  if (idx_j < idx_i)
145  {
146  return false;
147  }
148 
149  // fallback - always false
150  return false;
151 
180  } // operator()
181 
182 private:
187 };
188 
189 
191 template <typename FieldType>
193 {
194 public:
195  // constructor
196  VTKM_CONT
198  const IdArrayType& thisGlobalMeshIndex,
199  const IdArrayType& otherGlobalMeshIndex,
200  const vtkm::cont::ArrayHandle<FieldType>& thisSortedValues,
201  const vtkm::cont::ArrayHandle<FieldType>& otherSortedValues)
202  : ThisGlobalMeshIndex(thisGlobalMeshIndex)
203  , OtherGlobalMeshIndex(otherGlobalMeshIndex)
204  , ThisSortedValues(thisSortedValues)
205  , OtherSortedValues(otherSortedValues)
206  {
207  }
208 
211  vtkm::cont::Token& token)
212  {
214  this->OtherGlobalMeshIndex,
215  this->ThisSortedValues,
216  this->OtherSortedValues,
217  device,
218  token);
219  }
220 
221 private:
226 
227 }; // CombinedSimulatedSimplicityIndexComparator
228 
229 } // namespace mesh_dem_contourtree_mesh_inc
230 } // namespace contourtree_augmented
231 } // namespace worklet
232 } // namespace vtkm
233 
234 #endif
vtkm::worklet::contourtree_augmented::mesh_dem_contourtree_mesh_inc::CombinedSimulatedSimplicityIndexComparatorImpl::operator()
VTKM_EXEC_CONT bool operator()(vtkm::Id i, vtkm::Id j) const
Definition: CombinedSimulatedSimplicityIndexComparator.h:120
vtkm::cont::ArrayHandle< vtkm::Id >
ArrayHandle.h
vtkm
Groups connected points that have the same field value.
Definition: Atomic.h:19
vtkm::worklet::contourtree_augmented::mesh_dem_contourtree_mesh_inc::CombinedSimulatedSimplicityIndexComparatorImpl
Implementation of the comparator used initial sort of data values in ContourTreeMesh<FieldType>::Merg...
Definition: CombinedSimulatedSimplicityIndexComparator.h:81
VTKM_EXEC_CONT
#define VTKM_EXEC_CONT
Definition: ExportMacros.h:52
vtkm::worklet::contourtree_augmented::mesh_dem_contourtree_mesh_inc::CombinedSimulatedSimplicityIndexComparatorImpl::GetGlobalMeshIndex
VTKM_EXEC_CONT vtkm::Id GetGlobalMeshIndex(vtkm::Id idx) const
Definition: CombinedSimulatedSimplicityIndexComparator.h:104
vtkm::cont::ArrayHandle::PrepareForInput
VTKM_CONT ReadPortalType PrepareForInput(vtkm::cont::DeviceAdapterId device, vtkm::cont::Token &token) const
Prepares this array to be used as an input to an operation in the execution environment.
Definition: ArrayHandle.h:574
vtkm::worklet::contourtree_augmented::mesh_dem_contourtree_mesh_inc::CombinedSimulatedSimplicityIndexComparatorImpl::OtherGlobalMeshIndex
IdPortalType OtherGlobalMeshIndex
Definition: CombinedSimulatedSimplicityIndexComparator.h:184
vtkm::worklet::contourtree_augmented::mesh_dem_contourtree_mesh_inc::CombinedSimulatedSimplicityIndexComparatorImpl::ThisSortedValues
ValuePortalType ThisSortedValues
Definition: CombinedSimulatedSimplicityIndexComparator.h:185
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::cont::ArrayHandle::ReadPortalType
typename StorageType::ReadPortalType ReadPortalType
Definition: ArrayHandle.h:294
vtkm::Id
vtkm::Int32 Id
Represents an ID (index into arrays).
Definition: Types.h:191
vtkm::worklet::contourtree_augmented::mesh_dem_contourtree_mesh_inc::CombinedSimulatedSimplicityIndexComparatorImpl::ThisGlobalMeshIndex
IdPortalType ThisGlobalMeshIndex
Definition: CombinedSimulatedSimplicityIndexComparator.h:183
vtkm::worklet::contourtree_augmented::mesh_dem_contourtree_mesh_inc::CombinedSimulatedSimplicityIndexComparator::PrepareForExecution
VTKM_CONT CombinedSimulatedSimplicityIndexComparatorImpl< FieldType > PrepareForExecution(vtkm::cont::DeviceAdapterId device, vtkm::cont::Token &token)
Definition: CombinedSimulatedSimplicityIndexComparator.h:209
vtkm::cont::Token
A token to hold the scope of an ArrayHandle or other object.
Definition: Token.h:35
vtkm::worklet::contourtree_augmented::mesh_dem_contourtree_mesh_inc::CombinedSimulatedSimplicityIndexComparator
Execution object for the comparator used initial sort of data values in ContourTreeMesh<FieldType>::M...
Definition: CombinedSimulatedSimplicityIndexComparator.h:192
vtkm::worklet::contourtree_augmented::mesh_dem_contourtree_mesh_inc::CombinedSimulatedSimplicityIndexComparator::OtherSortedValues
vtkm::cont::ArrayHandle< FieldType > OtherSortedValues
Definition: CombinedSimulatedSimplicityIndexComparator.h:225
Types.h
VTKM_CONT
#define VTKM_CONT
Definition: ExportMacros.h:57
vtkm::worklet::contourtree_augmented::mesh_dem_contourtree_mesh_inc::CombinedSimulatedSimplicityIndexComparatorImpl::OtherSortedValues
ValuePortalType OtherSortedValues
Definition: CombinedSimulatedSimplicityIndexComparator.h:186
vtkm::worklet::contourtree_augmented::IsThis
VTKM_EXEC_CONT bool IsThis(vtkm::Id flaggedIndex)
Used in the context of CombinedVector class used in ContourTreeMesh to merge the mesh of contour tree...
Definition: filter/scalar_topology/worklet/contourtree_augmented/Types.h:134
vtkm::worklet::contourtree_augmented::mesh_dem_contourtree_mesh_inc::CombinedSimulatedSimplicityIndexComparatorImpl::CombinedSimulatedSimplicityIndexComparatorImpl
VTKM_CONT CombinedSimulatedSimplicityIndexComparatorImpl(const IdArrayType &thisGlobalMeshIndex, const IdArrayType &otherGlobalMeshIndex, const vtkm::cont::ArrayHandle< FieldType > &thisSortedValues, const vtkm::cont::ArrayHandle< FieldType > &otherSortedValues, vtkm::cont::DeviceAdapterId device, vtkm::cont::Token &token)
Definition: CombinedSimulatedSimplicityIndexComparator.h:88
vtkm::cont::ExecutionObjectBase
Base ExecutionObjectBase for execution objects to inherit from so that you can use an arbitrary objec...
Definition: ExecutionObjectBase.h:31
vtkm::cont::DeviceAdapterId
Definition: DeviceAdapterTag.h:52
vtkm::worklet::contourtree_augmented::mesh_dem_contourtree_mesh_inc::CombinedSimulatedSimplicityIndexComparator::CombinedSimulatedSimplicityIndexComparator
VTKM_CONT CombinedSimulatedSimplicityIndexComparator(const IdArrayType &thisGlobalMeshIndex, const IdArrayType &otherGlobalMeshIndex, const vtkm::cont::ArrayHandle< FieldType > &thisSortedValues, const vtkm::cont::ArrayHandle< FieldType > &otherSortedValues)
Definition: CombinedSimulatedSimplicityIndexComparator.h:197
vtkm::worklet::contourtree_augmented::mesh_dem_contourtree_mesh_inc::CombinedSimulatedSimplicityIndexComparator::ThisSortedValues
vtkm::cont::ArrayHandle< FieldType > ThisSortedValues
Definition: CombinedSimulatedSimplicityIndexComparator.h:224
vtkm::worklet::contourtree_augmented::mesh_dem_contourtree_mesh_inc::CombinedSimulatedSimplicityIndexComparatorImpl::ValuePortalType
typename vtkm::cont::ArrayHandle< FieldType >::ReadPortalType ValuePortalType
Definition: CombinedSimulatedSimplicityIndexComparator.h:85
vtkm::worklet::contourtree_augmented::mesh_dem_contourtree_mesh_inc::CombinedSimulatedSimplicityIndexComparatorImpl::GetSortedValue
VTKM_EXEC_CONT FieldType GetSortedValue(vtkm::Id idx) const
Definition: CombinedSimulatedSimplicityIndexComparator.h:112
vtkm::worklet::contourtree_augmented::mesh_dem_contourtree_mesh_inc::CombinedSimulatedSimplicityIndexComparator::ThisGlobalMeshIndex
IdArrayType ThisGlobalMeshIndex
Definition: CombinedSimulatedSimplicityIndexComparator.h:222
vtkm::worklet::contourtree_augmented::mesh_dem_contourtree_mesh_inc::CombinedSimulatedSimplicityIndexComparator::OtherGlobalMeshIndex
IdArrayType OtherGlobalMeshIndex
Definition: CombinedSimulatedSimplicityIndexComparator.h:223
vtkm::worklet::contourtree_augmented::mesh_dem_contourtree_mesh_inc::CombinedSimulatedSimplicityIndexComparatorImpl::IdPortalType
typename vtkm::cont::ArrayHandle< vtkm::Id >::ReadPortalType IdPortalType
Definition: CombinedSimulatedSimplicityIndexComparator.h:84