pysdic.compute_property_derivative#

compute_property_derivative(property_array, vertices_coordinates, connectivity, element_type, natural_coordinates, element_indices, *, skip_m1=True, default=nan)[source]#

Compute and assemble the derivative of a property defined at the nodes of a mesh to given integration points within elements with respect to global coordinates \((x,y,z,...)\) from mesh and integration point information.

derivated_properties[i] contains the derivated property at the integration point \(i\).

This function combines the remapping of vertex coordinates, computation of shape function derivatives, assembly of the Jacobian matrices, and assembly of the property derivatives for the entire mesh.

Note

  • Inputs property_array, vertices_coordinates and natural_coordinates will be converted to numpy.float64.

  • Inputs connectivity and element_indices will be converted to numpy.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 -1 in element_indices for invalid elements, ensure to set skip_m1 to True to 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)\).

  • vertices_coordinates (ArrayLike) – An array of shape \((N_{v}, E)\) containing the global coordinates \((x, y, z, ...)\) of the vertices in the mesh.

  • 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 to True, any element index of -1 in element_indices will result in the corresponding derivated properties being set to default. Default is True.

  • default (Real, optional) – The default value to assign to derivated properties for integration points associated with an element index of -1 when skip_m1 is True. The out-of-range natural coordinates will also result in derivated properties being set to this value. Default is numpy.nan.

Returns:

derivated_properties – An array of shape \((N_{p}, P, E)\) containing the derivated property values at each of the \(N_{p}\) integration points with respect to the global coordinates \((x, y, z, ...)\).

Return type:

numpy.ndarray

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 derivated property array has shape \((N_p, P, K)\) where \(P\) is the number of property components (e.g., 1 for scalar properties, 3 for vector properties), and \(K\) is the number of local coordinates.

The derivative of the property at each integration point is computed as:

If the dimension of the elements \(K\) is equal to the space dimension \(E\):

\[\nabla_X P(\xi, \eta, \zeta, ...) = J^{-T} \cdot \sum_{i=1}^{N_{vpe}} \nabla_{\Xi} N_i(\xi, \eta, \zeta, ...) P_i\]

See the notes in pysdic.assemble_property_derivative() for more details on the behaviour when \(K < E\) and the use of pseudo-inverse for non-square Jacobian matrices.

See also

pysdic.compute_shape_functions

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

pysdic.compute_jacobian_matrix

To compute the Jacobian matrices from mesh and integration point information.

pysdic.assemble_property_derivative

To assemble the property derivatives from precomputed shape function derivatives and Jacobian matrices.

Examples

Lets construct a simple 2D mesh and compute the derivative of a scalar property at given integration points for triangular elements.

 1import numpy
 2from pysdic import compute_property_derivative
 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
25derivated_properties = compute_property_derivative(
26    property_array=property_array,
27    vertices_coordinates=vertices_coordinates,
28    connectivity=connectivity,
29    element_type='triangle_3',
30    natural_coordinates=natural_coordinates,
31    element_indices=element_indices
32)
33
34print(f"derivated properties (shape={derivated_properties.shape}):")
35print(derivated_properties)
derivated properties (shape=(2, 1, 2)):
[[[ 10.  10.]]

 [[-10.  30.]]]