Hello,
I generate a mesh written in a xdmf file with the following script, where I add the “My Volume” and “My Obstacle” physical entities.
geometry = pygmsh.geo.Geometry()
model = geometry.__enter__()
# Add circle
circle_r = model.add_circle(c, r, mesh_size=resolution)
o_in = geometry.add_point([-L/2,0,0])
o_out = geometry.add_point([L/2,0,0])
p1 = geometry.add_point([-L/2,R,0])
p2 = geometry.add_point([-L/2-R,0,0])
p3 = geometry.add_point([-L/2,-R,0])
arc_R_in_up = model.add_circle_arc(p1,o_in,p2)
arc_R_in_down = model.add_circle_arc(p2,o_in,p3)
p4 = geometry.add_point([L/2,-R,0])
p5 = geometry.add_point([L/2+R,0,0])
p6 = geometry.add_point([L/2,R,0])
arc_R_out_down = model.add_circle_arc(p4,o_out,p5)
arc_R_out_up = model.add_circle_arc(p5,o_out,p6)
channel_lines = [arc_R_in_up, arc_R_in_down, model.add_line(p3, p4), arc_R_out_down, arc_R_out_up, model.add_line(p6,p1)]
plane_surface = model.add_plane_surface(channel_loop, holes=[circle_r.curve_loop])
model.synchronize()
model.add_physical([plane_surface], "My Volume")
model.add_physical(circle_r.curve_loop.curves, "My Obstacle")
I then read the xdmf file with
mesh=Mesh()
with XDMFFile("../mesh/triangle_mesh.xdmf") as infile:
infile.read(mesh)
mvc = MeshValueCollection("size_t", mesh, 2)
with XDMFFile("../mesh/line_mesh.xdmf") as infile:
infile.read(mvc, "name_to_read")
# Define function spaces
V = VectorFunctionSpace(mesh, 'P', 2)
Q = FunctionSpace(mesh, 'P', 1)
# Define boundaries
obstacle = 'on_boundary && (x[0]*x[0] + x[1]*x[1] < (0.5*0.5))'
I would like the last line, to define the obstacle. I would like to define obstacle
by reading the pysical object above with tag “My Obstacle” directly. How can I do that?
I looked at similar posts about this, but they are unclear
Thank you