pysdic.Mesh.compute_elements_adjacency_matrix#
- Mesh.compute_elements_adjacency_matrix(max_distance=None, precompute=False)[source]#
Compute the elements adjacency matrix from the connectivity of the mesh.
The adjacency between two elements is defined as 1 if they share at least one vertex, and 0 otherwise. The output is a symmetric square matrix of shape (\(N_e\), \(N_e\)), where \(N_e\) is the number of elements.
Note
The method is a convenience wrapper around the
pysdic.compute_elements_adjacency_matrix()function, which computes the elements adjacency matrix using a breadth-first search (BFS) algorithm for each element in the mesh.Warning
The same object returned by this method is stored in the precomputed properties of the mesh with the key ‘elements_adjacency_matrix’ if
precomputeis set toTrue. Please be cautious when modifying the returned adjacency matrix, as it will affect the value stored in the precomputed properties of the mesh.- Parameters:
max_distance (Integral, optional) – The maximum distance to consider between elements. If the distance between two elements exceeds this value, the corresponding entry in the adjacency matrix will be set to -1. If
None, there is no maximum distance and all adjacencies will be computed. By defaultNone.precompute (
bool, optional) – IfTrue, the computed elements adjacency matrix will be stored in the precomputed properties of the mesh with the key ‘elements_adjacency_matrix’. IfFalse, the computed elements adjacency matrix will not be stored in the precomputed properties of the mesh. By defaultFalse.
- Returns:
A square array of shape (\(N_e\), \(N_e\)) representing the adjacency matrix between elements.
- Return type:
See also
pysdic.compute_elements_adjacency_matrix()For more information on the algorithm used to compute the elements adjacency matrix and an example of the output format.