[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

Geo/GModelIO_MSH.cpp
Geo/GModelIO_MSH2.cpp

> 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:

http://onelab.info/pipermail/gmsh/2013/008183.html


> 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

https://bitbucket.org/seamplex/wasora/src/3dd04c3c1c236adae5799354114698112c46e232/src/mesh/gmsh.c?at=maste
r&fileviewer=file-view-default
https://bitbucket.org/seamplex/wasora/src/3dd04c3c1c236adae5799354114698112c46e232/src/mesh/neighbors.c?at=
master&fileviewer=file-view-default

Regards
--
jeremy
www.seamplex.com
-------------- 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