61. plugins.fe
— Finite Element Models in pyFormex.¶
Finite element models are geometrical models that consist of a unique set of nodal coordinates and one of more sets of elements.
61.1. Classes defined in module plugins.fe¶
-
class
plugins.fe.
FEModel
(meshes, fuse=True, **kargs)[source]¶ A base class for a Finite Element Model.
An FEModel is a collection of
Mesh
instances which share a single set of nodes.Examples
>>> from ..formex import Formex >>> M0 = Formex('4:01234412').toMesh().setProp(1) >>> M1 = Formex('3:027138').toMesh().setProp(2) >>> FEM = FEModel([M0,M1]) Finite Element Model Number of nodes: 7 Number of elements: 4 Number of element groups: 2 Number of elements per group: [2, 2] Plexitude of each group: [4, 3] >>> print(FEM.celems) [0 2 4] >>> print(FEM.coords) [[ 0. -1. 0.] [ 1. -1. 0.] [-1. 0. 0.] [ 0. 0. 0.] [ 1. 0. 0.] [ 0. 1. 0.] [ 1. 1. 0.]] >>> for e in FEM.elems: print(repr(e)) Elems([[3, 4, 6, 5], [3, 0, 1, 4]], eltype=Quad4) Elems([[3, 5, 2], [3, 2, 0]], eltype=Tri3) >>> for p in FEM.props(): print(p) [1 1] [2 2] >>> for M in FEM.meshes(): print(M) Mesh: nnodes: 7, nelems: 2, nplex: 4, level: 2, eltype: quad4 BBox: [-1. -1. 0.], [ 1. 1. 0.] Size: [ 2. 2. 0.] Area: 2.0 Mesh: nnodes: 7, nelems: 2, nplex: 3, level: 2, eltype: tri3 BBox: [-1. -1. 0.], [ 1. 1. 0.] Size: [ 2. 2. 0.] Area: 1.0 >>> glo, loc = FEM.splitElems([0,1,2]) >>> print(glo) [array([0, 1]), array([2])] >>> print(loc) [array([0, 1]), array([0])] >>> FEM.elemNrs(1,[0,1]) array([2, 3]) >>> FEM.getElems([[], [0,1]]) [Elems([], shape=(0, 4), eltype=Quad4), Elems([[3, 5, 2], [3, 2, 0]], eltype=Tri3)]
-
mplex
()[source]¶ Return the plexitude of all the element groups in the model.
Returns a list of integers.
-
props
()[source]¶ Return the individual prop arrays for all element groups.
Returns: list of int arrays – A list with the prop array for each of the element groups in the model.
-
meshes
(sel=None)[source]¶ Return the element groups as a list of separate Meshes.
Parameters: sel (int array_like) – The list of global element numbers to be included in the output. The default is to include all elements. Returns: list of Mesh
– A list with the Meshes corresponding with the (possibly partial) element groups in the model. The Meshes are not compacted and may be empty.
-
splitElems
(sel=None)[source]¶ Splits a list of element numbers over the element groups.
Parameters: sel (int array_like, optional.) – A list of global element numbers. All values should be in the range 0..self.nelems(). If not provided, the list of all elements is used. Returns: - global (lists of int arrays) – A list with the global element numbers from the input that belong to each of the groups.
- local (list of int arrays) – A list with the local (group) element numbers corresponding with the returned global numbers.
-
elemNrs
(group, elems=None)[source]¶ Return the global element numbers for given local group numbers.
Parameters: - group (int) – The group number
- elems (int array_like) – A list of local element numbers from the specified group. If omitted, the list of all the elements in that group is used.
Returns: int array – A list with global element numbers corresponding with input.
-
getElems
(sel)[source]¶ Return the definitions of selected elements.
Parameters: sel (list of int array_like) – A list with for each element group the list of local element numbers to be included in the output. Returns: list of Elems
– The connectivity table of the selected elements.
-
getProps
(sel)[source]¶ Return the prop values of selected elements.
Parameters: sel (list of int array_like) – A list with for each element group the list of local element numbers to be included in the output. Returns: list of int arrays – The prop values of the selected elements.
-
renumber
(old=None, new=None)[source]¶ Renumber a set of nodes.
old and new are equally sized lists with unique node numbers, all smaller than the number of nodes in the model. The old numbers will be renumbered to the new numbers. If one of the lists is None, a range with the length of the other is used. If the lists are shorter than the number of nodes, the remaining nodes will be numbered in an unspecified order. If both lists are None, the nodes are renumbered randomly.
This function returns a tuple (old,new) with the full renumbering vectors used. The first gives the old node numbers of the current numbers, the second gives the new numbers corresponding with the old ones.
-
61.2. Functions defined in module plugins.fe¶
-
plugins.fe.
mergedModel
(meshes, **kargs)[source]¶ Returns the fe Model obtained from merging individual meshes.
The input arguments are (coords,elems) tuples. The return value is a merged fe Model.
-
plugins.fe.
Model
(coords, elems, prop=None, fuse=False, **kargs)[source]¶ Create an FEModel from a single Coords and multiple Elems.
This is a convenience function to create an FEModel from a single Coords block and a list of Elems, and avoid the fusing and renumbering of the nodes.
Parameters: - coords (Coords) – A single block of nodes shared by all the meshes in the model.
- elems (list of Elems) – A list of element connectivity tables, that can have different element types.
- prop (list of prop) – A list of prop arrays for the meshes. If props are specified, they need to be given for all the meshes.