mesh.Mesh.partition_by_curve#

Mesh.partition_by_curve(edges, sort='number')#

Partition a level-2 Mesh by closed curve(s) along the edges.

Parameters#

edges: bool or int array_like | level-1 Mesh

If a bool type array, it flags for every edge with a True value whether the edge is part of the partitioning curve(s). The ordering of the edges is that as obtained from edges.

If an int type array, it is a list of edge nummers that constitute the curve(s). Numbers refer to the edges order of edges. The order in which the edge numbers are given is irrelevant though.

If a level-1 Mesh, it is a Mesh containing the edges that constitute the partitioning curve(s). In this case the edge numbers will be determined by matching the edges centroids on the level-2 Mesh.

sort: str

Defines how the resulting parts are sorted (by assigning them increasing part numbers). The following sort criteria are currently defined (any other value will return the parts unsorted):

  • ‘number’: sort in decreasing order of the number of elements in the part. This is the default.

  • ‘area’: sort according to decreasing surface area of the part.

Returns#

int array

An int array specifying for each element to which part it belongs. Values are in the range 0..nparts.

Notes#

In order for the operation to be non-trivial, the specified edges, possibly together with (parts of) the border, should form one or more closed loops.

Examples#

>>> M1 = Mesh(eltype='quad4').subdivide(2)
>>> print(M1.partition_by_curve([3, 7]))
[0 1 0 0]

Create a level-1 Mesh, and use this as the partioning curve:

>>> M2 = Mesh(eltype='quad4').subdivide(1,4)
>>> coords = Coords([[0.0, 0.25, 0.0],[1.0, 0.25, 0.0]])
>>> E = Mesh(coords,[[0,1]], eltype='line2')
>>> print(M2.partition_by_curve(E, sort='area'))
[1 0 0 0]