Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
gmsh
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Larry Price
gmsh
Commits
dcab669f
Commit
dcab669f
authored
19 years ago
by
Christophe Geuzaine
Browse files
Options
Downloads
Patches
Plain Diff
new upstream release
parent
9abbecef
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
utils/converters/scilab/load_gmsh.sci
+103
-84
103 additions, 84 deletions
utils/converters/scilab/load_gmsh.sci
with
103 additions
and
84 deletions
utils/converters/scilab/load_gmsh.sci
+
103
−
84
View file @
dcab669f
function gmesh = load_gmsh ( filename )
function gmesh = load_gmsh ( filename )
gmesh = [];
[fid,ierr] = mopen ( filename, 'r');
if ierr <> 0 then;
mclose(fid);
error('no such file: '+filename)
end
gmesh = [];
gmesh.MIN = zeros(3,1);
gmesh.MIN = zeros(3,1);
gmesh.MAX = zeros(3,1);
gmesh.MAX = zeros(3,1);
fid = mopen ( filename, 'r');
while 1
while 1
endoffile = 0;
endoffile = 0;
// while (1)
while (1)
// tline = mgetl(fid,1);
// jump over irrelevant text
// if meof(fid), endoffile=1,break, end
tline = mgetl(fid,1);
// if (tline == '$'), break, end
if meof(fid), endoffile=1,break, end
// end
if (part(tline,1) == '$'), break, end
end
tline = mgetl(fid,1);
if meof(fid), endoffile=1,break, end
if (tline == '$'), break, end
if (endoffile == 1), break, end
if (endoffile == 1), break, end
if (part(tline,1:4) == '$NOD' | part(tline,1:4) == '$Nod')
if tline == '$NOD'
disp('reading nodes')
disp('reading nodes')
gmesh.nbNod = mfscanf (1, fid, '%d');
gmesh.nbNod = mfscanf (1, fid, '%d');
gmesh.POS = zeros (gmesh.nbNod, 3);
gmesh.POS = zeros (gmesh.nbNod, 3);
for(I=1:gmesh.nbNod)
for(I=1:gmesh.nbNod)
iNod = mfscanf(1,fid,'%d');
iNod = mfscanf(1,fid,'%d');
X = mfscanf(3,fid,'%g');
X = mfscanf(3,fid,'%g');
...
@@ -48,74 +47,94 @@ function gmesh = load_gmsh ( filename )
...
@@ -48,74 +47,94 @@ function gmesh = load_gmsh ( filename )
tline = mgetl(fid,2); // read 2 dummy lines
tline = mgetl(fid,2); // read 2 dummy lines
disp('nodes have been read')
disp('nodes have been read')
else
elseif(part(tline,1:4)=='$ELM' | part(tline,1:4)=='$Ele')
if (tline == '$ELM')
disp('reading elements')
disp('reading elements')
gmesh.nbElm = mfscanf (1,fid, '%d');
gmesh.nbElm = mfscanf (1,fid, '%d');
gmesh.ELE_INFOS = zeros (gmesh.nbElm,5);
gmesh.ELE_INFOS = zeros (gmesh.nbElm,5);
gmesh.nbLines = 0;
gmesh.nbLines = 0;
gmesh.nbPoints = 0;
gmesh.nbPoints = 0;
gmesh.nbTriangles = 0;
gmesh.nbTriangles = 0;
gmesh.nbQuads = 0;
gmesh.nbQuads = 0;
gmesh.nbPrism=0;
gmesh.nbPrism=0;
gmesh.nbPyr=0;
gmesh.nbPyr=0;
gmesh.nbTet = 0;
gmesh.nbTet = 0;
gmesh.nbHex = 0;
gmesh.nbHex = 0;
gmesh.nbQTriangles = 0;
gmesh.nbQTriangles = 0;
gmesh.nbQQuads = 0;
gmesh.nbQQuads = 0;
gmesh.POINTS=[];
gmesh.POINTS=[];
gmesh.LINES=[];
gmesh.LINES=[];
gmesh.TRIANGLES=[];
gmesh.TRIANGLES=[];
gmesh.QUADS=[];
gmesh.QUADS=[];
gmesh.TETS=[];
gmesh.TETS=[];
gmesh.HEXA=[];
gmesh.HEXA=[];
gmesh.PRISM=[];
gmesh.PRISM=[];
gmesh.PYRAMID=[];
gmesh.PYRAMID=[];
gmesh.QTRIANGLES=[];
gmesh.QTRIANGLES=[];
gmesh.QQUADS=[];
gmesh.QQUADS=[];
for (I=1:gmesh.nbElm)
for (I=1:gmesh.nbElm)
if (part(tline,1:4)=='$Ele')
gmesh.ELE_INFOS(I,:) = mfscanf(5,fid,'%d')';
// file is in GMSH version 2.0 format
NODES_ELEM = mfscanf(gmesh.ELE_INFOS(I,5),fid,'%d')';
gmesh.ELE_INFOS(I,1:3) = mfscanf(3,fid,'%d')';
select gmesh.ELE_INFOS(I,2)
n_of_tags = gmesh.ELE_INFOS(I,3);
case 15 then // point
gmesh.ELE_INFOS(I,4+(1:n_of_tags)) = mfscanf(n_of_tags,fid,'%d')';
gmesh.nbPoints = gmesh.nbPoints + 1;
// the number of points
gmesh.POINTS =[gmesh.POINTS; IDS(NODES_ELEM (1))' I];
select gmesh.ELE_INFOS(I,2)
case 1 then // beam
case 15 then, np=1;
gmesh.nbLines = gmesh.nbLines + 1;
case 1 then, np=2;
gmesh.LINES =[gmesh.LINES; IDS(NODES_ELEM (1:2))' I];
case 2 then, np=3;
case 2 then // triangle
case 3 then, np=4;
gmesh.nbTriangles = gmesh.nbTriangles + 1;
case 4 then, np=4;
gmesh.TRIANGLES = [gmesh.TRIANGLES; IDS(NODES_ELEM (1:3))' I];
case 5 then, np=8;
case 3 then // quadrangle
case 6 then, np=6;
gmesh.nbQuads = gmesh.nbQuads + 1;
case 7 then, np=5;
gmesh.QUADS =[gmesh.QUADS; IDS(NODES_ELEM (1:4))' I];
case 9 then, np=6;
case 4 then // tetrahedron (4 node)
case 10 then, np=9;
gmesh.nbTet = gmesh.nbTet + 1;
end
gmesh.TETS = [gmesh.TETS; IDS(NODES_ELEM (1:4))' I];
NODES_ELEM = mfscanf(np,fid,'%d')';
case 5 then // hexahedron (8 nodes)
else
gmesh.nbHex = gmesh.nbHex + 1;
// version 1.0 format
gmesh.HEXA =[gmesh.HEXA; IDS(NODES_ELEM (1:8))' I];
gmesh.ELE_INFOS(I,:) = mfscanf(5,fid,'%d')';
case 6 then // prism (6 nodes)
NODES_ELEM = mfscanf(gmesh.ELE_INFOS(I,5),fid,'%d')';
gmesh.nbPrism = gmesh.nbPrism + 1;
end
gmesh.PRISM =[gmesh.PRISM; IDS(NODES_ELEM (1:6))' I];
select gmesh.ELE_INFOS(I,2)
case 7 then // pyramid (5 nodes)
case 15 then // point
gmesh.nbPyr = gmesh.nbPyr + 1;
gmesh.nbPoints = gmesh.nbPoints + 1;
gmesh.PYRAMID =[gmesh.PYRAMID; IDS(NODES_ELEM (1:5))' I];
gmesh.POINTS =[gmesh.POINTS; IDS(NODES_ELEM (1))' I];
case 9 then // second order triangle (6 nodes)
case 1 then // beam
gmesh.nbQTriangles = gmesh.nbQTriangles + 1;
gmesh.nbLines = gmesh.nbLines + 1;
gmesh.QTRIANGLES = [gmesh.QTRIANGLES; IDS(NODES_ELEM (1:6))' I];
gmesh.LINES =[gmesh.LINES; IDS(NODES_ELEM (1:2))' I];
case 10 then // second order quadrangle (9 nodes)
case 2 then // triangle
gmesh.nbQQuads = gmesh.nbQQuads + 1;
gmesh.nbTriangles = gmesh.nbTriangles + 1;
gmesh.QQUADS = [gmesh.QQUADS; IDS(NODES_ELEM (1:9))' I];
gmesh.TRIANGLES = [gmesh.TRIANGLES; IDS(NODES_ELEM (1:3))' I];
else
case 3 then // quadrangle
disp(' ')
gmesh.nbQuads = gmesh.nbQuads + 1;
warning('Unknown element type '+string(gmesh.ELE_INFOS(I,2)) +' !')
gmesh.QUADS =[gmesh.QUADS; IDS(NODES_ELEM (1:4))' I];
end
case 4 then // tetrahedron (4 node)
end
gmesh.nbTet = gmesh.nbTet + 1;
tline = mgetl(fid,1);
gmesh.TETS = [gmesh.TETS; IDS(NODES_ELEM (1:4))' I];
disp('elements have been read')
case 5 then // hexahedron (8 nodes)
gmesh.nbHex = gmesh.nbHex + 1;
gmesh.HEXA =[gmesh.HEXA; IDS(NODES_ELEM (1:8))' I];
case 6 then // prism (6 nodes)
gmesh.nbPrism = gmesh.nbPrism + 1;
gmesh.PRISM =[gmesh.PRISM; IDS(NODES_ELEM (1:6))' I];
case 7 then // pyramid (5 nodes)
gmesh.nbPyr = gmesh.nbPyr + 1;
gmesh.PYRAMID =[gmesh.PYRAMID; IDS(NODES_ELEM (1:5))' I];
case 9 then // second order triangle (6 nodes)
gmesh.nbQTriangles = gmesh.nbQTriangles + 1;
gmesh.QTRIANGLES = [gmesh.QTRIANGLES; IDS(NODES_ELEM (1:6))' I];
case 10 then // second order quadrangle (9 nodes)
gmesh.nbQQuads = gmesh.nbQQuads + 1;
gmesh.QQUADS = [gmesh.QQUADS; IDS(NODES_ELEM (1:9))' I];
else
disp(' ')
warning('Unknown element type ' + string(gmesh.ELE_INFOS(I,2)) + ' !')
end
end
end
end
disp('elements have been read')
end
tline = mgetl(fid,1);
end //
end // while
mclose (fid);
mclose (fid);
endfunction
endfunction
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment