Skip to content

getPhysicalGroups is not returning the correct tags

I wrote a simple code to specify different boundary types but when i access the physical groups using gmsh.model.getPhysicalGroups, it is not returning the correct results

Have a look at my code here,

from pygmsh.geo.geometry import Geometry

x0= np.array([0,0,0])
width, length= 5,10

with Geometry() as geom:
    rect= geom.add_polygon([
        (x0).tolist(),
        (x0 + [0,width,0]).tolist(), 
        (x0 + [length,width,0]).tolist(), 
        (x0 + [length,0,0]).tolist()
    ])
    geom.add_physical(rect.lines[0], "Displacement")
    geom.add_physical(rect.lines[2], "Traction")

    mesh = geom.generate_mesh(algorithm=6)
    
    print(gmsh.model.getPhysicalGroups(dim=1)) 
    
    gmsh.fltk.run()

This should have printed [(1, 1), (1, 3)] but instead it prints [(1, 1), (1, 2)]

But when i visualise the geometry it is correct, here have a look, Screenshot_2021-10-19_at_09.48.48