//------------------------------------------------------------------------ unsigned long long pos2key(REAL xc, REAL yc, REAL zc,int level){ int ix,iy,iz; bitmask_t c[8*sizeof(bitmask_t)]; // integer coordinates of the oct unsigned long long keyloc; // we convert it in dxcoarse octs unit ix=(int)(xc/POW(0.5,level-1)); iy=(int)(yc/POW(0.5,level-1)); iz=(int)(zc/POW(0.5,level-1)); // we compute the keys of the lowest corners c[0]=ix; c[1]=iy; c[2]=iz; #ifndef TUBE keyloc=(unsigned long long)(hilbert_c2i(3,level,c)); #else #ifdef SED keyloc=(unsigned long long)(hilbert_c2i(3,level,c)); #else keyloc=(unsigned long long)(ix+iy*POW(2,level-1)+iz*POW(2,level-1)*POW(2,level-1)); #endif #endif return keyloc; }
//------------------------------------------------------------------------ void assigncpu2coarseoct(struct OCT *curoct, struct CPUINFO *cpu, int levelcoarse) { REAL xc,yc,zc; int ix,iy,iz; REAL dxcur; bitmask_t c[8*sizeof(bitmask_t)]; // integer coordinates of the oct unsigned long long keyloc; int cpuloc; if(curoct->level<=LCO){ curoct->cpu=0; } else{ xc=curoct->x; yc=curoct->y; zc=curoct->z; // we convert it in dxcoarse octs unit ix=(int)(xc/POW(0.5,levelcoarse-1)); iy=(int)(yc/POW(0.5,levelcoarse-1)); iz=(int)(zc/POW(0.5,levelcoarse-1)); // we compute the keys of the lowest corners c[0]=ix; c[1]=iy; c[2]=iz; #ifndef TUBE keyloc=(unsigned long long)(hilbert_c2i(3,levelcoarse,c)); #else #ifdef SED keyloc=(unsigned long long)(hilbert_c2i(3,levelcoarse,c)); #else keyloc=(unsigned long long)(ix+iy*POW(2,levelcoarse-1)+iz*POW(2,levelcoarse-1)*POW(2,levelcoarse-1)); #endif #endif cpuloc=keyloc/cpu->nkeys; curoct->cpu=(cpuloc>(cpu->nproc-1)?cpu->nproc-1:cpuloc); /* if(xc==0.53125) */ /* if(yc==0.53125) */ /* if(zc==0.53125){ */ /* printf("TESTO rank=%d\n",curoct->cpu); */ /* abort(); */ /* } */ } }
int segment_part(REAL xc,REAL yc,REAL zc, struct CPUINFO *cpu, int levelcoarse) { int ix,iy,iz; REAL dxcur; bitmask_t c[8*sizeof(bitmask_t)]; // integer coordinates of the oct unsigned long long keyloc; int cpuloc; // we convert it in dxcoarse octs unit ix=(int)(xc/POW(0.5,levelcoarse-1)); iy=(int)(yc/POW(0.5,levelcoarse-1)); iz=(int)(zc/POW(0.5,levelcoarse-1)); // we compute the keys of the lowest corners c[0]=ix; c[1]=iy; c[2]=iz; #ifndef TUBE keyloc=(unsigned long long)(hilbert_c2i(3,levelcoarse,c)); #else #ifdef SED keyloc=(unsigned long long)(hilbert_c2i(3,levelcoarse,c)); #else keyloc=(unsigned long long)(ix+iy*POW(2,levelcoarse-1)+iz*POW(2,levelcoarse-1)*POW(2,levelcoarse-1)); #endif #endif if((keyloc>=cpu->kmin)&&(keyloc<=cpu->kmax)){ return 1; } else{ return 0; } }
long int evalhilbert_(bitmask_t const disc[3], int *nbits, int *ndims) { return hilbert_c2i(*ndims ,*nbits, disc); }
int segment_cell(struct OCT *curoct, int icell, struct CPUINFO *cpu, int levelcoarse) { int res=-1; REAL xc,yc,zc; REAL xc0,yc0,zc0; int ix,iy,iz; int ii,jj,kk; int i,j,k; REAL dxcur; bitmask_t c[8*sizeof(bitmask_t)]; // integer coordinates of the oct char first=1; int max,min; unsigned long long keyloc; // First we compute the current cell position (lower left corner) // Note : this is equivalenet to the position of the next level oct dxcur=POW(0.5,curoct->level); xc0=curoct->x+( icell %2)*dxcur; yc0=curoct->y+((icell/2)%2)*dxcur; zc0=curoct->z+( icell/4 )*dxcur; //if(curoct->level==1) printf("--\n"); // we test the 27 cells centered around the current position for(ii=-1;ii<=1;ii++){ for(jj=-1;jj<=1;jj++){ for(kk=-1;kk<=1;kk++){ // offset the current cell (for neighbor search) xc=xc0+ii*dxcur; yc=yc0+jj*dxcur; zc=zc0+kk*dxcur; // Periodic boundary conditions if(xc<0.){ xc+=1.; } else if(xc>=1.){ xc-=1.; } if(yc<0.){ yc+=1.; } else if(yc>=1.){ yc-=1.; } if(zc<0.){ zc+=1.; } else if(zc>=1.){ zc-=1.; } // we convert it in dxcoarse unit ix=(int)(xc/POW(0.5,levelcoarse-1)); iy=(int)(yc/POW(0.5,levelcoarse-1)); iz=(int)(zc/POW(0.5,levelcoarse-1)); //if((curoct->level==1)) printf("--------------- %d %d %d\n",ix,iy,iz); // we compute the keys of the 8 corners and extract the min/max key first=1; for(i=0;i<2;i++){ for(j=0;j<2;j++){ for(k=0;k<2;k++){ c[0]=ix+(int)(i*POW(0.5,curoct->level-levelcoarse+1))-(i==1); c[1]=iy+(int)(j*POW(0.5,curoct->level-levelcoarse+1))-(j==1); c[2]=iz+(int)(k*POW(0.5,curoct->level-levelcoarse+1))-(k==1); #ifndef TUBE keyloc=(unsigned long long)(hilbert_c2i(3,levelcoarse,c)); #else #ifdef SED keyloc=(unsigned long long)(hilbert_c2i(3,levelcoarse,c)); #else keyloc=(unsigned long long)(c[0]+c[1]*POW(2,levelcoarse-1)+c[2]*POW(2,levelcoarse-1)*POW(2,levelcoarse-1)); #endif #endif //if((curoct->level==1)) printf("i=%d j=%d k=%d|| %d %d %d || %d || %d %d\n",i,j,k,(int)(c[0]),(int)(c[1]),(int)(c[2]),keyloc,cpu->kmin,cpu->kmax); if(first){ min=keyloc; max=keyloc; first=0; } else{ min=(min>keyloc?keyloc:min); max=(max<keyloc?keyloc:max); } } } } // we check if these keys intersect the cpu domain if((max<cpu->kmin)||(min>cpu->kmax)){ res=0; } else { res=1; } // No need to go furhter if the intersection exists if(res==1) break; } if(res==1) break; } if(res==1) break; } return res; }