pysdic.fem.compute_property_interpolation#

compute_property_interpolation(nodal_values, connectivity_array, element_type, natural_coordinates, element_indices, *, allow_unlocated_points=False, tolerance=0.0, default=nan)[source]#

Interpolate a property defined at the nodes of a mesh to given integration points within elements using mesh and integration point information.

This function combines the computation of shape functions and the assembly of the property interpolation for the entire mesh.

interpolated_values[i] contains the interpolated property at the integration point \(i\).

Note

  • Inputs nodal_values and natural_coordinates will be converted to numpy.float64.

  • Inputs connectivity_array and element_indices will be converted to numpy.int64.

Note

The connectivity is validated (non-negative vertex indices lower than the number of vertices, distinct vertices in each element) and the element indices are checked against the number of elements. The geometry of the elements (e.g. their orientation) is not checked.

Important

The interpolated values of the points with element index -1 (only accepted with allow_unlocated_points=True) are set to default. A located point whose natural coordinates are outside the reference element (enlarged by tolerance) raises a ValueError.

Parameters:
  • nodal_values (ArrayLike) – An array of shape \((N_{v}, P)\) containing the property values defined at the nodes of the mesh. If 1D-array is provided, it will be treated as a single-component property of shape \((N_{v}, 1)\).

  • connectivity_array (ArrayLike) – An array of shape \((N_{e}, N_{vpe})\) defining the connectivity of the elements in the mesh, where each row contains the indices of the nodes that form an element.

  • element_type (str) – A string specifying the type of element (e.g., 'segment_2', 'triangle_3', etc.) to determine which shape function to use.

  • natural_coordinates (ArrayLike) – An array of shape \((N_{p}, K)\) containing the natural coordinates of the integration points within elements where \(K\) is the topological dimension of the element (e.g., 1 for segments, 2 for triangles/quadrangles, etc.).

  • element_indices (ArrayLike) – An array of shape \((N_{p},)\) containing the indices of each element corresponding to the \(N_{p}\) integration points.

  • allow_unlocated_points (bool, optional (default: False)) – If False (default), any negative element index raises an IndexError. If True, the element index -1 marks a point not located in any element of the mesh, and such a point is treated as invalid (see above). Other negative indices always raise an IndexError.

  • tolerance (Real, optional (default: 0.0)) – Non-negative tolerance enlarging the reference element when checking whether the natural coordinates of a point are inside its element (see pysdic.fem.compute_shape_functions()). Useful for points located on the boundary of their element up to rounding errors. With the default 0.0, only the points exactly inside the reference element are accepted.

  • default (Union[Real, ArrayLike], optional (default: numpy.nan)) – The value assigned to the interpolated values of the points with element index -1. The input can also be an array of shape \((P,)\) to assign different default values for each property component.

Returns:

interpolated_values – An array of shape \((N_{p}, P)\) containing the interpolated property values at each of the \(N_{p}\) integration points.

Return type:

numpy.ndarray

Notes

See pysdic.fem.assemble_property_interpolation() for the interpolation formula. To interpolate with precomputed shape functions, use pysdic.fem.assemble_property_interpolation() directly.

See also

pysdic.fem.compute_shape_functions

To compute the shape functions at given natural coordinates within elements.

pysdic.fem.assemble_property_interpolation

To assemble the property interpolation from precomputed shape functions.

pysdic.fem.compute_property_derivative

To compute the derivative of a property at integration points within elements.

pysdic.fem.compute_property_projection

To project properties defined at integration points back to the nodes of the mesh.

Examples

Lets construct a simple 2D mesh and interpolate a 2-components property at given integration points for triangular elements. The last point is outside the mesh.

 1import numpy
 2from pysdic.fem import compute_property_interpolation
 3
 4connectivity_array = numpy.array(
 5    [[0, 1, 2],
 6     [0, 2, 3]]
 7)
 8
 9natural_coordinates = numpy.array(
10    [[0.2, 0.3],
11     [0.6, 0.2],
12     [0.0, 0.0]]
13)
14
15element_indices = numpy.array([0, 1, -1])
16
17nodal_values = numpy.array(
18    [[10.0, 1.0],
19     [20.0, 2.0],
20     [30.0, 3.0],
21     [40.0, 4.0]]
22)
23
24interpolated_values = compute_property_interpolation(
25    nodal_values=nodal_values,
26    connectivity_array=connectivity_array,
27    element_type='triangle_3',
28    natural_coordinates=natural_coordinates,
29    element_indices=element_indices,
30    allow_unlocated_points=True,  # Accept the -1 of the last point
31    default=[-1.0, 0.0],
32)
33
34print(f"interpolated values (shape={interpolated_values.shape}):")
35print(interpolated_values)
interpolated values (shape=(3, 2)):
[[18.   1.8]
 [28.   2.8]
 [-1.   0. ]]