FEM Mesh
Do not translate !
Create a FEM Mesh
There are different possibilities to create a FEM Mesh in FreeCAD:
- The Gui tool
- The Gui tool by Python
- Python directly means make the FEM Mesh by Hand
- Import a FEM Mesh
Objects created in PartDesign and Part are supported, as well as simple copies of those bodies. There are two Meshers available to the user: Netgen and GMSH. Netgen is included in FreeCAD. Refer to FEM Install For FEM Mesh generation by GMSH user psicofil has provided a GMSHMesh Macro.
Element | Element | Import unv | Export unv | Export inp | Import frd | Python create | View nodes | View all |
---|---|---|---|---|---|---|---|---|
Med | CalculiX | IDEAS | IDEAS | Abaqus Mesh | CalculiX Result | FreeCAD API | ||
seg 2 | B31 | yes | yes | yes | yes | yes | yes | yes |
seg 3 | B32 | yes | yes | yes | no | no | yes | yes |
tria 3 | S3 | yes | yes | yes | yes | yes | yes | yes |
tria 6 | S6 | yes | yes | yes | yes | yes | yes | yes |
quad 4 | S4 | yes | yes | no | yes | yes | yes | yes |
quad 8 | S8 | yes | yes | no | yes | yes | no | no |
tetra 4 | C3D4 | yes | yes | yes | yes | yes | yes | yes |
tetra 10 | C3D10 | yes | yes | yes | yes | yes | yes | yes |
pyra 5 | ? | ? | ? | no | no | no | no | no |
pyra13 | ? | ? | ? | no | no | no | no | no |
hexa 8 | C3D8 | yes | yes | no | yes | yes | yes | yes |
hexa 20 | C3D20 | ? | ? | no | no | no | no | no |
penta 6 | C3D6 | ? | ? | no | no | no | no | no |
penta 15 | C3D15 | ? | ? | no | no | no | no | no |
FEM Mesh Datastructure inside FreeCAD
Element Types
If you are interested in the data structure of the Element Types inside FreeCAD have a look at FEM_Element_Types.
Segment element
Triangle element
Quadratic element
Tetrahedron element
Pyramid element
Hexahedron element
Pentahedron element
Scripting
Create a FEM Mesh totally py python
Creating a mesh with one Tet-10 Elements
import FreeCAD, Fem
# create a empty mesh
m = Fem.FemMesh()
#create the nodes
m.addNode(0,1,0)
m.addNode(0,0,1)
m.addNode(1,0,0)
m.addNode(0,0,0)
m.addNode(0,0.5,0.5)
m.addNode(0.5,0.03,.5)
m.addNode(0.5,0.5,0.03)
m.addNode(0,0.5,0)
m.addNode(0.03,0,0.5)
m.addNode(0.5,0,0)
# add the volume with the created nodes
m.addVolume([1,2,3,4,5,6,7,8,9,10])
Fem.show(m)
If you want to have predefined element and node numbering:
m.addNode(0.0,1.0,0.0,1)
m.addVolume([1,2,3,4,5,6,7,8,9,10],1)
Visual handling
Highlight some nodes on the view:
import FreeCAD, Fem
m = Fem.FemMesh()
m.addNode(0,1,0)
m.addNode(0,0,1)
m.addNode(1,0,0)
m.addNode(0,0,0)
m.addNode(0,0.5,0.5)
m.addNode(0.5,0.03,.5)
m.addNode(0.5,0.5,0.03)
m.addNode(0,0.5,0)
m.addNode(0.03,0,0.5)
m.addNode(0.5,0,0)
m.addVolume([1,2,3,4,5,6,7,8,9,10])
Fem.show(m)
Gui.ActiveDocument.ActiveObject.HighlightedNodes = [1,2,3]
Postprocessing colors and displacement:
Highlight some nodes on the view:
# set the volume 1 to red
Gui.ActiveDocument.ActiveObject.ElementColor= {1:(1,0,0)}
# set the node 1 and 2 to a certain Color and interpolate the survace
Gui.ActiveDocument.ActiveObject.NodeColor= {1:(1,0,0),2:(1,0,0)}
# set the node 1 and 2 to a certain displacement
Gui.ActiveDocument.ActiveObject.NodeDisplacement= {1:FreeCAD.Vector(1,0,0),2:FreeCAD.Vector(1,0,0)}
# double the factor of the displacement shown
Gui.ActiveDocument.ActiveObject.animate(2.0)