[Gmsh] file format

Rui Maciel rui.maciel at gmail.com
Fri Mar 12 10:31:23 CET 2010


oka wrote:
> Dear developer,
> 
> I am not familiar with gmsh file format.
> In my partitioed mesh case,
> One file (total 4 partitions) shows as follows.
> - - - -
> 21586 4 4 0 1 1 1 790 148 5726 6827
> 21587 4 5 0 1 2 1 -4 5004 1004 4710 7455
> 21588 4 4 0 1 1 1 3280 2145 3283 8302
> - - - -
> For example. for element number 21587,
> what is the meaning of following numbers,
> 5 0 1 2 1 -4
> especially, why extra -4 appears although other
> elements has no minus values ?
> 
> Best regards,
> 
> Oka

It may not be of much help but nonetheless here's my 0.02€.

The format which was implemented for the element definition field consists 
basically of the following four non-terminal fields:

<element-number> <element type> <element tags> <element nodes>


focusing on the <element tags> field, it basically follows the following 
format:

<element tags number> <element tag>+


To put it in other words, it consists of a leading integer ( indicating how 
many tags there are) followed by that many tags.  So, considering your element 
number 21587, the <element tags> field of that element includes the following 
tokens:

5 0 1 2 1 -4


That is, the <element tags number> is 5, followed by 5 tags.  As your <element 
type> tag is 4, it means that that particular element is a 4-node tetrahedron.  
As a consequence, you will notice that after the mysterious -4 token you will 
find the following tokens:

5004 1004 4710 7455


Those 4 integer tokens are the 4 references to the nodes which are used to 
define that particular element.

One of the tricky things about the MSH ASCII file format is that it isn't 
thoroughly defined in the specification presented in Gmsh's documentation[1].  
In fact, I believe that only the first 3 tags are defined.  Moreover, according 
to that specification you shouldn't get any negative number as a tag.  So this 
is a weird one.  

Nonetheless, the good news about this is that you can simply ignore that tag, 
possibly without any practical consequence.  You still get your mesh and you 
still get a hand-full of tags which you may or may not use (reference to a 
physical entity, geometrical entity and mesh partition).  If you weren't 
expecting to get more information from that mesh then you can pretty much 
ignore everything else and you won't miss any information.


Hope this helps,
Rui Maciel

[1] http://www.geuz.org/gmsh/doc/texinfo/gmsh.html#MSH-ASCII-file-format