VTK-m  2.2
ConnectivityPermuted.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 
11 #ifndef vtk_m_exec_ConnectivityPermuted_h
12 #define vtk_m_exec_ConnectivityPermuted_h
13 
14 #include <vtkm/CellShape.h>
16 #include <vtkm/Types.h>
17 #include <vtkm/VecFromPortal.h>
18 
19 namespace vtkm
20 {
21 namespace exec
22 {
23 
24 template <typename PermutationPortal, typename OriginalConnectivity>
26 {
27 public:
28  using SchedulingRangeType = typename OriginalConnectivity::SchedulingRangeType;
29 
31 
33  ConnectivityPermutedVisitCellsWithPoints(const PermutationPortal& portal,
34  const OriginalConnectivity& src)
35  : Portal(portal)
36  , Connectivity(src)
37  {
38  }
39 
41  default;
42 
44  const ConnectivityPermutedVisitCellsWithPoints& src) = default;
47 
48  VTKM_EXEC
49  vtkm::Id GetNumberOfElements() const { return this->Portal.GetNumberOfValues(); }
50 
51  using CellShapeTag = typename OriginalConnectivity::CellShapeTag;
52 
53  VTKM_EXEC
55  {
56  vtkm::Id pIndex = this->Portal.Get(index);
57  return this->Connectivity.GetCellShape(pIndex);
58  }
59 
60  VTKM_EXEC
62  {
63  return this->Connectivity.GetNumberOfIndices(this->Portal.Get(index));
64  }
65 
66  using IndicesType = typename OriginalConnectivity::IndicesType;
67 
68  template <typename IndexType>
69  VTKM_EXEC IndicesType GetIndices(const IndexType& index) const
70  {
71  return this->Connectivity.GetIndices(this->Portal.Get(index));
72  }
73 
74  PermutationPortal Portal;
75  OriginalConnectivity Connectivity;
76 };
77 
78 template <typename ConnectivityPortalType, typename OffsetPortalType>
80 {
81 public:
85 
87 
88  ConnectivityPermutedVisitPointsWithCells(const ConnectivityPortalType& connectivity,
89  const OffsetPortalType& offsets)
90  : Connectivity(connectivity)
91  , Offsets(offsets)
92  {
93  }
94 
95  VTKM_EXEC
96  SchedulingRangeType GetNumberOfElements() const { return this->Offsets.GetNumberOfValues() - 1; }
97 
99 
100  VTKM_EXEC
102  {
103  const vtkm::Id offBegin = this->Offsets.Get(index);
104  const vtkm::Id offEnd = this->Offsets.Get(index + 1);
105  return static_cast<vtkm::IdComponent>(offEnd - offBegin);
106  }
107 
109  {
110  const vtkm::Id offBegin = this->Offsets.Get(index);
111  const vtkm::Id offEnd = this->Offsets.Get(index + 1);
112  return IndicesType(
113  this->Connectivity, static_cast<vtkm::IdComponent>(offEnd - offBegin), offBegin);
114  }
115 
116 private:
117  ConnectivityPortalType Connectivity;
118  OffsetPortalType Offsets;
119 };
120 }
121 } // namespace vtkm::exec
122 
123 #endif //vtk_m_exec_ConnectivityPermuted_h
vtkm::exec::ConnectivityPermutedVisitPointsWithCells::Offsets
OffsetPortalType Offsets
Definition: ConnectivityPermuted.h:118
VTKM_EXEC
#define VTKM_EXEC
Definition: ExportMacros.h:51
vtkm::exec::ConnectivityPermutedVisitCellsWithPoints::GetIndices
IndicesType GetIndices(const IndexType &index) const
Definition: ConnectivityPermuted.h:69
vtkm
Groups connected points that have the same field value.
Definition: Atomic.h:19
Types.h
vtkm::exec::ConnectivityPermutedVisitPointsWithCells::ConnectivityPermutedVisitPointsWithCells
ConnectivityPermutedVisitPointsWithCells()=default
VTKM_EXEC_CONT
#define VTKM_EXEC_CONT
Definition: ExportMacros.h:52
vtkm::exec::ConnectivityPermutedVisitCellsWithPoints::ConnectivityPermutedVisitCellsWithPoints
ConnectivityPermutedVisitCellsWithPoints(const PermutationPortal &portal, const OriginalConnectivity &src)
Definition: ConnectivityPermuted.h:33
vtkm::IdComponent
vtkm::Int32 IdComponent
Base type to use to index small lists.
Definition: Types.h:194
vtkm::exec::ConnectivityPermutedVisitCellsWithPoints::GetNumberOfElements
vtkm::Id GetNumberOfElements() const
Definition: ConnectivityPermuted.h:49
vtkm::exec::ConnectivityPermutedVisitPointsWithCells::GetCellShape
CellShapeTag GetCellShape(vtkm::Id) const
Definition: ConnectivityPermuted.h:98
vtkm::exec::ConnectivityPermutedVisitPointsWithCells::GetIndices
IndicesType GetIndices(vtkm::Id index) const
Definition: ConnectivityPermuted.h:108
CellShape.h
vtkm::exec::ConnectivityPermutedVisitCellsWithPoints::operator=
ConnectivityPermutedVisitCellsWithPoints & operator=(const ConnectivityPermutedVisitCellsWithPoints &src)=default
vtkm::exec::ConnectivityPermutedVisitPointsWithCells::SchedulingRangeType
vtkm::Id SchedulingRangeType
Definition: ConnectivityPermuted.h:82
vtkm::exec::ConnectivityPermutedVisitCellsWithPoints::IndicesType
typename OriginalConnectivity::IndicesType IndicesType
Definition: ConnectivityPermuted.h:66
vtkm::CellShapeTagVertex
Definition: CellShape.h:148
VecFromPortal.h
vtkm::exec::ConnectivityPermutedVisitPointsWithCells::ConnectivityPermutedVisitPointsWithCells
ConnectivityPermutedVisitPointsWithCells(const ConnectivityPortalType &connectivity, const OffsetPortalType &offsets)
Definition: ConnectivityPermuted.h:88
vtkm::exec::ConnectivityPermutedVisitCellsWithPoints::Connectivity
OriginalConnectivity Connectivity
Definition: ConnectivityPermuted.h:75
vtkm::exec::ConnectivityPermutedVisitPointsWithCells::IndicesType
vtkm::VecFromPortal< ConnectivityPortalType > IndicesType
Definition: ConnectivityPermuted.h:83
vtkm::exec::ConnectivityPermutedVisitCellsWithPoints::ConnectivityPermutedVisitCellsWithPoints
ConnectivityPermutedVisitCellsWithPoints()=default
vtkm::exec::ConnectivityPermutedVisitPointsWithCells::GetNumberOfIndices
vtkm::IdComponent GetNumberOfIndices(vtkm::Id index) const
Definition: ConnectivityPermuted.h:101
vtkm::Id
vtkm::Int64 Id
Base type to use to index arrays.
Definition: Types.h:227
vtkm::exec::ConnectivityPermutedVisitPointsWithCells
Definition: ConnectivityPermuted.h:79
vtkm::exec::ConnectivityPermutedVisitPointsWithCells::CellShapeTag
vtkm::CellShapeTagVertex CellShapeTag
Definition: ConnectivityPermuted.h:84
vtkm::exec::ConnectivityPermutedVisitCellsWithPoints::SchedulingRangeType
typename OriginalConnectivity::SchedulingRangeType SchedulingRangeType
Definition: ConnectivityPermuted.h:28
vtkm::exec::ConnectivityPermutedVisitCellsWithPoints::GetNumberOfIndices
vtkm::IdComponent GetNumberOfIndices(vtkm::Id index) const
Definition: ConnectivityPermuted.h:61
vtkm::exec::ConnectivityPermutedVisitCellsWithPoints::Portal
PermutationPortal Portal
Definition: ConnectivityPermuted.h:74
vtkm::VecFromPortal
A short variable-length array from a window in an ArrayPortal.
Definition: VecFromPortal.h:29
vtkm::exec::ConnectivityPermutedVisitPointsWithCells::Connectivity
ConnectivityPortalType Connectivity
Definition: ConnectivityPermuted.h:117
vtkm::exec::ConnectivityPermutedVisitCellsWithPoints
Definition: ConnectivityPermuted.h:25
vtkm::exec::ConnectivityPermutedVisitCellsWithPoints::GetCellShape
CellShapeTag GetCellShape(vtkm::Id index) const
Definition: ConnectivityPermuted.h:54
vtkm::exec::ConnectivityPermutedVisitPointsWithCells::GetNumberOfElements
SchedulingRangeType GetNumberOfElements() const
Definition: ConnectivityPermuted.h:96
vtkm::exec::ConnectivityPermutedVisitCellsWithPoints::CellShapeTag
typename OriginalConnectivity::CellShapeTag CellShapeTag
Definition: ConnectivityPermuted.h:51
TopologyElementTag.h