pysdic.fem.remap_integration_points_neighborhood#

remap_integration_points_neighborhood(elements_neighborhood, element_indices, *, skip_m1=True)[source]#

Remap a neighborhood of the elements of a mesh to the integration points: for each element, get the integration points located in the elements of its neighborhood.

Note

  • Input element_indices will be converted to numpy.int64.

Important

With skip_m1=True, the points with element index -1 (outside the mesh) belong to no neighborhood. With skip_m1=False, negative element indices raise an IndexError.

Parameters:
  • elements_neighborhood (Union[ArrayLike, scipy.sparse.spmatrix]) – The neighborhood of the elements as a square matrix of shape \((N_{e}, N_{e})\) (sparse or dense), where a non-zero entry at \((i, j)\) means that element \(j\) is in the neighborhood of element \(i\) (see pysdic.fem.compute_elements_neighborhood()).

  • element_indices (ArrayLike) – An array of shape \((N_{p},)\) containing the indices of the element of each of the \(N_{p}\) integration points.

  • skip_m1 (bool, optional (default: True)) – If set to True, the points with element index -1 are ignored.

Returns:

points_neighborhood – A boolean sparse matrix of shape \((N_{e}, N_{p})\), where the integration points in the neighborhood of element \(i\) are points_neighborhood[i].indices (sorted).

Return type:

scipy.sparse.csr_matrix

Notes

Let \(\mathcal{V} \in \{0, 1\}^{N_{e} \times N_{e}}\) be the elements neighborhood and \(C \in \{0, 1\}^{N_{e} \times N_{p}}\) the matrix such that \(C_{e,p} = 1\) if point \(p\) is located in element \(e\). The points neighborhood is the boolean product \(\mathcal{V} C\).

See also

pysdic.fem.compute_elements_neighborhood

Neighborhood of each element of a mesh.

pysdic.fem.compute_integration_points_neighborhood

Neighborhood of integration points directly from the mesh connectivity.

Examples

Create a simple 'quadrangle_4' mesh with 10 vertices and 4 elements, with two integration points per element and one point outside the mesh, and remap the neighborhood of the elements to the integration points.

../../_images/graph_mesh.png

'quadrangle_4' mesh.#

 1import numpy
 2from pysdic.fem import (
 3    compute_elements_neighborhood,
 4    remap_integration_points_neighborhood,
 5)
 6
 7connectivity_array = numpy.array([
 8    [0, 1, 4, 5],
 9    [1, 2, 5, 6],
10    [2, 3, 6, 7],
11    [6, 7, 8, 9]])
12
13element_indices = numpy.array([0, 0, 1, 1, 2, 2, 3, 3, -1])
14
15elements_neighborhood = compute_elements_neighborhood(connectivity_array)
16points_neighborhood = remap_integration_points_neighborhood(
17    elements_neighborhood, element_indices
18)
19
20print(f"points neighborhood (shape={points_neighborhood.shape})")
21for element in range(points_neighborhood.shape[0]):
22    print(f"element {element}: points {points_neighborhood[element].indices}")
points neighborhood (shape=(4, 9))
element 0: points [0 1 2 3]
element 1: points [0 1 2 3 4 5 6 7]
element 2: points [2 3 4 5 6 7]
element 3: points [2 3 4 5 6 7]