Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove loop in savemphtxt #50

Closed
wants to merge 3 commits into from
Closed
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 28 additions & 28 deletions savemphtxt.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
function savemphtxt(node, face, elem, filename)
%
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you restore this empty line? without it, matlab has different behaviors

% savemphtxt(node, face, elem, filename)
%
% save tetrahedron mesh to comsol file (.mphtxt)
Expand All @@ -19,18 +18,17 @@ function savemphtxt(node, face, elem, filename)
n_node = size(node,1);
n_face = size(face,1);
n_elem = size(elem,1);

elem(:,1:4)=meshreorient(node(:,1:3),elem(:,1:4));
brainwatcher marked this conversation as resolved.
Show resolved Hide resolved

if(size(face,2)<4)
if size(face,2)==3
face(:,4)=1;
elseif(min(face(:,4))==0)
face(:,4)=face(:,4)+1;
end

if(size(elem,2)<5)
if size(elem,2)==4
elem(:,5)=1;
elseif(min(elem(:,5))==0)
end

if(min(face(:,4))==0)
face(:,4)=face(:,4)+1;
end
if(min(elem(:,5))==0)
elem(:,5)=elem(:,5)+1;
end

Expand All @@ -40,36 +38,38 @@ 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
% for i = 1:n_face
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove these commented lines if they are no longer needed. git keeps track of all edit history, so no need to keep those in the code.

fprintf(fp,'%d %d %d\n',face(:,1:3).');
% end
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
a = repmat([0 0], n_face, 1);
fprintf(fp,'%d %d\n', a); % no need for transpose since it's all 0s
% for i = 1:n_face
% fprintf(fp,'0 0\n');
% end

% 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
%for i = 1:n_elem
fprintf(fp,'%d %d %d %d\n',elem(:,1:4).');
%end
fprintf(fp, '\n4\n0\n%d\n%d\n', n_elem);
for i = 1:n_elem
fprintf(fp,'%d\n',elem(i,5));
end
% for i = 1:n_elem
fprintf(fp,'%d\n',elem(:,5).');
% end
fprintf(fp,'\n0\n');
fclose(fp);