VTK-m  1.8
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 
113  template <typename DeviceAdapter, typename VisitTopology, typename IncidentTopology>
115  1.6,
116  "Replace ExecutionTypes<D, V, I>::ExecObjectType with ExecConnectivityType<V, I>.")
117  ExecutionTypes
118  {
120  };
121 
125  vtkm::cont::Token&) const;
126 
130  vtkm::cont::Token&) const;
131 
132  VTKM_DEPRECATED(1.6, "Provide a vtkm::cont::Token object when calling PrepareForInput.")
133  vtkm::exec::ConnectivityExtrude PrepareForInput(
134  vtkm::cont::DeviceAdapterId device,
135  vtkm::TopologyElementTagCell visitTopology,
136  vtkm::TopologyElementTagPoint incidentTopology) const
137  {
138  vtkm::cont::Token token;
139  return this->PrepareForInput(device, visitTopology, incidentTopology, token);
140  }
141 
142  VTKM_DEPRECATED(1.6, "Provide a vtkm::cont::Token object when calling PrepareForInput.")
143  vtkm::exec::ReverseConnectivityExtrude PrepareForInput(
144  vtkm::cont::DeviceAdapterId device,
145  vtkm::TopologyElementTagPoint visitTopology,
146  vtkm::TopologyElementTagCell incidentTopology) const
147  {
148  vtkm::cont::Token token;
149  return this->PrepareForInput(device, visitTopology, incidentTopology, token);
150  }
151 
152 private:
153  void BuildReverseConnectivity();
154 
156 
162 
168 };
169 
170 template <typename T>
173  const vtkm::cont::ArrayHandle<vtkm::Int32>& nextNode,
174  bool periodic = true)
175 {
176  return CellSetExtrude{
177  conn, coords.GetNumberOfPointsPerPlane(), coords.GetNumberOfPlanes(), nextNode, periodic
178  };
179 }
180 
181 template <typename T>
182 CellSetExtrude make_CellSetExtrude(const std::vector<vtkm::Int32>& conn,
184  const std::vector<vtkm::Int32>& nextNode,
185  bool periodic = true)
186 {
188  static_cast<vtkm::Int32>(coords.GetNumberOfPointsPerPlane()),
189  static_cast<vtkm::Int32>(coords.GetNumberOfPlanes()),
191  periodic };
192 }
193 
194 template <typename T>
195 CellSetExtrude make_CellSetExtrude(std::vector<vtkm::Int32>&& conn,
197  std::vector<vtkm::Int32>&& nextNode,
198  bool periodic = true)
199 {
200  return CellSetExtrude{ vtkm::cont::make_ArrayHandleMove(std::move(conn)),
201  static_cast<vtkm::Int32>(coords.GetNumberOfPointsPerPlane()),
202  static_cast<vtkm::Int32>(coords.GetNumberOfPlanes()),
203  vtkm::cont::make_ArrayHandleMove(std::move(nextNode)),
204  periodic };
205 }
206 }
207 } // vtkm::cont
208 
209 
210 //=============================================================================
211 // Specializations of serialization related classes
213 namespace vtkm
214 {
215 namespace cont
216 {
217 
218 template <>
219 struct SerializableTypeString<vtkm::cont::CellSetExtrude>
220 {
221  static VTKM_CONT const std::string& Get()
222  {
223  static std::string name = "CS_Extrude";
224  return name;
225  }
226 };
227 }
228 } // vtkm::cont
229 
230 namespace mangled_diy_namespace
231 {
232 
233 template <>
234 struct Serialization<vtkm::cont::CellSetExtrude>
235 {
236 private:
237  using Type = vtkm::cont::CellSetExtrude;
238 
239 public:
240  static VTKM_CONT void save(BinaryBuffer& bb, const Type& cs)
241  {
242  vtkmdiy::save(bb, cs.GetNumberOfPointsPerPlane());
243  vtkmdiy::save(bb, cs.GetNumberOfPlanes());
244  vtkmdiy::save(bb, cs.GetIsPeriodic());
245  vtkmdiy::save(bb, cs.GetConnectivityArray());
246  vtkmdiy::save(bb, cs.GetNextNodeArray());
247  }
248 
249  static VTKM_CONT void load(BinaryBuffer& bb, Type& cs)
250  {
251  vtkm::Int32 numberOfPointsPerPlane;
252  vtkm::Int32 numberOfPlanes;
253  bool isPeriodic;
256 
257  vtkmdiy::load(bb, numberOfPointsPerPlane);
258  vtkmdiy::load(bb, numberOfPlanes);
259  vtkmdiy::load(bb, isPeriodic);
260  vtkmdiy::load(bb, conn);
261  vtkmdiy::load(bb, nextNode);
262 
263  cs = Type{ conn, numberOfPointsPerPlane, numberOfPlanes, nextNode, isPeriodic };
264  }
265 };
266 
267 } // diy
269 
270 #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:207
vtkm::exec::ReverseConnectivityExtrude
Definition: ConnectivityExtrude.h:95
vtkm::cont::ArrayHandle< vtkm::Int32 >
ArrayHandle.h
vtkm::cont::VTKM_DEPRECATED
struct VTKM_DEPRECATED(1.6, "Use vtkm::ColorSpace.") ColorSpace
Definition: cont/ColorTable.h:36
vtkm
VTKM_NO_DEPRECATED_VIRTUAL.
Definition: Algorithms.h:18
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:308
vtkm::cont::CellSetExtrude::NumberOfPlanes
vtkm::Int32 NumberOfPlanes
Definition: CellSetExtrude.h:159
vtkm::cont::CellSetExtrude::RConnectivity
vtkm::cont::ArrayHandle< vtkm::Int32 > RConnectivity
Definition: CellSetExtrude.h:164
vtkm::cont::ArrayHandleXGCCoordinates::GetNumberOfPointsPerPlane
VTKM_CONT vtkm::Id GetNumberOfPointsPerPlane() const
Definition: ArrayHandleXGCCoordinates.h:328
Invoker.h
vtkm::cont::CellSetExtrude
Definition: CellSetExtrude.h:49
mangled_diy_namespace
Definition: Particle.h:251
vtkm::cont::CellSetExtrude::IsPeriodic
bool IsPeriodic
Definition: CellSetExtrude.h:155
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:166
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:165
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:238
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:163
vtkm::cont::CellSetExtrude::NumberOfCellsPerPlane
vtkm::Int32 NumberOfCellsPerPlane
Definition: CellSetExtrude.h:158
vtkm::cont::DeviceAdapterId
Definition: DeviceAdapterTag.h:52
vtkm::Vec< vtkm::Id, 2 >
vtkm::cont::ArrayHandleXGCCoordinates
Definition: ArrayHandleXGCCoordinates.h:276
vtkm::cont::CellSetExtrude::Connectivity
vtkm::cont::ArrayHandle< vtkm::Int32 > Connectivity
Definition: CellSetExtrude.h:160
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:171
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:167
vtkm::cont::CellSetExtrude::NumberOfPointsPerPlane
vtkm::Int32 NumberOfPointsPerPlane
Definition: CellSetExtrude.h:157
vtkm::cont::CellSetExtrude::NextNode
vtkm::cont::ArrayHandle< vtkm::Int32 > NextNode
Definition: CellSetExtrude.h:161
TopologyElementTag.h