pysdic.fem.remap_vertices_coordinates#

remap_vertices_coordinates(vertices_coordinates, connectivity_array, element_indices, *, allow_unlocated_points=False, default=nan)[source]#

Remap the global coordinates of the vertices to given integration points within elements based on the element connectivity, and the remapped coordinates will have shape \((N_{p}, N_{vpe}, E)\).

remapped_coordinates[i] contains the global coordinates of the vertices for the element containing integration point \(i\).

Note

  • Input vertices_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

With allow_unlocated_points=True, the points with element index -1 are filled with default. With allow_unlocated_points=False (default), negative element indices raise an IndexError.

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_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.

  • default (Real, optional (default: numpy.nan)) – The default value to assign to remapped coordinates for integration points associated with an element index of -1 when allow_unlocated_points is True.

Returns:

remapped_coordinates – An array of shape \((N_{p}, N_{vpe}, E)\) containing the remapped global coordinates of the vertices for each integration point within the elements.

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 remapped coordinates array has shape \((N_{p}, N_{vpe}, E)\) where each entry corresponds to the global coordinates of the nodes associated with the element containing the integration point.

See also

pysdic.fem.assemble_jacobian_matrix

To compute the Jacobian matrices for the transformation between natural and global coordinates.

Examples

Lets construct a simple 2D mesh and remap the vertex coordinates to 3 integration points (the last one is outside the mesh).

 1import numpy
 2from pysdic.fem import remap_vertices_coordinates
 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
16element_indices = numpy.array([0, 1, -1])
17
18remapped_coords = remap_vertices_coordinates(
19    vertices_coordinates=vertices_coordinates,
20    connectivity_array=connectivity_array,
21    element_indices=element_indices,
22    allow_unlocated_points=True,  # Accept the -1 of the last point
23)
24
25print(f"remapped coordinates (shape={remapped_coords.shape}):")
26print(remapped_coords)
remapped coordinates (shape=(3, 3, 2)):
[[[ 0.  0.]
  [ 1.  0.]
  [ 1.  1.]]

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

 [[nan nan]
  [nan nan]
  [nan nan]]]