1
$\begingroup$

I'm trying to make a 2-D quad-only mesh of an "I"-shaped cross-section, with elements of size 5. So far I've managed to make it quad only, but some elements are very distorted when they shouldn't be. Also, the total number of elements is incorrect. Can you please help me out?

Here's my .geo code:

Point(1) = {0, 0, 0, 1.0};
Point(2) = {45, 0, 0, 1.0};
Point(3) = {55, 0, 0, 1.0};
Point(4) = {100, 0, 0, 1.0};
Point(5) = {100, 10, 0, 1.0};
Point(6) = {55, 10, 0, 1.0};
Point(7) = {45, 10, 0, 1.0};
Point(8) = {0, 10, 0, 1.0};
Point(9) = {0, 90, 0, 1.0};
Point(10) = {45, 90, 0, 1.0};
Point(11) = {55, 90, 0, 1.0};
Point(12) = {100, 90, 0, 1.0};
Point(13) = {100, 100, 0, 1.0};
Point(14) = {55, 100, 0, 1.0};
Point(15) = {45, 100, 0, 1.0};
Point(16) = {0, 100, 0, 1.0};

Line(1) = {1, 2};
Line(2) = {2, 3};
Line(3) = {3, 4};
Line(4) = {4, 5};
Line(5) = {5, 6};
Line(6) = {6, 11};
Line(7) = {11, 12};
Line(8) = {12, 13};
Line(9) = {13, 14};
Line(10) = {14, 15};
Line(11) = {15, 16};
Line(12) = {16, 9};
Line(13) = {9, 10};
Line(14) = {10, 7};
Line(15) = {7, 8};
Line(16) = {8, 1};

Line Loop(1) = {14, 15, 16, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13};

Plane Surface(1) = {1};

Recombine Surface {1};

Transfinite Line {2, 4, 16, 12, 10, 8} = 3 Using Progression 1;
Transfinite Line {14, 6} = 17 Using Progression 1;
Transfinite Line {1, 15, 3, 5, 7, 9, 13, 11} = 10 Using Progression 1;
$\endgroup$
2
$\begingroup$

So, by default and without recombination to quads (comment out Recombine Surface {1}), GMSH creates a mesh like the one in the left part of the picture. And by recombining surfaces into quad-elements you will obtain the mesh in the right part of the picture. Naturally, if your recombination comes from the original triangular mesh, you would expect the "distorted" quad elements you mentioned, as well as, "incorrect" number of elements in general.

By default, GMSH uses Blossom recombination algorithm that will be unable to produce your desired mesh from a "messy" mesh like on the left. Notice, that the original mesh on the left satisfies all your requirements in terms of triangles: it actually places the required number of elements over each side (specified by your Transfinite Line definitions); however, it is free to do whatever it wants inside your I-shaped geometry - and it does.

enter image description here

One of your options, is to change the meshing algorithm for the original triangular mesh. Now, GMSH supports (experimentally) Delaunay for quads 2-D meshing algorithm that should produce the mesh you desire (if I undesrstood your intentions correctly).

enter image description here

You can select this algorithm either in the GUI: Tools->Options->Mesh->General->2-D Meshing Algorithm or by adding the following line to the beginning of your GEO-file:

Mesh.Algorithm = 8; // Delaunay for quads

To have the correct output mesh, you should also add the physical surface in the end of your file:

Physical Surface(1) = {1};
$\endgroup$
  • $\begingroup$ Thanks for your help again Anton! I tried using your solution, and i got the mesh you posted, although when i export the .msh file it comes with incorrect number of elements. I think it might because of this -> imgur.com/ac3l47p Do you think combining 3 separate surfaces will do the trick? $\endgroup$ – MafiaSkafia Apr 26 '18 at 12:34
  • $\begingroup$ @MafiaSkafia I added the physical surface and I think it did the trick. I edited the answer accordingly. $\endgroup$ – Anton Menshov Apr 26 '18 at 12:38
  • 1
    $\begingroup$ I was trying to get a quads-only mesh for a shape with disk surfaces and getting distortion where the triangles went from intervals along the boundary to a central point. I'm not bothered by if the quads are regular (they can't be...) but I was getting very long, narrow triangles where I wanted smaller quads. I followed the above advice, switching my 2D meshing algorithm to Delauney and it didn't change (neither did Delauney for quads). What worked was choosing 'Packing of parallelograms' as my 2D algorithm and then checking the 'Recombine all triangular meshes' box. Hope this helps anyone who $\endgroup$ – user921140 Jun 20 at 14:08
  • $\begingroup$ @user921140 that's actually quite a useful comment! I don't recall seeing this option a year ago, so that might be one of the new GMSH meshing features. Thanks! $\endgroup$ – Anton Menshov Jun 20 at 14:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.