Home > vbmeg > external > iso2mesh > saveabaqus.m

saveabaqus

PURPOSE ^

SYNOPSIS ^

function saveabaqus(node,face,elem,fname,heading)

DESCRIPTION ^

 saveabaqus(node,fname)
 saveabaqus(node,face,fname)
 saveabaqus(node,face,elem,fname)

 save a tetrahedral and/or surface mesh as an ABAQUS input file

 author: Qianqian Fang, <q.fang at neu.edu>
 date: 2012/07/05

 input:
      node: input, surface node list, dimension (nn,3)
      face: input, surface face element list, dimension (be,3)
      elem: input, tetrahedral element list, dimension (ne,4)
      fname: output file name
      heading: optional, a descriptive string for the mesh

 -- 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 saveabaqus(node,face,elem,fname,heading)
0002 %
0003 % saveabaqus(node,fname)
0004 % saveabaqus(node,face,fname)
0005 % saveabaqus(node,face,elem,fname)
0006 %
0007 % save a tetrahedral and/or surface mesh as an ABAQUS input file
0008 %
0009 % author: Qianqian Fang, <q.fang at neu.edu>
0010 % date: 2012/07/05
0011 %
0012 % input:
0013 %      node: input, surface node list, dimension (nn,3)
0014 %      face: input, surface face element list, dimension (be,3)
0015 %      elem: input, tetrahedral element list, dimension (ne,4)
0016 %      fname: output file name
0017 %      heading: optional, a descriptive string for the mesh
0018 %
0019 % -- this function is part of iso2mesh toolbox (http://iso2mesh.sf.net)
0020 %
0021 
0022 if(nargin==2)
0023    fname=face;
0024    face=[];
0025    elem=[];
0026 end
0027 
0028 if(nargin==3)
0029    fname=elem;
0030    elem=[];
0031 end
0032 
0033 fid=fopen(fname,'wt');
0034 if(fid==-1)
0035     error('You do not have permission to save mesh files.');
0036 end
0037 
0038 fprintf(fid,'*HEADING\n');
0039 if(exist('heading','var'))
0040     fprintf(fid,'**%s\n',heading);
0041 end
0042 fprintf(fid,'*PREPRINT,MODEL=NO,HISTORY=NO,ECHO=NO\n');
0043 
0044 if(~isempty(node))
0045   node=[(1:size(node,1))' node(:,1:3)];
0046   fprintf(fid,'*NODE, NSET=MeshNode\n');
0047   fprintf(fid,'%d,\t%e,\t%e,\t%e\n',node');
0048 end
0049 
0050 if(~isempty(elem))
0051   if(size(elem,2)==4)
0052      elem(:,5)=0;
0053      labels=0;
0054   elseif(size(elem,2)<4)
0055      error('elem must have at least 4 columns');
0056   else
0057      labels=unique(elem(:,5));
0058   end
0059   len=length(labels);
0060   count=0;
0061   elsetall='';
0062   for i=1:len
0063       idx=find(elem(:,5)==labels(i));
0064       fprintf(fid,'*ELEMENT, ELSET=MeshTetra%d, TYPE=C3D4\n',labels(i));
0065       fprintf(fid,'%d,\t%d,\t%d,\t%d,\t%d\n',[count+(1:length(idx))' elem(idx,1:4)]');
0066       count=count+length(idx);
0067       if(length(elsetall)==0)
0068           elsetall=['MeshTetra' num2str(labels(i))];
0069       else
0070           elsetall=sprintf('%s,MeshTetra%d',elsetall,labels(i));
0071       end
0072   end
0073   if(length(elsetall))
0074       fprintf(fid,'*ELSET, ELSET=MeshTetraAll\n%s\n',elsetall);
0075   end
0076 end
0077 
0078 if(~isempty(face))
0079   if(size(face,2)==3)
0080      face(:,4)=0;
0081      labels=0;
0082   elseif(size(face,2)<3)
0083      error('face must have at least 3 columns');
0084   else
0085      labels=unique(face(:,4));
0086   end
0087   len=length(labels);
0088   if(exist('count','var')==0)
0089      count=0;
0090   end
0091   elsetall='';
0092   for i=1:len
0093       idx=find(face(:,4)==labels(i));
0094       fprintf(fid,'*ELEMENT, ELSET=MeshTri%d, TYPE=S3R\n',labels(i));
0095       fprintf(fid,'%d,\t%d,\t%d,\t%d\n',[count+(1:length(idx))' face(idx,1:3)]');
0096       count=count+length(idx);
0097       if(length(elsetall)==0)
0098           elsetall=['MeshTetra' num2str(labels(i))];
0099       else
0100           elsetall=sprintf('%s,MeshTri%d',elsetall,labels(i));
0101       end
0102   end
0103   if(length(elsetall))
0104       fprintf(fid,'*ELSET, ELSET=MeshTriAll\n%s\n',elsetall);
0105   end
0106 end
0107 
0108 fclose(fid);

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