Billy Case
Billy Case

Reputation: 27

Gmsh export to .su2 mesh

I am currently using a python script to build a mesh around an airfoil. However, once the msh is completed and it is time to export from Gmsh to .su2 mesh format one error occurs go wrong. The mesh file that is produced for SU2 the .su2 file has points which are used in the process of building the geometry. I have tried to created physical groups and then export without hiting save all but this has been of no use. The current .geo file is the following:

Point(1)={0.99655,0.00159,0,1};
Point(2)={0.98706,0.0065,0,1};
Point(3)={0.97304,0.01434,0,1};
Point(4)={0.9553,0.02381,0,1};
Point(5)={0.93358,0.03376,0,1};
Point(6)={0.90734,0.044,0,1};
Point(7)={0.87671,0.05481,0,1};
Point(8)={0.84221,0.0662,0,1};
Point(9)={0.80436,0.07803,0,1};
Point(10)={0.76373,0.0901,0,1};
Point(11)={0.7209,0.10215,0,1};
Point(12)={0.67644,0.11391,0,1};
Point(13)={0.63092,0.12506,0,1};
Point(14)={0.58491,0.13524,0,1};
Point(15)={0.53893,0.1441,0,1};
Point(16)={0.49347,0.15116,0,1};
Point(17)={0.4487,0.15593,0,1};
Point(18)={0.40464,0.15828,0,1};
Point(19)={0.36149,0.15824,0,1};
Point(20)={0.31947,0.1559,0,1};
Point(21)={0.27885,0.15138,0,1};
Point(22)={0.23987,0.14485,0,1};
Point(23)={0.20286,0.13657,0,1};
Point(24)={0.16816,0.12676,0,1};
Point(25)={0.13611,0.11562,0,1};
Point(26)={0.107,0.10337,0,1};
Point(27)={0.08106,0.09023,0,1};
Point(28)={0.05852,0.07646,0,1};
Point(29)={0.03953,0.06232,0,1};
Point(30)={0.02421,0.04812,0,1};
Point(31)={0.01262,0.03419,0,1};
Point(32)={0.00481,0.02093,0,1};
Point(33)={0.00071,0.00879,0,1};
Point(34)={2e-05,0.00088,0,1};
Point(35)={0.00033,-0.00192,0,1};
Point(36)={0.00071,-0.00362,0,1};
Point(37)={0.00125,-0.00518,0,1};
Point(38)={0.00157,-0.0059,0,1};
Point(39)={0.00194,-0.00656,0,1};
Point(40)={0.00237,-0.00717,0,1};
Point(41)={0.00288,-0.00771,0,1};
Point(42)={0.00348,-0.00823,0,1};
Point(43)={0.00415,-0.00874,0,1};
Point(44)={0.00571,-0.00969,0,1};
Point(45)={0.00751,-0.01057,0,1};
Point(46)={0.01065,-0.01177,0,1};
Point(47)={0.01365,-0.01266,0,1};
Point(48)={0.02892,-0.01485,0,1};
Point(49)={0.04947,-0.01482,0,1};
Point(50)={0.07533,-0.01236,0,1};
Point(51)={0.1067,-0.0074,0,1};
Point(52)={0.14385,-2e-05,0,1};
Point(53)={0.18727,0.00922,0,1};
Point(54)={0.23688,0.01913,0,1};
Point(55)={0.29196,0.02865,0,1};
Point(56)={0.35163,0.03687,0,1};
Point(57)={0.41449,0.04283,0,1};
Point(58)={0.47867,0.04626,0,1};
Point(59)={0.54275,0.0476,0,1};
Point(60)={0.60579,0.04715,0,1};
Point(61)={0.6669,0.04501,0,1};
Point(62)={0.72503,0.04126,0,1};
Point(63)={0.77912,0.03625,0,1};
Point(64)={0.82836,0.0305,0,1};
Point(65)={0.87219,0.02444,0,1};
Point(66)={0.91012,0.01844,0,1};
Point(67)={0.94179,0.01286,0,1};
Point(68)={0.96692,0.00794,0,1};
Point(69)={0.98519,0.0039,0,1};
Point(70)={0.99629,0.00106,0,1};
Point(71)={0.99655,0.25159,0,1};
Point(72)={0.67644,0.36391,0,1};
Point(73)={0.20286,0.38656999999999997,0,1};
Point(74)={-0.75,0,0,1};
Point(75)={0.23688,-0.23087,0,1};
Point(76)={0.72503,-0.20874,0,1};
Point(77)={0.99629,-0.24894,0,1};
Point(78)={0.99655,10.13657,0,1};
Point(79)={0.20286,10.13657,0,1};
Point(80)={-30,0,0,1};
Point(81)={0.23688,-9.98087,0,1};
Point(82)={0.99629,-9.98087,0,1};
BSpline(1)={1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23};
Transfinite Curve {1}=20 Using Progression 1;
BSpline(2)={23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54};
Transfinite Curve {2}=50 Using Progression 1;
BSpline(3)={54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70};
Transfinite Curve {3}=20 Using Progression 1;
BSpline(4)={71, 72, 73};
Transfinite Curve {4}=20 Using Progression 1;
BSpline(5)={73, 74, 75};
Transfinite Curve {5}=50 Using Progression 1;
BSpline(6)={75, 76, 77};
Transfinite Curve {6}=20 Using Progression 1;
BSpline(7)={79, 80, 81};
Transfinite Curve {7}=50 Using Progression 1;
Line(8)={70,1};
Transfinite Curve {8}=5 Using Progression 1;
Line(9)={1,71};
Transfinite Curve {9}=10 Using Progression 1.2;
Line(10)={71,78};
Transfinite Curve {10}=10 Using Progression 1;
Line(11)={78,79};
Transfinite Curve {11}=20 Using Progression 1;
Line(12)={79,73};
Transfinite Curve {12}=10 Using Progression 1;
Line(13)={23,73};
Transfinite Curve {13}=10 Using Progression 1.2;
Line(14)={54,75};
Transfinite Curve {14}=10 Using Progression 1.2;
Line(15)={75,81};
Transfinite Curve {15}=10 Using Progression 1;
Line(16)={81,82};
Transfinite Curve {16}=20 Using Progression 1;
Line(17)={82,77};
Transfinite Curve {17}=10 Using Progression 1;
Line(18)={70,77};
Transfinite Curve {18}=10 Using Progression 1.2;
Point(83)={20.99655,10.13657,0,1};
Point(84)={20.99655,0.25159,0,1};
Point(85)={20.99655,0.00159,0,1};
Point(86)={20.99655,0.00106,0,1};
Point(87)={20.99655,-0.24894,0,1};
Point(88)={20.99655,-9.98087,0,1};
Line(19)={78,83};
Transfinite Curve {19}=20 Using Progression 1;
Line(20)={71,84};
Transfinite Curve {20}=20 Using Progression 1;
Line(21)={1,85};
Transfinite Curve {21}=20 Using Progression 1;
Line(22)={70,86};
Transfinite Curve {22}=20 Using Progression 1;
Line(23)={77,87};
Transfinite Curve {23}=20 Using Progression 1;
Line(24)={82,88};
Transfinite Curve {24}=20 Using Progression 1;
Line(25)={86,85};
Transfinite Curve {25}=5 Using Progression 1;
Line(26)={85,84};
Transfinite Curve {26}=10 Using Progression 1.2;
Line(27)={84,83};
Transfinite Curve {27}=10 Using Progression 1;
Line(28)={86,87};
Transfinite Curve {28}=10 Using Progression 1.2;
Line(29)={87,88};
Transfinite Curve {29}=10 Using Progression 1;
Curve Loop(1) = {12, 5, 15, -7};Curve Loop(2) = {14, -5, -13, 2};Curve Loop(3) = {10, 11, 12, -4};Curve Loop(4) = {9, 4, -13, -1};Curve Loop(5) = {3, 18, -6, -14};Curve Loop(6) = {6, -17, -16, -15};Curve Loop(7) = {19, -27, -20, 10};Curve Loop(8) = {20, -26, -21, 9};Curve Loop(9) = {25, -21, -8, 22};Curve Loop(10) = {22, 28, -23, -18};Curve Loop(11) = {23, 29, -24, 17};Plane Surface(1) = {1};
 Transfinite Surface {1};
 Recombine Surface {1};
 Plane Surface(2) = {2};
 Transfinite Surface {2};
 Recombine Surface {2};
 Plane Surface(3) = {3};
 Transfinite Surface {3};
 Recombine Surface {3};
 Plane Surface(4) = {4};
 Transfinite Surface {4};
 Recombine Surface {4};
 Plane Surface(5) = {5};
 Transfinite Surface {5};
 Recombine Surface {5};
 Plane Surface(6) = {6};
 Transfinite Surface {6};
 Recombine Surface {6};
 Plane Surface(7) = {7};
 Transfinite Surface {7};
 Recombine Surface {7};
 Plane Surface(8) = {8};
 Transfinite Surface {8};
 Recombine Surface {8};
 Plane Surface(9) = {9};
 Transfinite Surface {9};
 Recombine Surface {9};
 Plane Surface(10) = {10};
 Transfinite Surface {10};
 Recombine Surface {10};
 Plane Surface(11) = {11};
 Transfinite Surface {11};
 Recombine Surface {11};
