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 00010 This program is free software; you can redistribute it and/or modify 00011 it under the terms of the GNU General Public License as published by 00012 the Free Software Foundation; either version 3, or (at your option) 00013 any later version. 00014 00015 This program is distributed in the hope that it will be useful, 00016 but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 GNU General Public License for more details. 00019 00020 You should have received a copy of the GNU General Public License 00021 along with this program. If not, see <http://www.gnu.org/licenses/>. 00022 */ 00023 00024 // Last modified : 16 september 2007, Siracusa, Jean Michel Sellier 00025 00026 // The input file unit is the micron 00027 00028 void load_mesh(char inp[]) 00029 { 00030 /* 00031 ============================================================================ 00032 Programmer : Jean Michel Sellier 00033 Creation : 07 Dic.2003, Paris, J.M.Sellier 00034 Purpose : Load the 3D mesh INRIA format file called "device.mesh" 00035 ============================================================================ 00036 */ 00037 00038 int i; 00039 int dum; 00040 00041 FILE *fp; 00042 00043 fp=fopen(inp,"r"); 00044 00045 // check the existence of the input file 00046 // ************************************* 00047 // if the file does not exist the code close the PETSc library and exit. 00048 if(fp==NULL){ 00049 printf("INPUT file 'device.mesh' does not exist\nexit\n"); 00050 exit(0); 00051 } 00052 00053 // ************************************************************* 00054 // Load 'device.mesh' and store the mesh in the correct arrays 00055 // ************************************************************* 00056 00057 // Read the number of vertices 00058 // *************************** 00059 /* The code skip two rows which have to be in the following format: 00060 MeshVersionFormatted 0 (or 1) 00061 Dimension 00062 3 00063 Vertices */ 00064 // Ng = number of vertices of the mesh (nombre total de noeuds du maillage) 00065 fscanf(fp,"%*s %*d %*s %*d %*s %d",&Ng); 00066 printf("Number of vertices = %d\n",Ng); 00067 00068 // allocation for i_front 00069 /* printf("Allocating memory for mesh arrays...\n"); 00070 i_front = malloc((Ng+1)*sizeof(int)); 00071 if(i_front==NULL){ 00072 printf("load_mesh : not enough memory for i_front allocation!\n"); 00073 exit(0); 00074 } 00075 for(i=0;i<3;i++){ 00076 coord[i] = malloc((Ng+1)*sizeof(double)); 00077 if(coord[i]==NULL){ 00078 printf("load_mesh : not enough memory for coord[%d] allocation!\n",i); 00079 exit(0); 00080 } 00081 }*/ 00082 // read the global coordinate of the mesh vertices and related reference number 00083 // **************************************************************************** 00084 // i_front[i] = reference number of the i-th vertex (nombre de reference du noeud) 00085 // This number = 0 if we are inside the device 00086 // '' != 0 if we are on the frontier 00087 // In this latter case this number makes one understand what 00088 // kind of boundary conditions one has to impose on that vertex. 00089 // coord[0][i] = global coordinate x of the i-th vertex (i=0..Ng-1) 00090 // coord[1][i] = global coordinate y of the i-th vertex 00091 // coord[2][i] = global coordinate z of the i-th vertex 00092 // French comment: 00093 // Pour k=0..dim-1 (dim = dimension de l'espace) et n=0..Ng-1, coord[k][n] est la k-ieme 00094 // coordonee du noeud de numero global n. 00095 00096 00097 for(i=0;i<Ng;i++){ 00098 fscanf(fp,"%lg %lg %lg %d",&coord[0][i],&coord[1][i],&coord[2][i],&i_front[i]); 00099 coord[0][i]*=1.e-6; 00100 coord[1][i]*=1.e-6; 00101 coord[2][i]*=1.e-6; 00102 00103 // printf("%2.20g %2.20g %2.20g %d\n",coord[0][i],coord[1][i],coord[2][i],i_front[i]); 00104 } 00105 00106 /* 00107 // Then we skip the informations about the triangles edges 00108 // ******************************************************* 00109 // The following skipped row has to be as follows: 00110 // Edges 00111 fscanf(fp,"%*s %d",&dum); 00112 // printf("%d\n",dum); 00113 for(i=1;i<=dum;i++) fscanf(fp,"%*d %*d %*d"); 00114 */ 00115 00116 // Then we skip the informations about the triangles 00117 // ************************************************* 00118 // (This gives us informations about the definition of triangles) 00119 // The skipped row has to be as follows: 00120 // Triangles 00121 fscanf(fp,"%*s %d",&dum); 00122 //printf("dum = %d\n",dum); 00123 // Allocate arrays and set values for **noeud_geo and *i_dom 00124 // PetscMalloc(Ne*sizeof(PetscInt),&i_dom); 00125 // PetscMalloc(ng,&noeud_geo); 00126 // for(i=0;i<ng;i++) PetscMalloc(Ne*sizeof(PetscInt),&noeud_geo[i]); 00127 for(i=0;i<dum;i++){ 00128 fscanf(fp,"%*d %*d %*d %*d\n"); 00129 // fscanf(fp,"%d %d %d %d\n",&noeud_geo[0][i],&noeud_geo[1][i],&noeud_geo[2][i],&i_dom[i]); 00130 // printf("%d %d %d %d %d\n",i,noeud_geo[0][i],noeud_geo[1][i],noeud_geo[2][i],i_dom[i]); 00131 } 00132 // Read informations about the various tetrahedra 00133 // ********************************************** 00134 // (this gives us informations about the definition of tetrahedra) 00135 // i_dom[i] = reference number of the i-th tetrahedra 00136 // noeud_geo[0][i] = global number of the first vertex in the i-th tetrahedra 00137 // noeud_geo[1][i] = global number of the second vertex in the i-th tetrahedra 00138 // noeud_geo[2][i] = global number of the third vertex in the i-th tetrahedra 00139 // noeud_geo[3][i] = global number of the fourth vertex in the i-th tetrahedra 00140 // The skipped row has to be as follows: 00141 // Tetrahedra 00142 fscanf(fp,"%*s %d",&Ne); 00143 printf("Number of elements (tetrahedra) = %d\n",Ne); 00144 00145 // allocations 00146 /* i_dom = malloc((Ne+1)*sizeof(int)); 00147 for(i=0;i<4;i++) noeud_geo[i] = malloc((Ne+1)*sizeof(int)); 00148 if(i_dom==NULL){ 00149 printf("load_mesh : not enough memory for i_front allocation!\n"); 00150 exit(0); 00151 }*/ 00152 00153 // Allocate arrays and set values for **noeud_geo and *i_dom 00154 // PetscMalloc(Ne*sizeof(PetscInt),&i_dom); 00155 // PetscMalloc(ng,&noeud_geo); 00156 // for(i=0;i<ng;i++) PetscMalloc(Ne*sizeof(PetscInt),&noeud_geo[i]); 00157 for(i=0;i<Ne;i++){ 00158 fscanf(fp,"%d %d %d %d %d",&noeud_geo[0][i],&noeud_geo[1][i], 00159 &noeud_geo[2][i],&noeud_geo[3][i],&i_dom[i]); 00160 // printf("%d %d %d %d %d %d\n",i,noeud_geo[0][i],noeud_geo[1][i], 00161 // noeud_geo[2][i],noeud_geo[3][i],i_dom[i]); 00162 } 00163 00164 fclose(fp); 00165 00166 // various dynamical allocations 00167 #include "../services/dynamical_allocations.h" 00168 }