0
votes

I've been trying without success to create a 3D SURFACE mesh using GMSH (v.3.0.6).

The problem that I am having is, after creating the surface and generating the mesh, when I read the .MSH file, I get a bizarre node numbering, i.e., not all the normal vectors are oriented outward, some points inward. I tried to create a cube and a sphere, but I always face the very same problem.

Below is the .GEO file I created using the GMSH GUI for the cube.

    // Gmsh project created on Fri Apr 20 17:08:44 2018
//+
Point(1) = {1, 0, 0, 1.0};
//+
Point(2) = {1, 1, 0, 1.0};
//+
Point(3) = {0, 1, 0, 1.0};
//+
Point(4) = {0, 0, 1, 1.0};
//+
Point(5) = {1, 0, 1, 1.0};
//+
Point(6) = {1, 1, 1, 1.0};
//+
Point(7) = {0, 1, 1, 1.0};
//+
Point(8) = {0, 0, 0, 1.0};
//+
Line(1) = {7, 6};
//+
Line(2) = {6, 5};
//+
Line(3) = {5, 1};
//+
Line(4) = {1, 8};
//+
Line(5) = {8, 3};
//+
Line(6) = {3, 7};
//+
Line(7) = {7, 4};
//+
Line(8) = {4, 8};
//+
Line(9) = {4, 5};
//+
Line(10) = {2, 1};
//+
Line(11) = {2, 6};
//+
Line(12) = {2, 3};
//+
Line Loop(1) = {6, 1, -11, 12};
//+
Plane Surface(1) = {1};
//+
Line Loop(2) = {11, 2, 3, -10};
//+
Plane Surface(2) = {2};
//+
Line Loop(3) = {2, -9, -7, 1};
//+
Plane Surface(3) = {3};
//+
Line Loop(4) = {6, 7, 8, 5};
//+
Plane Surface(4) = {4};
//+
Line Loop(5) = {8, -4, -3, -9};
//+
Plane Surface(5) = {5};
//+
Line Loop(6) = {10, 4, 5, -12};
//+
Plane Surface(6) = {6};
//+
Physical Surface(1) = {4, 3, 2, 6};
//+
Physical Surface(2) = {1};
//+
Physical Surface(3) = {5};
//+
Surface Loop(1) = {6, 2, 1, 4, 3, 5};
//+
Volume(1) = {1};

Since I also define a volume, all the normal vectors are supposed to point OUTWARD. Any idea how can I make it right (or the way I need it to be)?

Thanks all in advance,

1

1 Answers

3
votes

The ordering of the lines in Line Loop affects what normal is going to be used in the Surface created from this Line Loop. You either have to be consistent in the ordering of the lines in ALL of your Line Loops – or you can flip the ordering for the ones causing troubles.

For the normals to point outwards, for this particular example, you can just change two lines:

Plane Surface(3) = {-3};
Plane Surface(4) = {-4};

That tells GMSH, to invert the ordering of the lines in the Line Loop, therefore obtaining the opposite normal.

For reference, here is the overall corrected GMSH script that generates the mesh with correct normals:

Point(1) = {1, 0, 0, 1.0};
Point(2) = {1, 1, 0, 1.0};
Point(3) = {0, 1, 0, 1.0};
Point(4) = {0, 0, 1, 1.0};
Point(5) = {1, 0, 1, 1.0};
Point(6) = {1, 1, 1, 1.0};
Point(7) = {0, 1, 1, 1.0};
Point(8) = {0, 0, 0, 1.0};
Line(1) = {7, 6};
Line(2) = {6, 5};
Line(3) = {5, 1};
Line(4) = {1, 8};
Line(5) = {8, 3};
Line(6) = {3, 7};
Line(7) = {7, 4};
Line(8) = {4, 8};
Line(9) = {4, 5};
Line(10) = {2, 1};
Line(11) = {2, 6};
Line(12) = {2, 3};
Line Loop(1) = {6, 1, -11, 12};
Plane Surface(1) = {1};
Line Loop(2) = {11, 2, 3, -10};
Plane Surface(2) = {2};
Line Loop(3) = {2, -9, -7, 1};
Plane Surface(3) = {-3};
Line Loop(4) = {6, 7, 8, 5};
Plane Surface(4) = {-4};
Line Loop(5) = {8, -4, -3, -9};
Plane Surface(5) = {5};
Line Loop(6) = {10, 4, 5, -12};
Plane Surface(6) = {6};
Physical Surface(1) = {4, 3, 2, 6};
Physical Surface(2) = {1};
Physical Surface(3) = {5};
Surface Loop(1) = {6, 2, 1, 4, 3, 5};
Volume(1) = {1};