[Gmsh] help in reading element connectivity

Christophe Geuzaine cgeuzaine at uliege.be
Thu Feb 22 09:06:20 CET 2018


PS: there are also some scripts here: https://gitlab.onelab.info/gmsh/gmsh/tree/master/utils/converters/matlab

> On 21 Feb 2018, at 19:16, Octavio Castillo Reyes <ocastilloreyes at gmail.com> wrote:
> 
> Dear Preety, 
> 
> You need to write a Matlab script to import your mesh. This task is quite simple, for instance:
> 
> % Formats
> fstring  = '%s';
> finteger = '%d';
> fnodes   = '%d %f %f %f';
> felems   = '%f %f %f %f %f %f %f %f';
> % Open file
> Idfile = fopen(mesh_file,'r');
> % Read 4 lines (Header)
> n = 4; textscan(Idfile,fstring,n,'Delimiter','\n');
> % Read number of subdomains
> n = 1; input = textscan(Idfile,finteger,n,'Delimiter','\n');
> nsubdomains = input{1}(1);
> % Read 2 + nsubdomains lines
> n = 2 + nsubdomains; textscan(Idfile,fstring,n,'Delimiter','\n');
> % Read number of nodes
> n = 1; input = textscan(Idfile,finteger,n,'Delimiter','\n');
> nNodes = input{1}(1);
> % Read spatial positions of the nodes
> n = nNodes; input = textscan(Idfile,fnodes,n,'Delimiter','\n');
> nodes = transpose(horzcat(input{2},input{3},input{4}));
> % Read 2 lines
> n = 2; input = textscan(Idfile,fstring,n,'Delimiter', '\n');
> % Read number of elements
> n = 1; input = textscan(Idfile,finteger,n,'Delimiter','\n');
> nElems = input{1}(1);
> % Read nodal/elements connectivity
> n = nElems; input = textscan(Idfile,felems,n,'Delimiter','\n');
> elemsN = transpose(horzcat(input{6},input{7},input{8}));
> % Read physical groups
> phy_groups = input{4};
> fclose(Idfile);
> 
> 
> Otherwise, you can use the python parser by José A. Abell (https://github.com/jaabell/gmshtranslator <https://github.com/jaabell/gmshtranslator>)
> 
> Best regards
> 
> O.
> 
> 
> 
> On Wed, Feb 21, 2018 at 5:41 PM, preetyobi at gmail.com <mailto:preetyobi at gmail.com> <preetyobi at gmail.com <mailto:preetyobi at gmail.com>> wrote:
> Hi,
> I have created a 2D mesh in gmsh but able to understand how it is providing the elements connectivity also if possible provide me help regarding how to read this file in mathlab.
> 
> Thank you
> Preety
> 
> Send from my vivo smart phone
> _______________________________________________
> gmsh mailing list
> gmsh at onelab.info <mailto:gmsh at onelab.info>
> http://onelab.info/mailman/listinfo/gmsh <http://onelab.info/mailman/listinfo/gmsh>
> 
> _______________________________________________
> gmsh mailing list
> gmsh at onelab.info
> http://onelab.info/mailman/listinfo/gmsh

— 
Prof. Christophe Geuzaine
University of Liege, Electrical Engineering and Computer Science 
http://www.montefiore.ulg.ac.be/~geuzaine

Free software: http://gmsh.info | http://getdp.info | http://onelab.info

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://onelab.info/pipermail/gmsh/attachments/20180222/3018d16c/attachment.html>


More information about the gmsh mailing list