Reading gmsh mesh with elmer (ElmerGrid/Elmer GUI)

The graphical user interface of Elmer
samuel_user
Posts: 5
Joined: 28 Mar 2019, 12:56
Antispam: Yes

Reading gmsh mesh with elmer (ElmerGrid/Elmer GUI)

Post by samuel_user »

Hello,

I encounter some problem to read gmsh meshes with elmer. So I give below a simple example. Hope someone can help.

I used gmsh (version 4.2.1) to generate a mesh file (simply a cube)
$ gmsh cube.geo -3 -order 2

I used ElmerGrid (ElmerSoler Version: 8.4 (Rev: f598a6f7, Compiled: 2019-03-27)) to convert the mesh for Elmer
$ ElmerGrid 14 2 cube.msh -autoclean

I obtain a segmentation error (see ERRORS FROM ELMERGRID below and also the log_cube.txt file for details)

Using ElmerGUI to open cube.msh give also errors (see terminal output ERRORS FROM ELMERGUI below)

Is there some incompatibilities between version of gmsh and elmer?

Thanks for your help

Samuel

************ ERRORS FROM ELMERGRID ***********************************************
Starting program Elmergrid
Elmergrid reading in-line arguments
Lower dimensional boundaries will be removed
Materials and boundaries will be renumbered
Nodes that do not appear in any element will be removed
Output will be saved to file cube.

Elmergrid loading data:
-----------------------
Format chosen using the first line: $MeshFormat
Loading mesh in Gmsh format 4.0 from file cube.msh
Reading 8 entities in 0D
Reading 12 entities in 1D
Reading 6 entities in 2D
Reading 1 entities in 3D
$Nodes section should end to string $EndNodes:
-5e-05 -3.500000000000002e-05 5e-05

Allocating for 7888 knots and 5260 elements.
Boundary name for physical group 1 is: Anode
Boundary name for physical group 2 is: Cathode
Body name for physical group 3 is: Gas
Maximum original tag for 12 1DIM entities is 12
Maximum original tag for 6 2DIM entities is 6
Maximum original tag for 1 3DIM entities is 1
Reading 7888 nodes in 27 blocks.
$Nodes section should end to string $EndNodes:
-5e-05 -3.500000000000002e-05 5e-05

Untreated command: -5e-05 -2.500000000000003e-05 5e-05
Untreated command: -5e-05 -1.500000000000004e-05 5e-05
Untreated command: -5e-05 -5.000000000000033e-06 5e-05

...

Reading 5260 elements in 3 blocks.
Reading 258 elements with tag 2 of type 306
Mapping mesh tag 2 to physical tag 3 in 1DIM
Reading 258 elements with tag 2 of type 306
Erreur de segmentation (core dumped)
***************************************************

**************** ERRORS FROM ELMERGUI ***********************************
...
Untreated command: 5258 3321 1760 2159 3464 7826 7816 7767 7574 7721 7817
Untreated command: 5259 3234 306 241 269 7263 506 7499 7291 502 507
Untreated command: 5260 3234 241 306 3346 7499 506 7263 7262 7261 7772
Making elements to boundary conditions
Leading bulk elementtype is 306
Trailing bulk elementtype is 0
GetElementDimension: unknown elementtype 0
There are 0 (out of 5260) lower dimensional elements.
Successfully read the mesh from the Gmsh input file.

ElmerGrid manipulating and importing data
Input method: 14
Manipulate mesh definition: 14 0 1.000e+00
Converting ElmerGrid data to ElmerGUI data
Setting elements of 2dim
Setting number of nodes 7888
Setting number of 2d elements 5260
Done converting
Done converting mesh
Found 407 edges on boundary
Creating edge indexes
40 boundary edges were numbered up to index 1
findBoundaryElementNormals: error: unknown code
****************************************************
Attachments
log_cube.txt
terminal errors
(840 KiB) Downloaded 426 times
cube.geo
geometry used in gmsh
(1.26 KiB) Downloaded 504 times
cube.msh
mesh from gmsh
(819.61 KiB) Downloaded 472 times
kevinarden
Posts: 2237
Joined: 25 Jan 2019, 01:28
Antispam: Yes

Re: Reading gmsh mesh with elmer (ElmerGrid/Elmer GUI)

Post by kevinarden »

Elmer is not reading the new version of gmesh, gmesh changed file formats.

Go to GMSH help. current options and workspace, search for mesh.format, change it to a value of 2, goto file save mesh, GMSH will then save it as a *.unv file that ElmerGUI ro ElmerGrid can read.
samuel_user
Posts: 5
Joined: 28 Mar 2019, 12:56
Antispam: Yes

Re: Reading gmsh mesh with elmer (ElmerGrid/Elmer GUI)

Post by samuel_user »

