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() )
211 <<
"\n";
MB_CHK_SET_ERR( MB_FAILURE,
"non-manifold input mesh set" );
222 if( cell == cellsInSet[0] )
223 neighbors[i] = cellsInSet[1];
225 neighbors[i] = cellsInSet[0];
228 for(
int i = nsides; i < max_edges; i++ )
266 std::vector< EntityHandle >* nv =
new std::vector< EntityHandle >;
272 &defaultInt );
MB_CHK_SET_ERR( rval,
"can't create positive tag" );
275 &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"
877 for(
int k = i; k < nP - 1; k++ )
878 nodes[k] = nodes[k + 1];
894 if( gnomonic ) gnomonic =
false;
899 int num_local_verts = (int)local_verts.
size();
ERRORR( rval,
"can't get local vertices" );
901 assert( parcomm != NULL );
904 double bmin[3] = { std::numeric_limits<double>::max(), std::numeric_limits<double>::max(), std::numeric_limits<double>::max() };
905 double bmax[3] = { -std::numeric_limits<double>::max(), -std::numeric_limits<double>::max(), -std::numeric_limits<double>::max() };
907 std::vector< double > coords( 3 * num_local_verts );
908 rval =
mb->
get_coords( local_verts, &coords[0] );
ERRORR( rval,
"can't get coords of vertices " );
910 for(
int i = 0; i < num_local_verts; i++ )
912 for(
int k = 0; k < 3; k++ )
914 double val = coords[3 * i + k];
915 if( val < bmin[k] ) bmin[k] = val;
916 if( val > bmax[k] ) bmax[k] = val;
919 int numprocs = parcomm->proc_config().proc_size();
922 my_rank = parcomm->proc_config().proc_rank();
923 for(
int k = 0; k < 3; k++ )
931 #if( MPI_VERSION >= 2 )
933 mpi_err = MPI_Allgather( MPI_IN_PLACE, 0, MPI_DATATYPE_NULL, &
allBoxes[0], 6, MPI_DOUBLE,
934 parcomm->proc_config().proc_comm() );
937 std::vector< double > allBoxes_tmp( 6 * parcomm->proc_config().proc_size() );
938 mpi_err = MPI_Allgather( &
allBoxes[6 *
my_rank], 6, MPI_DOUBLE, &allBoxes_tmp[0], 6, MPI_DOUBLE,
939 parcomm->proc_config().proc_comm() );
943 if( MPI_SUCCESS != mpi_err )
return MB_FAILURE;
948 std::cout <<
" maximum number of vertices per cell are " <<
max_edges_1 <<
" on first mesh and " <<
max_edges_2
949 <<
" on second mesh \n";
950 for(
int i = 0; i < numprocs; i++ )
952 std::cout <<
"proc: " << i <<
" box min: " <<
allBoxes[6 * i] <<
" " <<
allBoxes[6 * i + 1] <<
" "
954 std::cout <<
" box max: " <<
allBoxes[6 * i + 3] <<
" " <<
allBoxes[6 * i + 4] <<
" "
966 assert( parcomm != NULL );
972 std::string tag_name(
"DP" );
981 int num_local_verts = (int)local_verts.size();
ERRORR( rval,
"can't get local vertices" );
983 rval = Intx2Mesh::build_processor_euler_boxes( euler_set, local_verts );
ERRORR( rval,
"can't build processor boxes" );
985 std::vector< int > gids( num_local_verts );
989 std::vector< double > dep_points( 3 * num_local_verts );
990 rval =
mb->
tag_get_data( dpTag, local_verts, (
void*)&dep_points[0] );
ERRORR( rval,
"can't get DP tag values" );
993 std::map< int, Range > Rto;
994 int numprocs = parcomm->proc_config().proc_size();
1002 CartVect qbmin( std::numeric_limits<double>::max() );
1003 CartVect qbmax( -std::numeric_limits<double>::max() );
1004 for(
int i = 0; i < num_nodes; i++ )
1007 size_t index = local_verts.find( v ) - local_verts.begin();
1008 CartVect dp( &dep_points[3 * index] );
1009 for(
int j = 0; j < 3; j++ )
1011 if( qbmin[j] > dp[j] ) qbmin[j] = dp[j];
1012 if( qbmax[j] < dp[j] ) qbmax[j] = dp[j];
1015 for(
int p = 0; p < numprocs; p++ )
1017 CartVect bbmin( &
allBoxes[6 * p] );
1018 CartVect bbmax( &
allBoxes[6 * p + 3] );
1029 for(
int p = 0; p < numprocs; p++ )
1031 if( p == (
int)
my_rank )
continue;
1032 Range& range_to_P = Rto[p];
1034 if( range_to_P.empty() )
continue;
1037 numq = numq + range_to_P.size();
1038 numv = numv + vertsToP.size();
1039 range_to_P.merge( vertsToP );
1043 TLv.initialize( 2, 0, 0, 3, numv );
1044 TLv.enableWriteAccess();
1049 TLq.enableWriteAccess();
1051 std::cout <<
"from proc " <<
my_rank <<
" send " << numv <<
" vertices and " << numq <<
" elements\n";
1053 for(
int to_proc = 0; to_proc < numprocs; to_proc++ )
1055 if( to_proc == (
int)
my_rank )
continue;
1056 Range& range_to_P = Rto[to_proc];
1057 Range V = range_to_P.subset_by_type(
MBVERTEX );
1062 unsigned int index = local_verts.find( v ) - local_verts.begin();
1063 int n = TLv.get_n();
1064 TLv.vi_wr[2 * n] = to_proc;
1065 TLv.vi_wr[2 * n + 1] = gids[index];
1066 TLv.vr_wr[3 * n] = dep_points[3 * index];
1067 TLv.vr_wr[3 * n + 1] = dep_points[3 * index + 1];
1068 TLv.vr_wr[3 * n + 2] = dep_points[3 * index + 2];
1072 Range Q = range_to_P.subset_by_dimension( 2 );
1078 int n = TLq.get_n();
1079 TLq.vi_wr[sizeTuple * n] = to_proc;
1080 TLq.vi_wr[sizeTuple * n + 1] = global_id;
1085 ERRORR( rval,
"can't get connectivity for cell" );
1086 if( num_nodes >
MAXEDGES )
ERRORR( MB_FAILURE,
"too many nodes in a polygon" );
1087 for(
int i = 0; i < num_nodes; i++ )
1090 unsigned int index = local_verts.find( v ) - local_verts.begin();
1091 TLq.vi_wr[sizeTuple * n + 2 + i] = gids[index];
1095 TLq.vi_wr[sizeTuple * n + 2 + k] =
1105 ( parcomm->proc_config().crystal_router() )->gs_transfer( 1, TLv, 0 );
1106 ( parcomm->proc_config().crystal_router() )->gs_transfer( 1, TLq, 0 );
1110 std::map< int, EntityHandle > globalID_to_handle;
1112 globalID_to_eh.clear();
1114 int n = TLv.get_n();
1115 for(
int i = 0; i < n; i++ )
1117 int globalId = TLv.vi_rd[2 * i + 1];
1118 if( globalID_to_handle.find( globalId ) == globalID_to_handle.end() )
1121 double dp_pos[3] = { TLv.vr_wr[3 * i], TLv.vr_wr[3 * i + 1], TLv.vr_wr[3 * i + 2] };
1123 globalID_to_handle[globalId] = new_vert;
1131 Range local_q = local.subset_by_dimension( 2 );
1133 for(
Range::iterator it = local_q.begin(); it != local_q.end(); ++it )
1140 for(
int i = 0; i < nnodes; i++ )
1143 unsigned int index = local_verts.find( v1 ) - local_verts.begin();
1144 int globalId = gids[index];
1145 if( globalID_to_handle.find( globalId ) == globalID_to_handle.end() )
1148 double dp_pos[3] = { dep_points[3 * index], dep_points[3 * index + 1], dep_points[3 * index + 2] };
1151 globalID_to_handle[globalId] = new_vert;
1153 new_conn[i] = globalID_to_handle[gids[index]];
1157 EntityType entType =
MBQUAD;
1159 if( nnodes < 4 ) entType =
MBTRI;
1161 rval =
mb->
create_element( entType, new_conn, nnodes, new_element );
ERRORR( rval,
"can't create new quad " );
1162 rval =
mb->
add_entities( covering_lagr_set, &new_element, 1 );
ERRORR( rval,
"can't add new element to dep set" );
1166 globalID_to_eh[gid_el] = new_element;
1168 rval =
mb->
tag_set_data( corrTag, &new_element, 1, &q );
ERRORR( rval,
"can't set corr tag on new el" );
1175 remote_cells =
new TupleList();
1176 remote_cells->initialize( 2, 0, 1, 0, n );
1177 remote_cells->enableWriteAccess();
1178 for(
int i = 0; i < n; i++ )
1180 int globalIdEl = TLq.vi_rd[sizeTuple * i + 1];
1181 int from_proc = TLq.vi_wr[sizeTuple * i];
1183 if( globalID_to_eh.find( globalIdEl ) == globalID_to_eh.end() )
1190 int vgid = TLq.vi_rd[sizeTuple * i + 2 + j];
1195 assert( globalID_to_handle.find( vgid ) != globalID_to_handle.end() );
1196 new_conn[j] = globalID_to_handle[vgid];
1202 EntityType entType =
MBQUAD;
1204 if( nnodes < 4 ) entType =
MBTRI;
1205 rval =
mb->
create_element( entType, new_conn, nnodes, new_element );
ERRORR( rval,
"can't create new element " );
1206 globalID_to_eh[globalIdEl] = new_element;
1207 rval =
mb->
add_entities( covering_lagr_set, &new_element, 1 );
ERRORR( rval,
"can't add new element to dep set" );
1209 remote_cells->vi_wr[2 * i] = from_proc;
1210 remote_cells->vi_wr[2 * i + 1] = globalIdEl;
1212 remote_cells->vul_wr[i] = TLq.vul_rd[i];
1213 remote_cells->inc_n();
1215 rval =
mb->
tag_set_data(
gid, &new_element, 1, &globalIdEl );
ERRORR( rval,
"can't set global id tag on new el" );
1221 sort_buffer.buffer_init( n );
1222 remote_cells->sort( 1, &sort_buffer );
1223 sort_buffer.
reset();
1240 assert( parcomm != NULL );
1241 if( 1 == parcomm->proc_config().proc_size() )
1243 covering_set = lagr_set;
1250 int num_local_verts = (int)local_verts.size();
ERRORR( rval,
"can't get local vertices" );
1252 std::vector< int > gids( num_local_verts );
1255 Range localDepCells;
1262 int num_lagr_verts = (int)lagr_verts.size();
ERRORR( rval,
"can't get local lagr vertices" );
1265 std::vector< double > dep_points( 3 * num_lagr_verts );
1266 rval =
mb->
get_coords( lagr_verts, &dep_points[0] );
ERRORR( rval,
"can't get departure points position" );
1269 std::map< int, Range > Rto;
1270 int numprocs = parcomm->proc_config().proc_size();
1272 for(
Range::iterator eit = localDepCells.begin(); eit != localDepCells.end(); ++eit )
1278 CartVect qbmin( std::numeric_limits<double>::max() );
1279 CartVect qbmax( -std::numeric_limits<double>::max() );
1280 for(
int i = 0; i < num_nodes; i++ )
1283 int index = lagr_verts.index( v );
1284 assert( -1 != index );
1285 CartVect dp( &dep_points[3 * index] );
1286 for(
int j = 0; j < 3; j++ )
1288 if( qbmin[j] > dp[j] ) qbmin[j] = dp[j];
1289 if( qbmax[j] < dp[j] ) qbmax[j] = dp[j];
1292 for(
int p = 0; p < numprocs; p++ )
1294 CartVect bbmin( &
allBoxes[6 * p] );
1295 CartVect bbmax( &
allBoxes[6 * p + 3] );
1306 for(
int p = 0; p < numprocs; p++ )
1308 if( p == (
int)
my_rank )
continue;
1309 Range& range_to_P = Rto[p];
1311 if( range_to_P.empty() )
continue;
1314 numq = numq + range_to_P.size();
1315 numv = numv + vertsToP.size();
1316 range_to_P.merge( vertsToP );
1320 TLv.initialize( 2, 0, 0, 3, numv );
1321 TLv.enableWriteAccess();
1327 TLq.enableWriteAccess();
1329 std::cout <<
"from proc " <<
my_rank <<
" send " << numv <<
" vertices and " << numq <<
" elements\n";
1332 for(
int to_proc = 0; to_proc < numprocs; to_proc++ )
1334 if( to_proc == (
int)
my_rank )
continue;
1335 Range& range_to_P = Rto[to_proc];
1336 Range V = range_to_P.subset_by_type(
MBVERTEX );
1341 int index = lagr_verts.index( v );
1342 assert( -1 != index );
1343 int n = TLv.get_n();
1344 TLv.vi_wr[2 * n] = to_proc;
1345 TLv.vi_wr[2 * n + 1] = gids[index];
1346 TLv.vr_wr[3 * n] = dep_points[3 * index];
1347 TLv.vr_wr[3 * n + 1] = dep_points[3 * index + 1];
1348 TLv.vr_wr[3 * n + 2] = dep_points[3 * index + 2];
1352 Range Q = range_to_P.subset_by_dimension( 2 );
1358 int n = TLq.get_n();
1359 TLq.vi_wr[sizeTuple * n] = to_proc;
1360 TLq.vi_wr[sizeTuple * n + 1] = global_id;
1364 q, conn4, num_nodes );
1365 if( num_nodes >
MAXEDGES )
ERRORR( MB_FAILURE,
"too many nodes in a polygon" );
1366 for(
int i = 0; i < num_nodes; i++ )
1369 int index = lagr_verts.index( v );
1370 assert( -1 != index );
1371 TLq.vi_wr[sizeTuple * n + 2 + i] = gids[index];
1375 TLq.vi_wr[sizeTuple * n + 2 + k] =
1379 rval =
mb->
tag_get_data( corrTag, &q, 1, &tgtCell );
ERRORR( rval,
"can't get corresponding tgt cell for dep cell" );
1380 TLq.vul_wr[n] = tgtCell;
1386 ( parcomm->proc_config().crystal_router() )->gs_transfer( 1, TLv, 0 );
1387 ( parcomm->proc_config().crystal_router() )->gs_transfer( 1, TLq, 0 );
1391 std::map< int, EntityHandle > globalID_to_handle;
1395 for(
Range::iterator vit = lagr_verts.begin(); vit != lagr_verts.end(); ++vit, k++ )
1397 globalID_to_handle[gids[k]] = *vit;
1401 globalID_to_eh.clear();
1403 int n = TLv.get_n();
1404 for(
int i = 0; i < n; i++ )
1406 int globalId = TLv.vi_rd[2 * i + 1];
1407 if( globalID_to_handle.find( globalId ) == globalID_to_handle.end() )
1410 double dp_pos[3] = { TLv.vr_wr[3 * i], TLv.vr_wr[3 * i + 1], TLv.vr_wr[3 * i + 2] };
1412 globalID_to_handle[globalId] = new_vert;
1420 Range local_q = local.subset_by_dimension( 2 );
1422 for(
Range::iterator it = local_q.begin(); it != local_q.end(); ++it )
1427 globalID_to_eh[gid_el] = q;
1435 remote_cells =
new TupleList();
1436 remote_cells->initialize( 2, 0, 1, 0, n );
1437 remote_cells->enableWriteAccess();
1438 for(
int i = 0; i < n; i++ )
1440 int globalIdEl = TLq.vi_rd[sizeTuple * i + 1];
1441 int from_proc = TLq.vi_rd[sizeTuple * i];
1443 if( globalID_to_eh.find( globalIdEl ) == globalID_to_eh.end() )
1450 int vgid = TLq.vi_rd[sizeTuple * i + 2 + j];
1455 assert( globalID_to_handle.find( vgid ) != globalID_to_handle.end() );
1456 new_conn[j] = globalID_to_handle[vgid];
1462 EntityType entType =
MBQUAD;
1464 if( nnodes < 4 ) entType =
MBTRI;
1465 rval =
mb->
create_element( entType, new_conn, nnodes, new_element );
ERRORR( rval,
"can't create new element " );
1466 globalID_to_eh[globalIdEl] = new_element;
1467 local_q.insert( new_element );
1470 remote_cells->vi_wr[2 * i] = from_proc;
1471 remote_cells->vi_wr[2 * i + 1] = globalIdEl;
1473 remote_cells->vul_wr[i] = TLq.vul_rd[i];
1474 remote_cells->inc_n();
1478 rval =
mb->
add_entities( covering_set, local_q );
ERRORR( rval,
"can't add entities to new mesh set " );
1482 sort_buffer.buffer_init( n );
1483 remote_cells->sort( 1, &sort_buffer );
1484 sort_buffer.
reset();
1489 ErrorCode Intx2Mesh::resolve_intersection_sharing()
1491 if( parcomm && parcomm->size() > 1 )
1501 Range nonOwnedVerts;
1517 Range vertsCovInterface;
1520 Range nodesToDuplicate =
intersect( vertsCovInterface, nonOwnedVerts );
1523 Range connectedCells;
1526 connectedCells =
intersect( connectedCells, intxCells );
1528 std::map< EntityHandle, EntityHandle > duplicatedVerticesMap;
1529 for(
Range::iterator vit = nodesToDuplicate.begin(); vit != nodesToDuplicate.end(); vit++ )
1536 duplicatedVerticesMap[
vertex] = newVertex;
1540 for(
Range::iterator eit = connectedCells.begin(); eit != connectedCells.end(); eit++ )
1544 std::vector< EntityHandle > connectivity;
1546 for(
size_t i = 0; i < connectivity.size(); i++ )
1549 std::map< EntityHandle, EntityHandle >::iterator mit = duplicatedVerticesMap.find( currentVertex );
1550 if( mit != duplicatedVerticesMap.end() )
1552 connectivity[i] = mit->second;
1555 int nnodes = (int)connectivity.size();