Main Page | Directories | File List | File Members

save_particles_mesh_format.h

Go to the documentation of this file.
00001 /*
00002    This file belongs to Aeneas. Aeneas is a GNU package released under GPL 3.
00003    This code is a simulator for Submicron 3D Semiconductor Devices. 
00004    It implements the Monte Carlo transport in 3D tetrahedra meshes
00005    for the simulation of the semiclassical Boltzmann equation for both electrons.
00006    It also includes all the relevant quantum effects for nanodevices.
00007 
00008    Copyright (C) 2007 Jean Michel Sellier <sellier@dmi.unict.it>
00009                                           <aeneas@southnovel.eu>
00010  
00011    This program is free software; you can redistribute it and/or modify
00012    it under the terms of the GNU General Public License as published by
00013    the Free Software Foundation; either version 3, or (at your option)
00014    any later version.
00015 
00016    This program is distributed in the hope that it will be useful,
00017    but WITHOUT ANY WARRANTY; without even the implied warranty of
00018    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019    GNU General Public License for more details.
00020 
00021    You should have received a copy of the GNU General Public License
00022    along with this program. If not, see <http://www.gnu.org/licenses/>.
00023 */
00024 
00025 // Created on : 11 june 2007, Siracusa, Jean Michel Sellier
00026 // Last modified : 16 september 2007, Siracusa, Jean Michel Sellier
00027 
00028 // save the position of all particles
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 // printf("INUM = %d\n",INUM);
00053  
00054  for(n=1;n<=INUM;n++){
00055 //        printf("n = %d\n",n);
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); // in micron
00071 /*if(z<-1.0){
00072   printf("n = %d\n",n);
00073   printf("%g %g %g %g\n",P[n][5],P[n][6],P[n][7],P[n][8]);
00074   printf("%f %f %f 1\n",x,y,z);  
00075 }*/
00076 //  if(n==10) printf("* %f %f %f\n",x,y,z);
00077 //  if(n==20) printf("# %f %f %f\n\n",x,y,z);
00078  }
00079  fclose(fp);    
00080 }

© sourcejam.com 2005-2008