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];
212 assert(edgeIndex >= 0 && edgeIndex < numEdges());
213 return _info->_edgeFaceInfo[edgeIndex].size();
224 assert(i >= 0 && i < numEdgeFaces(edgeIndex));
225 return _info->_edgeFaceInfo[edgeIndex][i];
233 assert(faceIndex >= 0 && faceIndex < numFaces());
234 return _info->_faceNodeInfo[faceIndex]._nboundaryNodes;
240 assert(faceIndex >= 0 && faceIndex < numFaces());
241 return _info->_faceNodeInfo[faceIndex]._faceNodes.size();
254 assert(i >= 0 && i < numFaceNodes(faceIndex));
255 return _info->_faceNodeInfo[faceIndex]._faceNodes[i];
261 assert(nodeIndex >= 0 && nodeIndex < numNodes());
262 return _info->_nodeIncidenceInfo[nodeIndex].size();
273 assert(i >= 0 && i < numIncidenceNodes(nodeIndex));
274 return _info->_nodeIncidenceInfo[nodeIndex][i];
287 assert(i >= 0 && i < numVolumeInternalNodes());
288 return _info->_volumeNodeInfo[i];
303 int nedges = numFaceEdges(faceIndex);
304 assert(nedges == 3 || nedges == 4);
314 assert(edgeIndex >= 0 && edgeIndex < numEdges());
315 GmCellType barType = _info->_edgeNodeInfo[edgeIndex]._eqEdgeType;
329 assert(faceIndex >= 0 && faceIndex < numFaces());
330 GmCellType faceType = _info->_faceNodeInfo[faceIndex]._eqFaceType;
351 assert(i >= 0 && i <
GmCellGeometry(edgeElement(edgeIndex)).numNodes());
352 static int bar3NodeTranslation[3] = { 0, 2, 1 };
353 if(numEdgeNodes(edgeIndex) == 2)
354 return edgeNode(edgeIndex, i);
356 return edgeNode(edgeIndex, bar3NodeTranslation[i]);
372 assert(i >= 0 && i <
GmCellGeometry(faceElement(faceIndex)).numNodes());
373 return _info->_faceNodeInfo[faceIndex]._faceTypeNodes[i];
386 static int strToFamilyType(
QString str);
389 static int strToFaceType(
QString str);
403 if(isSolid() || (isSurface() && !isInterface()))
405 return _info->dimension(X);
420 if(isLine() || (isSurface() && isInterface()) || (isSolid() && !isInterface()))
422 return _info->dimension(X);
435 if(!isSolid() || isInterface())
437 return _info->dimension(X);
447 if(isLine() || (isSurface() && isInterface()))
448 return _info->dimension(X);
449 else if(isSurface() || (isSolid() && isInterface()))
450 return std::sqrt(_info->dimension(X));
452 return std::pow(_info->dimension(X), 1.0/3.0);
491 return _info->_capabilities[capability];
499 bool isValid(
const GmMatrix& X,
double tol)
const { checkX(X);
return _info->isValid(X, tol); }
506 double quality(
const GmMatrix& J,
double tol)
const {
return _info->quality(J, tol); }
525 return _infoRegistry[type];
546 assert((!_info->_hierarchical && _P == 0 && _Q == 0) || (_info->_hierarchical && _P > 0 && _Q > 0));
547 return _info->shapeInstance(_P, _Q);
565 assert((!_info->_hierarchical && _P == 0 && _Q == 0) || (_info->_hierarchical && _P > 0 && _Q > 0));
566 return _info->integrationRule(irType, rule1, rule2, rule3, _P, _Q);
586 assert((!_info->_hierarchical && _P == 0 && _Q == 0) || (_info->_hierarchical && _P > 0 && _Q > 0));
587 return _info->edgeIntegrationRule(irType, rule1, _P, _Q);
613 assert((!_info->_hierarchical && _P == 0 && _Q == 0) || (_info->_hierarchical && _P > 0 && _Q > 0));
614 return _info->faceIntegrationRule(faceType, irType, rule1, rule2, _P, _Q);
630 return edgeIntegrationRule(irType, rule1);
632 return faceIntegrationRule(faceType, irType, rule1, rule2);
638 inline void checkX(
const GmMatrix& X)
const { Q_UNUSED(X); assert(X.n_cols == numNodes() && X.n_rows == numCoord()); }
642 static void checkGeometryIEFCompatibility(
GmCellType type);
643 static void checkElementRegistry();
GmIntegrationRuleType
The type of desired integration rule (Gauss quadrature, Lobatto quadrature, etc)
Definition: gmIntegrationRule.h:67
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
int faceEdge(int faceIndex, int i) const
Returns the ith edge belonging to face faceIndex.
Definition: gmCellGeometry.h:203
bool hasCapability(GmCellGeometryCapabilities capability) const
Returns true if this cell type implements the geometric related capability described by the given par...
Definition: gmCellGeometry.h:488
int numVolumeInternalNodes() const
Returns the number of internal nodes of this volume's cell type. Returns 0 for 1d/2d cells.
Definition: gmCellGeometry.h:278
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:477
bool isSurface() const
Is this element an 2D "surface".
Definition: gmCellGeometry.h:123
int _Q
The P & Q parameters for hierarchical element types. 0 otherwise.
Definition: gmCellGeometry.h:647
GmCellType edgeLinearElement(int edgeIndex) const
Returns the equivalent linear element of the given element's edge.
Definition: gmCellGeometry.h:377
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
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
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:298
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
GmCellFaceType
The type of a 3D element's face.
Definition: gmCellType.h:135
NOT a cell type. Stores the number of available types.
Definition: gmCellType.h:77
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:259
Declaration of usefull configuration definitions for the Core library.
GmShape * shapeInstance() const
Shape function factory. Returns a NEW instance of the shape function object for this type....
Definition: gmCellGeometry.h:544
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
Declaration of the GmCellType enum.
int incidenceNode(int nodeIndex, int i) const
Returns the ith incidence node belonging to node nodeIndex.
Definition: gmCellGeometry.h:271
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:611
static int maxNumNodes()
A static function that returns the maximum number of nodes among all known cell types.
Definition: gmCellGeometry.h:383
int edgeNode(int edgeIndex, int i) const
Returns the ith node belonging to edge edgeIndex.
Definition: gmCellGeometry.h:141
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:231
int order() const
Returns the cell interpolation order(1 = linear, 2 = quadratic, 3 = cubic, ...)
Definition: gmCellGeometry.h:86
Declaration of the GmMatrix class.
double characteristicDimension(const GmMatrix &X) const
Returns the cell characteristic dimension, defined as the length for 1D and 2D interface elements,...
Definition: gmCellGeometry.h:459
int numEdges() const
Returns the number of edges of this cell type.
Definition: gmCellGeometry.h:114
bool isInterface() const
Returns true if this is an interface element, false otherwise.
Definition: gmCellGeometry.h:80
GmCellType edgeElement(int edgeIndex) const
Returns the type of the equivalent Bar element (with either 2D or 3D coordinates) for an elements edg...
Definition: gmCellGeometry.h:312
Not a capability type. Stores the number of capabilities in the enum.
Definition: gmCellGeometryInfo.h:53
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:627
A class used to return static metadata information about a cell geometry, along with some methods for...
Definition: gmCellGeometry.h:54
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:506
bool isLine() const
Is this element an 1D "line" ?
Definition: gmCellGeometry.h:120
Integration rule base classe.
Definition: gmIntegrationRule.h:88
Shape function handling base classe.
Definition: gmShape.h:37
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:513
static const GmCellGeometryInfo * geometryInfo(GmCellType type)
Returns the geometry info objct associated with type. NOT FOR GENERAL USE.
Definition: gmCellGeometry.h:522
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
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:584
int numEdgeFaces(int edgeIndex) const
Returns the number of faces in the cell's edge numbered edgeIndex (edgeIndex from 0 to numEdges()-1)
Definition: gmCellGeometry.h:210
The element face is a quadrilateral.
Definition: gmCellType.h:137
GmCellGeometryCapabilities
An enum storing the possible geometric capabilities for a cell geometry info type that can be queried...
Definition: gmCellGeometryInfo.h:42
bool isHierarchical() const
Returns true if this is a hierarchical element, false otherwise.
Definition: gmCellGeometry.h:83
Border integration rule base classe.
Definition: gmBorderIntegrationRule.h:37
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:432
int edgeFace(int edgeIndex, int i) const
Returns the ith face belonging to edge edgeIndex.
Definition: gmCellGeometry.h:222
bool isSolid() const
Is this element an 3D "solid"?
Definition: gmCellGeometry.h:126
const char * typeName() const
Returns the type name.
Definition: gmCellGeometry.h:74
static int _maxNumNodes
The maximum number of nodes among all registered cell types.
Definition: gmCellGeometry.h:650
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
double characteristicLength(const GmMatrix &X) const
Returns the cell characteristic length, defined as the length for 1D and 2D interface elements,...
Definition: gmCellGeometry.h:444
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
GmCellFaceType faceType(int faceIndex) const
Returns the face type for the cells face numbered faceIndex (faceIndex from 0 to numFaces()-1)
Definition: gmCellGeometry.h:301
GmCellType faceLinearElement(int faceIndex) const
Returns the equivalent linear element of the given element's face.
Definition: gmCellGeometry.h:380
int numVertices() const
Returns the number of vertices of this cell type. This excludes center edge and face nodes - returns ...
Definition: gmCellGeometry.h:103
Declaration of the GmVector class.
#define GMC_API_EXPORT
Macro for controling if the class is being exported (GEMA_CORE_LIB defined) or imported (GEMA_CORE_LI...
Definition: gmCoreConfig.h:35
The element face is a triangle.
Definition: gmCellType.h:138
GmCellType
Mesh Cell types. Don't change type orders or add types without reading comments below.
Definition: gmCellType.h:30
int volumeInternalNode(int i) const
Returns the ith internal node belonging to the volume.
Definition: gmCellGeometry.h:285
GmCellType linearElement() const
Returns the type of the equivalent linear element (for a Quad9, returns a Quad4, for example).
Definition: gmCellGeometry.h:89
bool isValid(const GmMatrix &X, double tol) const
Definition: gmCellGeometry.h:499
GmCellFamilyType family() const
Returns the family to which this cell type belongs.
Definition: gmCellGeometry.h:77
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:238
int faceElementNode(int faceIndex, int i) const
Returns the ith node belonging to the face faceIndex using the equivalent surface element (returned b...
Definition: gmCellGeometry.h:369
Definition: gmCellGeometryInfo.h:153
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
GmCellType type() const
Return the cell type associated to this object.
Definition: gmCellGeometry.h:71
GmCellType faceElement(int faceIndex) const
Returns the type of the equivalent surface element (with 3D node coordinates) for a 3D element's face...
Definition: gmCellGeometry.h:327
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:400
NOT a cell type. Defines a marker for an invalid cell type.
Definition: gmCellType.h:78
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:252
Declaration of the GmCellGeometryInfo base class.
int numCoord() const
Returns the size of the cartesian coordinates for this cell type.
Definition: gmCellGeometry.h:111
arma::vec GmVector
The basic type for a GeMA vector object. Currently based on an Armadillo vector.
Definition: gmVector.h:34
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:563
arma::mat GmMatrix
The basic type for a GeMA matrix object. Currently based on an Armadillo matrix.
Definition: gmMatrix.h:38
const GmCellGeometryInfo * _info
The pointer to the cell geometry info object storing the cell type metadata.
Definition: gmCellGeometry.h:646
GmCellFamilyType
Mesh cell type families. Use to group all quad, tri, etc elements in a "family". Its start value is a...
Definition: gmCellType.h:106
int edgeElementNode(int edgeIndex, int i) const
Returns the ith node belonging to the edge edgeIndex using the equivalent linear element (returned by...
Definition: gmCellGeometry.h:348
int numNodes() const
Returns the total number of nodes of this cell type.
Definition: gmCellGeometry.h:92
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:417