34. polygons — Polygon meshes.

This module defines the Polygons class, which can be used to describe discrete geometrical models consisting of polygons.

34.1. Classes defined in module polygons

class polygons.Polygons(coords=None, elems=None, *, prop=None, check=True)[source]

Polygons is a discrete geometrical model consisting of polygons.

The Polygons class is implemented in a similar manner as the Mesh and :class`TriSurface` classes: the coordinates of all the vertices are collected in a single Coords array, and the ‘elements’ (polygons) are defined using indices into that array. While the Mesh and :class`TriSurface` classes store the elements in an Elems array (requiring a fixed plexitude for all elements), the Polygons class uses a Varray so that the polygons can have a variable number of vertices.

Parameters
  • coords (coords_like) – A 2-dim Coords (or data to initalize it) with the coordinates of all the vertices used to define the polygons.

  • elems (Varray) – A Varray (or data to initalize it) with the indices of the vertices that define each of the polygons. All values in elems should be in the range 0 <= value < len(coords).

  • prop (int array_like, optional) – 1-dim int array with non-negative element property numbers. If provided, setProp() will be called to assign the specified properties.

Examples

A Polygons with a triangle and a square.

>>> P = Polygons(Coords('0123'), [[0,1,2], [0,1,2,3]])
>>> print(P.report())
Polygons: nnodes: 4, nelems: 2, nplex: min 3, max 4, eltype: polygon
  BBox: [0. 0. 0.], [1. 1. 0.]
  Size: [1. 1. 0.]
  Coords: [[0. 0. 0.]
           [1. 0. 0.]
           [1. 1. 0.]
           [0. 1. 0.]]
  Elems: Varray (2, (3, 4))
           [0 1 2]
           [0 1 2 3]

34.2. Functions defined in module polygons

polygons.nodalVSum(val, elems, nnod=None)[source]

Compute the nodal sum of values defined at polygon vertices.

This is like arraytools.nodalSum(), but where elems is defined as a Varray and val contains the value in order of that Varray.

Parameters
  • val (float array (nsize, nval)) – Defines nval values at elems.nsize vertices.

  • elems (Varray) – The node indices of nelems polygons.

  • nnod (int) – The number of nodes. This should be higher than the maximum value in elems. If not specified, it will be set to the highest value in elems + 1.

Returns

  • sum (float ndarray (nnod, nval)) – The sum of all the values at the same node.

  • cnt (int ndarray (nnod)) – The number of values summed at each node.