I'm looking for a mesh generation software that
- is free and open source,
- provides a sane scripting interface for domain specification,
- works for complex geometries,
- can generate 2D and 3D meshes,
What options do I have?
Computational Science Stack Exchange is a question and answer site for scientists using computers to solve scientific problems. It only takes a minute to sign up.
Sign up to join this communityI would recommend you look at gmsh. It has both text and CAD-like input, capable of 2D and 3D, higher order meshes. It is licensed under the GPL, so there are some restrictions on integrating it into closed source software, but is otherwise completely free/open-source.
I usually use tetgen for 3D (MIT license for research/non-commercial) and triangle for 2D (Custom license free for non-commercial). To script them, you write a input file and call the command line.
I have found Salome to be very flexible, with a much better environment than gmsh. It has a much more professional feel IMHO. Moreover, it can generate also hexahedral meshes. It is really worth a try!
OpenSCAD fits all points except volume meshing. It is based on input scripts and generates STL surface meshes.
Why not Blender? It is a powerful, free and open-source software with python scripting support too.
In Blender 2.79 you need to choose Scripting
as Screen layout
.
In the top-left Text Editor
press + to create a new text data-block; start it with import bpy
and then insert the python commands relative to each operation that you can do from the GUI, reading the relative command putting your mouse over the GUI item.
In the attached screenshot are shown the commands to triangulate a circle, starting from the default scene with a cube:
In this way, you can use Blender in scripting mode, without its GUI to export, for example, an output file, running your python script in a terminal:
blender --background --python myscript.py
Here a videotutorial on YouTube.
Cheers