8.7.2 Functions defined in the connectivity module

magic_numbers( elems,magic)

demagic( mag,magic)

expandElems( elems)

compactElems( edges,faces)
Return compacted elems from edges and faces.

This is the inverse operation of expandElems. The algorithm only works if all vertex numbers of an element are unique.

reverseUniqueIndex( index)
Reverse an index.

index is a one-dimensional integer array with unique non-negative values.

The return value is the reverse index: each value shows the position of its index in the index array. The length of the reverse index is equal to maximum value in index plus one. Values not occurring in index get a value -1 in the reverse index.

Remark that reverseUniqueIndex(index)[index] == arange(1+index.max()). The reverse index thus translates the unique index numbers in a sequential index.

reverseIndex( index,maxcon=3)
Reverse an index.

index is a (nr,nc) shaped integer array.

The result is a (mr,mc) shaped integer array, where row i contains all the row numbers of index containing i.

Negative numbers in index are disregarded. mr will be equal to the highest positive value in index, +1. mc will be equal to the highest multiplicity of any number in index. On entry, maxcon is an estimate for this value. The procedure will automatically change it if needed.

Each row of the reverse index for a number that occurs less than mc times in index, will be filled up with -1 values.

mult is the highest possible multiplicity of any number in a single column of index.

adjacencyList( elems)
Create adjacency lists for 2-node elements.

adjacencyArray( elems,maxcon=3)
Create adjacency array for 2-node elements.

connected( index,i)
Return the list of elements connected to element i.

index is a (nr,nc) shaped integer array. An element j of index is said to be connected to element i, iff element j has at least one (non-negative) value in common with element i.

The result is a sorted list of unique element numbers, not containing the element number i itself.

adjacent( index,rev=None)
Return an index of connected elements.

index is a (nr,nc) shaped integer array. An element j of index is said to be connected to element i, iff element j has at least one (non-negative) value in common with element i.

The result is an integer array with shape (nr,mc), where row i holds a sorted list of the elements that are connected to element i, padded with -1 values to created an equal list length for all elements.

The result of this method provides the same information as repeated calls of connected(index,i), but may be more efficient if nr becomes large.

The reverse index may be specified, if it was already computed.

closedLoop( elems)
Check if a set of line elements form a closed curve.

elems is a connection table of line elements, such as obtained from the feModel() method on a plex-2 Formex.

The return value is a tuple of: - return code: - 0: the segments form a closed loop - 1: the segments form a single non-closed path - 2: the segments form multiple not connected paths - a new connection table which is equivalent to the input if it forms a closed loop. The new table has the elements in order of the loop.

connectedLineElems( elems)
Partition a segmented curve into connected segments.

The input argument is a (nelems,2) shaped array of integers. Each row holds the two vertex numbers of a single line segment.

The return value ia a list of (nsegi,2) shaped array of integers.