void JelloMesh::GetCell(int idx, int& i, int &j, int& k) const { float rows = m_rows+1; float cols = m_cols+1; float stacks = m_stacks+1; // derived from idx = cols*(rows*k + i) + j float tmp = FLOOR(idx/cols); j = (int) ROUND(cols*(FRACT(idx/cols))); i = (int) ROUND(rows*(FRACT(tmp/rows))); k = (int) FLOOR(tmp/rows); }
void Init_Decomposition() { long factors[MAX_NUMPROC]; double processors,newfactor; long i,sq,cu,maxcu,count; /* figure out what to divide dimensions of image and volume by to */ /* partition data and computation to processors */ if (num_nodes == 1) { image_section[X] = 1; image_section[Y] = 1; voxel_section[X] = 1; voxel_section[Y] = 1; voxel_section[Z] = 1; } else { count = 1; processors = (double)num_nodes; sq = (long)sqrt(processors); cu = (long)pow(processors,1.0/3.0); factors[0] = 1; for (i=2; i<sq; i++) { if (FRACT(processors/(double)i) == 0.0) { factors[count++] = i; if (i <= cu) { maxcu = i; newfactor = (double)(num_nodes/i); } } } count--; image_section[X] = factors[count]; image_section[Y] = num_nodes/factors[count]; sq = (long)sqrt(newfactor); count = 1; for (i=2; i<sq; i++) { if (FRACT(newfactor/(double)i) == 0.0) factors[count++] = i; } count--; voxel_section[X] = MIN(factors[count],maxcu); voxel_section[Y] = MAX(factors[count],maxcu); voxel_section[Z] = (long)newfactor/factors[count]; } }