Viskores  1.0
ConnectivityPermuted.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 
19 #ifndef viskores_exec_ConnectivityPermuted_h
20 #define viskores_exec_ConnectivityPermuted_h
21 
22 #include <viskores/CellShape.h>
24 #include <viskores/Types.h>
25 #include <viskores/VecFromPortal.h>
26 
27 namespace viskores
28 {
29 namespace exec
30 {
31 
32 template <typename PermutationPortal, typename OriginalConnectivity>
34 {
35 public:
36  using SchedulingRangeType = typename OriginalConnectivity::SchedulingRangeType;
37 
39 
41  ConnectivityPermutedVisitCellsWithPoints(const PermutationPortal& portal,
42  const OriginalConnectivity& src)
43  : Portal(portal)
44  , Connectivity(src)
45  {
46  }
47 
49  default;
50 
52  const ConnectivityPermutedVisitCellsWithPoints& src) = default;
55 
57  viskores::Id GetNumberOfElements() const { return this->Portal.GetNumberOfValues(); }
58 
59  using CellShapeTag = typename OriginalConnectivity::CellShapeTag;
60 
63  {
64  viskores::Id pIndex = this->Portal.Get(index);
65  return this->Connectivity.GetCellShape(pIndex);
66  }
67 
70  {
71  return this->Connectivity.GetNumberOfIndices(this->Portal.Get(index));
72  }
73 
74  using IndicesType = typename OriginalConnectivity::IndicesType;
75 
76  template <typename IndexType>
77  VISKORES_EXEC IndicesType GetIndices(const IndexType& index) const
78  {
79  return this->Connectivity.GetIndices(this->Portal.Get(index));
80  }
81 
82  PermutationPortal Portal;
83  OriginalConnectivity Connectivity;
84 };
85 
86 template <typename ConnectivityPortalType, typename OffsetPortalType>
88 {
89 public:
93 
95 
96  ConnectivityPermutedVisitPointsWithCells(const ConnectivityPortalType& connectivity,
97  const OffsetPortalType& offsets)
98  : Connectivity(connectivity)
99  , Offsets(offsets)
100  {
101  }
102 
104  SchedulingRangeType GetNumberOfElements() const { return this->Offsets.GetNumberOfValues() - 1; }
105 
107 
110  {
111  const viskores::Id offBegin = this->Offsets.Get(index);
112  const viskores::Id offEnd = this->Offsets.Get(index + 1);
113  return static_cast<viskores::IdComponent>(offEnd - offBegin);
114  }
115 
117  {
118  const viskores::Id offBegin = this->Offsets.Get(index);
119  const viskores::Id offEnd = this->Offsets.Get(index + 1);
120  return IndicesType(
121  this->Connectivity, static_cast<viskores::IdComponent>(offEnd - offBegin), offBegin);
122  }
123 
124 private:
125  ConnectivityPortalType Connectivity;
126  OffsetPortalType Offsets;
127 };
128 }
129 } // namespace viskores::exec
130 
131 #endif //viskores_exec_ConnectivityPermuted_h
viskores::exec::ConnectivityPermutedVisitCellsWithPoints::ConnectivityPermutedVisitCellsWithPoints
ConnectivityPermutedVisitCellsWithPoints()=default
Types.h
viskores::exec::ConnectivityPermutedVisitPointsWithCells::Connectivity
ConnectivityPortalType Connectivity
Definition: ConnectivityPermuted.h:125
viskores::VecFromPortal
A short variable-length array from a window in an ArrayPortal.
Definition: VecFromPortal.h:37
viskores::exec::ConnectivityPermutedVisitPointsWithCells::CellShapeTag
viskores::CellShapeTagVertex CellShapeTag
Definition: ConnectivityPermuted.h:92
viskores::IdComponent
viskores::Int32 IdComponent
Base type to use to index small lists.
Definition: Types.h:202
viskores::exec::ConnectivityPermutedVisitPointsWithCells::SchedulingRangeType
viskores::Id SchedulingRangeType
Definition: ConnectivityPermuted.h:90
CellShape.h
VISKORES_EXEC_CONT
#define VISKORES_EXEC_CONT
Definition: ExportMacros.h:60
viskores::exec::ConnectivityPermutedVisitPointsWithCells::IndicesType
viskores::VecFromPortal< ConnectivityPortalType > IndicesType
Definition: ConnectivityPermuted.h:91
viskores::exec::ConnectivityPermutedVisitCellsWithPoints::CellShapeTag
typename OriginalConnectivity::CellShapeTag CellShapeTag
Definition: ConnectivityPermuted.h:59
viskores::exec::ConnectivityPermutedVisitCellsWithPoints::operator=
ConnectivityPermutedVisitCellsWithPoints & operator=(const ConnectivityPermutedVisitCellsWithPoints &src)=default
viskores::exec::ConnectivityPermutedVisitPointsWithCells::GetNumberOfElements
SchedulingRangeType GetNumberOfElements() const
Definition: ConnectivityPermuted.h:104
viskores::exec::ConnectivityPermutedVisitCellsWithPoints
Definition: ConnectivityPermuted.h:33
viskores::exec::ConnectivityPermutedVisitPointsWithCells::GetCellShape
CellShapeTag GetCellShape(viskores::Id) const
Definition: ConnectivityPermuted.h:106
viskores::Id
viskores::Int64 Id
Base type to use to index arrays.
Definition: Types.h:235
viskores::exec::ConnectivityPermutedVisitCellsWithPoints::SchedulingRangeType
typename OriginalConnectivity::SchedulingRangeType SchedulingRangeType
Definition: ConnectivityPermuted.h:36
viskores
Groups connected points that have the same field value.
Definition: Atomic.h:27
VecFromPortal.h
viskores::exec::ConnectivityPermutedVisitPointsWithCells::GetNumberOfIndices
viskores::IdComponent GetNumberOfIndices(viskores::Id index) const
Definition: ConnectivityPermuted.h:109
viskores::exec::ConnectivityPermutedVisitCellsWithPoints::GetCellShape
CellShapeTag GetCellShape(viskores::Id index) const
Definition: ConnectivityPermuted.h:62
viskores::CellShapeTagVertex
Definition: CellShape.h:156
viskores::exec::ConnectivityPermutedVisitPointsWithCells::ConnectivityPermutedVisitPointsWithCells
ConnectivityPermutedVisitPointsWithCells()=default
viskores::exec::ConnectivityPermutedVisitCellsWithPoints::IndicesType
typename OriginalConnectivity::IndicesType IndicesType
Definition: ConnectivityPermuted.h:74
viskores::exec::ConnectivityPermutedVisitPointsWithCells
Definition: ConnectivityPermuted.h:87
viskores::exec::ConnectivityPermutedVisitCellsWithPoints::Portal
PermutationPortal Portal
Definition: ConnectivityPermuted.h:82
viskores::exec::ConnectivityPermutedVisitCellsWithPoints::GetIndices
IndicesType GetIndices(const IndexType &index) const
Definition: ConnectivityPermuted.h:77
viskores::exec::ConnectivityPermutedVisitPointsWithCells::Offsets
OffsetPortalType Offsets
Definition: ConnectivityPermuted.h:126
viskores::exec::ConnectivityPermutedVisitCellsWithPoints::GetNumberOfIndices
viskores::IdComponent GetNumberOfIndices(viskores::Id index) const
Definition: ConnectivityPermuted.h:69
VISKORES_EXEC
#define VISKORES_EXEC
Definition: ExportMacros.h:59
viskores::exec::ConnectivityPermutedVisitCellsWithPoints::Connectivity
OriginalConnectivity Connectivity
Definition: ConnectivityPermuted.h:83
viskores::exec::ConnectivityPermutedVisitCellsWithPoints::GetNumberOfElements
viskores::Id GetNumberOfElements() const
Definition: ConnectivityPermuted.h:57
viskores::exec::ConnectivityPermutedVisitPointsWithCells::GetIndices
IndicesType GetIndices(viskores::Id index) const
Definition: ConnectivityPermuted.h:116
TopologyElementTag.h
viskores::exec::ConnectivityPermutedVisitCellsWithPoints::ConnectivityPermutedVisitCellsWithPoints
ConnectivityPermutedVisitCellsWithPoints(const PermutationPortal &portal, const OriginalConnectivity &src)
Definition: ConnectivityPermuted.h:41
viskores::exec::ConnectivityPermutedVisitPointsWithCells::ConnectivityPermutedVisitPointsWithCells
ConnectivityPermutedVisitPointsWithCells(const ConnectivityPortalType &connectivity, const OffsetPortalType &offsets)
Definition: ConnectivityPermuted.h:96