GemaCoreLib
The GeMA Core library
Loading...
Searching...
No Matches
gmTriShape.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_TRI_SHAPE_H_
26#define _GEMA_TRI_SHAPE_H_
27
28#include "gmShape.h"
29
30
31//--------------------------------------------------------------------------------------------------------------------------
32// Tri Elements
33//--------------------------------------------------------------------------------------------------------------------------
42{
43public:
44 // See comments on the base class
45 virtual int numNaturalCoord() const { return 3; }
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 = 0.0; *max = 1.0; }
52
53 // See comments on the base class
54 virtual void naturalCenter(GmVector& coord) const { coord.set_size(3); coord.fill(1/3.0); } // Center = (1/3, 1/3, 1/3) for all triangles
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 0.5 * 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 jacDependentNatCoord(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 // See comments on the base class. Undefined for 2D elements.
86 virtual double faceScalingFactor(int border, const GmVector& borderCoord, const GmVector& elementCoord,
87 const GmMatrix& X, bool transposed = false) const
88 {
89 Q_UNUSED(border); Q_UNUSED(borderCoord); Q_UNUSED(elementCoord); Q_UNUSED(X); Q_UNUSED(transposed);
90 return 0.0;
91 }
92
93 // fixedEdgeCoord() is made static since it is "reused" by Int3DTFace shape functions
94 static int fixedEdgeCoord(int border);
95
96protected:
97
98 // See comments on the base class. Calls the default algorithm for Tri / Tet elements
99 virtual bool gradientBasedCartesianToNatural(const GmVector& coord, const GmMatrix& X, double tol,
100 int maxIter, double natTol, GmVector& ncoord, bool* inside) const
101 {
102 return gradientBasedCartesianToNaturalTriTet(coord, X, tol, maxIter, natTol, ncoord, inside);
103 }
104};
105
115{
116public:
117 // See comments on the base class
118 virtual GmCellType elemType() const { return GM_TRI3; }
119
120 // See comments on the base class
121 virtual int numFunctions() const { return 3; }
122
123 virtual void nodeNaturalCoord(int node, GmVector& coord) const;
124
125 virtual void shapeValues(const GmVector& ncoord, GmVector& N) const;
126 virtual void shapePartials(const GmVector& ncoord, GmMatrix& dN, bool transposed = false) const;
127
128 virtual double edgeScalingFactor(int border, const GmVector& borderCoord, const GmVector& elementCoord,
129 const GmMatrix& X, bool transposed = false) const;
130
131protected:
132 // See comments on the base class
133 virtual bool hasGeometryBasedCartesianToNatural() const { return true; }
134
135 virtual bool geometryBasedCartesianToNatural(const GmVector& coord, const GmMatrix& X, double natTol,
136 GmVector& ncoord, bool* inside) const;
137};
138
149{
150public:
151 // See comments on the base class
152 virtual GmCellType elemType() const { return GM_TRI6; }
153
154 // See comments on the base class
155 virtual int numFunctions() const { return 6; }
156
157 virtual void nodeNaturalCoord(int node, GmVector& coord) const;
158
159 virtual void shapeValues(const GmVector& ncoord, GmVector& N) const;
160 virtual void shapePartials(const GmVector& ncoord, GmMatrix& dN, bool transposed = false) const;
161
162 virtual double edgeScalingFactor(int border, const GmVector& borderCoord, const GmVector& elementCoord,
163 const GmMatrix& X, bool transposed = false) const;
164};
165
175{
176public:
177 // See comments on the base class
178 virtual GmCellType elemType() const { return GM_TRI3D3; }
179 virtual int numCartesianCoord() const { return 3; }
180
181 virtual void jacDependentNatCoord(const GmVector& ncoord, const GmMatrix& X, GmMatrix& J, GmMatrix& P, bool transposed) const;
182
183protected:
184 // Implementation of the geometric cartesian to natural method for Tri3 only works with 2D coordinates
185 virtual bool hasGeometryBasedCartesianToNatural() const { return false; }
186
187 // See comments on the base class. At the moment we don't have a working version for 3D triangles
188 virtual bool gradientBasedCartesianToNatural(const GmVector& coord, const GmMatrix& X, double tol,
189 int maxIter, double natTol, GmVector& ncoord, bool* inside) const
190 {
191 Q_UNUSED(coord); Q_UNUSED(X); Q_UNUSED(tol); Q_UNUSED(maxIter); Q_UNUSED(natTol); Q_UNUSED(ncoord); Q_UNUSED(inside);
192 return false;
193 }
194};
195
206{
207public:
208 // See comments on the base class
209 virtual GmCellType elemType() const { return GM_TRI3D6; }
210 virtual int numCartesianCoord() const { return 3; }
211
212 virtual void jacDependentNatCoord(const GmVector& ncoord, const GmMatrix& X, GmMatrix& J, GmMatrix& P, bool transposed) const;
213
214protected:
215 // See comments on the base class. At the moment we don't have a working version for 3D triangles
216 virtual bool gradientBasedCartesianToNatural(const GmVector& coord, const GmMatrix& X, double tol,
217 int maxIter, double natTol, GmVector& ncoord, bool* inside) const
218 {
219 Q_UNUSED(coord); Q_UNUSED(X); Q_UNUSED(tol); Q_UNUSED(maxIter); Q_UNUSED(natTol); Q_UNUSED(ncoord); Q_UNUSED(inside);
220 return false;
221 }
222};
223
224#endif
225
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...
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...
bool gradientBasedCartesianToNaturalTriTet(const GmVector &coord, const GmMatrix &X, double tol, int maxIter, double natTol, GmVector &ncoord, bool *inside, double alpha=_newtonAlpha) const
An implementation of the gradient based cartesian to natural algorithm specific to Tri and Tet elemen...
Definition gmShape.cpp:241
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 jacDependentNatCoord(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 NOT ...
Definition gmShape.cpp:864
GmShape specialization for a 3D Triangle with 3 nodes object.
Definition gmTriShape.h:175
virtual GmCellType elemType() const
Returns the type of this element.
Definition gmTriShape.h:178
virtual bool hasGeometryBasedCartesianToNatural() const
A virtual function that should be replaced to return true if the shape implements a geometry based al...
Definition gmTriShape.h:185
virtual int numCartesianCoord() const
Returns the number of cartesian coordinates expected by this element type.
Definition gmTriShape.h:179
GmShape specialization for a 3D Triangle with 6 nodes object.
Definition gmTriShape.h:206
virtual int numCartesianCoord() const
Returns the number of cartesian coordinates expected by this element type.
Definition gmTriShape.h:210
virtual GmCellType elemType() const
Returns the type of this element.
Definition gmTriShape.h:209
GmShape specialization for a Triangle with 3 nodes object.
Definition gmTriShape.h:115
virtual GmCellType elemType() const
Returns the type of this element.
Definition gmTriShape.h:118
virtual int numFunctions() const
Returns the number of shape functions of this element type (equal to the number of nodes)
Definition gmTriShape.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 gmTriShape.h:133
GmShape specialization for a Triangle with 6 nodes object.
Definition gmTriShape.h:149
virtual GmCellType elemType() const
Returns the type of this element.
Definition gmTriShape.h:152
virtual int numFunctions() const
Returns the number of shape functions of this element type (equal to the number of nodes)
Definition gmTriShape.h:155
GmShape specialization for Triangles, containing common functions used by concrete Tri specialization...
Definition gmTriShape.h:42
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 gmTriShape.h:70
virtual void jacobianRotation(const GmMatrix &J, GmMatrix &R) const
Computes the rotation matrix from the jacobian axis. Useful for interface elements.
Definition gmTriShape.h:76
virtual void naturalCenter(GmVector &coord) const
Fills the coord vector with the set of natural coordinates for the element center.
Definition gmTriShape.h:54
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 gmTriShape.h:79
virtual double scaledJacobianDet(const GmMatrix &J) const
Returns the Jacobian determinant multiplied by the scaling factor needed for transforming the differe...
Definition gmTriShape.h:67
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 gmTriShape.h:51
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 gmTriShape.h:59
virtual int numNaturalCoord() const
Returns the number of natural coordinates used by this element type.
Definition gmTriShape.h:45
virtual int numCartesianCoord() const
Returns the number of cartesian coordinates expected by this element type.
Definition gmTriShape.h:48
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 gmTriShape.h:86
GmCellType
Mesh Cell types. Don't change type orders or add types without reading comments below.
Definition gmCellType.h:31
@ GM_TRI3
A linear triangle with only 3 nodes.
Definition gmCellType.h:41
@ GM_TRI3D3
A 3D linear triangle with only 3 nodes.
Definition gmCellType.h:43
@ GM_TRI3D6
A 3D quadratic triangle with 6 nodes.
Definition gmCellType.h:44
@ GM_TRI6
A quadratic triangle with 6 nodes.
Definition gmCellType.h:42
#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