Main Page | Directories | File List | File Members

neighbourhood_table.h File Reference

Go to the source code of this file.

Functions

void neighbourhood_table (void)


Function Documentation

void neighbourhood_table void   ) 
 

Definition at line 33 of file neighbourhood_table.h.

References fp, Ne, noeud_geo, printf(), and vois.

Referenced by main().

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 }


© sourcejam.com 2005-2008