16 static bool debug =
false;
19 : mbImpl( impl ), myElems( elems ), myDim( -1 ), myTree( tree ), elemEval( eval ), iCreatedTree( false ),
20 timerInitialized( false )
67 if( !pc )
return MB_FAILURE;
81 int mpi_err = MPI_Allreduce( sendbuffer, rcvbuffer, 6, MPI_DOUBLE, MPI_MAX, MPI_COMM_WORLD );
82 if( MPI_SUCCESS != mpi_err )
return MB_FAILURE;
96 double mfactor = pow( 10.0, 6 - lg );
97 int ldims[6], lper[3];
100 for(
int i = 0; i < 6; i++ )
101 spd.
gDims[i] = dgijk[i] * mfactor;
106 for(
int i = 0; i < 3; i++ )
114 ErrorCode SpatialLocator::register_src_with_intermediate_procs( ParallelComm* pc,
122 ErrorCode rval = get_point_ijk(
localBox.
bMin - CartVect( abs_iter_tol ), abs_iter_tol, corner_ijk );
124 rval = get_point_ijk(
localBox.
bMax + CartVect( abs_iter_tol ), abs_iter_tol, corner_ijk + 3 );
129 TLreg_o.initialize( 1, 0, 0, 6, 0 );
138 for(
int k = corner_ijk[2]; k <= corner_ijk[5]; k++ )
140 for(
int j = corner_ijk[1]; j <= corner_ijk[4]; j++ )
142 for(
int i = corner_ijk[0]; i <= corner_ijk[3]; i++ )
145 TLreg_o.push_back( &dest, NULL, NULL, boxtosend );
152 if( pc ) pc->proc_config().crystal_router()->gs_transfer( 1, TLreg_o, 0 );
159 int NN = TLreg_o.get_n();
160 for(
int i = 0; i < NN; i++ )
162 srcProcBoxes[TLreg_o.vi_rd[i]] = BoundBox( TLreg_o.vr_rd + 6 * i );
167 ErrorCode SpatialLocator::par_locate_points( ParallelComm* ,
181 ErrorCode SpatialLocator::par_locate_points( ParallelComm* pc,
184 const double rel_iter_tol,
185 const double abs_iter_tol,
186 const double inside_tol )
192 TupleList TLforward_o;
193 TupleList TLsearch_results_o;
200 rval = initialize_intermediate_partition( pc );
204 rval = register_src_with_intermediate_procs( pc, abs_iter_tol, TLreg_o );
217 unsigned int my_rank = ( pc ? pc->proc_config().proc_rank() : 0 );
225 TLquery_o.initialize( 3, 0, 0, 3, 0 );
229 for(
int pnt = 0; pnt < 3 * num_points; pnt += 3 )
232 proc_from_point( pos + pnt, abs_iter_tol );
238 TLquery_o.push_back( iargs, NULL, NULL,
const_cast< double*
>( pos + pnt ) );
242 if( pc ) pc->proc_config().crystal_router()->gs_transfer( 1, TLquery_o, 0 );
252 TLforward_o.initialize( 3, 0, 0, 3, 0 );
254 int NN = TLquery_o.get_n();
256 for(
int i = 0; i < NN; i++ )
258 iargs[1] = TLquery_o.vi_rd[3 * i + 1];
259 iargs[2] = TLquery_o.vi_rd[3 * i + 2];
260 CartVect tmp_pnt( TLquery_o.vr_rd + 3 * i );
265 if( ( *mit ).second.contains_point( tmp_pnt.array(), abs_iter_tol ) )
267 iargs[0] = ( *mit ).first;
268 TLforward_o.push_back( iargs, NULL, NULL, tmp_pnt.array() );
275 if( pc ) pc->proc_config().crystal_router()->gs_transfer( 1, TLforward_o, 0 );
288 NN = TLforward_o.get_n();
292 TLsearch_results_o.initialize( 3, 0, 0, 0, 0 );
296 std::vector< double > params( 3 * NN );
297 std::vector< int > is_inside( NN, 0 );
298 std::vector< EntityHandle > ents( NN, 0 );
300 rval =
locate_points( TLforward_o.vr_rd, TLforward_o.get_n(), &ents[0], ¶ms[0], &is_inside[0], rel_iter_tol,
301 abs_iter_tol, inside_tol );
306 for(
int i = 0; i < NN; i++ )
310 iargs[0] = TLforward_o.vi_rd[3 * i + 1];
311 iargs[1] = TLforward_o.vi_rd[3 * i + 2];
313 TLsearch_results_o.push_back( iargs, NULL, NULL, NULL );
315 sint forward = (
sint)TLforward_o.vi_rd[3 * i + 1];
325 if( pc ) pc->proc_config().crystal_router()->gs_transfer( 1, TLsearch_results_o, 0 );
334 for(
unsigned int i = 0; i < TLsearch_results_o.get_n(); i++ )
336 int idx = TLsearch_results_o.vi_rd[3 * i + 1];
345 std::cout <<
"Points found = " << num_found <<
"/" << num_points <<
" ("
346 << 100.0 * ( (double)num_found / num_points ) <<
"%)" << std::endl;
357 const double rel_iter_tol,
358 const double abs_iter_tol,
359 const double inside_tol )
361 bool i_initialized =
false;
366 i_initialized =
true;
370 std::vector< double > pos( 3 * verts.
size() );
373 rval =
locate_points( &pos[0], verts.
size(), rel_iter_tol, abs_iter_tol, inside_tol );
384 const double rel_iter_tol,
385 const double abs_iter_tol,
386 const double inside_tol )
388 bool i_initialized =
false;
393 i_initialized =
true;
401 abs_iter_tol, inside_tol );
416 const double rel_iter_tol,
417 const double abs_iter_tol,
418 const double inside_tol )
420 bool i_initialized =
false;
425 i_initialized =
true;
429 std::vector< double > pos( 3 * verts.
size() );
432 rval =
locate_points( &pos[0], verts.
size(), ents, params, is_inside, rel_iter_tol, abs_iter_tol, inside_tol );
446 const double abs_iter_tol,
447 const double inside_tol )
449 bool i_initialized =
false;
454 i_initialized =
true;
468 for(
int i = 0; i < num_points; i++ )
479 if(
debug && !ents[i] )
481 std::cout <<
"Point " << i <<
" not found; point: (" << pos[i3] <<
"," << pos[i3 + 1] <<
"," << pos[i3 + 2]
485 if( is_inside ) is_inside[i] = ( ents[i] ? true : false );