Skip to content

Commit

Permalink
Update _FM_utils.py
Browse files Browse the repository at this point in the history
  • Loading branch information
abja-dhi committed Nov 6, 2024
1 parent 9b5c1c2 commit e92857c
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion mikeio/spatial/_FM_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,23 @@ def _to_polygons(node_coordinates: np.ndarray, element_table: np.ndarray) -> lis
return polygons


def _create_node_element_matrix(element_table, num_nodes):
def _create_node_element_matrix(element_table: np.ndarray, num_nodes: int) -> csr_matrix:
"""Creates a sparse node-element connectivity matrix from a given element table.
Parameters
----------
element_table : np.array
The element table (A 2D array where each row represents an element and each
column corresponds to a node index involved in the element.)
num_nodes : int
The total number of nodes in the mesh.
Returns
-------
scipy.sparse.csr_matrix
A sparse matrix of shape (num_nodes, number of elements), where the entry
(i, j) is 1 if node i is part of element j, and 0 otherwise.
"""
row_ind = element_table.ravel()
col_ind = np.repeat(np.arange(element_table.shape[0]), element_table.shape[1])
data = np.ones(len(row_ind), dtype=int)
Expand Down

0 comments on commit e92857c

Please sign in to comment.