GemaCoreLib
The GeMA Core library
Loading...
Searching...
No Matches
gmHexShape.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_HEX_SHAPE_H_
26#define _GEMA_HEX_SHAPE_H_
27
28#include "gmShape.h"
29
30//--------------------------------------------------------------------------------------------------------------------------
31// Hex Elements
32//--------------------------------------------------------------------------------------------------------------------------
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 3; }
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(3); } // Center = (0.0, 0.0, 0.0) for all hexahedrons
55
56 virtual bool translateEdgePoint(int edge, const GmVector& srcEdgeCoord, GmVector& elementCoord) const;
57 virtual bool translateFacePoint(int face, const GmVector& srcFaceCoord, GmVector& elementCoord) const;
58
59 virtual double shapeCartesianPartialsFromPJ(const GmMatrix& P, const GmMatrix& J, GmMatrix& dN, bool transposed = false) const;
60
61 // See comments on the base class
62 virtual double scaledJacobianDet(const GmMatrix& J) const { return arma::det(J); }
63
64 // See comments on the base class
65 virtual void jacobianAndPartials(const GmVector& ncoord, const GmMatrix& X, GmMatrix& J, GmMatrix& P, bool transposed = false) const
66 {
67 jacIndependentNatCoord(ncoord, X, J, P, transposed);
68 }
69
70 // See comments on the base class
71 virtual void jacobianRotation(const GmMatrix& J, GmMatrix& R) const { jacRotation3D(J, R);}
72
73 // See comments on the base class
74 virtual double borderScalingFactor(int border, const GmVector& borderCoord, const GmVector& elementCoord,
75 const GmMatrix& X, bool transposed = false) const
76 {
77 return faceScalingFactor(border, borderCoord, elementCoord, X, transposed);
78 }
79
80 virtual double edgeScalingFactor(int border, const GmVector& borderCoord, const GmVector& elementCoord,
81 const GmMatrix& X, bool transposed = false) const;
82
83 virtual double faceScalingFactor(int border, const GmVector& borderCoord, const GmVector& elementCoord,
84 const GmMatrix& X, bool transposed = false) const;
85
86protected:
87 const int* fixedEdgeCoord(int border) const;
88 const double* fixedEdgeValue(int border) const;
89 int fixedFaceCoord(int border) const;
90 double fixedFaceValue(int border) const;
91
92 // See comments on the base class. Calls the default algorithm for Quad / Hex elements
93 virtual bool gradientBasedCartesianToNatural(const GmVector& coord, const GmMatrix& X, double tol,
94 int maxIter, double natTol, GmVector& ncoord, bool* inside) const
95 {
96 return gradientBasedCartesianToNaturalQuadHex(coord, X, tol, maxIter, natTol, ncoord, inside);
97 }
98 virtual void jacIndependentNatCoord(const GmVector& ncoord, const GmMatrix& X, GmMatrix& J, GmMatrix& P, bool transposed) const;
99};
100
110{
111public:
112 // See comments on the base class
113 virtual GmCellType elemType() const { return GM_HEX8; }
114
115 // See comments on the base class
116 virtual int numFunctions() const { return 8; }
117
118 virtual void nodeNaturalCoord(int node, GmVector& coord) const;
119
120 virtual void shapeValues(const GmVector& ncoord, GmVector& N) const;
121 virtual void shapePartials(const GmVector& ncoord, GmMatrix& dN, bool transposed = false) const;
122};
123
133{
134public:
135 // See comments on the base class
136 virtual GmCellType elemType() const { return GM_HEX20; }
137
138 // See comments on the base class
139 virtual int numFunctions() const { return 20; }
140
141 virtual void nodeNaturalCoord(int node, GmVector& coord) const;
142
143 virtual void shapeValues(const GmVector& ncoord, GmVector& N) const;
144 virtual void shapePartials(const GmVector& ncoord, GmMatrix& dN, bool transposed = false) const;
145};
146
156{
157public:
158 // See comments on the base class
159 virtual GmCellType elemType() const { return GM_HEX27; }
160
161 // See comments on the base class
162 virtual int numFunctions() const { return 27; }
163
164 virtual void nodeNaturalCoord(int node, GmVector& coord) const;
165
166 virtual void shapeValues(const GmVector& ncoord, GmVector& N) const;
167 virtual void shapePartials(const GmVector& ncoord, GmMatrix& dN, bool transposed = false) const;
168};
169
170
171#endif
172
GmShape specialization for a Hexahedron with 20 nodes object.
Definition gmHexShape.h:133
virtual int numFunctions() const
Returns the number of shape functions of this element type (equal to the number of nodes)
Definition gmHexShape.h:139
virtual GmCellType elemType() const
Returns the type of this element.
Definition gmHexShape.h:136
GmShape specialization for a Hexahedron with 27 nodes object.
Definition gmHexShape.h:156
virtual GmCellType elemType() const
Returns the type of this element.
Definition gmHexShape.h:159
virtual int numFunctions() const
Returns the number of shape functions of this element type (equal to the number of nodes)
Definition gmHexShape.h:162
GmShape specialization for a Hexahedron with 8 nodes object.
Definition gmHexShape.h:110
virtual GmCellType elemType() const
Returns the type of this element.
Definition gmHexShape.h:113
virtual int numFunctions() const
Returns the number of shape functions of this element type (equal to the number of nodes)
Definition gmHexShape.h:116
GmShape specialization for Hexahedrons, containing common functions used by concrete Hex specializati...
Definition gmHexShape.h:42
virtual int numCartesianCoord() const
Returns the number of cartesian coordinates expected by this element type.
Definition gmHexShape.h:48
virtual int numNaturalCoord() const
Returns the number of natural coordinates used by this element type.
Definition gmHexShape.h:45
virtual void naturalCenter(GmVector &coord) const
Fills the coord vector with the set of natural coordinates for the element center.
Definition gmHexShape.h:54
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 gmHexShape.h:65
virtual void jacobianRotation(const GmMatrix &J, GmMatrix &R) const
Computes the rotation matrix from the jacobian axis. Useful for interface elements.
Definition gmHexShape.h:71
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 gmHexShape.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 gmHexShape.h:74
virtual double scaledJacobianDet(const GmMatrix &J) const
Returns the Jacobian determinant multiplied by the scaling factor needed for transforming the differe...
Definition gmHexShape.h:62
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 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
virtual bool translateFacePoint(int face, const GmVector &srcFaceCoord, GmVector &elementCoord) const =0
Given a "quad like" or "tri like" face coordinate (-1 to 1 pair for quad faces and 0 to 1 barycentric...
virtual double faceScalingFactor(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 faces. This has the same ef...
GmCellType
Mesh Cell types. Don't change type orders or add types without reading comments below.
Definition gmCellType.h:31
@ GM_HEX20
An hexahedron(brick) with 20 nodes.
Definition gmCellType.h:50
@ GM_HEX27
An hexahedron(brick) with 27 nodes.
Definition gmCellType.h:51
@ GM_HEX8
A linear hexahedron (brick) with 8 nodes.
Definition gmCellType.h:49
#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