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.
where \(P\) is the interpolated value at the point, \(N_i\) are the shape functions, and \(P_i\) are the nodal values.
See also
Operations on Integration Points (interpolation, projection, etc.) for operations on integrated points using shape functions.
Gauss quadrature points collection for Gauss quadrature points and weights.
Function signatures#
All of the shape function methods follow a similar interface.
Note
Input
natural_coordinateswill be converted tonumpy.float64.Output arrays will be
numpy.float64.
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 isFalse.- 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_derivativesisTrue, 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 the shape functions for a 2-node segment for given |
|
Compute the shape functions for a 3-node segment for given |
2-Dimensional elements#
Compute the shape functions for a 3-node triangle for given |
|
Compute the shape functions for a 6-node triangle for given |
|
Compute the shape functions for a 4-node quadrangle for given |
|
Compute the shape functions for a 8-node quadrangle for given |
3-Dimensional elements#
Note
3D shape functions are not yet implemented. Please contact the maintainers if you need this feature.
Dispatcher function#
Compute the shape functions for a given |