Thanks "kevinarden" it worked.

For how would be interested here is the command line for extracting unv mesh format with gmsh

GMSH : gmsh <geometry_file>.geo -3 -order 2 -format unv

the same with ElmerGrid : 8 is for unv format

ELMER : ElmerGrid 8 2 <mesh_file>.unv -autoclean
mzenker
Posts: 1999
Joined: 07 Dec 2009, 11:49
Location: Germany

Re: Reading gmsh mesh with elmer (ElmerGrid/Elmer GUI)

Post by mzenker »

kevinarden wrote: 28 Mar 2019, 16:06 Go to GMSH help. current options and workspace, search for mesh.format, change it to a value of 2, goto file save mesh, GMSH will then save it as a *.unv file that ElmerGUI ro ElmerGrid can read.
A value of 1 makes gmsh save the mesh in the old format which Elmer can also read.

HTH,
Matthias
Adev
Posts: 30
Joined: 02 Oct 2019, 22:18
Antispam: Yes
Location: Florida, USA

Re: Reading gmsh mesh with elmer (ElmerGrid/Elmer GUI)

Post by Adev »

kevinarden wrote: 28 Mar 2019, 16:06 Elmer is not reading the new version of gmesh, gmesh changed file formats.

Go to GMSH help. current options and workspace, search for mesh.format, change it to a value of 2, goto file save mesh, GMSH will then save it as a *.unv file that ElmerGUI ro ElmerGrid can read.
Awesome, thank you! I'm a beginner with ELMER and Gmsh, and I struggled for more than a day trying to figure this out, not finding any solution in any of the manuals.
Perhaps someone can incorporate this into future updates of the manuals?
:)
foadsf
Posts: 81
Joined: 20 Sep 2016, 23:56
Antispam: Yes
Contact:

Re: Reading gmsh mesh with elmer (ElmerGrid/Elmer GUI)

Post by foadsf »

So what worked for me:

Code: Select all

gmsh.exe <fileName>.geo -3 -order 1 -format unv
and then

Code: Select all

ElmerGrid.exe 8 2 <fileName>.unv -autoclean
and then in ElmerGUI File > Open > <fileName>.unv
kevinarden
Posts: 2237
Joined: 25 Jan 2019, 01:28
Antispam: Yes

Re: Reading gmsh mesh with elmer (ElmerGrid/Elmer GUI)

Post by kevinarden »

ElmerGUI File > Open > <fileName>.unv converts the unv file to an Elmer Mesh and opens it.

ElmerGrid.exe 8 2 <fileName>.unv -autoclean converts the unv file to an Elmer mesh and stores it in a folder named filename

To open the ElmerGrid mesh you would use the load mesh command in ElmerGUI.

In my experience ElmerGrid is the better conversion tool.
raback
Site Admin
Posts: 4812
Joined: 22 Aug 2009, 11:57
Antispam: Yes
Location: Espoo, Finland
Contact:

Re: Reading gmsh mesh with elmer (ElmerGrid/Elmer GUI)

Post by raback »

Hi

I've been trying to harmonize the ElmerGrid and it's old fork that is a plugin under ElmerGUI. I hope this is now finally working. I've done quite a bit of testing and merged it today to devel. The cmake was not yet updated. Just same piece of code used in both places. Both were able to open this cube.msh file of Gmsh style 4.1.

There was previously also different logic with the "autoclean" flag. This could make things different depending whether to use the plugin or ElmerGrid directly. Sometimes people really want to keep the numbering. This was resolved by having the "-autoclean" be default under Mesh -> Configure -> ElmerGrid. This means that you can also lift the flag by erasing it.

I hope also the Windows binaries may be tested tomorrow under:
https://www.nic.funet.fi/pub/sci/physic ... n/windows/

-Peter
mzenker
Posts: 1999
Joined: 07 Dec 2009, 11:49
Location: Germany

Re: Reading gmsh mesh with elmer (ElmerGrid/Elmer GUI)

Post by mzenker »

Hi Peter,

this is good news! So finally ElmerGUI-only users will not need to go to the command line in case of problems with mesh import.
Just by curiosity: Is this a new fork of ElmerGrid or will ElmerGUI and ElnerGrid have a shared codebase in the future?

Matthias
raback
Site Admin
Posts: 4812
Joined: 22 Aug 2009, 11:57
Antispam: Yes
Location: Espoo, Finland
Contact:

Re: Reading gmsh mesh with elmer (ElmerGrid/Elmer GUI)

Post by raback »

Well, the files are now identical. Ideally the common part would be a library. However, I didn't change the cmake part so if you change stuff in ElmerGrid you need to run this:

https://github.com/ElmerCSC/elmerfem/bl ... rid2gui.sh

Symlinks would have done the same but might now work on all platforms.

-Peter
Post Reply