mesh.Mesh.renumber#

Mesh.renumber(order='elems')#

Renumber the nodes of a Mesh in the specified order.

Parameters#

order: int array_like or str

If an array, it is an index with length equal to the number of nodes. It should be a permutation of np.arange(self.n_nodes()). The index specifies the node number that should come at this position. Thus, the order values are the old node numbers on the new node number positions.

order can also be a predefined string that will generate the node index automatically:

  • ‘elems’: the nodes are number in order of their appearance in the Mesh connectivity.

  • ‘front’: the nodes are numbered in order of their frontwalk.

Returns#

Mesh

A Mesh equivalent with the input, but with the nodes numbered differently.

Examples#

>>> coords = Coords([[1.0, 0.0, 0.0],
...                  [0.0, 0.0, 0.0],
...                  [2.0, 1.0, 0.0],
...                  [2.0, 0.0, 0.0],
...                  [1.0, 1.0, 0.0]])
>>> elems = [[1,0],[0,3],[0,4],[4,2]]
>>> M = Mesh(coords,elems,eltype='line2')
>>> M1 = M.renumber()
>>> print(M1.coords)
[[0. 0. 0.]
 [1. 0. 0.]
 [2. 0. 0.]
 [1. 1. 0.]
 [2. 1. 0.]]
>>> print(M1.elems)
[[0 1]
 [1 2]
 [1 3]
 [3 4]]
>>> M2 = M.renumber(order='front')
>>> print(M2.coords)
[[1. 0. 0.]
 [0. 0. 0.]
 [2. 0. 0.]
 [1. 1. 0.]
 [2. 1. 0.]]
>>> print(M2.elems)
[[1 0]
 [0 2]
 [0 3]
 [3 4]]