00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 void save_particles_mesh_format(int num)
00031 {
00032 int i,n;
00033 FILE *fp;
00034 char s[200];
00035
00036 sprintf(s,"particles/position_mesh_format/particles_pos%d.mesh",num);
00037 if(num<100) sprintf(s,"particles/position_mesh_format/particles_pos0%d.mesh",num);
00038 if(num<10) sprintf(s,"particles/position_mesh_format/particles_pos00%d.mesh",num);
00039
00040 printf("Saving the %d particle positions in mesh format... num = %d\n",INUM,num);
00041
00042 fp=fopen(s,"w");
00043 if(fp==NULL){
00044 printf("save_particles_mesh_format : impossible to open the output file!\n");
00045 exit(0);
00046 }
00047 fprintf(fp,"MeshVersionFormatted 1\n");
00048 fprintf(fp,"Dimension\n 3\n");
00049 fprintf(fp,"Vertices\n");
00050 fprintf(fp,"%d\n",INUM);
00051
00052
00053
00054 for(n=1;n<=INUM;n++){
00055
00056 double x,y,z;
00057 i=(int) P[n][9];
00058 x=0.25*(P[n][5]*coord[0][noeud_geo[0][i]-1]
00059 +P[n][6]*coord[0][noeud_geo[1][i]-1]
00060 +P[n][7]*coord[0][noeud_geo[2][i]-1]
00061 +P[n][8]*coord[0][noeud_geo[3][i]-1]);
00062 y=0.25*(P[n][5]*coord[1][noeud_geo[0][i]-1]
00063 +P[n][6]*coord[1][noeud_geo[1][i]-1]
00064 +P[n][7]*coord[1][noeud_geo[2][i]-1]
00065 +P[n][8]*coord[1][noeud_geo[3][i]-1]);
00066 z=0.25*(P[n][5]*coord[2][noeud_geo[0][i]-1]
00067 +P[n][6]*coord[2][noeud_geo[1][i]-1]
00068 +P[n][7]*coord[2][noeud_geo[2][i]-1]
00069 +P[n][8]*coord[2][noeud_geo[3][i]-1]);
00070 fprintf(fp,"%f %f %f 1\n",x*1.e6,y*1.e6,z*1.e6);
00071
00072
00073
00074
00075
00076
00077
00078 }
00079 fclose(fp);
00080 }