### Navigation

- index
- modules |
- next |
- previous |
- pyFormex v0.8.6 documentation >
- pyFormex reference manual >

# 12. `elements` — Definition of elements.

This modules allows for a consistent local numbering scheme of element connectivities throughout pyFormex. When interfacing with other programs, one should be aware that conversions may be necessary. Conversions to/from external programs should be done by the interface modules.

`Classes defined in module elements`

class `elements.``Element`(name, doc, ndim, vertices, edges=(''[], ), faces=(''[], ), **kargs)

  Element base class: an empty element.

  All derived classes should have a capitalized name: starting with an uppercase character and further only lower case and digits.

  Each element is defined by the following attributes:

  - vertices: the natural coordinates of its vertices,
  - edges: a list of edges, each defined by 2 or 3 node numbers,
  - faces: a list of faces, each defined by a list of minimum 3 node numbers,
  - element: a list of all node numbers
  - drawfaces: a list of faces to be drawn, if different from faces. This is an optional attribute. If defined, it will be used instead of the faces attribute to draw the element. This can e.g. be used to draw approximate representations for higher order elements for which there is no correct drawing function.

  The vertices of the elements are defined in a unit space [0,1] in each axis direction.

  The elements guarantee a fixed local numbering scheme of the vertices. One should however not rely on a specific numbering scheme of edges, faces or elements. For solid elements, it is guaranteed that the vertices of all faces are numbered in a consecutive order spinning positively around the outward normal on the face.

  The list of available element types can be found by:

      >>> printElementTypes()
      Available Element Types:
        0-dimensional elements: ['point']
        1-dimensional elements: ['line2', 'line3']
        2-dimensional elements: ['tri3', 'tri6', 'quad4', 'quad6', 'quad8', 'quad9']
        3-dimensional elements: ['tet4', 'tet10', 'tet14', 'tet15', 'wedge6', 'hex8', 'hex16', 'hex20', 'icosa']

  Optional attributes:

  - conversions: Defines possible strategies for conversion of the element to other element types. It is a dictionary with the target element name as key, and a list of actions as value. Each action in the list consists of a tuple ( action, data ), where action is one of the action identifier characters defined below, and data are the data needed for this action.

  Conversion actions:

  ‘m’: add new nodes to the element by taking the mean values of existing
    nodes. data is a list of tuples containing the nodes numbers whose coorrdinates have to be averaged.
  ‘s’: select nodes from the existing ones. data is a list of the node numbers
    to retain in the new element. This can be used to reduce the plexitude but also just to reorder the existing nodes.
  ‘v’: perform a conversion via an intermediate type. data is the name of the
    intermediate element type. The current element will first be converted to the intermediate type, and then conversion from that type to the target will be attempted.
  ‘r’: randomly choose one of the possible conversions. data is a list of
    element names. This can e.g. be used to select randomly between different but equivalent conversion paths.
  `getEntities`(level, reduce=False)

    Return the type and connectivity table of some element entities.

    The full list of entities with increasing dimensionality 0,1,2,3 is:

        ['points', 'edges', 'faces', 'cells' ]

    If level is negative, the dimensionality returned is relative to the highest dimensionality (.i.e., that of the element). If it is positive, it is taken absolute.

    Thus, for a 3D element type, getEntities(-1) returns the faces, while for a 2D element type, it returns the edges. For both types however, getLowerEntities(+1) returns the edges.

    The return value is a dict where the keys are element types and the values are connectivity tables. If reduce == False: there will be only one connectivity table and it may include degenerate elements. If reduce == True, an attempt is made to reduce the degenerate elements. The returned dict may then have multiple entries.

    If the requested entity level is outside the range 0..ndim, the return value is None.

`Functions defined in module elements`

`elements.``elementType`(name=None, nplex=-1)

  Return the requested element type

  Parameters:

  - name: a string (case ignored) with the name of an element. If not specified, or the named element does not exist, the default element for the specified plexitude is returned.
  - nplex: plexitude of the element. If specified and no element name was given, the default element type for this plexitude is returned.

  Returns: a subclass of `Element`

  Errors: if neither name nor nplex can resolve into an element type,
    an error is raised.

  Example:

      >>> elementType('tri3').name()
      'tri3'
      >>> elementType(nplex=2).name()
      'line2'

`elements.``elementTypes`(ndim=None)

  Return the names of available elements.

  If a value is specified for ndim, only the elements with the matching dimensionality are returned.

`elements.``printElementTypes`()

  Print all available element types.

  Prints a list of the names of all availabale element types, grouped by their dimensionality.

### Navigation

- index
- modules |
- next |
- previous |
- pyFormex v0.8.6 documentation >
- pyFormex reference manual >