VTK-m  2.2
ContourTreeUniformDistributed.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 
54 #ifndef vtk_m_filter_scalar_topology_ContourTreeUniformDistributed_h
55 #define vtk_m_filter_scalar_topology_ContourTreeUniformDistributed_h
56 
57 #include <vtkm/Types.h>
58 #include <vtkm/cont/ArrayHandle.h>
59 #include <vtkm/filter/scalar_topology/worklet/contourtree_augmented/ContourTree.h>
60 #include <vtkm/filter/scalar_topology/worklet/contourtree_augmented/DataSetMesh.h>
61 #include <vtkm/filter/scalar_topology/worklet/contourtree_distributed/BoundaryTree.h>
62 #include <vtkm/filter/scalar_topology/worklet/contourtree_distributed/HierarchicalContourTree.h>
63 #include <vtkm/filter/scalar_topology/worklet/contourtree_distributed/InteriorForest.h>
64 
65 #include <memory>
66 #include <vtkm/filter/Filter.h>
68 
69 namespace vtkm
70 {
71 namespace filter
72 {
73 namespace scalar_topology
74 {
91 {
92 public:
93  VTKM_CONT bool CanThread() const override
94  {
95  // tons of shared mutable states
96  return false;
97  }
98 
101 
102  VTKM_CONT void SetUseBoundaryExtremaOnly(bool useBoundaryExtremaOnly)
103  {
104  this->UseBoundaryExtremaOnly = useBoundaryExtremaOnly;
105  }
106 
107  VTKM_CONT bool GetUseBoundaryExtremaOnly() { return this->UseBoundaryExtremaOnly; }
108 
109  VTKM_CONT void SetUseMarchingCubes(bool useMarchingCubes)
110  {
111  this->UseMarchingCubes = useMarchingCubes;
112  }
113 
114  VTKM_CONT bool GetUseMarchingCubes() { return this->UseMarchingCubes; }
115 
116  VTKM_CONT void SetAugmentHierarchicalTree(bool augmentHierarchicalTree)
117  {
118  this->AugmentHierarchicalTree = augmentHierarchicalTree;
119  }
120 
121  VTKM_CONT void SetPresimplifyThreshold(vtkm::Id presimplifyThreshold)
122  {
123  this->PresimplifyThreshold = presimplifyThreshold;
124  }
125 
127  const vtkm::cont::ArrayHandle<vtkm::Id3>& localBlockIndices)
128  {
129  this->BlocksPerDimension = blocksPerDim;
130  vtkm::cont::ArrayCopy(localBlockIndices, this->LocalBlockIndices);
131  }
132 
133  VTKM_CONT bool GetAugmentHierarchicalTree() { return this->AugmentHierarchicalTree; }
134 
135  VTKM_CONT vtkm::Id GetPresimplifyThreshold() { return this->PresimplifyThreshold; }
136 
137  VTKM_CONT void SetSaveDotFiles(bool saveDotFiles) { this->SaveDotFiles = saveDotFiles; }
138 
139  VTKM_CONT bool GetSaveDotFiles() { return this->SaveDotFiles; }
140 
141  template <typename T, typename StorageType>
142  VTKM_CONT void ComputeLocalTree(const vtkm::Id blockIndex,
143  const vtkm::cont::DataSet& input,
144  const vtkm::cont::ArrayHandle<T, StorageType>& fieldArray);
145 
147  template <typename T, typename StorageType, typename MeshType, typename MeshBoundaryExecType>
148  VTKM_CONT void ComputeLocalTreeImpl(const vtkm::Id blockIndex,
149  const vtkm::cont::DataSet& input,
151  MeshType& mesh,
152  MeshBoundaryExecType& meshBoundaryExecObject);
153 
154 private:
155  VTKM_CONT vtkm::cont::DataSet DoExecute(const vtkm::cont::DataSet& input) override;
156  VTKM_CONT vtkm::cont::PartitionedDataSet DoExecutePartitions(
157  const vtkm::cont::PartitionedDataSet& input) override;
158 
163  VTKM_CONT void PreExecute(const vtkm::cont::PartitionedDataSet& input);
164 
165  VTKM_CONT void PostExecute(const vtkm::cont::PartitionedDataSet& input,
167 
168 
169  template <typename FieldType>
170  VTKM_CONT void ComputeVolumeMetric(
171  vtkmdiy::Master& inputContourTreeMaster,
172  vtkmdiy::DynamicAssigner& assigner,
173  vtkmdiy::RegularSwapPartners& partners,
174  const FieldType&, // dummy parameter to get the type
175  std::stringstream& timingsStream,
176  const vtkm::cont::PartitionedDataSet& input,
177  bool useAugmentedTree,
178  std::vector<vtkm::cont::ArrayHandle<vtkm::Id>>& intrinsicVolumes,
179  std::vector<vtkm::cont::ArrayHandle<vtkm::Id>>& dependentVolumes);
180 
186  template <typename T>
187  VTKM_CONT void DoPostExecute(const vtkm::cont::PartitionedDataSet& input,
190 
194 
197 
200 
203 
206 
209 
212 
214  // ... Number of blocks along each dimension
216  // ... Index of the local blocks in x,y,z, i.e., in i,j,k mesh coordinates
218 
221  std::vector<vtkm::worklet::contourtree_augmented::DataSetMesh> LocalMeshes;
223  std::vector<vtkm::worklet::contourtree_augmented::ContourTree> LocalContourTrees;
224  std::vector<vtkm::worklet::contourtree_distributed::BoundaryTree> LocalBoundaryTrees;
225  std::vector<vtkm::worklet::contourtree_distributed::InteriorForest> LocalInteriorForests;
226 
228  // TODO/FIXME: We need to find a way to store the final hieararchical trees somewhere.
229  // Currently we cannot do this here as it is a template on FieldType
230  //
231  //std::vector<vtkm::worklet::contourtree_distributed::HierarchicalContourTree> HierarchicalContourTrees;
234 };
235 } // namespace scalar_topology
236 } // namespace filter
237 } // namespace vtkm
238 
239 #endif // vtk_m_filter_scalar_topology_ContourTreeUniformDistributed_h
vtkm::filter::scalar_topology::ContourTreeUniformDistributed::SetBlockIndices
void SetBlockIndices(vtkm::Id3 blocksPerDim, const vtkm::cont::ArrayHandle< vtkm::Id3 > &localBlockIndices)
Definition: ContourTreeUniformDistributed.h:126
vtkm::cont::ArrayHandle
Manages an array-worth of data.
Definition: ArrayHandle.h:300
ArrayHandle.h
vtkm::filter::scalar_topology::ContourTreeUniformDistributed::GetPresimplifyThreshold
vtkm::Id GetPresimplifyThreshold()
Definition: ContourTreeUniformDistributed.h:135
vtkm
Groups connected points that have the same field value.
Definition: Atomic.h:19
vtkm::filter::scalar_topology::ContourTreeUniformDistributed
Construct the Contour Tree for a 2D or 3D regular mesh.
Definition: ContourTreeUniformDistributed.h:90
Types.h
VTKM_FILTER_SCALAR_TOPOLOGY_EXPORT
#define VTKM_FILTER_SCALAR_TOPOLOGY_EXPORT
Definition: vtkm_filter_scalar_topology_export.h:44
vtkm::filter::scalar_topology::ContourTreeUniformDistributed::SetUseBoundaryExtremaOnly
void SetUseBoundaryExtremaOnly(bool useBoundaryExtremaOnly)
Definition: ContourTreeUniformDistributed.h:102
vtkm::cont::LogLevel
LogLevel
Log levels for use with the logging macros.
Definition: Logging.h:298
vtkm::filter::scalar_topology::ContourTreeUniformDistributed::LocalInteriorForests
std::vector< vtkm::worklet::contourtree_distributed::InteriorForest > LocalInteriorForests
Definition: ContourTreeUniformDistributed.h:225
vtkm::cont::DataSet
Contains and manages the geometric data structures that VTK-m operates on.
Definition: DataSet.h:57
vtkm::filter::scalar_topology::ContourTreeUniformDistributed::SetAugmentHierarchicalTree
void SetAugmentHierarchicalTree(bool augmentHierarchicalTree)
Definition: ContourTreeUniformDistributed.h:116
vtkm::filter::scalar_topology::ContourTreeUniformDistributed::LocalContourTrees
std::vector< vtkm::worklet::contourtree_augmented::ContourTree > LocalContourTrees
... local contour trees etc. computed during fan in and used during fan out
Definition: ContourTreeUniformDistributed.h:223
vtkm::filter::scalar_topology::ContourTreeUniformDistributed::LocalBlockIndices
vtkm::cont::ArrayHandle< vtkm::Id3 > LocalBlockIndices
Definition: ContourTreeUniformDistributed.h:217
vtkm::filter::scalar_topology::ContourTreeUniformDistributed::UseMarchingCubes
bool UseMarchingCubes
Use marching cubes connectivity for computing the contour tree.
Definition: ContourTreeUniformDistributed.h:196
vtkm::filter::scalar_topology::ContourTreeUniformDistributed::SetSaveDotFiles
void SetSaveDotFiles(bool saveDotFiles)
Definition: ContourTreeUniformDistributed.h:137
vtkm::cont::LogLevel::Info
@ Info
Information messages (detected hardware, etc) and temporary debugging output.
vtkm::filter::scalar_topology::ContourTreeUniformDistributed::PresimplifyThreshold
vtkm::Id PresimplifyThreshold
Threshold to use for volume pre-simplification.
Definition: ContourTreeUniformDistributed.h:202
vtkm::filter::scalar_topology::ContourTreeUniformDistributed::GetUseMarchingCubes
bool GetUseMarchingCubes()
Definition: ContourTreeUniformDistributed.h:114
vtkm::filter::Filter
Base class for all filters.
Definition: Filter.h:163
vtkm::cont::ArrayCopy
void ArrayCopy(const SourceArrayType &source, DestArrayType &destination)
Does a deep copy from one array to another array.
Definition: ArrayCopy.h:120
vtkm::filter::scalar_topology::ContourTreeUniformDistributed::CanThread
bool CanThread() const override
Returns whether the filter can execute on partitions in concurrent threads.
Definition: ContourTreeUniformDistributed.h:93
vtkm::filter::scalar_topology::ContourTreeUniformDistributed::UseBoundaryExtremaOnly
bool UseBoundaryExtremaOnly
Use only boundary critical points in the parallel merge to reduce communication.
Definition: ContourTreeUniformDistributed.h:193
VTKM_CONT
#define VTKM_CONT
Definition: ExportMacros.h:57
vtkm::Id
vtkm::Int64 Id
Base type to use to index arrays.
Definition: Types.h:227
vtkm::filter::scalar_topology::ContourTreeUniformDistributed::GetUseBoundaryExtremaOnly
bool GetUseBoundaryExtremaOnly()
Definition: ContourTreeUniformDistributed.h:107
vtkm::filter::scalar_topology::ContourTreeUniformDistributed::SetUseMarchingCubes
void SetUseMarchingCubes(bool useMarchingCubes)
Definition: ContourTreeUniformDistributed.h:109
vtkm::filter::scalar_topology::ContourTreeUniformDistributed::LocalBoundaryTrees
std::vector< vtkm::worklet::contourtree_distributed::BoundaryTree > LocalBoundaryTrees
Definition: ContourTreeUniformDistributed.h:224
vtkm::Vec
A short fixed-length array.
Definition: Types.h:357
vtkm::filter::scalar_topology::ContourTreeUniformDistributed::SaveDotFiles
bool SaveDotFiles
Save dot files for all tree computations.
Definition: ContourTreeUniformDistributed.h:205
vtkm::filter::scalar_topology::ContourTreeUniformDistributed::GetAugmentHierarchicalTree
bool GetAugmentHierarchicalTree()
Definition: ContourTreeUniformDistributed.h:133
vtkm::filter::scalar_topology::ContourTreeUniformDistributed::AugmentHierarchicalTree
bool AugmentHierarchicalTree
Augment hierarchical tree.
Definition: ContourTreeUniformDistributed.h:199
vtkm::filter::scalar_topology::ContourTreeUniformDistributed::GetSaveDotFiles
bool GetSaveDotFiles()
Definition: ContourTreeUniformDistributed.h:139
vtkm::filter::scalar_topology::ContourTreeUniformDistributed::SetPresimplifyThreshold
void SetPresimplifyThreshold(vtkm::Id presimplifyThreshold)
Definition: ContourTreeUniformDistributed.h:121
vtkm_filter_scalar_topology_export.h
vtkm::filter::scalar_topology::ContourTreeUniformDistributed::BlocksPerDimension
vtkm::Id3 BlocksPerDimension
Information about block decomposition TODO/FIXME: Remove need for this information.
Definition: ContourTreeUniformDistributed.h:215
vtkm::filter::scalar_topology::ContourTreeUniformDistributed::NumIterations
vtkm::Id NumIterations
The hierarchical trees computed by the filter (array with one entry per block)
Definition: ContourTreeUniformDistributed.h:233
vtkm::cont::LogLevel::Perf
@ Perf
General timing data and algorithm flow information, such as filter execution, worklet dispatches,...
vtkm::filter::scalar_topology::ContourTreeUniformDistributed::LocalMeshes
std::vector< vtkm::worklet::contourtree_augmented::DataSetMesh > LocalMeshes
Intermediate results (one per local data block)...
Definition: ContourTreeUniformDistributed.h:221
vtkm::cont::PartitionedDataSet
Comprises a set of vtkm::cont::DataSet objects.
Definition: PartitionedDataSet.h:26
Filter.h