Physical Curve("airfoil") = {1, 2, 3,8};
Physical Curve("farfield") = {25, 26, 27, 19, 11, 7, 16, 24, 29, 28};
Physical Surface("domain") = {1, 3, 7, 11, 8, 10, 6, 5, 2, 4,9};

Upvotes: 1

Views: 1909

Answers (3)

bexben
bexben

Reputation: 1

An easy soluton here is to add the following at the end of your .geo file, and before any scripts if you use scripts:

Delete { Points{:}; }

This deletes all the points after they are used for reference, keeping geometry and mesh intact.

So in short: Make your mesh in GMSH, add the above line, export as SU2, Do NOT save all elements. And Don't define any physical surfaces (2D), presumably don't define physical volumes if working in 3D, but unverified.

Upvotes: 0

TobiK
TobiK

Reputation: 1

With gmsh 4.8.4 under Windows this problem does not occur and your script works fine. You already mention the 2 important steps:

  1. Create Physical Tags for boundaries and the Surface in 2D (or Volume in 3D). Although the name of the Physical Surface(/Volume) will not appear in the mesh for the .su2-format, it is important to create it. To my knowledge gmsh only writes what is contained in a Physical Tag IF...

  2. ... you do not select the Save all elements when exporting the mesh.

You can extend the above gmsh script by:

