4.1.1.9.1.9. pyfem.util.shapeFunctions module

class shapeData[source]

Bases: object

Container for shape function data at a single integration point.

h

Shape function values at the integration point

dhdxi

Derivatives of shape functions w.r.t. parent coordinates

dhdx

Derivatives of shape functions w.r.t. physical coordinates

xi

Coordinates in parent element

x

Coordinates in physical element

weight

Integration weight

class elemShapeData[source]

Bases: object

Container for shape function data for an entire element.

Stores shape data for all integration points and provides iteration capability over the integration points.

getShapeLine2(xi: float) shapeData[source]

Shape functions for 1D linear line element with 2 nodes (Line2).

Computes shape functions and derivatives at a single integration point in the parent coordinate system.

Parameters:

xi – Location of the integration point in parent element

Returns:

Object containing h, dhdxi, and xi

Return type:

shapeData

Raises:

NotImplementedError – If input is not a float (1D only)

getShapeLine3(xi: float) shapeData[source]

Shape functions for 1D quadratic line element with 3 nodes (Line3).

Computes shape functions and derivatives at a single integration point in the parent coordinate system.

Parameters:

xi – Location of the integration point in parent element

Returns:

Object containing h, dhdxi, and xi

Return type:

shapeData

Raises:

NotImplementedError – If input is not a float (1D only)

getShapeTria3(xi: ndarray) shapeData[source]

Shape functions for 2D triangular element with 3 nodes (Tria3).

Computes shape functions and derivatives at a single integration point in the parent coordinate system.

Parameters:

xi – Location of integration point as ndarray of length 2

Returns:

Object containing h, dhdxi, and xi

Return type:

shapeData

Raises:

NotImplementedError – If input is not 2D (length != 2)

getShapeQuad4(xi: ndarray) shapeData[source]

Shape functions for 2D quadrilateral element with 4 nodes (Quad4).

Computes shape functions and derivatives at a single integration point in the parent coordinate system.

Parameters:

xi – Location of integration point as ndarray of length 2

Returns:

Object containing h, dhdxi, and xi

Return type:

shapeData

Raises:

NotImplementedError – If input is not 2D (length != 2)

getShapeTria6(xi: ndarray) shapeData[source]

Shape functions for 2D triangular element with 6 nodes (Tria6).

Computes shape functions and derivatives at a single integration point in the parent coordinate system.

Parameters:

xi – Location of integration point as ndarray of length 2

Returns:

Object containing h, dhdxi, and xi

Return type:

shapeData

Raises:

NotImplementedError – If input is not 2D (length != 2)

getShapeQuad8(xi: ndarray) shapeData[source]

Shape functions for 2D quadrilateral element with 8 nodes (Quad8).

Computes shape functions and derivatives at a single integration point in the parent coordinate system.

Parameters:

xi – Location of integration point as ndarray of length 2

Returns:

Object containing h, dhdxi, and xi

Return type:

shapeData

Raises:

NotImplementedError – If input is not 2D (length != 2)

getShapeQuad9(xi: ndarray) shapeData[source]

Shape functions for 2D quadrilateral element with 9 nodes (Quad9).

Computes shape functions and derivatives at a single integration point using tensor product of Line3 functions.

Parameters:

xi – Location of integration point as ndarray of length 2

Returns:

Object containing h, dhdxi, and xi

Return type:

shapeData

Raises:

NotImplementedError – If input is not 2D (length != 2)

getShapeTetra4(xi: ndarray) shapeData[source]

Shape functions for 3D tetrahedral element with 4 nodes (Tetra4).

Computes shape functions and derivatives at a single integration point in the parent coordinate system.

Parameters:

xi – Location of integration point as ndarray of length 3

Returns:

Object containing h, dhdxi, and xi

Return type:

shapeData

Raises:

NotImplementedError – If input is not 3D (length != 3)

getShapePyramid5(xi: ndarray) shapeData[source]

Shape functions for 3D pyramid element with 5 nodes (Pyramid5).

Computes shape functions and derivatives at a single integration point in the parent coordinate system.

Parameters:

xi – Location of integration point as ndarray of length 3

Returns:

Object containing h, dhdxi, and xi

Return type:

shapeData

Raises:

NotImplementedError – If input is not 3D (length != 3)

getShapePrism6(xi: ndarray) shapeData[source]

Shape functions for 3D prismatic element with 6 nodes (Prism6).

Computes shape functions using tensor product of Line2 and Tria3 functions.

Parameters:

xi – Location of integration point as ndarray of length 3

Returns:

Object containing h, dhdxi, and xi

Return type:

shapeData

Raises:

NotImplementedError – If input is not 3D (length != 3)

getShapePrism18(xi: ndarray) shapeData[source]

Shape functions for 3D prismatic element with 18 nodes (Prism18).

Computes shape functions using tensor product of Line3 and Tria6 functions.

Parameters:

xi – Location of integration point as ndarray of length 3

Returns:

Object containing h, dhdxi, and xi

Return type:

shapeData

Raises:

NotImplementedError – If input is not 3D (length != 3)

