17
$\begingroup$

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?

$\endgroup$
10
$\begingroup$

I 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.

$\endgroup$
  • $\begingroup$ Unfortunately, the scripting language is insane. ;) $\endgroup$ – Nico Schlömer Jun 4 '13 at 18:11
  • $\begingroup$ In what way? Are you refering to the text file inputs, or some other interface? $\endgroup$ – Godric Seer Jun 4 '13 at 18:17
  • 2
    $\begingroup$ I have only used gmsh in someone simple-ish geometries since my problems are almost always complicated by factors other than geometry. While I have only worked on these simpler geometries, I definitely found gmsh to be the most intuitive and easiest to learn. I won't argue with you though about trying to do more complicated procedures since I don't have experience with them. $\endgroup$ – Godric Seer Jun 4 '13 at 18:28
  • 5
    $\begingroup$ You can always write your scripts in whatever language you like and simply create files as a result of your script that are then fed as inputs to gmsh. $\endgroup$ – Wolfgang Bangerth Jun 5 '13 at 10:34
  • 1
    $\begingroup$ @WolfgangBangerth I actually started a little toy project in Python on github.com/nschloe/python4gmsh. $\endgroup$ – Nico Schlömer Oct 3 '13 at 21:53
4
$\begingroup$

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.

$\endgroup$
  • 2
    $\begingroup$ "Please note that TetGen is free for research and non-commercial uses. For any commercial utilization, a commercial license is available upon request." -- This is not a free or open source software license (under OSI or FSF definition), let alone an MIT license. $\endgroup$ – Jed Brown Jun 5 '13 at 4:25
  • $\begingroup$ Yes I just read the first bit of the License file. Most people are not as strict in their meaning of Free as the OSI or FSF. $\endgroup$ – aterrel Jun 5 '13 at 13:41
  • $\begingroup$ I was about to ask a similar question. Is tetgen compatible with FEniCS? $\endgroup$ – seb Jun 5 '13 at 14:10
  • $\begingroup$ @aterrel Read the LICENSE file: "This means that TetGen is no free software, but for private, research, and educational purposes it can be used at absolutely no cost and without further arrangements." $\endgroup$ – Jed Brown Jun 5 '13 at 14:16
  • 1
    $\begingroup$ Yes, @JedBrown, I agreed with you and edited the response. But to the laymen, free usually means "I don't have to pay for it" not the RMS legalize. I would also argue that GPL is not "free" but that is probably not an appropriate discussion for this forum. $\endgroup$ – aterrel Jun 5 '13 at 14:55
3
$\begingroup$

MeshPy can be used for obtaining triangular and tetrahedral meshes. It provides an easy means of scripted mesh generation.

MeshPy provides Python interfaces to Triangle and TetGen mentioned by aterrel.

$\endgroup$
1
$\begingroup$

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!

$\endgroup$
  • $\begingroup$ I don't like the fact that nothing in the geometry model is editable from either UI or Python console. Basically if you want to do changes you need to delete and recreate. That adds a lot of overhead during design $\endgroup$ – lurscher Dec 4 '13 at 17:49
  • $\begingroup$ This is true if you import a geometry given to you in a STEP file for example. But if I am not mistaken, this is also true for the other programs mentioned here! Moreover, if you have the HDF file or the python dump script, you can surely change anything. $\endgroup$ – FlatronL1917 Jan 7 '14 at 13:14
1
$\begingroup$

OpenSCAD fits all points except volume meshing. It is based on input scripts and generates STL surface meshes.

$\endgroup$
1
$\begingroup$

In the meantime, I created

  • pygmsh as a Python front end for gmsh and
  • pygalmesh as a Python front end for CGAL's 3D meshing capabilities.

Both are fairly well received, so I'm guessing they are helpful to others as well.

$\endgroup$
1
$\begingroup$

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:

enter image description here

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

$\endgroup$
  • $\begingroup$ Blender can do this? Never knew. How would I triangulate, for example, a circle? $\endgroup$ – Nico Schlömer Mar 31 '17 at 8:32
  • $\begingroup$ @ChristianClason: How is this not an answer? It addresses the question. You can complain that it lacks detail or even that it is wrong, but that’s what downvotes are for. It certainly isn’t a comment. $\endgroup$ – Wrzlprmft Mar 31 '17 at 10:50
  • $\begingroup$ @Wrzlprmft Thanks a lot. I think that could be good if I will provide to Nico Schlömer a detailed videotutorial, writing the essential code here. But in the meanwhile, I can link a topic written by myself times ago in Italian language, asking for an help to export a mesh by using Blender's scripting (that website has been updated, for which some resources are not more available): blender.it/forums/topic/difetto-texture-file-obj-da-wrl Here an example of videotutorial on YouTube: youtube.com/watch?v=K0yb4sZ7B4g $\endgroup$ – Riccardo Volpe Mar 31 '17 at 16:46
  • $\begingroup$ If you have something to add to your question, please edit it in. $\endgroup$ – Wrzlprmft Mar 31 '17 at 16:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.