source: issm/trunk/src/m/utils/Mesh/BamgCallFromMetric.m@ 6860

Last change on this file since 6860 was 6860, checked in by Mathieu Morlighem, 14 years ago

deleted all global variables. If ISSM_DIR is needed, call issmdir() routine. This makes everything easier: no more clearall

File size: 1.9 KB
RevLine 
[2953]1function md=BamgCallFromMetric(md,metric,gradation),
2%BAMGCALL - call bam
3%
4% call Bamg and the output mesh is plugged onto the model
5% -gradation = maximum edge length gradation between 2 elements
6%
7% Usage:
8% md=BamgCallFromMetric(md,metric,gradation);
9%
10% Example:
11% md=BamgCall(md,metric,1500,10^8,1.3,0.9);
12
13%2d geometric parameter (do not change)
14scale=2/9;
15
16%write files
17t1=clock; fprintf('%s',' writing initial mesh files...');
18fid=fopen('carre0.met','w');
19fprintf(fid,'%i %i\n',md.numberofgrids,3);
20fprintf(fid,'%i %i %i\n',metric');
21fclose(fid);
22
23fid=fopen('carre0.mesh','w');
24
25%initialiation
26fprintf(fid,'%s %i\n','MeshVersionFormatted',0);
27
28%dimension
29fprintf(fid,'\n%s\n%i\n','Dimension',2);
30
31%Vertices
32fprintf(fid,'\n%s\n%i\n\n','Vertices',md.numberofgrids);
33fprintf(fid,'%8g %8g %i\n',[md.x md.y ones(md.numberofgrids,1)]');
34
35%Triangles
36fprintf(fid,'\n\n%s\n%i\n\n','Triangles',md.numberofelements);
37fprintf(fid,'%i %i %i %i\n',[md.elements ones(md.numberofelements,1)]');
38numberofelements1=md.numberofelements;
39
40%close
41fclose(fid);
42t2=clock;fprintf('%s\n',[' done (' num2str(etime(t2,t1)) ' seconds)']);
43
44%call bamg
45fprintf('%s\n',' call Bamg...');
46system(['bamg -ratio ' num2str(gradation) ' -splitpbedge -nbv 1000000 -M carre0.met -b carre0.mesh -o carre1.mesh']);
47
48%plug new mesh
49t1=clock; fprintf('\n%s',' reading final mesh files...');
50A=meshread('carre1.mesh');
51md.x=A.x;
52md.y=A.y;
53md.z=zeros(A.nods,1);
54md.elements=A.index;
55md.numberofgrids=A.nods;
56md.numberofelements=A.nels;
57numberofelements2=md.numberofelements;
58t2=clock;fprintf('%s\n\n',[' done (' num2str(etime(t2,t1)) ' seconds)']);
59
60%display number of elements
61fprintf('\n%s %i',' inital number of elements:',numberofelements1);
62fprintf('\n%s %i\n\n',' new number of elements:',numberofelements2);
63
64%clean up:
65system('rm carre0.mesh carre0.met carre1.mesh carre1.mesh.gmsh');
Note: See TracBrowser for help on using the repository browser.