VTK-m  2.0
CellSetExtrude.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 #ifndef vtk_m_cont_CellSetExtrude_h
11 #define vtk_m_cont_CellSetExtrude_h
12 
14 #include <vtkm/cont/ArrayHandle.h>
17 #include <vtkm/cont/CellSet.h>
18 #include <vtkm/cont/Invoker.h>
21 
22 namespace vtkm
23 {
24 namespace cont
25 {
26 
27 namespace detail
28 {
29 
30 template <typename VisitTopology, typename IncidentTopology>
31 struct CellSetExtrudeConnectivityChooser;
32 
33 template <>
34 struct CellSetExtrudeConnectivityChooser<vtkm::TopologyElementTagCell,
36 {
37  using ExecConnectivityType = vtkm::exec::ConnectivityExtrude;
38 };
39 
40 template <>
41 struct CellSetExtrudeConnectivityChooser<vtkm::TopologyElementTagPoint,
43 {
44  using ExecConnectivityType = vtkm::exec::ReverseConnectivityExtrude;
45 };
46 
47 } // namespace detail
48 
49 class VTKM_CONT_EXPORT CellSetExtrude : public CellSet
50 {
51 public:
53 
55  vtkm::Int32 numberOfPointsPerPlane,
56  vtkm::Int32 numberOfPlanes,
58  bool periodic);
59 
61  VTKM_CONT CellSetExtrude(CellSetExtrude&& src) noexcept;
62 
63  VTKM_CONT CellSetExtrude& operator=(const CellSetExtrude& src);
64  VTKM_CONT CellSetExtrude& operator=(CellSetExtrude&& src) noexcept;
65 
66  virtual ~CellSetExtrude() override;
67 
68  vtkm::Int32 GetNumberOfPlanes() const;
69 
70  vtkm::Id GetNumberOfCells() const override;
71 
72  vtkm::Id GetNumberOfPoints() const override;
73 
74  vtkm::Id GetNumberOfFaces() const override;
75 
76  vtkm::Id GetNumberOfEdges() const override;
77 
78  VTKM_CONT vtkm::Id2 GetSchedulingRange(vtkm::TopologyElementTagCell) const;
79 
80  VTKM_CONT vtkm::Id2 GetSchedulingRange(vtkm::TopologyElementTagPoint) const;
81 
82  vtkm::UInt8 GetCellShape(vtkm::Id id) const override;
83  vtkm::IdComponent GetNumberOfPointsInCell(vtkm::Id id) const override;
84  void GetCellPointIds(vtkm::Id id, vtkm::Id* ptids) const override;
85 
86  std::shared_ptr<CellSet> NewInstance() const override;
87  void DeepCopy(const CellSet* src) override;
88 
89  void PrintSummary(std::ostream& out) const override;
90  void ReleaseResourcesExecution() override;
91 
93  {
94  return this->Connectivity;
95  }
96 
97  vtkm::Int32 GetNumberOfPointsPerPlane() const { return this->NumberOfPointsPerPlane; }
98 
99  const vtkm::cont::ArrayHandle<vtkm::Int32>& GetNextNodeArray() const { return this->NextNode; }
100 
101  bool GetIsPeriodic() const { return this->IsPeriodic; }
102 
103  template <vtkm::IdComponent NumIndices>
104  VTKM_CONT void GetIndices(vtkm::Id index, vtkm::Vec<vtkm::Id, NumIndices>& ids) const;
105 
106  VTKM_CONT void GetIndices(vtkm::Id index, vtkm::cont::ArrayHandle<vtkm::Id>& ids) const;
107 
108  template <typename VisitTopology, typename IncidentTopology>
109  using ExecConnectivityType =
110  typename detail::CellSetExtrudeConnectivityChooser<VisitTopology,
111  IncidentTopology>::ExecConnectivityType;
112 
116  vtkm::cont::Token&) const;
117 
121  vtkm::cont::Token&) const;
122 
123 private:
124  void BuildReverseConnectivity();
125 
127 
133 
139 };
140 
141 template <typename T>
144  const vtkm::cont::ArrayHandle<vtkm::Int32>& nextNode,
145  bool periodic = true)
146 {
147  return CellSetExtrude{
148  conn, coords.GetNumberOfPointsPerPlane(), coords.GetNumberOfPlanes(), nextNode, periodic
149  };
150 }
151 
152 template <typename T>
153 CellSetExtrude make_CellSetExtrude(const std::vector<vtkm::Int32>& conn,
155  const std::vector<vtkm::Int32>& nextNode,
156  bool periodic = true)
157 {
159  static_cast<vtkm::Int32>(coords.GetNumberOfPointsPerPlane()),
160  static_cast<vtkm::Int32>(coords.GetNumberOfPlanes()),
162  periodic };
163 }
164 
165 template <typename T>
166 CellSetExtrude make_CellSetExtrude(std::vector<vtkm::Int32>&& conn,
168  std::vector<vtkm::Int32>&& nextNode,
169  bool periodic = true)
170 {
171  return CellSetExtrude{ vtkm::cont::make_ArrayHandleMove(std::move(conn)),
172  static_cast<vtkm::Int32>(coords.GetNumberOfPointsPerPlane()),
173  static_cast<vtkm::Int32>(coords.GetNumberOfPlanes()),
174  vtkm::cont::make_ArrayHandleMove(std::move(nextNode)),
175  periodic };
176 }
177 }
178 } // vtkm::cont
179 
180 
181 //=============================================================================
182 // Specializations of serialization related classes
184 namespace vtkm
185 {
186 namespace cont
187 {
188 
189 template <>
190 struct SerializableTypeString<vtkm::cont::CellSetExtrude>
191 {
192  static VTKM_CONT const std::string& Get()
193  {
194  static std::string name = "CS_Extrude";
195  return name;
196  }
197 };
198 }
199 } // vtkm::cont
200 
201 namespace mangled_diy_namespace
202 {
203 
204 template <>
205 struct Serialization<vtkm::cont::CellSetExtrude>
206 {
207 private:
208  using Type = vtkm::cont::CellSetExtrude;
209 
210 public:
211  static VTKM_CONT void save(BinaryBuffer& bb, const Type& cs)
212  {
213  vtkmdiy::save(bb, cs.GetNumberOfPointsPerPlane());
214  vtkmdiy::save(bb, cs.GetNumberOfPlanes());
215  vtkmdiy::save(bb, cs.GetIsPeriodic());
216  vtkmdiy::save(bb, cs.GetConnectivityArray());
217  vtkmdiy::save(bb, cs.GetNextNodeArray());
218  }
219 
220  static VTKM_CONT void load(BinaryBuffer& bb, Type& cs)
221  {
222  vtkm::Int32 numberOfPointsPerPlane;
223  vtkm::Int32 numberOfPlanes;
224  bool isPeriodic;
227 
228  vtkmdiy::load(bb, numberOfPointsPerPlane);
229  vtkmdiy::load(bb, numberOfPlanes);
230  vtkmdiy::load(bb, isPeriodic);
231  vtkmdiy::load(bb, conn);
232  vtkmdiy::load(bb, nextNode);
233 
234  cs = Type{ conn, numberOfPointsPerPlane, numberOfPlanes, nextNode, isPeriodic };
235  }
236 };
237 
238 } // diy
240 
241 #endif // vtk_m_cont_CellSetExtrude.h
vtkm::TopologyElementTagPoint
A tag used to identify the point elements in a topology.
Definition: TopologyElementTag.h:34
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::exec::ReverseConnectivityExtrude
Definition: ConnectivityExtrude.h:95
vtkm::cont::ArrayHandle< vtkm::Int32 >
ArrayHandle.h
vtkm
Groups connected points that have the same field value.
Definition: Atomic.h:19
ThreadIndicesExtrude.h
vtkm::Get
VTKM_SUPPRESS_EXEC_WARNINGS VTKM_EXEC_CONT auto Get(const vtkm::Tuple< Ts... > &tuple) -> decltype(tuple.template Get< Index >())
Retrieve the object from a vtkm::Tuple at the given index.
Definition: Tuple.h:83
vtkm::IdComponent
vtkm::Int32 IdComponent
Represents a component ID (index of component in a vector).
Definition: Types.h:168
vtkm::cont::ArrayHandleXGCCoordinates::GetNumberOfPlanes
VTKM_CONT vtkm::Id GetNumberOfPlanes() const
Definition: ArrayHandleXGCCoordinates.h:314
vtkm::cont::CellSetExtrude::NumberOfPlanes
vtkm::Int32 NumberOfPlanes
Definition: CellSetExtrude.h:130
vtkm::cont::CellSetExtrude::RConnectivity
vtkm::cont::ArrayHandle< vtkm::Int32 > RConnectivity
Definition: CellSetExtrude.h:135
vtkm::cont::ArrayHandleXGCCoordinates::GetNumberOfPointsPerPlane
VTKM_CONT vtkm::Id GetNumberOfPointsPerPlane() const
Definition: ArrayHandleXGCCoordinates.h:334
Invoker.h
vtkm::cont::CellSetExtrude
Definition: CellSetExtrude.h:49
mangled_diy_namespace
Definition: Particle.h:331
vtkm::cont::CellSetExtrude::IsPeriodic
bool IsPeriodic
Definition: CellSetExtrude.h:126
vtkm::Id
vtkm::Int32 Id
Represents an ID (index into arrays).
Definition: Types.h:191
vtkm::exec::arg::load
VTKM_SUPPRESS_EXEC_WARNINGS VTKM_EXEC T load(const U &u, vtkm::Id v)
Definition: FetchTagArrayDirectIn.h:36
ConnectivityExtrude.h
vtkm::cont::CellSetExtrude::RCounts
vtkm::cont::ArrayHandle< vtkm::Int32 > RCounts
Definition: CellSetExtrude.h:137
vtkm::cont::Token
A token to hold the scope of an ArrayHandle or other object.
Definition: Token.h:35
vtkm::cont::CellSetExtrude::ROffsets
vtkm::cont::ArrayHandle< vtkm::Int32 > ROffsets
Definition: CellSetExtrude.h:136
vtkm::cont::make_ArrayHandleMove
VTKM_CONT vtkm::cont::ArrayHandleBasic< T > make_ArrayHandleMove(T *&array, vtkm::Id numberOfValues, vtkm::cont::internal::BufferInfo::Deleter deleter=internal::SimpleArrayDeleter< T >, vtkm::cont::internal::BufferInfo::Reallocater reallocater=internal::SimpleArrayReallocater< T >)
A convenience function to move a user-allocated array into an ArrayHandle.
Definition: ArrayHandleBasic.h:241
vtkm::cont::CellSetExtrude::GetNextNodeArray
const vtkm::cont::ArrayHandle< vtkm::Int32 > & GetNextNodeArray() const
Definition: CellSetExtrude.h:99
vtkm::cont::CellSetExtrude::GetNumberOfPointsPerPlane
vtkm::Int32 GetNumberOfPointsPerPlane() const
Definition: CellSetExtrude.h:97
VTKM_CONT
#define VTKM_CONT
Definition: ExportMacros.h:57
CellSet.h
vtkm::cont::CellSetExtrude::GetIsPeriodic
bool GetIsPeriodic() const
Definition: CellSetExtrude.h:101
vtkm::cont::CellSet
Definition: CellSet.h:24
vtkm::exec::ConnectivityExtrude
Definition: ConnectivityExtrude.h:26
vtkm::UInt8
uint8_t UInt8
Definition: Types.h:157
vtkm::CopyFlag::On
@ On
vtkm::cont::CellSetExtrude::ReverseConnectivityBuilt
bool ReverseConnectivityBuilt
Definition: CellSetExtrude.h:134
vtkm::cont::CellSetExtrude::NumberOfCellsPerPlane
vtkm::Int32 NumberOfCellsPerPlane
Definition: CellSetExtrude.h:129
vtkm::cont::DeviceAdapterId
Definition: DeviceAdapterTag.h:52
vtkm::Vec< vtkm::Id, 2 >
vtkm::cont::ArrayHandleXGCCoordinates
Definition: ArrayHandleXGCCoordinates.h:282
vtkm::cont::CellSetExtrude::Connectivity
vtkm::cont::ArrayHandle< vtkm::Int32 > Connectivity
Definition: CellSetExtrude.h:131
ArrayHandleCounting.h
vtkm::Int32
int32_t Int32
Definition: Types.h:160
vtkm::cont::make_CellSetExtrude
CellSetExtrude make_CellSetExtrude(const vtkm::cont::ArrayHandle< vtkm::Int32 > &conn, const vtkm::cont::ArrayHandleXGCCoordinates< T > &coords, const vtkm::cont::ArrayHandle< vtkm::Int32 > &nextNode, bool periodic=true)
Definition: CellSetExtrude.h:142
vtkm::cont::CellSetExtrude::GetConnectivityArray
const vtkm::cont::ArrayHandle< vtkm::Int32 > & GetConnectivityArray() const
Definition: CellSetExtrude.h:92
vtkm::TopologyElementTagCell
A tag used to identify the cell elements in a topology.
Definition: TopologyElementTag.h:24
vtkm::cont::CellSetExtrude::ExecConnectivityType
typename detail::CellSetExtrudeConnectivityChooser< VisitTopology, IncidentTopology >::ExecConnectivityType ExecConnectivityType
Definition: CellSetExtrude.h:111
ArrayHandleXGCCoordinates.h
vtkm::cont::CellSetExtrude::PrevNode
vtkm::cont::ArrayHandle< vtkm::Int32 > PrevNode
Definition: CellSetExtrude.h:138
vtkm::cont::CellSetExtrude::NumberOfPointsPerPlane
vtkm::Int32 NumberOfPointsPerPlane
Definition: CellSetExtrude.h:128
vtkm::cont::CellSetExtrude::NextNode
vtkm::cont::ArrayHandle< vtkm::Int32 > NextNode
Definition: CellSetExtrude.h:132
TopologyElementTag.h