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

Last change on this file since 2953 was 2953, checked in by Eric.Larour, 15 years ago

Took out system calls in OS, because Matlab tends to hang with system commands.
oshostname should not return the hostname, without trailing whites.
Added routines for analysis runs, typically found in runme.m files.
BamgCallFromMetric: can now call Bamg with metric directly.
ddewhite,ddeblank,ddeblank: strip trailing whites from string.

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