VTK  9.4.20241108
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 IsInside, GetParametricCenterOfSide APIs.
31
32#include <vector> // for side connectivity
33
34VTK_ABI_NAMESPACE_BEGIN
35
37class vtkCellGrid;
38class vtkDataArray;
40class vtkTypeFloat32Array;
41class vtkTypeInt32Array;
42
43class VTKFILTERSCELLGRID_EXPORT vtkDGCell : public vtkCellMetadata
44{
45public:
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 {
80
81 None
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
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;
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
180
183 void ShallowCopy(vtkCellMetadata* other) override;
184 void DeepCopy(vtkCellMetadata* other) override;
186
192 virtual bool IsInside(const vtkVector3d& rst, double tolerance = 1e-6) = 0;
193
194 static int GetShapeCornerCount(Shape shape);
195 static int GetShapeDimension(Shape shape);
202
204 virtual Shape GetShape() const = 0;
205
207 virtual int GetDimension() const { return vtkDGCell::GetShapeDimension(this->GetShape()); }
208
210 virtual int GetNumberOfCorners() const
211 {
212 return vtkDGCell::GetShapeCornerCount(this->GetShape());
213 }
214
220 virtual const std::array<double, 3>& GetCornerParameter(int corner) const = 0;
221
231 virtual vtkVector3d GetParametricCenterOfSide(int sideId) const;
232
236 virtual int GetNumberOfSideTypes() const = 0;
237
260 virtual std::pair<int, int> GetSideRangeForType(int sideType) const = 0;
261
264
269 virtual std::pair<int, int> GetSideRangeForDimension(int dimension) const;
270
272 int* GetSideRangeForSideDimension(int sideDimension) VTK_SIZEHINT(2);
273
293 virtual int GetNumberOfSidesOfDimension(int dimension) const = 0;
294
301 virtual Shape GetSideShape(int side) const = 0;
302
307 virtual int GetSideTypeForShape(Shape s) const;
308
317 virtual const std::vector<vtkIdType>& GetSideConnectivity(int side) const = 0;
318
325 virtual const std::vector<vtkIdType>& GetSidesOfSide(int side) const = 0;
326
332 virtual vtkTypeFloat32Array* GetReferencePoints() const = 0;
333
341 virtual vtkTypeInt32Array* GetSideConnectivity() const = 0;
342
348 virtual vtkTypeInt32Array* GetSideOffsetsAndShapes() const = 0;
349
351 void FillReferencePoints(vtkTypeFloat32Array* arr) const;
352
354 void FillSideConnectivity(vtkTypeInt32Array* arr) const;
355
376 void FillSideOffsetsAndShapes(vtkTypeInt32Array* arr) const;
377
391 vtkCellAttribute* attribute, bool inheritedTypes = false);
392
395 vtkStringToken opName, const vtkCellAttribute::CellTypeInfo& attributeInfo);
396
399
400protected:
402 ~vtkDGCell() override;
403
409 std::vector<Source> SideSpecs;
410
411private:
412 vtkDGCell(const vtkDGCell&) = delete;
413 void operator=(const vtkDGCell&) = delete;
414};
415
416VTK_ABI_NAMESPACE_END
417#endif
RealT rst
Definition TetF2Basis.h:17
A function defined over the physical domain of a vtkCellGrid.
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 ...
Visualization data composed of cells of arbitrary type.
Definition vtkCellGrid.h:49
Metadata for a particular type of cell (finite element).
Base class for a discontinuous Galerkin cells of all shapes.
Definition vtkDGCell.h:44
void FillSideConnectivity(vtkTypeInt32Array *arr) const
Fill the passed array with the connectivity (point IDs) of all the element's sides.
virtual const std::array< double, 3 > & GetCornerParameter(int corner) const =0
Return the coordinates of the reference element's corner vertex.
~vtkDGCell() override
Shape
All possible shapes for DG cells.
Definition vtkDGCell.h:71
@ Hexahedron
An eight-cornered volume; a quadrilateral prism.
Definition vtkDGCell.h:77
@ Triangle
A three-cornered face bounded by 3 edges.
Definition vtkDGCell.h:74
@ Tetrahedron
A four-cornered volume bounded by 4 triangular shapes.
Definition vtkDGCell.h:76
@ Quadrilateral
A four-cornered face bounded by 4 edges.
Definition vtkDGCell.h:75
@ Wedge
A volumetric, triangular prism.
Definition vtkDGCell.h:78
@ Pyramid
A volumetric shape whose quadrilateral base attaches to a vertex.
Definition vtkDGCell.h:79
@ Edge
A curve connecting two vertices.
Definition vtkDGCell.h:73
@ Vertex
A corner point.
Definition vtkDGCell.h:72
std::vector< Source > SideSpecs
The connectivity array(s) specifying sides.
Definition vtkDGCell.h:409
static int GetShapeDimension(Shape shape)
virtual Shape GetSideShape(int side) const =0
For a given side, return its cell shape.
void DeepCopy(vtkCellMetadata *other) override
vtkDataArray * GetCellSourceConnectivity(int sideType=-1) const
Python-accessible methods to fetch cell source information.
static int GetShapeCornerCount(Shape shape)
void FillReferencePoints(vtkTypeFloat32Array *arr) const
Fill the passed array with the parametric coordinates of all the element's corners.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkIdType GetNumberOfCells() override
Return the number of cells (and sides) of this type present in this cell grid.
bool GetCellSourceIsBlanked(int sideType=-1) const
virtual Shape GetShape() const =0
Return the topological shape of this cell or side type.
std::size_t GetNumberOfCellSources() const
Python-accessible method to identify number of cell sources.
Definition vtkDGCell.h:165
const Source & GetCellSource(int sideType=-1) const
Provide access to cell specifications in a uniform way (for both cells and sides).
virtual const std::vector< vtkIdType > & GetSideConnectivity(int side) const =0
Return the connectivity of the given side.
virtual int GetSideTypeForShape(Shape s) const
Return the side type index for the given shape (or -1).
Source CellSpec
The connectivity array specifying cells.
Definition vtkDGCell.h:406
int * GetSideRangeForSideType(int sideType)
A python-wrapped version of GetSideRangeForType.
Source & GetCellSource(int sideType=-1)
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
virtual vtkTypeInt32Array * GetSideConnectivity() const =0
Return a singleton array initialized with point-ids of each side's corners.
void FillSideOffsetsAndShapes(vtkTypeInt32Array *arr) const
Fill the passed array with tuples of (1) offsets into the side-connectivity and (2) shapes for each t...
virtual vtkTypeFloat32Array * GetReferencePoints() const =0
Return a singleton array initialized with the reference-cell's corner point coordinates.
vtkIdType GetCellSourceOffset(int sideType=-1) const
virtual std::pair< int, int > GetSideRangeForType(int sideType) const =0
Return the range of sides of the ii-th type, where ii is in [-2, this->GetNumberOfSideTypes()[.
virtual int GetDimension() const
Return the parametric dimension of this cell type (0, 1, 2, or 3).
Definition vtkDGCell.h:207
virtual bool IsInside(const vtkVector3d &rst, double tolerance=1e-6)=0
Return true if the parametric coordinates (rst) lie inside the reference cell or its closure and fals...
vtkInheritanceHierarchyOverrideMacro(vtkDGCell)
virtual int GetNumberOfSideTypes() const =0
Return the number of different side shapes of this cell type.
vtkCellGridResponders::TagSet GetAttributeTags(vtkCellAttribute *attribute, bool inheritedTypes=false)
A convenience function to fetch attribute-calculator tags for an attribute.
std::vector< Source > & GetSideSpecs()
Provide access to the (cellId,sideId)-arrays used to define side-cells of this type.
Definition vtkDGCell.h:158
void ShallowCopy(vtkCellMetadata *other) override
virtual std::pair< int, int > GetSideRangeForDimension(int dimension) const
Return the range of side IDs for all sides of the given dimension.
virtual vtkTypeInt32Array * GetSideOffsetsAndShapes() const =0
Return a singleton array initialized with 2-tuples of (offset, shape) values.
Source & GetCellSpec()
Provide access to the connectivity array used to define cells of this type.
Definition vtkDGCell.h:155
int * GetSideRangeForSideDimension(int sideDimension)
A python-wrapped version of GetSideRangeForDimension.
vtkDGOperatorEntry GetOperatorEntry(vtkStringToken opName, const vtkCellAttribute::CellTypeInfo &attributeInfo)
Return an operator entry.
virtual vtkVector3d GetParametricCenterOfSide(int sideId) const
Return the parametric center of a cell or its side.
static OperatorMap & GetOperators()
Return a map of operators registered for vtkDGCell and its subclasses.
static vtkStringToken GetShapeName(Shape shape)
int GetCellSourceSelectionType(int sideType=-1) const
virtual int GetNumberOfSidesOfDimension(int dimension) const =0
Return the number of boundaries this type of cell has of a given dimension.
Shape GetCellSourceShape(int sideType=-1) const
vtkDataArray * GetCellSourceNodalGhostMarks(int sideType=-1) const
int GetCellSourceSideType(int sideType=-1) const
virtual int GetNumberOfCorners() const
Return the number of corner points for this cell type.
Definition vtkDGCell.h:210
virtual const std::vector< vtkIdType > & GetSidesOfSide(int side) const =0
Return a vector of side IDs given an input side ID.
static Shape GetShapeEnum(vtkStringToken shapeName)
Given a string description of a cell shape, return the DG equivalent enum.
A record for a basis in a function space that is specific to one cell shape.
abstract superclass for arrays of numeric data
represent and manipulate attribute data in a dataset
a simple class to control print indentation
Definition vtkIndent.h:108
Represent a string by its integer hash.
Records describing the source arrays for cells or cell-sides.
Definition vtkDGCell.h:90
virtual ~Source()=default
Override the destructor to de-reference Connectivity, NodalGhostMarks.
friend ostream & operator<<(ostream &os, const Source &source)
Definition vtkDGCell.h:100
Source(vtkDataArray *conn, vtkIdType off, bool blank, Shape shape, int sideType, int selnType, vtkDataArray *nodalGhostMarks)
Source & operator=(const Source &)=default
Source(const Source &)=default
Source(vtkDataArray *conn, vtkIdType off, bool blank, Shape shape, int sideType)
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
@ None
!< For HCURL
int vtkIdType
Definition vtkType.h:315
#define VTK_SIZEHINT(...)