GemaCoreLib
The GeMA Core library
Loading...
Searching...
No Matches
gmTriCellGeometryInfo.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_TRI_CELL_GEOMETRY_INFO_H_
25#define _GEMA_TRI_CELL_GEOMETRY_INFO_H_
26
27#include "gmCellGeometryInfo.h"
29
30#include "gmGeometryUtils.h"
31
33#include "gmTriShape.h"
34
35//---------------------------------------------------------
36// Tri integration rules
37//---------------------------------------------------------
38
42
46
47
48//---------------------------------------------------------
49// Tri3 & Tri3D3 rule defaults
50//---------------------------------------------------------
51
56
61
62//---------------------------------------------------------
63// Tri6 & Tri3D6 rule defaults
64//---------------------------------------------------------
65
70
75
76
77//---------------------------------------------------------
78// GmTri3CellGeometryInfo
79//---------------------------------------------------------
80
83 : public GmCellGeometryInfoSurfaceElement<GmTriIntegrationRuleSet, GmLinearTriIntegrationRuleSetDefaults,
84 GmTriEdgeIntegrationRuleSet, GmLinearTriEdgeIntegrationRuleSetDefaults>
85{
86public:
87 static const GmTri3CellGeometryInfo* 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 GmTri3Shape; }
91
93 virtual double dimension(const GmMatrix& X) const
94 {
95 return GmGeometryUtils::triangleArea(X.col(0), X.col(1), X.col(2));
96 }
97
99 virtual void centroidCartesian(const GmMatrix& X, GmVector& coord) const
100 {
101 GmGeometryUtils::triangleCentroid(X.col(0), X.col(1), X.col(2), 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 virtual int isValid(const GmMatrix& X, double tol) const {
110 Q_UNUSED(tol);
111 int ret = GM_GEOMETRY_STATE_VALID;
112 if (!GmGeometryUtils::polygon2DIsCCW(X)) ret |= GM_GEOMETRY_STATE_BAD_ORIENTATION;
113 if (GmGeometryUtils::polygon2DIsSelfIntersecting(X)) ret |= GM_GEOMETRY_STATE_SELF_INTERSECT;
114 return ret;
115 }
116
117 // See comments on the base class
118 virtual bool contains(const GmMatrix& X, const GmVector& coord) const { return GmGeometryUtils::pointInConvexPolygon(X, coord); }
119
120protected:
125};
126
127//---------------------------------------------------------
128// GmTri3D3CellGeometryInfo
129//---------------------------------------------------------
130
133{
134public:
135 static const GmTri3D3CellGeometryInfo* instance();
136
137 // Shape factory. See comments on the base class.
138 virtual GmShape* shapeInstance(int P, int Q) const { Q_UNUSED(P); Q_UNUSED(Q); return new GmTri3D3Shape; }
139
140 // --------- Capabilities API ---------
141
142 virtual int isValid(const GmMatrix& X, double tol) const {
143 Q_UNUSED(tol);
144 int ret = GM_GEOMETRY_STATE_VALID;
145 if (GmGeometryUtils::tri3DIsColinear(X)) ret |= GM_GEOMETRY_STATE_SELF_INTERSECT;
146 return ret;
147 }
148 // contains() capability is currently not supported in 3D, so the implementation
149 // from GmTri3CellGeometryInfo must be overridden. Quality is ok.
150 virtual bool contains(const GmMatrix& X, const GmVector& coord) const { Q_UNUSED(X); Q_UNUSED(coord); return false; }
151
152
154 virtual bool localAxis(const GmMatrix&X, GmMatrix& R) const {Q_UNUSED(X); R = arma::eye(3, 3); return false; }
155
156private:
159};
160
161//---------------------------------------------------------
162// GmTri6CellGeometryInfo
163//---------------------------------------------------------
164
165//tri6 nodes in circular order
166static int tri6order[] = {0,3,1,4,2,5};
167
170 : public GmCellGeometryInfoSurfaceElement<GmTriIntegrationRuleSet, GmQuadraticTriIntegrationRuleSetDefaults,
171 GmTriEdgeIntegrationRuleSet, GmQuadraticTriEdgeIntegrationRuleSetDefaults>
172{
173public:
174 static const GmTri6CellGeometryInfo* instance();
175
176 // Shape factory. See comments on the base class.
177 virtual GmShape* shapeInstance(int P, int Q) const { Q_UNUSED(P); Q_UNUSED(Q); return new GmTri6Shape; }
178
180 virtual double dimension(const GmMatrix& X) const { return dimensionByIntegration(X); }
181
183 virtual void centroidCartesian(const GmMatrix& X, GmVector& coord) const { centroidByIntegration(X, coord); }
184
186 virtual bool localAxis(const GmMatrix&X, GmMatrix& R) const {Q_UNUSED(X); R = arma::eye(2, 2); return false; }
187
188 // --------- Capabilities API ---------
189
190 virtual int isValid(const GmMatrix& X, double tol) const {
191 Q_UNUSED(tol);
192 GmMatrix Xr = GmGeometryUtils::shuffle(X, tri6order, 6);
193 int ret = GM_GEOMETRY_STATE_VALID;
194 if (!GmGeometryUtils::polygon2DIsCCW(Xr)) ret |= GM_GEOMETRY_STATE_BAD_ORIENTATION;
195 if (GmGeometryUtils::polygon2DIsSelfIntersecting(Xr)) ret |= GM_GEOMETRY_STATE_SELF_INTERSECT;
196 return ret;
197 }
198
199 // See comments on the base class
200 virtual bool contains(const GmMatrix& X, const GmVector& coord) const { return GmGeometryUtils::pointInTesselatedPolygon_T6(X, coord); }
201
202protected:
207};
208
209//---------------------------------------------------------
210// GmTri3D6CellGeometryInfo
211//---------------------------------------------------------
212
215{
216public:
217 static const GmTri3D6CellGeometryInfo* instance();
218
219 // Shape factory. See comments on the base class.
220 virtual GmShape* shapeInstance(int P, int Q) const { Q_UNUSED(P); Q_UNUSED(Q); return new GmTri3D6Shape; }
221
222
224 virtual bool localAxis(const GmMatrix&X, GmMatrix& R) const {Q_UNUSED(X); R = arma::eye(3, 3); return false; }
225
226 // --------- Capabilities API ---------
227
228 virtual int isValid(const GmMatrix& X, double tol) const {
229 int ret = GM_GEOMETRY_STATE_VALID;
230 if (!GmGeometryUtils::polygon3DIsPlanar(GmGeometryUtils::shuffle(X, tri6order, 6), tol)) ret |= GM_GEOMETRY_STATE_NON_PLANAR;
231 if (GmGeometryUtils::tri3DIsColinear(X.cols(0, 2))) ret |= GM_GEOMETRY_STATE_SELF_INTERSECT;
232 return ret;
233 }
234
235 // contains() capability is currently not supported in 3D, so the implementation
236 // from GmTri6CellGeometryInfo must be overridden.
237 virtual bool contains(const GmMatrix& X, const GmVector& coord) const { Q_UNUSED(X); Q_UNUSED(coord); return false; }
238
239private:
242};
243
244
245#endif
246
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
Shape function handling base classe.
Definition gmShape.h:38
The Tri3 implementation.
Definition gmTriCellGeometryInfo.h:85
virtual void centroidCartesian(const GmMatrix &X, GmVector &coord) const
Returns the Tri3 centroid by calculating the mean of the vertices (simplex centroid)
Definition gmTriCellGeometryInfo.h:99
virtual double dimension(const GmMatrix &X) const
Returns the Tri3 area.
Definition gmTriCellGeometryInfo.h:93
virtual bool localAxis(const GmMatrix &X, GmMatrix &R) const
Local axis for Tri == Identity.
Definition gmTriCellGeometryInfo.h:105
GmTri3CellGeometryInfo(GmCellGeometryMetadata &&metadata)
Protected constructor. Only a single Tri3 geometry info object is ever necessary, created by GmTriCel...
Definition gmTriCellGeometryInfo.h:122
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 gmTriCellGeometryInfo.h:90
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 gmTriCellGeometryInfo.h:118
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 gmTriCellGeometryInfo.h:109
The Tri3D3 implementation.
Definition gmTriCellGeometryInfo.h:133
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 gmTriCellGeometryInfo.h:142
GmTri3D3CellGeometryInfo(const GmTri3CellGeometryInfo &tri3)
Private constructor. Only a single Tri3D3 geometry info object is ever necessary, created by GmTriCel...
Definition gmTriCellGeometryInfo.h:158
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 gmTriCellGeometryInfo.h:150
virtual bool localAxis(const GmMatrix &X, GmMatrix &R) const
Local axis for Tri == Identity.
Definition gmTriCellGeometryInfo.h:154
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 gmTriCellGeometryInfo.h:138
GmShape specialization for a 3D Triangle with 3 nodes object.
Definition gmTriShape.h:175
The Tri3D6 implementation.
Definition gmTriCellGeometryInfo.h:215
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 gmTriCellGeometryInfo.h:237
virtual bool localAxis(const GmMatrix &X, GmMatrix &R) const
Local axis for Tri == Identity.
Definition gmTriCellGeometryInfo.h:224
GmTri3D6CellGeometryInfo(const GmTri6CellGeometryInfo &tri6)
Private constructor. Only a single Tri3D6 geometry info object is ever necessary, created by GmTriCel...
Definition gmTriCellGeometryInfo.h:241
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 gmTriCellGeometryInfo.h:228
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 gmTriCellGeometryInfo.h:220
GmShape specialization for a 3D Triangle with 6 nodes object.
Definition gmTriShape.h:206
GmShape specialization for a Triangle with 3 nodes object.
Definition gmTriShape.h:115
The Tri6 implementation.
Definition gmTriCellGeometryInfo.h:172
virtual double dimension(const GmMatrix &X) const
Returns the Tri6 area by numeric integration.
Definition gmTriCellGeometryInfo.h:180
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 gmTriCellGeometryInfo.h:190
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 gmTriCellGeometryInfo.h:177
GmTri6CellGeometryInfo(GmCellGeometryMetadata &&metadata)
Protected constructor. Only a single Tri6 geometry info object is ever necessary, created by GmTriCel...
Definition gmTriCellGeometryInfo.h:204
virtual void centroidCartesian(const GmMatrix &X, GmVector &coord) const
Returns the Tri6 centroid by numeric integration.
Definition gmTriCellGeometryInfo.h:183
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 gmTriCellGeometryInfo.h:200
virtual bool localAxis(const GmMatrix &X, GmMatrix &R) const
Local axis for Tri == Identity.
Definition gmTriCellGeometryInfo.h:186
GmShape specialization for a Triangle with 6 nodes object.
Definition gmTriShape.h:149
Gauss integration rule for Tri element borders.
Definition gmTriIntegrationRule.h:96
Gauss Integration rule for triangle elements. Base on Felippa, IFEM, section 24.2.
Definition gmTriIntegrationRule.h:43
Newton Integration rule for triangle elements. Accepts both open and closed rules.
Definition gmTriIntegrationRule.h:66
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, 2, -1, -1, -1 > GmLinearTriEdgeIntegrationRuleSetDefaults
The set of default rules for a linear Tri EDGE. Template parameters 2 to 5 are the default rule numbe...
Definition gmTriCellGeometryInfo.h:60
GmCellGeometryIntegrationRuleSetDefaultRules< GM_GAUSS_RULE_TYPE, 3, -1, 1, 1 > GmLinearTriIntegrationRuleSetDefaults
The set of default rules for a linear Tri ELEMENT. Template parameters 2 to 5 are the default rule nu...
Definition gmTriCellGeometryInfo.h:55
GmCellGeometryIntegrationRuleSet< GmTriGaussIntegrationRule, GmCellGeometryNullIntegrationRule, GmTriNewtonIntegrationRule, GmTriNewtonIntegrationRule > GmTriIntegrationRuleSet
The set of possible ELEMENT integration rules, per integration rule type, for the family of Tri eleme...
Definition gmTriCellGeometryInfo.h:41
GmCellGeometryIntegrationRuleSetDefaultRules< GM_GAUSS_RULE_TYPE, 3, -1, -1, -1 > GmQuadraticTriEdgeIntegrationRuleSetDefaults
The set of default rules for a quadratic Tri EDGE. Template parameters 2 to 5 are the default rule nu...
Definition gmTriCellGeometryInfo.h:74
GmCellGeometryIntegrationRuleSet< GmTriGaussEdgeIntegrationRule, GmCellGeometryNullIntegrationRule, GmCellGeometryNullIntegrationRule, GmCellGeometryNullIntegrationRule > GmTriEdgeIntegrationRuleSet
The set of possible EDGE integration rules, per integration rule type, for the family of Tri elements...
Definition gmTriCellGeometryInfo.h:45
GmCellGeometryIntegrationRuleSetDefaultRules< GM_GAUSS_RULE_TYPE, 6, -1, 2, 2 > GmQuadraticTriIntegrationRuleSetDefaults
The set of default rules for a quadratic Tri ELEMENT. Template parameters 2 to 5 are the default rule...
Definition gmTriCellGeometryInfo.h:69
Declaration of the GmTriXxxxIntegrationRule family of classes, including border rules....
Declaration of the 2D tri 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 triangleCentroid(const GmVector &p1, const GmVector &p2, const GmVector &p3, GmVector &coord)
Returns the cartesian coordinate of the triangle centroid.
Definition gmGeometryUtils.cpp:262
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
double triangleArea(const GmVector &p1, const GmVector &p2, const GmVector &p3)
Calculates the area of the triangle determined by points p1, p2 and p3 (2D or 3D),...
Definition gmGeometryUtils.cpp:161
bool pointInTesselatedPolygon_T6(const GmMatrix &X, const GmVector &p)
Returns true if the point p is inside the tesselated T6 polygon or false otherwise.
Definition gmGeometryUtils.cpp:635
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
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