25 int Intx2Mesh::dbg_1 = 0;
29 :
mb( mbimpl ), mbs1( 0 ), mbs2( 0 ), outSet( 0 ), gid( 0 ), TgtFlagTag( 0 ), tgtParentTag( 0 ), srcParentTag( 0 ),
30 countTag( 0 ), srcNeighTag( 0 ), tgtNeighTag( 0 ), neighTgtEdgeTag( 0 ), orgSendProcTag( 0 ), imaskTag( 0 ),
31 tgtConn( NULL ), srcConn( NULL ), epsilon_1( 0.0 ), epsilon_area( 0.0 ), box_error( 0.0 ), localRoot( 0 ),
35 parcomm( NULL ), remote_cells( NULL ), remote_cells_with_tracers( NULL )
38 max_edges_1( 0 ), max_edges_2( 0 ), counting( 0 )
67 if( nnodes > max_edges ) max_edges = nnodes;
74 int local_max_edges = max_edges;
77 MPI_Allreduce( &local_max_edges, &max_edges, 1, MPI_INT, MPI_MAX, parcomm->proc_config().proc_comm() );
78 if( MPI_SUCCESS != mpi_err )
return MB_FAILURE;
99 unsigned char def_data_bit = 0;
114 std::vector< EntityHandle >* nv =
new std::vector< EntityHandle >;
121 &defaultInt );
MB_CHK_SET_ERR( rval,
"can't create positive tag" );
124 &defaultInt );
MB_CHK_SET_ERR( rval,
"can't create negative tag" );
135 std::vector< EntityHandle > zeroh(
max_edges_2, 0 );
147 while(
tgtConn[num_nodes - 2] ==
tgtConn[num_nodes - 1] && num_nodes > 3 )
151 for( i = 0; i < num_nodes; i++ )
154 tgtConn[( i + 1 ) % num_nodes] };
155 std::vector< EntityHandle > adj_entities;
157 if( rval !=
MB_SUCCESS || adj_entities.size() < 1 )
return rval;
158 zeroh[i] = adj_entities[0];
173 std::vector< EntityHandle > neighbors( max_edges );
174 std::vector< EntityHandle > zeroh( max_edges, 0 );
189 while( conn4[nsides - 2] == conn4[nsides - 1] && nsides > 3 )
192 for(
int i = 0; i < nsides; i++ )
196 v[1] = conn4[( i + 1 ) % nsides];
198 std::vector< EntityHandle > adjcells;
199 std::vector< EntityHandle > cellsInSet;
203 size_t siz = adjcells.size();
204 for(
size_t j = 0; j < siz; j++ )
205 if(
mb->
contains_entities( inputSet, &( adjcells[j] ), 1 ) ) cellsInSet.push_back( adjcells[j] );
206 siz = cellsInSet.size();
210 std::cout <<
"non manifold mesh, error" <<
mb->
list_entities( &( cellsInSet[0] ), cellsInSet.size() )
223 if( cell == cellsInSet[0] )
224 neighbors[i] = cellsInSet[1];
226 neighbors[i] = cellsInSet[0];
229 for(
int i = nsides; i < max_edges; i++ )
267 std::vector< EntityHandle >* nv =
new std::vector< EntityHandle >;
274 &defaultInt );
MB_CHK_SET_ERR( rval,
"can't create positive tag" );
276 &defaultInt );
MB_CHK_SET_ERR( rval,
"can't create negative tag" );
284 std::vector< EntityHandle > zeroh(
max_edges_2, 0 );
294 while(
tgtConn[num_nodes - 2] ==
tgtConn[num_nodes - 1] && num_nodes > 3 )
297 for(
int i = 0; i < num_nodes; i++ )
300 tgtConn[( i + 1 ) % num_nodes] };
301 std::vector< EntityHandle > adj_entities;
303 if( rval !=
MB_SUCCESS || adj_entities.size() < 1 )
return rval;
304 zeroh[i] = adj_entities[0];
313 double max_length = 0;
315 std::vector< double > coords( 3 *
max_edges_1, 0.0 );
321 while( conn[nnodes - 2] == conn[nnodes - 1] && nnodes > 3 )
324 for(
int j = 0; j < nnodes; j++ )
326 int next = ( j + 1 ) % nnodes;
328 ( coords[3 * j] - coords[3 * next] ) * ( coords[3 * j] - coords[3 * next] ) +
329 ( coords[3 * j + 1] - coords[3 * next + 1] ) * ( coords[3 * j + 1] - coords[3 * next + 1] ) +
330 ( coords[3 * j + 2] - coords[3 * next + 2] ) * ( coords[3 * j + 2] - coords[3 * next + 2] );
334 max_length = std::sqrt( max_length );
339 if( max_length < 1. )
342 tolerance = 1. - sqrt( 1 - max_length * max_length / 4 );
349 std::cout <<
" max edge length: " << max_length <<
" tolerance for kd tree: " <<
tolerance <<
"\n";
350 std::cout <<
" box overlap tolerance: " <<
box_error <<
"\n";
356 MPI_Allreduce( &
box_error, &min_box_eps, 1, MPI_DOUBLE, MPI_MIN, parcomm->comm() );
362 FileOptions kdOpts(
"PLANE_SET=1;SPLITS_PER_DIR=2;SPHERICAL;RADIUS=1.0;" );
377 double recoveredArea = 0;
378 std::vector< double > positions;
379 positions.resize( nnodes * 3 );
384 for(
int k = 0; k < nnodes; k++ )
386 int ik = ( k + 1 ) % nnodes;
388 for(
int j = 0; j < 3; j++ )
390 double len2 = positions[3 * k + j] - positions[3 * ik + j];
393 av_len += sqrt( len1 );
395 if( nnodes > 0 ) av_len /= nnodes;
398 Range close_source_cells;
399 std::vector< EntityHandle > leaves;
400 for(
int i = 0; i < nnodes; i++ )
405 for( std::vector< EntityHandle >::iterator j = leaves.begin(); j != leaves.end(); ++j )
414 if( close_source_cells.
empty() )
416 std::cout <<
" there are no close source cells to target cell " << tcell <<
" id from handle "
437 recoveredArea += area;
440 recoveredArea = ( recoveredArea - areaTgtCell ) / areaTgtCell;
446 rval = resolve_intersection_sharing();
MB_CHK_SET_ERR( rval,
"can't correct position, Intx2Mesh.cpp \n" );
462 std::stringstream ffs, fft;
463 ffs <<
"source_rank0" <<
my_rank <<
".vtk";
465 fft <<
"target_rank0" <<
my_rank <<
".vtk";
495 FileOptions kdOpts(
"PLANE_SET=1;SPLITS_PER_DIR=2;SPHERICAL;RADIUS=1.0;" );
501 while( !rs22.
empty() )
503 #if defined( ENABLE_DEBUG ) || defined( VERBOSE )
506 std::cout <<
" possible not connected arrival mesh; my_rank: " <<
my_rank <<
" counting: " <<
counting
508 std::stringstream ffo;
513 bool seedFound =
false;
523 std::vector< double > positions;
524 positions.resize( nnodes * 3 );
529 Range close_source_cells;
530 std::vector< EntityHandle > leaves;
531 for(
int i = 0; i < nnodes; i++ )
536 for( std::vector< EntityHandle >::iterator j = leaves.begin(); j != leaves.end(); ++j )
568 #if defined( VERBOSE )
570 <<
" not intx with any source\n";
572 rs22.
erase( startTgt );
575 if( !seedFound )
continue;
577 std::queue< EntityHandle > srcQueue;
578 srcQueue.push( startSrc );
579 std::queue< EntityHandle > tgtQueue;
580 tgtQueue.push( startTgt );
586 unsigned char used = 1;
589 while( !tgtQueue.empty() )
600 double recoveredArea = 0;
608 std::cout <<
"Next: neighbors for current tgt ";
609 for(
int kk = 0; kk < nsidesTgt; kk++ )
611 if( tgtNeighbors[kk] > 0 )
614 std::cout << 0 <<
" ";
616 std::cout << std::endl;
621 for(
int j = 0; j < nsidesTgt; j++ )
624 unsigned char status = 1;
625 if( tgtNeigh == 0 )
continue;
627 if( 1 == status ) tgtNeighbors[j] = 0;
633 std::cout <<
"reset sources: ";
636 std::cout << std::endl;
648 toResetSrcs.
insert( currentSrc );
650 std::queue< EntityHandle > localSrc;
651 localSrc.push( currentSrc );
659 while( !localSrc.empty() )
683 for(
int k = 0; k < 3; k++ )
685 std::cout <<
" nb, nr: " << k <<
" " << nb[k] <<
" " <<
nr[k] <<
"\n";
695 std::cout <<
" can't get the neighbors for src element " <<
mb->
id_from_handle( srcT );
700 for(
int nn = 0; nn < nsidesSrc; nn++ )
703 if( neighbor > 0 && nb[nn] > 0 )
705 if( toResetSrcs.
find( neighbor ) == toResetSrcs.
end() )
707 localSrc.push( neighbor );
716 toResetSrcs.
insert( neighbor );
721 for(
int nn = 0; nn < nsidesTgt; nn++ )
723 if(
nr[nn] > 0 && tgtNeighbors[nn] > 0 )
724 nextSrc[nn].
insert( srcT );
732 recoveredArea += area;
737 std::cout <<
" tgt, src, do not intersect: " <<
mb->
id_from_handle( currentTgt ) <<
" "
742 recoveredArea = ( recoveredArea - areaTgtCell ) / areaTgtCell;
743 #if defined( ENABLE_DEBUG ) || defined( VERBOSE )
747 std::cout <<
" tgt area: " << areaTgtCell <<
" recovered :" << recoveredArea * ( 1 + areaTgtCell )
748 <<
" fraction error recovery:" << recoveredArea
749 <<
" tgtID: " <<
mb->
id_from_handle( currentTgt ) <<
" countingStart:" << countingStart
756 rs22.
erase( currentTgt );
759 for(
int j = 0; j < nsidesTgt; j++ )
762 if( tgtNeigh == 0 || nextSrc[j].
size() == 0 )
780 tgtNeigh, nextB, P, nP, area, nb,
nr, nsidesSrc, nsidesTgt2 );
MB_CHK_ERR( rval );
783 tgtQueue.push( tgtNeigh );
784 srcQueue.push( nextB );
787 std::cout <<
"new polys pushed: src, tgt:" <<
mb->
id_from_handle( tgtNeigh ) <<
" "
802 for(
int k = 0; k < 6; k++ )
810 rval = resolve_intersection_sharing();
MB_CHK_SET_ERR( rval,
"can't correct position, Intx2Mesh.cpp \n" );
820 size_t sz = cells.
size();
821 std::vector< int > masks( sz );
828 if( masks[indx] )
continue;
829 cellsToRemove.
insert( *eit );
831 cells =
subtract( cells, cellsToRemove );
859 int nextIndex = ( i + 1 ) % nP;
860 if( nodes[i] == nodes[nextIndex] )
866 std::cout <<
" nodes duplicated in list: ";
867 for(
int j = 0; j < nP; j++ )
868 std::cout << nodes[j] <<
" ";
870 std::cout <<
" node " << nodes[i] <<
" at index " << i <<
" is duplicated" <<
"\n";
876 for(
int k = i; k < nP - 1; k++ )
877 nodes[k] = nodes[k + 1];
893 if( gnomonic ) gnomonic =
false;
898 int num_local_verts = (int)local_verts.
size();
ERRORR( rval,
"can't get local vertices" );
900 assert( parcomm != NULL );
903 double bmin[3] = { std::numeric_limits< double >::max(), std::numeric_limits< double >::max(),
904 std::numeric_limits< double >::max() };
905 double bmax[3] = { -std::numeric_limits< double >::max(), -std::numeric_limits< double >::max(),
906 -std::numeric_limits< double >::max() };
908 std::vector< double > coords( 3 * num_local_verts );
909 rval =
mb->
get_coords( local_verts, &coords[0] );
ERRORR( rval,
"can't get coords of vertices " );
911 for(
int i = 0; i < num_local_verts; i++ )
913 for(
int k = 0; k < 3; k++ )
915 double val = coords[3 * i + k];
916 if( val < bmin[k] ) bmin[k] = val;
917 if( val > bmax[k] ) bmax[k] = val;
920 int numprocs = parcomm->proc_config().proc_size();
923 my_rank = parcomm->proc_config().proc_rank();
924 for(
int k = 0; k < 3; k++ )
932 #if( MPI_VERSION >= 2 )
934 mpi_err = MPI_Allgather( MPI_IN_PLACE, 0, MPI_DATATYPE_NULL, &
allBoxes[0], 6, MPI_DOUBLE,
935 parcomm->proc_config().proc_comm() );
938 std::vector< double > allBoxes_tmp( 6 * parcomm->proc_config().proc_size() );
939 mpi_err = MPI_Allgather( &
allBoxes[6 *
my_rank], 6, MPI_DOUBLE, &allBoxes_tmp[0], 6, MPI_DOUBLE,
940 parcomm->proc_config().proc_comm() );
944 if( MPI_SUCCESS != mpi_err )
return MB_FAILURE;
949 std::cout <<
" maximum number of vertices per cell are " <<
max_edges_1 <<
" on first mesh and " <<
max_edges_2
950 <<
" on second mesh \n";
951 for(
int i = 0; i < numprocs; i++ )
953 std::cout <<
"proc: " << i <<
" box min: " <<
allBoxes[6 * i] <<
" " <<
allBoxes[6 * i + 1] <<
" "
955 std::cout <<
" box max: " <<
allBoxes[6 * i + 3] <<
" " <<
allBoxes[6 * i + 4] <<
" "
967 assert( parcomm != NULL );
973 std::string tag_name(
"DP" );
982 int num_local_verts = (int)local_verts.size();
ERRORR( rval,
"can't get local vertices" );
984 rval = Intx2Mesh::build_processor_euler_boxes( euler_set, local_verts );
ERRORR( rval,
"can't build processor boxes" );
986 std::vector< int > gids( num_local_verts );
990 std::vector< double > dep_points( 3 * num_local_verts );
991 rval =
mb->
tag_get_data( dpTag, local_verts, (
void*)&dep_points[0] );
ERRORR( rval,
"can't get DP tag values" );
994 std::map< int, Range > Rto;
995 int numprocs = parcomm->proc_config().proc_size();
1003 CartVect qbmin( std::numeric_limits< double >::max() );
1004 CartVect qbmax( -std::numeric_limits< double >::max() );
1005 for(
int i = 0; i < num_nodes; i++ )
1008 size_t index = local_verts.find( v ) - local_verts.begin();
1009 CartVect dp( &dep_points[3 * index] );
1010 for(
int j = 0; j < 3; j++ )
1012 if( qbmin[j] > dp[j] ) qbmin[j] = dp[j];
1013 if( qbmax[j] < dp[j] ) qbmax[j] = dp[j];
1016 for(
int p = 0; p < numprocs; p++ )
1018 CartVect bbmin( &
allBoxes[6 * p] );
1019 CartVect bbmax( &
allBoxes[6 * p + 3] );
1030 for(
int p = 0; p < numprocs; p++ )
1032 if( p == (
int)
my_rank )
continue;
1033 Range& range_to_P = Rto[p];
1035 if( range_to_P.empty() )
continue;
1038 numq = numq + range_to_P.size();
1039 numv = numv + vertsToP.size();
1040 range_to_P.merge( vertsToP );
1044 TLv.initialize( 2, 0, 0, 3, numv );
1045 TLv.enableWriteAccess();
1050 TLq.enableWriteAccess();
1052 std::cout <<
"from proc " <<
my_rank <<
" send " << numv <<
" vertices and " << numq <<
" elements\n";
1054 for(
int to_proc = 0; to_proc < numprocs; to_proc++ )
1056 if( to_proc == (
int)
my_rank )
continue;
1057 Range& range_to_P = Rto[to_proc];
1058 Range V = range_to_P.subset_by_type(
MBVERTEX );
1063 unsigned int index = local_verts.find( v ) - local_verts.begin();
1064 int n = TLv.get_n();
1065 TLv.vi_wr[2 * n] = to_proc;
1066 TLv.vi_wr[2 * n + 1] = gids[index];
1067 TLv.vr_wr[3 * n] = dep_points[3 * index];
1068 TLv.vr_wr[3 * n + 1] = dep_points[3 * index + 1];
1069 TLv.vr_wr[3 * n + 2] = dep_points[3 * index + 2];
1073 Range Q = range_to_P.subset_by_dimension( 2 );
1079 int n = TLq.get_n();
1080 TLq.vi_wr[sizeTuple * n] = to_proc;
1081 TLq.vi_wr[sizeTuple * n + 1] = global_id;
1086 ERRORR( rval,
"can't get connectivity for cell" );
1087 if( num_nodes >
MAXEDGES )
ERRORR( MB_FAILURE,
"too many nodes in a polygon" );
1088 for(
int i = 0; i < num_nodes; i++ )
1091 unsigned int index = local_verts.find( v ) - local_verts.begin();
1092 TLq.vi_wr[sizeTuple * n + 2 + i] = gids[index];
1096 TLq.vi_wr[sizeTuple * n + 2 + k] =
1106 ( parcomm->proc_config().crystal_router() )->gs_transfer( 1, TLv, 0 );
1107 ( parcomm->proc_config().crystal_router() )->gs_transfer( 1, TLq, 0 );
1111 std::map< int, EntityHandle > globalID_to_handle;
1113 globalID_to_eh.clear();
1115 int n = TLv.get_n();
1116 for(
int i = 0; i < n; i++ )
1118 int globalId = TLv.vi_rd[2 * i + 1];
1119 if( globalID_to_handle.find( globalId ) == globalID_to_handle.end() )
1122 double dp_pos[3] = { TLv.vr_wr[3 * i], TLv.vr_wr[3 * i + 1], TLv.vr_wr[3 * i + 2] };
1124 globalID_to_handle[globalId] = new_vert;
1132 Range local_q = local.subset_by_dimension( 2 );
1134 for(
Range::iterator it = local_q.begin(); it != local_q.end(); ++it )
1141 for(
int i = 0; i < nnodes; i++ )
1144 unsigned int index = local_verts.find( v1 ) - local_verts.begin();
1145 int globalId = gids[index];
1146 if( globalID_to_handle.find( globalId ) == globalID_to_handle.end() )
1149 double dp_pos[3] = { dep_points[3 * index], dep_points[3 * index + 1], dep_points[3 * index + 2] };
1152 globalID_to_handle[globalId] = new_vert;
1154 new_conn[i] = globalID_to_handle[gids[index]];
1158 EntityType entType =
MBQUAD;
1160 if( nnodes < 4 ) entType =
MBTRI;
1162 rval =
mb->
create_element( entType, new_conn, nnodes, new_element );
ERRORR( rval,
"can't create new quad " );
1163 rval =
mb->
add_entities( covering_lagr_set, &new_element, 1 );
ERRORR( rval,
"can't add new element to dep set" );
1167 globalID_to_eh[gid_el] = new_element;
1169 rval =
mb->
tag_set_data( corrTag, &new_element, 1, &q );
ERRORR( rval,
"can't set corr tag on new el" );
1176 remote_cells =
new TupleList();
1177 remote_cells->initialize( 2, 0, 1, 0, n );
1178 remote_cells->enableWriteAccess();
1179 for(
int i = 0; i < n; i++ )
1181 int globalIdEl = TLq.vi_rd[sizeTuple * i + 1];
1182 int from_proc = TLq.vi_wr[sizeTuple * i];
1184 if( globalID_to_eh.find( globalIdEl ) == globalID_to_eh.end() )
1191 int vgid = TLq.vi_rd[sizeTuple * i + 2 + j];
1196 assert( globalID_to_handle.find( vgid ) != globalID_to_handle.end() );
1197 new_conn[j] = globalID_to_handle[vgid];
1203 EntityType entType =
MBQUAD;
1205 if( nnodes < 4 ) entType =
MBTRI;
1206 rval =
mb->
create_element( entType, new_conn, nnodes, new_element );
ERRORR( rval,
"can't create new element " );
1207 globalID_to_eh[globalIdEl] = new_element;
1208 rval =
mb->
add_entities( covering_lagr_set, &new_element, 1 );
ERRORR( rval,
"can't add new element to dep set" );
1210 remote_cells->vi_wr[2 * i] = from_proc;
1211 remote_cells->vi_wr[2 * i + 1] = globalIdEl;
1213 remote_cells->vul_wr[i] = TLq.vul_rd[i];
1214 remote_cells->inc_n();
1216 rval =
mb->
tag_set_data(
gid, &new_element, 1, &globalIdEl );
ERRORR( rval,
"can't set global id tag on new el" );
1222 sort_buffer.buffer_init( n );
1223 remote_cells->sort( 1, &sort_buffer );
1224 sort_buffer.
reset();
1241 assert( parcomm != NULL );
1242 if( 1 == parcomm->proc_config().proc_size() )
1244 covering_set = lagr_set;
1251 int num_local_verts = (int)local_verts.size();
ERRORR( rval,
"can't get local vertices" );
1253 std::vector< int > gids( num_local_verts );
1256 Range localDepCells;
1263 int num_lagr_verts = (int)lagr_verts.size();
ERRORR( rval,
"can't get local lagr vertices" );
1266 std::vector< double > dep_points( 3 * num_lagr_verts );
1267 rval =
mb->
get_coords( lagr_verts, &dep_points[0] );
ERRORR( rval,
"can't get departure points position" );
1270 std::map< int, Range > Rto;
1271 int numprocs = parcomm->proc_config().proc_size();
1273 for(
Range::iterator eit = localDepCells.begin(); eit != localDepCells.end(); ++eit )
1279 CartVect qbmin( std::numeric_limits< double >::max() );
1280 CartVect qbmax( -std::numeric_limits< double >::max() );
1281 for(
int i = 0; i < num_nodes; i++ )
1284 int index = lagr_verts.index( v );
1285 assert( -1 != index );
1286 CartVect dp( &dep_points[3 * index] );
1287 for(
int j = 0; j < 3; j++ )
1289 if( qbmin[j] > dp[j] ) qbmin[j] = dp[j];
1290 if( qbmax[j] < dp[j] ) qbmax[j] = dp[j];
1293 for(
int p = 0; p < numprocs; p++ )
1295 CartVect bbmin( &
allBoxes[6 * p] );
1296 CartVect bbmax( &
allBoxes[6 * p + 3] );
1307 for(
int p = 0; p < numprocs; p++ )
1309 if( p == (
int)
my_rank )
continue;
1310 Range& range_to_P = Rto[p];
1312 if( range_to_P.empty() )
continue;
1315 numq = numq + range_to_P.size();
1316 numv = numv + vertsToP.size();
1317 range_to_P.merge( vertsToP );
1321 TLv.initialize( 2, 0, 0, 3, numv );
1322 TLv.enableWriteAccess();
1328 TLq.enableWriteAccess();
1330 std::cout <<
"from proc " <<
my_rank <<
" send " << numv <<
" vertices and " << numq <<
" elements\n";
1333 for(
int to_proc = 0; to_proc < numprocs; to_proc++ )
1335 if( to_proc == (
int)
my_rank )
continue;
1336 Range& range_to_P = Rto[to_proc];
1337 Range V = range_to_P.subset_by_type(
MBVERTEX );
1342 int index = lagr_verts.index( v );
1343 assert( -1 != index );
1344 int n = TLv.get_n();
1345 TLv.vi_wr[2 * n] = to_proc;
1346 TLv.vi_wr[2 * n + 1] = gids[index];
1347 TLv.vr_wr[3 * n] = dep_points[3 * index];
1348 TLv.vr_wr[3 * n + 1] = dep_points[3 * index + 1];
1349 TLv.vr_wr[3 * n + 2] = dep_points[3 * index + 2];
1353 Range Q = range_to_P.subset_by_dimension( 2 );
1359 int n = TLq.get_n();
1360 TLq.vi_wr[sizeTuple * n] = to_proc;
1361 TLq.vi_wr[sizeTuple * n + 1] = global_id;
1365 q, conn4, num_nodes );
1366 if( num_nodes >
MAXEDGES )
ERRORR( MB_FAILURE,
"too many nodes in a polygon" );
1367 for(
int i = 0; i < num_nodes; i++ )
1370 int index = lagr_verts.index( v );
1371 assert( -1 != index );
1372 TLq.vi_wr[sizeTuple * n + 2 + i] = gids[index];
1376 TLq.vi_wr[sizeTuple * n + 2 + k] =
1380 rval =
mb->
tag_get_data( corrTag, &q, 1, &tgtCell );
ERRORR( rval,
"can't get corresponding tgt cell for dep cell" );
1381 TLq.vul_wr[n] = tgtCell;
1387 ( parcomm->proc_config().crystal_router() )->gs_transfer( 1, TLv, 0 );
1388 ( parcomm->proc_config().crystal_router() )->gs_transfer( 1, TLq, 0 );
1392 std::map< int, EntityHandle > globalID_to_handle;
1396 for(
Range::iterator vit = lagr_verts.begin(); vit != lagr_verts.end(); ++vit, k++ )
1398 globalID_to_handle[gids[k]] = *vit;
1402 globalID_to_eh.clear();
1404 int n = TLv.get_n();
1405 for(
int i = 0; i < n; i++ )
1407 int globalId = TLv.vi_rd[2 * i + 1];
1408 if( globalID_to_handle.find( globalId ) == globalID_to_handle.end() )
1411 double dp_pos[3] = { TLv.vr_wr[3 * i], TLv.vr_wr[3 * i + 1], TLv.vr_wr[3 * i + 2] };
1413 globalID_to_handle[globalId] = new_vert;
1421 Range local_q = local.subset_by_dimension( 2 );
1423 for(
Range::iterator it = local_q.begin(); it != local_q.end(); ++it )
1428 globalID_to_eh[gid_el] = q;
1436 remote_cells =
new TupleList();
1437 remote_cells->initialize( 2, 0, 1, 0, n );
1438 remote_cells->enableWriteAccess();
1439 for(
int i = 0; i < n; i++ )
1441 int globalIdEl = TLq.vi_rd[sizeTuple * i + 1];
1442 int from_proc = TLq.vi_rd[sizeTuple * i];
1444 if( globalID_to_eh.find( globalIdEl ) == globalID_to_eh.end() )
1451 int vgid = TLq.vi_rd[sizeTuple * i + 2 + j];
1456 assert( globalID_to_handle.find( vgid ) != globalID_to_handle.end() );
1457 new_conn[j] = globalID_to_handle[vgid];
1463 EntityType entType =
MBQUAD;
1465 if( nnodes < 4 ) entType =
MBTRI;
1466 rval =
mb->
create_element( entType, new_conn, nnodes, new_element );
ERRORR( rval,
"can't create new element " );
1467 globalID_to_eh[globalIdEl] = new_element;
1468 local_q.insert( new_element );
1471 remote_cells->vi_wr[2 * i] = from_proc;
1472 remote_cells->vi_wr[2 * i + 1] = globalIdEl;
1474 remote_cells->vul_wr[i] = TLq.vul_rd[i];
1475 remote_cells->inc_n();
1479 rval =
mb->
add_entities( covering_set, local_q );
ERRORR( rval,
"can't add entities to new mesh set " );
1483 sort_buffer.buffer_init( n );
1484 remote_cells->sort( 1, &sort_buffer );
1485 sort_buffer.
reset();
1490 ErrorCode Intx2Mesh::resolve_intersection_sharing()
1492 if( parcomm && parcomm->size() > 1 )
1502 Range nonOwnedVerts;
1518 Range vertsCovInterface;
1521 Range nodesToDuplicate =
intersect( vertsCovInterface, nonOwnedVerts );
1524 Range connectedCells;
1527 connectedCells =
intersect( connectedCells, intxCells );
1529 std::map< EntityHandle, EntityHandle > duplicatedVerticesMap;
1530 for(
Range::iterator vit = nodesToDuplicate.begin(); vit != nodesToDuplicate.end(); vit++ )
1537 duplicatedVerticesMap[
vertex] = newVertex;
1541 for(
Range::iterator eit = connectedCells.begin(); eit != connectedCells.end(); eit++ )
1545 std::vector< EntityHandle > connectivity;
1547 for(
size_t i = 0; i < connectivity.size(); i++ )
1550 std::map< EntityHandle, EntityHandle >::iterator mit = duplicatedVerticesMap.find( currentVertex );
1551 if( mit != duplicatedVerticesMap.end() )
1553 connectivity[i] = mit->second;
1556 int nnodes = (int)connectivity.size();