pysdic.fem.compute_property_derivative#
- compute_property_derivative(nodal_values, vertices_coordinates, connectivity_array, element_type, natural_coordinates, element_indices, *, allow_unlocated_points=False, tolerance=0.0, 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.
gradients[i]contains the derivative of the 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
nodal_values,vertices_coordinatesandnatural_coordinateswill 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 derivatives of the points with element index
-1(only accepted withallow_unlocated_points=True) are set todefault. AValueErroris raised if a located point has natural coordinates outside the reference element (enlarged bytolerance) or a degenerated Jacobian matrix (seepysdic.fem.assemble_property_derivative()).- 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)\).
vertices_coordinates (ArrayLike) – An array of shape \((N_{v}, E)\) containing the global coordinates \((x, y, z, ...)\) of the vertices in the mesh.
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 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.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 (seepysdic.fem.compute_shape_functions()). Useful for points located on the boundary of their element up to rounding errors. With the default0.0, only the points exactly inside the reference element are accepted.default (Real, optional (default:
numpy.nan)) – The value assigned to the derivatives of the points with element index-1.
- Returns:
gradients – An array of shape \((N_{p}, P, E)\) containing the derivatives of the property at each of the \(N_{p}\) integration points with respect to the global coordinates \((x, y, z, ...)\).
- Return type:
Notes
See
pysdic.fem.assemble_property_derivative()for the computation of the derivatives with respect to the global coordinates (inverse or pseudo-inverse of the Jacobian matrix for \(K = E\) or \(K < E\)) and its demonstration.See also
pysdic.fem.compute_shape_functionsTo compute the shape functions and their derivatives at given natural coordinates within elements.
pysdic.fem.compute_jacobian_matrixTo compute the Jacobian matrices from mesh and integration point information.
pysdic.fem.assemble_property_derivativeTo 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.fem 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_array = 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 23nodal_values = numpy.array([10.0, 20.0, 30.0, 40.0]) # Scalar property 24 25gradients = compute_property_derivative( 26 nodal_values=nodal_values, 27 vertices_coordinates=vertices_coordinates, 28 connectivity_array=connectivity_array, 29 element_type='triangle_3', 30 natural_coordinates=natural_coordinates, 31 element_indices=element_indices 32) 33 34print(f"gradients (shape={gradients.shape}):") 35print(gradients)
gradients (shape=(2, 1, 2)): [[[ 10. 10.]] [[-10. 30.]]]