mesh.Mesh.compact#
- Mesh.compact(return_index=False)#
Remove unconnected nodes and renumber the Mesh.
Returns a Mesh where all nodes that are not used in any element have been removed, and the nodes are renumbered to a compacter scheme.
If return_index is True, also returns an index specifying the index of the new nodes in the old node scheme.
Examples#
>>> x = Coords([[i] for i in np.arange(5)]) >>> M = Mesh(x,[[0,2],[1,4],[4,2]]) >>> M,ind = M.compact(True) >>> print(M.coords) [[0. 0. 0.] [1. 0. 0.] [2. 0. 0.] [4. 0. 0.]] >>> print(M.elems) [[0 2] [1 3] [3 2]]
>>> M = Mesh(x,[[0,2],[1,3],[3,2]]) >>> M = M.compact() >>> print(M.coords) [[0. 0. 0.] [1. 0. 0.] [2. 0. 0.] [3. 0. 0.]] >>> print(M.elems) [[0 2] [1 3] [3 2]] >>> print(ind) [0 1 2 4]
>>> M = M.remove_selected([0,1,2]) >>> M.coords.shape, M.elems.shape ((4, 3), (0, 2)) >>> M = M.compact() >>> M.coords.shape, M.elems.shape ((0, 3), (0, 2))