pysdic.fem.compute_triangle_3_shape_functions#

compute_triangle_3_shape_functions(natural_coordinates, *, return_derivatives=False, default=0.0, tolerance=0.0)[source]#

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

Note

  • Input natural_coordinates will be converted to numpy.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}, 2)\), 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 \(\xi, \eta \geq 0\) with \(\xi + \eta \leq 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 \(\xi, \eta \geq -\text{tol}\) with \(\xi + \eta \leq 1 + \text{tol}\). Useful for points located on the boundary of the element up to rounding errors. Ignored if default is None.

Returns:

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

  • shape_function_derivatives (numpy.ndarray) – Only returned if return_derivatives is True. First derivatives of the shape functions with respect to the natural coordinates, with shape \((N_{p}, 3, 2)\) such that shape_function_derivatives[p, j, k] is \(\frac{\partial N_j}{\partial \xi_k}\) at point \(p\) (with \(\xi_0 = \xi\) and \(\xi_1 = \eta\)).

Return type:

ndarray | Tuple[ndarray, ndarray]

Notes

A 3-node triangle represented in the figure below has the following shape functions:

Node No.

\((\xi, \eta)\)

Shape Function \(N\)

First Derivative \((\frac{dN}{d\xi}, \frac{dN}{d\eta})\)

1

\((0, 0)\)

\(N_1(\xi, \eta) = 1 - \xi - \eta\)

\((-1, -1)\)

2

\((1, 0)\)

\(N_2(\xi, \eta) = \xi\)

\((1, 0)\)

3

\((0, 1)\)

\(N_3(\xi, \eta) = \eta\)

\((0, 1)\)

3-node triangle element

See also

pysdic.fem.compute_triangle_6_shape_functions

Shape functions for 6-node triangle 2D-elements.

pysdic.fem.compute_shape_functions

Shape functions for any supported element type.

pysdic.fem.get_triangle_3_gauss_points

Gauss integration points for 3-node triangle 2D-elements.

Examples

Compute shape functions without derivatives for 3 valid points and 1 invalid point:

1import numpy
2from pysdic.fem import compute_triangle_3_shape_functions
3
4coords = numpy.array([[0.0, 0.0], [0.5, 0.0], [0.0, 0.5], [0.7, 0.5]])
5shape_functions = compute_triangle_3_shape_functions(coords)
6print("Shape function values:")
7print(shape_functions)
Shape function values:
[[1.  0.  0. ]
 [0.5 0.5 0. ]
 [0.5 0.  0.5]
 [0.  0.  0. ]]

A point on the edge \(\xi + \eta = 1\) up to rounding errors is considered outside without tolerance:

1coords = numpy.array([[0.7, 0.3 + 1e-15]])  # xi + eta = 1.000000000000001
2print(compute_triangle_3_shape_functions(coords))
3print(compute_triangle_3_shape_functions(coords, tolerance=1e-12))
[[0. 0. 0.]]
[[-9.43689571e-16  7.00000000e-01  3.00000000e-01]]