GemaCoreLib
The GeMA Core library
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 
32 #include "gmHexIntegrationRule.h"
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 {
100 public:
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 bool isValid(const GmMatrix& X, double tol) const {
121  return GmGeometryUtils::hex8PlanarFaces(X, tol) && GmGeometryUtils::hex8IsWellDefined(X);
122  }
123 
124  // See comments on the base class
125  virtual bool contains(const GmMatrix& X, const GmVector& coord) const { return GmGeometryUtils::pointInHexahedron(X, coord); }
126 
127 private:
133 };
134 
135 //---------------------------------------------------------
136 // GmHex20CellGeometryInfo
137 //---------------------------------------------------------
138 
141  : public GmCellGeometryInfoSolidElement<GmHexIntegrationRuleSet, GmQuadraticHexIntegrationRuleSetDefaults,
142  GmHexEdgeIntegrationRuleSet, GmQuadraticHexEdgeIntegrationRuleSetDefaults,
143  GmHexFaceIntegrationRuleSet, GmQuadraticHexFaceIntegrationRuleSetDefaults>
144 {
145 public:
146  static const GmHex20CellGeometryInfo* instance();
147 
148  // Shape factory. See comments on the base class.
149  virtual GmShape* shapeInstance(int P, int Q) const { Q_UNUSED(P); Q_UNUSED(Q); return new GmHex20Shape; }
150 
152  virtual double dimension(const GmMatrix& X) const { return dimensionByIntegration(X); }
153 
155  virtual void centroidCartesian(const GmMatrix& X, GmVector& coord) const { centroidByIntegration(X, coord); }
156 
157  // --------- Capabilities API ---------
158  virtual bool isValid(const GmMatrix& X, double tol) const {
160  GmGeometryUtils::hex8PlanarFaces(X, tol) &&
161  GmGeometryUtils::hex8IsWellDefined(X);
162  }
163 
164 private:
170 };
171 
172 //---------------------------------------------------------
173 // GmHex27CellGeometryInfo
174 //---------------------------------------------------------
175 
178  : public GmCellGeometryInfoSolidElement<GmHexIntegrationRuleSet, GmQuadraticHexIntegrationRuleSetDefaults,
179  GmHexEdgeIntegrationRuleSet, GmQuadraticHexEdgeIntegrationRuleSetDefaults,
180  GmHexFaceIntegrationRuleSet, GmQuadraticHexFaceIntegrationRuleSetDefaults>
181 {
182 public:
183  static const GmHex27CellGeometryInfo* instance();
184 
185  // Shape factory. See comments on the base class.
186  virtual GmShape* shapeInstance(int P, int Q) const { Q_UNUSED(P); Q_UNUSED(Q); return new GmHex27Shape; }
187 
189  virtual double dimension(const GmMatrix& X) const { return dimensionByIntegration(X); }
190 
192  virtual void centroidCartesian(const GmMatrix& X, GmVector& coord) const { centroidByIntegration(X, coord); }
193 
194  // --------- Capabilities API ---------
195  virtual bool isValid(const GmMatrix& X, double tol) const {
196 
199  GmGeometryUtils::hex8PlanarFaces(X, tol) &&
200  GmGeometryUtils::hex8IsWellDefined(X);
201  }
202 private:
208 };
209 
210 
211 #endif
212 
Lobatto integration rule for Hex element borders (faces)
Definition: gmHexIntegrationRule.h:146
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:933
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
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
virtual double dimension(const GmMatrix &X) const
Returns the Hex20 volume by numeric integration.
Definition: gmHexCellGeometryInfo.h:152
Gauss rules.
Definition: gmIntegrationRule.h:75
GmShape specialization for a Hexahedron with 20 nodes object.
Definition: gmHexShape.h:128
An auxiliary class that can be used as base for solid elements. Implements the needed integration rul...
Definition: gmCellGeometryInfo.h:380
The hex20 implementation.
Definition: gmHexCellGeometryInfo.h:140
A type used to represent a 'unexistant" integration rule. Should be used as template parameter for Gm...
Definition: gmCellGeometryIntegrationRuleSet.h:35
virtual void centroidCartesian(const GmMatrix &X, GmVector &coord) const
Returns the Hex27 centroid by numeric integration.
Definition: gmHexCellGeometryInfo.h:192
GmHex27CellGeometryInfo(const GmHex20CellGeometryInfo &hex20)
Protected constructor. Only a single Hex27 geometry info object is ever necessary,...
Definition: gmHexCellGeometryInfo.h:204
3D Isotropic / anisotropic Lobatto integration rules for Hex elements
Definition: gmHexIntegrationRule.h:92
A helper class used to store the default rules for each rule type. Template parameters are the defaul...
Definition: gmCellGeometryIntegrationRuleSet.h:43
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
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:325
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
3D Isotropic / anisotropic Gauss integration rules for Hex elements
Definition: gmHexIntegrationRule.h:44
Gauss integration rule for Hex element borders (edges)
Definition: gmHexIntegrationRule.h:172
virtual bool 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:195
Shape function handling base classe.
Definition: gmShape.h:37
Lobatto integration rule for Hex element borders (edges)
Definition: gmHexIntegrationRule.h:185
Declaration of the GmCellGeometryIntegrationRuleSet class & friends.
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
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 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
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:203
3D Isotropic / anisotropic Newton cotes integration rules for Hex elements
Definition: gmHexIntegrationRule.h:68
GmShape specialization for a Hexahedron with 27 nodes object.
Definition: gmHexShape.h:151
A helper class used to store the class types for each rule type. Template parameters are the implemen...
Definition: gmCellGeometryIntegrationRuleSet.h:196
GmShape specialization for a Hexahedron with 8 nodes object.
Definition: gmHexShape.h:105
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 void centroidCartesian(const GmMatrix &X, GmVector &coord) const
Returns the Hex20 centroid by numeric integration.
Definition: gmHexCellGeometryInfo.h:155
virtual double dimension(const GmMatrix &X) const
Returns the Hex8 volume.
Definition: gmHexCellGeometryInfo.h:107
Utilitary functions for working with geometry.
GmHex20CellGeometryInfo(GmCellGeometryMetadata &&metadata)
Protected constructor. Only a single Hex20 geometry info object is ever necessary,...
Definition: gmHexCellGeometryInfo.h:166
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
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
Gauss integration rule for Hex element borders (faces)
Definition: gmHexIntegrationRule.h:133
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:125
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
#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
GmHex8CellGeometryInfo(GmCellGeometryMetadata &&metadata)
Protected constructor. Only a single Hex8 geometry info object is ever necessary, created by GmHexCel...
Definition: gmHexCellGeometryInfo.h:129
Declaration of the 3D Hex shapes inheriting from GmShape class Previosuly part of the gmShape3D....
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:958
virtual double dimension(const GmMatrix &X) const
Returns the Hex27 volume by numeric integration.
Definition: gmHexCellGeometryInfo.h:189
The hex8 implementation.
Definition: gmHexCellGeometryInfo.h:95
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:149
Declaration of the GmCellGeometryInfo base class.
arma::vec GmVector
The basic type for a GeMA vector object. Currently based on an Armadillo vector.
Definition: gmVector.h:34
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:186
Declaration of the GmHexXxxxxIntegrationRule family of classes, including border rules....
virtual bool 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:158
arma::mat GmMatrix
The basic type for a GeMA matrix object. Currently based on an Armadillo matrix.
Definition: gmMatrix.h:38
The hex27 implementation.
Definition: gmHexCellGeometryInfo.h:177
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
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
Plane structure storing the full set of geometric metadata for a cell type.
Definition: gmCellGeometryInfo.h:57