GemaCoreLib
The GeMA Core library
Loading...
Searching...
No Matches
gmInt2DShape.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_INT2D_SHAPE_H_
26#define _GEMA_INT2D_SHAPE_H_
27
28#include "gmShape.h"
29
30//--------------------------------------------------------------------------------------------------------------------------
31// 2D Interface Elements
32//--------------------------------------------------------------------------------------------------------------------------
33
42{
43public:
44 // See comments on the base class
45 virtual int numNaturalCoord() const { return 1; }
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(1); }
55
56 // See comments on the base class.
57 virtual bool translateEdgePoint(int edge, const GmVector& srcEdgeCoord, GmVector& elementCoord) const
58 {
59 Q_UNUSED(edge);
60 elementCoord = srcEdgeCoord; // edge and element coordinates are the same!!!
61 return !(edge % 2); // Returns true for edges 0 & 2 and false for edges 1 & 3, since those should not be used for integration
62 }
63
64 // See comments on the base class. Undefined for 2D interface elements.
65 virtual bool translateFacePoint(int face, const GmVector& srcFaceCoord, GmVector& elementCoord) const
66 {
67 Q_UNUSED(face); Q_UNUSED(srcFaceCoord); Q_UNUSED(elementCoord); return false;
68 }
69
70 virtual double shapeCartesianPartialsFromPJ(const GmMatrix& P, const GmMatrix& J, GmMatrix& dN, bool transposed = false) const;
71
72 // See comments on the base class
73 virtual double scaledJacobianDet(const GmMatrix& J) const
74 {
75 assert(J.n_elem == 2);
76 // Get dx/dxi and dy/dxi derivate. Remember that J might be transposed
77 double dx = J(0, 0);
78 double dy = (J.n_cols == 2) ? J(0, 1) : J(1, 0);
79 return sqrt(dx*dx + dy*dy);
80 }
81
82 // See comments on the base class
83 virtual void jacobianAndPartials(const GmVector& ncoord, const GmMatrix& X, GmMatrix& J,
84 GmMatrix& P, bool transposed = false) const;
85
86 // See comments on the base class
87 virtual void jacobianRotation(const GmMatrix& J, GmMatrix& R) const { jacRotation2D(J, R);}
88
89 // Undefined
90 virtual double borderScalingFactor(int border, const GmVector& borderCoord, const GmVector& elementCoord,
91 const GmMatrix& X, bool transposed = false) const
92 {
93 Q_UNUSED(border); Q_UNUSED(borderCoord); Q_UNUSED(elementCoord); Q_UNUSED(X); Q_UNUSED(transposed);
94 return 0.0;
95 }
96
97 // Undefined
98 virtual double edgeScalingFactor(int border, const GmVector& borderCoord, const GmVector& elementCoord,
99 const GmMatrix& X, bool transposed = false) const
100 {
101 Q_UNUSED(border); Q_UNUSED(borderCoord); Q_UNUSED(elementCoord); Q_UNUSED(X); Q_UNUSED(transposed);
102 return 0.0;
103 }
104
105 // Undefined
106 virtual double faceScalingFactor(int border, const GmVector& borderCoord, const GmVector& elementCoord,
107 const GmMatrix& X, bool transposed = false) const
108 {
109 Q_UNUSED(border); Q_UNUSED(borderCoord); Q_UNUSED(elementCoord); Q_UNUSED(X); Q_UNUSED(transposed);
110 return 0.0;
111 }
112
113 // See comments on the base class
114 void naturalToCartesian(const GmVector& ncoord, const GmMatrix& X, GmVector& coord) const;
115
116protected:
117 // See comments on the base class. At the moment we don't have a working version for interface elements
118 // Can we just reuse the Bar implementation for all elements?
119 virtual bool gradientBasedCartesianToNatural(const GmVector& coord, const GmMatrix& X, double tol,
120 int maxIter, double natTol, GmVector& ncoord, bool* inside) const
121 {
122 Q_UNUSED(coord); Q_UNUSED(X); Q_UNUSED(tol); Q_UNUSED(maxIter); Q_UNUSED(natTol); Q_UNUSED(ncoord); Q_UNUSED(inside);
123 return false;
124 }
125
126 virtual void midPlaneMatrix(const GmMatrix& X, GmMatrix& MX, bool transposed) const = 0;
127};
128
139{
140public:
141 // See comments on the base class
142 virtual GmCellType elemType() const { return GM_INT2DL4; }
143
144 // Returns the number of shape functions of this cohesive element (equal to the node number at middle plane)
145 virtual int numFunctions() const { return 2; }
146
147 // See comments on the base class
148 virtual void nodeNaturalCoord(int node, GmVector& coord) const;
149
150 virtual void shapeValues(const GmVector& ncoord, GmVector& N) const;
151 virtual void shapePartials(const GmVector& ncoord, GmMatrix& dN, bool transposed = false) const;
152
153protected:
154 // See comments on the base class
155 virtual bool hasGeometryBasedCartesianToNatural() const { return true; }
156
157 virtual bool geometryBasedCartesianToNatural(const GmVector& coord, const GmMatrix& X, double natTol,
158 GmVector& ncoord, bool* inside) const;
159
160 virtual void midPlaneMatrix(const GmMatrix& X, GmMatrix& MX, bool transposed) const;
161};
162
174{
175public:
176 // See comments on the base class
177 virtual GmCellType elemType() const { return GM_INT2DL6; }
178};
179
190{
191public:
192 // See comments on the base class
193 virtual GmCellType elemType() const { return GM_INT2DQ6; }
194
195 // Returns the number of shape functions of this interface element (equal to the node number at middle plane)
196 virtual int numFunctions() const { return 3; }
197
198 // See comments on the base class
199 virtual void nodeNaturalCoord(int node, GmVector& coord) const;
200
201 virtual void shapeValues(const GmVector& ncoord, GmVector& N) const;
202 virtual void shapePartials(const GmVector& ncoord, GmMatrix& dN, bool transposed = false) const;
203protected:
204 virtual void midPlaneMatrix(const GmMatrix& X, GmMatrix& MX, bool transposed) const;
205};
206
218{
219public:
220 // See comments on the base class
221 virtual GmCellType elemType() const { return GM_INT2DQ8; }
222};
223
224#endif
225
GmShape specialization for a 2D linear interface element with 4 nodes object.
Definition gmInt2DShape.h:139
virtual bool hasGeometryBasedCartesianToNatural() const
A virtual function that should be replaced to return true if the shape implements a geometry based al...
Definition gmInt2DShape.h:155
virtual int numFunctions() const
Returns the number of shape functions of this element type (equal to the number of nodes)
Definition gmInt2DShape.h:145
virtual GmCellType elemType() const
Returns the type of this element.
Definition gmInt2DShape.h:142
GmShape specialization for a 2D coupled interface element with 6 nodes object with 4 nodes (x,...
Definition gmInt2DShape.h:174
virtual GmCellType elemType() const
Returns the type of this element.
Definition gmInt2DShape.h:177
GmShape specialization for a 2D quadratic interface element with 6 nodes object.
Definition gmInt2DShape.h:190
virtual int numFunctions() const
Returns the number of shape functions of this element type (equal to the number of nodes)
Definition gmInt2DShape.h:196
virtual GmCellType elemType() const
Returns the type of this element.
Definition gmInt2DShape.h:193
GmShape specialization for a 2D quadratic interface element with 8 nodes object 2 nodes (x,...
Definition gmInt2DShape.h:218
virtual GmCellType elemType() const
Returns the type of this element.
Definition gmInt2DShape.h:221
GmShape specialization for Cohesive elements, containing common functions used to model fracture proc...
Definition gmInt2DShape.h:42
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 gmInt2DShape.h:51
virtual double scaledJacobianDet(const GmMatrix &J) const
Returns the Jacobian determinant multiplied by the scaling factor needed for transforming the differe...
Definition gmInt2DShape.h:73
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 gmInt2DShape.h:106
virtual void jacobianRotation(const GmMatrix &J, GmMatrix &R) const
Computes the rotation matrix from the jacobian axis. Useful for interface elements.
Definition gmInt2DShape.h:87
virtual int numCartesianCoord() const
Returns the number of cartesian coordinates expected by this element type.
Definition gmInt2DShape.h:48
virtual double edgeScalingFactor(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 edges. This has the same ef...
Definition gmInt2DShape.h:98
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 gmInt2DShape.h:90
virtual int numNaturalCoord() const
Returns the number of natural coordinates used by this element type.
Definition gmInt2DShape.h:45
virtual void naturalCenter(GmVector &coord) const
Fills the coord vector with the set of natural coordinates for the element center.
Definition gmInt2DShape.h:54
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 gmInt2DShape.h:65
virtual bool translateEdgePoint(int edge, const GmVector &srcEdgeCoord, GmVector &elementCoord) const
Given a "bar like" edge coordinate (from -1 to 1), at the given edge, fills elementCoord with the equ...
Definition gmInt2DShape.h:57
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 void naturalToCartesian(const GmVector &ncoord, const GmMatrix &X, GmVector &coord) const
Given a set of natural coordinates 'ncoord' and a matrix with node coordinates 'X',...
Definition gmShape.cpp:106
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 void jacobianAndPartials(const GmVector &ncoord, const GmMatrix &X, GmMatrix &J, GmMatrix &P, bool transposed=false) const =0
This function does the same calculations as the jacobian() call, but also filling the extra parameter...
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.
GmCellType
Mesh Cell types. Don't change type orders or add types without reading comments below.
Definition gmCellType.h:31
@ GM_INT2DL4
A 2D linear interface element with 4 nodes.
Definition gmCellType.h:45
@ GM_INT2DL6
A 2D linear interface element with 6 nodes (2 nodes of pore pressure dof at the middle)
Definition gmCellType.h:46
@ GM_INT2DQ6
A 2D quadratic interface element with 6 nodes.
Definition gmCellType.h:47
@ GM_INT2DQ8
A 2D quadratic interface element with 8 nodes (2 nodes of pore pressure dof at the middle)
Definition gmCellType.h:48
#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