ConnectivityStructured.h 3.37 KB
Newer Older
Dave Pugmire's avatar
Dave Pugmire committed
1 2 3 4
//============================================================================
//  Copyright (c) Kitware, Inc.
//  All rights reserved.
//  See LICENSE.txt for details.
5
//
Dave Pugmire's avatar
Dave Pugmire committed
6 7 8 9 10
//  This software is distributed WITHOUT ANY WARRANTY; without even
//  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
//  PURPOSE.  See the above copyright notice for more information.
//============================================================================

11 12
#ifndef vtk_m_exec_ConnectivityStructured_h
#define vtk_m_exec_ConnectivityStructured_h
13

14
#include <vtkm/TopologyElementTag.h>
15 16
#include <vtkm/Types.h>
#include <vtkm/internal/ConnectivityStructuredInternals.h>
17

18 19 20 21
namespace vtkm
{
namespace exec
{
Dave Pugmire's avatar
Dave Pugmire committed
22

23
template <typename FromTopology, typename ToTopology, vtkm::IdComponent Dimension>
24
class ConnectivityStructured
25
{
26 27 28
  VTKM_IS_TOPOLOGY_ELEMENT_TAG(FromTopology);
  VTKM_IS_TOPOLOGY_ELEMENT_TAG(ToTopology);

29
  using InternalsType = vtkm::internal::ConnectivityStructuredInternals<Dimension>;
30

31 32
  using Helper =
    vtkm::internal::ConnectivityStructuredIndexHelper<FromTopology, ToTopology, Dimension>;
33

34
public:
35
  using SchedulingRangeType = typename InternalsType::SchedulingRangeType;
36

37
  VTKM_EXEC_CONT
38 39
  ConnectivityStructured()
    : Internals()
40 41
  {
  }
42

43
  VTKM_EXEC_CONT
44 45
  ConnectivityStructured(const InternalsType& src)
    : Internals(src)
46 47
  {
  }
48

49
  VTKM_EXEC_CONT
50 51
  ConnectivityStructured(const ConnectivityStructured& src)
    : Internals(src.Internals)
52 53
  {
  }
54

55 56 57 58 59 60
  VTKM_EXEC_CONT
  ConnectivityStructured(const ConnectivityStructured<ToTopology, FromTopology, Dimension>& src)
    : Internals(src.Internals)
  {
  }

61 62 63
  VTKM_EXEC
  vtkm::Id GetNumberOfElements() const { return Helper::GetNumberOfElements(this->Internals); }

64
  using CellShapeTag = typename Helper::CellShapeTag;
65
  VTKM_EXEC
66
  CellShapeTag GetCellShape(vtkm::Id) const { return CellShapeTag(); }
67

68 69 70 71 72 73
  template <typename IndexType>
  VTKM_EXEC vtkm::IdComponent GetNumberOfIndices(const IndexType& index) const
  {
    return Helper::GetNumberOfIndices(this->Internals, index);
  }

74
  using IndicesType = typename Helper::IndicesType;
75

76 77
  template <typename IndexType>
  VTKM_EXEC IndicesType GetIndices(const IndexType& index) const
78
  {
79
    return Helper::GetIndices(this->Internals, index);
80
  }
81

82
  VTKM_EXEC_CONT
83
  SchedulingRangeType FlatToLogicalFromIndex(vtkm::Id flatFromIndex) const
84
  {
85
    return Helper::FlatToLogicalFromIndex(this->Internals, flatFromIndex);
86 87
  }

88
  VTKM_EXEC_CONT
89
  vtkm::Id LogicalToFlatFromIndex(const SchedulingRangeType& logicalFromIndex) const
90
  {
91
    return Helper::LogicalToFlatFromIndex(this->Internals, logicalFromIndex);
92 93
  }

94
  VTKM_EXEC_CONT
95
  SchedulingRangeType FlatToLogicalToIndex(vtkm::Id flatToIndex) const
96
  {
97
    return Helper::FlatToLogicalToIndex(this->Internals, flatToIndex);
98 99
  }

100
  VTKM_EXEC_CONT
101
  vtkm::Id LogicalToFlatToIndex(const SchedulingRangeType& logicalToIndex) const
102
  {
103
    return Helper::LogicalToFlatToIndex(this->Internals, logicalToIndex);
104 105
  }

106
  VTKM_EXEC_CONT
107
  vtkm::Vec<vtkm::Id, Dimension> GetPointDimensions() const
108 109 110
  {
    return this->Internals.GetPointDimensions();
  }
111

Sujin Philip's avatar
Sujin Philip committed
112 113 114 115 116 117
  VTKM_EXEC_CONT
  SchedulingRangeType GetGlobalPointIndexStart() const
  {
    return this->Internals.GetGlobalPointIndexStart();
  }

118 119
  friend class ConnectivityStructured<ToTopology, FromTopology, Dimension>;

120
private:
121
  InternalsType Internals;
122
};
123 124
}
} // namespace vtkm::exec
125

126
#endif //vtk_m_exec_ConnectivityStructured_h