24#ifndef _GEMA_CELL_GEOMETRY_H_
25#define _GEMA_CELL_GEOMETRY_H_
31#include <QAtomicPointer>
64 : _info(_infoRegistry[type]), _P(P), _Q(Q)
74 const char*
typeName()
const {
return _info->_name; }
86 int order()
const {
return _info->_order; }
92 int numNodes()
const {
return _info->_nnodes; }
120 bool isLine()
const {
return numFaces() == 0; }
126 bool isSolid()
const {
return numFaces() > 1; }
131 assert(edgeIndex >= 0 && edgeIndex < numEdges());
132 return _info->_edgeNodeInfo[edgeIndex]._edgeNodes.size();
143 assert(i >= 0 && i < numEdgeNodes(edgeIndex));
144 return _info->_edgeNodeInfo[edgeIndex]._edgeNodes[i];
152 assert(edgeIndex >= 0 && edgeIndex < numEdges());
153 return _info->_edgeNodeInfo[edgeIndex]._edgeNodes.first();
161 assert(edgeIndex >= 0 && edgeIndex < numEdges());
162 return _info->_edgeNodeInfo[edgeIndex]._edgeNodes.last();
168 assert(nodeIndex >= 0 && nodeIndex < numNodes());
169 assert(edgeIndex >= 0 && edgeIndex < numEdges());
170 return _info->_edgeNodeInfo[edgeIndex]._edgeNodes.indexOf(nodeIndex) >= 0;
179 assert(n1 >= 0 && n1 < numNodes() && n2 >= 0 && n2 < numNodes());
180 for(
int e = 0; e < numEdges(); e++)
182 int en1 = _info->_edgeNodeInfo[e]._edgeNodes.first();
183 int en2 = _info->_edgeNodeInfo[e]._edgeNodes.last();
184 if((n1 == en1 && n2 == en2) || (n1 == en2 && n2 == en1))
193 assert(faceIndex >= 0 && faceIndex < numFaces());
194 return _info->_faceEdgeInfo[faceIndex].size();
205 assert(i >= 0 && i < numFaceEdges(faceIndex));
206 return _info->_faceEdgeInfo[faceIndex][i];
215 assert(edgeIndex >= 0 && edgeIndex < numEdges());
216 return _info->_edgeFaceInfo[edgeIndex].size();
227 assert(i >= 0 && i < numEdgeFaces(edgeIndex));
228 return _info->_edgeFaceInfo[edgeIndex][i];
236 assert(faceIndex >= 0 && faceIndex < numFaces());
237 return _info->_faceNodeInfo[faceIndex]._nboundaryNodes;
243 assert(faceIndex >= 0 && faceIndex < numFaces());
244 return _info->_faceNodeInfo[faceIndex]._faceNodes.size();
257 assert(i >= 0 && i < numFaceNodes(faceIndex));
258 return _info->_faceNodeInfo[faceIndex]._faceNodes[i];
264 assert(nodeIndex >= 0 && nodeIndex < numNodes());
265 return _info->_nodeIncidenceInfo[nodeIndex].size();
276 assert(i >= 0 && i < numIncidenceNodes(nodeIndex));
277 return _info->_nodeIncidenceInfo[nodeIndex][i];
290 assert(i >= 0 && i < numVolumeInternalNodes());
291 return _info->_volumeNodeInfo[i];
306 int nedges = numFaceEdges(faceIndex);
307 assert(nedges == 3 || nedges == 4);
320 assert(edgeIndex >= 0 && edgeIndex < numEdges());
321 GmCellType barType = mesh ? _info->_edgeNodeInfo[edgeIndex]._meshEdgeType :
322 _info->_edgeNodeInfo[edgeIndex]._eqEdgeType;
326 (mesh ||
GmCellGeometry(barType).numNodes() == numEdgeNodes(edgeIndex))));
339 assert(faceIndex >= 0 && faceIndex < numFaces());
340 GmCellType faceType = mesh ? _info->_faceNodeInfo[faceIndex]._meshFaceType :
341 _info->_faceNodeInfo[faceIndex]._eqFaceType;
345 (mesh ||
GmCellGeometry(faceType).numNodes() == numFaceNodes(faceIndex))));
365 assert(i >= 0 && i <
GmCellGeometry(edgeElement(edgeIndex, mesh)).numNodes());
367 return firstEdgeNode(edgeIndex);
369 return lastEdgeNode(edgeIndex);
372 assert(i == 2 && (mesh || numEdgeNodes(edgeIndex) == 3));
373 return numEdgeNodes(edgeIndex) == 3 ? edgeNode(edgeIndex, 1) : -1;
395 assert(i >= 0 && i <
GmCellGeometry(faceElement(faceIndex, mesh)).numNodes());
396 return mesh ? _info->_faceNodeInfo[faceIndex]._meshTypeNodes[i] :
397 _info->_faceNodeInfo[faceIndex]._faceTypeNodes[i];
417 assert(i >= 0 && i < numInterfaceContactSides());
418 return _info->_interfaceInfo._contactSides[i];
432 assert(i >= 0 && i < numInterfaceApertureSides());
433 return _info->_interfaceInfo._apertureSides[i];
443 assert(faceIndex >= 0 && faceIndex < numFaces());
444 return _info->_interfaceInfo._contactEdges[faceIndex].size();
455 assert(faceIndex >= 0 && faceIndex < numFaces());
456 assert(i >= 0 && i < numInterfaceContactEdges(faceIndex));
457 return _info->_interfaceInfo._contactEdges[faceIndex][i];
467 assert(faceIndex >= 0 && faceIndex < numFaces());
468 return _info->_interfaceInfo._apertureEdges[faceIndex].size();
479 assert(faceIndex >= 0 && faceIndex < numFaces());
480 assert(i >= 0 && i < numInterfaceApertureEdges(faceIndex));
481 return _info->_interfaceInfo._apertureEdges[faceIndex][i];
488 static int strToFamilyType(
QString str);
491 static int strToFaceType(
QString str);
493 static int name2Type(
const QString name) {
502 nameToType[_infoRegistry[i]->_name] = i;
508 auto it = nameToType.
find(name);
509 if(it == nameToType.
end()) {
516 return _infoRegistry[t]->_name;
531 if(isSolid() || (isSurface() && !isInterface()))
533 return _info->dimension(X);
548 if(isLine() || (isSurface() && isInterface()) || (isSolid() && !isInterface()))
550 return _info->dimension(X);
563 if(!isSolid() || isInterface())
565 return _info->dimension(X);
575 if(isLine() || (isSurface() && isInterface()))
576 return _info->dimension(X);
577 else if(isSurface() || (isSolid() && isInterface()))
578 return std::sqrt(_info->dimension(X));
580 return std::pow(_info->dimension(X), 1.0/3.0);
630 return _info->_capabilities[capability];
638 int isValid(
const GmMatrix& X,
double tol)
const { checkX(X);
return _info->isValid(X, tol); }
645 double quality(
const GmMatrix& J,
double tol)
const {
return _info->quality(J, tol); }
664 return _infoRegistry[type];
685 assert((!_info->_hierarchical && _P == 0 && _Q == 0) || (_info->_hierarchical && _P > 0 && _Q > 0));
686 return _info->shapeInstance(_P, _Q);
704 assert((!_info->_hierarchical && _P == 0 && _Q == 0) || (_info->_hierarchical && _P > 0 && _Q > 0));
705 return _info->integrationRule(irType, rule1, rule2, rule3, _P, _Q);
725 assert((!_info->_hierarchical && _P == 0 && _Q == 0) || (_info->_hierarchical && _P > 0 && _Q > 0));
726 return _info->edgeIntegrationRule(irType, rule1, _P, _Q);
752 assert((!_info->_hierarchical && _P == 0 && _Q == 0) || (_info->_hierarchical && _P > 0 && _Q > 0));
753 return _info->faceIntegrationRule(faceType, irType, rule1, rule2, _P, _Q);
769 return edgeIntegrationRule(irType, rule1);
771 return faceIntegrationRule(faceType, irType, rule1, rule2);
777 inline void checkX(
const GmMatrix& X)
const { Q_UNUSED(X); assert(X.n_cols == numNodes() && X.n_rows == numCoord()); }
781 static void checkGeometryIEFCompatibility(
GmCellType type);
782 static void checkElementRegistry();
Border integration rule base classe.
Definition gmBorderIntegrationRule.h:38
A class used to return static metadata information about a cell geometry, along with some methods for...
Definition gmCellGeometry.h:55
GmCellFamilyType family() const
Returns the family to which this cell type belongs.
Definition gmCellGeometry.h:77
int edgeFromNodes(int n1, int n2) const
Returns the edge index of the edge starting with n1 and ending with n2 or vice-versa....
Definition gmCellGeometry.h:177
double characteristicLength(const GmMatrix &X) const
Returns the cell characteristic length, defined as the length for 1D and 2D interface elements,...
Definition gmCellGeometry.h:572
int numInterfaceApertureSides() const
Returns the number of sides (edges for 2D and faces for 3D) of an interface element that are NOT in c...
Definition gmCellGeometry.h:425
bool isLine() const
Is this element an 1D "line" ?
Definition gmCellGeometry.h:120
int lastEdgeNode(int edgeIndex) const
Returns the last node in the cell's edge numbered edgeIndex (edgeIndex from 0 to numEdges()-1) Equiva...
Definition gmCellGeometry.h:159
double characteristicDimension(const GmMatrix &X) const
Returns the cell characteristic dimension, defined as the length for 1D and 2D interface elements,...
Definition gmCellGeometry.h:587
int numEdges() const
Returns the number of edges of this cell type.
Definition gmCellGeometry.h:114
int faceElementNode(int faceIndex, int i, bool mesh=false) const
Returns the ith node belonging to the face faceIndex using the equivalent surface element (returned b...
Definition gmCellGeometry.h:392
static int _maxNumNodes
The maximum number of nodes among all registered cell types.
Definition gmCellGeometry.h:789
GmCellType edgeElement(int edgeIndex, bool mesh=false) const
Returns the type of the equivalent Bar element (with either 2D or 3D coordinates) for an elements edg...
Definition gmCellGeometry.h:318
int numIncidenceNodes(int nodeIndex) const
Returns the number of incident nodes into the cell's node numbered nodeIndex (nodeIndex from 0 to num...
Definition gmCellGeometry.h:262
int _Q
The P & Q parameters for hierarchical element types. 0 otherwise.
Definition gmCellGeometry.h:786
int numInterfaceContactSides() const
Returns the number of sides (edges for 2D and faces for 3D) of an interface element that are in conta...
Definition gmCellGeometry.h:410
static int maxNumNodes()
A static function that returns the maximum number of nodes among all known cell types.
Definition gmCellGeometry.h:485
static const GmCellGeometryInfo * geometryInfo(GmCellType type)
Returns the geometry info objct associated with type. NOT FOR GENERAL USE.
Definition gmCellGeometry.h:661
int order() const
Returns the cell interpolation order(1 = linear, 2 = quadratic, 3 = cubic, ...)
Definition gmCellGeometry.h:86
int faceNode(int faceIndex, int i) const
Returns the ith node belonging to the face faceIndex. Since boundary nodes are always returned first ...
Definition gmCellGeometry.h:255
void centroidCartesian(const GmMatrix &X, GmVector &coord) const
Fills the coord vector with the cartesian coordinates of the cell centroid, with nodes defined by the...
Definition gmCellGeometry.h:616
GmBorderIntegrationRule * edgeIntegrationRule(GmIntegrationRuleType irType, int rule1=-1) const
A factory function that returns a NEW border integration rule object suited for this kind of element....
Definition gmCellGeometry.h:723
GmBorderIntegrationRule * faceIntegrationRule(int faceType, GmIntegrationRuleType irType, int rule1=-1, int rule2=-1) const
A factory function that returns a NEW border integration rule object suited for this kind of element....
Definition gmCellGeometry.h:750
int numInterfaceApertureEdges(int faceIndex) const
Returns the number of aperture edges (edges NOT shared between the interface element with "normal" el...
Definition gmCellGeometry.h:465
int interfaceContactEdge(int faceIndex, int i) const
Returns the local to the face index of the i'th contact edge for the given face (a value between 0 an...
Definition gmCellGeometry.h:453
bool isInterface() const
Returns true if this is an interface element, false otherwise.
Definition gmCellGeometry.h:80
int numVolumeInternalNodes() const
Returns the number of internal nodes of this volume's cell type. Returns 0 for 1d/2d cells.
Definition gmCellGeometry.h:281
int interfaceApertureSide(int i) const
Returns the local element index of the i'th aperture side (edge or face). The parameter i should be i...
Definition gmCellGeometry.h:430
double length(const GmMatrix &X) const
Returns the length of a bar element with nodes defined by the X matrix (with node coordinates organiz...
Definition gmCellGeometry.h:528
int firstEdgeNode(int edgeIndex) const
Returns the first node in the cell's edge numbered edgeIndex (edgeIndex from 0 to numEdges()-1) Equiv...
Definition gmCellGeometry.h:150
GmShape * shapeInstance() const
Shape function factory. Returns a NEW instance of the shape function object for this type....
Definition gmCellGeometry.h:683
int numFaceTypes() const
Returns the number of face types for a 3D element (generally 1), 1 for 2D elements and 0 for 1D eleme...
Definition gmCellGeometry.h:301
int numExtraDofNodes() const
Returns the number of extra degrees of freedom (dof) nodes. This is usually 0, except for some kinds ...
Definition gmCellGeometry.h:108
GmBorderIntegrationRule * borderIntegrationRule(int faceType, GmIntegrationRuleType irType, int rule1=-1, int rule2=-1) const
Returns a NEW border integration rule object suited for this kind of element. Border rules are used t...
Definition gmCellGeometry.h:766
GmCellType linearElement() const
Returns the type of the equivalent linear element (for a Quad9, returns a Quad4, for example).
Definition gmCellGeometry.h:89
int numInterfaceContactEdges(int faceIndex) const
Returns the number of contact edges (edges shared between the interface element with "normal" element...
Definition gmCellGeometry.h:441
GmCellType faceElement(int faceIndex, bool mesh=false) const
Returns the type of the equivalent surface element (with 3D node coordinates) for a 3D element's face...
Definition gmCellGeometry.h:337
int interfaceContactSide(int i) const
Returns the local element index of the i'th contact side (edge or face). The parameter i should be in...
Definition gmCellGeometry.h:415
double area(const GmMatrix &X) const
Returns the area of a 2D element with nodes defined by the X matrix (with node coordinates organized ...
Definition gmCellGeometry.h:545
bool isSurface() const
Is this element an 2D "surface".
Definition gmCellGeometry.h:123
GmCellType type() const
Return the cell type associated to this object.
Definition gmCellGeometry.h:71
int numFaceNodes(int faceIndex) const
Returns the number of nodes in the cell's face numbered faceIndex (faceIndex from 0 to numFaces()-1)
Definition gmCellGeometry.h:241
int faceEdge(int faceIndex, int i) const
Returns the ith edge belonging to face faceIndex.
Definition gmCellGeometry.h:203
GmCellFaceType faceType(int faceIndex) const
Returns the face type for the cells face numbered faceIndex (faceIndex from 0 to numFaces()-1)
Definition gmCellGeometry.h:304
int numNodes() const
Returns the total number of nodes of this cell type.
Definition gmCellGeometry.h:92
int volumeInternalNode(int i) const
Returns the ith internal node belonging to the volume.
Definition gmCellGeometry.h:288
const GmCellGeometryInfo * _info
The pointer to the cell geometry info object storing the cell type metadata.
Definition gmCellGeometry.h:785
int numEdgeNodes(int edgeIndex) const
Returns the number of nodes in the cell's edge numbered edgeIndex (edgeIndex from 0 to numEdges()-1)
Definition gmCellGeometry.h:129
GmIntegrationRule * integrationRule(GmIntegrationRuleType irType, int rule1=-1, int rule2=-1, int rule3=-1) const
A factory function that returns a NEW integration rule object suited for this kind of element.
Definition gmCellGeometry.h:702
const char * typeName() const
Returns the type name.
Definition gmCellGeometry.h:74
int incidenceNode(int nodeIndex, int i) const
Returns the ith incidence node belonging to node nodeIndex.
Definition gmCellGeometry.h:274
int numFaceEdges(int faceIndex) const
Returns the number of edges in the cell's face numbered faceIndex (faceIndex from 0 to numFaces()-1)
Definition gmCellGeometry.h:191
bool localAxis(const GmMatrix &X, GmMatrix &R) const
Computes the cell local axis system, with R = [X, Y, Z] and X, Y and Z being the local axis unit vect...
Definition gmCellGeometry.h:598
double quality(const GmMatrix &J, double tol) const
Returns a normalized quality measure of the cell geometry, from 0 to 1, where 0.0 means very bad and ...
Definition gmCellGeometry.h:645
int edgeFace(int edgeIndex, int i) const
Returns the ith face incident to the edge edgeIndex.
Definition gmCellGeometry.h:225
bool contains(const GmMatrix &X, const GmVector &coord) const
Returns true if the cell contains the point specified by the given cartesian coordinates 'coord'....
Definition gmCellGeometry.h:652
int numFaces() const
Returns the number of faces of this cell type (0 for "bar" alike cells, 1 for surface cells)
Definition gmCellGeometry.h:117
GmCellGeometry(GmCellType type, int P=0, int Q=0)
Constructor. Receives the cell type for which geometry information will be returned....
Definition gmCellGeometry.h:63
bool isSolid() const
Is this element an 3D "solid"?
Definition gmCellGeometry.h:126
bool isHierarchical() const
Returns true if this is a hierarchical element, false otherwise.
Definition gmCellGeometry.h:83
GmCellType faceLinearElement(int faceIndex, bool mesh=false) const
Returns the equivalent linear element of the given element's face.
Definition gmCellGeometry.h:404
bool nodeOnEdge(int nodeIndex, int edgeIndex) const
Returns true if the given (local) node index belongs to the given edge definition.
Definition gmCellGeometry.h:166
int numFaceBoundaryNodes(int faceIndex) const
Returns the number of boundary nodes in the cell's face numbered faceIndex (faceIndex from 0 to numFa...
Definition gmCellGeometry.h:234
bool hasCapability(GmCellGeometryCapabilities capability) const
Returns true if this cell type implements the geometric related capability described by the given par...
Definition gmCellGeometry.h:627
int interfaceApertureEdge(int faceIndex, int i) const
Returns the local to the face index of the i'th aperture edge for the given face (a value between 0 a...
Definition gmCellGeometry.h:477
int numCoord() const
Returns the size of the cartesian coordinates for this cell type.
Definition gmCellGeometry.h:111
int edgeNode(int edgeIndex, int i) const
Returns the ith node belonging to edge edgeIndex.
Definition gmCellGeometry.h:141
int edgeElementNode(int edgeIndex, int i, bool mesh=false) const
Returns the ith node belonging to the edge edgeIndex using the equivalent bar element (returned by ed...
Definition gmCellGeometry.h:361
int isValid(const GmMatrix &X, double tol) const
Definition gmCellGeometry.h:638
double volume(const GmMatrix &X) const
Returns the volume of a 3D element with nodes defined by the X matrix (with node coordinates organize...
Definition gmCellGeometry.h:560
GmCellType edgeLinearElement(int edgeIndex, bool mesh=false) const
Returns the equivalent linear element of the given element's edge.
Definition gmCellGeometry.h:401
int numVertices() const
Returns the number of vertices of this cell type. This excludes center edge and face nodes - returns ...
Definition gmCellGeometry.h:103
int numEdgeFaces(int edgeIndex) const
Returns the number of faces incident to the cell's edge numbered edgeIndex (edgeIndex from 0 to numEd...
Definition gmCellGeometry.h:213
Definition gmCellGeometryInfo.h:202
Integration rule base classe.
Definition gmIntegrationRule.h:89
Shape function handling base classe.
Definition gmShape.h:38
Declaration of the GmCellGeometryInfo base class.
GmCellGeometryCapabilities
An enum storing the possible geometric capabilities for a cell geometry info type that can be queried...
Definition gmCellGeometryInfo.h:43
@ GM_CELL_GEOMETRY_CAPABILITY_COUNT
Not a capability type. Stores the number of capabilities in the enum.
Definition gmCellGeometryInfo.h:53
Declaration of the GmCellType enum.
GmCellType
Mesh Cell types. Don't change type orders or add types without reading comments below.
Definition gmCellType.h:31
@ GM_INV_CELL_TYPE
NOT a cell type. Defines a marker for an invalid cell type.
Definition gmCellType.h:78
@ GM_NUM_CELL_TYPES
NOT a cell type. Stores the number of available types.
Definition gmCellType.h:77
GmCellFamilyType
Mesh cell type families. Use to group all quad, tri, etc elements in a "family". Its start value is a...
Definition gmCellType.h:107
GmCellFaceType
The type of a 3D element's face.
Definition gmCellType.h:136
@ GM_QUAD_FACE
The element face is a quadrilateral.
Definition gmCellType.h:137
@ GM_TRI_FACE
The element face is a triangle.
Definition gmCellType.h:138
Declaration of useful configuration definitions for the Core library.
#define GMC_API_EXPORT
Macro for controlling if the class is being exported (GEMA_CORE_LIB defined) or imported (GEMA_CORE_L...
Definition gmCoreConfig.h:35
GmIntegrationRuleType
The type of desired integration rule (Gauss quadrature, Lobatto quadrature, etc)
Definition gmIntegrationRule.h:68
Declaration of the GmMatrix class.
arma::mat GmMatrix
The basic type for a GeMA matrix object. Currently based on an Armadillo matrix.
Definition gmMatrix.h:38
Declaration of the GmVector class.
arma::vec GmVector
The basic type for a GeMA vector object. Currently based on an Armadillo vector.
Definition gmVector.h:34
QHash::iterator find(const Key &key)
bool isEmpty() const const