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 // Created on : 09 june 2007, Siracusa, Jean Michel Sellier 00025 // Last modified : 16 september 2007, Siracusa, Jean Michel Sellier 00026 00027 // Here we construct the neighbourhood table which is done as follows 00028 // vois[i][j] = is the global number of the i-th neighbour, 0<=i<=3 (tetrahedra) 00029 // of the j-th element, 0<=j<=Ne-1. 00030 // By convention, we put vois[n][m]=-1 if the face opposed to n-th node of the 00031 // m-th element belongs to the frontier. 00032 00033 void neighbourhood_table(void) 00034 { 00035 int i,j,k,l,m; 00036 FILE *fp; 00037 00038 // open the output file on which we save the computed neighbourhood table 00039 fp=fopen("neighbourhood_table.dat","w"); 00040 if(fp==NULL){ 00041 printf("neighbourhood_table error : problem in saving the file!\n"); 00042 exit(0); 00043 } 00044 // at the beginning all the values are a negative number 00045 for(i=0;i<Ne;i++) for(j=0;j<4;j++) vois[j][i]=-10; 00046 00047 // neighbours search on every element 00048 for(i=0;i<Ne;i++){ 00049 int vertex[3]; 00050 // we store the 3 vertices of the i-th tetrahedra opposite to the j-th vertex 00051 for(j=0;j<4;j++){ 00052 if(vois[j][i]==-10){ // i.e. if this neighbourhoodness has never been found... 00053 // printf("%d ",i); 00054 if(j==0){ 00055 vertex[0]=noeud_geo[1][i]; 00056 vertex[1]=noeud_geo[2][i]; 00057 vertex[2]=noeud_geo[3][i]; 00058 } 00059 if(j==1){ 00060 vertex[0]=noeud_geo[0][i]; 00061 vertex[1]=noeud_geo[2][i]; 00062 vertex[2]=noeud_geo[3][i]; 00063 } 00064 if(j==2){ 00065 vertex[0]=noeud_geo[0][i]; 00066 vertex[1]=noeud_geo[1][i]; 00067 vertex[2]=noeud_geo[3][i]; 00068 } 00069 if(j==3){ 00070 vertex[0]=noeud_geo[0][i]; 00071 vertex[1]=noeud_geo[1][i]; 00072 vertex[2]=noeud_geo[2][i]; 00073 } 00074 int flag=0; 00075 for(k=0;k<Ne;k++){ 00076 int sum=0; 00077 int ten=10; // 10 = 1+2+3+4 00078 for(m=0;m<3;m++){ 00079 for(l=0;l<4;l++) 00080 if(vertex[m]==noeud_geo[l][k]){ 00081 sum++; 00082 // printf("k=%d i=%d sum=%d\n",k,i,sum); 00083 ten-=(l+1); 00084 } 00085 } // end of m-cycle 00086 if((sum==3) && (i!=k)){ 00087 vois[j][i]=k; 00088 vois[ten-1][k]=i; 00089 flag=1; 00090 // printf("i = %d j = %d k = %d ten = %d\n",i,j,k,ten-1); 00091 } 00092 } // end k-cycle 00093 if(flag==0) vois[j][i]=-1; 00094 } // end j-cycle 00095 } 00096 } 00097 // save the computed table in a file 00098 for(i=0;i<Ne;i++){ 00099 for(j=0;j<4;j++) fprintf(fp,"%d ",vois[j][i]); 00100 fprintf(fp,"\n"); 00101 } 00102 // close the output file 00103 fclose(fp); 00104 }