I used these python script to generate three-dimensional, tetrahedral mesh in my PhD study.
The ROBIN (ROtor Body INteraction) is a generic helicopter configuration consists of a fuselage and a pylon. From now on, the fuselage and pylon configuration is termed as main body. Blades, hub and other features which are not included in the main body need to be generated separately. In this code, in addition to the main body, four NACA0012-profiled blades and a hub are modelled.
CAD models are modelled in FreeCAD with python scripting. FreeCAD can be invoked with either freecadcmd fuselage_pylon.py or freecad fuselage_pylon.py which additionally opens up the FreeCAD GUI. It is possible to generate surface mesh of the main body or go further and generate three-dimensional mesh given an outer shape. In my case, the ROBIN body is cut out from a sphere and the remaining portion is meshed with tetrahedral elements. mesh.py can be modified according to your needs. FreeCAD produces mesh files in native GMSH format, that is, .geo. FreeCAD can set geometry and mesh parameters. To name a few, FreeCAD can set dimension of elements (2D or 3D), the meshing algorithm and define mesh groups in order to distinguish different regions of geometry such as walls, outer boundary and so on.
It is not expected that all GMSH features to be integrated to FreeCAD, therefore, you might want to add/remove lines from the geo file generated by FreeCAD. Since CAD modelling requires multiple iterations, it is recommended to write a script to modify the produced geo file after every iteration. modify_geo.py is the script which I used to modify the produced geo file. For example, I use few fields in order to control element volume such that the elements closer to walls have smaller volumes.
The blades and the hub are modelled/meshed with the same machinery of FreeCAD and GMSH.
Warning: Surface points of main body are obtained with super-ellipse equations. The coefficients which are used in super-ellipse equations of Mineck are wrong as pointed out here and here. The coefficients that are used in this work are in coef_fuselage.py and coef_pylon.py and are taken from the appendix of this where modified coefficients are pointed out.
Tested on: FreeCAD version: 0.18.4 GMSH 4.7.1