Viskores  1.0
ConnectivityExplicit.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 #ifndef viskores_exec_ConnectivityExplicit_h
19 #define viskores_exec_ConnectivityExplicit_h
20 
21 #include <viskores/CellShape.h>
22 #include <viskores/Types.h>
23 
24 #include <viskores/VecFromPortal.h>
25 
26 namespace viskores
27 {
28 namespace exec
29 {
30 
36 template <typename ShapesPortalType, typename ConnectivityPortalType, typename OffsetsPortalType>
38 {
39 public:
41 
43 
44  ConnectivityExplicit(const ShapesPortalType& shapesPortal,
45  const ConnectivityPortalType& connPortal,
46  const OffsetsPortalType& offsetsPortal)
47  : Shapes(shapesPortal)
48  , Connectivity(connPortal)
49  , Offsets(offsetsPortal)
50  {
51  }
52 
59  SchedulingRangeType GetNumberOfElements() const { return this->Shapes.GetNumberOfValues(); }
60 
66 
73  {
74  return CellShapeTag(this->Shapes.Get(index));
75  }
76 
81  {
82  return static_cast<viskores::IdComponent>(this->Offsets.Get(index + 1) -
83  this->Offsets.Get(index));
84  }
85 
88 
98  {
99  const viskores::Id offset = this->Offsets.Get(index);
100  const viskores::Id endOffset = this->Offsets.Get(index + 1);
101  const auto length = static_cast<viskores::IdComponent>(endOffset - offset);
102 
103  return IndicesType(this->Connectivity, length, offset);
104  }
105 
106 private:
107  ShapesPortalType Shapes;
108  ConnectivityPortalType Connectivity;
109  OffsetsPortalType Offsets;
110 };
111 
112 } // namespace exec
113 } // namespace viskores
114 
115 #endif // viskores_exec_ConnectivityExplicit_h
viskores::exec::ConnectivityExplicit::SchedulingRangeType
viskores::Id SchedulingRangeType
Definition: ConnectivityExplicit.h:40
viskores::exec::ConnectivityExplicit::CellShapeTag
viskores::CellShapeTagGeneric CellShapeTag
The tag representing the cell shape of the visited elements.
Definition: ConnectivityExplicit.h:65
viskores::exec::ConnectivityExplicit::Offsets
OffsetsPortalType Offsets
Definition: ConnectivityExplicit.h:109
Types.h
viskores::exec::ConnectivityExplicit::Connectivity
ConnectivityPortalType Connectivity
Definition: ConnectivityExplicit.h:108
viskores::VecFromPortal
A short variable-length array from a window in an ArrayPortal.
Definition: VecFromPortal.h:37
viskores::exec::ConnectivityExplicit
A class holding information about topology connections.
Definition: ConnectivityExplicit.h:37
viskores::IdComponent
viskores::Int32 IdComponent
Base type to use to index small lists.
Definition: Types.h:202
CellShape.h
viskores::CellShapeTagGeneric
A special cell shape tag that holds a cell shape that is not known at compile time.
Definition: CellShape.h:178
viskores::exec::ConnectivityExplicit::GetNumberOfIndices
viskores::IdComponent GetNumberOfIndices(viskores::Id index) const
Given the index of a visited element, returns the number of incident elements touching it.
Definition: ConnectivityExplicit.h:80
viskores::exec::ConnectivityExplicit::ConnectivityExplicit
ConnectivityExplicit(const ShapesPortalType &shapesPortal, const ConnectivityPortalType &connPortal, const OffsetsPortalType &offsetsPortal)
Definition: ConnectivityExplicit.h:44
viskores::Id
viskores::Int64 Id
Base type to use to index arrays.
Definition: Types.h:235
viskores::exec::ConnectivityExplicit::ConnectivityExplicit
ConnectivityExplicit()
Definition: ConnectivityExplicit.h:42
viskores
Groups connected points that have the same field value.
Definition: Atomic.h:27
VecFromPortal.h
viskores::exec::ConnectivityExplicit::IndicesType
viskores::VecFromPortal< ConnectivityPortalType > IndicesType
Type of variable that lists of incident indices will be put into.
Definition: ConnectivityExplicit.h:87
viskores::exec::ConnectivityExplicit::GetIndices
IndicesType GetIndices(viskores::Id index) const
Provides the indices of all elements incident to the visit element of the provided index.
Definition: ConnectivityExplicit.h:97
viskores::exec::ConnectivityExplicit::GetNumberOfElements
SchedulingRangeType GetNumberOfElements() const
Provides the number of elements in the topology.
Definition: ConnectivityExplicit.h:59
viskores::exec::ConnectivityExplicit::GetCellShape
CellShapeTag GetCellShape(viskores::Id index) const
Returns a tagfor the cell shape associated with the element at the given index.
Definition: ConnectivityExplicit.h:72
VISKORES_EXEC
#define VISKORES_EXEC
Definition: ExportMacros.h:59
viskores::exec::ConnectivityExplicit::Shapes
ShapesPortalType Shapes
Definition: ConnectivityExplicit.h:107