pygmsh icon indicating copy to clipboard operation
pygmsh copied to clipboard

Specifying boundaries on a polygon

Open nguyenkhoa0209 opened this issue 4 years ago • 3 comments

Hello, I would like to create my geometry and then specify boundaries. The way I create the geometry is similar as your example:

with pygmsh.geo.Geometry() as geom:
    poly = geom.add_polygon(
        [
            [0.0, 0.0],
            [2.0, 0.0],
            [3.0, 1.0],
            [1.0, 2.0],
            [0.0, 1.0],
        ],
        mesh_size=0.3,
    )`

Then I would like to specify, for example, the edge between two points: [0.0, 0.0], [2.0, 0.0] as a 'top' boundary, and the edges created by the other vertex as 'bottom' boundary. How can I do this? My purpose is to specify these boundaries and then export into a .msh file to solve a PDE with Fenics.

Thank you for your help.

nguyenkhoa0209 avatar Jun 09 '21 06:06 nguyenkhoa0209

I guess you can use poly.lines

for example:

with pygmsh.geo.Geometry() as geom:
    poly = geom.add_polygon(
        [
            [0.0, 0.0],
            [2.0, 0.0],
            [3.0, 1.0],
            [1.0, 2.0],
            [0.0, 1.0],
        ],
        mesh_size=0.3,
    )

    geom.add_physical(poly.lines[0], "top")
    geom.add_physical(poly.lines[1:], "bottom")
    geom.generate_mesh()
    geom.synchronize()
    gmsh.fltk.run()

Zevrap-81 avatar Oct 14 '21 11:10 Zevrap-81

@Zevrap-81 Instead of attaching your code as a zip, better just copy-paste it with triple backticks.

nschloe avatar Oct 14 '21 11:10 nschloe

@Zevrap-81 Instead of attaching your code as a zip, better just copy-paste it with triple backticks.

Thanks for the tip 👍

Zevrap-81 avatar Oct 14 '21 11:10 Zevrap-81