Changeset 14862
- Timestamp:
- 05/02/13 15:21:57 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified issm/trunk-jpl/src/m/mesh/ExportGmsh.m ΒΆ
r14845 r14862 9 9 fid=fopen(filename,'w'); 10 10 11 %initialiation 12 fprintf(fid,'\n%s\n%i\n','MeshVersionFormatted',1); 11 %initialiaion 12 fprintf(fid,'$MeshFormat \n'); 13 fprintf(fid,'2.2 0 8 \n'); 14 fprintf(fid,'$EndMeshFormat \n'); 15 fprintf(fid,'$Nodes \n'); 16 fprintf(fid,'%i \n',md.mesh.numberofvertices); 17 np=0; 18 %printing point positions 19 for ii=1:md.mesh.numberofvertices 20 np = np+1; 21 fprintf(fid,'%g %14.7e %14.7e 0.0 \n',np,md.mesh.x(np),md.mesh.y(np)); 22 end 13 23 14 %dimension 15 fprintf(fid,'\n%s\n%i\n','Dimension',2); 24 fprintf(fid,'$EndNodes \n'); 25 fprintf(fid,'$Elements \n'); 26 fprintf(fid,'%i \n',md.mesh.numberofelements+size(md.mesh.segments,1)); 27 np=0; 16 28 17 %Vertices 18 fprintf(fid,'\n%s\n%i\n\n','Vertices',md.mesh.numberofvertices); 19 fprintf(fid,'%8g %8g %i\n',[md.mesh.x md.mesh.y zeros(md.mesh.numberofvertices,1)]'); 29 %printing elements caracteristics for boundaries 20 30 21 %Triangles 22 fprintf(fid,'\n\n%s\n%i\n\n','Triangles',md.mesh.numberofelements); 23 fprintf(fid,'%i %i %i %i\n',[md.mesh.elements zeros(md.mesh.numberofelements,1)]'); 24 31 for ii=1:size(md.mesh.segments,1) 32 np = np+1; 33 if(md.mesh.x(md.mesh.segments(np,1))==max(md.mesh.x(:))&&md.mesh.x(md.mesh.segments(np,2))==max(md.mesh.x(:))), 34 bc_id=1; 35 elseif(md.mesh.y(md.mesh.segments(np,1))==max(md.mesh.y(:))&&md.mesh.y(md.mesh.segments(np,2))==max(md.mesh.y(:))), 36 bc_id=2; 37 elseif(md.mesh.x(md.mesh.segments(np,1))==min(md.mesh.x(:))&&md.mesh.x(md.mesh.segments(np,2))==min(md.mesh.x(:))), 38 bc_id=3; 39 elseif(md.mesh.y(md.mesh.segments(np,1))==min(md.mesh.y(:))&&md.mesh.y(md.mesh.segments(np,2))==min(md.mesh.y(:))), 40 bc_id=4; 41 end 42 fprintf(fid,'%g 1 2 %g 1 %g %g \n',np,bc_id,md.mesh.segments(np,1),md.mesh.segments(np,2)); 43 end 44 %and for the body 45 body_id=1; 46 for ii=1:md.mesh.numberofelements 47 np = np+1; 48 fprintf(fid,'%g 2 2 %g 3 %g %g %g \n',np,body_id,md.mesh.elements(ii,1),md.mesh.elements(ii,2),md.mesh.elements(ii,3)); 49 end 50 fprintf(fid,'$EndElements \n'); 25 51 %close 26 52 fclose(fid); 27 53 t2=clock;fprintf('%s\n',[' done (' num2str(etime(t2,t1)) ' seconds)']); 54
Note:
See TracChangeset
for help on using the changeset viewer.