pysdic.fem.compute_jacobian_matrix#

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

Compute and assemble the Jacobian (derivative) matrix \(J\) of the transformation from natural coordinates \((\xi, \eta, \zeta, ...)\) to global coordinates \((x, y, z, ...)\) with shape \((N_{p}, E, K)\) at given integration points within specified elements.

jacobians[i] contains the Jacobian matrix for the integration point \(i\).

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

Note

  • Inputs vertices_coordinates 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 Jacobian matrices of the points with element index -1 (only accepted with allow_unlocated_points=True) are filled with default. A located point whose natural coordinates are outside the reference element (enlarged by tolerance) raises a ValueError.

Parameters:
  • vertices_coordinates (ArrayLike) – An array of shape \((N_{v}, E)\) containing the global coordinates 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 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 (Real, optional (default: numpy.nan)) – The value assigned to the Jacobian matrices of the points with element index -1.

Returns:

jacobians – An array of shape \((N_{p}, E, K)\) containing the Jacobian matrices for each of the \(N_{p}\) points. Each Jacobian matrix has dimensions \((E \times K)\).

Return type:

numpy.ndarray

Notes

See pysdic.fem.assemble_jacobian_matrix() for the definition of the Jacobian matrix \(J\) of shape \((E \times K)\), the transformation between natural and global coordinates and the use of the pseudo-inverse for non-square Jacobian matrices (\(K < E\)).

See also

pysdic.fem.compute_shape_functions

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

pysdic.fem.remap_vertices_coordinates

To remap the vertices coordinates for each element at given integration points.

pysdic.fem.assemble_jacobian_matrix

To assemble the Jacobian matrices from shape function derivatives and remapped coordinates.

Examples

Lets construct a simple 2D mesh and compute the Jacobian at given integration points for triangular elements.

 1import numpy
 2from pysdic.fem import compute_jacobian_matrix
 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
23jacobians = compute_jacobian_matrix(
24    vertices_coordinates=vertices_coordinates,
25    connectivity_array=connectivity_array,
26    element_type='triangle_3',
27    natural_coordinates=natural_coordinates,
28    element_indices=element_indices,
29)
30
31print(f"jacobians (shape={jacobians.shape}):")
32print(jacobians)
jacobians (shape=(2, 2, 2)):
[[[1. 1.]
  [0. 1.]]

 [[1. 0.]
  [1. 1.]]]