GemaCoreLib
The GeMA Core library
Loading...
Searching...
No Matches
gmQuadCellGeometryInfo.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_QUAD_CELL_GEOMETRY_INFO_H_
25#define _GEMA_QUAD_CELL_GEOMETRY_INFO_H_
26
27#include "gmCellGeometryInfo.h"
29
30#include "gmGeometryUtils.h"
31
33#include "gmQuadShape.h"
34
35//---------------------------------------------------------
36// Quad integration rules
37//---------------------------------------------------------
38
42
46
47
48//---------------------------------------------------------
49// Quad4 & Quad3D4 rule defaults
50//---------------------------------------------------------
51
56
61
62//---------------------------------------------------------
63// Quad8, Quad3D8 & Quad9 rule defaults
64//---------------------------------------------------------
65
70
75
76
77//---------------------------------------------------------
78// GmQuad4CellGeometryInfo
79//---------------------------------------------------------
80
83 : public GmCellGeometryInfoSurfaceElement<GmQuadIntegrationRuleSet, GmLinearQuadIntegrationRuleSetDefaults,
84 GmQuadEdgeIntegrationRuleSet, GmLinearQuadEdgeIntegrationRuleSetDefaults>
85{
86public:
87 static const GmQuad4CellGeometryInfo* instance();
88
89 // Shape factory. See comments on the base class.
90 virtual GmShape* shapeInstance(int P, int Q) const { Q_UNUSED(P); Q_UNUSED(Q); return new GmQuad4Shape; }
91
93 virtual double dimension(const GmMatrix& X) const
94 {
95 return GmGeometryUtils::quadArea(X.col(0), X.col(1), X.col(2), X.col(3));
96 }
97
99 virtual void centroidCartesian(const GmMatrix& X, GmVector& coord) const
100 {
101 GmGeometryUtils::quadCentroid(X.col(0), X.col(1), X.col(2), X.col(3), coord);
102 }
103
105 virtual bool localAxis(const GmMatrix&X, GmMatrix& R) const {Q_UNUSED(X); R = arma::eye(2, 2); return false; }
106
107 // --------- Capabilities API ---------
108
109 // See comments on the base class
110 virtual int isValid(const GmMatrix& X, double tol) const
111 {
112 Q_UNUSED(tol);
113 int ret = GM_GEOMETRY_STATE_VALID;
114 if (!GmGeometryUtils::polygon2DIsCCW(X)) ret |= GM_GEOMETRY_STATE_BAD_ORIENTATION;
115 if (GmGeometryUtils::polygon2DIsSelfIntersecting(X)) ret |= GM_GEOMETRY_STATE_SELF_INTERSECT;
116 return ret;
117 }
118
119 // See comments on the base class
120 virtual bool contains(const GmMatrix& X, const GmVector& coord) const { return GmGeometryUtils::pointInConvexPolygon(X, coord); }
121
122protected:
127};
128
129//---------------------------------------------------------
130// GmQuad3D4CellGeometryInfo
131//---------------------------------------------------------
132
135{
136public:
137 static const GmQuad3D4CellGeometryInfo* instance();
138
139 // Shape factory. See comments on the base class.
140 virtual GmShape* shapeInstance(int P, int Q) const { Q_UNUSED(P); Q_UNUSED(Q); return new GmQuad3D4Shape; }
141
142 // --------- Capabilities API ---------
143
144 virtual int isValid(const GmMatrix& X, double tol) const {
145 int ret = GM_GEOMETRY_STATE_VALID;
146 if (!GmGeometryUtils::polygon3DIsPlanar(X, tol)) ret |= GM_GEOMETRY_STATE_NON_PLANAR;
147 return ret;
148 }
149
151 virtual bool localAxis(const GmMatrix&X, GmMatrix& R) const {Q_UNUSED(X); R = arma::eye(3, 3); return false; }
152
153 // contains() capabilities are currently not supported in 3D, so the implementation
154 // from Quad4CellGeometryInfo must be overridden. Quality is ok.
155 virtual bool contains(const GmMatrix& X, const GmVector& coord) const { Q_UNUSED(X); Q_UNUSED(coord); return false; }
156
157private:
160};
161
162
163//---------------------------------------------------------
164// GmQuad8CellGeometryInfo
165//---------------------------------------------------------
166
167//vertices in circular order
168static int quad8order[] = { 0,4,1,5,2,6,3,7 };
169
172 : public GmCellGeometryInfoSurfaceElement<GmQuadIntegrationRuleSet, GmQuadraticQuadIntegrationRuleSetDefaults,
173 GmQuadEdgeIntegrationRuleSet, GmQuadraticQuadEdgeIntegrationRuleSetDefaults>
174{
175public:
176 static const GmQuad8CellGeometryInfo* instance();
177
178 // Shape factory. See comments on the base class.
179 virtual GmShape* shapeInstance(int P, int Q) const { Q_UNUSED(P); Q_UNUSED(Q); return new GmQuad8Shape; }
180
182 virtual double dimension(const GmMatrix& X) const { return dimensionByIntegration(X); }
183
185 virtual void centroidCartesian(const GmMatrix& X, GmVector& coord) const { centroidByIntegration(X, coord); }
186
188 virtual bool localAxis(const GmMatrix&X, GmMatrix& R) const {Q_UNUSED(X); R = arma::eye(2, 2); return false; }
189
190 // --------- Capabilities API ---------
191
192 virtual int isValid(const GmMatrix & X, double tol) const {
193 Q_UNUSED(tol);
194 //reorder nodes
195 GmMatrix Xr = GmGeometryUtils::shuffle(X, quad8order, 8);
196 int ret = GM_GEOMETRY_STATE_VALID;
197 if (!GmGeometryUtils::polygon2DIsCCW(Xr)) ret |= GM_GEOMETRY_STATE_BAD_ORIENTATION;
198 if (GmGeometryUtils::polygon2DIsSelfIntersecting(Xr)) ret |= GM_GEOMETRY_STATE_SELF_INTERSECT;
199 return ret;
200 }
201
202 // See comments on the base class
203 virtual bool contains(const GmMatrix& X, const GmVector& coord) const { return GmGeometryUtils::pointInTesselatedPolygon_Q8(X, coord); }
204
205protected:
210};
211
212//---------------------------------------------------------
213// GmQuad3D8CellGeometryInfo
214//---------------------------------------------------------
215
218{
219public:
220 static const GmQuad3D8CellGeometryInfo* instance();
221
222 // Shape factory. See comments on the base class.
223 virtual GmShape* shapeInstance(int P, int Q) const { Q_UNUSED(P); Q_UNUSED(Q); return new GmQuad3D8Shape; }
224
225 // --------- Capabilities API ---------
226
227 virtual int isValid(const GmMatrix& X, double tol) const {
228 int ret = GM_GEOMETRY_STATE_VALID;
230 ret |= GM_GEOMETRY_STATE_NON_PLANAR;
231
232 return ret;
233 }
234
236 virtual bool localAxis(const GmMatrix&X, GmMatrix& R) const {Q_UNUSED(X); R = arma::eye(3, 3); return false; }
237
238 // No capabilities are currently supported in 3D, so the contains() implementation
239 // from Quad8CellGeometryInfo must be overridden.
240 virtual bool contains(const GmMatrix& X, const GmVector& coord) const { Q_UNUSED(X); Q_UNUSED(coord); return false; }
241
242private:
245};
246
247//---------------------------------------------------------
248// GmQuad9CellGeometryInfo
249//---------------------------------------------------------
250
253 : public GmCellGeometryInfoSurfaceElement<GmQuadIntegrationRuleSet, GmQuadraticQuadIntegrationRuleSetDefaults,
254 GmQuadEdgeIntegrationRuleSet, GmQuadraticQuadEdgeIntegrationRuleSetDefaults>
255{
256public:
257 static const GmQuad9CellGeometryInfo* instance();
258
259 // Shape factory. See comments on the base class.
260 virtual GmShape* shapeInstance(int P, int Q) const { Q_UNUSED(P); Q_UNUSED(Q); return new GmQuad9Shape; }
261
263 virtual double dimension(const GmMatrix& X) const { return dimensionByIntegration(X); }
264
266 virtual void centroidCartesian(const GmMatrix& X, GmVector& coord) const { centroidByIntegration(X, coord); }
267
269 virtual bool localAxis(const GmMatrix&X, GmMatrix& R) const {Q_UNUSED(X); R = arma::eye(2, 2); return false; }
270
271 // --------- Capabilities API ---------
272 virtual int isValid(const GmMatrix & X, double tol) const {
273 Q_UNUSED(tol);
274 //reorder nodes, ignores node 9 (center)
275 GmMatrix Xr = GmGeometryUtils::shuffle(X, quad8order, 8);
276 int ret = GM_GEOMETRY_STATE_VALID;
277 if (!GmGeometryUtils::polygon2DIsCCW(Xr)) ret |= GM_GEOMETRY_STATE_BAD_ORIENTATION;
278 if (GmGeometryUtils::polygon2DIsSelfIntersecting(Xr)) ret |= GM_GEOMETRY_STATE_SELF_INTERSECT;
279 return ret;
280 }
281private:
286};
287
288
289#endif
290
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 Quad3D4 implementation.
Definition gmQuadCellGeometryInfo.h:135
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 gmQuadCellGeometryInfo.h:155
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 gmQuadCellGeometryInfo.h:140
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 gmQuadCellGeometryInfo.h:144
virtual bool localAxis(const GmMatrix &X, GmMatrix &R) const
Local axis for Quad == Identity.
Definition gmQuadCellGeometryInfo.h:151
GmQuad3D4CellGeometryInfo(const GmQuad4CellGeometryInfo &quad4)
Private constructor. Only a single Quad3D4 geometry info object is ever necessary,...
Definition gmQuadCellGeometryInfo.h:159
GmShape specialization for a 3D Quadrilateral with 4 nodes object.
Definition gmQuadShape.h:206
The Quad3D8 implementation.
Definition gmQuadCellGeometryInfo.h:218
virtual bool localAxis(const GmMatrix &X, GmMatrix &R) const
Local axis for Quad == Identity.
Definition gmQuadCellGeometryInfo.h:236
GmQuad3D8CellGeometryInfo(const GmQuad8CellGeometryInfo &quad8)
Private constructor. Only a single Quad3D8 geometry info object is ever necessary,...
Definition gmQuadCellGeometryInfo.h:244
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 gmQuadCellGeometryInfo.h:223
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 gmQuadCellGeometryInfo.h:227
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 gmQuadCellGeometryInfo.h:240
GmShape specialization for a 3D Quadrilateral with 8 nodes object.
Definition gmQuadShape.h:239
The Quad4 implementation.
Definition gmQuadCellGeometryInfo.h:85
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 gmQuadCellGeometryInfo.h:90
virtual double dimension(const GmMatrix &X) const
Returns the Quad4 area.
Definition gmQuadCellGeometryInfo.h:93
virtual bool localAxis(const GmMatrix &X, GmMatrix &R) const
Local axis for Quad == Identity.
Definition gmQuadCellGeometryInfo.h:105
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 gmQuadCellGeometryInfo.h:110
virtual void centroidCartesian(const GmMatrix &X, GmVector &coord) const
Returns the Quad4 centroid by decomposing it into two triangles and weighting each coordinate by the ...
Definition gmQuadCellGeometryInfo.h:99
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 gmQuadCellGeometryInfo.h:120
GmQuad4CellGeometryInfo(GmCellGeometryMetadata &&metadata)
Protected constructor. Only a single Quad4 geometry info object is ever necessary,...
Definition gmQuadCellGeometryInfo.h:124
GmShape specialization for a Quadrilateral with 4 nodes object.
Definition gmQuadShape.h:121
The Quad8 implementation.
Definition gmQuadCellGeometryInfo.h:174
virtual void centroidCartesian(const GmMatrix &X, GmVector &coord) const
Returns the Quad8 centroid by numeric integration.
Definition gmQuadCellGeometryInfo.h:185
virtual bool localAxis(const GmMatrix &X, GmMatrix &R) const
Local axis for Quad == Identity.
Definition gmQuadCellGeometryInfo.h:188
GmQuad8CellGeometryInfo(GmCellGeometryMetadata &&metadata)
Protected constructor. Only a single Quad8 geometry info object is ever necessary,...
Definition gmQuadCellGeometryInfo.h:207
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 gmQuadCellGeometryInfo.h:203
virtual double dimension(const GmMatrix &X) const
Returns the Quad8 area by numeric integration.
Definition gmQuadCellGeometryInfo.h:182
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 gmQuadCellGeometryInfo.h:179
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 gmQuadCellGeometryInfo.h:192
GmShape specialization for a Quadrilateral with 8 nodes object.
Definition gmQuadShape.h:152
The Quad9 implementation.
Definition gmQuadCellGeometryInfo.h:255
virtual double dimension(const GmMatrix &X) const
Returns the Quad9 area by numeric integration.
Definition gmQuadCellGeometryInfo.h:263
GmQuad9CellGeometryInfo(const GmQuad8CellGeometryInfo &quad8)
Private constructor. Only a single Quad9 geometry info object is ever necessary, created by GmQuadCel...
Definition gmQuadCellGeometryInfo.h:283
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 gmQuadCellGeometryInfo.h:272
virtual void centroidCartesian(const GmMatrix &X, GmVector &coord) const
Returns the Quad9 centroid by numeric integration.
Definition gmQuadCellGeometryInfo.h:266
virtual bool localAxis(const GmMatrix &X, GmMatrix &R) const
Local axis for Quad == Identity.
Definition gmQuadCellGeometryInfo.h:269
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 gmQuadCellGeometryInfo.h:260
GmShape specialization for a Quadrilateral with 9 nodes object.
Definition gmQuadShape.h:182
Gauss integration rule for Quad element borders.
Definition gmQuadIntegrationRule.h:131
2D Isotropic / anisotropic Gauss integration rules for Quad elements
Definition gmQuadIntegrationRule.h:43
Lobatto integration rule for Quad element borders.
Definition gmQuadIntegrationRule.h:145
2D Isotropic / anisotropic Lobatto integration rules for Quad elements
Definition gmQuadIntegrationRule.h:89
2D Isotropic / anisotropic Newton cotes integration rules for Quad elements
Definition gmQuadIntegrationRule.h:66
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.
@ 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
GmCellGeometryIntegrationRuleSetDefaultRules< GM_GAUSS_RULE_TYPE, 3, 3, 3, 3 > GmQuadraticQuadIntegrationRuleSetDefaults
The set of default rules for a quadratic Quad ELEMENT. Template parameters 2 to 5 are the default rul...
Definition gmQuadCellGeometryInfo.h:69
GmCellGeometryIntegrationRuleSet< GmQuadGaussIntegrationRule, GmQuadLobattoIntegrationRule, GmQuadNewtonIntegrationRule, GmQuadNewtonIntegrationRule > GmQuadIntegrationRuleSet
The set of possible ELEMENT integration rules, per integration rule type, for the family of Quad elem...
Definition gmQuadCellGeometryInfo.h:41
GmCellGeometryIntegrationRuleSetDefaultRules< GM_GAUSS_RULE_TYPE, 3, 3, -1, -1 > GmQuadraticQuadEdgeIntegrationRuleSetDefaults
The set of default rules for a quadratic Quad EDGE. Template parameters 2 to 5 are the default rule n...
Definition gmQuadCellGeometryInfo.h:74
GmCellGeometryIntegrationRuleSetDefaultRules< GM_GAUSS_RULE_TYPE, 2, 2, -1, -1 > GmLinearQuadEdgeIntegrationRuleSetDefaults
The set of default rules for a linear Quad EDGE. Template parameters 2 to 5 are the default rule numb...
Definition gmQuadCellGeometryInfo.h:60
GmCellGeometryIntegrationRuleSetDefaultRules< GM_GAUSS_RULE_TYPE, 2, 2, 2, 2 > GmLinearQuadIntegrationRuleSetDefaults
The set of default rules for a linear Quad ELEMENT. Template parameters 2 to 5 are the default rule n...
Definition gmQuadCellGeometryInfo.h:55
GmCellGeometryIntegrationRuleSet< GmQuadGaussEdgeIntegrationRule, GmQuadLobattoEdgeIntegrationRule, GmCellGeometryNullIntegrationRule, GmCellGeometryNullIntegrationRule > GmQuadEdgeIntegrationRuleSet
The set of possible EDGE integration rules, per integration rule type, for the family of Quad element...
Definition gmQuadCellGeometryInfo.h:45
Declaration of the GmQuadXxxxIntegrationRule family of classes, including border rules....
Declaration of the 2D Quad shapes inheriting from GmShape class Previosuly part of the gmShape2D....
arma::vec GmVector
The basic type for a GeMA vector object. Currently based on an Armadillo vector.
Definition gmVector.h:34
void quadCentroid(const GmVector &p1, const GmVector &p2, const GmVector &p3, const GmVector &p4, GmVector &coord)
Returns the cartesian coordinate of the quad centroid.
Definition gmGeometryUtils.cpp:273
bool polygon3DIsPlanar(const GmMatrix &X, double tol)
Returns true if the polygon delimited by the cell vertices is planar.
Definition gmGeometryUtils.cpp:556
bool pointInConvexPolygon(const GmMatrix &X, const GmVector &p)
Returns true if the point p is inside the polygon delimited by the cell vertices (convex hull),...
Definition gmGeometryUtils.cpp:614
bool polygon2DIsSelfIntersecting(const GmMatrix &X)
Returns true if the polygon delimited by the cell vertices is self-intersecting, or false otherwise.
Definition gmGeometryUtils.cpp:467
bool polygon2DIsCCW(const GmMatrix &X)
Returns true if the polygon delimited by the cell vertices is oriented CCW.
Definition gmGeometryUtils.cpp:496
double quadArea(const GmVector &p1, const GmVector &p2, const GmVector &p3, const GmVector &p4)
Calculates the area of a quad defined by points p1 to p4 (2D or 3D), defined in CCW order.
Definition gmGeometryUtils.cpp:192
bool pointInTesselatedPolygon_Q8(const GmMatrix &X, const GmVector &p)
Returns true if the point p is inside the tesselated Q8 polygon or false otherwise.
Definition gmGeometryUtils.cpp:669
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