Skip to content

Commit

Permalink
remove loop in savemphtxt, patch by @brainwatcher,close #50
Browse files Browse the repository at this point in the history
  • Loading branch information
fangq committed Sep 12, 2021
1 parent 180618d commit 238c987
Showing 1 changed file with 10 additions and 18 deletions.
28 changes: 10 additions & 18 deletions savemphtxt.m
Original file line number Diff line number Diff line change
Expand Up @@ -40,36 +40,28 @@ function savemphtxt(node, face, elem, filename)
fprintf(fp,'0 0 1\n4 Mesh\n2\n3\n%d\n1\n',n_node);

% Write Node information
for i = 1:n_node
fprintf(fp,'%.16f %.16f %.16f\n',node(i,1),node(i,2),node(i,3));
end
fprintf(fp,'%.16f %.16f %.16f\n',node(:,1:3).');
fprintf(fp, '\n2\n\n3 tri\n');

% Write Tri information
fprintf(fp, '\n3\n');
fprintf(fp, '%d\n\n',n_face);
for i = 1:n_face
fprintf(fp,'%d %d %d\n',face(i,1),face(i,2),face(i,3));
end
fprintf(fp,'%d %d %d\n',face(:,1:3).');

fprintf(fp, '\n1\n0\n');
fprintf(fp, '%d\n',n_face);
for i = 1:n_face
fprintf(fp,'%d\n',face(i,4));
end
fprintf(fp,'%d\n',face(:,4).');

fprintf(fp, '\n%d\n',n_face);
for i = 1:n_face
fprintf(fp,'0 0\n');
end
fprintf(fp,'%d %d\n', zeros(0,n_face));

% Write Tet information
fprintf(fp, '\n\n3 tet\n4\n\n%d\n', n_elem);
for i = 1:n_elem
fprintf(fp,'%d %d %d %d\n',elem(i,1),elem(i,2),elem(i,3),elem(i,4));
end
fprintf(fp,'%d %d %d %d\n',elem(:,1:4).');

fprintf(fp, '\n4\n0\n%d\n%d\n', n_elem);
for i = 1:n_elem
fprintf(fp,'%d\n',elem(i,5));
end
fprintf(fp,'%d\n',elem(:,5).');

fprintf(fp,'\n0\n');
fclose(fp);

0 comments on commit 238c987

Please sign in to comment.