Mesh 1; Mesh 2; // do 1D and 2D meshing
Mesh.Format = 42; // specifies the .su2 format
Mesh.SaveAll= 0; // 0= No (default), 1= Yes
Save "mesh_name.su2";

to create the mesh and Save it correctly (e.g. without saving all elements) just by calling the script.

With Mesh.SaveAll= 0; I get the correct amount of 2454 nodes written into the mesh. In the .su2 format the points section starts with NPOIN= 2454 in this case

NPOIN= 2454
0.99655 0.00159 0
0.20286 0.13657 1
0.23688 0.01913 2
0.99629 0.00106 3
0.99655 0.25159 4
0.20286 0.38657 5
0.23688 -0.23087 6
0.99629 -0.24894 7
0.99655 10.13657 8
0.20286 10.13657 9
0.23688 -9.980869999999999 10
0.99629 -9.980869999999999 11
20.99655 10.13657 12
20.99655 0.25159 13
20.99655 0.00159 14
20.99655 0.00106 15
20.99655 -0.24894 16
20.99655 -9.980869999999999 17
0.9585217395211783 0.0219493557141525 18
... more mesh points

Especially note: If one of your gmsh-Points ends up as an actual mesh nodes. It will be written first in that list. You'll recognize those because you'll usually use less than the default precision on the nodes that gmsh determines itself.

Now with Mesh.SaveAll= 1; I get 70 "helper"-points additionally written to the points list which we do not want:

NPOIN= 2524
0.99655 0.00159 0
0.98706 0.0065 1
0.97304 0.01434 2
... more points
0.20286 10.13657 78
-30 0 79 // <-- this is exactly Point(80) in gmsh
0.23688 -9.980869999999999 80
... more points

That is easy to spot if one takes a look at the beginning of the points list in the mesh as the first points written are all the Points from the .geo file.

I use this approach to write .su2 meshes together with the SU2-solver successfully for a couple of years now, so this is not an issue that might have been recently fixed. To conclude: Create Physical Entities for everything you want to have in your final mesh and do not Save all elements.

Upvotes: 0

Anton Menshov
Anton Menshov

Reputation: 2326

It is a bit odd and I don't know how to resolve the issue in a standard way, because those entities (say, Point 80 at (-30,0,0)) appears even in the native GMSH mesh format. The "building points" are present in the msh v4 format which was relatively recently introduced. And while I am sure there is a way to turn those off from being exported, I don't know exactly how.

However, I found a workaround. Alternatively to the standard workflow, you can use msh v2 legacy format. In this case, I see a clean mesh without extra points:

enter image description here

Then, you can use this mshv2 file to convert it to any other mesh format of your choice.

To obtain the mshv2, I use command line:

/Applications/Gmsh.app/Contents/MacOS/gmsh -2 -format msh2 test.geo 

If you are using Windows or GMSH binary installed any other fashion, adjust you path to GMSH executable.

While this answer does not satisfy me to 100%, it should offer at least a temporary workaround.

Upvotes: 2

Related Questions