106 if( ents.
empty() && dim == 3 )
113 if( !skip_local_merge )
132 for(
int skin_dim = dim; skin_dim >= 0; skin_dim-- )
153 MPI_Allreduce( (
void*)&box, gbox, 6, MPI_DOUBLE, MPI_MIN,
myPcomm->
comm() );
157 for(
int i = 3; i < 6; i++ )
182 return moab::MB_FAILURE;
186 std::vector< int > toProcs;
187 int xPart, yPart, zPart, xEps, yEps, zEps, baseProc;
188 unsigned long long tup_i = 0, tup_ul = 0, tup_r = 0, count = 0;
190 bool xDup, yDup, zDup;
200 xPart =
static_cast< int >( floor( ( x[count] - gbox[0] ) / lengths[0] ) );
201 xPart = ( xPart < parts[0] ? xPart : parts[0] - 1 );
203 yPart =
static_cast< int >( floor( ( y[count] - gbox[1] ) / lengths[1] ) );
204 yPart = ( yPart < parts[1] ? yPart : parts[1] - 1 );
206 zPart =
static_cast< int >( floor( ( z[count] - gbox[2] ) / lengths[2] ) );
207 zPart = ( zPart < parts[2] ? zPart : parts[2] - 1 );
210 xEps =
static_cast< int >( floor( ( x[count] - gbox[0] +
myEps ) / lengths[0] ) );
211 yEps =
static_cast< int >( floor( ( y[count] - gbox[1] +
myEps ) / lengths[1] ) );
212 zEps =
static_cast< int >( floor( ( z[count] - gbox[2] +
myEps ) / lengths[2] ) );
215 xDup = ( xPart != xEps && xEps < parts[0] );
216 yDup = ( yPart != yEps && yEps < parts[1] );
217 zDup = ( zPart != zEps && zEps < parts[2] );
220 baseProc = xPart + yPart * parts[0] + zPart * parts[0] * parts[1];
221 toProcs.push_back( baseProc );
224 toProcs.push_back( baseProc + 1 );
229 toProcs.push_back( baseProc + parts[0] );
234 toProcs.push_back( baseProc + parts[0] * parts[1] );
239 toProcs.push_back( baseProc + parts[0] + 1 );
244 toProcs.push_back( baseProc + parts[0] * parts[1] + 1 );
249 toProcs.push_back( baseProc + parts[0] * parts[1] + parts[0] );
251 if( xDup && yDup && zDup )
254 toProcs.push_back( baseProc + parts[0] * parts[1] + parts[0] + 1 );
263 for( std::vector< int >::iterator proc = toProcs.begin(); proc != toProcs.end(); ++proc )
286 double xLen = gbox[3] - gbox[0];
287 double yLen = gbox[4] - gbox[1];
288 double zLen = gbox[5] - gbox[2];
299 if( xLen >= yLen && xLen >= zLen )
301 parts[0] =
PartitionSide( xLen, yLen * zLen, numProcs,
true );
302 numProcs /= parts[0];
307 parts[2] = numProcs / parts[1];
313 parts[1] = numProcs / parts[2];
317 else if( yLen >= zLen )
319 parts[1] =
PartitionSide( yLen, xLen * zLen, numProcs,
true );
320 numProcs /= parts[1];
325 parts[2] = numProcs / parts[0];
331 parts[0] = numProcs / parts[2];
337 parts[2] =
PartitionSide( zLen, xLen * yLen, numProcs,
true );
338 numProcs /= parts[2];
343 parts[1] = numProcs / parts[0];
349 parts[0] = numProcs / parts[1];
354 lengths[0] = xLen / (double)parts[0];
355 lengths[1] = yLen / (double)parts[1];
356 lengths[2] = zLen / (double)parts[2];
369 double ratio = -DBL_MAX;
372 double oldRatio = ratio;
373 double oldFactor = 1;
376 double goalRatio = sideLen / restLen;
383 divisor = (double)numProcs * sideLen;
388 divisor = (double)numProcs;
393 for(
unsigned i = 2; i <= numProcs / 2; i++ )
396 if( numProcs % i == 0 )
408 ratio = pow( (
double)i, p ) / divisor;
412 if( ratio >= goalRatio )
419 if( ratio < goalRatio )
424 ratio = pow( (
double)numProcs, p ) / divisor;
428 if( fabs( ratio - goalRatio ) > fabs( oldRatio - goalRatio ) )
440 unsigned long i = 0, mat_i = 0, mat_ul = 0, j = 0, tup_r = 0;
443 uint tup_mi, tup_ml, tup_mul, tup_mr;
480 int kproc = i * tup_mi;
481 unsigned long khand = i * tup_mul;
482 for(
unsigned long k = i; k < j; k++ )
484 int lproc = kproc + tup_mi;
485 unsigned long lhand = khand + tup_mul;
486 for(
unsigned long l = k + 1; l < j; l++ )
540 proc_ents.
merge( tmp_ents );
546 proc_ents.
erase( lower, upper );
552 std::fill( sharing_procs.begin(), sharing_procs.end(), maxp );
555 std::map< std::vector< int >, std::vector< EntityHandle > > proc_nranges;
570 std::set< unsigned int > procs;
599 uint mi, ml, mul, mr;
611 uint mi, ml, mul, mr;
615 unsigned long a_val = a * mi, b_val = b * mi;
616 for(
unsigned long i = 0; i < mi; i++ )
620 tup.
vi_wr[b_val] = t;
627 for(
unsigned long i = 0; i < ml; i++ )
631 tup.
vl_wr[b_val] = t;
638 for(
unsigned long i = 0; i < mul; i++ )
649 for(
unsigned long i = 0; i < mr; i++ )
653 tup.
vr_wr[b_val] = t;
668 if( left + 1 >= right )
672 unsigned long swap = left, tup_l = left * tup_mr, tup_t = tup_l + tup_mr;
675 SwapTuples( tup, left, ( left + right ) / 2 );
678 for(
unsigned long t = left + 1; t < right; t++ )
705 while(
check < tup_mr )