python API: fails with seg fault if mesh is generated a second time after geometry is modified
Hi Christophe,
as reported earlier, this piece of code crashes with a Seg fault when model.mesh.generate(2) is called in line A and line B without clearing the mesh first.
Henrik
import gmsh
import math
import numpy as np
model = gmsh.model
factory = model.occ
gmsh.initialize()
gmsh.option.setNumber("General.Terminal", 1)
model.add("test")
v1 = factory.addCylinder(-1.0, 0.0, 0.0, 2.0, 0.0, 0.0, 0.5)
factory.synchronize()
#line A
model.mesh.generate(2) # OK, if not mesh is not generated here
D = 0.2
p = np.array([-1.0, 0.0, 0.0])
u = np.array([0,1,0])
v = np.array([0,0,1])
s = factory.addPoint( *(p.tolist() + [D/10]) )
x = p + D/2*u
factory.addPoint( *(x.tolist() + [D/10]) )
x = p + D/2*(math.cos(2*math.pi/3)*u + math.sin(2*math.pi/3)*v)
factory.addPoint( *(x.tolist() + [D/10]) )
x = p + D/2*(math.cos(4*math.pi/3)*u + math.sin(4*math.pi/3)*v)
factory.addPoint( *(x.tolist() + [D/10]) )
c = factory.addCircleArc(s+1, s, s+2)
factory.addCircleArc(s+2, s, s+3)
factory.addCircleArc(s+3, s, s+1)
curve = factory.addCurveLoop([c, c+1, c+2])
surface = factory.addPlaneSurface([curve])
lc = factory.addCurveLoop([ i for d, i in model.getBoundary([(2,3)]) ] )
factory.remove([(3,v1), (2,3)])
factory.addPlaneSurface([ lc ] + [ surface ], 3)
factory.synchronize()
#model.mesh.clear() # OK, if mesh is generated, but cleared here
#line B
model.mesh.generate(2)
#gmsh.fltk.run()