gmsh2nek for a straight pipe

960 views
Skip to first unread message

Jimmy

unread,
May 29, 2021, 6:08:31 AM5/29/21
to Nek5000
Dear Nek users,

I am suffering from the ERROR: invalid msh file format in gmsh2nek that both 2D and 3D files have been tested. I really appreciate it if someone can help to figure it out. Some lines at the beginning of the file have been listed below. 

Regards,

Jimmy

$MeshFormat
4.1 0 8
$EndMeshFormat
$PhysicalNames
1
1 1 "wall"
$EndPhysicalNames
$Entities
17 20 9 0
1 0 0 0 0 
2 0.3 0 0 0 
3 0 -0.3 0 0 
4 -0.3 0 0 0 
5 0 0.3 0 0 
6 0.4949747468305576 0.4949747468306088 0 0 
7 0.4949747468305576 -0.4949747468306088 0 0 
8 -0.4949747468305576 -0.4949747468306088 0 0 
9 -0.4949747468305576 0.4949747468306088 0 0 
10 0.6917929696263546 0.6917929696264262 0 0 
11 0.6917929696263546 -0.6917929696264262 0 0 
12 -0.6917929696263546 -0.6917929696264262 0 0 
13 -0.6917929696263546 0.6917929696264262 0 0 
14 0.7071067811865109 0.7071067811865841 0 0 
15 0.7071067811865109 -0.7071067811865841 0 0 
16 -0.7071067811865109 -0.7071067811865841 0 0 
17 -0.7071067811865109 0.7071067811865841 0 0 
1 -0.4949747468305578 0.4949747468306085 0 0.4949747468305577 0.6346824944327563 0 0 2 9 -6 
2 0.4949747468305577 -0.4949747468306087 0 0.6346824944327396 0.4949747468306088 0 0 2 6 -7 
3 -0.4949747468305577 -0.6346824944327563 0 0.4949747468305578 -0.4949747468306085 0 0 2 7 -8 
4 -0.6346824944327396 -0.4949747468306088 0 -0.4949747468305577 0.4949747468306087 0 0 2 8 -9 
5 -0.6917929696263548 0.6917929696264264 0 0.6917929696263548 0.9746201095151733 0 0 2 13 -10 
6 0.6917929696263548 -0.6917929696264264 0 0.9746201095151723 0.6917929696264264 0 0 2 10 -11 
7 -0.6917929696263548 -0.9746201095151733 0 0.6917929696263548 -0.6917929696264264 0 0 2 11 -12 
8 -0.9746201095151723 -0.6917929696264264 0 -0.6917929696263548 0.6917929696264264 0 0 2 12 -13 
9 -0.7071067811865109 0.7071067811865841 0 0.7071067811865109 0.996194698091746 0 1 1 2 17 -14 
10 0.7071067811865109 -0.7071067811865841 0 0.9961946980917451 0.7071067811865841 0 1 1 2 14 -15 
11 -0.7071067811865109 -0.996194698091746 0 0.7071067811865109 -0.7071067811865841 0 1 1 2 15 -16 
12 -0.9961946980917451 -0.7071067811865841 0 -0.7071067811865109 0.7071067811865841 0 1 1 2 16 -17 
13 0.4949747468305576 0.4949747468306088 0 0.6917929696263546 0.6917929696264262 0 0 2 6 -10 
14 0.4949747468305576 -0.6917929696264262 0 0.6917929696263546 -0.4949747468306088 0 0 2 7 -11 

Stefan K.

unread,
May 29, 2021, 6:41:14 AM5/29/21
to Jimmy, Nek5000
The readme should help you:
https://github.com/Nek5000/Nek5000/blob/master/tools/gmsh2nek/README.md
> --
> You received this message because you are subscribed to the Google Groups "Nek5000" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to nek5000+u...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/nek5000/30a3a97f-de74-42a1-b8a6-576de3e61772n%40googlegroups.com.

Yuan, Haomin

