7. connectivity — A class and functions for handling nodal connectivity.

A class and functions for handling nodal connectivity.

This module defines a specialized array class for representing nodal connectivity. This is e.g. used in mesh models, where geometry is represented by a set of numbered points (nodes) and the geometric elements are described by refering to the node numbers. In a mesh model, points common to adjacent elements are unique, and adjacency of elements can easily be detected from common node numbers.

class connectivity.Connectivity

A class for handling element/node connectivity.

A connectivity object is a 2-dimensional integer array with all non-negative values. In this implementation, all values should be lower than 2**31.

Furthermore, all values in a row should be unique. This is not enforced at creation time, but a method is provided to check the uniqueness.

Connectivity objects have the following methods:

nelems()
nplex()
Max()
unique()
Return a list of arrays with the unique values for each row.
checkUnique()

Flag the rows which have all unique entries.

Returns an array with the value True or Falsefor each row.

check()
Returns True if all rows have unique entries.
reverseIndex()

Return a reverse index for the connectivity table.

This is equivalent to the function reverseIndex()

expand()

Transform elems to edges and faces.

Return a tuple edges,faces where

  • edges is an (nedges,2) int array of edges connecting two node numbers.
  • faces is an (nelems,nplex) int array with the edge numbers connecting each pair os subsequent nodes in the elements of elems.

The order of the edges respects the node order, and starts with nodes 0-1. The node numbering in the edges is always lowest node number first.

The inverse operation can be obtained from function compactElems.

Functions defined in the module connectivity

connectivity.magic_numbers(elems, magic)
connectivity.demagic(mag, magic)
connectivity.expandElems(elems)
connectivity.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.

connectivity.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.

connectivity.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.

connectivity.adjacencyList(elems)
Create adjacency lists for 2-node elements.
connectivity.adjacencyArray(elems, maxcon=3, neighbours=1)

Create adjacency array for 2-node elements.

The n-ring neighbourhood of the nodes is calculated (n=neighbours). These are the nodes connected through maximum n elements.

connectivity.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.

connectivity.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.

connectivity.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.

connectivity.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.

Documentation

Previous topic

6. colors — Definition of some RGB colors and color conversion functions

Next topic

8. simple — Predefined geometries with a simple shape.

This Page