GMSH / Elmer tutorial

Mesh generators, CAD programs, and other tools
Post Reply
mark smith
Posts: 215
Joined: 26 Aug 2009, 18:20
Location: Peterborough, England

GMSH / Elmer tutorial

Post by mark smith »

Hi
I currently use GiD as my pre processor but would like to use gmsh so as to use all open source tools.
In GiD I can set bodies and boundary conditions to values I want so my sif file refers to the correct parts in the mesh files. I seem to be unable to do this using Gmsh as physical groups seem to be lost in the "elmergrid 14 2 part.mesh" translation. I seem to have to use elmergui to interogate the gmsh mesh file to discover the boundary & body numbers, is there a procedure where I can drive gmsh and the mesh translation to be able to produce the mesh files with known body and boundary numbers so I don't need to use elmergui?
The pdf file using elmer with other pre and post processors from the Elmer basic course 25.5.2010 implies that vou cannot make use of the physical groups in gmsh?
If anyone has a more detailed procedure/tutorial I'd be most grateful.
BR mark
raback
Site Admin
Posts: 4832
Joined: 22 Aug 2009, 11:57
Antispam: Yes
Location: Espoo, Finland
Contact:

Re: GMSH / Elmer tutorial

Post by raback »

Hi Mark

The logic of the Gsmh parser of ElmerGrid is as follows:

In the gmsh file there are a number of tags for each element, see
http://geuz.org/gmsh/doc/texinfo/gmsh.h ... ile-format

The 1st tag refers to physical quantity and the second one to geometric. In Elmer the renumbering of entities is enforced (line 3646 of femfilein.c) if for some element the physical quantity is zero. This is taken as a sign that they are not defined. Geometric entities typically have inproper indexes for Elmer ranging up to thousands. Therefore they are always renumbered.

So *if* you define all your physical quantities to be nonzero you should maintain the original numbering. When you do this you should be able to maintain the mesh numbering without the need to pass through the GUI. The numbering of the geometric quantities in Gmsh may be mesh dependent. Look at the output of ElmerGrid to see info on the numbering. And if needed, sent a minimilistic .msh file where you have defined the physical quantities but where the indexes are not maintained.

-Peter
mark smith
Posts: 215
Joined: 26 Aug 2009, 18:20
Location: Peterborough, England

Re: GMSH / Elmer tutorial

Post by mark smith »

Hi Peter
Attached is a simple gmsh geo file where I have defined some volume surfaces and lines as physical groups and given them names. If i save the mesh without the option save all (ignore physical groups) elmergui does not import all the geometry, with it ticked then elmergui does but then I have to findout the ID's of the bodies, lines,surfaces etc.
If I use elmergrid to produce the meshfiles elmergui crashes on importing the mesh with Exit code: -1073741819
Status: CrashExit

Not being able to apply boundary or body tags in Gmsh make it less useful as it is far more preferable to apply these on the geometry than the mesh as any remeshing will require the sif file to be edited.
Best regards
mark
Attachments
box.geo
gmsh mesh test case
(1.74 KiB) Downloaded 551 times
raback
Site Admin
Posts: 4832
Joined: 22 Aug 2009, 11:57
Antispam: Yes
Location: Espoo, Finland
Contact:

Re: GMSH / Elmer tutorial

Post by raback »

Hi Mark

I think that the problem lies in the fact that you have entities of dims 1,2 and 3. ElmerGUI doesn't like that. In automatic cleaning, used when physical entities are not given, the line elements are eliminated. You can come up with the same outcome with flag '-removelowdim'. You might perhaps be able to circumwent the problems also if you don't visit ElmerGUI at all. ElmerSolver can deal with dimensions 0,1,2,3 at the same time without problems.

-Peter
mark smith
Posts: 215
Joined: 26 Aug 2009, 18:20
Location: Peterborough, England

Re: GMSH / Elmer tutorial

Post by mark smith »

Hi Peter
When I produce a mesh in GiD using the elmer problemtype it produces the 4 mesh files I use sucessfully with elmersolver. I have tried to view this mesh in elmergui or elmerpost with no luck, is there a viewer which can display this mesh?
Are there any plans to produce a gmsh parser that will preserve the physical groups? I have thought of writing a routine to convert the gmsh mesh output into the .dat file that elmerproblem type produces so I can use the routines gid2elmer.exe and findparents.exe to produce the elmer mesh files but this seems a bit long winded, have you any alternative suggestions?
I'd like to use gmsh as I can paramertise my geometry and my BC's will remain in place, meshing then carries these over automatically. In Gid I end up modifying my geometry then having to reimpose the BC's on the geometry, I probably could parameterise in GiD using a batch file but I would still be reliant on a comercial preprocessor.
Best regards
mark
mzenker
Posts: 1999
Joined: 07 Dec 2009, 11:49
Location: Germany

Re: GMSH / Elmer tutorial

Post by mzenker »

Hi,

I have just meshed the testcase with gmsh (saved as "Version 2.0 ASCII" without "save all" checked) and imported the mesh in ElmerGUI.
It imports the physical volumes and the surface with numbers preserved, but not the physical line.
So if you can live with not having the physical line imported (perhaps you can define a physical surface instead, having the same effect for your model?), then it should work OK.

BTW, when I do "View" -> "Volume Mesh" (since the volume mesh is not shown by default) and double-click on the volume to select it, the volume disappears and I get the following messages in the log window:

glRenderMode(GL_RENDER) produces bad z-values
Unable to reliably select objects
Vendor: Intel
Renderer: Intel Eaglelake
Version: 1.5.0 - Build 7.14.10.4964
Detected bad GL-context or broken graphics driver

Then I cannot make the volume appear again. This might be a bug in ElmerGUI.
I use Elmer revision 4551 under Windoze XP.

Best regards,

Matthias
mark smith
Posts: 215
Joined: 26 Aug 2009, 18:20
Location: Peterborough, England

Re: GMSH / Elmer tutorial

Post by mark smith »

Hi All
I've put together a set of instructions which outlines the method I now employ to get Gmsh to produce meshes for Elmer, see the attached PDF.
In the process of my investigations I wrote a C programme which reads in a Gmsh.msh file and writes out the elmer mesh files then using findparents.exe routine which is bundled up in the Elmer.gid interface module downloadable from http://www.csc.fi/english/pages/elmer/d ... /elmer.gid corrects my boundary.mesh file, if the source code is of any interest just email me for a copy and I'll send it.
Regards
mark
Attachments
Elmer mesh file creation using Gmsh.pdf
Short tutorial on using Gmsh to produce Elmer mesh file
(25.36 KiB) Downloaded 1207 times
Post Reply