pysdic.fem.compute_segment_2_shape_functions#
- compute_segment_2_shape_functions(natural_coordinates, *, return_derivatives=False, default=0.0, tolerance=0.0)[source]#
Compute the shape functions for a 2-node segment for given
natural_coordinates\(\xi\).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},)\) or \((N_{p}, 1)\), where \(N_{p}\) is the number of points to evaluate.
return_derivatives (bool, optional (default:
False)) – If True, the function will also return the first derivatives of the shape functions with respect to the natural coordinates.default (Optional[Real], optional (default:
0.0)) – Default value to assign to shape functions (and derivatives) when the input natural coordinates are out of the valid range (i.e., not in \([-1, 1]\)). If None, no masking is applied and the shape functions are extrapolated outside the element.tolerance (Real, optional (default:
0.0)) – Non-negative tolerance enlarging the valid range to \([-1 - \text{tol}, 1 + \text{tol}]\). Useful for points located on the boundary of the element up to rounding errors. Ignored ifdefaultis None.
- Returns:
shape_functions (numpy.ndarray) – Shape functions evaluated at the given natural coordinates. The returned array has shape \((N_{p}, 2)\), where each row corresponds to a point and each column to a node.
shape_function_derivatives (numpy.ndarray) – Only returned if
return_derivativesis True. First derivatives of the shape functions with respect to the natural coordinates, with shape \((N_{p}, 2, 1)\) such thatshape_function_derivatives[p, j, 0]is \(\frac{dN_j}{d\xi}\) at point \(p\).
- Return type:
Notes
A 2-node segment represented in the figure below has the following shape functions:
Node No.
\((\xi)\)
Shape Function \(N\)
First Derivative \((\frac{dN}{d\xi})\)
1
\(-1\)
\(N_1(\xi) = \frac{1}{2}(1 - \xi)\)
\(-\frac{1}{2}\)
2
\(1\)
\(N_2(\xi) = \frac{1}{2}(1 + \xi)\)
\(\frac{1}{2}\)
See also
pysdic.fem.compute_segment_3_shape_functionsShape functions for 3-node segment 1D-elements.
pysdic.fem.compute_shape_functionsShape functions for any supported element type.
pysdic.fem.get_segment_2_gauss_pointsGauss integration points for 2-node segment 1D-elements.
Examples
Compute shape functions without derivatives for 3 valid points and 1 invalid point:
1import numpy 2from pysdic.fem import compute_segment_2_shape_functions 3 4coords = numpy.array([[-1.0], [0.0], [1.0], [1.5]]) 5shape_functions = compute_segment_2_shape_functions(coords) 6print("Shape function values:") 7print(shape_functions)
Shape function values: [[1. 0. ] [0.5 0.5] [0. 1. ] [0. 0. ]]
Extrapolate the shape functions outside the element with
default=None:1shape_functions = compute_segment_2_shape_functions([1.5], default=None) 2print(shape_functions)
[[-0.25 1.25]]