VTK  9.6.20260703
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
18
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
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
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
121
128
131
133 bool Blanked{ false };
134
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 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);
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
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
397 vtkCellAttribute* attribute, bool inheritedTypes = false);
398
401 vtkStringToken opName, const vtkCellAttribute::CellTypeInfo& attributeInfo);
402
405
406protected:
408 ~vtkDGCell() override;
409
415 std::vector<Source> SideSpecs;
416
417private:
418 vtkDGCell(const vtkDGCell&) = delete;
419 void operator=(const vtkDGCell&) = delete;
420};
421
422VTK_ABI_NAMESPACE_END
423#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
vtkCellMetadata()=default
void FillSideConnectivity(vtkTypeInt32Array *arr) const
Fill the passed array with the connectivity (point IDs) of all the element's sides.
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
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
@ None
A placeholder for an indeterminate or invalid shape.
Definition vtkDGCell.h:81
@ 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:415
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:412
int * GetSideRangeForSideType(int sideType)
A python-wrapped version of GetSideRangeForType.
Source & GetCellSource(int sideType=-1)
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()[.
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:62
virtual int GetDimension() const
Return the parametric dimension of this cell type (0, 1, 2, or 3).
Definition vtkDGCell.h:213
vtkInheritanceHierarchyOverrideMacro(vtkDGCell)
virtual double GetSignedParametricDistance(const vtkVector3d &rst) const =0
Return the signed parametric distance of rst from the reference element boundary.
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:216
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.
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
vtkDataArray * Connectivity
An array holding cell connectivity or (cell-id, side-id) tuples.
Definition vtkDGCell.h:120
vtkDataArray * NodalGhostMarks
An array holding per-point "ghost" information (or null).
Definition vtkDGCell.h:127
virtual ~Source()=default
Override the destructor to de-reference Connectivity, NodalGhostMarks.
friend ostream & operator<<(ostream &os, const Source &source)
Definition vtkDGCell.h:100
vtkIdType Offset
Offset (start ID; used for picking) of the first cell or side in Connectivity.
Definition vtkDGCell.h:130
int SideType
The type of the side (for calling GetSideRangeForType).
Definition vtkDGCell.h:140
Shape SourceShape
The shape of this type of cell/side.
Definition vtkDGCell.h:136
Source(vtkDataArray *conn, vtkIdType off, bool blank, Shape shape, int sideType, int selnType, vtkDataArray *nodalGhostMarks)
Source & operator=(const Source &)=default
int SelectionType
If SideType >= 0, this determines what should be selected.
Definition vtkDGCell.h:147
bool Blanked
True when the cells/sides should be omitted from processing.
Definition vtkDGCell.h:133
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 *)
#define vtkDataArray
int vtkIdType
Definition vtkType.h:363
#define VTK_SIZEHINT(...)