[Gmsh] Where to find the code that reads msh file and generates faces?

Jeremy Theler jeremy at seamplex.com
Fri Sep 22 17:50:13 CEST 2017

On Fri, 2017-09-22 at 12:13 +0200, Jayesh Badwaik wrote:

> I am looking for code in gmsh that reads the msh file (say of an 2d 
> triangular grid as the msh file attached in the mail) and populates the 
> faces which are displayed in the mesh but not written in the gmsh file. 
> (As far as I understand, gmsh writes only the boundary faces.) 

your question can be answered by grepping for '$Nodes' for example in the source tree. The answer is


> I am trying to write a code that reads msh files and and converts it into 
> a grid. This involves populating the faces which are not written in the 
> msh file. I see that gmsh itself is able to read the msh file and populate 
> the faces very quickly (almost instantly on my computer). 

At first I did not understand your point, but after a second look it seems to me you are referring to the
faces of the volumetric elements that are in the bulk of a volume (i.e. the triangles that conform a
tetrahedron) so you can detect neighboring cells,  aren't you?
If that is the case, then it is an old unresolved issue:


> In contrast, my own finite volume code takes substantially more time to 
> read the same mesh. Hence, I am wondering how gmsh does it so quickly 
> and would like to read the relevant code. 

I am betting on inefficient loops.
I am not a Gmsh developer, but I have written my own .msh reader/writer for both FEM and FVM.
See for example


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://onelab.info/pipermail/gmsh/attachments/20170922/3f7cfed3/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: This is a digitally signed message part
URL: <http://onelab.info/pipermail/gmsh/attachments/20170922/3f7cfed3/attachment.asc>

More information about the gmsh mailing list