mesh.Mesh.partition_by_connection#

Mesh.partition_by_connection(level=0, startat=0, sort='number')#

Detect the connected parts of a Mesh.

The Mesh is partitioned in parts in which all elements are connected.

Parameters#

level: int, optional

The minimal geometric entity that two elements must share in order to be considered connected:

  • 0 = node: elements are connected if they share at least one node.

  • 1 = edge: elements are connected if they share at least one edge

  • 2 = face: elements are connected if they share at least one face

startat: int or list of ints, optional

Initial element number(s) in the front.

sort: str, optional

One of ‘number’ (default), ‘length’, ‘area’, ‘volume’. Defines the weights to be used in sorting the parts. Specifying another string will leave the parts unsorted.

Returns#

int array

An int array specifying for each element the part number to which it belongs. By default the parts are sorted in decreasing order of the number of elements.

Examples#

>>> M1 = Mesh(eltype='quad4').subdivide(2)
>>> M2 = Mesh(eltype='quad4').scale(2.0).trl([3.0,0.0,0.0])
>>> M = M1 + M2
>>> print(M.partition_by_connection())
[0 0 0 0 1]
>>> print(M.partition_by_connection(sort='length'))
[1 1 1 1 0]
>>> M3 = Mesh(eltype='hex8')
>>> M4 = Mesh(eltype='hex8').scale(2.0).trl([3.0,0.0,0.0])
>>> M = M3 + M4
>>> print(M.partition_by_connection(sort='volume'))
[1 0]