![]() |
GemaCoreLib
The GeMA Core library
|
GmShape specialization for Quadrilaterals, containing common functions used by concrete Quad specializations, such as Quad4, Quad8 or Quad9. More...
#include <gmQuadShape.h>
Public Member Functions | |
virtual int | numNaturalCoord () const |
Returns the number of natural coordinates used by this element type. | |
virtual int | numCartesianCoord () const |
Returns the number of cartesian coordinates expected by this element type. | |
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 numNaturalCoord() - 1) | |
virtual void | naturalCenter (GmVector &coord) const |
Fills the coord vector with the set of natural coordinates for the element center. More... | |
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 equivalent element natural coordinate. Should be implemented for 2D & 3D elements. More... | |
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 triple for tri faces), at the given face, fills elementCoord with the equivalent element natural coordinate. Should be implemented for 3D elements. More... | |
virtual double | shapeCartesianPartialsFromPJ (const GmMatrix &P, const GmMatrix &J, GmMatrix &dN, bool transposed=false) const |
Alternative version of shapeCartesianPartialsXxxx() to calculate shape function partial derivatives with respect to its cartesian coordinates, given a previously calculated Jacobian matrix and a previously calculated shape function partial matrix. More... | |
virtual double | scaledJacobianDet (const GmMatrix &J) const |
Returns the Jacobian determinant multiplied by the scaling factor needed for transforming the differential area element. dOmega = dx.dy = J.dXi.dEta where J is the scaled Jacobian determinant. More... | |
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 P with the matrix of shape function partials. More... | |
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). This has the same effect as the jacobian determinant when integrating over the whole element. It can be used to treat 2D and 3D edge / face boundary conditions in a single code. More... | |
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 effect as the jacobian determinant when integrating over the whole element. More... | |
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 effect as the jacobian determinant when integrating over the whole element. More... | |
![]() | |
virtual GmCellType | elemType () const =0 |
Returns the type of this element. | |
virtual int | numFunctions () const =0 |
Returns the number of shape functions of this element type (equal to the number of nodes) | |
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. Node should be a value between 0 and numFunctions(). This is generally equal to the number of nodes but can be different for interface elements. More... | |
void | fillNaturalCoordinates (GmMatrix &coord, bool transposed=false) const |
Fills the coord matrix with the set of natural coordinates for the shape nodes. More... | |
virtual bool | cartesianToNatural (const GmVector &coord, const GmMatrix &X, GmVector &ncoord, bool *inside) const |
Given a set of cartesian coordinates 'coord' and a matrix with node coordinates 'X', calculates the corresponding natural coordinate filling 'ncoord'. The inside parameter is filled with true if the given cartesian coordinate is inside the element, false otherwise. More... | |
virtual bool | cartesianToNatural (const GmVector &coord, const GmMatrix &X, bool preferGeometric, double gradTol, int maxGradIter, double outsideNatTol, GmVector &ncoord, bool *inside) const |
Given a set of cartesian coordinates 'coord' and a matrix with node coordinates 'X', calculates the corresponding natural coordinate filling 'ncoord'. The inside parameter is filled with true if the given cartesian coordinate is inside the element, false otherwise. More... | |
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', calculates the corresponding cartesian coordinates filling 'coord'. More... | |
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. More... | |
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, evaluated at the given point. More... | |
virtual double | shapeCartesianPartialsFromCoord (const GmVector &ncoord, const GmMatrix &X, GmMatrix &dN, bool transposed=false) const |
Function used to calculate shape function partial derivatives with respect to its cartesian coordinates, evaluated at the given point. More... | |
virtual double | shapeCartesianPartialsFromJacobian (const GmVector &ncoord, const GmMatrix &J, GmMatrix &dN, bool transposed=false) const |
Alternative version of shapeCartesianPartials() to calculate shape function partial derivatives with respect to its cartesian coordinates, given a previously calculated Jacobian matrix. More... | |
virtual void | jacobian (const GmVector &ncoord, const GmMatrix &X, GmMatrix &J, bool transposed=false) const |
Calculates the jacobian matrix, relating cartesian coordinates to natural coordinates. More... | |
virtual const GmMatrix & | gaussExtrapolationMatrix (const GmIntegrationRule *ir) const |
Given an integration rule, compatible with the current element type, constructs an extrapolation matrix to calculate node values from integration point values. More... | |
virtual bool | pointExtrapolationMatrix (const GmMatrix &points, GmMatrix &em) const |
Given the set of 'm' natural coordinates in points, builds an 'n x m' extrapolation matrix that can be used to extrapolate values from an 'm' sized value vector to the 'n' elements nodes. More... | |
double | interpolate (const GmVector &nodeValues, const GmVector &ncoord) const |
Given a set of node values and a set of natural coordinates, interpolates the node values on the given coordinate. More... | |
Static Public Member Functions | |
static int | fixedEdgeCoord (int border) |
Given a border index referencing a Quad element edge, returns the index of the natural coordinate fixed over that edge. More... | |
static double | fixedEdgeValue (int border) |
Given a border index referencing a Quad element edge, returns the coordinate value for the the natural coordinate given by fixedEdgeCoord() More... | |
![]() | |
static bool | initShapeFunctions () |
Initializes the shape function module. Must be called BEFORE any calls to shapeFromElementType() or linearShapeFromElementType(), but AFTER the static initialization of the geometry objects. More... | |
static void | setConfigOptions (const GmSimulationData *simData) |
Updates the default config options used by the "simple" cartesianToNatural() call. | |
static const GmShape * | shapeFromElementType (GmCellType etype, int P, int Q) |
Returns a shape object suitable for handling elements of type etype. Parameters P and Q are needed only when working with hierarchical element types, such as GM_HQUADP or GM_HHEXP. They can be set to 0 for "common" element types. | |
static const GmShape * | linearShapeFromElementType (GmCellType etype, int P, int Q) |
Returns a linear shape object suitable for handling elements of type etype. Parameters P and Q are needed only when working with hierarchical element types, such as GM_HQUADP or GM_HHEXP. They can be set to 0 for "common" element types. | |
Protected Member Functions | |
virtual bool | gradientBasedCartesianToNatural (const GmVector &coord, const GmMatrix &X, double tol, int maxIter, double natTol, GmVector &ncoord, bool *inside) const |
![]() | |
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 independent, such as in line segments, quads and hexahedrons. More... | |
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 independent, such as in triangles and tetrahedrons. More... | |
bool | ginv (const GmMatrix &A, GmMatrix &inv) const |
Calculates the Moore-Penrose generalized matrix inverse for the 'm x n' matrix A, filling inv. More... | |
bool | gradientBasedCartesianToNaturalQuadHex (const GmVector &coord, const GmMatrix &X, double tol, int maxIter, double natTol, GmVector &ncoord, bool *inside) const |
Given a set of cartesian coordinates 'coord' and a matrix with node coordinates 'X', calculates the corresponding natural coordinate filling 'ncoord'. Returns true if the calculation succeeded, false otherwise. More... | |
bool | gradientBasedCartesianToNaturalTriTet (const GmVector &coord, const GmMatrix &X, double tol, int maxIter, double natTol, GmVector &ncoord, bool *inside) const |
An implementation of the gradient based cartesian to natural algorithm specific to Tri and Tet elements. For a description of the algorithm and function parameters, see gradientBasedCartesianToNaturalQuadHex(). | |
bool | gradientBasedCartesianToNaturalBar (const GmVector &coord, const GmMatrix &X, double tol, int maxIter, double natTol, GmVector &ncoord, bool *inside) const |
An implementation of the gradient based cartesian to natural algorithm specific to Bar elements. For a description of the algorithm and function parameters, see gradientBasedCartesianToNaturalQuadHex(). | |
bool | gradientBasedCartesianToNaturalWedge (const GmVector &coord, const GmMatrix &X, double tol, int maxIter, double natTol, GmVector &ncoord, bool *inside) const |
An implementation of the gradient based cartesian to natural algorithm specific to Wedge elements. For a description of the algorithm and function parameters, see gradientBasedCartesianToNaturalQuadHex(). | |
virtual bool | hasGeometryBasedCartesianToNatural () const |
A virtual function that should be replaced to return true if the shape implements a geometry based algorithm for converting cartesian coordinates to natural coordinates. In that case, geometryBasedCartesianToNatural() must also be reimplemented. | |
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 converting cartesian coordinates to natural coordinates. See the cartesianToNatural() description for the arguments description. | |
bool | checkAndClampNaturalCoordinate (double &ncoord, double min, double max, double natTol) const |
An utilitary function that given a natural coordinate component and its domain (given by min and max), checks that coord is inside the interval, possibly clamping it to the domain if outside by a little bit, controled by the given tolerance. More... | |
bool | checkAndClampBarycentricNaturalCoordinates (GmVector &ncoord, double natTol) const |
An utilitary function that given a set of 3 or 4 barycentric natural coordinates, checks for out of the triangle/tetrahedron values, possibly clamping it to the domain if outside by a little bit, controled by the given tolerance. More... | |
GmShape specialization for Quadrilaterals, containing common functions used by concrete Quad specializations, such as Quad4, Quad8 or Quad9.
Natural coordinates: Xi, Eta Natural coordinates domain: [-1, 1], [-1, 1]
|
inlinevirtual |
Returns the scaling factor needed when calculating integrals over borders (edges or faces). This has the same effect as the jacobian determinant when integrating over the whole element. It can be used to treat 2D and 3D edge / face boundary conditions in a single code.
For 2D elements it is equivalent to edgeScalingFactor() and for 3D elements to faceScalingFactor(). This function is undefined for line elements.
border | Defines the edge or face where the integration is taking place. |
borderCoord | Defines the integration point where the factor will be calculated in the border (edge or face) reference system. |
elementCoord | Defines the integration point where the factor will be calculated in the element reference system. It should have a dimension equal to numNaturalCoord(). |
X | The X matrix gives the cartesian coordinates of every node and should be organized as a 'd x n' matrix wher d is the number of dimension and n the number of shape functions. See the description given in jacobian(). |
transposed | If true, the X matrix should be the transposed of the matrix defined above. |
Implements GmShape.
|
virtual |
Returns the scaling factor needed when calculating integrals over element edges. This has the same effect as the jacobian determinant when integrating over the whole element.
This function is undefined for line elements.
border | Defines the edge where the integration is taking place. |
borderCoord | Defines the integration point where the factor will be calculated in the edge reference system. |
elementCoord | Defines the integration point where the factor will be calculated in the element reference system. It should have a dimension equal to numNaturalCoord(). |
X | The X matrix gives the cartesian coordinates of every node and should be organized as a 'd x n' matrix wher d is the number of dimension and n the number of shape functions. See the description given in jacobian(). |
transposed | If true, the X matrix should be the transposed of the matrix defined above. |
Implements GmShape.
|
inlinevirtual |
Returns the scaling factor needed when calculating integrals over element faces. This has the same effect as the jacobian determinant when integrating over the whole element.
This function is undefined for line or 2D elements.
border | Defines the face where the integration is taking place. |
borderCoord | Defines the integration point where the factor will be calculated in the face reference system. |
elementCoord | Defines the integration point where the factor will be calculated in the element reference system. It should have a dimension equal to numNaturalCoord(). |
X | The X matrix gives the cartesian coordinates of every node and should be organized as a 'd x n' matrix wher d is the number of dimension and n the number of shape functions. See the description given in jacobian(). |
transposed | If true, the X matrix should be the transposed of the matrix defined above. |
Implements GmShape.
|
static |
Given a border index referencing a Quad element edge, returns the index of the natural coordinate fixed over that edge.
Edge indices are numbered following the definition given by GmCellGeometry, which are the same for every Quad element.
|
static |
Given a border index referencing a Quad element edge, returns the coordinate value for the the natural coordinate given by fixedEdgeCoord()
Edge indices are numbered following the definition given by GmCellGeometry, which are the same for every Quad element.
|
inlinevirtual |
This function does the same calculations as the jacobian() call, but also filling the extra parameter P with the matrix of shape function partials.
When the user needs the partials P as well as the Jacobian matrix for its computations, this function saves the need to compute P twice (since it is used in the Jacobian computation).
The result matrix P has the same layout as a call to shapePartials(ncoord, P, transposed)
Implements GmShape.
|
inlinevirtual |
Fills the coord vector with the set of natural coordinates for the element center.
The resulting vector will have size equal to numNaturalCoord(). If coord holds a vector created by DECLARE_REF_VECTOR(), its size MUST already be equal to the expected result size.
Implements GmShape.
|
inlinevirtual |
Returns the Jacobian determinant multiplied by the scaling factor needed for transforming the differential area element. dOmega = dx.dy = J.dXi.dEta where J is the scaled Jacobian determinant.
See Felippa AFEM, appendix I, table I.3 / section I.2.4 or Felippa IFEM, chapters 17 (eq 17.20) and 24 (eq 24.7).
Implements GmShape.
|
virtual |
Alternative version of shapeCartesianPartialsXxxx() to calculate shape function partial derivatives with respect to its cartesian coordinates, given a previously calculated Jacobian matrix and a previously calculated shape function partial matrix.
This is the basic WORKER function for the previous two overloads. On a physics calculation calling one of the other two family functions is probably better...
P | The shape functions natural partials matrix, formated with the same transposed parameter passed to this function. |
J | The Jacobian matrix, formated with the same transposed parameter passed to this function. |
dN | Matrix filled with partial derivatives. If dN holds a matrix created by DECLARE_REF_MATRIX(), its size MUST already be equal to the expected size. |
transposed | If true, the result matrix will be transposed (and the J matrix format also). |
Implements GmShape.
|
virtual |
Given a "bar like" edge coordinate (from -1 to 1), at the given edge, fills elementCoord with the equivalent element natural coordinate. Should be implemented for 2D & 3D elements.
edge | The number of the edge for the source edge coordinate |
srcEdgeCoord | The edge coordinate (single value, from -1 to 1). |
elementCoord | The vector to be filled with element coordinates equivalent to srcEdgeCoord. After filled, elementCoord will be a vector with size equal to numNaturalCoord(). |
Implements GmShape.
|
inlinevirtual |
Given a "quad like" or "tri like" face coordinate (-1 to 1 pair for quad faces and 0 to 1 barycentric triple for tri faces), at the given face, fills elementCoord with the equivalent element natural coordinate. Should be implemented for 3D elements.
face | The number of the face for the source face coordinate |
srcFaceCoord | The face coordinate (-1 to 1 pair for quad faces and 0 to 1 barycentric triple for tri faces). |
elementCoord | The vector to be filled with element coordinates equivalent to srcFaceCoord. After filled, elementCoord will be a vector with size equal to numNaturalCoord(). |
Implements GmShape.