Skip to content
Snippets Groups Projects
Commit 3640900a authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

fix+cleanup
parent e92281e3
No related branches found
No related tags found
No related merge requests found
...@@ -9,10 +9,9 @@ function mesh = load_gmsh ( filename ) ...@@ -9,10 +9,9 @@ function mesh = load_gmsh ( filename )
while 1 while 1
tline = fgetl(fid); tline = fgetl(fid);
if feof(fid), endoffile=1, break, end if feof(fid), endoffile=1, break, end
if tline(1) == '$' break, end if tline(1) == '$', break, end
end end
if endoffile == 1, break, end if endoffile == 1, break, end
if tline(2) == 'N' && tline(3) == 'O' if tline(2) == 'N' && tline(3) == 'O'
disp('reading nodes') disp('reading nodes')
mesh.nbNod = fscanf(fid, '%d', 1); mesh.nbNod = fscanf(fid, '%d', 1);
...@@ -38,18 +37,18 @@ function mesh = load_gmsh ( filename ) ...@@ -38,18 +37,18 @@ function mesh = load_gmsh ( filename )
end end
tline = fgetl(fid); tline = fgetl(fid);
disp('nodes have been read') disp('nodes have been read')
elseif tline(2) == 'E' && tline(3) == 'L' elseif tline(2) == 'E' && tline(3) == 'L'
disp('reading elements') disp('reading elements')
mesh.nbElm = fscanf(fid, '%d', 1); mesh.nbElm = fscanf(fid, '%d', 1);
mesh.ELE_INFOS = zeros(mesh.nbElm, 5); mesh.ELE_INFOS = zeros(mesh.nbElm, 5);
mesh.nbBeams = 0; mesh.nbLines = 0;
mesh.nbPoints = 0; mesh.nbPoints = 0;
mesh.nbTriangles = 0; mesh.nbTriangles = 0;
mesh.nbQuads = 0; mesh.nbQuads = 0;
mesh.nbTet = 0; mesh.nbTets = 0;
% comment next 5 lines to get "tight" arrays (will slow down reading)
mesh.POINTS = zeros(mesh.nbElm, 2); mesh.POINTS = zeros(mesh.nbElm, 2);
mesh.BEAMS=zeros(mesh.nbElm,3); mesh.LINES = zeros(mesh.nbElm, 3);
mesh.TRIANGLES = zeros(mesh.nbElm, 4); mesh.TRIANGLES = zeros(mesh.nbElm, 4);
mesh.QUADS = zeros(mesh.nbElm, 5); mesh.QUADS = zeros(mesh.nbElm, 5);
mesh.TETS = zeros(mesh.nbElm, 5); mesh.TETS = zeros(mesh.nbElm, 5);
...@@ -59,20 +58,20 @@ function mesh = load_gmsh ( filename ) ...@@ -59,20 +58,20 @@ function mesh = load_gmsh ( filename )
if(mesh.ELE_INFOS(I, 2) == 15) %% point if(mesh.ELE_INFOS(I, 2) == 15) %% point
mesh.nbPoints = mesh.nbPoints + 1; mesh.nbPoints = mesh.nbPoints + 1;
mesh.POINTS(mesh.nbPoints, 1) = IDS(NODES_ELEM(1)); mesh.POINTS(mesh.nbPoints, 1) = IDS(NODES_ELEM(1));
mesh.POINTS ( mesh.nbPoints,2 ) = I; mesh.POINTS(mesh.nbPoints, 2) = mesh.ELE_INFOS(I, 3);
end end
if (mesh.ELE_INFOS(I,2) == 1) %% beam if(mesh.ELE_INFOS(I, 2) == 1) %% line
mesh.nbBeams = mesh.nbBeams + 1; mesh.nbLines = mesh.nbLines + 1;
mesh.BEAMS ( mesh.nbBeams,1 ) = IDS (NODES_ELEM ( 1) ); mesh.LINES(mesh.nbLines, 1) = IDS(NODES_ELEM(1));
mesh.BEAMS ( mesh.nbBeams,2 ) = IDS (NODES_ELEM ( 2) ); mesh.LINES(mesh.nbLines, 2) = IDS(NODES_ELEM(2));
mesh.BEAMS ( mesh.nbBeams,3 ) = I; mesh.LINES(mesh.nbLines, 3) = mesh.ELE_INFOS(I, 3);
end end
if(mesh.ELE_INFOS(I, 2) == 2) %% triangle if(mesh.ELE_INFOS(I, 2) == 2) %% triangle
mesh.nbTriangles = mesh.nbTriangles + 1; mesh.nbTriangles = mesh.nbTriangles + 1;
mesh.TRIANGLES(mesh.nbTriangles, 1) = IDS(NODES_ELEM(1)); mesh.TRIANGLES(mesh.nbTriangles, 1) = IDS(NODES_ELEM(1));
mesh.TRIANGLES(mesh.nbTriangles, 2) = IDS(NODES_ELEM(2)); mesh.TRIANGLES(mesh.nbTriangles, 2) = IDS(NODES_ELEM(2));
mesh.TRIANGLES(mesh.nbTriangles, 3) = IDS(NODES_ELEM(3)); mesh.TRIANGLES(mesh.nbTriangles, 3) = IDS(NODES_ELEM(3));
mesh.TRIANGLES ( mesh.nbTriangles , 4) = I; mesh.TRIANGLES(mesh.nbTriangles, 4) = mesh.ELE_INFOS(I, 3);
end end
if(mesh.ELE_INFOS(I, 2) == 3) %% quadrangle if(mesh.ELE_INFOS(I, 2) == 3) %% quadrangle
mesh.nbQuads = mesh.nbQuads + 1; mesh.nbQuads = mesh.nbQuads + 1;
...@@ -80,17 +79,16 @@ function mesh = load_gmsh ( filename ) ...@@ -80,17 +79,16 @@ function mesh = load_gmsh ( filename )
mesh.QUADS(mesh.nbQuads, 2) = IDS(NODES_ELEM(2)); mesh.QUADS(mesh.nbQuads, 2) = IDS(NODES_ELEM(2));
mesh.QUADS(mesh.nbQuads, 3) = IDS(NODES_ELEM(3)); mesh.QUADS(mesh.nbQuads, 3) = IDS(NODES_ELEM(3));
mesh.QUADS(mesh.nbQuads, 4) = IDS(NODES_ELEM(4)); mesh.QUADS(mesh.nbQuads, 4) = IDS(NODES_ELEM(4));
mesh.QUADS ( mesh.nbQuads , 5) = I; mesh.QUADS(mesh.nbQuads, 5) = mesh.ELE_INFOS(I, 3);
end end
if(mesh.ELE_INFOS(I, 2) == 4) %% tet if(mesh.ELE_INFOS(I, 2) == 4) %% tet
mesh.nbTet = mesh.nbTet + 1; mesh.nbTets = mesh.nbTets + 1;
mesh.QUADS ( mesh.nbTet , 1) = IDS (NODES_ELEM ( 1) ); mesh.TETS(mesh.nbTets, 1) = IDS(NODES_ELEM(1));
mesh.QUADS ( mesh.nbTet , 2) = IDS (NODES_ELEM ( 2) ); mesh.TETS(mesh.nbTets, 2) = IDS(NODES_ELEM(2));
mesh.QUADS ( mesh.nbTet , 3) = IDS (NODES_ELEM ( 3) ); mesh.TETS(mesh.nbTets, 3) = IDS(NODES_ELEM(3));
mesh.QUADS ( mesh.nbTet , 4) = IDS (NODES_ELEM ( 4) ); mesh.TETS(mesh.nbTets, 4) = IDS(NODES_ELEM(4));
mesh.QUADS ( mesh.nbTet , 5) = mesh.ELE_INFOS(I,3); mesh.TETS(mesh.nbTets, 5) = mesh.ELE_INFOS(I, 3);
end end
end end
tline = fgetl(fid); tline = fgetl(fid);
disp('elements have been read') disp('elements have been read')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment