Viskores  1.0
ContourTreeUniformDistributed.h
Go to the documentation of this file.
1 //============================================================================
2 // The contents of this file are covered by the Viskores license. See
3 // LICENSE.txt for details.
4 //
5 // By contributing to this file, all contributors agree to the Developer
6 // Certificate of Origin Version 1.1 (DCO 1.1) as stated in DCO.txt.
7 //============================================================================
8 
9 //============================================================================
10 // Copyright (c) Kitware, Inc.
11 // All rights reserved.
12 // See LICENSE.txt for details.
13 //
14 // This software is distributed WITHOUT ANY WARRANTY; without even
15 // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
16 // PURPOSE. See the above copyright notice for more information.
17 //============================================================================
18 // Copyright (c) 2018, The Regents of the University of California, through
19 // Lawrence Berkeley National Laboratory (subject to receipt of any required approvals
20 // from the U.S. Dept. of Energy). All rights reserved.
21 //
22 // Redistribution and use in source and binary forms, with or without modification,
23 // are permitted provided that the following conditions are met:
24 //
25 // (1) Redistributions of source code must retain the above copyright notice, this
26 // list of conditions and the following disclaimer.
27 //
28 // (2) Redistributions in binary form must reproduce the above copyright notice,
29 // this list of conditions and the following disclaimer in the documentation
30 // and/or other materials provided with the distribution.
31 //
32 // (3) Neither the name of the University of California, Lawrence Berkeley National
33 // Laboratory, U.S. Dept. of Energy nor the names of its contributors may be
34 // used to endorse or promote products derived from this software without
35 // specific prior written permission.
36 //
37 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
38 // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
39 // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
40 // IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
41 // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
42 // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
43 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
44 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
45 // OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
46 // OF THE POSSIBILITY OF SUCH DAMAGE.
47 //
48 //=============================================================================
49 //
50 // This code is an extension of the algorithm presented in the paper:
51 // Parallel Peak Pruning for Scalable SMP Contour Tree Computation.
52 // Hamish Carr, Gunther Weber, Christopher Sewell, and James Ahrens.
53 // Proceedings of the IEEE Symposium on Large Data Analysis and Visualization
54 // (LDAV), October 2016, Baltimore, Maryland.
55 //
56 // The PPP2 algorithm and software were jointly developed by
57 // Hamish Carr (University of Leeds), Gunther H. Weber (LBNL), and
58 // Oliver Ruebel (LBNL)
59 //==============================================================================
60 
61 
62 #ifndef viskores_filter_scalar_topology_ContourTreeUniformDistributed_h
63 #define viskores_filter_scalar_topology_ContourTreeUniformDistributed_h
64 
65 #include <viskores/Types.h>
67 #include <viskores/filter/scalar_topology/worklet/contourtree_augmented/ContourTree.h>
68 #include <viskores/filter/scalar_topology/worklet/contourtree_augmented/DataSetMesh.h>
69 #include <viskores/filter/scalar_topology/worklet/contourtree_distributed/BoundaryTree.h>
70 #include <viskores/filter/scalar_topology/worklet/contourtree_distributed/HierarchicalContourTree.h>
71 #include <viskores/filter/scalar_topology/worklet/contourtree_distributed/InteriorForest.h>
72 
73 #include <memory>
74 #include <viskores/filter/Filter.h>
76 
77 namespace viskores
78 {
79 namespace filter
80 {
81 namespace scalar_topology
82 {
98 class VISKORES_FILTER_SCALAR_TOPOLOGY_EXPORT ContourTreeUniformDistributed
100 {
101 public:
102  VISKORES_CONT bool CanThread() const override
103  {
104  // tons of shared mutable states
105  return false;
106  }
107 
111 
112  VISKORES_CONT void SetUseBoundaryExtremaOnly(bool useBoundaryExtremaOnly)
113  {
114  this->UseBoundaryExtremaOnly = useBoundaryExtremaOnly;
115  }
116 
117  VISKORES_CONT bool GetUseBoundaryExtremaOnly() { return this->UseBoundaryExtremaOnly; }
118 
119  VISKORES_CONT void SetUseMarchingCubes(bool useMarchingCubes)
120  {
121  this->UseMarchingCubes = useMarchingCubes;
122  }
123 
124  VISKORES_CONT bool GetUseMarchingCubes() { return this->UseMarchingCubes; }
125 
126  VISKORES_CONT void SetAugmentHierarchicalTree(bool augmentHierarchicalTree)
127  {
128  this->AugmentHierarchicalTree = augmentHierarchicalTree;
129  }
130 
132  {
133  this->PresimplifyThreshold = presimplifyThreshold;
134  }
135 
137  viskores::Id3 blocksPerDim,
138  const viskores::cont::ArrayHandle<viskores::Id3>& localBlockIndices)
139  {
140  this->BlocksPerDimension = blocksPerDim;
141  viskores::cont::ArrayCopy(localBlockIndices, this->LocalBlockIndices);
142  }
143 
144  VISKORES_CONT bool GetAugmentHierarchicalTree() { return this->AugmentHierarchicalTree; }
145 
146  VISKORES_CONT viskores::Id GetPresimplifyThreshold() { return this->PresimplifyThreshold; }
147 
148  VISKORES_CONT void SetSaveDotFiles(bool saveDotFiles) { this->SaveDotFiles = saveDotFiles; }
149 
150  VISKORES_CONT bool GetSaveDotFiles() { return this->SaveDotFiles; }
151 
152  template <typename T, typename StorageType>
153  VISKORES_CONT void ComputeLocalTree(
154  const viskores::Id blockIndex,
155  const viskores::cont::DataSet& input,
157 
159  template <typename T, typename StorageType, typename MeshType, typename MeshBoundaryExecType>
160  VISKORES_CONT void ComputeLocalTreeImpl(const viskores::Id blockIndex,
161  const viskores::cont::DataSet& input,
163  MeshType& mesh,
164  MeshBoundaryExecType& meshBoundaryExecObject);
165 
166 private:
167  VISKORES_CONT viskores::cont::DataSet DoExecute(const viskores::cont::DataSet& input) override;
169  const viskores::cont::PartitionedDataSet& input) override;
170 
175  VISKORES_CONT void PreExecute(const viskores::cont::PartitionedDataSet& input);
176 
177  VISKORES_CONT void PostExecute(const viskores::cont::PartitionedDataSet& input,
179 
180 
181  template <typename FieldType>
182  VISKORES_CONT void ComputeVolumeMetric(
183  viskoresdiy::Master& inputContourTreeMaster,
184  viskoresdiy::DynamicAssigner& assigner,
185  viskoresdiy::RegularSwapPartners& partners,
186  const FieldType&, // dummy parameter to get the type
187  std::stringstream& timingsStream,
189  bool useAugmentedTree,
190  std::vector<viskores::cont::ArrayHandle<viskores::Id>>& intrinsicVolumes,
191  std::vector<viskores::cont::ArrayHandle<viskores::Id>>& dependentVolumes);
192 
198  template <typename T>
199  VISKORES_CONT void DoPostExecute(const viskores::cont::PartitionedDataSet& input,
202 
206 
209 
212 
214  viskores::Id PresimplifyThreshold = 0;
215 
218 
221 
224 
226  // ... Number of blocks along each dimension
228  // ... Index of the local blocks in x,y,z, i.e., in i,j,k mesh coordinates
230 
233  std::vector<viskores::worklet::contourtree_augmented::DataSetMesh> LocalMeshes;
235  std::vector<viskores::worklet::contourtree_augmented::ContourTree> LocalContourTrees;
236  std::vector<viskores::worklet::contourtree_distributed::BoundaryTree> LocalBoundaryTrees;
237  std::vector<viskores::worklet::contourtree_distributed::InteriorForest> LocalInteriorForests;
238 
240  // TODO/FIXME: We need to find a way to store the final hieararchical trees somewhere.
241  // Currently we cannot do this here as it is a template on FieldType
242  //
243  //std::vector<viskores::worklet::contourtree_distributed::HierarchicalContourTree> HierarchicalContourTrees;
246 };
247 } // namespace scalar_topology
248 } // namespace filter
249 } // namespace viskores
250 
251 #endif // viskores_filter_scalar_topology_ContourTreeUniformDistributed_h
ArrayHandle.h
viskores::filter::scalar_topology::ContourTreeUniformDistributed::BlocksPerDimension
viskores::Id3 BlocksPerDimension
Information about block decomposition TODO/FIXME: Remove need for this information.
Definition: ContourTreeUniformDistributed.h:227
viskores::filter::scalar_topology::ContourTreeUniformDistributed::SetSaveDotFiles
void SetSaveDotFiles(bool saveDotFiles)
Definition: ContourTreeUniformDistributed.h:148
viskores::filter::scalar_topology::ContourTreeUniformDistributed::CanThread
bool CanThread() const override
Returns whether the filter can execute on partitions in concurrent threads.
Definition: ContourTreeUniformDistributed.h:102
viskores::cont::DataSet
Contains and manages the geometric data structures that Viskores operates on.
Definition: DataSet.h:66
Types.h
viskores::filter::scalar_topology::ContourTreeUniformDistributed::LocalBlockIndices
viskores::cont::ArrayHandle< viskores::Id3 > LocalBlockIndices
Definition: ContourTreeUniformDistributed.h:229
viskores::filter::scalar_topology::ContourTreeUniformDistributed::GetSaveDotFiles
bool GetSaveDotFiles()
Definition: ContourTreeUniformDistributed.h:150
viskores::filter::Filter
Base class for all filters.
Definition: Filter.h:171
viskores::filter::scalar_topology::ContourTreeUniformDistributed::NumIterations
viskores::Id NumIterations
The hierarchical trees computed by the filter (array with one entry per block)
Definition: ContourTreeUniformDistributed.h:245
viskores::cont::ArrayHandle
Manages an array-worth of data.
Definition: ArrayHandle.h:313
viskores::filter::scalar_topology::ContourTreeUniformDistributed::UseBoundaryExtremaOnly
bool UseBoundaryExtremaOnly
Use only boundary critical points in the parallel merge to reduce communication.
Definition: ContourTreeUniformDistributed.h:205
viskores::filter::scalar_topology::ContourTreeUniformDistributed::GetAugmentHierarchicalTree
bool GetAugmentHierarchicalTree()
Definition: ContourTreeUniformDistributed.h:144
viskores::cont::LogLevel::Info
@ Info
Information messages (detected hardware, etc) and temporary debugging output.
viskores::filter::scalar_topology::ContourTreeUniformDistributed::SetPresimplifyThreshold
void SetPresimplifyThreshold(viskores::Id presimplifyThreshold)
Definition: ContourTreeUniformDistributed.h:131
viskores::filter::scalar_topology::ContourTreeUniformDistributed
Construct the Contour Tree for a 2D or 3D regular mesh.
Definition: ContourTreeUniformDistributed.h:98
viskores::Id
viskores::Int64 Id
Base type to use to index arrays.
Definition: Types.h:235
VISKORES_CONT
#define VISKORES_CONT
Definition: ExportMacros.h:65
viskores
Groups connected points that have the same field value.
Definition: Atomic.h:27
viskores::filter::scalar_topology::ContourTreeUniformDistributed::SetBlockIndices
void SetBlockIndices(viskores::Id3 blocksPerDim, const viskores::cont::ArrayHandle< viskores::Id3 > &localBlockIndices)
Definition: ContourTreeUniformDistributed.h:136
viskores::cont::LogLevel
LogLevel
Log levels for use with the logging macros.
Definition: Logging.h:311
viskores::filter::scalar_topology::ContourTreeUniformDistributed::LocalMeshes
std::vector< viskores::worklet::contourtree_augmented::DataSetMesh > LocalMeshes
Intermediate results (one per local data block)...
Definition: ContourTreeUniformDistributed.h:233
viskores::filter::scalar_topology::ContourTreeUniformDistributed::LocalInteriorForests
std::vector< viskores::worklet::contourtree_distributed::InteriorForest > LocalInteriorForests
Definition: ContourTreeUniformDistributed.h:237
viskores::cont::PartitionedDataSet
Comprises a set of viskores::cont::DataSet objects.
Definition: PartitionedDataSet.h:34
viskores::filter::scalar_topology::ContourTreeUniformDistributed::UseMarchingCubes
bool UseMarchingCubes
Use marching cubes connectivity for computing the contour tree.
Definition: ContourTreeUniformDistributed.h:208
viskores::filter::scalar_topology::ContourTreeUniformDistributed::LocalBoundaryTrees
std::vector< viskores::worklet::contourtree_distributed::BoundaryTree > LocalBoundaryTrees
Definition: ContourTreeUniformDistributed.h:236
viskores::filter::scalar_topology::ContourTreeUniformDistributed::SaveDotFiles
bool SaveDotFiles
Save dot files for all tree computations.
Definition: ContourTreeUniformDistributed.h:217
viskores::cont::LogLevel::Perf
@ Perf
General timing data and algorithm flow information, such as filter execution, worklet dispatches,...
viskores::filter::scalar_topology::ContourTreeUniformDistributed::SetUseMarchingCubes
void SetUseMarchingCubes(bool useMarchingCubes)
Definition: ContourTreeUniformDistributed.h:119
viskores::filter::scalar_topology::ContourTreeUniformDistributed::GetPresimplifyThreshold
viskores::Id GetPresimplifyThreshold()
Definition: ContourTreeUniformDistributed.h:146
viskores::filter::scalar_topology::ContourTreeUniformDistributed::AugmentHierarchicalTree
bool AugmentHierarchicalTree
Augment hierarchical tree.
Definition: ContourTreeUniformDistributed.h:211
viskores::cont::ArrayCopy
void ArrayCopy(const SourceArrayType &source, DestArrayType &destination)
Does a deep copy from one array to another array.
Definition: ArrayCopy.h:129
viskores::filter::scalar_topology::ContourTreeUniformDistributed::SetUseBoundaryExtremaOnly
void SetUseBoundaryExtremaOnly(bool useBoundaryExtremaOnly)
Definition: ContourTreeUniformDistributed.h:112
viskores::filter::scalar_topology::ContourTreeUniformDistributed::LocalContourTrees
std::vector< viskores::worklet::contourtree_augmented::ContourTree > LocalContourTrees
... local contour trees etc. computed during fan in and used during fan out
Definition: ContourTreeUniformDistributed.h:235
viskores::filter::scalar_topology::ContourTreeUniformDistributed::SetAugmentHierarchicalTree
void SetAugmentHierarchicalTree(bool augmentHierarchicalTree)
Definition: ContourTreeUniformDistributed.h:126
viskores::filter::scalar_topology::ContourTreeUniformDistributed::GetUseBoundaryExtremaOnly
bool GetUseBoundaryExtremaOnly()
Definition: ContourTreeUniformDistributed.h:117
viskores_filter_scalar_topology_export.h
viskores::Vec
A short fixed-length array.
Definition: Types.h:365
viskores::filter::scalar_topology::ContourTreeUniformDistributed::GetUseMarchingCubes
bool GetUseMarchingCubes()
Definition: ContourTreeUniformDistributed.h:124
Filter.h