2.3.8 Converting a Formex to a Finite Element model

The feModel() method is important in exporting the geometry to finite element (FE) programs. A Formex often contains many points with (nearly) the same coordinates. In a finite element model, theses points have to be merged into a single nod, to express the continuity of the material. This is exactly whatfeModel() does. It returns a tuple of two numpy arrays (nodes,elems), where

>>> from simple import *
>>> F = Formex(pattern(Pattern['cube']))
>>> draw(F)
>>> nodes,elems = F.feModel()
>>> print 'Nodes',nodes
>>> print 'Elements',elems

Nodes
[[ 0.  0.  0.]
 [ 1.  0.  0.]
 [ 0.  1.  0.]
 [ 1.  1.  0.]
 [ 0.  0.  1.]
 [ 1.  0.  1.]
 [ 0.  1.  1.]
 [ 1.  1.  1.]]
Elements
[[0 1]
 [1 3]
 [3 2]
 [2 0]
 [0 4]
 [1 5]
 [3 7]
 [2 6]
 [4 5]
 [5 7]
 [7 6]
 [6 4]]

The reverse operation of transforming a finite element model back into a Formex is quite simple: Formex(nodes[elems]) will indeed be identical to the original F (within the tolerance used in merging of the nodes).

>>> G = Formex(nodes[elems])
>>> print allclose(F.f,G.f)
True
The allclose funcion in the second line tests that all coordinates in bopth arrays are the same, within a small tolerance.