examples/tetrahedra_neighbours.c
/*----------------------------------------------------------------------------*/
/* Setup the missing links between tets that cross subdomains                 */
/*----------------------------------------------------------------------------*/
Setup the missing links between tets that cross subdomains
Setup the missing links between tets that cross subdomains
static void ParNgb2(int BegIdx, int EndIdx, int c, ParSct *par)
{
   int n, i, j, k, key, BasKey, flg, (*NgbTab)[4] = par[c].NgbTab;
   unsigned int min, mid, max;
   TetSct *tet, *ngb;
   HshSct *tab;
   MshSct *msh = par[c].msh;
   for(i=par[c].beg; i<=par[c].end; i++)
   {
      if(par[c].FlgTab[i] == 4)
         continue;
      tet = &msh->tet[i];
      for(j=0;j<4;j++)
      {
         if(NgbTab[i][j])
            continue;
         min = max = (j+1)%4;
         for(k=0;k<4;k++)
            if(k != j)
            {
               if(tet->idx[k] < tet->idx[ min ])
                  min = k;
               else if(tet->idx[k] > tet->idx[ max ])
                  max = k;
            }
         mid = 6 - min - max - j;
         flg = 0;
         BasKey = (3 * tet->idx[ min ] + 5 * tet->idx[ mid ] + 7 * tet->idx[ max ]) \
               % par[c].HshSiz;
         for(n=0; n<par[c].NmbCpu; n++)
         {
            if(n == c)
               continue;
            tab = par[n].tab;
            key = BasKey;
            do
            {
               ngb = &msh->tet[ tab[ key ].tet ];
               if( (ngb->idx[ (int)tab[ key ].min ] == tet->idx[ min ]) \
               &&  (ngb->idx[ (int)tab[ key ].mid ] == tet->idx[ mid ]) \
               &&  (ngb->idx[ (int)tab[ key ].max ] == tet->idx[ max ]) )
               {
                  NgbTab[i][j] = tab[ key ].tet;
                  flg = 1;
                  break;
               }
               if(tab[ key ].nex)
                  key = tab[ key ].nex;
               else
                  break;
            }while(1);
            if(flg)
               break;
         }
      }
   }
}
static void ParNgb2 ( int BegIdx , int EndIdx , int c , ParSct * par ) { int n , i , j , k , key , BasKey , flg , ( * NgbTab ) [ 4 ] = par [ c ] . NgbTab ; unsigned int min , mid , max ; TetSct * tet , * ngb ; HshSct * tab ; MshSct * msh = par [ c ] . msh ; for ( i = par [ c ] . beg ; i <= par [ c ] . end ; i ++ ) { if ( par [ c ] . FlgTab [ i ] == 4 ) continue ; tet = & msh -> tet [ i ] ; for ( j = 0 ; j < 4 ; j ++ ) { if ( NgbTab [ i ] [ j ] ) continue ; min = max = ( j + 1 ) % 4 ; for ( k = 0 ; k < 4 ; k ++ ) if ( k != j ) { if ( tet -> idx [ k ] < tet -> idx [ min ] ) min = k ; else if ( tet -> idx [ k ] > tet -> idx [ max ] ) max = k ; } mid = 6 - min - max - j ; flg = 0 ; BasKey = ( 3 * tet -> idx [ min ] + 5 * tet -> idx [ mid ] + 7 * tet -> idx [ max ] ) % par [ c ] . HshSiz ; for ( n = 0 ; n < par [ c ] . NmbCpu ; n ++ ) { if ( n == c ) continue ; tab = par [ n ] . tab ; key = BasKey ; do { ngb = & msh -> tet [ tab [ key ] . tet ] ; if ( ( ngb -> idx [ ( int ) tab [ key ] . min ] == tet -> idx [ min ] ) && ( ngb -> idx [ ( int ) tab [ key ] . mid ] == tet -> idx [ mid ] ) && ( ngb -> idx [ ( int ) tab [ key ] . max ] == tet -> idx [ max ] ) ) { NgbTab [ i ] [ j ] = tab [ key ] . tet ; flg = 1 ; break ; } if ( tab [ key ] . nex ) key = tab [ key ] . nex ; else break ; } while ( 1 ) ; if ( flg ) break ; } } } }
Setup the missing links between tets that cross subdomains
Setup the missing links between tets that cross subdomains
/* If a tetrahedron has already 4 links,
         there is no need to find a missing ones */ /* If there is no neighbour through this face,
            try to find on among other subdomains local hash tables */