getShapeHexa8(xi: ndarray) shapeData[source]

Shape functions for 3D hexahedral element with 8 nodes (Hexa8).

Computes shape functions and derivatives at a single integration point in the parent coordinate system.

Parameters:

xi – Location of integration point as ndarray of length 3

Returns:

Object containing h, dhdxi, and xi

Return type:

shapeData

Raises:

NotImplementedError – If input is not 3D (length != 3)

getElemType(elemCoords: ndarray) str[source]

Determine element type from nodal coordinates.

Returns the element type name based on the shape and number of nodes in the element.

Parameters:

elemCoords – Array of nodal coordinates with shape (nNodes, nDimensions)

Returns:

Element type name
  • 1D: ‘Line2’, ‘Line3’

  • 2D: ‘Tria3’, ‘Tria6’, ‘Quad4’, ‘Quad8’, ‘Quad9’

  • 3D: ‘Tetra4’, ‘Pyramid5’, ‘Prism6’, ‘Prism18’, ‘Hexa8’

Return type:

str

Raises:

NotImplementedError – If element type not supported or rank is not 1, 2, or 3

tria_scheme(order: int) Tuple[List[List[float]], List[float]][source]

Integration scheme for 2D triangular elements.

Returns integration point coordinates and weights for triangular elements.

Parameters:

order – Integration order (1, 3, or 7 integration points)

Returns:

  • List of integration point coordinates in parent element

  • List of corresponding integration weights

Return type:

Tuple of

Raises:

NotImplementedError – If order is not 1, 3, or 7

tetra_scheme(order: int) Tuple[List[List[float]], List[float]][source]

Integration scheme for 3D tetrahedral elements.

Returns integration point coordinates and weights for tetrahedral elements.

Parameters:

order – Integration order (1 for single integration point)

Returns:

  • List of integration point coordinates in parent element

  • List of corresponding integration weights

Return type:

Tuple of

Raises:

NotImplementedError – If order is not 1

pyramid_scheme(order: int) Tuple[List[List[float]], List[float]][source]

Integration scheme for 3D pyramid elements.

Returns integration point coordinates and weights for pyramid elements.

Parameters:

order – Integration order (1 for single integration point)

Returns:

  • List of integration point coordinates in parent element

  • List of corresponding integration weights

Return type:

Tuple of

Raises:

NotImplementedError – If order is not 1

getIntegrationPoints(elemType: str, order: int, scheme: str) Tuple[List[List[float]], List[float]][source]

Get integration points and weights for any element type.

Returns integration scheme (coordinates and weights) for any supported element type. Allows modification of standard integration order.

Parameters:
  • elemType – Element type name - 1D: ‘Line2’, ‘Line3’ - 2D: ‘Tria3’, ‘Tria6’, ‘Quad4’, ‘Quad8’, ‘Quad9’ - 3D: ‘Tetra4’, ‘Pyramid5’, ‘Prism6’, ‘Prism18’, ‘Hexa8’

  • order – Integration order adjustment - 0: Standard integration for element type - +1: Higher order integration - -1: Lower order integration

  • scheme – Integration scheme name (e.g., ‘Gauss’)

Returns:

  • List of integration point coordinates

  • List of integration weights

Return type:

Tuple of

Raises:

NotImplementedError – If element type is unknown

calcWeightandDerivatives(elemCoords: ndarray, sData: shapeData, weight: float) None[source]

Calculate physical derivatives and integration weight.

Computes the derivatives of shape functions with respect to physical coordinates and the weighted integration weight using the Jacobian transformation. Results are stored in sData.

Parameters:
  • elemCoords – Array of nodal coordinates (nNodes, nDimensions)

  • sData – Shape data object containing dhdxi and xi

  • weight – Integration weight in parent element

Modifies:

sData.dhdx: Derivatives w.r.t. physical coordinates sData.weight: Integration weight in physical element

getElemShapeData(elemCoords: ndarray, order: int = 0, method: str = 'Gauss', elemType: str = 'Default') elemShapeData[source]

Get shape function and integration data for an element.

Determines element type, generates integration points, and computes shape functions and physical derivatives at each integration point.

Parameters:
  • elemCoords – Array of nodal coordinates (nNodes, nDimensions)

  • order – Integration order adjustment (default 0)

  • method – Integration scheme name, e.g., ‘Gauss’ (default)

  • elemType – Element type name. If ‘Default’, determined from elemCoords

Returns:

Object containing shape data for all integration points

Return type:

elemShapeData

Raises:

NotImplementedError – If element type is unknown

getShapeData(order: int = 0, method: str = 'Gauss', elemType: str = 'Default') elemShapeData[source]

Get shape function and integration data for an element type.

Generates integration points and computes shape functions and parent element derivatives at each integration point. Does not compute physical derivatives.

Parameters:
  • order – Integration order adjustment (default 0)

  • method – Integration scheme name, e.g., ‘Gauss’ (default)

  • elemType – Element type name (required)

Returns:

Object containing shape data for all integration points

Return type:

elemShapeData

Raises:

NotImplementedError – If element type is unknown