pysdic.compute_property_interpolation#
- compute_property_interpolation(property_array, connectivity, element_type, natural_coordinates, element_indices, *, skip_m1=True, 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 remapping of vertex coordinates, computation of shape functions, and assembly of the property interpolation for the entire mesh.
interpolated_properties[i]contains the interpolated property at the integration point \(i\).Note
Inputs
property_arrayandnatural_coordinateswill be converted tonumpy.float64.Inputs
connectivityandelement_indiceswill be converted tonumpy.int64.
Warning
No tests are performed to check if the inputs array are consistent (e.g., if the connectivity contains invalid vertex indices, …). Only shapes are validated. The behavior of the function is undefined in this case.
Important
When using
-1inelement_indicesfor invalid elements, ensure to setskip_m1toTrueto avoid indexing errors.- Parameters:
property_array (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 (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.
skip_m1 (
bool, optional) – If set toTrue, any element index of -1 inelement_indiceswill result in the corresponding interpolated property being set todefault. Default isTrue.default (Union[Real, ArrayLike], optional) – The default value to assign to interpolated properties for integration points associated with an element index of -1 when
skip_m1isTrue. Default isnumpy.nan. The input can also be anumpy.ndarrayof shape (P,) to assign different default values for each property component.
- Returns:
interpolated_properties – An array of shape \((N_{p}, P)\) containing the interpolated property values at each of the \(N_{p}\) integration points.
- Return type:
Notes
In a space of dimension \(E\) with a mesh constituted of \(N_{e}\) elements and \(N_{v}\) nodes, the mesh is composed of \(K\)-dimensional elements (with \(K \leq E\)) defined by \(N_{vpe}\) nodes for each element.
For a given set of \(N_{p}\) integration points located within elements, the interpolated property array has shape \((N_{p}, P)\) where \(P\) is the number of property components (e.g., 1 for scalar properties, 3 for vector properties).
The property at each integration point is computed as:
\[P(\xi, \eta, \zeta, ...) = \sum_{i=1}^{N_{vpe}} N_i(\xi, \eta, \zeta, ...) P_i\]where \(N_i\) are the shape functions associated with each node, and \(P_i\) are the property values at the nodes of the element.
See also
pysdic.compute_shape_functionsTo compute the shape functions at given natural coordinates within elements.
pysdic.assemble_property_interpolationTo assemble the property interpolation from precomputed shape functions.
pysdic.compute_property_derivativeTo compute the derivative of a property at integration points within elements.
pysdic.compute_property_projectionTo project properties defined at integration points back to the nodes of the mesh.
Examples
Lets construct a simple 2D mesh and interpolate a scalar property at given integration points for triangular elements.
1import numpy 2from pysdic import compute_property_interpolation 3 4vertices_coordinates = numpy.array( 5 [[0.0, 0.0], 6 [1.0, 0.0], 7 [1.0, 1.0], 8 [0.0, 1.0]] 9) 10 11connectivity = numpy.array( 12 [[0, 1, 2], 13 [0, 2, 3]] 14) 15 16natural_coordinates = numpy.array( 17 [[0.2, 0.3], 18 [0.6, 0.2]] 19) 20 21element_indices = numpy.array([0, 1]) 22 23property_array = numpy.array([10.0, 20.0, 30.0, 40.0]) # Scalar property 24 25interpolated_props = compute_property_interpolation( 26 property_array=property_array, 27 connectivity=connectivity, 28 element_type='triangle_3', 29 natural_coordinates=natural_coordinates, 30 element_indices=element_indices 31) 32 33print(f"interpolated properties (shape={interpolated_props.shape}):") 34print(interpolated_props)
interpolated properties (shape=(2, 1)): [[18. ] [28. ]]