GemaCoreLib
The GeMA Core library
Loading...
Searching...
No Matches
gmQuadShape.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
25#ifndef _GEMA_QUAD_SHAPE_H_
26#define _GEMA_QUAD_SHAPE_H_
27
28#include "gmShape.h"
29
30//--------------------------------------------------------------------------------------------------------------------------
31// Quad Elements
32//--------------------------------------------------------------------------------------------------------------------------
33
42{
43public:
44 // See comments on the base class
45 virtual int numNaturalCoord() const { return 2; }
46
47 // See comments on the base class
48 virtual int numCartesianCoord() const { return 2; }
49
50 // See comments on the base class
51 virtual void naturalCoordLimits(int coord, double* min, double* max) const { Q_UNUSED(coord); *min = -1.0; *max = 1.0; }
52
53 // See comments on the base class
54 virtual void naturalCenter(GmVector& coord) const { coord.zeros(2); } // Center = (0.0, 0.0) for all quads
55
56 virtual bool translateEdgePoint(int edge, const GmVector& srcEdgeCoord, GmVector& elementCoord) const;
57
58 // See comments on the base class. Undefined for surface elements.
59 virtual bool translateFacePoint(int face, const GmVector& srcFaceCoord, GmVector& elementCoord) const
60 {
61 Q_UNUSED(face); Q_UNUSED(srcFaceCoord); Q_UNUSED(elementCoord); return false;
62 }
63
64 virtual double shapeCartesianPartialsFromPJ(const GmMatrix& P, const GmMatrix& J, GmMatrix& dN, bool transposed = false) const;
65
66 // See comments on the base class
67 virtual double scaledJacobianDet(const GmMatrix& J) const { return arma::det(J); }
68
69 // See comments on the base class
70 virtual void jacobianAndPartials(const GmVector& ncoord, const GmMatrix& X, GmMatrix& J, GmMatrix& P, bool transposed = false) const
71 {
72 jacIndependentNatCoord(ncoord, X, J, P, transposed);
73 }
74
75 // See comments on the base class
76 virtual void jacobianRotation(const GmMatrix& J, GmMatrix& R) const { jacRotation2D(J, R);}
77
78 // See comments on the base class
79 virtual double borderScalingFactor(int border, const GmVector& borderCoord, const GmVector& elementCoord,
80 const GmMatrix& X, bool transposed = false) const
81 {
82 return edgeScalingFactor(border, borderCoord, elementCoord, X, transposed);
83 }
84
85 virtual double edgeScalingFactor(int border, const GmVector& borderCoord, const GmVector& elementCoord,
86 const GmMatrix& X, bool transposed = false) const;
87
88 // See comments on the base class. Undefined for 2D elements.
89 virtual double faceScalingFactor(int border, const GmVector& borderCoord, const GmVector& elementCoord,
90 const GmMatrix& X, bool transposed = false) const
91 {
92 Q_UNUSED(border); Q_UNUSED(borderCoord); Q_UNUSED(elementCoord); Q_UNUSED(X); Q_UNUSED(transposed);
93 return 0.0;
94 }
95
96 // fixedEdgeCoord() & Value() are made static since they are "reused" by Int3DQFace shape functions
97 static int fixedEdgeCoord(int border);
98 static double fixedEdgeValue(int border);
99
100protected:
101
102 // See comments on the base class. Calls the default algorithm for Quad / Hex elements
103 virtual bool gradientBasedCartesianToNatural(const GmVector& coord, const GmMatrix& X, double tol,
104 int maxIter, double natTol, GmVector& ncoord, bool* inside) const
105 {
106 return gradientBasedCartesianToNaturalQuadHex(coord, X, tol, maxIter, natTol, ncoord, inside);
107 }
108};
109
110
121{
122public:
123 // See comments on the base class
124 virtual GmCellType elemType() const { return GM_QUAD4; }
125
126 // See comments on the base class
127 virtual int numFunctions() const { return 4; }
128
129 virtual void nodeNaturalCoord(int node, GmVector& coord) const;
130
131 virtual void shapeValues (const GmVector& ncoord, GmVector& N) const;
132 virtual void shapePartials(const GmVector& ncoord, GmMatrix& dN, bool transposed = false) const;
133
134protected:
135 // See comments on the base class
136 virtual bool hasGeometryBasedCartesianToNatural() const { return true; }
137
138 virtual bool geometryBasedCartesianToNatural(const GmVector& coord, const GmMatrix& X, double natTol,
139 GmVector& ncoord, bool* inside) const;
140};
141
152{
153public:
154 // See comments on the base class
155 virtual GmCellType elemType() const { return GM_QUAD8; }
156
157 // See comments on the base class
158 virtual int numFunctions() const { return 8; }
159
160 virtual void nodeNaturalCoord(int node, GmVector& coord) const;
161
162 // We previously had (by Erwan) a tentative implementation of a geometric method
163 // for cartesian to natural based on the paper "Distorsion measures ans inverse mapping
164 // for isoparametric 8-node plane finite elements with curved boundaries" - Lautersztajn (1998)
165 // but it didn't worked and was removed
166
167 virtual void shapeValues(const GmVector& ncoord, GmVector& N) const;
168 virtual void shapePartials(const GmVector& ncoord, GmMatrix& dN, bool transposed = false) const;
169};
170
182{
183public:
184 // See comments on the base class
185 virtual GmCellType elemType() const { return GM_QUAD9; }
186
187 // See comments on the base class
188 virtual int numFunctions() const { return 9; }
189
190 virtual void nodeNaturalCoord(int node, GmVector& coord) const;
191
192 virtual void shapeValues (const GmVector& ncoord, GmVector& N) const;
193 virtual void shapePartials(const GmVector& ncoord, GmMatrix& dN, bool transposed = false) const;
194};
195
206{
207public:
208 // See comments on the base class
209 virtual GmCellType elemType() const { return GM_QUAD3D4; }
210 virtual int numCartesianCoord() const { return 3; }
211
212 // See comments on the base class
213 virtual void jacIndependentNatCoord(const GmVector& ncoord, const GmMatrix& X, GmMatrix& J, GmMatrix& P, bool transposed) const;
214
215protected:
216 // Implementation of the geometric cartesian to natural method for Quad4 only works with 2D coordinates
217 virtual bool hasGeometryBasedCartesianToNatural() const { return false; }
218
219 // See comments on the base class. At the moment we don't have a working version for 3D quads
220 virtual bool gradientBasedCartesianToNatural(const GmVector& coord, const GmMatrix& X, double tol,
221 int maxIter, double natTol, GmVector& ncoord, bool* inside) const
222 {
223 Q_UNUSED(coord); Q_UNUSED(X); Q_UNUSED(tol); Q_UNUSED(maxIter); Q_UNUSED(natTol); Q_UNUSED(ncoord); Q_UNUSED(inside);
224 return false;
225 }
226
227};
228
239{
240public:
241 // See comments on the base class
242 virtual GmCellType elemType() const { return GM_QUAD3D8; }
243 virtual int numCartesianCoord() const { return 3; }
244
245 virtual void jacIndependentNatCoord(const GmVector& ncoord, const GmMatrix& X, GmMatrix& J, GmMatrix& P, bool transposed) const;
246
247protected:
248 // See comments on the base class. At the moment we don't have a working version for 3D quads
249 virtual bool gradientBasedCartesianToNatural(const GmVector& coord, const GmMatrix& X, double tol,
250 int maxIter, double natTol, GmVector& ncoord, bool* inside) const
251 {
252 Q_UNUSED(coord); Q_UNUSED(X); Q_UNUSED(tol); Q_UNUSED(maxIter); Q_UNUSED(natTol); Q_UNUSED(ncoord); Q_UNUSED(inside);
253 return false;
254 }
255};
256
257
258#endif
259
GmShape specialization for a 3D Quadrilateral with 4 nodes object.
Definition gmQuadShape.h:206
virtual bool hasGeometryBasedCartesianToNatural() const
A virtual function that should be replaced to return true if the shape implements a geometry based al...
Definition gmQuadShape.h:217
virtual GmCellType elemType() const
Returns the type of this element.
Definition gmQuadShape.h:209
virtual int numCartesianCoord() const
Returns the number of cartesian coordinates expected by this element type.
Definition gmQuadShape.h:210
GmShape specialization for a 3D Quadrilateral with 8 nodes object.
Definition gmQuadShape.h:239
virtual int numCartesianCoord() const
Returns the number of cartesian coordinates expected by this element type.
Definition gmQuadShape.h:243
virtual GmCellType elemType() const
Returns the type of this element.
Definition gmQuadShape.h:242
GmShape specialization for a Quadrilateral with 4 nodes object.
Definition gmQuadShape.h:121
virtual bool hasGeometryBasedCartesianToNatural() const
A virtual function that should be replaced to return true if the shape implements a geometry based al...
Definition gmQuadShape.h:136
virtual GmCellType elemType() const
Returns the type of this element.
Definition gmQuadShape.h:124
virtual int numFunctions() const
Returns the number of shape functions of this element type (equal to the number of nodes)
Definition gmQuadShape.h:127
GmShape specialization for a Quadrilateral with 8 nodes object.
Definition gmQuadShape.h:152
virtual GmCellType elemType() const
Returns the type of this element.
Definition gmQuadShape.h:155
virtual int numFunctions() const
Returns the number of shape functions of this element type (equal to the number of nodes)
Definition gmQuadShape.h:158
GmShape specialization for a Quadrilateral with 9 nodes object.
Definition gmQuadShape.h:182
virtual int numFunctions() const
Returns the number of shape functions of this element type (equal to the number of nodes)
Definition gmQuadShape.h:188
virtual GmCellType elemType() const
Returns the type of this element.
Definition gmQuadShape.h:185
GmShape specialization for Quadrilaterals, containing common functions used by concrete Quad speciali...
Definition gmQuadShape.h:42
virtual void jacobianRotation(const GmMatrix &J, GmMatrix &R) const
Computes the rotation matrix from the jacobian axis. Useful for interface elements.
Definition gmQuadShape.h:76
virtual bool translateFacePoint(int face, const GmVector &srcFaceCoord, GmVector &elementCoord) const
Given a "quad like" or "tri like" face coordinate (-1 to 1 pair for quad faces and 0 to 1 barycentric...
Definition gmQuadShape.h:59
virtual double scaledJacobianDet(const GmMatrix &J) const
Returns the Jacobian determinant multiplied by the scaling factor needed for transforming the differe...
Definition gmQuadShape.h:67
virtual int numNaturalCoord() const
Returns the number of natural coordinates used by this element type.
Definition gmQuadShape.h:45
virtual double faceScalingFactor(int border, const GmVector &borderCoord, const GmVector &elementCoord, const GmMatrix &X, bool transposed=false) const
Returns the scaling factor needed when calculating integrals over element faces. This has the same ef...
Definition gmQuadShape.h:89
virtual void jacobianAndPartials(const GmVector &ncoord, const GmMatrix &X, GmMatrix &J, GmMatrix &P, bool transposed=false) const
This function does the same calculations as the jacobian() call, but also filling the extra parameter...
Definition gmQuadShape.h:70
virtual void naturalCoordLimits(int coord, double *min, double *max) const
Fills min and max with the domain limits for the given natural coordinate (between 0 and numNaturalCo...
Definition gmQuadShape.h:51
virtual double borderScalingFactor(int border, const GmVector &borderCoord, const GmVector &elementCoord, const GmMatrix &X, bool transposed=false) const
Returns the scaling factor needed when calculating integrals over borders (edges or faces)....
Definition gmQuadShape.h:79
virtual int numCartesianCoord() const
Returns the number of cartesian coordinates expected by this element type.
Definition gmQuadShape.h:48
virtual void naturalCenter(GmVector &coord) const
Fills the coord vector with the set of natural coordinates for the element center.
Definition gmQuadShape.h:54
Shape function handling base classe.
Definition gmShape.h:38
virtual double shapeCartesianPartialsFromPJ(const GmMatrix &P, const GmMatrix &J, GmMatrix &dN, bool transposed=false) const =0
Alternative version of shapeCartesianPartialsXxxx() to calculate shape function partial derivatives w...
bool gradientBasedCartesianToNaturalQuadHex(const GmVector &coord, const GmMatrix &X, double tol, int maxIter, double natTol, GmVector &ncoord, bool *inside, double alpha=_newtonAlpha) const
Given a set of cartesian coordinates 'coord' and a matrix with node coordinates 'X',...
Definition gmShape.cpp:174
virtual void nodeNaturalCoord(int node, GmVector &coord) const =0
Fills the coord vector with the set of natural coordinates for the reference shape function node....
virtual double edgeScalingFactor(int border, const GmVector &borderCoord, const GmVector &elementCoord, const GmMatrix &X, bool transposed=false) const =0
Returns the scaling factor needed when calculating integrals over element edges. This has the same ef...
virtual bool geometryBasedCartesianToNatural(const GmVector &coord, const GmMatrix &X, double natTol, GmVector &ncoord, bool *inside) const
Virtual function that should be implemented if a shape can provide a geometric algorithm for converti...
Definition gmShape.h:433
virtual void shapePartials(const GmVector &ncoord, GmMatrix &dN, bool transposed=false) const =0
Function used to calculate shape function partial derivatives with respect to its natural coordinates...
virtual bool translateEdgePoint(int edge, const GmVector &srcEdgeCoord, GmVector &elementCoord) const =0
Given a "bar like" edge coordinate (from -1 to 1), at the given edge, fills elementCoord with the equ...
virtual void shapeValues(const GmVector &ncoord, GmVector &N) const =0
Function used to evaluate the set of shape functions over a point defined by its natural coordinates.
virtual void jacIndependentNatCoord(const GmVector &ncoord, const GmMatrix &X, GmMatrix &J, GmMatrix &P, bool transposed) const
A generic implementation of jacobianAndPartials() for the case where all natural coordinates are inde...
Definition gmShape.cpp:842
GmCellType
Mesh Cell types. Don't change type orders or add types without reading comments below.
Definition gmCellType.h:31
@ GM_QUAD9
A quadratic quadrilateral cell with 9 nodes.
Definition gmCellType.h:38
@ GM_QUAD4
A linear quadrilateral cell with only 4 nodes.
Definition gmCellType.h:36
@ GM_QUAD3D4
A 3D linear quadrilateral cell with only 4 nodes.
Definition gmCellType.h:39
@ GM_QUAD3D8
A 3D quadratic quadrilateral cell with 8 nodes.
Definition gmCellType.h:40
@ GM_QUAD8
A quadratic quadrilateral cell with 8 nodes.
Definition gmCellType.h:37
#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
arma::mat GmMatrix
The basic type for a GeMA matrix object. Currently based on an Armadillo matrix.
Definition gmMatrix.h:38
Declaration of the GmShape base class.
arma::vec GmVector
The basic type for a GeMA vector object. Currently based on an Armadillo vector.
Definition gmVector.h:34