VTK-m  2.2
ConnectivityStructuredInternals.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 
11 #ifndef vtk_m_internal_ConnectivityStructuredInternals_h
12 #define vtk_m_internal_ConnectivityStructuredInternals_h
13 
14 #include <vtkm/CellShape.h>
15 #include <vtkm/StaticAssert.h>
17 #include <vtkm/Types.h>
18 #include <vtkm/VecVariable.h>
19 
20 #include <vtkm/internal/Assume.h>
21 
22 namespace vtkm
23 {
24 namespace internal
25 {
26 
27 template <vtkm::IdComponent>
28 class ConnectivityStructuredInternals;
29 
30 //1 D specialization.
31 template <>
32 class ConnectivityStructuredInternals<1>
33 {
34 public:
35  using SchedulingRangeType = vtkm::Id;
36 
38  void SetPointDimensions(vtkm::Id dimensions) { this->PointDimensions = dimensions; }
39 
41  void SetGlobalPointDimensions(vtkm::Id dimensions) { this->GlobalPointDimensions = dimensions; }
42 
44  void SetGlobalPointIndexStart(vtkm::Id start) { this->GlobalPointIndexStart = start; }
45 
47  vtkm::Id GetPointDimensions() const { return this->PointDimensions; }
48 
50  vtkm::Id GetGlobalPointDimensions() const { return this->GlobalPointDimensions; }
51 
53  vtkm::Id GetCellDimensions() const { return this->PointDimensions - 1; }
54 
56  vtkm::Id GetGlobalCellDimensions() const { return this->GlobalPointDimensions - 1; }
57 
59  SchedulingRangeType GetSchedulingRange(vtkm::TopologyElementTagCell) const
60  {
61  return this->GetNumberOfCells();
62  }
63 
65  SchedulingRangeType GetSchedulingRange(vtkm::TopologyElementTagPoint) const
66  {
67  return this->GetNumberOfPoints();
68  }
69 
71  SchedulingRangeType GetGlobalPointIndexStart() const { return this->GlobalPointIndexStart; }
72 
73  static constexpr vtkm::IdComponent NUM_POINTS_IN_CELL = 2;
74  static constexpr vtkm::IdComponent MAX_CELL_TO_POINT = 2;
75 
77  vtkm::Id GetNumberOfPoints() const { return this->PointDimensions; }
79  vtkm::Id GetNumberOfCells() const { return this->PointDimensions - 1; }
81  vtkm::IdComponent GetNumberOfPointsInCell() const { return NUM_POINTS_IN_CELL; }
83  vtkm::IdComponent GetCellShape() const { return vtkm::CELL_SHAPE_LINE; }
84 
85  using CellShapeTag = vtkm::CellShapeTagLine;
86 
88  vtkm::Vec<vtkm::Id, NUM_POINTS_IN_CELL> GetPointsOfCell(vtkm::Id index) const
89  {
90  VTKM_ASSUME(index >= 0);
91 
93  pointIds[0] = index;
94  pointIds[1] = pointIds[0] + 1;
95  return pointIds;
96  }
97 
99  vtkm::IdComponent GetNumberOfCellsOnPoint(vtkm::Id pointIndex) const
100  {
101  VTKM_ASSUME(pointIndex >= 0);
102 
103  if ((pointIndex > 0) && (pointIndex < this->PointDimensions - 1))
104  {
105  return 2;
106  }
107  else
108  {
109  return 1;
110  }
111  }
112 
114  vtkm::VecVariable<vtkm::Id, MAX_CELL_TO_POINT> GetCellsOfPoint(vtkm::Id index) const
115  {
116  VTKM_ASSUME(index >= 0);
117  VTKM_ASSUME(this->PointDimensions > 1);
118 
120 
121  if (index > 0)
122  {
123  cellIds.Append(index - 1);
124  }
125  if (index < this->PointDimensions - 1)
126  {
127  cellIds.Append(index);
128  }
129 
130  return cellIds;
131  }
132 
133 
135  vtkm::Id FlatToLogicalPointIndex(vtkm::Id flatPointIndex) const { return flatPointIndex; }
136 
138  vtkm::Id LogicalToFlatPointIndex(vtkm::Id logicalPointIndex) const { return logicalPointIndex; }
139 
141  vtkm::Id FlatToLogicalCellIndex(vtkm::Id flatCellIndex) const { return flatCellIndex; }
142 
144  vtkm::Id LogicalToFlatCellIndex(vtkm::Id logicalCellIndex) const { return logicalCellIndex; }
145 
146  VTKM_CONT
147  void PrintSummary(std::ostream& out) const
148  {
149  out << " UniformConnectivity<1> ";
150  out << "PointDimensions[" << this->PointDimensions << "] ";
151  out << "GlobalPointDimensions[" << this->GlobalPointDimensions << "] ";
152  out << "GlobalPointIndexStart[" << this->GlobalPointIndexStart << "] ";
153  out << "\n";
154  }
155 
156 private:
157  vtkm::Id PointDimensions = 0;
158  vtkm::Id GlobalPointDimensions = 0;
159  vtkm::Id GlobalPointIndexStart = 0;
160 };
161 
162 //2 D specialization.
163 template <>
164 class ConnectivityStructuredInternals<2>
165 {
166 public:
167  using SchedulingRangeType = vtkm::Id2;
168 
170  void SetPointDimensions(vtkm::Id2 dims) { this->PointDimensions = dims; }
171 
173  void SetGlobalPointDimensions(vtkm::Id2 dims) { this->GlobalPointDimensions = dims; }
174 
176  void SetGlobalPointIndexStart(vtkm::Id2 start) { this->GlobalPointIndexStart = start; }
177 
179  const vtkm::Id2& GetPointDimensions() const { return this->PointDimensions; }
180 
182  const vtkm::Id2& GetGlobalPointDimensions() const { return this->GlobalPointDimensions; }
183 
185  vtkm::Id2 GetCellDimensions() const { return this->PointDimensions - vtkm::Id2(1); }
186 
188  vtkm::Id2 GetGlobalCellDimensions() const { return this->GlobalPointDimensions - vtkm::Id2(1); }
189 
191  vtkm::Id GetNumberOfPoints() const { return vtkm::ReduceProduct(this->GetPointDimensions()); }
192 
193  //returns an id2 to signal what kind of scheduling to use
195  vtkm::Id2 GetSchedulingRange(vtkm::TopologyElementTagCell) const
196  {
197  return this->GetCellDimensions();
198  }
200  vtkm::Id2 GetSchedulingRange(vtkm::TopologyElementTagPoint) const
201  {
202  return this->GetPointDimensions();
203  }
204 
206  const vtkm::Id2& GetGlobalPointIndexStart() const { return this->GlobalPointIndexStart; }
207 
208  static constexpr vtkm::IdComponent NUM_POINTS_IN_CELL = 4;
209  static constexpr vtkm::IdComponent MAX_CELL_TO_POINT = 4;
210 
212  vtkm::Id GetNumberOfCells() const { return vtkm::ReduceProduct(this->GetCellDimensions()); }
214  vtkm::IdComponent GetNumberOfPointsInCell() const { return NUM_POINTS_IN_CELL; }
216  vtkm::IdComponent GetCellShape() const { return vtkm::CELL_SHAPE_QUAD; }
217 
218  using CellShapeTag = vtkm::CellShapeTagQuad;
219 
222  const SchedulingRangeType& logicalCellIndex) const
223  {
225  pointIds[0] = this->LogicalToFlatPointIndex(logicalCellIndex);
226  pointIds[1] = pointIds[0] + 1;
227  pointIds[2] = pointIds[1] + this->PointDimensions[0];
228  pointIds[3] = pointIds[2] - 1;
229  return pointIds;
230  }
231 
233  vtkm::Vec<vtkm::Id, NUM_POINTS_IN_CELL> GetPointsOfCell(vtkm::Id cellIndex) const
234  {
235  return this->GetPointsOfCell(this->FlatToLogicalCellIndex(cellIndex));
236  }
237 
238  VTKM_EXEC_CONT vtkm::IdComponent GetNumberOfCellsOnPoint(const SchedulingRangeType& ij) const
239  {
240  vtkm::IdComponent numCells = 1;
241 
242  for (vtkm::IdComponent dim = 0; dim < 2; dim++)
243  {
244  if ((ij[dim] > 0) && (ij[dim] < this->PointDimensions[dim] - 1))
245  {
246  numCells *= 2;
247  }
248  }
249 
250  return numCells;
251  }
252 
254  vtkm::IdComponent GetNumberOfCellsOnPoint(vtkm::Id pointIndex) const
255  {
256  return this->GetNumberOfCellsOnPoint(this->FlatToLogicalPointIndex(pointIndex));
257  }
258 
261  const SchedulingRangeType& ij) const
262  {
264 
265  if ((ij[0] > 0) && (ij[1] > 0))
266  {
267  cellIds.Append(this->LogicalToFlatCellIndex(ij - vtkm::Id2(1, 1)));
268  }
269  if ((ij[0] < this->PointDimensions[0] - 1) && (ij[1] > 0))
270  {
271  cellIds.Append(this->LogicalToFlatCellIndex(ij - vtkm::Id2(0, 1)));
272  }
273  if ((ij[0] > 0) && (ij[1] < this->PointDimensions[1] - 1))
274  {
275  cellIds.Append(this->LogicalToFlatCellIndex(ij - vtkm::Id2(1, 0)));
276  }
277  if ((ij[0] < this->PointDimensions[0] - 1) && (ij[1] < this->PointDimensions[1] - 1))
278  {
279  cellIds.Append(this->LogicalToFlatCellIndex(ij));
280  }
281 
282  return cellIds;
283  }
284 
286  vtkm::VecVariable<vtkm::Id, MAX_CELL_TO_POINT> GetCellsOfPoint(vtkm::Id pointIndex) const
287  {
288  return this->GetCellsOfPoint(this->FlatToLogicalPointIndex(pointIndex));
289  }
290 
292  vtkm::Id2 FlatToLogicalPointIndex(vtkm::Id flatPointIndex) const
293  {
294  vtkm::Id2 logicalPointIndex;
295  logicalPointIndex[0] = flatPointIndex % this->PointDimensions[0];
296  logicalPointIndex[1] = flatPointIndex / this->PointDimensions[0];
297  return logicalPointIndex;
298  }
299 
301  vtkm::Id LogicalToFlatPointIndex(const vtkm::Id2& logicalPointIndex) const
302  {
303  return logicalPointIndex[0] + this->PointDimensions[0] * logicalPointIndex[1];
304  }
305 
307  vtkm::Id2 FlatToLogicalCellIndex(vtkm::Id flatCellIndex) const
308  {
309  vtkm::Id2 cellDimensions = this->GetCellDimensions();
310  vtkm::Id2 logicalCellIndex;
311  logicalCellIndex[0] = flatCellIndex % cellDimensions[0];
312  logicalCellIndex[1] = flatCellIndex / cellDimensions[0];
313  return logicalCellIndex;
314  }
315 
317  vtkm::Id LogicalToFlatCellIndex(const vtkm::Id2& logicalCellIndex) const
318  {
319  vtkm::Id2 cellDimensions = this->GetCellDimensions();
320  return logicalCellIndex[0] + cellDimensions[0] * logicalCellIndex[1];
321  }
322 
323  VTKM_CONT
324  void PrintSummary(std::ostream& out) const
325  {
326  out << " UniformConnectivity<2> ";
327  out << "PointDimensions[" << this->PointDimensions[0] << " " << this->PointDimensions[1]
328  << "] ";
329  out << "GlobalPointDimensions[" << this->GlobalPointDimensions[0] << " "
330  << this->GlobalPointDimensions[1] << "] ";
331  out << "GlobalPointIndexStart[" << this->GlobalPointIndexStart[0] << " "
332  << this->GlobalPointIndexStart[1] << "] ";
333  out << std::endl;
334  }
335 
336 private:
337  vtkm::Id2 PointDimensions = { 0, 0 };
338  vtkm::Id2 GlobalPointDimensions = { 0, 0 };
339  vtkm::Id2 GlobalPointIndexStart = { 0, 0 };
340 };
341 
342 //3 D specialization.
343 template <>
344 class ConnectivityStructuredInternals<3>
345 {
346 public:
347  using SchedulingRangeType = vtkm::Id3;
348 
350  void SetPointDimensions(vtkm::Id3 dims)
351  {
352  this->PointDimensions = dims;
353  this->CellDimensions = dims - vtkm::Id3(1);
354  this->CellDim01 = (dims[0] - 1) * (dims[1] - 1);
355  }
356 
358  void SetGlobalPointDimensions(vtkm::Id3 dims)
359  {
360  this->GlobalPointDimensions = dims;
361  this->GlobalCellDimensions = dims - vtkm::Id3(1);
362  }
363 
365  void SetGlobalPointIndexStart(vtkm::Id3 start) { this->GlobalPointIndexStart = start; }
366 
368  const vtkm::Id3& GetPointDimensions() const { return this->PointDimensions; }
369 
371  const vtkm::Id3& GetGlobalPointDimensions() const { return this->GlobalPointDimensions; }
372 
374  const vtkm::Id3& GetCellDimensions() const { return this->CellDimensions; }
375 
377  const vtkm::Id3& GetGlobalCellDimensions() const { return this->GlobalCellDimensions; }
378 
380  vtkm::Id GetNumberOfPoints() const { return vtkm::ReduceProduct(this->PointDimensions); }
381 
382  //returns an id3 to signal what kind of scheduling to use
384  const vtkm::Id3& GetSchedulingRange(vtkm::TopologyElementTagCell) const
385  {
386  return this->GetCellDimensions();
387  }
389  const vtkm::Id3& GetSchedulingRange(vtkm::TopologyElementTagPoint) const
390  {
391  return this->GetPointDimensions();
392  }
393 
395  const vtkm::Id3& GetGlobalPointIndexStart() const { return this->GlobalPointIndexStart; }
396 
397  static constexpr vtkm::IdComponent NUM_POINTS_IN_CELL = 8;
398  static constexpr vtkm::IdComponent MAX_CELL_TO_POINT = 8;
399 
401  vtkm::Id GetNumberOfCells() const { return vtkm::ReduceProduct(this->GetCellDimensions()); }
403  vtkm::IdComponent GetNumberOfPointsInCell() const { return NUM_POINTS_IN_CELL; }
405  vtkm::IdComponent GetCellShape() const { return vtkm::CELL_SHAPE_HEXAHEDRON; }
406 
407  using CellShapeTag = vtkm::CellShapeTagHexahedron;
408 
410  vtkm::Vec<vtkm::Id, NUM_POINTS_IN_CELL> GetPointsOfCell(const SchedulingRangeType& ijk) const
411  {
413  pointIds[0] = (ijk[2] * this->PointDimensions[1] + ijk[1]) * this->PointDimensions[0] + ijk[0];
414  pointIds[1] = pointIds[0] + 1;
415  pointIds[2] = pointIds[1] + this->PointDimensions[0];
416  pointIds[3] = pointIds[2] - 1;
417  pointIds[4] = pointIds[0] + this->PointDimensions[0] * this->PointDimensions[1];
418  pointIds[5] = pointIds[4] + 1;
419  pointIds[6] = pointIds[5] + this->PointDimensions[0];
420  pointIds[7] = pointIds[6] - 1;
421 
422  return pointIds;
423  }
424 
426  vtkm::Vec<vtkm::Id, NUM_POINTS_IN_CELL> GetPointsOfCell(vtkm::Id cellIndex) const
427  {
428  return this->GetPointsOfCell(this->FlatToLogicalCellIndex(cellIndex));
429  }
430 
431  VTKM_EXEC_CONT vtkm::IdComponent GetNumberOfCellsOnPoint(const SchedulingRangeType& ijk) const
432  {
433  vtkm::IdComponent numCells = 1;
434 
435  for (vtkm::IdComponent dim = 0; dim < 3; dim++)
436  {
437  if ((ijk[dim] > 0) && (ijk[dim] < this->PointDimensions[dim] - 1))
438  {
439  numCells *= 2;
440  }
441  }
442 
443  return numCells;
444  }
445 
447  vtkm::IdComponent GetNumberOfCellsOnPoint(vtkm::Id pointIndex) const
448  {
449  return this->GetNumberOfCellsOnPoint(this->FlatToLogicalPointIndex(pointIndex));
450  }
451 
454  const SchedulingRangeType& ijk) const
455  {
457 
458  if ((ijk[0] > 0) && (ijk[1] > 0) && (ijk[2] > 0))
459  {
460  cellIds.Append(this->LogicalToFlatCellIndex(ijk - vtkm::Id3(1, 1, 1)));
461  }
462  if ((ijk[0] < this->PointDimensions[0] - 1) && (ijk[1] > 0) && (ijk[2] > 0))
463  {
464  cellIds.Append(this->LogicalToFlatCellIndex(ijk - vtkm::Id3(0, 1, 1)));
465  }
466  if ((ijk[0] > 0) && (ijk[1] < this->PointDimensions[1] - 1) && (ijk[2] > 0))
467  {
468  cellIds.Append(this->LogicalToFlatCellIndex(ijk - vtkm::Id3(1, 0, 1)));
469  }
470  if ((ijk[0] < this->PointDimensions[0] - 1) && (ijk[1] < this->PointDimensions[1] - 1) &&
471  (ijk[2] > 0))
472  {
473  cellIds.Append(this->LogicalToFlatCellIndex(ijk - vtkm::Id3(0, 0, 1)));
474  }
475 
476  if ((ijk[0] > 0) && (ijk[1] > 0) && (ijk[2] < this->PointDimensions[2] - 1))
477  {
478  cellIds.Append(this->LogicalToFlatCellIndex(ijk - vtkm::Id3(1, 1, 0)));
479  }
480  if ((ijk[0] < this->PointDimensions[0] - 1) && (ijk[1] > 0) &&
481  (ijk[2] < this->PointDimensions[2] - 1))
482  {
483  cellIds.Append(this->LogicalToFlatCellIndex(ijk - vtkm::Id3(0, 1, 0)));
484  }
485  if ((ijk[0] > 0) && (ijk[1] < this->PointDimensions[1] - 1) &&
486  (ijk[2] < this->PointDimensions[2] - 1))
487  {
488  cellIds.Append(this->LogicalToFlatCellIndex(ijk - vtkm::Id3(1, 0, 0)));
489  }
490  if ((ijk[0] < this->PointDimensions[0] - 1) && (ijk[1] < this->PointDimensions[1] - 1) &&
491  (ijk[2] < this->PointDimensions[2] - 1))
492  {
493  cellIds.Append(this->LogicalToFlatCellIndex(ijk));
494  }
495 
496  return cellIds;
497  }
498 
500  vtkm::VecVariable<vtkm::Id, MAX_CELL_TO_POINT> GetCellsOfPoint(vtkm::Id pointIndex) const
501  {
502  return this->GetCellsOfPoint(this->FlatToLogicalPointIndex(pointIndex));
503  }
504 
505  VTKM_CONT
506  void PrintSummary(std::ostream& out) const
507  {
508  out << " UniformConnectivity<3> ";
509  out << "PointDimensions[" << this->PointDimensions[0] << " " << this->PointDimensions[1] << " "
510  << this->PointDimensions[2] << "] ";
511  out << "GlobalPointDimensions[" << this->GlobalPointDimensions[0] << " "
512  << this->GlobalPointDimensions[1] << " " << this->GlobalPointDimensions[2] << "] ";
513  out << "GlobalPointIndexStart[" << this->GlobalPointIndexStart[0] << " "
514  << this->GlobalPointIndexStart[1] << " " << this->GlobalPointIndexStart[2] << "] ";
515  out << std::endl;
516  }
517 
519  vtkm::Id3 FlatToLogicalPointIndex(vtkm::Id flatPointIndex) const
520  {
521  const vtkm::Id pointDims01 = this->PointDimensions[0] * this->PointDimensions[1];
522  const vtkm::Id indexij = flatPointIndex % pointDims01;
523 
524  return vtkm::Id3(indexij % this->PointDimensions[0],
525  indexij / this->PointDimensions[0],
526  flatPointIndex / pointDims01);
527  }
528 
530  vtkm::Id LogicalToFlatPointIndex(const vtkm::Id3& logicalPointIndex) const
531  {
532  return logicalPointIndex[0] +
533  this->PointDimensions[0] *
534  (logicalPointIndex[1] + this->PointDimensions[1] * logicalPointIndex[2]);
535  }
536 
538  vtkm::Id3 FlatToLogicalCellIndex(vtkm::Id flatCellIndex) const
539  {
540  const vtkm::Id indexij = flatCellIndex % this->CellDim01;
541  return vtkm::Id3(indexij % this->CellDimensions[0],
542  indexij / this->CellDimensions[0],
543  flatCellIndex / this->CellDim01);
544  }
545 
547  vtkm::Id LogicalToFlatCellIndex(const vtkm::Id3& logicalCellIndex) const
548  {
549  return logicalCellIndex[0] +
550  this->CellDimensions[0] *
551  (logicalCellIndex[1] + this->CellDimensions[1] * logicalCellIndex[2]);
552  }
553 
554 private:
555  vtkm::Id3 PointDimensions = { 0, 0, 0 };
556  vtkm::Id3 GlobalPointDimensions = { 0, 0, 0 };
557  vtkm::Id3 GlobalCellDimensions = { 0, 0, 0 };
558  vtkm::Id3 GlobalPointIndexStart = { 0, 0, 0 };
559  vtkm::Id3 CellDimensions = { 0, 0, 0 };
560  vtkm::Id CellDim01 = 0;
561 };
562 
563 // We may want to generalize this class depending on how ConnectivityExplicit
564 // eventually handles retrieving cell to point connectivity.
565 
566 template <typename VisitTopology, typename IncidentTopology, vtkm::IdComponent Dimension>
567 struct ConnectivityStructuredIndexHelper
568 {
569  // We want an unconditional failure if this unspecialized class ever gets
570  // instantiated, because it means someone missed a topology mapping type.
571  // We need to create a test which depends on the templated types so
572  // it doesn't get picked up without a concrete instantiation.
573  VTKM_STATIC_ASSERT_MSG(sizeof(VisitTopology) == static_cast<size_t>(-1),
574  "Missing Specialization for Topologies");
575 };
576 
577 template <vtkm::IdComponent Dimension>
578 struct ConnectivityStructuredIndexHelper<vtkm::TopologyElementTagCell,
580  Dimension>
581 {
582  using ConnectivityType = vtkm::internal::ConnectivityStructuredInternals<Dimension>;
583  using LogicalIndexType = typename ConnectivityType::SchedulingRangeType;
584 
585  using CellShapeTag = typename ConnectivityType::CellShapeTag;
586 
588 
589  VTKM_EXEC_CONT static vtkm::Id GetNumberOfElements(const ConnectivityType& connectivity)
590  {
591  return connectivity.GetNumberOfCells();
592  }
593 
594  template <typename IndexType>
595  VTKM_EXEC_CONT static vtkm::IdComponent GetNumberOfIndices(
596  const ConnectivityType& vtkmNotUsed(connectivity),
597  const IndexType& vtkmNotUsed(cellIndex))
598  {
599  return ConnectivityType::NUM_POINTS_IN_CELL;
600  }
601 
602  template <typename IndexType>
603  VTKM_EXEC_CONT static IndicesType GetIndices(const ConnectivityType& connectivity,
604  const IndexType& cellIndex)
605  {
606  return connectivity.GetPointsOfCell(cellIndex);
607  }
608 
610  static LogicalIndexType FlatToLogicalIncidentIndex(const ConnectivityType& connectivity,
611  vtkm::Id flatFromIndex)
612  {
613  return connectivity.FlatToLogicalPointIndex(flatFromIndex);
614  }
615 
617  static vtkm::Id LogicalToFlatIncidentIndex(const ConnectivityType& connectivity,
618  const LogicalIndexType& logicalFromIndex)
619  {
620  return connectivity.LogicalToFlatPointIndex(logicalFromIndex);
621  }
622 
624  static LogicalIndexType FlatToLogicalVisitIndex(const ConnectivityType& connectivity,
625  vtkm::Id flatToIndex)
626  {
627  return connectivity.FlatToLogicalCellIndex(flatToIndex);
628  }
629 
631  static vtkm::Id LogicalToFlatVisitIndex(const ConnectivityType& connectivity,
632  const LogicalIndexType& logicalToIndex)
633  {
634  return connectivity.LogicalToFlatCellIndex(logicalToIndex);
635  }
636 };
637 
638 template <vtkm::IdComponent Dimension>
639 struct ConnectivityStructuredIndexHelper<vtkm::TopologyElementTagPoint,
641  Dimension>
642 {
643  using ConnectivityType = vtkm::internal::ConnectivityStructuredInternals<Dimension>;
644  using LogicalIndexType = typename ConnectivityType::SchedulingRangeType;
645 
646  using CellShapeTag = vtkm::CellShapeTagVertex;
647 
649 
650  VTKM_EXEC_CONT static vtkm::Id GetNumberOfElements(const ConnectivityType& connectivity)
651  {
652  return connectivity.GetNumberOfPoints();
653  }
654 
655  template <typename IndexType>
656  VTKM_EXEC_CONT static vtkm::IdComponent GetNumberOfIndices(const ConnectivityType& connectivity,
657  const IndexType& pointIndex)
658  {
659  return connectivity.GetNumberOfCellsOnPoint(pointIndex);
660  }
661 
662  template <typename IndexType>
663  VTKM_EXEC_CONT static IndicesType GetIndices(const ConnectivityType& connectivity,
664  const IndexType& pointIndex)
665  {
666  return connectivity.GetCellsOfPoint(pointIndex);
667  }
668 
670  static LogicalIndexType FlatToLogicalIncidentIndex(const ConnectivityType& connectivity,
671  vtkm::Id flatFromIndex)
672  {
673  return connectivity.FlatToLogicalCellIndex(flatFromIndex);
674  }
675 
677  static vtkm::Id LogicalToFlatIncidentIndex(const ConnectivityType& connectivity,
678  const LogicalIndexType& logicalFromIndex)
679  {
680  return connectivity.LogicalToFlatCellIndex(logicalFromIndex);
681  }
682 
684  static LogicalIndexType FlatToLogicalVisitIndex(const ConnectivityType& connectivity,
685  vtkm::Id flatToIndex)
686  {
687  return connectivity.FlatToLogicalPointIndex(flatToIndex);
688  }
689 
691  static vtkm::Id LogicalToFlatVisitIndex(const ConnectivityType& connectivity,
692  const LogicalIndexType& logicalToIndex)
693  {
694  return connectivity.LogicalToFlatPointIndex(logicalToIndex);
695  }
696 };
697 }
698 } // namespace vtkm::internal
699 
700 #endif //vtk_m_internal_ConnectivityStructuredInternals_h
vtkm::CellShapeTagQuad
Definition: CellShape.h:156
vtkm::TopologyElementTagPoint
A tag used to identify the point elements in a topology.
Definition: TopologyElementTag.h:34
vtkm::filter::mesh_info::CellMetric::Dimension
@ Dimension
Compute for each cell a metric specifically designed for Sandia's Pronto code.
vtkm
Groups connected points that have the same field value.
Definition: Atomic.h:19
Types.h
VTKM_EXEC_CONT
#define VTKM_EXEC_CONT
Definition: ExportMacros.h:52
vtkm::IdComponent
vtkm::Int32 IdComponent
Base type to use to index small lists.
Definition: Types.h:194
vtkm::ReduceProduct
T ReduceProduct(const vtkm::Vec< T, Size > &a)
Definition: Types.h:1585
CellShape.h
vtkm::VecVariable::Append
void Append(ComponentType value)
Definition: VecVariable.h:80
Assume.h
vtkm::CellShapeTagVertex
Definition: CellShape.h:148
vtkm::VecVariable
A short variable-length array with maximum length.
Definition: VecVariable.h:30
VTKM_STATIC_ASSERT_MSG
#define VTKM_STATIC_ASSERT_MSG(condition, message)
Definition: StaticAssert.h:18
vtkm::CellShapeTagLine
Definition: CellShape.h:150
VTKM_CONT
#define VTKM_CONT
Definition: ExportMacros.h:57
vtkm::Id
vtkm::Int64 Id
Base type to use to index arrays.
Definition: Types.h:227
vtkm::CELL_SHAPE_HEXAHEDRON
@ CELL_SHAPE_HEXAHEDRON
A hexahedron.
Definition: CellShape.h:62
vtkm::CellShapeTagHexahedron
Definition: CellShape.h:159
vtkmNotUsed
#define vtkmNotUsed(parameter_name)
Simple macro to identify a parameter as unused.
Definition: ExportMacros.h:128
vtkm::Id3
vtkm::Vec< vtkm::Id, 3 > Id3
Id3 corresponds to a 3-dimensional index for 3d arrays.
Definition: Types.h:1044
vtkm::CELL_SHAPE_LINE
@ CELL_SHAPE_LINE
A line cell connecting two points.
Definition: CellShape.h:42
vtkm::Vec
A short fixed-length array.
Definition: Types.h:357
VecVariable.h
StaticAssert.h
vtkm::TopologyElementTagCell
A tag used to identify the cell elements in a topology.
Definition: TopologyElementTag.h:24
VTKM_ASSUME
#define VTKM_ASSUME(cond)
Definition: Assume.h:27
vtkm::Id2
vtkm::Vec< vtkm::Id, 2 > Id2
Id2 corresponds to a 2-dimensional index.
Definition: Types.h:926
TopologyElementTag.h
vtkm::CELL_SHAPE_QUAD
@ CELL_SHAPE_QUAD
A four-sided polygon.
Definition: CellShape.h:56