[Gmsh] help in reading element connectivity
Octavio Castillo Reyes
ocastilloreyes at gmail.com
Wed Feb 21 19:16:22 CET 2018
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)
Best regards
O.
On Wed, Feb 21, 2018 at 5:41 PM, preetyobi at gmail.com <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
> http://onelab.info/mailman/listinfo/gmsh
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://onelab.info/pipermail/gmsh/attachments/20180221/035cfbc1/attachment.html>
More information about the gmsh
mailing list