VTK-m  2.2
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 
57 {
58 public:
60 
62  vtkm::Int32 numberOfPointsPerPlane,
63  vtkm::Int32 numberOfPlanes,
65  bool periodic);
66 
68  VTKM_CONT CellSetExtrude(CellSetExtrude&& src) noexcept;
69 
70  VTKM_CONT CellSetExtrude& operator=(const CellSetExtrude& src);
71  VTKM_CONT CellSetExtrude& operator=(CellSetExtrude&& src) noexcept;
72 
73  ~CellSetExtrude() override;
74 
75  vtkm::Int32 GetNumberOfPlanes() const;
76 
77  vtkm::Id GetNumberOfCells() const override;
78 
79  vtkm::Id GetNumberOfPoints() const override;
80 
81  vtkm::Id GetNumberOfFaces() const override;
82 
83  vtkm::Id GetNumberOfEdges() const override;
84 
85  VTKM_CONT vtkm::Id2 GetSchedulingRange(vtkm::TopologyElementTagCell) const;
86 
87  VTKM_CONT vtkm::Id2 GetSchedulingRange(vtkm::TopologyElementTagPoint) const;
88 
89  vtkm::UInt8 GetCellShape(vtkm::Id id) const override;
90  vtkm::IdComponent GetNumberOfPointsInCell(vtkm::Id id) const override;
91  void GetCellPointIds(vtkm::Id id, vtkm::Id* ptids) const override;
92 
93  std::shared_ptr<CellSet> NewInstance() const override;
94  void DeepCopy(const CellSet* src) override;
95 
96  void PrintSummary(std::ostream& out) const override;
97  void ReleaseResourcesExecution() override;
98 
100  {
101  return this->Connectivity;
102  }
103 
104  vtkm::Int32 GetNumberOfPointsPerPlane() const { return this->NumberOfPointsPerPlane; }
105 
106  const vtkm::cont::ArrayHandle<vtkm::Int32>& GetNextNodeArray() const { return this->NextNode; }
107 
108  bool GetIsPeriodic() const { return this->IsPeriodic; }
109 
110  template <vtkm::IdComponent NumIndices>
111  VTKM_CONT void GetIndices(vtkm::Id index, vtkm::Vec<vtkm::Id, NumIndices>& ids) const;
112 
113  VTKM_CONT void GetIndices(vtkm::Id index, vtkm::cont::ArrayHandle<vtkm::Id>& ids) const;
114 
115  template <typename VisitTopology, typename IncidentTopology>
116  using ExecConnectivityType =
117  typename detail::CellSetExtrudeConnectivityChooser<VisitTopology,
118  IncidentTopology>::ExecConnectivityType;
119 
123  vtkm::cont::Token&) const;
124 
128  vtkm::cont::Token&) const;
129 
130 private:
131  void BuildReverseConnectivity();
132 
134 
140 
146 };
147 
148 template <typename T>
151  const vtkm::cont::ArrayHandle<vtkm::Int32>& nextNode,
152  bool periodic = true)
153 {
154  return CellSetExtrude{
155  conn, coords.GetNumberOfPointsPerPlane(), coords.GetNumberOfPlanes(), nextNode, periodic
156  };
157 }
158 
159 template <typename T>
160 CellSetExtrude make_CellSetExtrude(const std::vector<vtkm::Int32>& conn,
162  const std::vector<vtkm::Int32>& nextNode,
163  bool periodic = true)
164 {
166  static_cast<vtkm::Int32>(coords.GetNumberOfPointsPerPlane()),
167  static_cast<vtkm::Int32>(coords.GetNumberOfPlanes()),
169  periodic };
170 }
171 
172 template <typename T>
173 CellSetExtrude make_CellSetExtrude(std::vector<vtkm::Int32>&& conn,
175  std::vector<vtkm::Int32>&& nextNode,
176  bool periodic = true)
177 {
178  return CellSetExtrude{ vtkm::cont::make_ArrayHandleMove(std::move(conn)),
179  static_cast<vtkm::Int32>(coords.GetNumberOfPointsPerPlane()),
180  static_cast<vtkm::Int32>(coords.GetNumberOfPlanes()),
181  vtkm::cont::make_ArrayHandleMove(std::move(nextNode)),
182  periodic };
183 }
184 }
185 } // vtkm::cont
186 
187 
188 //=============================================================================
189 // Specializations of serialization related classes
191 namespace vtkm
192 {
193 namespace cont
194 {
195 
196 template <>
197 struct SerializableTypeString<vtkm::cont::CellSetExtrude>
198 {
199  static VTKM_CONT const std::string& Get()
200  {
201  static std::string name = "CS_Extrude";
202  return name;
203  }
204 };
205 }
206 } // vtkm::cont
207 
208 namespace mangled_diy_namespace
209 {
210 
211 template <>
212 struct Serialization<vtkm::cont::CellSetExtrude>
213 {
214 private:
215  using Type = vtkm::cont::CellSetExtrude;
216 
217 public:
218  static VTKM_CONT void save(BinaryBuffer& bb, const Type& cs)
219  {
220  vtkmdiy::save(bb, cs.GetNumberOfPointsPerPlane());
221  vtkmdiy::save(bb, cs.GetNumberOfPlanes());
222  vtkmdiy::save(bb, cs.GetIsPeriodic());
223  vtkmdiy::save(bb, cs.GetConnectivityArray());
224  vtkmdiy::save(bb, cs.GetNextNodeArray());
225  }
226 
227  static VTKM_CONT void load(BinaryBuffer& bb, Type& cs)
228  {
229  vtkm::Int32 numberOfPointsPerPlane;
230  vtkm::Int32 numberOfPlanes;
231  bool isPeriodic;
234 
235  vtkmdiy::load(bb, numberOfPointsPerPlane);
236  vtkmdiy::load(bb, numberOfPlanes);
237  vtkmdiy::load(bb, isPeriodic);
238  vtkmdiy::load(bb, conn);
239  vtkmdiy::load(bb, nextNode);
240 
241  cs = Type{ conn, numberOfPointsPerPlane, numberOfPlanes, nextNode, isPeriodic };
242  }
243 };
244 
245 } // diy
247 
248 #endif // vtk_m_cont_CellSetExtrude.h
vtkm::TopologyElementTagPoint
A tag used to identify the point elements in a topology.
Definition: TopologyElementTag.h:34
vtkm::exec::ReverseConnectivityExtrude
Definition: ConnectivityExtrude.h:95
vtkm::cont::ArrayHandle< vtkm::Int32 >
ArrayHandle.h
vtkm::exec::arg::load
T load(const U &u, vtkm::Id v)
Definition: FetchTagArrayDirectIn.h:36
vtkm
Groups connected points that have the same field value.
Definition: Atomic.h:19
vtkm::Get
auto Get(const vtkm::Tuple< Ts... > &tuple)
Retrieve the object from a vtkm::Tuple at the given index.
Definition: Tuple.h:81
ThreadIndicesExtrude.h
vtkm::IdComponent
vtkm::Int32 IdComponent
Base type to use to index small lists.
Definition: Types.h:194
vtkm::cont::CellSetExtrude::NumberOfPlanes
vtkm::Int32 NumberOfPlanes
Definition: CellSetExtrude.h:137
vtkm::cont::CellSetExtrude::RConnectivity
vtkm::cont::ArrayHandle< vtkm::Int32 > RConnectivity
Definition: CellSetExtrude.h:142
vtkm::cont::make_ArrayHandleMove
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:294
Invoker.h
vtkm::cont::ArrayHandleXGCCoordinates::GetNumberOfPointsPerPlane
vtkm::Id GetNumberOfPointsPerPlane() const
Definition: ArrayHandleXGCCoordinates.h:336
vtkm::cont::CellSetExtrude
Defines a 3-dimensional extruded mesh representation.
Definition: CellSetExtrude.h:56
mangled_diy_namespace
Definition: Particle.h:351
vtkm::cont::CellSetExtrude::IsPeriodic
bool IsPeriodic
Definition: CellSetExtrude.h:133
ConnectivityExtrude.h
vtkm::cont::CellSetExtrude::RCounts
vtkm::cont::ArrayHandle< vtkm::Int32 > RCounts
Definition: CellSetExtrude.h:144
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:143
vtkm::cont::CellSetExtrude::GetNextNodeArray
const vtkm::cont::ArrayHandle< vtkm::Int32 > & GetNextNodeArray() const
Definition: CellSetExtrude.h:106
vtkm::cont::ArrayHandleXGCCoordinates::GetNumberOfPlanes
vtkm::Id GetNumberOfPlanes() const
Definition: ArrayHandleXGCCoordinates.h:316
VTKM_CONT_EXPORT
#define VTKM_CONT_EXPORT
Definition: vtkm_cont_export.h:44
vtkm::cont::CellSetExtrude::GetNumberOfPointsPerPlane
vtkm::Int32 GetNumberOfPointsPerPlane() const
Definition: CellSetExtrude.h:104
VTKM_CONT
#define VTKM_CONT
Definition: ExportMacros.h:57
CellSet.h
vtkm::cont::CellSetExtrude::GetIsPeriodic
bool GetIsPeriodic() const
Definition: CellSetExtrude.h:108
vtkm::Id
vtkm::Int64 Id
Base type to use to index arrays.
Definition: Types.h:227
vtkm::cont::CellSet
Defines the topological structure of the data in a DataSet.
Definition: CellSet.h:28
vtkm::exec::ConnectivityExtrude
Definition: ConnectivityExtrude.h:26
vtkm::UInt8
uint8_t UInt8
Base type to use for 8-bit unsigned integer numbers.
Definition: Types.h:169
vtkm::CopyFlag::On
@ On
vtkm::cont::CellSetExtrude::ReverseConnectivityBuilt
bool ReverseConnectivityBuilt
Definition: CellSetExtrude.h:141
vtkm::cont::CellSetExtrude::NumberOfCellsPerPlane
vtkm::Int32 NumberOfCellsPerPlane
Definition: CellSetExtrude.h:136
vtkm::cont::DeviceAdapterId
An object used to specify a device.
Definition: DeviceAdapterTag.h:58
vtkm::Vec< vtkm::Id, 2 >
vtkm::cont::ArrayHandleXGCCoordinates
Definition: ArrayHandleXGCCoordinates.h:288
vtkm::cont::CellSetExtrude::Connectivity
vtkm::cont::ArrayHandle< vtkm::Int32 > Connectivity
Definition: CellSetExtrude.h:138
ArrayHandleCounting.h
vtkm::Int32
int32_t Int32
Base type to use for 32-bit signed integer numbers.
Definition: Types.h:181
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:149
vtkm::cont::CellSetExtrude::GetConnectivityArray
const vtkm::cont::ArrayHandle< vtkm::Int32 > & GetConnectivityArray() const
Definition: CellSetExtrude.h:99
vtkm::TopologyElementTagCell
A tag used to identify the cell elements in a topology.
Definition: TopologyElementTag.h:24
vtkm::cont::make_ArrayHandle
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:270
vtkm::cont::CellSetExtrude::ExecConnectivityType
typename detail::CellSetExtrudeConnectivityChooser< VisitTopology, IncidentTopology >::ExecConnectivityType ExecConnectivityType
Definition: CellSetExtrude.h:118
ArrayHandleXGCCoordinates.h
vtkm::cont::CellSetExtrude::PrevNode
vtkm::cont::ArrayHandle< vtkm::Int32 > PrevNode
Definition: CellSetExtrude.h:145
vtkm::cont::CellSetExtrude::NumberOfPointsPerPlane
vtkm::Int32 NumberOfPointsPerPlane
Definition: CellSetExtrude.h:135
vtkm::cont::CellSetExtrude::NextNode
vtkm::cont::ArrayHandle< vtkm::Int32 > NextNode
Definition: CellSetExtrude.h:139
TopologyElementTag.h