GemaCoreLib
The GeMA Core library
Loading...
Searching...
No Matches
gmCellGeometryInfo.h
Go to the documentation of this file.
1/************************************************************************
2**
3** Copyright (C) 2014 by Carlos Augusto Teixera Mendes
4** All rights reserved.
5**
6** This file is part of the "GeMA" software. It's use should respect
7** the terms in the license agreement that can be found together
8** with this source code.
9** It is provided AS IS, with NO WARRANTY OF ANY KIND,
10** INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR
11** A PARTICULAR PURPOSE.
12**
13************************************************************************/
14
24#ifndef _GEMA_CELL_GEOMETRY_INFO_H_
25#define _GEMA_CELL_GEOMETRY_INFO_H_
26
27#include "gmCoreConfig.h"
28#include "gmCellType.h"
29#include "gmIntegrationRule.h"
30#include "gmMatrix.h"
31#include "gmVector.h"
32
33#include <QAtomicPointer>
34#include <QMutex>
35
36class GmShape;
38
43{
44 // IMPORTANT: DO NOT CHANGE THE ORDER OF THE ENUM BELOW without changing the order
45 // used to fill the GmCellGeometryMetadata._capabilities vector for
46 // EVERY GmCellGeometryInfo derived class!!!!
47 // Also, when ADDING entries, rember to fill the said vector in EVERY derived class.
51 // ----------------------------
52 // No adding after this line
54};
55
56enum GmCellGeometryValidity
57{
58 GM_GEOMETRY_STATE_VALID = 0b000000, //Valid geometry
59 GM_GEOMETRY_STATE_NON_PLANAR = 0b000001, //Invalid geometry with non-planar faces
60 GM_GEOMETRY_STATE_BAD_ORIENTATION = 0b000010, //Invalid geometry with bad orientation/negative volume
61 GM_GEOMETRY_STATE_BAD_EDGE = 0b000100, //Invalid geometry with invalid quadratic edge
62 GM_GEOMETRY_STATE_BAD_FACE_CENTER = 0b001000, //Invalid geometry with invalid quadratic face center
63 GM_GEOMETRY_STATE_SELF_INTERSECT = 0b010000, //Invalid geometry, self-intersection
64 GM_GEOMETRY_STATE_INVALID_NODES = 0b100000, //Invalid geometry, repeated/out of range nodes
65};
66
69{
89
130
141
143 const char* _name;
147 int _order;
156
157 // A vector storing true or false to specifiy if a cell type has the capabilities listed in GmCellGeometryCapabilities
158 bool _capabilities[GM_CELL_GEOMETRY_CAPABILITY_COUNT];
159
162
165
168
171
174
177
180
183
186};
187
188
189/* \brief An interface that links a cell geometric metadata with the associated
190 shape function and integration rules through factory methods that can
191 create those associated objects. It also implements the geometric routines
192 specifica for a type (like length and area calculation routines).
193
194 This interface should be instanced only by way of derived classes that make the
195 concrete link with the shape function / integration rules.
196
197 If in the future we need to support an hypotetic cell type that has no associated
198 shape function or integration rule (a cell type that is not an element type), a
199 derived class that returns NULL for all factory methods can be implemented.
200*/
202{
203public:
206
209
215 virtual GmShape* shapeInstance(int P, int Q) const = 0;
216
234 virtual GmIntegrationRule* integrationRule(GmIntegrationRuleType irType, int rule1, int rule2, int rule3, int P, int Q) const = 0;
235
255 virtual GmBorderIntegrationRule* edgeIntegrationRule(GmIntegrationRuleType irType, int rule1, int P, int Q) const = 0;
256
282 virtual GmBorderIntegrationRule* faceIntegrationRule(int faceType, GmIntegrationRuleType irType, int rule1, int rule2, int P, int Q) const = 0;
283
284
291 virtual double dimension(const GmMatrix& X) const = 0;
292
302 virtual bool localAxis(const GmMatrix& X, GmMatrix& R) const = 0;
303
308 virtual void centroidCartesian(const GmMatrix& X, GmVector& coord) const = 0;
309
310 //
311 // Capability related methods. Must be implmented on every derived classes that
312 // do implement the capability and should be IN SYNC with the information
313 // stored in the associeted GmCellGeometryMetadata _capabilities field.
314 //------------------------------------------------------------------------------------
315
323 virtual int isValid(const GmMatrix& X, double tol) const { Q_UNUSED(tol); Q_UNUSED(X); return GM_GEOMETRY_STATE_VALID; }
324
332 virtual double quality(const GmMatrix& J, double tol) const {
333 assert(tol > 0);
334 if (arma::det(J) > tol) {
335 GmMatrix U, V;
336 GmVector s;
337 arma::svd_econ(U, s, V, J, "left");
338
339 //Proportion between the smaller / largest eigen value.
340 return s[s.n_elem - 1] / s[0];
341 }
342 return 0;
343 }
344
351 virtual bool contains(const GmMatrix& X, const GmVector& coord) const { Q_UNUSED(X); Q_UNUSED(coord); return false; }
352
353 //------------------------------------------------------------------------------------
354 // Helper functions for dimension and centroid calculation by numeric integration
355 //------------------------------------------------------------------------------------
356 const GmIntegrationRule* cellIntegrationRule() const;
357
358 double dimensionByIntegration(const GmMatrix& X, const GmIntegrationRule* ir = NULL) const;
359 void centroidByIntegration (const GmMatrix& X, GmVector& coord, const GmIntegrationRule* ir = NULL) const;
360
361private:
367};
368
369
373template <class RuleSet, class RuleSetDefaults>
375{
376public:
379
381 virtual GmIntegrationRule* integrationRule(GmIntegrationRuleType irType, int rule1, int rule2, int rule3, int P, int Q) const
382 {
383 Q_UNUSED(P); Q_UNUSED(Q);
384 return RuleSet::instance<RuleSetDefaults>(this, irType, rule1, rule2, rule3);
385 }
386
387 // Element edge integration rule factory. See comments on the base class.
388 virtual GmBorderIntegrationRule* edgeIntegrationRule(GmIntegrationRuleType irType, int rule1, int P, int Q) const
389 {
390 Q_UNUSED(irType); Q_UNUSED(rule1); Q_UNUSED(P); Q_UNUSED(Q);
391 return NULL;
392 }
393
394 // Element face integration rule factory. See comments on the base class.
395 virtual GmBorderIntegrationRule* faceIntegrationRule(int faceType, GmIntegrationRuleType irType, int rule1, int rule2, int P, int Q) const
396 {
397 Q_UNUSED(faceType); Q_UNUSED(irType); Q_UNUSED(rule1); Q_UNUSED(rule2); Q_UNUSED(P); Q_UNUSED(Q);
398 return NULL;
399 }
400};
401
402
406template <class RuleSet, class RuleSetDefaults, class EdgeRuleSet, class EdgeRuleSetDefaults>
408{
409public:
412
413 // Element integration rule factory. See comments on the base class.
414 virtual GmIntegrationRule* integrationRule(GmIntegrationRuleType irType, int rule1, int rule2, int rule3, int P, int Q) const
415 {
416 Q_UNUSED(P); Q_UNUSED(Q);
417 return RuleSet::instance<RuleSetDefaults>(this, irType, rule1, rule2, rule3);
418 }
419
420 // Element edge integration rule factory. See comments on the base class.
421 virtual GmBorderIntegrationRule* edgeIntegrationRule(GmIntegrationRuleType irType, int rule1, int P, int Q) const
422 {
423 Q_UNUSED(P); Q_UNUSED(Q);
424 return EdgeRuleSet::edgeInstance<EdgeRuleSetDefaults>(this, irType, rule1);
425 }
426
427 // Element face integration rule factory. See comments on the base class.
428 virtual GmBorderIntegrationRule* faceIntegrationRule(int faceType, GmIntegrationRuleType irType, int rule1, int rule2, int P, int Q) const
429 {
430 Q_UNUSED(faceType); Q_UNUSED(irType); Q_UNUSED(rule1); Q_UNUSED(rule2); Q_UNUSED(P); Q_UNUSED(Q);
431 return NULL;
432 }
433};
434
438template <class RuleSet, class RuleSetDefaults, class EdgeRuleSet, class EdgeRuleSetDefaults, class FaceRuleSet, class FaceRuleSetDefaults>
440{
441public:
444
445 // Element integration rule factory. See comments on the base class.
446 virtual GmIntegrationRule* integrationRule(GmIntegrationRuleType irType, int rule1, int rule2, int rule3, int P, int Q) const
447 {
448 Q_UNUSED(P); Q_UNUSED(Q);
449 return RuleSet::instance<RuleSetDefaults>(this, irType, rule1, rule2, rule3);
450 }
451
452 // Element edge integration rule factory. See comments on the base class.
453 virtual GmBorderIntegrationRule* edgeIntegrationRule(GmIntegrationRuleType irType, int rule1, int P, int Q) const
454 {
455 Q_UNUSED(P); Q_UNUSED(Q);
456 return EdgeRuleSet::edgeInstance<EdgeRuleSetDefaults>(this, irType, rule1);
457 }
458
459 // Element face integration rule factory. See comments on the base class.
460 virtual GmBorderIntegrationRule* faceIntegrationRule(int faceType, GmIntegrationRuleType irType, int rule1, int rule2, int P, int Q) const
461 {
462 Q_UNUSED(P); Q_UNUSED(Q);
463 return FaceRuleSet::faceInstance<FaceRuleSetDefaults>(this, faceType, irType, rule1, rule2);
464 }
465};
466
467
468#endif
469
Border integration rule base classe.
Definition gmBorderIntegrationRule.h:38
Definition gmCellGeometryInfo.h:202
virtual GmBorderIntegrationRule * edgeIntegrationRule(GmIntegrationRuleType irType, int rule1, int P, int Q) const =0
A factory function that returns a new border integration rule object suited for this kind of element....
virtual bool contains(const GmMatrix &X, const GmVector &coord) const
Virtual method that should be implemented if this geometry info supports the GM_CELL_GEOMETRY_CONTAIN...
Definition gmCellGeometryInfo.h:351
virtual GmBorderIntegrationRule * faceIntegrationRule(int faceType, GmIntegrationRuleType irType, int rule1, int rule2, int P, int Q) const =0
A factory function that returns a new border integration rule object suited for this kind of element....
virtual int isValid(const GmMatrix &X, double tol) const
Virtual method that should be implemented if this geometry info supports the GM_CELL_GEOMETRY_VALID c...
Definition gmCellGeometryInfo.h:323
virtual double quality(const GmMatrix &J, double tol) const
Virtual method that should be implemented if this geometry info supports the GM_CELL_GEOMETRY_QUALITY...
Definition gmCellGeometryInfo.h:332
GmCellGeometryInfo(GmCellGeometryMetadata &&metadata)
Standard move constructor receiving the type metadata.
Definition gmCellGeometryInfo.h:208
GmCellGeometryInfo(const GmCellGeometryInfo &other)
Standard copy constructor receiving the type metadata.
Definition gmCellGeometryInfo.h:205
virtual double dimension(const GmMatrix &X) const =0
Virtual function responsible for returning the cell characteristic dimension, defined as the length f...
virtual GmShape * shapeInstance(int P, int Q) const =0
Shape function factory. Should return a NEW instance of the shape function object for this type....
virtual bool localAxis(const GmMatrix &X, GmMatrix &R) const =0
Computes the cell local axis system, with R = [X, Y, Z] and X, Y and Z being the local axis unit vect...
virtual void centroidCartesian(const GmMatrix &X, GmVector &coord) const =0
Virtual function responsible for filling the coord vector with the cartesian coordinates of the cell ...
static QMutex _cellIntegrationRulesMutex
The mutex protecting _cellIntegrationRules.
Definition gmCellGeometryInfo.h:366
virtual GmIntegrationRule * integrationRule(GmIntegrationRuleType irType, int rule1, int rule2, int rule3, int P, int Q) const =0
A factory function that returns a new integration rule object suited for this kind of element.
An auxiliary class that can be used as base for line (bar) elements. Implements the needed integratio...
Definition gmCellGeometryInfo.h:375
virtual GmIntegrationRule * integrationRule(GmIntegrationRuleType irType, int rule1, int rule2, int rule3, int P, int Q) const
Element integration rule factory. See comments on the base class.
Definition gmCellGeometryInfo.h:381
virtual GmBorderIntegrationRule * edgeIntegrationRule(GmIntegrationRuleType irType, int rule1, int P, int Q) const
A factory function that returns a new border integration rule object suited for this kind of element....
Definition gmCellGeometryInfo.h:388
virtual GmBorderIntegrationRule * faceIntegrationRule(int faceType, GmIntegrationRuleType irType, int rule1, int rule2, int P, int Q) const
A factory function that returns a new border integration rule object suited for this kind of element....
Definition gmCellGeometryInfo.h:395
GmCellGeometryInfoLineElement(GmCellGeometryMetadata &&metadata)
Constructor receiving as parameter a metadata object that will be MOVED to the new object.
Definition gmCellGeometryInfo.h:378
An auxiliary class that can be used as base for solid elements. Implements the needed integration rul...
Definition gmCellGeometryInfo.h:440
virtual GmBorderIntegrationRule * faceIntegrationRule(int faceType, GmIntegrationRuleType irType, int rule1, int rule2, int P, int Q) const
A factory function that returns a new border integration rule object suited for this kind of element....
Definition gmCellGeometryInfo.h:460
GmCellGeometryInfoSolidElement(GmCellGeometryMetadata &&metadata)
Constructor receiving as parameter a metadata object that will be MOVED to the new object.
Definition gmCellGeometryInfo.h:443
virtual GmIntegrationRule * integrationRule(GmIntegrationRuleType irType, int rule1, int rule2, int rule3, int P, int Q) const
A factory function that returns a new integration rule object suited for this kind of element.
Definition gmCellGeometryInfo.h:446
virtual GmBorderIntegrationRule * edgeIntegrationRule(GmIntegrationRuleType irType, int rule1, int P, int Q) const
A factory function that returns a new border integration rule object suited for this kind of element....
Definition gmCellGeometryInfo.h:453
An auxiliary class that can be used as base for surface elements. Implements the needed integration r...
Definition gmCellGeometryInfo.h:408
GmCellGeometryInfoSurfaceElement(GmCellGeometryMetadata &&metadata)
Constructor receiving as parameter a metadata object that will be MOVED to the new object.
Definition gmCellGeometryInfo.h:411
virtual GmBorderIntegrationRule * faceIntegrationRule(int faceType, GmIntegrationRuleType irType, int rule1, int rule2, int P, int Q) const
A factory function that returns a new border integration rule object suited for this kind of element....
Definition gmCellGeometryInfo.h:428
virtual GmIntegrationRule * integrationRule(GmIntegrationRuleType irType, int rule1, int rule2, int rule3, int P, int Q) const
A factory function that returns a new integration rule object suited for this kind of element.
Definition gmCellGeometryInfo.h:414
virtual GmBorderIntegrationRule * edgeIntegrationRule(GmIntegrationRuleType irType, int rule1, int P, int Q) const
A factory function that returns a new border integration rule object suited for this kind of element....
Definition gmCellGeometryInfo.h:421
Integration rule base classe.
Definition gmIntegrationRule.h:89
Shape function handling base classe.
Definition gmShape.h:38
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_CONTAINS
Can the cell geometry info type check wheter a point is inside a cell?
Definition gmCellGeometryInfo.h:50
@ GM_CELL_GEOMETRY_QUALITY
Can the cell geometry info type give a cell quality measure?
Definition gmCellGeometryInfo.h:49
@ GM_CELL_GEOMETRY_CAPABILITY_COUNT
Not a capability type. Stores the number of capabilities in the enum.
Definition gmCellGeometryInfo.h:53
@ GM_CELL_GEOMETRY_VALID
Can the cell geometry info type check if a cell is valid?
Definition gmCellGeometryInfo.h:48
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_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
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
Declaration of the GmIntegrationRule class and its helper decendants.
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
Aux structure storing information about one edge of a cell type.
Definition gmCellGeometryInfo.h:72
QVector< int > _edgeNodes
The set of local node numbers, ordered sequentialy in the edge. The extremes(first and last entries) ...
Definition gmCellGeometryInfo.h:87
GmCellType _eqEdgeType
The 2D/3D bar equivalent edge element or GM_INV_CELL_TYPE if there is none. Currently,...
Definition gmCellGeometryInfo.h:77
GmCellType _meshEdgeType
The 2D/3D bar equivalent edge element used when creating a mesh from surface borders....
Definition gmCellGeometryInfo.h:82
Aux structure storing information about the set of face edges for a cell type.
Definition gmCellGeometryInfo.h:92
QVector< int > _meshTypeNodes
If meshFaceType is not GM_INV_CELL_TYPE, stores the list of nodes in the surface element node order w...
Definition gmCellGeometryInfo.h:128
GmCellType _eqFaceType
The 3D face equivalent surface element or GM_INV_CELL_TYPE if there is none. The invalid type is also...
Definition gmCellGeometryInfo.h:97
GmCellType _meshFaceType
The 3D face equivalent surface element used when creating a mesh from surface borders....
Definition gmCellGeometryInfo.h:102
int _nboundaryNodes
The number "b" of boundary nodes for this cell face. Excludes internal face nodes.
Definition gmCellGeometryInfo.h:93
QVector< int > _faceNodes
The list of nodes in the face, ordered in a way that the first b entries are the boundary nodes order...
Definition gmCellGeometryInfo.h:108
QVector< int > _faceTypeNodes
If eqFaceType is not GM_INV_CELL_TYPE, stores the list of nodes in the equivalent surface element n...
Definition gmCellGeometryInfo.h:115
Aux structure storing information about interface element "contact" and "aperture" sides....
Definition gmCellGeometryInfo.h:135
QVector< int > _contactSides
List of edges or faces in contact with "normal" elements.
Definition gmCellGeometryInfo.h:136
QVector< QVector< int > > _apertureEdges
The set of aperture edges (NOT shared with "normal" elements) per element face. Indices are local TO ...
Definition gmCellGeometryInfo.h:139
QVector< QVector< int > > _contactEdges
The set of contact edges (shared with "normal" elements) per element face. Indices are local TO THE F...
Definition gmCellGeometryInfo.h:138
QVector< int > _apertureSides
List of edges or faces not in contact with "normal" elements.
Definition gmCellGeometryInfo.h:137
Plane structure storing the full set of geometric metadata for a cell type.
Definition gmCellGeometryInfo.h:69
const char * _name
The cell type name.
Definition gmCellGeometryInfo.h:143
GmCellGeometryMetadata(const GmCellGeometryMetadata &other)=default
Copy constructor.
int _nextraDofNodes
Number of extra dof nodes. Usually 0. See comments for GmCellGeometry::numVertices().
Definition gmCellGeometryInfo.h:151
int _order
The cell order (1: linear, 2: quadratic, 3: cubic, ...)
Definition gmCellGeometryInfo.h:147
QVector< QVector< int > > _edgeFaceInfo
Face information for each cell's edge.
Definition gmCellGeometryInfo.h:167
GmCellType _type
The cell type.
Definition gmCellGeometryInfo.h:142
GmCellGeometryMetadata(GmCellGeometryMetadata &&other)=default
Move constructor.
QVector< QVector< int > > _faceEdgeInfo
Edge information for each cell's face, ordered according to the cell's face description....
Definition gmCellGeometryInfo.h:164
QVector< int > _volumeNodeInfo
Mid volume node list.
Definition gmCellGeometryInfo.h:179
int _nfaceTypes
Number of face types for a 3D element. 1 For surface elements.
Definition gmCellGeometryInfo.h:155
int _nnodes
Number of cell nodes.
Definition gmCellGeometryInfo.h:149
bool _hierarchical
Is this cell an hierarchical element (needing P & Q order parameters?)
Definition gmCellGeometryInfo.h:146
InterfaceData _interfaceInfo
Additional face / edge descriptions for interface elements.
Definition gmCellGeometryInfo.h:173
QVector< FaceNodeData > _faceNodeInfo
Node information for each cell's face. Size equal to "nfaces". Empty for 1D elements.
Definition gmCellGeometryInfo.h:170
QVector< EdgeNodeData > _edgeNodeInfo
Node information for each cell's edge. Size equal to "nedges".
Definition gmCellGeometryInfo.h:161
int _ncoord
The number of cartesian coordinates for nodes of this cell type.
Definition gmCellGeometryInfo.h:152
GmCellFamilyType _family
The family that this cell type belongs to.
Definition gmCellGeometryInfo.h:144
GmCellType _eqLinearType
The equivalent linear element.
Definition gmCellGeometryInfo.h:148
bool _interface
Is this cell an interface element?
Definition gmCellGeometryInfo.h:145
QVector< QVector< int > > _nodeIncidenceInfo
Node incidence information for each cell's node. Size equal to "nnodes".
Definition gmCellGeometryInfo.h:176
int _nedges
Number of cell edges.
Definition gmCellGeometryInfo.h:153
int _nfaces
Number of cell faces.
Definition gmCellGeometryInfo.h:154
int _nvertices
Number of cell vertices. Excludes "quadratic" nodes and extra dof nodes. See comments for GmCellGeome...
Definition gmCellGeometryInfo.h:150