The connectivity.py module#

Summary#

get_faces_tetra

Get faces that make up the tetrahedrons.

face_tetra_connectivity

Compute the tetra-face connectivity tables.

get_face_type

Establish the face type, which indicates whether it is a boundary or an interior face.

get_edges_from_triangles

Generate an array of edges from an array of triangles.

get_free_edges

Get the boundary edges that are only referenced once.

edge_connectivity

Group edges by connectivity.

remove_triangle_layers_from_trimesh

Remove boundary triangles.

Description#

Module containing methods for mesh connectivity.

Module detail#

connectivity.get_faces_tetra(tetra: numpy.ndarray) numpy.ndarray#

Get faces that make up the tetrahedrons.

connectivity.face_tetra_connectivity(tetra: numpy.ndarray) Tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray]#

Compute the tetra-face connectivity tables.

connectivity.get_face_type(faces: numpy.ndarray, face_cell_connectivity: numpy.ndarray) numpy.ndarray#

Establish the face type, which indicates whether it is a boundary or an interior face.

Parameters:
facesnp.ndarray

Array with face definitions.

face_cell_connectivitynp.ndarray

Array describing the cells that each of the faces is connected to. For example, np.array([c0, c1]).

Returns:
np.ndarray

Type of face, which is either interior (face_type = 1) or boundary (face_type = 2).

connectivity.get_edges_from_triangles(triangles: numpy.ndarray) numpy.ndarray#

Generate an array of edges from an array of triangles.

connectivity.get_free_edges(triangles: numpy.ndarray, return_free_triangles: bool = False) numpy.ndarray | Tuple[numpy.ndarray, numpy.ndarray]#

Get the boundary edges that are only referenced once.

Parameters:
trianglesnp.ndarray

Array of triangles.

return_free_trianglesbool, default: False

Whether to return the free triangles.

Returns:
free_edgesnp.ndarray

NumPy array with the free edges.

free_triangles: np.ndarray, optional

Numpy array with the triangles that use these free edges

connectivity.edge_connectivity(edges: numpy.ndarray, return_type: bool = False, sort_closed: bool = False) numpy.ndarray#

Group edges by connectivity.

Parameters:
edgesnp.array

NumEdges x 2 NumPy arrays with edge definitions.

return_typebool, default: False

Whether to return the edge group type. If True, the function returns a list of strings with these types:

  • open: Edge group is open-ended.

  • closed: Edge group forms a closed edge loop.

sort_closedbool, default: False

Whether to sort closed edge loops.

Returns:
edge_groupsnp.ndarray

Grouped edges by connectivity.

group_typeslist[str], optional

Type of the edge group. Options are open or closed.

Notes

This method uses an implementation of a depth-first search. For more information, seeDepth-first search <https://en.wikipedia.org/wiki/Depth-first_search>`_ on the Wikipedia site.

Performance of this method is not tested. It might not be suitable for large arrays of edges.

connectivity.remove_triangle_layers_from_trimesh(triangles: numpy.ndarray, iters: int = 1) numpy.ndarray#

Remove boundary triangles.

Parameters:
trianglesnp.ndarray

Array of triangles.

itersint, default: 1

Number of iterations.

Returns:
np.ndarray

Reduced set of triangles.