Shape functions collection (1D, 2D)#

Description and mathematical background#

The package pysdic provides shape functions for various types of elements used in finite element analysis. Shape functions are mathematical functions that describe how the displacement within an element varies with respect to its nodal displacements.

In a space of dimension \(E\), we consider a \(K\)-dimensional element (with \(K \leq E\)) defined by \(N_{vpe}\) nodes/vertices.

For an \(K\)-dimensional element defined by \(N_{vpe}\) nodes, points inside the element are represented in a local coordinate system \((\xi, \eta, \zeta, ...)\) also named natural coordinates. Shape functions are defined in this local coordinate system in order to interpolate values at any point within the element based on the values at the nodes.

\[P(\xi, \eta, \zeta, ...) = \sum_{i=1}^{N_{vpe}} N_i(\xi, \eta, \zeta, ...) P_i\]

where \(P\) is the interpolated value at the point, \(N_i\) are the shape functions, and \(P_i\) are the nodal values.

See also

Function signatures#

All of the shape function methods follow a similar interface.

Note

Parameters

natural_coordinates: Arraylike

Natural coordinates where to evaluate the shape functions. The array must have shape \((N_{p}, K)\), where \(N_{p}\) is the number of points to evaluate and \(K\) is the dimension of the element.

return_derivatives: bool, optional

If True, the method also returns the derivatives of the shape functions with respect to the natural coordinates. Default is False.

default: Real, optional

The default value to assign to shape functions for points outside the valid range. Default is 0.0.

Returns

shape_functions: numpy.ndarray

Shape functions evaluated at the given natural coordinates. The returned array has shape \((N_{p}, N_{vpe})\), where each row corresponds to a point and each column to a node.

shape_function_derivatives: numpy.ndarray, optional

If return_derivatives is True, the function also returns an array of the first derivatives of the shape functions with respect to the natural coordinates. The returned array has shape \((N_{p}, N_{vpe}, K)\), where each slice along the first dimension corresponds to a point, each column to a node, and each slice along the last dimension to a natural coordinate direction.

Usage#

Lets illustrate the usage of the shape functions with an example. We will compute the shape functions for a 2-node line element (segment_2) at 3 valid points and 1 invalid point.

 1import numpy
 2import pysdic
 3
 4# Define the natural coordinate where to evaluate the shape functions
 5natural_coordinates = numpy.array([[-1.0], [0.0], [1.0], [1.5]])
 6print("Expected shape of natural_coordinates: (Np, K)")
 7print("Natural coordinates shape:", natural_coordinates.shape)
 8
 9# Compute the shape functions for a 2-node line element (segment_2)
10shape_functions = pysdic.compute_segment_2_shape_functions(natural_coordinates)
11print("Expected shape of shape_functions: (Np, Nvpe)")
12print("Shape functions shape:", shape_functions.shape)
13print("Shape function values:")
14print(shape_functions)
Expected shape of natural_coordinates: (Np, K)
Natural coordinates shape: (4, 1)
Expected shape of shape_functions: (Np, Nvpe)
Shape functions shape: (4, 2)
Shape function values:
[[1. 0.]
 [0.5 0.5]
 [0. 1.]
 [0. 0.]]

Implemented shape functions#

1-Dimensional elements#

compute_segment_2_shape_functions

Compute the shape functions for a 2-node segment for given natural_coordinates \(\xi\).

compute_segment_3_shape_functions

Compute the shape functions for a 3-node segment for given natural_coordinates \(\xi\).

2-Dimensional elements#

compute_triangle_3_shape_functions

Compute the shape functions for a 3-node triangle for given natural_coordinates \((\xi, \eta)\).

compute_triangle_6_shape_functions

Compute the shape functions for a 6-node triangle for given natural_coordinates \((\xi, \eta)\).

compute_quadrangle_4_shape_functions

Compute the shape functions for a 4-node quadrangle for given natural_coordinates \((\xi, \eta)\).

compute_quadrangle_8_shape_functions

Compute the shape functions for a 8-node quadrangle for given natural_coordinates \((\xi, \eta)\).

3-Dimensional elements#

Note

3D shape functions are not yet implemented. Please contact the maintainers if you need this feature.

Dispatcher function#

compute_shape_functions

Compute the shape functions for a given element_type at specified natural_coordinates.

References elements for implemented shape functions#

Element Type

Reference Element

segment_2 (2-node line element)

../_images/segment_2.png

segment_3 (3-node line element)

../_images/segment_3.png

triangle_3 (3-node triangular element)

../_images/triangle_3.png

triangle_6 (6-node triangular element)

../_images/triangle_6.png

quadrangle_4 (4-node quadrilateral element)

../_images/quadrangle_4.png

quadrangle_8 (8-node quadrilateral element)

../_images/quadrangle_8.png