GemaCoreLib
The GeMA Core library
Loading...
Searching...
No Matches
gmInt2dCellGeometryInfo.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_INT2D_CELL_GEOMETRY_INFO_H_
25#define _GEMA_INT2D_CELL_GEOMETRY_INFO_H_
26
27#include "gmCellGeometryInfo.h"
29
30#include "gmGeometryUtils.h"
31
34#include "gmInt2DShape.h"
35
36//---------------------------------------------------------
37// Int2D integration rules
38//---------------------------------------------------------
39
43
51
52//---------------------------------------------------------
53// Int2DL4 & Int2DL6 rule defaults
54//---------------------------------------------------------
55
60
65
66//---------------------------------------------------------
67// Int2DQ6 & Int2DQ8 rule defaults
68//---------------------------------------------------------
69
74
79
80
81//---------------------------------------------------------
82// GmInt2DL4CellGeometryInfo
83//---------------------------------------------------------
84
87 : public GmCellGeometryInfoSurfaceElement<GmInt2DIntegrationRuleSet, GmLinearInt2DIntegrationRuleSetDefaults,
88 GmInt2DEdgeIntegrationRuleSet, GmLinearInt2DEdgeIntegrationRuleSetDefaults>
89{
90public:
91 static const GmInt2DL4CellGeometryInfo* instance();
92
93 // Shape factory. See comments on the base class.
94 virtual GmShape* shapeInstance(int P, int Q) const { Q_UNUSED(P); Q_UNUSED(Q); return new GmInt2DL4Shape; }
95
97 virtual double dimension(const GmMatrix& X) const
98 {
99 return GmGeometryUtils::edgeLength(0.5*(X.col(0)+X.col(3)), 0.5*(X.col(1)+X.col(2)));
100 }
101
103 virtual void centroidCartesian(const GmMatrix& X, GmVector& coord) const
104 {
105 GmGeometryUtils::edgeCentroid(0.5*(X.col(0)+X.col(3)), 0.5*(X.col(1)+X.col(2)), coord);
106 }
107
109 virtual bool localAxis(const GmMatrix&X, GmMatrix& R) const {
110 GmVector p1 = (X.col(1) + X.col(2)) * 0.5;
111 GmVector p0 = (X.col(0) + X.col(3)) * 0.5;
112 return GmGeometryUtils::computeLocalAxis2(p1 - p0, R);
113 }
114
115 // --------- Capabilities API ---------
116
117 virtual int isValid(const GmMatrix& X, double tol) const {
118 Q_UNUSED(tol);
119 int ret = GM_GEOMETRY_STATE_VALID;
120 if (!GmGeometryUtils::polygon2DIsCCW(X)) ret |= GM_GEOMETRY_STATE_BAD_ORIENTATION;
121 return ret;
122 }
123
124protected:
129};
130
131//---------------------------------------------------------
132// GmInt2DL6CellGeometryInfo
133//---------------------------------------------------------
134
137{
138public:
139 static const GmInt2DL6CellGeometryInfo* instance();
140
141 // Shape factory. See comments on the base class.
142 virtual GmShape* shapeInstance(int P, int Q) const { Q_UNUSED(P); Q_UNUSED(Q); return new GmInt2DL6Shape; }
143
145 virtual bool localAxis(const GmMatrix&X, GmMatrix& R) const {
146 GmVector p1 = (X.col(1) + X.col(2)) * 0.5;
147 GmVector p0 = (X.col(0) + X.col(3)) * 0.5;
148 return GmGeometryUtils::computeLocalAxis2(p1 - p0, R);
149 }
150
151 // --------- Capabilities API ---------
152
153 virtual int isValid(const GmMatrix& X, double tol) const {
154 Q_UNUSED(tol);
155 //reorder nodes
156 constexpr int order[] = { 0,1,5,2,3,4 };
157 GmMatrix Xr = GmGeometryUtils::shuffle(X, order, 6);
158 int ret = GM_GEOMETRY_STATE_VALID;
159 if (!GmGeometryUtils::polygon2DIsCCW(Xr)) ret |= GM_GEOMETRY_STATE_BAD_ORIENTATION;
160 return ret;
161 }
162
163private:
166};
167
168//---------------------------------------------------------
169// GmInt2DQ6CellGeometryInfo
170//---------------------------------------------------------
171
174 : public GmCellGeometryInfoSurfaceElement<GmInt2DIntegrationRuleSet, GmQuadraticInt2DIntegrationRuleSetDefaults,
175 GmInt2DEdgeIntegrationRuleSet, GmQuadraticInt2DEdgeIntegrationRuleSetDefaults>
176{
177public:
178 static const GmInt2DQ6CellGeometryInfo* instance();
179
180 // Shape factory. See comments on the base class.
181 virtual GmShape* shapeInstance(int P, int Q) const { Q_UNUSED(P); Q_UNUSED(Q); return new GmInt2DQ6Shape; }
182
184 virtual double dimension(const GmMatrix& X) const
185 {
186 GmMatrix Xm(2, 3);
187 Xm.col(0) = 0.5*(X.col(0)+X.col(3)); // First node
188 Xm.col(1) = 0.5*(X.col(1)+X.col(2)); // Last node
189 Xm.col(2) = 0.5*(X.col(4)+X.col(5)); // Mid node
191 }
192
194 virtual void centroidCartesian(const GmMatrix& X, GmVector& coord) const
195 {
196 GmMatrix Xm(2, 3);
197 Xm.col(0) = 0.5*(X.col(0)+X.col(3)); // First node
198 Xm.col(1) = 0.5*(X.col(1)+X.col(2)); // Last node
199 Xm.col(2) = 0.5*(X.col(4)+X.col(5)); // Mid node
201 }
202
204 virtual bool localAxis(const GmMatrix&X, GmMatrix& R) const {
205 GmVector p1 = (X.col(1) + X.col(2)) * 0.5;
206 GmVector p0 = (X.col(0) + X.col(3)) * 0.5;
207 return GmGeometryUtils::computeLocalAxis2(p1 - p0, R);
208 }
209
210 // --------- Capabilities API ---------
211
212 virtual int isValid(const GmMatrix& X, double tol) const {
213 Q_UNUSED(tol);
214 //reorder nodes
215 constexpr int order[] = {0,4,1,2,5,3};
216 GmMatrix Xr = GmGeometryUtils::shuffle(X, order, 6);
217 int ret = GM_GEOMETRY_STATE_VALID;
218 if (!GmGeometryUtils::polygon2DIsCCW(Xr)) ret |= GM_GEOMETRY_STATE_BAD_ORIENTATION;
219 return ret;
220 }
221
222protected:
227};
228
229
230//---------------------------------------------------------
231// GmInt2DQ8CellGeometryInfo
232//---------------------------------------------------------
233
236{
237public:
238 static const GmInt2DQ8CellGeometryInfo* instance();
239
240 // Shape factory. See comments on the base class.
241 virtual GmShape* shapeInstance(int P, int Q) const { Q_UNUSED(P); Q_UNUSED(Q); return new GmInt2DQ8Shape; }
242
244 virtual bool localAxis(const GmMatrix&X, GmMatrix& R) const {
245 GmVector p1 = (X.col(1) + X.col(2)) * 0.5;
246 GmVector p0 = (X.col(0) + X.col(3)) * 0.5;
247 return GmGeometryUtils::computeLocalAxis2(p1 - p0, R);
248 }
249
250 // --------- Capabilities API ---------
251
252 virtual int isValid(const GmMatrix& X, double tol) const {
253 Q_UNUSED(tol);
254 //reorder nodes
255 constexpr int order[] = {0,4,1,7,2,5,3,6};
256 GmMatrix Xr = GmGeometryUtils::shuffle(X, order, 8);
257 int ret = GM_GEOMETRY_STATE_VALID;
258 if (!GmGeometryUtils::polygon2DIsCCW(Xr)) ret |= GM_GEOMETRY_STATE_BAD_ORIENTATION;
259 return ret;
260 }
261
262private:
265};
266
267#endif
268
static const GmCellGeometryInfo * geometryInfo(GmCellType type)
Returns the geometry info objct associated with type. NOT FOR GENERAL USE.
Definition gmCellGeometry.h:661
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 surface elements. Implements the needed integration r...
Definition gmCellGeometryInfo.h:408
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 Int2DL4 implementation.
Definition gmInt2dCellGeometryInfo.h:89
virtual double dimension(const GmMatrix &X) const
Returns the Int2DL4 length at the "mid edge".
Definition gmInt2dCellGeometryInfo.h:97
virtual void centroidCartesian(const GmMatrix &X, GmVector &coord) const
Returns the Int2DL4 centroid as a Bar2 at the "mid edge".
Definition gmInt2dCellGeometryInfo.h:103
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 gmInt2dCellGeometryInfo.h:94
virtual bool localAxis(const GmMatrix &X, GmMatrix &R) const
Local axis 2D interface element.
Definition gmInt2dCellGeometryInfo.h:109
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 gmInt2dCellGeometryInfo.h:117
GmInt2DL4CellGeometryInfo(GmCellGeometryMetadata &&metadata)
Protected constructor. Only a single Int2DL4 geometry info object is ever necessary,...
Definition gmInt2dCellGeometryInfo.h:126
GmShape specialization for a 2D linear interface element with 4 nodes object.
Definition gmInt2DShape.h:139
The Int2DL6 implementation.
Definition gmInt2dCellGeometryInfo.h:137
virtual bool localAxis(const GmMatrix &X, GmMatrix &R) const
Local axis 2D interface element.
Definition gmInt2dCellGeometryInfo.h:145
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 gmInt2dCellGeometryInfo.h:153
GmInt2DL6CellGeometryInfo(GmCellGeometryMetadata &&metadata)
Private constructor. Only a single Int2DL6 geometry info object is ever necessary,...
Definition gmInt2dCellGeometryInfo.h:165
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 gmInt2dCellGeometryInfo.h:142
GmShape specialization for a 2D coupled interface element with 6 nodes object with 4 nodes (x,...
Definition gmInt2DShape.h:174
The Int2DQ6 implementation.
Definition gmInt2dCellGeometryInfo.h:176
GmInt2DQ6CellGeometryInfo(GmCellGeometryMetadata &&metadata)
Protected constructor. Only a single Int2DQ6 geometry info object is ever necessary,...
Definition gmInt2dCellGeometryInfo.h:224
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 gmInt2dCellGeometryInfo.h:212
virtual void centroidCartesian(const GmMatrix &X, GmVector &coord) const
Returns the Int2DQ6 centroid as a Bar3 at the "mid edge".
Definition gmInt2dCellGeometryInfo.h:194
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 gmInt2dCellGeometryInfo.h:181
virtual double dimension(const GmMatrix &X) const
Returns the Int2DQ6 length at the "mid edge".
Definition gmInt2dCellGeometryInfo.h:184
virtual bool localAxis(const GmMatrix &X, GmMatrix &R) const
Local axis 2D interface element.
Definition gmInt2dCellGeometryInfo.h:204
GmShape specialization for a 2D quadratic interface element with 6 nodes object.
Definition gmInt2DShape.h:190
The Int2DQ8 implementation.
Definition gmInt2dCellGeometryInfo.h:236
GmInt2DQ8CellGeometryInfo(GmCellGeometryMetadata &&metadata)
Private constructor. Only a single Int2DQ8 geometry info object is ever necessary,...
Definition gmInt2dCellGeometryInfo.h:264
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 gmInt2dCellGeometryInfo.h:241
virtual bool localAxis(const GmMatrix &X, GmMatrix &R) const
Local axis 2D interface element.
Definition gmInt2dCellGeometryInfo.h:244
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 gmInt2dCellGeometryInfo.h:252
GmShape specialization for a 2D quadratic interface element with 8 nodes object 2 nodes (x,...
Definition gmInt2DShape.h:218
1D Gauss Integration rules (for bar elements)
Definition gmBarIntegrationRule.h:37
1D Lobatto Integration rules (for bar elements)
Definition gmBarIntegrationRule.h:84
1D Newton cotes Integration rules (for bar elements)
Definition gmBarIntegrationRule.h:60
Gauss integration rule for Quad element borders.
Definition gmQuadIntegrationRule.h:131
Lobatto integration rule for Quad element borders.
Definition gmQuadIntegrationRule.h:145
Shape function handling base classe.
Definition gmShape.h:38
Declaration of the GmLineXxxxIntegrationRule family of classes Content previously in gmIntegrationRul...
Declaration of the GmCellGeometryInfo base class.
Declaration of the GmCellGeometryIntegrationRuleSet class & friends.
@ GM_BAR3
A bar cell 2D with 3 nodes.
Definition gmCellType.h:33
#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.
Declaration of the 2D shapes for interface elements inheriting from GmShape class Previosuly part of ...
GmCellGeometryIntegrationRuleSetDefaultRules< GM_GAUSS_RULE_TYPE, 2, 2, 2, 2 > GmLinearInt2DIntegrationRuleSetDefaults
The set of default rules for a linear 2D interface ELEMENT. Template parameters 2 to 5 are the defaul...
Definition gmInt2dCellGeometryInfo.h:59
GmCellGeometryIntegrationRuleSetDefaultRules< GM_GAUSS_RULE_TYPE, 3, 3, 3, 3 > GmQuadraticInt2DIntegrationRuleSetDefaults
The set of default rules for a quadratic 2D interface ELEMENT. Template parameters 2 to 5 are the def...
Definition gmInt2dCellGeometryInfo.h:73
GmCellGeometryIntegrationRuleSetDefaultRules< GM_GAUSS_RULE_TYPE, 3, 3, -1, -1 > GmQuadraticInt2DEdgeIntegrationRuleSetDefaults
The set of default rules for a quadratic 2D interface EDGE. Template parameters 2 to 5 are the defaul...
Definition gmInt2dCellGeometryInfo.h:78
GmCellGeometryIntegrationRuleSetDefaultRules< GM_GAUSS_RULE_TYPE, 2, 2, -1, -1 > GmLinearInt2DEdgeIntegrationRuleSetDefaults
The set of default rules for a linear 2D interface EDGE. Template parameters 2 to 5 are the default r...
Definition gmInt2dCellGeometryInfo.h:64
GmCellGeometryIntegrationRuleSet< GmQuadGaussEdgeIntegrationRule, GmQuadLobattoEdgeIntegrationRule, GmCellGeometryNullIntegrationRule, GmCellGeometryNullIntegrationRule > GmInt2DEdgeIntegrationRuleSet
The set of possible EDGE integration rules, per integration rule type, for the family of 2D interface...
Definition gmInt2dCellGeometryInfo.h:50
GmCellGeometryIntegrationRuleSet< GmLineGaussIntegrationRule, GmLineLobattoIntegrationRule, GmLineNewtonIntegrationRule, GmLineNewtonIntegrationRule > GmInt2DIntegrationRuleSet
The set of possible ELEMENT integration rules, per integration rule type, for the family of 2D interf...
Definition gmInt2dCellGeometryInfo.h:42
@ 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
Declaration of the GmQuadXxxxIntegrationRule family of classes, including border rules....
arma::vec GmVector
The basic type for a GeMA vector object. Currently based on an Armadillo vector.
Definition gmVector.h:34
void edgeCentroid(const GmVector &p1, const GmVector &p2, GmVector &coord)
Returns the cartesian coordinate of the edge centroid.
Definition gmGeometryUtils.cpp:252
double edgeLength(const GmVector &p1, const GmVector &p2)
Calculates the length of the edge determined by points p1 and p2.
Definition gmGeometryUtils.cpp:153
bool polygon2DIsCCW(const GmMatrix &X)
Returns true if the polygon delimited by the cell vertices is oriented CCW.
Definition gmGeometryUtils.cpp:496
GmMatrix shuffle(const GmMatrix &X, const int order[], int size)
Returns quad8 vertices in circular order.
Definition gmGeometryUtils.cpp:581
Plane structure storing the full set of geometric metadata for a cell type.
Definition gmCellGeometryInfo.h:69