18 #define ERRORR( rval, str ) \
20 if( MB_SUCCESS != ( rval ) ) \
22 std::cerr << ( str ); \
31 "sqijk",
"trivial",
"rcbzoltan",
"nopart" };
34 : mbImpl( imp ), searchedBoxes( false ), boxPeriodicTag( 0 ), boxDimsTag( 0 ), globalBoxDimsTag( 0 ),
35 partMethodTag( 0 ), boxSetTag( 0 )
43 std::vector< ScdBox* > tmp_boxes;
46 for( std::vector< ScdBox* >::iterator rit = tmp_boxes.begin(); rit != tmp_boxes.end(); ++rit )
67 scd_boxes.push_back( tmp_box );
92 std::bind( std::equal_to< ScdBox* >(), std::placeholders::_1,
dum ) );
97 for( std::vector< ScdBox* >::iterator vit =
scdBoxes.begin(); vit !=
scdBoxes.end(); ++vit )
98 scd_boxes.
insert( ( *vit )->box_set() );
114 const double*
const coords,
115 unsigned int num_coords,
117 int*
const lperiodic,
120 int tag_shared_ents )
125 int tmp_lper[3] = { 0, 0, 0 };
126 if( lperiodic ) std::copy( lperiodic, lperiodic + 3, tmp_lper );
128 #ifndef MOAB_HAVE_MPI
129 if( -1 != tag_shared_ents )
ERRORR( MB_FAILURE,
"Parallel capability requested but MOAB not compiled parallel." );
130 if( -1 == tag_shared_ents && !assign_gids ) assign_gids =
true;
135 if( !par_data->
pComm )
143 par_data->
pDims );
ERRORR( rval,
"Error returned from compute_partition." );
144 low.
set( ldims[0], ldims[1], ldims[2] );
145 high.
set( ldims[3], ldims[4], ldims[5] );
148 std::cout <<
"Proc " << par_data->
pComm->
rank() <<
": " << *par_data;
149 std::cout <<
"Proc " << par_data->
pComm->
rank() <<
" local dims: " << low <<
"-" << high << std::endl;
155 if( ( tmp_size[1] && num_coords && (
int)num_coords < tmp_size[0] ) ||
156 ( tmp_size[2] && num_coords && (
int)num_coords < tmp_size[0] * tmp_size[1] ) )
162 double *xc, *yc, *zc;
165 if( coords && num_coords )
168 for(
int kl = low[2]; kl <= high[2]; kl++ )
170 for(
int jl = low[1]; jl <= high[1]; jl++ )
172 for(
int il = low[0]; il <= high[0]; il++ )
174 xc[i] = coords[3 * i];
175 if( new_box->
box_size()[1] ) yc[i] = coords[3 * i + 1];
176 if( new_box->
box_size()[2] ) zc[i] = coords[3 * i + 2];
185 for(
int kl = low[2]; kl <= high[2]; kl++ )
187 for(
int jl = low[1]; jl <= high[1]; jl++ )
189 for(
int il = low[0]; il <= high[0]; il++ )
214 EntityType this_tp =
MBHEX;
215 if( 1 >= tmp_size[2] ) this_tp =
MBQUAD;
216 if( 1 >= tmp_size[2] && 1 >= tmp_size[1] ) this_tp =
MBEDGE;
217 rval = seq_mgr->
create_scd_sequence( low, high, this_tp, 0, start_ent, tmp_seq, tmp_lper );
ERRORR( rval,
"Trouble creating scd element sequence." );
229 low +
HomCoord( 0, 1, 0 ), low +
HomCoord( 0, 1, 0 ) );
ERRORR( rval,
"Error constructing structured element sequence." );
235 if( par_data ) new_box->
par_data( *par_data );
243 if( par_data && -1 != tag_shared_ents )
261 int* gid_data = (
int*)data;
275 *gid_data = ( -1 != kl ? kl * di * dj : 0 ) + jl * di + itmp + 1;
292 if( ( tp ==
MBHEX && 1 >= tmp_size[2] ) || ( tp ==
MBQUAD && 1 >= tmp_size[1] ) ||
293 ( tp ==
MBEDGE && 1 >= tmp_size[0] ) )
297 assert( mbcore != NULL );
312 new_box =
new ScdBox(
this, scd_set, tmp_seq );
313 if( !new_box )
return MB_FAILURE;
348 for(
int i = 0; i < 3; i++ )
350 for(
int i = 0; i < 3; i++ )
351 boxdims[3 + i] = high[i];
369 std::string tag_name;
386 std::string tag_name;
402 std::string tag_name;
419 std::string tag_name;
436 std::string tag_name;
451 std::vector< ScdBox* >::iterator vit = std::find(
scdBoxes.begin(),
scdBoxes.end(), box );
475 : scImpl( impl ), boxSet( bset ), vertDat( NULL ), elemSeq( NULL ), startVertex( 0 ), startElem( 0 )
477 for(
int i = 0; i < 6; i++ )
479 for(
int i = 0; i < 3; i++ )
486 for(
int i = 0; i < 3; i++ )
519 for(
int i = 0; i < 3; i++ )
556 assert( mbcore != NULL );
591 if( !vbox->
vertDat )
return MB_FAILURE;
605 if( !
vertDat )
return MB_FAILURE;
615 if( !
vertDat )
return MB_FAILURE;
646 if( ( 0 == this_dim && !
vertDat ) || ( this_dim && this_dim == dimension ) )
652 else if( !this_dim &&
vertDat )
675 bool create_if_missing )
const
683 int subconnect[2][3][4][3] = { { { { 0, 0, 0 }, { 1, 0, 0 }, { -1, -1, -1 }, { -1, -1, -1 } },
684 { { 0, 0, 0 }, { 0, 1, 0 }, { -1, -1, -1 }, { -1, -1, -1 } },
685 { { 0, 0, 0 }, { 0, 0, 1 }, { -1, -1, -1 }, { -1, -1, -1 } } },
687 { { { 0, 0, 0 }, { 0, 1, 0 }, { 0, 1, 1 }, { 0, 0, 1 } },
688 { { 0, 0, 0 }, { 1, 0, 0 }, { 1, 0, 1 }, { 0, 0, 1 } },
689 { { 0, 0, 0 }, { 1, 0, 0 }, { 1, 1, 0 }, { 0, 1, 0 } } } };
703 for(
int ind = 0; ind < 2 *
dim; ind++ )
705 int i1 = i + subconnect[
dim - 1][dir][ind][0];
706 int j1 = j + subconnect[
dim - 1][dir][ind][1];
711 verts[ind] =
get_vertex( i1, j1, k + subconnect[
dim - 1][dir][ind][2] );
712 if( !verts[ind] )
return MB_FAILURE;
719 if( ents.
size() > 1 )
722 else if( ents.
size() == 1 )
726 else if( create_if_missing )
732 #ifndef MOAB_HAVE_MPI
749 if( ( gdims[0] == gdims[3] && gdims[1] == gdims[4] && gdims[2] == gdims[5] ) || -1 == box->
par_data().
partMethod )
753 std::vector< int > procs, offsets, shared_indices;
758 std::vector< MPI_Request > recv_reqs( procs.size(), MPI_REQUEST_NULL ), send_reqs( procs.size(), MPI_REQUEST_NULL );
759 std::vector< EntityHandle > rhandles( 4 * procs.size() ), shandles( 4 );
760 for(
unsigned int i = 0; i < procs.size(); i++ )
762 int success = MPI_Irecv( (
void*)&rhandles[4 * i], 4 *
sizeof(
EntityHandle ), MPI_UNSIGNED_CHAR, procs[i], 1,
764 if( success != MPI_SUCCESS )
return MB_FAILURE;
786 for(
unsigned int i = 0; i < procs.size(); i++ )
788 int success = MPI_Isend( (
void*)&shandles[0], 4 *
sizeof(
EntityHandle ), MPI_UNSIGNED_CHAR, procs[i], 1,
790 if( success != MPI_SUCCESS )
return MB_FAILURE;
794 int incoming = procs.size();
798 shared_data.
initialize( 1, 0, 2, 0, shared_indices.size() / 2 );
805 int success = MPI_Waitany( procs.size(), &recv_reqs[0], &p, &status );
806 if( MPI_SUCCESS != success )
return MB_FAILURE;
807 unsigned int num_indices = ( offsets[p + 1] - offsets[p] ) / 2;
808 int *lh = &shared_indices[offsets[p]], *rh = lh + num_indices;
809 for(
unsigned int i = 0; i < num_indices; i++ )
811 shared_data.
vi_wr[j++] = procs[p];
812 shared_data.
vul_wr[k++] = shandles[0] + lh[i];
813 shared_data.
vul_wr[k++] = rhandles[4 * p] + rh[i];
820 std::vector< MPI_Status > mult_status( procs.size() );
821 int success = MPI_Waitall( procs.size(), &send_reqs[0], &mult_status[0] );
822 if( MPI_SUCCESS != success )
824 MB_SET_ERR( MB_FAILURE,
"Failed in waitall in ScdInterface::tag_shared_vertices" );
828 sort_buffer.buffer_init( shared_indices.size() / 2 );
829 shared_data.
sort( 1, &sort_buffer );
833 std::map< std::vector< int >, std::vector< EntityHandle > > proc_nvecs;
846 for( std::vector< int >::iterator pit = procs.begin(); pit != procs.end(); ++pit )
863 const int*
const gdims,
864 const int*
const gperiodic,
865 const int*
const dijk,
878 across_bdy[0] = across_bdy[1] = across_bdy[2] = 0;
880 int ldims[6], pijk[3], lperiodic[3];
883 assert( pijk[1] * pijk[2] == np );
885 bool bot_j = pfrom< pijk[2], top_j = pfrom > np - pijk[2];
886 if( ( 1 == pijk[2] && dijk[2] ) ||
887 ( !( pfrom % pijk[2] ) && -1 == dijk[2] ) ||
888 ( pfrom % pijk[2] == pijk[2] - 1 && 1 == dijk[2] ) ||
889 ( pfrom < pijk[2] && -1 == dijk[1] && !gperiodic[1] ) ||
890 ( pfrom >= np - pijk[2] && 1 == dijk[1] && !gperiodic[1] ) )
894 std::copy( ldims, ldims + 6, rdims );
895 std::copy( ldims, ldims + 6, facedims );
899 pto = ( pto + dijk[1] * pijk[2] + np ) % np;
900 assert( pto >= 0 && pto < np );
901 int dj = ( gdims[4] - gdims[1] ) / pijk[1], extra = ( gdims[4] - gdims[1] ) % pijk[1];
904 facedims[4] = facedims[1];
915 rdims[1] = rdims[4] - dj;
916 if( pto < extra ) rdims[1]--;
920 if( pfrom > np - pijk[2] ) facedims[4] = gdims[1];
921 facedims[1] = facedims[4];
932 rdims[4] = rdims[1] + dj;
933 if( pto < extra ) rdims[4]++;
938 pto = ( pto + dijk[2] ) % np;
939 assert( pto >= 0 && pto < np );
940 facedims[2] = facedims[5] = ( -1 == dijk[2] ? facedims[2] : facedims[5] );
941 int dk = ( gdims[5] - gdims[2] ) / pijk[2];
944 facedims[5] = facedims[2];
946 rdims[2] = rdims[5] - dk;
950 facedims[2] = facedims[5];
952 rdims[5] = rdims[2] + dk;
956 assert( -1 == pto || ( rdims[0] >= gdims[0] && rdims[3] <= gdims[3] ) );
957 assert( -1 == pto || ( rdims[1] >= gdims[1] && ( rdims[4] <= gdims[4] || ( across_bdy[1] && bot_j ) ) ) );
958 assert( -1 == pto || ( rdims[2] >= gdims[2] && rdims[5] <= gdims[5] ) );
959 assert( -1 == pto || ( ( facedims[0] >= rdims[0] ||
960 ( gperiodic[0] && rdims[3] == gdims[3] + 1 && facedims[0] == gdims[0] ) ) ) );
961 assert( -1 == pto || ( facedims[3] <= rdims[3] ) );
962 assert( -1 == pto || ( ( facedims[1] >= rdims[1] ||
963 ( gperiodic[1] && rdims[4] == gdims[4] + 1 && facedims[1] == gdims[1] ) ) ) );
964 assert( -1 == pto || ( facedims[4] <= rdims[4] ) );
965 assert( -1 == pto || ( facedims[2] >= rdims[2] ) );
966 assert( -1 == pto || ( facedims[5] <= rdims[5] ) );
967 assert( -1 == pto || ( facedims[0] >= ldims[0] ) );
968 assert( -1 == pto || ( facedims[3] <= ldims[3] ) );
969 assert( -1 == pto || ( facedims[1] >= ldims[1] ) );
970 assert( -1 == pto || ( facedims[4] <= ldims[4] ) );
971 assert( -1 == pto || ( facedims[2] >= ldims[2] ) );
972 assert( -1 == pto || ( facedims[5] <= ldims[5] ) );
979 const int*
const gdims,
980 const int*
const gperiodic,
981 const int*
const dijk,
995 across_bdy[0] = across_bdy[1] = across_bdy[2] = 0;
996 int lperiodic[3], pijk[3], ldims[6];
999 assert( pijk[0] * pijk[1] == np );
1001 bool top_i = 0, top_j = 0, bot_i = 0, bot_j = 0;
1002 int ni = pfrom % pijk[0], nj = pfrom / pijk[0];
1003 if( ni == pijk[0] - 1 ) top_i = 1;
1004 if( nj == pijk[1] - 1 ) top_j = 1;
1005 if( !ni ) bot_i = 1;
1006 if( !nj ) bot_j = 1;
1007 if( ( !gperiodic[0] && bot_i && -1 == dijk[0] ) ||
1008 ( !gperiodic[0] && top_i && 1 == dijk[0] ) ||
1009 ( !gperiodic[1] && bot_j && -1 == dijk[1] ) ||
1010 ( !gperiodic[1] && top_j && 1 == dijk[1] ) )
1013 std::copy( ldims, ldims + 6, facedims );
1014 std::copy( ldims, ldims + 6, rdims );
1016 int j = gdims[4] - gdims[1], dj = j / pijk[1], jextra = ( gdims[4] - gdims[1] ) % dj, i = gdims[3] - gdims[0],
1017 di = i / pijk[0], iextra = ( gdims[3] - gdims[0] ) % di;
1021 pto = ( ni + dijk[0] + pijk[0] ) % pijk[0];
1022 pto = nj * pijk[0] + pto;
1023 assert( pto >= 0 && pto < np );
1026 facedims[3] = facedims[0];
1031 rdims[3] = gdims[3] + 1;
1032 rdims[0] = rdims[3] - di - 1;
1036 rdims[3] = ldims[0];
1037 rdims[0] = rdims[3] - di;
1040 if( pto % pijk[0] < iextra ) rdims[0]--;
1047 facedims[3] = gdims[0];
1050 facedims[0] = facedims[3];
1051 rdims[0] = ( top_i ? gdims[0] : ldims[3] );
1052 rdims[3] = rdims[0] + di;
1053 if( pto % pijk[0] < iextra ) rdims[3]++;
1054 if( gperiodic[0] && ni == pijk[0] - 2 ) rdims[3]++;
1059 pto = ( pto + dijk[1] * pijk[0] + np ) % np;
1060 assert( pto >= 0 && pto < np );
1063 facedims[4] = facedims[1];
1067 rdims[4] = gdims[4] + 1;
1068 rdims[1] = rdims[4] - dj - 1;
1073 rdims[4] = ldims[1];
1074 rdims[1] = rdims[4] - dj;
1076 if( pto / pijk[0] < jextra ) rdims[1]--;
1083 facedims[4] = gdims[1];
1084 rdims[1] = gdims[1];
1089 rdims[1] = ldims[4];
1091 facedims[1] = facedims[4];
1092 rdims[4] = rdims[1] + dj;
1093 if( nj + 1 < jextra ) rdims[4]++;
1094 if( gperiodic[1] && nj == pijk[1] - 2 ) rdims[4]++;
1099 assert( -1 == pto || ( rdims[0] >= gdims[0] &&
1100 ( rdims[3] <= gdims[3] + ( gperiodic[0] && pto % pijk[0] == pijk[0] - 1 ? 1 : 0 ) ) ) );
1101 assert( -1 == pto || ( rdims[1] >= gdims[1] &&
1102 ( rdims[4] <= gdims[4] + ( gperiodic[1] && pto / pijk[0] == pijk[1] - 1 ? 1 : 0 ) ) ) );
1103 assert( -1 == pto || ( rdims[2] >= gdims[2] && rdims[5] <= gdims[5] ) );
1105 assert( -1 == pto || ( ( facedims[0] >= rdims[0] ||
1106 ( gperiodic[0] && pto % pijk[0] == pijk[0] - 1 && facedims[0] == gdims[0] ) ) ) );
1107 assert( -1 == pto || ( facedims[3] <= rdims[3] ) );
1108 assert( -1 == pto || ( ( facedims[1] >= rdims[1] ||
1109 ( gperiodic[1] && pto / pijk[0] == pijk[1] - 1 && facedims[1] == gdims[1] ) ) ) );
1110 assert( -1 == pto || ( facedims[4] <= rdims[4] ) );
1111 assert( -1 == pto || ( facedims[2] >= rdims[2] && facedims[5] <= rdims[5] ) );
1113 assert( -1 == pto || ( ( facedims[0] >= ldims[0] || ( top_i && facedims[0] == gdims[0] ) ) ) );
1114 assert( -1 == pto || ( facedims[3] <= ldims[3] ) );
1115 assert( -1 == pto || ( ( facedims[1] >= ldims[1] || ( gperiodic[1] && top_j && facedims[1] == gdims[1] ) ) ) );
1116 assert( -1 == pto || ( facedims[4] <= ldims[4] ) );
1117 assert( -1 == pto || ( facedims[2] >= ldims[2] && facedims[5] <= ldims[5] ) );
1124 const int*
const gdims,
1125 const int*
const gperiodic,
1126 const int*
const dijk,
1139 across_bdy[0] = across_bdy[1] = across_bdy[2] = 0;
1140 int pijk[3], lperiodic[3], ldims[6];
1143 assert( pijk[1] * pijk[2] == np );
1145 bool top_j = 0, top_k = 0, bot_j = 0, bot_k = 0;
1146 int nj = pfrom % pijk[1], nk = pfrom / pijk[1];
1147 if( nj == pijk[1] - 1 ) top_j = 1;
1148 if( nk == pijk[2] - 1 ) top_k = 1;
1149 if( !nj ) bot_j = 1;
1150 if( !nk ) bot_k = 1;
1151 if( ( !gperiodic[1] && bot_j && -1 == dijk[1] ) ||
1152 ( !gperiodic[1] && top_j && 1 == dijk[1] ) ||
1153 ( bot_k && -1 == dijk[2] ) ||
1154 ( top_k && 1 == dijk[2] ) )
1157 std::copy( ldims, ldims + 6, facedims );
1158 std::copy( ldims, ldims + 6, rdims );
1160 int dj = ( gdims[4] - gdims[1] ) / pijk[1], jextra = ( gdims[4] - gdims[1] ) % dj,
1161 dk = ( gdims[5] == gdims[2] ? 0 : ( gdims[5] - gdims[2] ) / pijk[2] ),
1162 kextra = ( gdims[5] - gdims[2] ) - dk * pijk[2];
1163 assert( ( dj * pijk[1] + jextra == ( gdims[4] - gdims[1] ) ) &&
1164 ( dk * pijk[2] + kextra == ( gdims[5] - gdims[2] ) ) );
1167 pto = ( nj + dijk[1] + pijk[1] ) % pijk[1];
1168 pto = nk * pijk[1] + pto;
1169 assert( pto >= 0 && pto < np );
1172 facedims[4] = facedims[1];
1176 rdims[4] = gdims[4] + 1;
1181 rdims[4] = ldims[1];
1183 rdims[1] = rdims[4] - dj;
1184 if( nj < jextra ) rdims[1]--;
1191 rdims[1] = gdims[1];
1192 facedims[4] = gdims[1];
1197 rdims[1] = ldims[4];
1199 facedims[1] = facedims[4];
1200 rdims[4] = rdims[1] + dj;
1201 if( nj < jextra ) rdims[4]++;
1202 if( gperiodic[1] && nj == dijk[1] - 2 ) rdims[4]++;
1207 pto = ( pto + dijk[2] * pijk[1] + np ) % np;
1208 assert( pto >= 0 && pto < np );
1211 facedims[5] = facedims[2];
1212 rdims[5] = ldims[2];
1214 if( pto / pijk[1] < kextra ) rdims[2]--;
1218 facedims[2] = facedims[5];
1219 rdims[2] = ldims[5];
1221 if( pto / pijk[1] < kextra ) rdims[5]++;
1225 assert( -1 == pto || ( rdims[0] >= gdims[0] && rdims[3] <= gdims[3] ) );
1226 assert( -1 == pto || ( rdims[1] >= gdims[1] && ( rdims[4] <= gdims[4] || ( across_bdy[1] && bot_j ) ) ) );
1227 assert( -1 == pto || ( rdims[2] >= gdims[2] && rdims[5] <= gdims[5] ) );
1228 assert( -1 == pto || ( facedims[0] >= rdims[0] && facedims[3] <= rdims[3] ) );
1229 assert( -1 == pto ||
1230 ( ( facedims[1] >= rdims[1] || ( gperiodic[1] && rdims[4] == gdims[4] && facedims[1] == gdims[1] ) ) ) );
1231 assert( -1 == pto || ( facedims[4] <= rdims[4] ) );
1232 assert( -1 == pto || ( facedims[2] >= rdims[2] && facedims[5] <= rdims[5] ) );
1233 assert( -1 == pto || ( facedims[0] >= ldims[0] && facedims[3] <= ldims[3] ) );
1234 assert( -1 == pto || ( facedims[1] >= ldims[1] && facedims[4] <= ldims[4] ) );
1235 assert( -1 == pto || ( facedims[2] >= ldims[2] && facedims[5] <= ldims[5] ) );
1242 const int*
const gdims,
1243 const int*
const gperiodic,
1244 const int*
const dijk,
1250 if( gperiodic[0] || gperiodic[1] || gperiodic[2] )
return MB_FAILURE;
1253 across_bdy[0] = across_bdy[1] = across_bdy[2] = 0;
1254 int pijk[3], lperiodic[3], ldims[6];
1257 assert( pijk[0] * pijk[1] * pijk[2] == np );
1259 bool top[3] = {
false,
false,
false }, bot[3] = {
false,
false,
false };
1261 int nijk[3] = { pfrom % pijk[0], ( pfrom % ( pijk[0] * pijk[1] ) ) / pijk[0], pfrom / ( pijk[0] * pijk[1] ) };
1263 for(
int i = 0; i < 3; i++ )
1265 if( nijk[i] == pijk[i] - 1 ) top[i] =
true;
1266 if( !nijk[i] ) bot[i] =
true;
1267 if( ( !gperiodic[i] && bot[i] && -1 == dijk[i] ) ||
1268 ( !gperiodic[i] && top[i] && 1 == dijk[i] ) )
1272 std::copy( ldims, ldims + 6, facedims );
1273 std::copy( ldims, ldims + 6, rdims );
1275 int delijk[3], extra[3];
1278 for(
int i = 0; i < 3; i++ )
1280 delijk[i] = ( gdims[i + 3] == gdims[i] ? 0 : ( gdims[i + 3] - gdims[i] ) / pijk[i] );
1281 extra[i] = ( gdims[i + 3] - gdims[i] ) % delijk[i];
1282 nijk_to[i] = ( nijk[i] + dijk[i] + pijk[i] ) % pijk[i];
1284 pto = nijk_to[2] * pijk[0] * pijk[1] + nijk_to[1] * pijk[0] + nijk_to[0];
1285 assert( pto >= 0 && pto < np );
1286 for(
int i = 0; i < 3; i++ )
1292 facedims[i + 3] = facedims[i];
1296 rdims[i + 3] = gdims[i + 3] + 1;
1301 rdims[i + 3] = ldims[i];
1303 rdims[i] = rdims[i + 3] - delijk[i];
1304 if( nijk[i] < extra[i] ) rdims[i]--;
1311 rdims[i] = gdims[i];
1312 facedims[i + 3] = gdims[i];
1317 rdims[i] = ldims[i + 3];
1319 facedims[i] = facedims[i + 3];
1320 rdims[i + 3] = rdims[i] + delijk[i];
1321 if( nijk[i] < extra[i] ) rdims[i + 3]++;
1322 if( gperiodic[i] && nijk[i] == dijk[i] - 2 ) rdims[i + 3]++;
1327 assert( -1 != pto );
1329 for(
int i = 0; i < 3; i++ )
1331 assert( ( rdims[i] >= gdims[i] && ( rdims[i + 3] <= gdims[i + 3] || ( across_bdy[i] && bot[i] ) ) ) );
1332 assert( ( ( facedims[i] >= rdims[i] ||
1333 ( gperiodic[i] && rdims[i + 3] == gdims[i + 3] && facedims[i] == gdims[i] ) ) ) );
1334 assert( ( facedims[i] >= ldims[i] && facedims[i + 3] <= ldims[i + 3] ) );
1343 const int*
const gdims,
1344 const int*
const gperiodic,
1345 const int*
const dijk,
1355 int pijk[3], lperiodic[3], ldims[6];
1360 across_bdy[0] = across_bdy[1] = across_bdy[2] = 0;
1362 for(
int i = 0; i < 3; i++ )
1377 bool is_periodic = ( ( gperiodic[0] && ind == 0 ) || ( gperiodic[1] && ind == 1 ) );
1378 if( dijk[( ind + 1 ) % 3] || dijk[( ind + 2 ) % 3] ||
1379 ( !is_periodic && ldims[ind] == gdims[ind] && dijk[ind] == -1 ) ||
1380 ( !is_periodic && ldims[3 + ind] >= gdims[3 + ind] &&
1385 std::copy( ldims, ldims + 6, facedims );
1386 std::copy( ldims, ldims + 6, rdims );
1388 int dind = ( gdims[ind + 3] - gdims[ind] ) / np;
1389 int extra = ( gdims[ind + 3] - gdims[ind] ) % np;
1390 if( -1 == dijk[ind] && pfrom )
1394 facedims[ind + 3] = facedims[ind];
1395 rdims[ind + 3] = ldims[ind];
1396 rdims[ind] = rdims[ind + 3] - dind - ( pto < extra ? 1 : 0 );
1398 else if( 1 == dijk[ind] && pfrom < np - 1 )
1402 facedims[ind] = facedims[ind + 3];
1403 rdims[ind] = ldims[ind + 3];
1404 rdims[ind + 3] = rdims[ind] + dind + ( pto < extra ? 1 : 0 );
1405 if( is_periodic && pfrom == np - 2 ) rdims[ind + 3]++;
1407 else if( -1 == dijk[ind] && !pfrom && gperiodic[ind] )
1411 facedims[ind + 3] = facedims[ind] = gdims[ind];
1414 rdims[ind] = rdims[ind + 3] - dind - 1;
1415 across_bdy[ind] = -1;
1417 else if( 1 == dijk[ind] && pfrom == np - 1 && is_periodic )
1421 facedims[ind + 3] = facedims[ind] = gdims[ind];
1422 rdims[ind] = gdims[ind];
1423 rdims[ind + 3] = rdims[ind] + dind + ( pto < extra ? 1 : 0 );
1424 across_bdy[ind] = 1;
1427 assert( -1 == pto || ( rdims[0] >= gdims[0] && ( rdims[3] <= gdims[3] || ( across_bdy[0] && !pfrom ) ) ) );
1428 assert( -1 == pto || ( rdims[1] >= gdims[1] && ( rdims[4] <= gdims[4] || ( across_bdy[1] && !pfrom ) ) ) );
1429 assert( -1 == pto || ( rdims[2] >= gdims[2] && rdims[5] <= gdims[5] ) );
1430 assert( -1 == pto || ( facedims[0] >= rdims[0] && facedims[3] <= rdims[3] ) );
1431 assert( -1 == pto || ( facedims[1] >= rdims[1] && facedims[4] <= rdims[4] ) );
1432 assert( -1 == pto || ( facedims[2] >= rdims[2] && facedims[5] <= rdims[5] ) );
1433 assert( -1 == pto || ( facedims[0] >= ldims[0] && facedims[3] <= ldims[3] ) );
1434 assert( -1 == pto || ( facedims[1] >= ldims[1] && facedims[4] <= ldims[4] ) );
1435 assert( -1 == pto || ( facedims[2] >= ldims[2] && facedims[5] <= ldims[5] ) );
1441 #ifndef MOAB_HAVE_MPI
1444 std::vector< int >&,
1445 std::vector< int >&,
1446 std::vector< int >& )
1452 std::vector< int >& procs,
1453 std::vector< int >& offsets,
1454 std::vector< int >& shared_indices )
1457 const int* ldims = box->
box_dims();
1459 int ijkrem[6], ijkface[6], across_bdy[3];
1461 for(
int k = -1; k <= 1; k++ )
1463 for(
int j = -1; j <= 1; j++ )
1465 for(
int i = -1; i <= 1; i++ )
1467 if( !i && !j && !k )
continue;
1469 int dijk[] = { i, j, k };
1471 box->
par_data(), dijk, pto, ijkrem, ijkface, across_bdy );
1475 if( procs.empty() || pto != *procs.rbegin() )
1477 procs.push_back( pto );
1478 offsets.push_back( shared_indices.size() );
1480 rval =
get_indices( ldims, ijkrem, across_bdy, ijkface, shared_indices );
1488 int start_idx = *offsets.rbegin(), end_idx = shared_indices.size(),
1489 mid_idx = ( start_idx + end_idx ) / 2;
1491 int num_local_verts = ( ldims[3] - ldims[0] + 1 ) * ( ldims[4] - ldims[1] + 1 ) *
1492 ( -1 == ldims[2] && -1 == ldims[5] ? 1 : ( ldims[5] - ldims[2] + 1 ) ),
1493 num_remote_verts = ( ijkrem[3] - ijkrem[0] + 1 ) * ( ijkrem[4] - ijkrem[1] + 1 ) *
1494 ( -1 == ijkrem[2] && -1 == ijkrem[5] ? 1 : ( ijkrem[5] - ijkrem[2] + 1 ) );
1497 *std::min_element( &shared_indices[start_idx], &shared_indices[mid_idx] ) >= 0 &&
1498 *std::max_element( &shared_indices[start_idx], &shared_indices[mid_idx] ) < num_local_verts &&
1499 *std::min_element( &shared_indices[mid_idx], &shared_indices[end_idx] ) >= 0 &&
1500 *std::max_element( &shared_indices[mid_idx], &shared_indices[end_idx] ) < num_remote_verts );
1507 offsets.push_back( shared_indices.size() );
1518 << pd.
pDims[0] <<
"," << pd.
pDims[1] <<
"," << pd.
pDims[2] <<
")" << std::endl;