Creating a body in FreeCAD but being able to use a mesh made externaly in Gmsh can be useful when you want to use all the latest features from Gmsh. In this article I will be exploring how this is done in FreeCAD.
HOW TO DO IT
1. FILE TYPES
To be able to perform this approach it is important to understand the main file types involved in the process. To enable this we need to create in FreeCAD an output file that will be read by Gmsh and an input file generated by Gmsh that will be read by FreeCAD.
- FREECAD output to Gmsh: .BREP file
This file type is an OPENCascade format and will contain the geometry that Gmsh needs.
Want more details? Check here: https://dev.opencascade.org/doc/occt-6.7.0/overview/html/occt_brep_format.html
- FREECAD input from Gmsh: .unv file
This file type will contain the mesh. Nodes, elements and solids… This format will replace a mesh built inside Gmsh in FreeCAD. The origin of this file type can be seen in the following link: http://fileformats.archiveteam.org/wiki/UNV
2. HOW TO DO IT
We start by creating or importing a geometry into FreeCAD. In my case I built the geometry.
You need to select the geometry or Part in FreeCAD and then go to File -> Export
Next you need to open Gmsh and go to File -> Open
After this the geometry is displayed in Gmsh. Next you have to create a mesh. On the tree view in the left click 1D and finally 2D to get the surface elements. In my case I have a shell so I don’t need 3D elements.
After a mesh is generated we need to export the mesh in a format that FreeCAD can work with. For this we need to export to .unv, go to File -> Export
From the new window select I-deas Universal (*.unv)
Now you can close Gmsh if no more editing is needed.
It was in this part that I had most difficulty. Not because of the complexity but because I could find the unv file format. To import the mesh to FreeCAD you will need to go to File -> Import
The option is in FEM mesh formats (…, *.unv, …).
After this you will see on the tree view the following:
All the rest is the same procedure to create a simulation in the FEM workbench from FreeCAD.
From here with the model built with boundary conditions and material data you can now solve.
Importing the mesh done in Gmsh worked with no problems. The same workflow should work on other meshers as long as the formats keep the same.
3. DIFICULTY RATING
Afters this guide, meshing out of freeCAD is easy as it gets. Our rating for this guide is EASY to follow.