# gmsh python api ignores quad mesh option [closed]

I am trying to mesh a geometry using the gmsh python api, however it seems like my algorithm selection option (i.e. gmsh.option.setNumber("Mesh.Algorithm", 8) ) is being ignored. Can anyone tell me if this is a bug or if I am simply making a mistake. This code replicates the problem:

import gmsh
import sys
h=1.0

gmsh.initialize(sys.argv)

#gmsh.option.setNumber("General.Terminal", 1)
#use the quad mesh alogrithm Mesh.Algorithm = 8
gmsh.option.setNumber("Mesh.Algorithm", 8);

model = gmsh.model

#have some duplicate points to make this more like my actual problem
coords=[[0,0],[100,0],[100,0],[100,30],[50,30],[50,100],[50,100],[0,100]]
points=[]
lines=[]

for point in range(len(coords)):

for i in range(len(points)):
#print(points[i],points[(i +1) % len(points)])

#join lines into a surface!

#and mesh it!
gmsh.model.geo.synchronize()
gmsh.model.mesh.generate()

gmsh.fltk.run()
gmsh.finalize()


Which generates this (clearly triangular) mesh. How can I get gmsh to use the quad mesh algorithm from within the python API instead?

• This is a problem best asked on the gmsh specific forums. Jun 9 at 1:40
• You have to turn "recombine" on. The triangles will then be recombined into quads. Jun 9 at 1:40

Based on the comment from Biswajit Banerjee (above) I determined that I was missing mesh recombine option:

 gmsh.option.setNumber("Mesh.RecombineAll", 1)


Adding this to the code fixes the issue (this apparently also addressed in appendix A of the manual.

import gmsh
import sys

h=5

gmsh.initialize(sys.argv)

#gmsh.option.setNumber("General.Terminal", 1)
gmsh.option.setNumber("Mesh.Algorithm", 8)

model = gmsh.model

#have some duplicate points to make this more like my actual problem
coords=[[0,0],[100,0],[100,0],[100,30],[50,30],[50,100],[50,100],[0,100]]
points=[]
lines=[]

for point in range(len(coords)):

for i in range(len(points)):
#print(points[i],points[(i +1) % len(points)])

#join lines into a surface!