unread,
May 29, 2021, 12:09:08 PM5/29/21
to Stefan K., Jimmy, Nek5000
Make sure your gmsh mesh is in version 2 


From: nek...@googlegroups.com <nek...@googlegroups.com> on behalf of Stefan K. <stg...@gmail.com>
Sent: Saturday, May 29, 2021 5:40:37 AM
To: Jimmy <pmj...@gmail.com>
Cc: Nek5000 <nek...@googlegroups.com>
Subject: Re: [nek5000] gmsh2nek for a straight pipe
 

Byron Guerrero

unread,
May 30, 2021, 4:45:53 PM5/30/21
to Jimmy, Nek5000
Hi Jimmy,

It seems that you saved your file as V4. I think you should save your file as version 2. Do not forget to convert your elements to 2nd order before saving the file. This is explained in the header of gmsh2nek.f code.

Hope this helps.

Regards,
Byron

--
Message has been deleted

Jimmy

unread,
May 31, 2021, 5:43:25 AM5/31/21
to Nek5000
Dear all,

Thanks for your help. The problem has been sorted. However, I am not fully sure about the input in gmsh2nek. Below is what I did which works and can generate a .re2 file. However, I am still wondering how to set it properly. Does it need to match with the input settings in .geo file? I mean number of pairs are 1 2 3 4 5 6 7 8, and the boundaryID is 6-152, 7-174, 8-196,..., 1-42

 ******************************************************
 Enter number of periodic boundary surface pairs:
1 2
 input surface 1 and  surface 2  BoundaryID
1 2
 input translation vector (surface 1 -> surface 2)
0 0 8.16667
 ******************************************************
 Please set boundary conditions to all non-periodic boundaries
 in .usr file usrdat2() subroutine
 ******************************************************

   Physical Surface("inlet") = {6, 7, 8, 9, 5, 2, 3, 4, 1};
   Physical Surface("outlet") = {152, 174, 196, 218, 64, 86, 108, 130, 42};
   Physical Surface("wall") = {139, 213, 191, 165};
   Physical Volume("flowDomain") = {6, 2, 1, 4, 8, 3, 7, 5, 9};



Kind regards,

Jimmy

Emmanuel Gillyns

unread,
Jun 1, 2021, 9:49:21 AM6/1/21
to Nek5000
Hi,

When running GMSH2NEK, the "boundary info summary" should be as follows :
Boundary name   Boundary ID
inlet                            1
outlet                         2
wall                             3

You should enter "1" as "Number of periodic boundary surface pairs" (not "1 2" as you did here)
All the rest should work properly the way you set it.

Hope this helps,

Emmanuel

Jundi He

unread,
Jun 10, 2021, 6:48:25 PM6/10/21
to Nek5000
Hi,

I also had a problem when I used gmsh2nek to convert the mesh from .msh to .re2 format:

The mesh is a simple test mesh of a 3x3x3 cube, and it was exported in Version 2, with the mesh set to order 2. When I type gmsh2nek, the terminal shows: 

jhe@heft-vis2:~/Nek5000/run/gmsh2nek_test$ gmsh2nek
Enter mesh dimension: 3
Input .msh file name: cube
At line 553 of file gmsh2nek.f90 (unit = 299, file = 'cube.msh')
Fortran runtime error: End of file

Does anyone know what's the problem here? The .msh file is attached. Thanks! 

Regards!
Jundi


cube.msh

Emmanuel Gillyns

unread,
Jun 11, 2021, 10:26:02 AM6/11/21
to Nek5000
Hi,

Could you send your .geo file please ?
It would be easier to troubleshoot. With your .msh file I get the same error as you do.

Emmanuel

Jundi He

unread,
Jun 11, 2021, 1:05:15 PM6/11/21
to Nek5000
Hi Emmanuel:

Thank you so much for your time! Sorry I keep getting error when I tried to attach the .geo file. This is my .geo file: 



//Sets the mesh element order
Mesh.ElementOrder = 2;

//Sets the mesh version for exporting the mesh
Mesh.MshFileVersion = 2.2;

