[Gmsh] Physical groups in msh file

Geordie McBain gdmcbain at freeshell.org
Wed Aug 18 01:09:15 CEST 2010


2010/8/17 D Haley <mycae at yahoo.com>:
> I am trying to write .msh files for use in Elmer, however I am having some problems with boundary condition grouping.
>
> What is the correct way to either (1) use GMSH to export simple groupings in msh files (It always seems to drop the physical groups?) or (2) write physical groups to a .msh file. I am looking for an example that I can copy from.

I'm not too sure what you mean by `it always seems to drop the
physical groups'; I haven't noticed this.  If saving the .msh via the
Gmsh GUI, be sure not to check `Save all (ignore physical groups)'.

I attach an example.  It's your unit cube, with the top (z = 1) and
the volume marked as physical entities 2 and 3, respectively.  Running
this with "gmsh -3 die.geo" produces the file die.msh, also attached.
I notice your mesh file only has triangular elements; if you just want
to mesh the surface of the cube, replace "-3" with "-2".  I get
essentially the same thing saving interactively.

> The documentation did not seem quite clear, at least to me in the description of the physical names. As far as I can see, a valid  section  might be something like:
>
> $PhysicalNames
> 1
> 2  (Something) "description"
> $EndPhysicalNames
>
> But I am unclear on the "Something", and the "description" secions

I don't know Elmer, but perhaps you can get away without using
PhysicalNames.  If you do need it though, I think the (Something) is
most likely the number of the physical entity (number as in
integer-tag rather than as in how many of them), and "description" is
a string-tag, so I think this PhysicalNames block is like a dictionary
or associative array, translating integer-tags into more user-friendly
string names; e.g. for the die example above it might look like

$PhysicalNames
2
2 2 "top"
3 3 "interior"
$PhysicalNames


> So using an example to clarify, I have the following unit cube, with surface triangles:
>
> $MeshFormat
> 2.1 0 8
> $EndMeshFormat
> $Nodes
> 8
> 1 0 0 0
> 2 0 0 1
> 3 0 1 0
> 4 0 1 1
> 5 1 0 0
> 6 1 0 1
> 7 1 1 0
> 8 1 1 1
> $EndNodes
> $Elements
> 12
> 1 2 3 0 1 0 1 3 7
> 2 2 3 0 1 0 1 5 7
> 3 2 3 0 1 0 6 8 5
> 4 2 3 0 1 0 5 8 7
> 5 2 3 0 1 0 5 1 2
> 6 2 3 0 1 0 5 2 6
> 7 2 3 0 1 0 1 3 4
> 8 2 3 0 1 0 1 2 4
> 9 2 3 0 1 0 3 4 7
> 10 2 3 0 1 0 7 8 4
> 11 2 3 0 1 0 2 8 4
> 12 2 3 0 1 0 6 2 8
> $EndElements
>
> I might, say, like to group the top 2 triangles together (z=1), such that I can assign them in Elmer to a single boundary condition, so what would the PhysicalNames section look like? I can't quite seem to get it to work... Would the following be right?
>
> $PhysicalNames
> 1
> 2 11 12 "Top Boundary"
> $EndPhysicalNames

No, 11 and 12 identify elements, not physical entities.  Also I think
there should probably only be one here, although maybe one is allowed
to group multiple numerically identified physical entities (of the
same physical dimension) into one string-identified physical entity.

The physical entity tags are found in the Element block, being by
convention the first tag.  The third number on each element line tells
how many tags.  You've got 3 (my attached die.msh has 2).  Your first
tags are all zero.  Mine are "2" for the type-2 elements (the
triangles on top) and "3" for the type-4 elements (the tetrahedra
constituting the body).
-------------- next part --------------
A non-text attachment was scrubbed...
Name: die.geo
Type: application/octet-stream
Size: 912 bytes
Desc: not available
URL: <http://www.geuz.org/pipermail/gmsh/attachments/20100818/180af3e0/attachment.geo>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: die.msh
Type: model/mesh
Size: 823 bytes
Desc: not available
URL: <http://www.geuz.org/pipermail/gmsh/attachments/20100818/180af3e0/attachment.msh>