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 singleCoords
array, and the ‘elements’ (polygons) are defined using indices into that array. While theMesh
and :class`TriSurface` classes store the elements in anElems
array (requiring a fixed plexitude for all elements), the Polygons class uses aVarray
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
) – AVarray
(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
- 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.