I cannot reproduce your issue, as the following files produce:
cl1=10.00000;
Point(1)={0.000000000000,0.000000000000,0.000000000000,10.000000000000};
Point(2)={0.000000000000,142.396746892315,0.000000000000,10.000000000000};
Point(3)={0.000000000000,145.466715498889,0.000000000000,10.000000000000};
Point(4)={0.000000000000,200.000000000000,0.000000000000,10.000000000000};
Point(5)={77.743845982826,111.656425285816,0.000000000000,10.000000000000};
Point(6)={78.755203779039,114.726393892391,0.000000000000,10.000000000000};
Point(7)={80.725851100509,112.331578854362,0.000000000000,10.000000000000};
Point(8)={115.633749225333,0.000000000000,0.000000000000,10.000000000000};
Point(9)={118.615754343016,0.000000000000,0.000000000000,10.000000000000};
Point(10)={200.000000000000,0.000000000000,0.000000000000,10.000000000000};
Point(11)={200.000000000000,189.447515960198,0.000000000000,10.000000000000};
Point(12)={200.000000000000,191.842330998227,0.000000000000,10.000000000000};
Point(13)={200.000000000000,200.000000000000,0.000000000000,10.000000000000};
Line(1)={9,10};
Line(2)={10,11};
Line(3)={11,7};
Line(4)={7,9};
Line(5)={2,1};
Line(6)={1,8};
Line(7)={8,5};
Line(8)={5,2};
Line(9)={13,4};
Line(10)={4,3};
Line(11)={3,6};
Line(12)={6,12};
Line(13)={12,13};
Line(14)={8,9};
Line(16)={7,5};
Line(19)={6,7};
Line(21)={11,12};
Line(22)={3,2};
Line(24)={5,6};
Line(28)={5,7};
Curve Loop(1) = {1 , 2 , 3 , 4};
Curve Loop(2) = {5 , 6 , 7 , 8};
Curve Loop(3) = {9 , 10 , 11 , 12 , 13};
Curve Loop(4) = {14 , -4 , 16 , -7};
Curve Loop(5) = {-12 , 19 , -3 , 21};
Curve Loop(6) = {22 , -8 , 24 , -11};
Curve Loop(7) = {-19 , -24 , 28};
Physical Line("Right",1) = {2,13,21};
Physical Line("Left",2) = {5,10,22};
Physical Line("Top",3) = {9};
Physical Line("Bottom",4) = {1,6,14};
Plane Surface(1) = {1};
Plane Surface(2) = {2};
Plane Surface(3) = {3};
Plane Surface(4) = {4};
Plane Surface(5) = {5};
Plane Surface(6) = {6};
Plane Surface(7) = {7};
Physical Surface ("Gr1",5) = {1};
Physical Surface ("Gr2",6) = {2};
Physical Surface ("Gr3",7) = {3};
Physical Surface ("Gb",8) = {4,5,6,7};
and
import numpy as np
import meshio
def create_mesh(mesh, cell_type, prune_z=False):
cells = mesh.get_cells_type(cell_type)
cell_data = mesh.get_cell_data("gmsh:physical", cell_type)
points = mesh.points[:, :2] if prune_z else mesh.points
out_mesh = meshio.Mesh(points=points, cells={cell_type: cells}, cell_data={
"name_to_read": [cell_data]})
return out_mesh
mesh_from_file = meshio.read("meshnew.msh")
line_mesh = create_mesh(mesh_from_file, "line", prune_z=True)
meshio.write("mf.xdmf", line_mesh)
triangle_mesh = create_mesh(mesh_from_file, "triangle", prune_z=True)
meshio.write("mesh.xdmf", triangle_mesh)
assert np.allclose(line_mesh.points, triangle_mesh.points)
vertices_in_triangles = np.unique(
triangle_mesh.cells_dict["triangle"].reshape(-1))
print(vertices_in_triangles)
vertices_in_lines = np.unique(line_mesh.cells_dict["line"].reshape(-1))
print(vertices_in_lines)
executed in
docker run -ti --network=host -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix -v $(pwd):/root/shared -w /root/shared --rm ghcr.io/scientificcomputing/fenics-gmsh:2023-11-15
produces: