pysdic.fem.assemble_vertices_adjacency_graph#

assemble_vertices_adjacency_graph(connectivity_array, *, n_vertices=None)[source]#

Assemble the vertices adjacency graph of a mesh, where two vertices are neighbors if they belong to the same element.

The function is independent of the geometry of the elements: all the vertices of an element are neighbors of each other (e.g. the diagonal vertices of a quadrangle, or the corner and mid-edge vertices of a 6-node triangle).

Note

  • Input connectivity_array will be converted to numpy.int64.

Warning

No tests are performed to check if the input connectivity is valid (e.g., if the connectivity contains invalid vertex indices, …). The behavior of the function is undefined in that case.

Parameters:
  • 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 vertices that form an element.

  • n_vertices (Optional[Integral], optional (default: None)) – The total number of vertices \(N_{v}\) in the mesh. If not provided, it will be inferred as the maximum vertex index in connectivity_array plus one.

Returns:

graph – A symmetric boolean sparse matrix of shape \((N_{v}, N_{v})\) with an empty diagonal, where graph[i, j] is True if vertices \(i\) and \(j\) are neighbors. The neighbors of vertex \(i\) are graph[i].indices.

Return type:

scipy.sparse.csr_matrix

See also

pysdic.fem.assemble_elements_adjacency_graph

Elements adjacency graph of a mesh.

Examples

Create a simple 'quadrangle_4' mesh with 10 vertices and 4 elements and assemble the vertices adjacency graph.

../../_images/graph_mesh.png

'quadrangle_4' mesh. The neighboring vertices of vertex 1 are vertices 0, 2, 4, 5 and 6 since they are part of the same elements in the mesh (elements 0 and 1).#

 1import numpy
 2from pysdic.fem import assemble_vertices_adjacency_graph
 3
 4connectivity_array = numpy.array([
 5    [0, 1, 4, 5],
 6    [1, 2, 5, 6],
 7    [2, 3, 6, 7],
 8    [6, 7, 8, 9]])
 9
10graph = assemble_vertices_adjacency_graph(connectivity_array)
11
12print(f"vertices adjacency graph (shape={graph.shape})")
13print(f"neighbors of vertex 1: {graph[1].indices}")
vertices adjacency graph (shape=(10, 10))
neighbors of vertex 1: [0 2 4 5 6]