GemaCoreLib
The GeMA Core library
Loading...
Searching...
No Matches
gmHexCellGeometryInfo.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_HEX_CELL_GEOMETRY_INFO_H_
25#define _GEMA_HEX_CELL_GEOMETRY_INFO_H_
26
27#include "gmCellGeometryInfo.h"
29
30#include "gmGeometryUtils.h"
31
33#include "gmHexShape.h"
34
35//---------------------------------------------------------
36// Hex integration rules
37//---------------------------------------------------------
38
42
46
50
51//---------------------------------------------------------
52// Hex8 rule defaults
53//---------------------------------------------------------
54
59
64
69
70//---------------------------------------------------------
71// Hex20 & Hex27 rule defaults
72//---------------------------------------------------------
73
78
83
88
89
90//---------------------------------------------------------
91// GmHex8CellGeometryInfo
92//---------------------------------------------------------
93
96 : public GmCellGeometryInfoSolidElement<GmHexIntegrationRuleSet, GmLinearHexIntegrationRuleSetDefaults,
97 GmHexEdgeIntegrationRuleSet, GmLinearHexEdgeIntegrationRuleSetDefaults,
98 GmHexFaceIntegrationRuleSet, GmLinearHexFaceIntegrationRuleSetDefaults>
99{
100public:
101 static const GmHex8CellGeometryInfo* instance();
102
103 // Shape factory. See comments on the base class.
104 virtual GmShape* shapeInstance(int P, int Q) const { Q_UNUSED(P); Q_UNUSED(Q); return new GmHex8Shape; }
105
107 virtual double dimension(const GmMatrix& X) const
108 {
109 return GmGeometryUtils::hexahedronVolume(X.col(0), X.col(1), X.col(2), X.col(3), X.col(4), X.col(5), X.col(6), X.col(7));
110 }
111
113 virtual void centroidCartesian(const GmMatrix& X, GmVector& coord) const
114 {
115 GmGeometryUtils::hexahedronCentroid(X.col(0), X.col(1), X.col(2), X.col(3), X.col(4), X.col(5), X.col(6), X.col(7), coord);
116 }
117
118 // --------- Capabilities API ---------
119
120 virtual int isValid(const GmMatrix& X, double tol) const {
121 int ret = GM_GEOMETRY_STATE_VALID;
122 if (!GmGeometryUtils::hex8PlanarFaces(X, tol)) ret |= GM_GEOMETRY_STATE_NON_PLANAR;
123 if (!GmGeometryUtils::hex8IsWellDefined(X)) ret |= GM_GEOMETRY_STATE_BAD_ORIENTATION;
124 return ret;
125 }
126
127 // See comments on the base class
128 virtual bool contains(const GmMatrix& X, const GmVector& coord) const { return GmGeometryUtils::pointInHexahedron(X, coord); }
129
130 virtual bool localAxis(const GmMatrix&X, GmMatrix& R) const {Q_UNUSED(X); R = arma::eye(3, 3); return false; }
131
132private:
138};
139
140//---------------------------------------------------------
141// GmHex20CellGeometryInfo
142//---------------------------------------------------------
143
146 : public GmCellGeometryInfoSolidElement<GmHexIntegrationRuleSet, GmQuadraticHexIntegrationRuleSetDefaults,
147 GmHexEdgeIntegrationRuleSet, GmQuadraticHexEdgeIntegrationRuleSetDefaults,
148 GmHexFaceIntegrationRuleSet, GmQuadraticHexFaceIntegrationRuleSetDefaults>
149{
150public:
151 static const GmHex20CellGeometryInfo* instance();
152
153 // Shape factory. See comments on the base class.
154 virtual GmShape* shapeInstance(int P, int Q) const { Q_UNUSED(P); Q_UNUSED(Q); return new GmHex20Shape; }
155
157 virtual double dimension(const GmMatrix& X) const { return dimensionByIntegration(X); }
158
160 virtual void centroidCartesian(const GmMatrix& X, GmVector& coord) const { centroidByIntegration(X, coord); }
161
162 virtual bool localAxis(const GmMatrix&X, GmMatrix& R) const { Q_UNUSED(X); R = arma::eye(3, 3); return false; }
163
164 // --------- Capabilities API ---------
165 virtual int isValid(const GmMatrix& X, double tol) const {
166 int ret = GM_GEOMETRY_STATE_VALID;
167 if (!GmGeometryUtils::hex20ValidEdges(X)) ret |= GM_GEOMETRY_STATE_BAD_EDGE;
168 if (!GmGeometryUtils::hex8PlanarFaces(X, tol)) ret |= GM_GEOMETRY_STATE_NON_PLANAR;
169 if (!GmGeometryUtils::hex8IsWellDefined(X)) ret |= GM_GEOMETRY_STATE_BAD_ORIENTATION;
170 return ret;
171 }
172
173private:
179};
180
181//---------------------------------------------------------
182// GmHex27CellGeometryInfo
183//---------------------------------------------------------
184
187 : public GmCellGeometryInfoSolidElement<GmHexIntegrationRuleSet, GmQuadraticHexIntegrationRuleSetDefaults,
188 GmHexEdgeIntegrationRuleSet, GmQuadraticHexEdgeIntegrationRuleSetDefaults,
189 GmHexFaceIntegrationRuleSet, GmQuadraticHexFaceIntegrationRuleSetDefaults>
190{
191public:
192 static const GmHex27CellGeometryInfo* instance();
193
194 // Shape factory. See comments on the base class.
195 virtual GmShape* shapeInstance(int P, int Q) const { Q_UNUSED(P); Q_UNUSED(Q); return new GmHex27Shape; }
196
198 virtual double dimension(const GmMatrix& X) const { return dimensionByIntegration(X); }
199
201 virtual void centroidCartesian(const GmMatrix& X, GmVector& coord) const { centroidByIntegration(X, coord); }
202
203 virtual bool localAxis(const GmMatrix&X, GmMatrix& R) const { Q_UNUSED(X); R = arma::eye(3, 3); return false; }
204 // --------- Capabilities API ---------
205 virtual int isValid(const GmMatrix& X, double tol) const {
206
207 int ret = GM_GEOMETRY_STATE_VALID;
208 if (!GmGeometryUtils::hex27ValidFacesCenter(X, tol)) ret |= GM_GEOMETRY_STATE_BAD_FACE_CENTER;
209 if (!GmGeometryUtils::hex20ValidEdges(X)) ret |= GM_GEOMETRY_STATE_BAD_EDGE;
210 if (!GmGeometryUtils::hex8PlanarFaces(X, tol)) ret |= GM_GEOMETRY_STATE_NON_PLANAR;
211 if (!GmGeometryUtils::hex8IsWellDefined(X)) ret |= GM_GEOMETRY_STATE_BAD_ORIENTATION;
212 return ret;
213 }
214private:
220};
221
222
223#endif
224
void centroidByIntegration(const GmMatrix &X, GmVector &coord, const GmIntegrationRule *ir=NULL) const
Given a cell geometry defined by matrix X (with node coordinates organized by column) performs a nume...
Definition gmCellGeometryInfo.cpp:114
double dimensionByIntegration(const GmMatrix &X, const GmIntegrationRule *ir=NULL) const
Given a cell geometry defined by matrix X (with node coordinates organized by column) performs a nume...
Definition gmCellGeometryInfo.cpp:76
An auxiliary class that can be used as base for solid elements. Implements the needed integration rul...
Definition gmCellGeometryInfo.h:440
A helper class used to store the default rules for each rule type. Template parameters are the defaul...
Definition gmCellGeometryIntegrationRuleSet.h:44
A helper class used to store the class types for each rule type. Template parameters are the implemen...
Definition gmCellGeometryIntegrationRuleSet.h:197
A type used to represent a 'unexistant" integration rule. Should be used as template parameter for Gm...
Definition gmCellGeometryIntegrationRuleSet.h:35
The hex20 implementation.
Definition gmHexCellGeometryInfo.h:149
virtual void centroidCartesian(const GmMatrix &X, GmVector &coord) const
Returns the Hex20 centroid by numeric integration.
Definition gmHexCellGeometryInfo.h:160
virtual double dimension(const GmMatrix &X) const
Returns the Hex20 volume by numeric integration.
Definition gmHexCellGeometryInfo.h:157
virtual GmShape * shapeInstance(int P, int Q) const
Shape function factory. Should return a NEW instance of the shape function object for this type....
Definition gmHexCellGeometryInfo.h:154
GmHex20CellGeometryInfo(GmCellGeometryMetadata &&metadata)
Protected constructor. Only a single Hex20 geometry info object is ever necessary,...
Definition gmHexCellGeometryInfo.h:175
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 gmHexCellGeometryInfo.h:165
virtual 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 gmHexCellGeometryInfo.h:162
GmShape specialization for a Hexahedron with 20 nodes object.
Definition gmHexShape.h:133
The hex27 implementation.
Definition gmHexCellGeometryInfo.h:190
virtual 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 gmHexCellGeometryInfo.h:203
virtual void centroidCartesian(const GmMatrix &X, GmVector &coord) const
Returns the Hex27 centroid by numeric integration.
Definition gmHexCellGeometryInfo.h:201
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 gmHexCellGeometryInfo.h:205
virtual GmShape * shapeInstance(int P, int Q) const
Shape function factory. Should return a NEW instance of the shape function object for this type....
Definition gmHexCellGeometryInfo.h:195
virtual double dimension(const GmMatrix &X) const
Returns the Hex27 volume by numeric integration.
Definition gmHexCellGeometryInfo.h:198
GmHex27CellGeometryInfo(const GmHex20CellGeometryInfo &hex20)
Protected constructor. Only a single Hex27 geometry info object is ever necessary,...
Definition gmHexCellGeometryInfo.h:216
GmShape specialization for a Hexahedron with 27 nodes object.
Definition gmHexShape.h:156
The hex8 implementation.
Definition gmHexCellGeometryInfo.h:99
GmHex8CellGeometryInfo(GmCellGeometryMetadata &&metadata)
Protected constructor. Only a single Hex8 geometry info object is ever necessary, created by GmHexCel...
Definition gmHexCellGeometryInfo.h:134
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 gmHexCellGeometryInfo.h:120
virtual double dimension(const GmMatrix &X) const
Returns the Hex8 volume.
Definition gmHexCellGeometryInfo.h:107
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 gmHexCellGeometryInfo.h:128
virtual void centroidCartesian(const GmMatrix &X, GmVector &coord) const
Returns the Hex8 centroid by decomposing it into 6 tetrahedra and weighting each coordinate by the te...
Definition gmHexCellGeometryInfo.h:113
virtual GmShape * shapeInstance(int P, int Q) const
Shape function factory. Should return a NEW instance of the shape function object for this type....
Definition gmHexCellGeometryInfo.h:104
virtual 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 gmHexCellGeometryInfo.h:130
GmShape specialization for a Hexahedron with 8 nodes object.
Definition gmHexShape.h:110
Gauss integration rule for Hex element borders (edges)
Definition gmHexIntegrationRule.h:173
Gauss integration rule for Hex element borders (faces)
Definition gmHexIntegrationRule.h:134
3D Isotropic / anisotropic Gauss integration rules for Hex elements
Definition gmHexIntegrationRule.h:45
Lobatto integration rule for Hex element borders (edges)
Definition gmHexIntegrationRule.h:186
Lobatto integration rule for Hex element borders (faces)
Definition gmHexIntegrationRule.h:147
3D Isotropic / anisotropic Lobatto integration rules for Hex elements
Definition gmHexIntegrationRule.h:93
3D Isotropic / anisotropic Newton cotes integration rules for Hex elements
Definition gmHexIntegrationRule.h:69
Shape function handling base classe.
Definition gmShape.h:38
Declaration of the GmCellGeometryInfo base class.
Declaration of the GmCellGeometryIntegrationRuleSet class & friends.
#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
Utilitary functions for working with geometry.
GmCellGeometryIntegrationRuleSetDefaultRules< GM_GAUSS_RULE_TYPE, 2, 2, 2, 2 > GmQuadraticHexIntegrationRuleSetDefaults
The set of default rules for an Hex20/27 ELEMENT. Template parameters 2 to 5 are the default rule num...
Definition gmHexCellGeometryInfo.h:77
GmCellGeometryIntegrationRuleSetDefaultRules< GM_GAUSS_RULE_TYPE, 2, 2, -1, -1 > GmLinearHexFaceIntegrationRuleSetDefaults
The set of default rules for an Hex8 FACE. Template parameters 2 to 5 are the default rule numbers fo...
Definition gmHexCellGeometryInfo.h:63
GmCellGeometryIntegrationRuleSet< GmHexGaussIntegrationRule, GmHexLobattoIntegrationRule, GmHexNewtonIntegrationRule, GmHexNewtonIntegrationRule > GmHexIntegrationRuleSet
The set of possible ELEMENT integration rules, per integration rule type, for the family of Hex eleme...
Definition gmHexCellGeometryInfo.h:41
GmCellGeometryIntegrationRuleSetDefaultRules< GM_GAUSS_RULE_TYPE, 2, 2, -1, -1 > GmQuadraticHexFaceIntegrationRuleSetDefaults
The set of default rules for an Hex20/27 FACE. Template parameters 2 to 5 are the default rule number...
Definition gmHexCellGeometryInfo.h:82
GmCellGeometryIntegrationRuleSetDefaultRules< GM_GAUSS_RULE_TYPE, 2, 2, -1, -1 > GmQuadraticHexEdgeIntegrationRuleSetDefaults
The set of default rules for an Hex20/27 EDGE. Template parameters 2 to 5 are the default rule number...
Definition gmHexCellGeometryInfo.h:87
GmCellGeometryIntegrationRuleSetDefaultRules< GM_GAUSS_RULE_TYPE, 2, 2, 2, 2 > GmLinearHexIntegrationRuleSetDefaults
The set of default rules for an Hex8 ELEMENT. Template parameters 2 to 5 are the default rule numbers...
Definition gmHexCellGeometryInfo.h:58
GmCellGeometryIntegrationRuleSet< GmHexGaussFaceIntegrationRule, GmHexLobattoFaceIntegrationRule, GmCellGeometryNullIntegrationRule, GmCellGeometryNullIntegrationRule > GmHexFaceIntegrationRuleSet
The set of possible FACE integration rules, per integration rule type, for the family of Hex elements...
Definition gmHexCellGeometryInfo.h:45
GmCellGeometryIntegrationRuleSet< GmHexGaussEdgeIntegrationRule, GmHexLobattoEdgeIntegrationRule, GmCellGeometryNullIntegrationRule, GmCellGeometryNullIntegrationRule > GmHexEdgeIntegrationRuleSet
The set of possible EDGE integration rules, per integration rule type, for the family of Hex elements...
Definition gmHexCellGeometryInfo.h:49
GmCellGeometryIntegrationRuleSetDefaultRules< GM_GAUSS_RULE_TYPE, 2, 2, -1, -1 > GmLinearHexEdgeIntegrationRuleSetDefaults
The set of default rules for an Hex8 EDGE. Template parameters 2 to 5 are the default rule numbers fo...
Definition gmHexCellGeometryInfo.h:68
Declaration of the GmHexXxxxxIntegrationRule family of classes, including border rules....
Declaration of the 3D Hex shapes inheriting from GmShape class Previosuly part of the gmShape3D....
@ GM_GAUSS_RULE_TYPE
Gauss rules.
Definition gmIntegrationRule.h:75
arma::mat GmMatrix
The basic type for a GeMA matrix object. Currently based on an Armadillo matrix.
Definition gmMatrix.h:38
arma::vec GmVector
The basic type for a GeMA vector object. Currently based on an Armadillo vector.
Definition gmVector.h:34
void hexahedronCentroid(const GmVector &p1, const GmVector &p2, const GmVector &p3, const GmVector &p4, const GmVector &p5, const GmVector &p6, const GmVector &p7, const GmVector &p8, GmVector &coord)
Definition gmGeometryUtils.cpp:294
double hexahedronVolume(const GmVector &p1, const GmVector &p2, const GmVector &p3, const GmVector &p4, const GmVector &p5, const GmVector &p6, const GmVector &p7, const GmVector &p8)
Calculates the volume of the given hexahedron. Points follow the standard Hex cell definition.
Definition gmGeometryUtils.cpp:199
bool hex27ValidFacesCenter(const GmMatrix &X, double tol)
Returns true if face center point is collinear with the face. Assumes that the quad faces are planar.
Definition gmGeometryUtils.cpp:1039
bool hex20ValidEdges(const GmMatrix &X, double proportion_max)
Returns true if the points defined between the edges of hex20 follows: 1) Their projection to the 3d ...
Definition gmGeometryUtils.cpp:951
Plane structure storing the full set of geometric metadata for a cell type.
Definition gmCellGeometryInfo.h:69