geometry.Geometry.add_set#
- Geometry.add_set(indices, type='node', name=None)#
Add a Set of nodes or elements to the Geometry.
Sets are named groups of nodes or elements that can be used for selection, boundary conditions, or other topological operations.
Parameters#
- indicesarray_like
A list or array of node or element indices defining the set.
- typestr, optional
The type of the set. Must be one of the types supported by the geometry (e.g. ‘node’, ‘elem’). Default is ‘node’.
- namestr, optional
The name of the set. If not provided, an automatic name like ‘set-0’ will be assigned.
Returns#
- Set
The created and stored Set object.
Examples#
>>> M = Mesh(eltype="quad4").subdivide(2) >>> M.add_set([0, 1, 2], name="set_nodes") Set(name='set_nodes', type='node', size=3) >>> M.add_set([2, 3], type="elem") Set(name='set-0', type='elem', size=2)
>>> print(M.set_report()) Set 'set_nodes', type 'node', size 3 Set 'set-0', type 'elem', size 2 >>> M.del_set('set-0') >>> print(M.set_report()) Set 'set_nodes', type 'node', size 3