Point(1) = {0, 0, 0, 1.0};
Point(2) = {1, 0, 0, 1.0};
Point(3) = {1, 1, 0, 1.0};
Point(4) = {0, 1, 0, 1.0};

Line(1) = {4, 3};
Line(2) = {3, 2};
Line(3) = {2, 1};
Line(4) = {1, 4};

Line Loop(5) = {1, 2, 3, 4};
Plane Surface(6) = {5};

Transfinite Line {1, 2, 3, 4} = 4 Using Progression 1;
Transfinite Surface {6};
Recombine Surface {6};

//+
Extrude {0, 0, 1} {
  Surface{6};
  Layers{3};
  Recombine;
}

Physical Surface("inlet", 29) = {15};
Physical Surface("outlet", 30) = {23};
Physical Surface("walls", 31) = {28, 27, 6, 19};
Physical Volume("fluid", 32) = {1};






Regards!
Jundi

Yuan, Haomin

unread,
Jun 12, 2021, 12:31:20 AM6/12/21
to Jundi He, Nek5000
Hi, Jundi,

I found the msh file you dumped used some different keywords.

for example, it should be $Nodes but your msh file is $ParametricNodes

what gmsh version you used to generate this msh file ?


Haomin (Kirk) Yuan,
Nuclear/Reactor Engineer, Building 208/C145
Nuclear Science & Engineering Division,
Argonne National Laboratory


From: nek...@googlegroups.com <nek...@googlegroups.com> on behalf of Jundi He <jh...@sheffield.ac.uk>
Sent: Friday, June 11, 2021 12:05 PM
To: Nek5000 <nek...@googlegroups.com>

Subject: Re: [nek5000] gmsh2nek for a straight pipe
--
You received this message because you are subscribed to the Google Groups "Nek5000" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nek5000+u...@googlegroups.com.

Jundi He

unread,
Jun 12, 2021, 5:10:07 AM6/12/21
to Nek5000
Hi Haomin:

I am using Gmsh 4.8.4 (the latest version released at April 2021), I think this might be the problem. I'll try to get an older version of Gmsh. Thanks for the check. 

Regards!
Jundi

Emmanuel Gillyns

unread,
Jun 12, 2021, 8:48:18 AM6/12/21
to Nek5000
Hi,

I used the .geo file you provided and it worked fine.
The command I used was :
    gmsh file.geo -3 -order 2 -format msh2 -o file.msh
and the gmsh version I am using is gmsh 4.4.1

You might want to downgrade your gmsh to see if the problem is solved.

Let us know about it,

Emmanuel

Jundi He

unread,
Jun 12, 2021, 9:26:42 AM6/12/21
to Nek5000
Hi Emmanuel & Haomin:

Thanks for the information, I've tried a lower version of Gmsh to export the .msh file, and it can be successfully converted to .re2 using gmsh2nek. Maybe the .msh file exported by the latest version of Gmsh contains some strings that gmsh2nek cannot recognize correctly. 

Again, many thanks for your help, problem solved! 

Jundi

Jundi He

unread,
Jun 13, 2021, 1:55:11 PM6/13/21
to Nek5000
Hi,

I have a problem with my mesh again. 

This is, again, a 3x3x3 cube with 27 elements. Previously, I used "extrusion" in Gmsh to extrude a 2D mesh to a 3D mesh, then with gmsh2nek, a .re2 file can be successfully generated from the .msh file. But in this method (extrusion), the mesh must be uniform at the extrusion direction. Now I try to use another way to generate this 3x3x3 cube, using the "Transfinite line/surface/volume", to create a structured mesh, as shown in the attached .geo file. When I tried to use gmsh2nek to convert the mesh, the terminal shown these error messages:


jhe@heft-vis2:~/Nek5000/run/Gmsh_test_cube$ gmsh2nek
Enter mesh dimension: 3
Input .msh file name: cube
 ERRPOR: unknown element type
 only quad8/9 and hex20/27 elements are accepted
 please choose "set order 2" option to set all elements to 2nd order
 please uncheck "save all elements" when exporting mesh
 please see readme for more information



