gmsh to Elmer

Mesh generators, CAD programs, and other tools
modelman
Posts: 11
Joined: 13 May 2012, 15:35
Antispam: Yes

gmsh to Elmer

Post by modelman »

I recently constructed a 3D model in gmsh to investigate capacitive coupling among a plurality of microstrip conductors oriented at various angles to one-and-other. One model of interest contains three dielectric regions. Each dielectric region is defined by a physical volume entity in gmsh. Here is the problem encountered when using the gmsh generated 3D mesh (V2 ascii .msh format) in Elmer:

Although the original .msh file from gmsh has 3 dielectric regions, Elmer claims that it has 5 bodies. Since the mesh is unstructured and is moderately complex (~300K tetrehedral elements), displaying the 5 bodies identified by Elmer is intractable. I found that the following procedure results in a correct translation of the mesh from gmsh to Elmer.

1) In gmsh, construct a .geo file, generate mesh and save as ascii V1 .msh file.
2) Import ascii V1 .msh file (from 1 above) into EnGrid.
3) Export from EnGrid as a gmsh ascii V2 .msh file.
4) Open gmsh ascii V2 .msh file (from 3 above) with Elmer.
5) Proceed to build Elmer .sif file.

So far, only when I generate a V1 .msh file and convert is to a V2 .msh format with EnGrid can I successfully use the mesh in Elmer. I don't know if this is a bug in gmsh or Elmer, or perhaps an incompatibility between versions. I am using Elmer version 6.1.0.svn.5272.dfsg-1ubuntu2 and gmsh version 2.5.1~beta1~svn9724~dfsg-1 in linux mint 12. Any comments and/or suggestions regarding this issue are greatly appreciated.

Dr. Jack Mandelman (aka "The Modelman")
raback
Site Admin
Posts: 4812
Joined: 22 Aug 2009, 11:57
Antispam: Yes
Location: Espoo, Finland
Contact:

Re: gmsh to Elmer

Post by raback »

Hi Modelman

Perhaps you can sent the original .msh file for inspection.

-Peter
modelman
Posts: 11
Joined: 13 May 2012, 15:35
Antispam: Yes

Re: gmsh to Elmer

Post by modelman »

Hi Peter,
I have attached a zip archive containing 3 .msh files: 1) a V2 created by gmsh, 2) a V1 created by gmsh, and 3) a V2 resulting from a converted V1 by EnGrid.

I notice that the file format of the 2 V2 versions differ. Specifically, the number of fields between the element number and the node numbers are 4 and 3 for the native and converted V2 .msh files, respectively. All tetrahedral elements in the .msh file from EnGrid are assigned a "0" for the physical volume region number, meaning that it is unassigned. However, the triangular elements in this file are correctly assigned to physical surface regions. In the EnGrid converted file the 3 fields between the ele number appear to be "ele type" "number of tags" "physical region number." Since Elmer correctly identifies the physical region numbers for this file, I assume that the physical surfaces are read from the identifiers in the file. However, since the identifiers for the physical volumes are all "0" I wonder how Elmer correcly identified these regions?

In the V2 .msh file produced by gmsh directly, the 4 fields following the element number appear to be "ele type" "number of tags" "phys region number" and "some other number that I don't understand." Please tell me the meaning of this field. This .msh file is consistent with what gmsh displays, but I find that it is misinterpreted by Elmer.

Thank you for looking into this issue.

Jack
modelman
Posts: 11
Joined: 13 May 2012, 15:35
Antispam: Yes

Re: gmsh to Elmer

Post by modelman »

Peter,
The upload failed because the size of the zip file is ~13MB, which exceeds the 2MB limit. I will scale down the mesh density and upload each file separately, to work within the limit.

Sorry for the confusion.
Jack
modelman
Posts: 11
Joined: 13 May 2012, 15:35
Antispam: Yes

Re: gmsh to Elmer

Post by modelman »

Hi Peter,
I reduced the number of elements by ~ a factor of 10. Still shows the same characteristics, so this is a good test case.

Thanks again.
Jack
mzenker
Posts: 1999
Joined: 07 Dec 2009, 11:49
Location: Germany

Re: gmsh to Elmer

Post by mzenker »

Hi,

I think this is the bug contained in the ElmerGUI version of Elmergrid.

* Open V1_from_gmsh.msh with ElmerGUI. You will see 5 bodies (there are really 3 volumes, as shown by gmsh). Opening the Elmer mesh files saved by ElmerGUI with ElmerFront produces a crash.

* Convert V1_from_gmsh.msh with Elmergrid on the command line. Open it with ElmerGUI. You will see 3 bodies.

So using the files generated by Elmergrid might solve your problem.

But it would be a good thing if this would be fixed... ;)

HTH,

Matthias
modelman
Posts: 11
Joined: 13 May 2012, 15:35
Antispam: Yes

Re: gmsh to Elmer

Post by modelman »

Hi Matthias,
Thank you, your work-around appears to be the best option at this time. I was focusing too much on the formatting of the .msh file, while the real problem appears to be in the conversion within ElmerGUI from .msh to mesh.*.

Using ElmerGrid via the command line is an acceptable solution for me, although it would be nice to have it fixed in ElmerGUI as well.

Jack
Kraut~salat
Posts: 9
Joined: 22 Jul 2012, 14:03
Antispam: Yes

Re: gmsh to Elmer

Post by Kraut~salat »

hi, since I also have a problem getting a gmsh into ElmerGUI which has multiple (2) bodies I wanted to try your Method. I have little experience with FEM, Elmer and Gmsh. Can you please tell me where I can set the format version of the .msh? When I regularly export a mesh with the "File->Save Mesh" option it says
$MeshFormat
2.1 0 8
$EndMeshFormat
in the saved file.

If I try to use "ElmerGrid 14 2 myfile.msh" it does something and saves an Elmer mesh, but loading it in ElmerGUI simply makes it crash without a comment

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

Re: gmsh to Elmer

Post by mzenker »

Hi,

do you use the latest binaries? There was an Elmergrid update recently, and the (buggy) Elmergrid fork used in ElmerGUI might also have been updated.

What else you can try:

1. Open the .msh with ElmerGUI directly (file->Open, NOT File->Load Mesh!) . This works most of the time.
2. If this doesn't work, try "Elmergrid 14 2 mymesh.msh -autoclean" and open it with ElmerGUI (File->Load Mesh).
3. If this still doesn't work, you can write your sif file with a text editor and start Elmersolver from the command line. Not very comfortable, though.

In case 2 and 3, you might post a .msh file here which reproduces the problem for the Elmer team to inspect.

HTH,

Matthias

EDIT: The Elmergrid command was wrong, I have corrected it.
skoushik
Posts: 20
Joined: 22 Jan 2018, 01:55
Antispam: Yes

Re: gmsh to Elmer

Post by skoushik »

Hi

I'm using Gmsh and Elmer both in GUI, in windows. How should I convert gmsh file to elmer mesh i.e., how to execute "Elmergrid 14 2 mymesh.msh -autoclean" in windows?

And if it's possible, may I know the use of different GMSH save options (V1 or V2 , ASCII formats, etc.) in ELMER?

Thanks.
Post Reply