pysdic.fem.assemble_property_interpolation#
- assemble_property_interpolation(nodal_values, connectivity_array, element_indices, shape_functions, *, allow_unlocated_points=False, default=nan)[source]#
Interpolate a property defined at the nodes of a mesh to given integration points within elements using precomputed shape functions.
interpolated_values[i]contains the interpolated property at the integration point \(i\).Note
Inputs
nodal_valuesandshape_functionswill be converted tonumpy.float64.Inputs
connectivity_arrayandelement_indiceswill be converted tonumpy.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 withallow_unlocated_points=True) are set todefault. A non-finite shape function value of a located point raises aValueError.- 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_indices (ArrayLike) – An array of shape \((N_{p},)\) containing the indices of each element corresponding to the \(N_{p}\) integration points.
shape_functions (ArrayLike) – An array of shape \((N_{p}, N_{vpe})\) containing the shape function values evaluated at \(N_{p}\) points for the \(N_{vpe}\) nodes of the element.
allow_unlocated_points (bool, optional (default:
False)) – If False (default), any negative element index raises anIndexError. If True, the element index-1marks 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 anIndexError.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:
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 values 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.fem.compute_shape_functionsTo compute the shape functions at given natural coordinates within elements.
pysdic.fem.compute_property_interpolationTo compute the property interpolation directly from mesh and integration point information.
pysdic.fem.assemble_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.fem import ( 3 compute_shape_functions, 4 assemble_property_interpolation 5) 6 7connectivity_array = numpy.array( 8 [[0, 1, 2], 9 [0, 2, 3]] 10) 11 12natural_coordinates = numpy.array( 13 [[0.2, 0.3], 14 [0.6, 0.2]] 15) 16 17element_indices = numpy.array([0, 1]) 18 19nodal_values = numpy.array([10.0, 20.0, 30.0, 40.0]) # Scalar property 20 21shape_functions = compute_shape_functions( 22 natural_coordinates=natural_coordinates, 23 element_type='triangle_3', 24) 25 26interpolated_values = assemble_property_interpolation( 27 nodal_values=nodal_values, 28 connectivity_array=connectivity_array, 29 element_indices=element_indices, 30 shape_functions=shape_functions 31) 32 33print(f"interpolated values (shape={interpolated_values.shape}):") 34print(interpolated_values)
interpolated values (shape=(2, 1)): [[18.] [28.]]