Home > vbmeg > external > iso2mesh > savetetgenele.m

savetetgenele

PURPOSE ^

SYNOPSIS ^

function savetetgenele(elem,fname)

DESCRIPTION ^

 savetetgenele(elem,fname)

 save a mesh tetrahedral element list to tetgen .ele format

 author: Qianqian Fang, <q.fang at neu.edu>

 input:
      elem: tetrahedral element list, dimension (ne,4)
            columns beyound the 4rd column are treated as 
            markers and attributes associated with the element
      fname: output file name

 -- this function is part of iso2mesh toolbox (http://iso2mesh.sf.net)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function savetetgenele(elem,fname)
0002 %
0003 % savetetgenele(elem,fname)
0004 %
0005 % save a mesh tetrahedral element list to tetgen .ele format
0006 %
0007 % author: Qianqian Fang, <q.fang at neu.edu>
0008 %
0009 % input:
0010 %      elem: tetrahedral element list, dimension (ne,4)
0011 %            columns beyound the 4rd column are treated as
0012 %            markers and attributes associated with the element
0013 %      fname: output file name
0014 %
0015 % -- this function is part of iso2mesh toolbox (http://iso2mesh.sf.net)
0016 %
0017 
0018 hasprop=0;
0019 attrstr='';
0020 markers='';
0021 
0022 fid=fopen(fname,'wt');
0023 if(fid==0)
0024         error(['can not write to file ' fname]);
0025 end
0026 if(size(elem,2)>=6)
0027         hasprop=size(elem,2)-5;
0028         attrstr=repmat('%e ',1,hasprop);
0029 end
0030 if(size(elem,2)>=5)
0031         markers='%d';
0032 end
0033 elem(:,1:4)=elem(:,1:4)-1;
0034 fprintf(fid,'%d %d %d\n',size(elem,1),4,hasprop+(size(elem,2)>=5));
0035 fprintf(fid,['%d %d %d %d %d ' attrstr markers '\n'], [(1:size(elem,1))'-1 elem]');
0036 fclose(fid);

Generated on Mon 22-May-2023 06:53:56 by m2html © 2005