ElmerGrid unexpected failure (import msh from GMSH)

Mesh generators, CAD programs, and other tools
Post Reply
Heiko
Posts: 2
Joined: 11 Aug 2022, 12:47
Antispam: Yes

ElmerGrid unexpected failure (import msh from GMSH)

Post by Heiko »

Hi everybody,

I am facing a quite unexpected behaviour when converting meshes from gmsh's msh file format using Elmergrid. I am using ElmerGrid as follows:

Code: Select all

ElmerGrid.exe 14 2 my_mesh.msh -out [path to my data folder]

I am currently setting up a simulation pipeline where I build parametric meshes in GMSH and solve them in Elmer. Thus, I have to run mesh generation - ElmerGrid conversion - ElmerSolver hundreds of times. In more than 99% of cases, above conversion works flawlessly. But every hundred-and-so cases, it fails giving the following error message:

Code: Select all

Elmergrid loading data:
-----------------------
Format chosen using the first line: $MeshFormat
Gmsh version is 4.1
Loading mesh in Gmsh format 4.1 from file my_mesh.msh
Reading 485 entities in 0D
Reading 989 entities in 1D
Reading 594 entities in 2D
Reading 1 entities in 3D
Entity line 1 has length 3615.
$Entities section should end to string $EndEntities:
$Nodes

The program encountered a major error...
No nodes to load in Gmsh file!
...now exiting to system...
I have inspected the respective msh files and they DO contain an

Code: Select all

$EndEntities
line, which is for some reason not recognized by ElmerGrid. Here is an exemplary section from the msh file:

Code: Select all

$Entities
485 989 594 1
...
[shortened for readability]
...
594 -118.0897519161978 83.67989938860785 51.62813872604876 -117.2223149013572 84.88132485396667 52.40084486291649 1 14 1 100000988 
1 -132.2982841579826 81.40252336735487 26.04584897934522 -92.29827415798256 86.48892438835442 66.04585897934523 1 12 594 1 -2 3 4 5 6 [shortened for readability] 593 594
$EndEntities
$Nodes
1655 6701 1 6701
0 200002 0 1
1
-112.0317137726694 83.50117900126195 45.74750382841989
0 200003 0 1
So the line does exist. Visually, I cannot detect any difference from other msh files that are converted successfully. Empirically, I found that inserting an empty line CR+LF (carriage return + line feed) after the

Code: Select all

$EndEntities
line makes ElmerGrid run. It still complains about

Code: Select all

$Entities section should end to string $EndEntities:
but it does the conversion and does not stop at this point. Exemplary output with the blank line:

Code: Select all

Elmergrid loading data:
-----------------------
Format chosen using the first line: $MeshFormat
Gmsh version is 4.1
Loading mesh in Gmsh format 4.1 from file my_mesh.msh
Reading 485 entities in 0D
Reading 989 entities in 1D
Reading 594 entities in 2D
Reading 1 entities in 3D
Entity line 1 has length 3615.
$Entities section should end to string $EndEntities:


Allocating for 6701 knots and 33335 elements.
Boundary name for physical group 12 is: Phys A
Boundary name for physical group 13 is: Phys B
Boundary name for physical group 14 is: Other Surfaces
Body name for physical group 12 is: Main Volume
Allocating lookup table for tags of size 100000988
Maximum original tag for 989 1DIM entities is 100000988
Maximum original tag for 594 2DIM entities is 594
Maximum original tag for 1 3DIM entities is 1
$Entities section should end to string $EndEntities:


Untreated command:
Reading 6701 nodes in 1655 blocks.
Reading 33335 elements in 595 blocks.
Reading 5 elements with tag 1 of type 303
Mapping mesh tag 1 to physical tag 14 in 2DIM
Reading 32 elements with tag 2 of type 303
Mapping mesh tag 2 to physical tag 14 in 2DIM
Reading 5 elements with tag 3 of type 303
Mapping mesh tag 3 to physical tag 14 in 2DIM
Other msh files can be converted without this blank line, though. I am really puzzled as to why ElmerGrid does not recognize the $EndEntities tag in this file, and also as to why the blank line solves it.

I inspected the meshing result of GMSH before exporting it into msh format and cannot see any difference to meshes that can be successfully converted with ElmerGrid.

Any help/hints on this would be greatly appreciated!
raback
Site Admin
Posts: 4812
Joined: 22 Aug 2009, 11:57
Antispam: Yes
Location: Espoo, Finland
Contact:

Re: ElmerGrid unexpected failure (import msh from GMSH)

Post by raback »

Hi,

Would you have the .msh files available.

You can always use Gmsh output format ~2. They added lot of complexities with format 4. For example, a line can sometimes be extremely long. ElmerGrid had problems with that and reads it now in pieces. Maybe something is lost in translation. I cannot check without the .msh file though...

-Peter
Post Reply