VTK-m  2.0
DataSetMeshTriangulation2DFreudenthal.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 #ifndef vtk_m_worklet_contourtree_augmented_data_set_mesh_triangulation_2d_freudenthal_h
54 #define vtk_m_worklet_contourtree_augmented_data_set_mesh_triangulation_2d_freudenthal_h
55 
56 #include <cstdlib>
57 
62 
64 
65 namespace vtkm
66 {
67 namespace worklet
68 {
69 namespace contourtree_augmented
70 {
71 
74  : public DataSetMesh
76 { // class DataSetMeshTriangulation
77 public:
80  static constexpr int MAX_OUTDEGREE = 3;
81 
82  //Mesh dependent helper functions
83  void SetPrepareForExecutionBehavior(bool getMax);
84 
88  vtkm::cont::Token& token) const;
89 
93 
98 
104  void GetBoundaryVertices(IdArrayType& boundaryVertexArray,
105  IdArrayType& boundarySortIndexArray,
106  MeshBoundary2DExec* meshBoundaryExecObj = NULL) const;
107 
111  const vtkm::worklet::contourtree_augmented::mesh_dem::IdRelabeler& localToGlobalIdRelabeler,
112  IdArrayType& ownedVertices) const;
113 
114 private:
115  bool UseGetMax; // Define the behavior ofr the PrepareForExecution function
116 }; // class DataSetMeshTriangulation
117 
118 // creates input mesh
120  vtkm::Id2 meshSize)
121  : DataSetMesh(vtkm::Id3{ meshSize[0], meshSize[1], 1 })
122  , EdgeBoundaryDetectionMasks{ vtkm::cont::make_ArrayHandle(
123  m2d_freudenthal::EdgeBoundaryDetectionMasks,
124  m2d_freudenthal::N_INCIDENT_EDGES,
126 {
127 }
128 
130 {
131  this->UseGetMax = getMax;
132 }
133 
134 // Get VTKM execution object that represents the structure of the mesh and provides the mesh helper functions on the device
137  vtkm::cont::Token& token) const
138 {
139  return MeshStructureFreudenthal2D(vtkm::Id2{ this->MeshSize[0], this->MeshSize[1] },
140  m2d_freudenthal::N_INCIDENT_EDGES,
141  this->UseGetMax,
142  this->SortIndices,
143  this->SortOrder,
145  device,
146  token);
147 }
148 
150  const
151 {
152  return MeshBoundary2DExec(vtkm::Id2{ this->MeshSize[0], this->MeshSize[1] }, this->SortIndices);
153 }
154 
156  IdArrayType& boundaryVertexArray, // output
157  IdArrayType& boundarySortIndexArray, // output
159  meshBoundaryExecObj // optional input, included for consistency with ContourTreeMesh
160 ) const
161 {
162  vtkm::Id numBoundary = 2 * this->MeshSize[1] + 2 * this->MeshSize[0] - 4;
163  auto boundaryId = vtkm::cont::ArrayHandleIndex(numBoundary);
164  ComputeMeshBoundary2D computeMeshBoundary2dWorklet;
165  vtkm::cont::Invoker invoke;
166  invoke(computeMeshBoundary2dWorklet,
167  boundaryId, // input
168  this->SortIndices, // input
169  (meshBoundaryExecObj == NULL) ? this->GetMeshBoundaryExecutionObject()
170  : *meshBoundaryExecObj, // input
171  boundaryVertexArray, // output
172  boundarySortIndexArray // output
173  );
174 }
175 
176 // Overwrite the implemenation from the base DataSetMesh parent class
178  const vtkm::worklet::contourtree_augmented::mesh_dem::IdRelabeler& localToGlobalIdRelabeler,
179  IdArrayType& ownedVertices) const
180 {
181  return this->GetOwnedVerticesByGlobalIdImpl(this, localToGlobalIdRelabeler, ownedVertices);
182 }
183 
184 } // namespace contourtree_augmented
185 } // worklet
186 } // vtkm
187 
188 #endif
ComputeMeshBoundary2D.h
vtkm::cont::make_ArrayHandle
VTKM_CONT vtkm::cont::ArrayHandleBasic< T > make_ArrayHandle(const T *array, vtkm::Id numberOfValues, vtkm::CopyFlag copy)
A convenience function for creating an ArrayHandle from a standard C array.
Definition: ArrayHandleBasic.h:217
vtkm::cont::ArrayHandle< vtkm::Id >
MeshBoundary2D.h
vtkm
Groups connected points that have the same field value.
Definition: Atomic.h:19
vtkm::worklet::contourtree_augmented::DataSetMesh::SortOrder
IdArrayType SortOrder
Definition: DataSetMesh.h:107
vtkm::worklet::contourtree_augmented::m2d_freudenthal::EdgeBoundaryDetectionMasksType
typename vtkm::cont::ArrayHandle< vtkm::Int8 > EdgeBoundaryDetectionMasksType
Definition: filter/scalar_topology/worklet/contourtree_augmented/meshtypes/freudenthal_2D/Types.h:68
MeshStructureFreudenthal2D.h
vtkm::worklet::contourtree_augmented::DataSetMeshTriangulation2DFreudenthal
Class representing a 2D dataset mesh with freudenthal triangulation connectivity for contour tree com...
Definition: DataSetMeshTriangulation2DFreudenthal.h:73
vtkm::worklet::contourtree_augmented::DataSetMesh::SortIndices
IdArrayType SortIndices
Definition: DataSetMesh.h:111
vtkm::worklet::contourtree_augmented::DataSetMeshTriangulation2DFreudenthal::GetBoundaryVertices
void GetBoundaryVertices(IdArrayType &boundaryVertexArray, IdArrayType &boundarySortIndexArray, MeshBoundary2DExec *meshBoundaryExecObj=NULL) const
Get boundary vertices.
Definition: DataSetMeshTriangulation2DFreudenthal.h:155
vtkm::worklet::contourtree_augmented::DataSetMeshTriangulation2DFreudenthal::MAX_OUTDEGREE
static constexpr int MAX_OUTDEGREE
Definition: DataSetMeshTriangulation2DFreudenthal.h:80
vtkm::worklet::contourtree_augmented::DataSetMesh::GetOwnedVerticesByGlobalIdImpl
void GetOwnedVerticesByGlobalIdImpl(const MeshTypeObj *mesh, const vtkm::worklet::contourtree_augmented::mesh_dem::IdRelabeler &localToGlobalIdRelabeler, IdArrayType &ownedVertices) const
Compute a list of the global Iss of all vertices that logically belong to the data block represented ...
Definition: DataSetMesh.h:216
vtkm::worklet::contourtree_augmented::DataSetMeshTriangulation2DFreudenthal::EdgeBoundaryDetectionMasks
m2d_freudenthal::EdgeBoundaryDetectionMasksType EdgeBoundaryDetectionMasks
Constants and case tables.
Definition: DataSetMeshTriangulation2DFreudenthal.h:79
vtkm::Id
vtkm::Int32 Id
Represents an ID (index into arrays).
Definition: Types.h:191
vtkm::cont::Token
A token to hold the scope of an ArrayHandle or other object.
Definition: Token.h:35
vtkm::worklet::contourtree_augmented::DataSetMeshTriangulation2DFreudenthal::SetPrepareForExecutionBehavior
void SetPrepareForExecutionBehavior(bool getMax)
Definition: DataSetMeshTriangulation2DFreudenthal.h:129
vtkm::worklet::contourtree_augmented::ComputeMeshBoundary2D
Definition: ComputeMeshBoundary2D.h:69
DataSetMesh.h
vtkm::cont::Invoker
Allows launching any worklet without a dispatcher.
Definition: Invoker.h:41
vtkm::worklet::contourtree_augmented::MeshBoundary2DExec
Definition: MeshBoundary2D.h:167
vtkm::worklet::contourtree_augmented::DataSetMeshTriangulation2DFreudenthal::GetMeshBoundaryExecutionObject
MeshBoundary2DExec GetMeshBoundaryExecutionObject() const
Helper function to create a boundary excution object for the mesh.
Definition: DataSetMeshTriangulation2DFreudenthal.h:149
vtkm::worklet::contourtree_augmented::DataSetMeshTriangulation2DFreudenthal::UseGetMax
bool UseGetMax
Definition: DataSetMeshTriangulation2DFreudenthal.h:115
vtkm::worklet::contourtree_augmented::DataSetMesh::MeshSize
vtkm::Id3 MeshSize
Definition: DataSetMesh.h:103
vtkm::worklet::contourtree_augmented::MeshStructureFreudenthal2D
Definition: MeshStructureFreudenthal2D.h:72
vtkm::worklet::contourtree_augmented::DataSetMeshTriangulation2DFreudenthal::DataSetMeshTriangulation2DFreudenthal
DataSetMeshTriangulation2DFreudenthal(vtkm::Id2 meshSize)
Constructor.
Definition: DataSetMeshTriangulation2DFreudenthal.h:119
vtkm::worklet::contourtree_augmented::mesh_dem::IdRelabeler
A utility class that converts Ids from local to global given a mesh.
Definition: IdRelabeler.h:79
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::Vec< vtkm::Id, 2 >
vtkm::CopyFlag::Off
@ Off
vtkm::worklet::contourtree_augmented::DataSetMeshTriangulation2DFreudenthal::GetOwnedVerticesByGlobalId
void GetOwnedVerticesByGlobalId(const vtkm::worklet::contourtree_augmented::mesh_dem::IdRelabeler &localToGlobalIdRelabeler, IdArrayType &ownedVertices) const
Get of global indices of the vertices owned by this mesh.
Definition: DataSetMeshTriangulation2DFreudenthal.h:177
vtkm::worklet::contourtree_augmented::DataSetMeshTriangulation2DFreudenthal::PrepareForExecution
MeshStructureFreudenthal2D PrepareForExecution(vtkm::cont::DeviceAdapterId device, vtkm::cont::Token &token) const
Prepare mesh for use in VTKm worklets.
Definition: DataSetMeshTriangulation2DFreudenthal.h:135
vtkm::worklet::contourtree_augmented::DataSetMesh
Definition: DataSetMesh.h:97
ExecutionObjectBase.h
vtkm::cont::ArrayHandleIndex
An implicit array handle containing the its own indices.
Definition: ArrayHandleIndex.h:54