VTK  9.7.1
vtkDGCell.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
19 #ifndef vtkDGCell_h
20 #define vtkDGCell_h
21 
22 #include "vtkFiltersCellGridModule.h" // For export macro.
23 
24 #include "vtkCellAttribute.h" // For CellTypeInfo.
25 #include "vtkCellGridResponders.h" // For vtkCellGridResponders::TagSet.
26 #include "vtkCellMetadata.h"
27 #include "vtkDGOperatorEntry.h" // For GetOperatorEntry API.
28 #include "vtkDataArray.h" // for vtkDataArray::PrintValues
29 #include "vtkStringToken.h" // For vtkStringToken::Hash.
30 #include "vtkVector.h" // For GetSignedParametricDistance, GetParametricCenterOfSide APIs.
31 
32 #include <vector> // for side connectivity
33 
34 VTK_ABI_NAMESPACE_BEGIN
35 
36 class vtkCellAttribute;
37 class vtkCellGrid;
38 class vtkDataArray;
40 class vtkTypeFloat32Array;
41 class vtkTypeInt32Array;
42 
43 class VTKFILTERSCELLGRID_EXPORT vtkDGCell : public vtkCellMetadata
44 {
45 public:
62  using OperatorMap = std::unordered_map<vtkStringToken, // operator name
63  std::unordered_map<vtkStringToken, // function space
64  std::unordered_map<vtkStringToken, // basis name
65  std::unordered_map<int, // order or -1
66  std::unordered_map<vtkStringToken, // cell type-name
68 
70  enum Shape : int
71  {
73  Edge,
80 
82  // It is probably more efficient to create a new cell type for arbitrary shapes
83  // than to attempt generalizing vtkDGCell, but for the sake of completeness:
84  // Polygon //!< We may one day support an n-sided polygonal face.
85  // Polyhedron //!< We may one day support an n-faced polyhedral volume with polygonal sides.
86  };
87 
89  struct Source
90  {
91  Source() = default;
92  Source(const Source&) = default;
93  Source(vtkDataArray* conn, vtkIdType off, bool blank, Shape shape, int sideType);
94  Source(vtkDataArray* conn, vtkIdType off, bool blank, Shape shape, int sideType, int selnType,
95  vtkDataArray* nodalGhostMarks);
96  Source& operator=(const Source&) = default;
98  virtual ~Source() = default;
99 
100  friend ostream& operator<<(ostream& os, const Source& source)
101  {
102  os << "vtkDGCell::Source(" << &source << ")\n";
103  source.Connectivity->PrintValues(os);
104  os << "Connectivity: " << source.Connectivity << '\n';
105  os << "NodalGhostMarks: " << source.NodalGhostMarks << '\n';
106  os << "Offset: " << source.Offset << '\n';
107  os << "Blanked: " << (source.Blanked ? "T\n" : "F\n");
108  os << "SourceShape: " << source.SourceShape << '\n';
109  os << "SideType: " << source.SideType << '\n';
110  os << "SelectionType: " << source.SelectionType << '\n';
111  return os;
112  }
113 
120  vtkDataArray* Connectivity{ nullptr };
121 
127  vtkDataArray* NodalGhostMarks{ nullptr };
128 
130  vtkIdType Offset{ 0 };
131 
133  bool Blanked{ false };
134 
136  Shape SourceShape{ Shape::None };
137 
140  int SideType{ -1 };
141 
147  int SelectionType{ -1 };
148  };
149 
150  vtkTypeMacro(vtkDGCell, vtkCellMetadata);
152  void PrintSelf(ostream& os, vtkIndent indent) override;
153 
155  Source& GetCellSpec() { return this->CellSpec; }
156 
158  std::vector<Source>& GetSideSpecs() { return this->SideSpecs; }
159 
161  const Source& GetCellSource(int sideType = -1) const;
162  Source& GetCellSource(int sideType = -1);
163 
165  std::size_t GetNumberOfCellSources() const { return this->SideSpecs.size(); }
166 
170  vtkDataArray* GetCellSourceConnectivity(int sideType = -1) const;
171  vtkDataArray* GetCellSourceNodalGhostMarks(int sideType = -1) const;
172  vtkIdType GetCellSourceOffset(int sideType = -1) const;
173  bool GetCellSourceIsBlanked(int sideType = -1) const;
174  Shape GetCellSourceShape(int sideType = -1) const;
175  int GetCellSourceSideType(int sideType = -1) const;
176  int GetCellSourceSelectionType(int sideType = -1) const;
177 
179  vtkIdType GetNumberOfCells() override;
180 
183  void ShallowCopy(vtkCellMetadata* other) override;
184  void DeepCopy(vtkCellMetadata* other) override;
186 
192  virtual double GetSignedParametricDistance(const vtkVector3d& rst) const = 0;
193 
195  bool IsInside(const vtkVector3d& rst, double tolerance = 1e-6) const
196  {
197  return this->GetSignedParametricDistance(rst) <= std::abs(tolerance);
198  }
199 
200  static int GetShapeCornerCount(Shape shape);
201  static int GetShapeDimension(Shape shape);
202  static vtkStringToken GetShapeName(Shape shape);
207  static Shape GetShapeEnum(vtkStringToken shapeName);
208 
210  virtual Shape GetShape() const = 0;
211 
213  virtual int GetDimension() const { return vtkDGCell::GetShapeDimension(this->GetShape()); }
214 
216  virtual int GetNumberOfCorners() const
217  {
219  }
220 
226  virtual const std::array<double, 3>& GetCornerParameter(int corner) const = 0;
227 
237  virtual vtkVector3d GetParametricCenterOfSide(int sideId) const;
238 
242  virtual int GetNumberOfSideTypes() const = 0;
243 
266  virtual std::pair<int, int> GetSideRangeForType(int sideType) const = 0;
267 
269  int* GetSideRangeForSideType(int sideType) VTK_SIZEHINT(2);
270 
275  virtual std::pair<int, int> GetSideRangeForDimension(int dimension) const;
276 
278  int* GetSideRangeForSideDimension(int sideDimension) VTK_SIZEHINT(2);
279 
299  virtual int GetNumberOfSidesOfDimension(int dimension) const = 0;
300 
307  virtual Shape GetSideShape(int side) const = 0;
308 
313  virtual int GetSideTypeForShape(Shape s) const;
314 
323  virtual const std::vector<vtkIdType>& GetSideConnectivity(int side) const = 0;
324 
331  virtual const std::vector<vtkIdType>& GetSidesOfSide(int side) const = 0;
332 
338  virtual vtkTypeFloat32Array* GetReferencePoints() const = 0;
339 
347  virtual vtkTypeInt32Array* GetSideConnectivity() const = 0;
348 
354  virtual vtkTypeInt32Array* GetSideOffsetsAndShapes() const = 0;
355 
357  void FillReferencePoints(vtkTypeFloat32Array* arr) const;
358 
360  void FillSideConnectivity(vtkTypeInt32Array* arr) const;
361 
382  void FillSideOffsetsAndShapes(vtkTypeInt32Array* arr) const;
383 
396  vtkCellGridResponders::TagSet GetAttributeTags(
397  vtkCellAttribute* attribute, bool inheritedTypes = false);
398 
400  vtkDGOperatorEntry GetOperatorEntry(
401  vtkStringToken opName, const vtkCellAttribute::CellTypeInfo& attributeInfo);
402 
404  static OperatorMap& GetOperators();
405 
406 protected:
407  vtkDGCell();
408  ~vtkDGCell() override;
409 
415  std::vector<Source> SideSpecs;
416 
417 private:
418  vtkDGCell(const vtkDGCell&) = delete;
419  void operator=(const vtkDGCell&) = delete;
420 };
421 
422 VTK_ABI_NAMESPACE_END
423 #endif
virtual int GetDimension() const
Return the parametric dimension of this cell type (0, 1, 2, or 3).
Definition: vtkDGCell.h:213
std::unordered_map< vtkStringToken, std::unordered_map< vtkStringToken, std::unordered_map< vtkStringToken, std::unordered_map< int, std::unordered_map< vtkStringToken, vtkDGOperatorEntry >>>>> OperatorMap
A map holding operators that evaluate DG cells.
Definition: vtkDGCell.h:67
std::vector< Source > SideSpecs
The connectivity array(s) specifying sides.
Definition: vtkDGCell.h:415
std::vector< Source > & GetSideSpecs()
Provide access to the (cellId,sideId)-arrays used to define side-cells of this type.
Definition: vtkDGCell.h:158
vtkDataArray * Connectivity
An array holding cell connectivity or (cell-id, side-id) tuples.
Definition: vtkDGCell.h:120
Metadata for a particular type of cell (finite element).
virtual vtkIdType GetNumberOfCells()
Return the number of cells of this type in the parent cell-grid object.
std::unordered_map< vtkStringToken, std::unordered_set< vtkStringToken >> TagSet
A map of tag names (such as the cell's type-name) to values of the tag accepted or provided for that ...
RealT rst
Definition: TetF2Basis.h:17
void PrintValues(ostream &os)
Print the array values to an ostream object.
int vtkIdType
Definition: vtkType.h:363
A volumetric shape whose quadrilateral base attaches to a vertex.
Definition: vtkDGCell.h:79
std::size_t GetNumberOfCellSources() const
Python-accessible method to identify number of cell sources.
Definition: vtkDGCell.h:165
A four-cornered volume bounded by 4 triangular shapes.
Definition: vtkDGCell.h:76
virtual void DeepCopy(vtkCellMetadata *other)
A volumetric, triangular prism.
Definition: vtkDGCell.h:78
Visualization data composed of cells of arbitrary type.
Definition: vtkCellGrid.h:48
a simple class to control print indentation
Definition: vtkIndent.h:28
A function defined over the physical domain of a vtkCellGrid.
!< For HCURL
Source CellSpec
The connectivity array specifying cells.
Definition: vtkDGCell.h:412
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:44
Base class for a discontinuous Galerkin cells of all shapes.
Definition: vtkDGCell.h:43
virtual int GetNumberOfCorners() const
Return the number of corner points for this cell type.
Definition: vtkDGCell.h:216
represent and manipulate attribute data in a dataset
Represent a string by its integer hash.
#define VTK_SIZEHINT(...)
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
Source & GetCellSpec()
Provide access to the connectivity array used to define cells of this type.
Definition: vtkDGCell.h:155
A three-cornered face bounded by 3 edges.
Definition: vtkDGCell.h:74
A corner point.
Definition: vtkDGCell.h:72
#define vtkInheritanceHierarchyOverrideMacro(thisClass)
Use these macros to add an "InheritanceHierarchy()" method to a VTK class.
Definition: vtkInherits.h:27
A record for a basis in a function space that is specific to one cell shape.
A four-cornered face bounded by 4 edges.
Definition: vtkDGCell.h:75
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
An eight-cornered volume; a quadrilateral prism.
Definition: vtkDGCell.h:77
bool IsInside(const vtkVector3d &rst, double tolerance=1e-6) const
Return true if rst lies inside the reference cell (within tolerance).
Definition: vtkDGCell.h:195
bool GetShape(Ioss::Region *region, const Ioss::GroupingEntity *group_entity, vtkCellAttribute::CellTypeInfo &cellShapeInfo, int timestep, vtkDGCell *meta, vtkCellGrid *grid=nullptr, vtkIOSSUtilities::Cache *cache=nullptr)
Fetch the nodal coordinates for group_entity and create the cell_grid's shape attribute.
friend ostream & operator<<(ostream &os, const Source &source)
Definition: vtkDGCell.h:100
virtual void ShallowCopy(vtkCellMetadata *other)
Copy other into this instance (which must be of the same type).
Records describing the source arrays for cells or cell-sides.
Definition: vtkDGCell.h:89
Shape
All possible shapes for DG cells.
Definition: vtkDGCell.h:70
static int GetShapeCornerCount(Shape shape)
A curve connecting two vertices.
Definition: vtkDGCell.h:73
static int GetShapeDimension(Shape shape)