VTK-m  2.0
HierarchicalAugmenterInOutData.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 // Parallel Peak Pruning v. 2.0
43 //
44 // Started June 15, 2017
45 //
46 // Copyright Hamish Carr, University of Leeds
47 //
48 // HierarchicalAugmenter.h
49 //
50 //=======================================================================================
51 
52 #ifndef vtk_m_worklet_contourtree_distributed_hierarchical_augmenter_hierarchical_augmenter_in_out_data_h
53 #define vtk_m_worklet_contourtree_distributed_hierarchical_augmenter_hierarchical_augmenter_in_out_data_h
54 
55 
56 #include <iostream> // std::cout
57 #include <sstream> // std::stringstrea
58 #include <string> // std::string
59 
60 
61 namespace vtkm
62 {
63 namespace worklet
64 {
65 namespace contourtree_distributed
66 {
67 namespace hierarchical_augmenter
68 {
69 
72 template <typename FieldType>
74 { // class HierarchicalAugmenter
75 public:
82 
85 
94  : GlobalRegularIds(globalRegularIds)
95  , DataValues(dataValues)
96  , SupernodeIds(supernodeIds)
97  , Superparents(superparents)
98  , SuperparentRounds(superparentRounds)
99  , WhichRounds(whichRounds)
100  {
101  }
102 
105 
107  void ReleaseResources();
108 
110  std::string DebugPrint(std::string message, const char* fileName, long lineNum);
111 
112 }; // class HierarchicalAugmenterInOutData
113 
114 template <typename FieldType>
116 {
117  this->ReleaseResources();
118 }
119 
120 // routine to release memory used for out arrays
121 template <typename FieldType>
123 { // ReleaseResources()
124  this->GlobalRegularIds.ReleaseResources();
125  this->DataValues.ReleaseResources();
126  this->SupernodeIds.ReleaseResources();
127  this->Superparents.ReleaseResources();
128  this->SuperparentRounds.ReleaseResources();
129  this->WhichRounds.ReleaseResources();
130 } // ReleaseResources()
131 
132 template <typename FieldType>
134  const char* fileName,
135  long lineNum)
136 {
137  // DebugPrint()
138  std::stringstream resultStream;
139  resultStream << std::endl;
140  resultStream << "----------------------------------------" << std::endl;
141  resultStream << std::setw(30) << std::left << fileName << ":" << std::right << std::setw(4)
142  << lineNum << std::endl;
143  resultStream << message << std::endl;
144  resultStream << "----------------------------------------" << std::endl;
146  "Global Regular Ids", this->GlobalRegularIds, -1, resultStream);
148  "Data Values", this->DataValues, -1, resultStream);
150  "Supernode Ids", this->SupernodeIds, -1, resultStream);
152  "Superparents", this->Superparents, -1, resultStream);
154  "Superparent Rounds", this->SuperparentRounds, -1, resultStream);
156  "Which Rounds", this->WhichRounds, -1, resultStream);
157  return resultStream.str();
158 }
159 
160 } // namespace hierarchical_augmenter
161 } // namespace contourtree_distributed
162 } // namespace worklet
163 } // namespace vtkm
164 
165 namespace vtkmdiy
166 {
167 
168 // Struct to serialize ContourTreeMesh objects (i.e., load/save) needed in parralle for DIY
169 template <typename FieldType>
170 struct Serialization<vtkm::worklet::contourtree_distributed::hierarchical_augmenter::
171  HierarchicalAugmenterInOutData<FieldType>>
172 {
173  static void save(vtkmdiy::BinaryBuffer& bb,
175  HierarchicalAugmenterInOutData<FieldType>& ha)
176  {
177  vtkmdiy::save(bb, ha.GlobalRegularIds);
178  vtkmdiy::save(bb, ha.DataValues);
179  vtkmdiy::save(bb, ha.SupernodeIds);
180  vtkmdiy::save(bb, ha.Superparents);
181  vtkmdiy::save(bb, ha.SuperparentRounds);
182  vtkmdiy::save(bb, ha.WhichRounds);
183  }
184 
185  static void load(vtkmdiy::BinaryBuffer& bb,
187  HierarchicalAugmenterInOutData<FieldType>& ha)
188  {
189  vtkmdiy::load(bb, ha.GlobalRegularIds);
190  vtkmdiy::load(bb, ha.DataValues);
191  vtkmdiy::load(bb, ha.SupernodeIds);
192  vtkmdiy::load(bb, ha.Superparents);
193  vtkmdiy::load(bb, ha.SuperparentRounds);
194  vtkmdiy::load(bb, ha.WhichRounds);
195  }
196 };
197 
198 } // namespace mangled_vtkmdiy_namespace
199 
200 #endif
vtkm::worklet::contourtree_distributed::hierarchical_augmenter::HierarchicalAugmenterInOutData::ReleaseResources
void ReleaseResources()
Clear all arrays.
Definition: HierarchicalAugmenterInOutData.h:122
vtkm::cont::ArrayHandle< vtkm::Id >
vtkm::worklet::contourtree_distributed::hierarchical_augmenter::HierarchicalAugmenterInOutData::SuperparentRounds
vtkm::worklet::contourtree_augmented::IdArrayType SuperparentRounds
Definition: HierarchicalAugmenterInOutData.h:80
vtkm::worklet::contourtree_distributed::hierarchical_augmenter::HierarchicalAugmenterInOutData::DataValues
vtkm::cont::ArrayHandle< FieldType > DataValues
Definition: HierarchicalAugmenterInOutData.h:77
vtkm::worklet::contourtree_distributed::hierarchical_augmenter::HierarchicalAugmenterInOutData::~HierarchicalAugmenterInOutData
~HierarchicalAugmenterInOutData()
Destructor.
Definition: HierarchicalAugmenterInOutData.h:115
vtkm
Groups connected points that have the same field value.
Definition: Atomic.h:19
vtkmdiy::Serialization< vtkm::worklet::contourtree_distributed::hierarchical_augmenter::HierarchicalAugmenterInOutData< FieldType > >::load
static void load(vtkmdiy::BinaryBuffer &bb, vtkm::worklet::contourtree_distributed::hierarchical_augmenter::HierarchicalAugmenterInOutData< FieldType > &ha)
Definition: HierarchicalAugmenterInOutData.h:185
vtkm::worklet::contourtree_distributed::hierarchical_augmenter::HierarchicalAugmenterInOutData::DebugPrint
std::string DebugPrint(std::string message, const char *fileName, long lineNum)
Print contents fo this objects.
Definition: HierarchicalAugmenterInOutData.h:133
vtkm::worklet::contourtree_distributed::hierarchical_augmenter::HierarchicalAugmenterInOutData::WhichRounds
vtkm::worklet::contourtree_augmented::IdArrayType WhichRounds
Definition: HierarchicalAugmenterInOutData.h:81
vtkm::worklet::contourtree_distributed::hierarchical_augmenter::HierarchicalAugmenterInOutData::GlobalRegularIds
vtkm::worklet::contourtree_augmented::IdArrayType GlobalRegularIds
Definition: HierarchicalAugmenterInOutData.h:76
vtkm::exec::arg::load
VTKM_SUPPRESS_EXEC_WARNINGS VTKM_EXEC T load(const U &u, vtkm::Id v)
Definition: FetchTagArrayDirectIn.h:36
vtkm::worklet::contourtree_distributed::hierarchical_augmenter
Definition: AttachmentAndSupernodeComparator.h:69
vtkmdiy
Definition: ContourTreeBlockData.h:97
vtkm::worklet::contourtree_distributed::hierarchical_augmenter::HierarchicalAugmenterInOutData::SupernodeIds
vtkm::worklet::contourtree_augmented::IdArrayType SupernodeIds
Definition: HierarchicalAugmenterInOutData.h:78
vtkm::worklet::contourtree_distributed::hierarchical_augmenter::HierarchicalAugmenterInOutData::HierarchicalAugmenterInOutData
HierarchicalAugmenterInOutData()
empty constructor
Definition: HierarchicalAugmenterInOutData.h:84
vtkm::worklet::contourtree_augmented::PrintValues
void PrintValues(std::string label, const vtkm::cont::ArrayHandle< T, StorageType > &dVec, vtkm::Id nValues=-1, std::ostream &outStream=std::cout)
Definition: augmented/PrintVectors.h:197
vtkm::worklet::contourtree_distributed::hierarchical_augmenter::HierarchicalAugmenterInOutData::Superparents
vtkm::worklet::contourtree_augmented::IdArrayType Superparents
Definition: HierarchicalAugmenterInOutData.h:79
vtkm::worklet::contourtree_distributed::hierarchical_augmenter::HierarchicalAugmenterInOutData
Class for storing input or output data for the HierarchicalAugmenter.
Definition: HierarchicalAugmenterInOutData.h:73
vtkmdiy::Serialization< vtkm::worklet::contourtree_distributed::hierarchical_augmenter::HierarchicalAugmenterInOutData< FieldType > >::save
static void save(vtkmdiy::BinaryBuffer &bb, const vtkm::worklet::contourtree_distributed::hierarchical_augmenter::HierarchicalAugmenterInOutData< FieldType > &ha)
Definition: HierarchicalAugmenterInOutData.h:173
vtkm::worklet::contourtree_augmented::PrintIndices
void PrintIndices(std::string label, const vtkm::cont::ArrayHandle< T > &iVec, vtkm::Id nIndices=-1, std::ostream &outStream=std::cout)
Definition: augmented/PrintVectors.h:253
vtkm::worklet::contourtree_distributed::hierarchical_augmenter::HierarchicalAugmenterInOutData::HierarchicalAugmenterInOutData
HierarchicalAugmenterInOutData(vtkm::worklet::contourtree_augmented::IdArrayType &globalRegularIds, vtkm::cont::ArrayHandle< FieldType > &dataValues, vtkm::worklet::contourtree_augmented::IdArrayType &supernodeIds, vtkm::worklet::contourtree_augmented::IdArrayType &superparents, vtkm::worklet::contourtree_augmented::IdArrayType &superparentRounds, vtkm::worklet::contourtree_augmented::IdArrayType &whichRounds)
main constructor
Definition: HierarchicalAugmenterInOutData.h:87