VTK-m  2.0
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>
64 
65 #include <memory>
67 #include <vtkm/filter/scalar_topology/vtkm_filter_scalar_topology_export.h>
68 
69 namespace vtkm
70 {
71 namespace filter
72 {
73 namespace scalar_topology
74 {
90 class VTKM_FILTER_SCALAR_TOPOLOGY_EXPORT ContourTreeUniformDistributed
92 {
93 public:
94  VTKM_CONT bool CanThread() const override
95  {
96  // tons of shared mutable states
97  return false;
98  }
99 
102 
103  VTKM_CONT void SetUseBoundaryExtremaOnly(bool useBoundaryExtremaOnly)
104  {
105  this->UseBoundaryExtremaOnly = useBoundaryExtremaOnly;
106  }
107 
108  VTKM_CONT bool GetUseBoundaryExtremaOnly() { return this->UseBoundaryExtremaOnly; }
109 
110  VTKM_CONT void SetUseMarchingCubes(bool useMarchingCubes)
111  {
112  this->UseMarchingCubes = useMarchingCubes;
113  }
114 
115  VTKM_CONT bool GetUseMarchingCubes() { return this->UseMarchingCubes; }
116 
117  VTKM_CONT void SetAugmentHierarchicalTree(bool augmentHierarchicalTree)
118  {
119  this->AugmentHierarchicalTree = augmentHierarchicalTree;
120  }
121 
123  const vtkm::cont::ArrayHandle<vtkm::Id3>& localBlockIndices)
124  {
125  this->BlocksPerDimension = blocksPerDim;
126  vtkm::cont::ArrayCopy(localBlockIndices, this->LocalBlockIndices);
127  }
128 
129  VTKM_CONT bool GetAugmentHierarchicalTree() { return this->AugmentHierarchicalTree; }
130 
131  VTKM_CONT void SetSaveDotFiles(bool saveDotFiles) { this->SaveDotFiles = saveDotFiles; }
132 
133  VTKM_CONT bool GetSaveDotFiles() { return this->SaveDotFiles; }
134 
135  template <typename T, typename StorageType>
136  VTKM_CONT void ComputeLocalTree(const vtkm::Id blockIndex,
137  const vtkm::cont::DataSet& input,
138  const vtkm::cont::ArrayHandle<T, StorageType>& fieldArray);
139 
141  template <typename T, typename StorageType, typename MeshType, typename MeshBoundaryExecType>
142  VTKM_CONT void ComputeLocalTreeImpl(const vtkm::Id blockIndex,
143  const vtkm::cont::DataSet& input,
145  MeshType& mesh,
146  MeshBoundaryExecType& meshBoundaryExecObject);
147 
148 private:
149  VTKM_CONT vtkm::cont::DataSet DoExecute(const vtkm::cont::DataSet& input) override;
150  VTKM_CONT vtkm::cont::PartitionedDataSet DoExecutePartitions(
151  const vtkm::cont::PartitionedDataSet& input) override;
152 
157  VTKM_CONT void PreExecute(const vtkm::cont::PartitionedDataSet& input);
158 
159  VTKM_CONT void PostExecute(const vtkm::cont::PartitionedDataSet& input,
161 
162 
163  template <typename FieldType>
164  VTKM_CONT void ComputeVolumeMetric(
165  vtkmdiy::Master& inputContourTreeMaster,
166  vtkmdiy::DynamicAssigner& assigner,
167  vtkmdiy::RegularSwapPartners& partners,
168  const FieldType&, // dummy parameter to get the type
169  std::stringstream& timingsStream,
170  std::vector<vtkm::cont::DataSet>& hierarchicalTreeOutputDataSet);
171 
177  template <typename T>
178  VTKM_CONT void DoPostExecute(const vtkm::cont::PartitionedDataSet& input,
181 
185 
188 
191 
194 
197 
200 
202  // ... Number of blocks along each dimension
204  // ... Index of the local blocks in x,y,z, i.e., in i,j,k mesh coordinates
206 
209  std::vector<vtkm::worklet::contourtree_augmented::DataSetMesh> LocalMeshes;
211  std::vector<vtkm::worklet::contourtree_augmented::ContourTree> LocalContourTrees;
212  std::vector<vtkm::worklet::contourtree_distributed::BoundaryTree> LocalBoundaryTrees;
213  std::vector<vtkm::worklet::contourtree_distributed::InteriorForest> LocalInteriorForests;
214 
216  // TODO/FIXME: We need to find a way to store the final hieararchical trees somewhere.
217  // Currently we cannot do this here as it is a template on FieldType
218  //
219  //std::vector<vtkm::worklet::contourtree_distributed::HierarchicalContourTree> HierarchicalContourTrees;
222 };
223 } // namespace scalar_topology
224 } // namespace filter
225 } // namespace vtkm
226 
227 #endif // vtk_m_filter_scalar_topology_ContourTreeUniformDistributed_h
vtkm::cont::ArrayHandle
Manages an array-worth of data.
Definition: ArrayHandle.h:283
ArrayHandle.h
vtkm
Groups connected points that have the same field value.
Definition: Atomic.h:19
HierarchicalContourTree.h
vtkm::filter::scalar_topology::ContourTreeUniformDistributed
Construct the Contour Tree for a 2D or 3D regular mesh.
Definition: ContourTreeUniformDistributed.h:90
Types.h
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:213
BoundaryTree.h
vtkm::filter::scalar_topology::ContourTreeUniformDistributed::SetUseBoundaryExtremaOnly
VTKM_CONT void SetUseBoundaryExtremaOnly(bool useBoundaryExtremaOnly)
Definition: ContourTreeUniformDistributed.h:103
vtkm::cont::DataSet
Definition: DataSet.h:34
vtkm::Id
vtkm::Int32 Id
Represents an ID (index into arrays).
Definition: Types.h:191
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:211
vtkm::filter::scalar_topology::ContourTreeUniformDistributed::LocalBlockIndices
vtkm::cont::ArrayHandle< vtkm::Id3 > LocalBlockIndices
Definition: ContourTreeUniformDistributed.h:205
vtkm::filter::scalar_topology::ContourTreeUniformDistributed::SetUseMarchingCubes
VTKM_CONT void SetUseMarchingCubes(bool useMarchingCubes)
Definition: ContourTreeUniformDistributed.h:110
vtkm::filter::scalar_topology::ContourTreeUniformDistributed::UseMarchingCubes
bool UseMarchingCubes
Use marching cubes connectivity for computing the contour tree.
Definition: ContourTreeUniformDistributed.h:187
vtkm::filter::scalar_topology::ContourTreeUniformDistributed::GetUseBoundaryExtremaOnly
VTKM_CONT bool GetUseBoundaryExtremaOnly()
Definition: ContourTreeUniformDistributed.h:108
FilterField.h
vtkm::filter::FilterField
Definition: FilterField.h:21
vtkm::filter::scalar_topology::ContourTreeUniformDistributed::SetSaveDotFiles
VTKM_CONT void SetSaveDotFiles(bool saveDotFiles)
Definition: ContourTreeUniformDistributed.h:131
vtkm::cont::LogLevel::Info
@ Info
Information messages (detected hardware, etc) and temporary debugging output.
vtkm::filter::scalar_topology::ContourTreeUniformDistributed::GetSaveDotFiles
VTKM_CONT bool GetSaveDotFiles()
Definition: ContourTreeUniformDistributed.h:133
vtkm::filter::scalar_topology::ContourTreeUniformDistributed::GetAugmentHierarchicalTree
VTKM_CONT bool GetAugmentHierarchicalTree()
Definition: ContourTreeUniformDistributed.h:129
DataSetMesh.h
vtkm::filter::scalar_topology::ContourTreeUniformDistributed::SetBlockIndices
VTKM_CONT void SetBlockIndices(vtkm::Id3 blocksPerDim, const vtkm::cont::ArrayHandle< vtkm::Id3 > &localBlockIndices)
Definition: ContourTreeUniformDistributed.h:122
InteriorForest.h
vtkm::cont::ArrayCopy
void ArrayCopy(const SourceArrayType &source, DestArrayType &destination)
Does a deep copy from one array to another array.
Definition: ArrayCopy.h:142
vtkm::filter::scalar_topology::ContourTreeUniformDistributed::UseBoundaryExtremaOnly
bool UseBoundaryExtremaOnly
Use only boundary critical points in the parallel merge to reduce communication.
Definition: ContourTreeUniformDistributed.h:184
VTKM_CONT
#define VTKM_CONT
Definition: ExportMacros.h:57
vtkm::filter::scalar_topology::ContourTreeUniformDistributed::LocalBoundaryTrees
std::vector< vtkm::worklet::contourtree_distributed::BoundaryTree > LocalBoundaryTrees
Definition: ContourTreeUniformDistributed.h:212
vtkm::Vec
A short fixed-length array.
Definition: Types.h:767
vtkm::filter::scalar_topology::ContourTreeUniformDistributed::CanThread
VTKM_CONT bool CanThread() const override
Definition: ContourTreeUniformDistributed.h:94
vtkm::filter::scalar_topology::ContourTreeUniformDistributed::SaveDotFiles
bool SaveDotFiles
Save dot files for all tree computations.
Definition: ContourTreeUniformDistributed.h:193
vtkm::filter::scalar_topology::ContourTreeUniformDistributed::AugmentHierarchicalTree
bool AugmentHierarchicalTree
Augment hierarchical tree.
Definition: ContourTreeUniformDistributed.h:190
vtkm::filter::scalar_topology::ContourTreeUniformDistributed::GetUseMarchingCubes
VTKM_CONT bool GetUseMarchingCubes()
Definition: ContourTreeUniformDistributed.h:115
ContourTree.h
vtkm::filter::scalar_topology::ContourTreeUniformDistributed::BlocksPerDimension
vtkm::Id3 BlocksPerDimension
Information about block decomposition TODO/FIXME: Remove need for this information.
Definition: ContourTreeUniformDistributed.h:203
vtkm::filter::scalar_topology::ContourTreeUniformDistributed::SetAugmentHierarchicalTree
VTKM_CONT void SetAugmentHierarchicalTree(bool augmentHierarchicalTree)
Definition: ContourTreeUniformDistributed.h:117
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:221
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:209
vtkm::cont::PartitionedDataSet
Definition: PartitionedDataSet.h:25