I have chosen "set order 2" and "save all elements" before outputting the .msh file, and the Gmsh version I used is 4.4.1. Does anyone has some clue about what's going wrong with my mesh? Thanks! 

Regards!
Jundi


P.S. I keep getting error when I tried to attach the .geo file, so I just paste the .geo file herein:

//Sets the mesh element order
Mesh.ElementOrder = 2;
//Sets the mesh version for exporting the mesh
Mesh.MshFileVersion = 2.2;
Point(1) = {0, 0, 0, 1.0};
Point(2) = {0, 0.5, 0, 1.0};
Point(3) = {0.5, 0.5, 0, 1.0};
Point(4) = {0.5, 0, 0, 1.0};
Line(1) = {4, 3};
Line(2) = {3, 2};
Line(3) = {4, 1};
Line(4) = {1, 2};

Line Loop(1) = {4, -2, -1, 3};
Plane Surface(1) = {1};

Extrude {0, 0, 0.5} {
  Surface{1}; 
}

Transfinite Line {20, 11, 8, 9, 6, 7, 16, 12, 4, 1, 2, 3} = 4 Using Progression 1;
Transfinite Surface {25, 13, 21, 17, 26, 1};
Recombine Surface {25, 13, 21, 17, 26, 1};
Transfinite Volume{1} = {5, 14, 10, 6, 1, 4, 3, 2};

Physical Surface("wall", 1) = {13, 17, 1, 21, 25, 26};

Yuan, Haomin

unread,
Jun 13, 2021, 3:03:44 PM6/13/21
to Jundi He, Nek5000
please uncheck "save all elements" when exporting mesh

Sent: Sunday, June 13, 2021 12:55:11 PM

To: Nek5000 <nek...@googlegroups.com>
Subject: Re: [nek5000] gmsh2nek for a straight pipe
--
You received this message because you are subscribed to the Google Groups "Nek5000" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nek5000+u...@googlegroups.com.

Jundi He

unread,
Jun 13, 2021, 3:29:04 PM6/13/21
to Nek5000
Hi, 

Many thanks for the suggestion. I've unchecked "save all elements" when exporting the mesh. When I tried to convert the mesh using gmsh2nek, the terminal shown some error messages:

jhe@heft-vis2:~/Nek5000/run/Gmsh_test_cube$ gmsh2nek
Enter mesh dimension: 3
Input .msh file name: cube
 total node number is          218
 total quad element number is           54
 total hex element number is            0
 ERROR: cannot find hex face for quad id            1
 ERROR: this should not happen, please check your mesh
 ERROR: or your mesh exporting process in gmsh
 ERROR: cannot find hex face for quad id            2
 ERROR: this should not happen, please check your mesh
 ERROR: or your mesh exporting process in gmsh
 ERROR: cannot find hex face for quad id            3
 ERROR: this should not happen, please check your mesh
 ERROR: or your mesh exporting process in gmsh
...
 ERROR: cannot find hex face for quad id           54
 ERROR: this should not happen, please check your mesh
 ERROR: or your mesh exporting process in gmsh
 ******************************************************
 Boundary info summary
 BoundaryName     BoundaryID
 wall           1
 ******************************************************
 Enter number of periodic boundary surface pairs:
0

writing cube.re2 


It successfully generated a .re2 file, but it seems that the code cannot locate some of the hex faces. 

Regards!
Jundi


Yuan, Haomin

unread,
Jun 13, 2021, 3:39:13 PM6/13/21
to Jundi He, Nek5000
there is no hex elements in your mesh.
Did you define physical volume?


Sent: Sunday, June 13, 2021 2:29:03 PM

Jundi He

unread,
Jun 13, 2021, 3:47:40 PM6/13/21
to Nek5000
Hi,

After defining the physical volume, gmsh2nek can now detect the hex elements. Thanks for your reminding! 

Regards!
Jundi

Reply all
Reply to author
Forward
0 new messages