15. 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(data=[], dtyp=None, copy=False, nplex=0, eltype=None)[source]

A class for handling element to node connectivity.

A connectivity object is a 2-dimensional integer array with all non-negative values. Each row of the array defines an element by listing the numbers of its lower entity types. A typical use is a Mesh object, where each element is defined in function of its nodes. While in a Mesh the word ‘node’ will normally refer to a geometrical point, here we will use ‘node’ for the lower entity whatever its nature is. It doesn’t even have to be a geometrical entity.

Note

The current implementation limits a Connectivity object to numbers that are smaller than 2**31. That is however largely sufficient for all practical cases.

In a row (element), the same node number may occur more than once, though usually all numbers in a row are different. Rows containing duplicate numbers are called degenerate elements. Rows containing the same node sets, albeit different permutations thereof, are called duplicates.

Parameters
  • data (int array_like) – Data to initialize the Connectivity. The data should be 2-dim with shape (nelems,nplex), where nelems is the number of elements and nplex is the plexitude of the elements.

  • dtyp (float datatype, optional) – It not provided, the datatype of data is used.

  • copy (bool, optional) – If True, the data are copied. The default setting will try to use the original data if possible, e.g. if data is a correctly shaped and typed numpy.ndarray.

  • nplex (int, optional) – The plexitude of the data. This can be specified to force a check on the plexitude of the data, or to set the plexitude for an empty Connectivity. If an eltype is specified, the plexitude of the element type will override this value.

  • eltype (str or elements.ElementType subclass, optional) – The element type associated with the Connectivity. It can be either a subclass of:class:elements.ElementType or the name of such a subclass. If not provided, a non-typed Connectivity will result.

Raises

ValueError – If nplex is provided and the specified data do not match the specified plexitude.

Notes

The Connectivity class has no knowledge about the geometrical meaning of the element types. In most cases the use of its subclass Elems is therefore more appropriate.

Empty Connectivities with nelems==0 and nplex > 0 can be useful, but a Connectivity with nplex==0 generally is not.

See also

Elems

a subclass that holds geometrical information about the element types and is used to create Mesh geometries.

Examples

>>> Connectivity([[0,1,2],[0,1,3],[0,3,2],[0,5,3]])
Connectivity([[0, 1, 2],
              [0, 1, 3],
              [0, 3, 2],
              [0, 5, 3]])
>>> Connectivity(np.array([],dtype=at.Int).reshape(0,3))
Connectivity([], shape=(0, 3))