VTK-m  2.0
DataSetMeshTriangulation3DFreudenthal.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_worklet_contourtree_augmented_data_set_mesh_triangulation_3d_freudenthal_h
55 #define vtk_m_worklet_contourtree_augmented_data_set_mesh_triangulation_3d_freudenthal_h
56 
57 #include <cstdlib>
58 
65 
66 namespace vtkm
67 {
68 namespace worklet
69 {
70 namespace contourtree_augmented
71 {
72 
74  : public DataSetMesh
76 { // class DataSetMeshTriangulation3DFreudenthal
77 public:
78  // Constants and case tables
82  static constexpr int MAX_OUTDEGREE = 6; // True for Freudenthal and Marching Cubes
83 
84  // Mesh helper functions
85  void SetPrepareForExecutionBehavior(bool getMax);
86 
88  vtkm::cont::Token& token) const;
89 
91 
93 
94  void GetBoundaryVertices(IdArrayType& boundaryVertexArray, // output
95  IdArrayType& boundarySortIndexArray, // output
96  MeshBoundary3DExec* meshBoundaryExecObj =
97  NULL // optional input, included for consistency with ContourTreeMesh
98  ) const;
99 
103  const vtkm::worklet::contourtree_augmented::mesh_dem::IdRelabeler& localToGlobalIdRelabeler,
104  IdArrayType& ownedVertices) const;
105 
106 private:
107  bool UseGetMax; // Define the behavior ofr the PrepareForExecution function
108 }; // class DataSetMeshTriangulation
109 
110 // creates input mesh
112  vtkm::Id3 meshSize)
113  : DataSetMesh(meshSize)
114 
115 {
116  // Initialize the case tables in vtkm
119  m3d_freudenthal::N_INCIDENT_EDGES,
121  this->NeighbourOffsets = vtkm::cont::make_ArrayHandleGroupVec<3>(vtkm::cont::make_ArrayHandle(
122  m3d_freudenthal::NeighbourOffsets, m3d_freudenthal::N_INCIDENT_EDGES * 3, vtkm::CopyFlag::Off));
123  this->LinkComponentCaseTable =
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 {
140  m3d_freudenthal::N_INCIDENT_EDGES,
141  this->UseGetMax,
142  this->SortIndices,
143  this->SortOrder,
145  this->NeighbourOffsets,
147  device,
148  token);
149 }
150 
152  const
153 {
154  return MeshBoundary3DExec(this->MeshSize, this->SortIndices);
155 }
156 
158  IdArrayType& boundaryVertexArray, // output
159  IdArrayType& boundarySortIndexArray, // output
160  MeshBoundary3DExec* meshBoundaryExecObj // input
161 ) const
162 {
163  vtkm::Id numBoundary = 2 * this->MeshSize[1] * this->MeshSize[0] // xy faces
164  + 2 * this->MeshSize[1] * (this->MeshSize[2] - 2) // yz faces - excluding vertices on xy
165  + 2 * (this->MeshSize[0] - 2) * (this->MeshSize[2] - 2); // xz face interiors
166  auto boundaryId = vtkm::cont::ArrayHandleIndex(numBoundary);
167  ComputeMeshBoundary3D computeMeshBoundary3dWorklet;
168  vtkm::cont::Invoker invoke;
169  invoke(computeMeshBoundary3dWorklet,
170  boundaryId, // input
171  this->SortIndices, // input
172  (meshBoundaryExecObj == NULL) ? this->GetMeshBoundaryExecutionObject()
173  : *meshBoundaryExecObj, // input
174  boundaryVertexArray, // output
175  boundarySortIndexArray // output
176  );
177 }
178 
179 // Overwrite the implemenation from the base DataSetMesh parent class
181  const vtkm::worklet::contourtree_augmented::mesh_dem::IdRelabeler& localToGlobalIdRelabeler,
182  IdArrayType& ownedVertices) const
183 {
184  return this->GetOwnedVerticesByGlobalIdImpl(this, localToGlobalIdRelabeler, ownedVertices);
185 }
186 
187 } // namespace contourtree_augmented
188 } // worklet
189 } // vtkm
190 
191 #endif
vtkm::worklet::contourtree_augmented::MeshBoundary3DExec
Definition: MeshBoundary3D.h:272
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::Int8 >
vtkm::worklet::contourtree_augmented::m3d_freudenthal::LINK_COMPONENT_CASES
constexpr vtkm::Int32 LINK_COMPONENT_CASES
Definition: filter/scalar_topology/worklet/contourtree_augmented/meshtypes/freudenthal_3D/Types.h:108
vtkm
Groups connected points that have the same field value.
Definition: Atomic.h:19
vtkm::worklet::contourtree_augmented::DataSetMeshTriangulation3DFreudenthal::DataSetMeshTriangulation3DFreudenthal
DataSetMeshTriangulation3DFreudenthal(vtkm::Id3 meshSize)
Definition: DataSetMeshTriangulation3DFreudenthal.h:111
vtkm::worklet::contourtree_augmented::m3d_freudenthal::NeighbourOffsets
VTKM_STATIC_CONSTEXPR_ARRAY vtkm::IdComponent NeighbourOffsets[N_INCIDENT_EDGES *3]
Definition: filter/scalar_topology/worklet/contourtree_augmented/meshtypes/freudenthal_3D/Types.h:86
vtkm::worklet::contourtree_augmented::DataSetMesh::SortOrder
IdArrayType SortOrder
Definition: DataSetMesh.h:107
vtkm::worklet::contourtree_augmented::DataSetMeshTriangulation3DFreudenthal::NeighbourOffsets
m3d_freudenthal::NeighbourOffsetsType NeighbourOffsets
Definition: DataSetMeshTriangulation3DFreudenthal.h:80
vtkm::worklet::contourtree_augmented::MeshStructureFreudenthal3D
Definition: MeshStructureFreudenthal3D.h:73
vtkm::worklet::contourtree_augmented::DataSetMesh::SortIndices
IdArrayType SortIndices
Definition: DataSetMesh.h:111
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::DataSetMeshTriangulation3DFreudenthal::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: DataSetMeshTriangulation3DFreudenthal.h:180
vtkm::Id
vtkm::Int32 Id
Represents an ID (index into arrays).
Definition: Types.h:191
vtkm::worklet::contourtree_augmented::m3d_freudenthal::EdgeBoundaryDetectionMasks
VTKM_STATIC_CONSTEXPR_ARRAY vtkm::Int8 EdgeBoundaryDetectionMasks[N_INCIDENT_EDGES]
Definition: filter/scalar_topology/worklet/contourtree_augmented/meshtypes/freudenthal_3D/Types.h:91
vtkm::cont::Token
A token to hold the scope of an ArrayHandle or other object.
Definition: Token.h:35
vtkm::worklet::contourtree_augmented::m3d_freudenthal::LinkComponentCaseTable
VTKM_STATIC_CONSTEXPR_ARRAY vtkm::UInt16 LinkComponentCaseTable[LINK_COMPONENT_CASES]
Definition: filter/scalar_topology/worklet/contourtree_augmented/meshtypes/freudenthal_3D/Types.h:109
ComputeMeshBoundary3D.h
vtkm::worklet::contourtree_augmented::DataSetMeshTriangulation3DFreudenthal::SetPrepareForExecutionBehavior
void SetPrepareForExecutionBehavior(bool getMax)
Definition: DataSetMeshTriangulation3DFreudenthal.h:129
vtkm::worklet::contourtree_augmented::DataSetMeshTriangulation3DFreudenthal::GetBoundaryVertices
void GetBoundaryVertices(IdArrayType &boundaryVertexArray, IdArrayType &boundarySortIndexArray, MeshBoundary3DExec *meshBoundaryExecObj=NULL) const
Definition: DataSetMeshTriangulation3DFreudenthal.h:157
MeshBoundary3D.h
vtkm::worklet::contourtree_augmented::DataSetMeshTriangulation3DFreudenthal
Definition: DataSetMeshTriangulation3DFreudenthal.h:73
DataSetMesh.h
vtkm::cont::Invoker
Allows launching any worklet without a dispatcher.
Definition: Invoker.h:41
MeshStructureFreudenthal3D.h
vtkm::worklet::contourtree_augmented::DataSetMeshTriangulation3DFreudenthal::MAX_OUTDEGREE
static constexpr int MAX_OUTDEGREE
Definition: DataSetMeshTriangulation3DFreudenthal.h:82
vtkm::worklet::contourtree_augmented::DataSetMesh::MeshSize
vtkm::Id3 MeshSize
Definition: DataSetMesh.h:103
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, 3 >
vtkm::CopyFlag::Off
@ Off
vtkm::worklet::contourtree_augmented::DataSetMeshTriangulation3DFreudenthal::UseGetMax
bool UseGetMax
Definition: DataSetMeshTriangulation3DFreudenthal.h:107
vtkm::worklet::contourtree_augmented::DataSetMeshTriangulation3DFreudenthal::LinkComponentCaseTable
m3d_freudenthal::LinkComponentCaseTableType LinkComponentCaseTable
Definition: DataSetMeshTriangulation3DFreudenthal.h:81
vtkm::worklet::contourtree_augmented::DataSetMeshTriangulation3DFreudenthal::EdgeBoundaryDetectionMasks
m3d_freudenthal::EdgeBoundaryDetectionMasksType EdgeBoundaryDetectionMasks
Definition: DataSetMeshTriangulation3DFreudenthal.h:79
vtkm::worklet::contourtree_augmented::DataSetMeshTriangulation3DFreudenthal::PrepareForExecution
MeshStructureFreudenthal3D PrepareForExecution(vtkm::cont::DeviceAdapterId device, vtkm::cont::Token &token) const
Definition: DataSetMeshTriangulation3DFreudenthal.h:135
vtkm::worklet::contourtree_augmented::DataSetMeshTriangulation3DFreudenthal::GetMeshBoundaryExecutionObject
MeshBoundary3DExec GetMeshBoundaryExecutionObject() const
Definition: DataSetMeshTriangulation3DFreudenthal.h:151
vtkm::cont::ArrayHandleGroupVec< vtkm::cont::ArrayHandle< vtkm::IdComponent >, 3 >
vtkm::worklet::contourtree_augmented::DataSetMesh
Definition: DataSetMesh.h:97
ExecutionObjectBase.h
vtkm::worklet::contourtree_augmented::ComputeMeshBoundary3D
Definition: ComputeMeshBoundary3D.h:69
vtkm::cont::ArrayHandleIndex
An implicit array handle containing the its own indices.
Definition: ArrayHandleIndex.h:54
Types.h