# Gmsh exporting wrong mesh DATA [closed]

so hopefully I'll be using gmsh to make meshes out of 2-D cross sections with o thickness. I tried to make a structured mesh with quad elements of a rectangular cross-section, but when I checked the .mesh file to see if it had the correct number of elements and nodes, it hadn't and I can't seem to figure out why...

I'll post the .geo and .mesh files here:

.geo file:

// Gmsh project created on Mon Apr 09 15:44:32 2018
Point(1) = {0, 0, 0, 1};
Point(2) = {6, 0, 0, 1};
Point(3) = {6, 2, 0, 1};
Point(4) = {0, 2, 0, 1};
Line(1) = {1, 2};
Line(2) = {2, 3};
Line(3) = {3, 4};
Line(4) = {4, 1};
Physical Line("left") = {4};
Physical Line("right") = {2};
Physical Line("top") = {3};
Physical Line("bottom") = {1};
Line Loop(1) = {4, 1, 2, 3};
Plane Surface(1) = {1};
Transfinite Surface {1} = {1, 2, 3, 4};
Transfinite Line {4, 2} = 3 Using Progression 1;
Transfinite Line {1, 3} = 7 Using Progression 1;
Recombine Surface {1};


.mesh file:

$MeshFormat 2.2 0 8$EndMeshFormat
$PhysicalNames 4 1 1 "left" 1 2 "right" 1 3 "top" 1 4 "bottom"$EndPhysicalNames
$Nodes 16 1 0 0 0 2 6 0 0 3 6 2 0 4 0 2 0 5 0.999999999995645 0 0 6 1.99999999999205 0 0 7 2.999999999988572 0 0 8 3.999999999992324 0 0 9 4.999999999996161 0 0 10 6 0.9999999999973842 0 11 5.000000000006331 2 0 12 4.000000000003875 2 0 13 3.000000000008324 2 0 14 2.000000000005607 2 0 15 1.000000000002804 2 0 16 0 1.000000000004119 0$EndNodes
$Elements 16 1 1 2 4 1 1 5 2 1 2 4 1 5 6 3 1 2 4 1 6 7 4 1 2 4 1 7 8 5 1 2 4 1 8 9 6 1 2 4 1 9 2 7 1 2 2 2 2 10 8 1 2 2 2 10 3 9 1 2 3 3 3 11 10 1 2 3 3 11 12 11 1 2 3 3 12 13 12 1 2 3 3 13 14 13 1 2 3 3 14 15 14 1 2 3 3 15 4 15 1 2 1 4 4 16 16 1 2 1 4 16 1$EndElements


I was supposed to get 12 elements and 21 nodes, but I'm getting 16 elements and 16 nodes... Would be really grateful if anyone can help me with this. Thanks in advance!

PS: I just need a quad-only mesh generator, if you know any open source one besides gmsh let me know!

You have specified the wrong things to be Physical. If you just want to obtain 2-D elements, there is no need to specify the lines to be physical. However, you certainly need to specify your surface to be physical.

Also, you may want to specify the #points in the structured mesh for transfinite lines before announcing the Surface to be transfinite.

Please, see the corrected code attached that produces exactly 12 2-D elements and 21 nodes.

Point(1) = {0, 0, 0, 1};
Point(2) = {6, 0, 0, 1};
Point(3) = {6, 2, 0, 1};
Point(4) = {0, 2, 0, 1};
Line(1) = {1, 2};
Line(2) = {2, 3};
Line(3) = {3, 4};
Line(4) = {4, 1};
Line Loop(1) = {4, 1, 2, 3};
Plane Surface(1) = {1};
Transfinite Line {4, 2} = 3 Using Progression 1;
Transfinite Line {1, 3} = 7 Using Progression 1;
Transfinite Surface {1} = {1, 2, 3, 4};
Recombine Surface {1};
Physical Surface(1) = {1};

• I just tried that and it worked wonders! Thank you very much – MafiaSkafia Apr 9 '18 at 17:40