pygmsh
pygmsh copied to clipboard
Specifying boundaries on a polygon
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.
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 Instead of attaching your code as a zip, better just copy-paste it with triple backticks.
@Zevrap-81 Instead of attaching your code as a zip, better just copy-paste it with triple backticks.
Thanks for the tip 👍