28 _meshList(mesh_list), _nPart(nPart), _eType(eType), _options(0), _bMesh(NULL)
30 if ( !MPI::Is_initialized() ) MPI::Init();
39 MPI::COMM_WORLD.Barrier();
41 vector< Array<int>* > ::iterator it_array;
49 vector< int* > ::iterator it_int;
50 for ( it_int =
_ePtr.begin(); it_int !=
_ePtr.end(); it_int++)
53 for ( it_int =
_eInd.begin(); it_int !=
_eInd.end(); it_int++)
56 for ( it_int =
_eElm.begin(); it_int !=
_eElm.end(); it_int++)
62 for ( it_int =
_row.begin(); it_int !=
_row.end(); it_int++)
65 for ( it_int =
_col.begin(); it_int !=
_col.end(); it_int++)
68 for ( it_int =
_elem.begin(); it_int !=
_elem.end(); it_int++)
72 vector< float* > ::iterator it_float;
73 for ( it_float =
_tpwgts.begin(); it_float !=
_tpwgts.end(); it_float++)
76 for ( it_float =
_ubvec.begin(); it_float !=
_ubvec.end(); it_float++)
78 vector< int* > ::iterator it_int;
79 for ( it_int =
_part.begin(); it_int !=
_part.end(); it_int++)
88 vector< Mesh* >::iterator it_mesh;
142 MeshPartitioner::dumpTecplot()
146 MPI::COMM_WORLD.Barrier();
156 for (
int n = 0; n < tot_elems; n++ ){
158 cout <<
" elem = " << n <<
", ";
159 for (
int node = 0; node < nnodes; node++ )
160 cout << cellNodes(n,node) <<
" ";
167 for (
int node = 0; node < tot_nodes; node++)
168 cout <<
" nodeID = " << node <<
" x = " << coord[node][0] <<
" y = " << coord[node][1] <<
" z = " << coord[node][2] << endl;
174 MPI::Status status_row;
175 MPI::Status status_col;
179 ofstream part_file(
"partiton.dat" );
181 int *row =
new int[tot_elems];
182 int *col =
new int[8*tot_elems];
185 part_file <<
"title = \" tecplot file for partionoing \" " << endl;
186 part_file <<
"variables = \"x\", \"y\", \"z\", \"partID\" " << endl;
187 part_file <<
"zone N = " << tot_nodes <<
" E = " << tot_elems <<
188 " DATAPACKING = BLOCK, VARLOCATION = ([4]=CELLCENTERED), ZONETYPE=FETRIANGLE " << endl;
191 for (
int n = 0; n < tot_nodes; n++){
192 part_file << scientific << coord[n][0] <<
" " ;
193 if ( n % 5 == 0 ) part_file << endl;
197 for (
int n= 0; n < tot_nodes; n++){
198 part_file << scientific << coord[n][1] <<
" ";
199 if ( n % 5 == 0 ) part_file << endl;
203 for (
int n = 0; n < tot_nodes; n++){
204 part_file << scientific << coord[n][2] <<
" ";
205 if ( n % 5 == 0) part_file << endl;
209 for (
int elem = 0; elem <
_nelems.at(0); elem++){
210 part_file << 0 <<
" ";
211 if ( elem % 10 == 0 ) part_file << endl;
214 vector< shared_ptr< Array<int> > > row_root;
215 vector< shared_ptr< Array<int> > > col_root;
221 for (
int r = 0; r <
_nelems.at(0)+1; r++)
222 (*row_root.at(0))[r] =
_row.at(0)[r];
224 for (
int c = 0; c <
_colDim.at(0); c++)
225 (*col_root.at(0))[c] =
_col.at(0)[c];
228 for (
int p = 1; p <
_nPart.at(0); p++){
229 MPI::COMM_WORLD.Recv( row, tot_elems, MPI::INT, p, tag_row, status_row);
230 MPI::COMM_WORLD.Recv( col, 8*tot_elems, MPI::INT, p, tag_col, status_col);
232 int nelems = status_row.Get_count(MPI::INT) - 1;
233 int col_dim = status_col.Get_count(MPI::INT);
237 for (
int r = 0; r < nelems+1; r++)
238 (*row_root.at(p))[r] = row[r];
240 for (
int c = 0; c < col_dim; c++)
241 (*col_root.at(p))[c] = col[c];
243 for (
int elem = 0; elem < nelems; elem++){
244 part_file << p <<
" ";
245 if ( elem % 10 == 0 ) part_file << endl;
251 for (
int p = 0; p <
_nPart.at(0); p++){
253 int nelems = row_root.at(p)->getLength() - 1;
254 for (
int elem = 0; elem < nelems; elem++){
255 int node_start = (*row_root.at(p))[elem];
256 int node_end = (*row_root.at(p))[elem+1];
257 for (
int node = node_start; node < node_end; node++)
258 part_file << setw(6) << (*col_root.at(p))[node]+1 <<
" ";
271 MPI::COMM_WORLD.Send(
_row.at(0),
_nelems.at(0)+1, MPI::INT, 0, tag_row);
272 MPI::COMM_WORLD.Send(
_col.at(0),
_colDim.at(0) , MPI::INT, 0, tag_col);
283 for (
int id = 0;
id <
_nmesh;
id++)
291 for (
int id = 0;
id <
_nmesh;
id++)
302 _procID = MPI::COMM_WORLD.Get_rank();
332 for (
int id = 0;
id <
_nmesh;
id++){
345 for (
int n = 0; n <
_ncon.at(
id); n++)
364 cout <<
" ONLY TRIANGLE, TETRAHEDRAL, HEXAHEDRAL and QUADRILATERAL elements must be chose " <<
370 _tpwgts.push_back(
new float[ ncon_by_nparts ] );
371 for (
int n = 0; n < ncon_by_nparts; n++){
372 _tpwgts.at(
id)[n] = 1.0f / float( ncon_by_nparts );
392 for (
int id = 0;
id <
_nmesh;
id++){
395 int nremainder = nelems % npart;
396 int init_dist = (nelems - nremainder) / npart;
402 while ( nremainder != 0 ){
410 for (
int n = 1; n <= npart; n++){
416 for (
int id = 0;
id <
_nmesh;
id++){
418 _part.push_back(
new int[mesh_nlocal] );
419 for (
int n = 0; n < mesh_nlocal; n++)
420 _part.at(
id)[n] = -1;
444 for(
int n = 0; n <
_nPart[0]; n++ )
449 for(
int n = 0; n < _nPart[0]+1; n++ )
464 for (
int id = 0;
id <
_nmesh;
id++){
467 _ePtr.push_back(
new int[mesh_nlocal+1] );
468 _eElm.push_back(
new int[mesh_nlocal+1] );
471 if ( !
_meshList.at(
id)->isMergedMesh() ){
473 for (
int n = 0; n <
_ncon.at(
id)*mesh_nlocal; n++)
479 for (
int n =0; n < mesh_nlocal; n++ ){
480 for (
int i = 0; i <
_meshList.at(
id)->getNumOfAssembleMesh(); i++ ){
510 for (
int n = nstart; n < npart; n++)
511 local_nodes += cellNodes.
getCount(n);
526 _ePtr.at(
id)[indxPtr] = 0;
527 for (
int elem = elem_start; elem < elem_finish; elem++ ){
528 _eElm.at(
id)[indxPtr] = elem;
532 for (
int node = 0; node < cellNodes.
getCount(elem); node++ )
533 _eInd.at(
id)[indxInd++] = cellNodes(elem,node);
537 for (
int node = cellNodes.
getCount(elem)-1; node >=0; node-- )
538 _eInd.at(
id)[indxInd++] = cellNodes(elem,node);
553 for (
int i = 0; i <= mesh_nlocal; i++ ){
560 for (
int i = 0; i < mesh_nlocal; i++ ){
561 _debugFile <<
"_eInd[" << i <<
"], glblCellID = " << setw(3) <<
_eElm.at(0)[i] <<
", ";
562 for (
int j =
_ePtr[0][i]; j <
_ePtr[0][i+1]; j++ ){
575 MPI_Comm comm_world = MPI::COMM_WORLD;
576 for (
int id = 0;
id <
_nmesh;
id++){
600 for (
int i = elem_start; i < elem_finish; i++ ){
618 ifstream permutation_file( fname.c_str() );
620 for (
int i = 0; i < totElms; i++ ){
621 permutation_file >> cellID;
622 (*_fiedlerMap)[i] = cellID - 1;
624 for (
int i = totElms; i < totElmsAndGhost; i++ ){
625 (*_fiedlerMap)[i] = i;
628 permutation_file.close();
634 MPI::COMM_WORLD.Barrier();
641 for (
int i = elem_start; i < elem_finish; i++ ){
649 MPI::COMM_WORLD.Barrier();
665 for (
int n = 0; n < totElms; n++ )
674 for (
int i = elem_start; i < elem_finish; i++ ){
690 for (
int id = 0;
id <
_nmesh;
id++){
692 for (
int elm = 0; elm < nlocal_elem; elm++){
693 int partID =
_part[id][elm];
711 for (
int p = 0; p <
_nPart[0]; p++){
712 multimap<int,int>::iterator it, itlow, itup;
715 for( it = itlow; it != itup; it++)
716 _debugFile <<
" partID = " << it->first <<
" elemID = " << it->second << endl;
727 for (
int id = 0;
id <
_nmesh;
id++){
728 for (
int partID = 0; partID <
_nPart.at(
id); partID++){
732 multimap<int,int>::const_iterator it =
_mapPartAndElms.at(
id).find(partID);
733 multimap<int,int>::const_iterator itlow =
_mapPartAndElms.at(
id).lower_bound(partID);
734 multimap<int,int>::const_iterator itup =
_mapPartAndElms.at(
id).upper_bound(partID);
736 for ( it = itlow; it != itup; it++){
737 int pos = it->second;
738 ncol_local +=
_ePtr.at(
id)[pos+1] -
_ePtr.at(
id)[pos];
741 MPI::COMM_WORLD.Reduce(&nelems_local, &
_nelems.at(
id), 1, MPI::INT, MPI::SUM, partID);
742 MPI::COMM_WORLD.Reduce(&ncol_local, &
_colDim.at(
id), 1, MPI::INT, MPI::SUM, partID);
749 for (
int n = 0; n <
_nelems.at(
id)+1; n++ )
751 for (
int n = 0; n <
_colDim.at(
id); n++)
753 for (
int n = 0; n <
_nelems.at(
id); n++)
754 _elem.at(
id)[n] = -1;
787 for (
int id = 0;
id <
_nmesh;
id++){
789 int *countsRow =
new int[
_nPart.at(
id)];
790 int *countsCol =
new int[
_nPart.at(
id)];
791 int *offsetsRow =
new int[
_nPart.at(
id)];
792 int *offsetsCol =
new int[
_nPart.at(
id)];
795 for (
int partID = 0; partID <
_nPart.at(
id); partID++){
797 int *row_local =
new int[nelems_local];
798 int *elem_local =
new int[nelems_local];
800 multimap<int,int>::const_iterator it =
_mapPartAndElms.at(
id).find(partID);
801 multimap<int,int>::const_iterator itlow =
_mapPartAndElms.at(
id).lower_bound(partID);
802 multimap<int,int>::const_iterator itup =
_mapPartAndElms.at(
id).upper_bound(partID);
807 for ( it = itlow; it != itup; it++){
808 int pos = it->second;
809 ncol_local +=
_ePtr.at(
id)[pos+1] -
_ePtr.at(
id)[pos];
810 row_local[indx] =
_ePtr.at(
id)[pos+1]-
_ePtr.at(
id)[pos];
811 elem_local[indx] =
_eElm.at(
id)[pos];
816 int *col_local =
new int[ncol_local];
818 for ( it = itlow; it != itup; it++ ){
819 int elID = it->second;
820 int node_start =
_ePtr.at(
id)[elID];
821 int node_end =
_ePtr.at(
id)[elID+1];
822 for (
int node = node_start; node < node_end; node++){
823 col_local[indx++] =
_eInd.at(
id)[node];
828 int nrow_local = nelems_local;
829 MPI::COMM_WORLD.Allgather(&nrow_local, 1, MPI::INT, countsRow, 1, MPI::INT);
830 MPI::COMM_WORLD.Allgather(&ncol_local, 1, MPI::INT, countsCol, 1, MPI::INT);
836 for (
int p = 1; p < int(
_nPart.at(
id)); p++ ){
837 offsetsRow[p] = countsRow[p-1] + offsetsRow[p-1];
838 offsetsCol[p] = countsCol[p-1] + offsetsCol[p-1];
842 MPI::COMM_WORLD.Gatherv(row_local, countsRow[
_procID], MPI::INT,
_row.at(
id),
843 countsRow, offsetsRow, MPI::INT, partID);
845 MPI::COMM_WORLD.Gatherv(col_local, countsCol[_procID], MPI::INT,
_col.at(
id),
846 countsCol, offsetsCol, MPI::INT, partID);
848 MPI::COMM_WORLD.Gatherv(elem_local, countsRow[_procID], MPI::INT,
_elem.at(
id),
849 countsRow, offsetsRow, MPI::INT, partID);
854 delete [] elem_local;
858 delete [] countsRow ;
859 delete [] countsCol ;
860 delete [] offsetsRow;
861 delete [] offsetsCol;
880 for (
int id = 0;
id <
_nmesh;
id++){
882 for (
int n =
_nelems.at(
id); n > 0; n--)
886 for (
int n = 1; n <
_nelems.at(
id)+1; n++ )
899 MPI::COMM_WORLD.Barrier();
900 vector< int* > ::iterator it_int;
901 for ( it_int =
_ePtr.begin(); it_int !=
_ePtr.end(); it_int++)
904 for ( it_int =
_eInd.begin(); it_int !=
_eInd.end(); it_int++)
907 for ( it_int =
_eElm.begin(); it_int !=
_eElm.end(); it_int++)
913 for ( it_int =
_row.begin(); it_int !=
_row.end(); it_int++)
916 for ( it_int =
_col.begin(); it_int !=
_col.end(); it_int++)
927 for (
int n = 0; n <
_nelems.at(0)+1; n++){
932 for (
int n = 0; n <
_colDim.at(0); n++){
937 for (
int n = 0; n <
_nelems.at(0); n++){
950 for (
int id = 0;
id <
_nmesh;
id++){
955 set<int>::const_iterator it_set;
957 int bndryID = *it_set;
962 _meshListLocal.at(
id)->createBoundaryFaceGroup(size, offset, bndryID, boundaryType);
968 int interfaceID = *it_set;
974 _meshListLocal.at(
id)->createInterfaceGroup( size, offset, -interfaceID );
975 shared_ptr<StorageSite> siteGather (
new StorageSite(size) );
976 shared_ptr<StorageSite> siteScatter(
new StorageSite(size) );
977 siteGather->setScatterProcID(
_procID );
978 siteGather->setGatherProcID ( interfaceID );
979 siteScatter->setScatterProcID(
_procID );
980 siteScatter->setGatherProcID ( interfaceID );
982 siteScatter->setTag( packed_info );
986 _meshListLocal.at(
id)->createGhostCellSiteScatter( pairID, siteScatter );
987 _meshListLocal.at(
id)->createGhostCellSiteGather ( pairID, siteScatter );
1003 int nmesh =
_meshList.at(0)->getNumOfAssembleMesh();
1015 int glblID = localToGlobalMappers.find(i)->second;
1016 colorLocal[i] = colorGlbl[ glblID ];
1022 int acrossCellID = cellCells(i,0);
1023 colorLocal[i] = colorLocal[ acrossCellID ];
1030 int glblID = localToGlobal[i];
1031 colorOtherLocal[i] = colorGlbl[ glblID ];
1052 for (
int bounID = 0; bounID < int(boundaryFaceGroups.size()); bounID++){
1053 int group_id = boundaryFaceGroups.at(bounID)->id;
1055 string boun_type( boundaryFaceGroups.at(bounID)->groupType );
1059 int nBounElm = boundaryFaceGroups.at(bounID)->site.getCount();
1061 for (
int n = 0; n < nBounElm; n++){
1062 mapBounIDAndCell.insert( pair<int,int>(group_id, indx) );
1068 for (
int n = 0; n <
_nelems.at(
id); n++ )
1071 multimap<int,int>::const_iterator it;
1073 for ( it = mapBounIDAndCell.begin(); it != mapBounIDAndCell.end(); it++ ){
1074 int boun_cell_id = it->second;
1075 int neigh_id = cellCells(boun_cell_id,0);
1076 if (
_elemSet.at(
id).count( neigh_id ) > 0 )
1093 foreach(
const set<int>::value_type
id ,
_boundarySet.at(0) ){
1098 _debugFile <<
"_mapBounIDAndBounType : " << endl;
1100 multimap<int,string>::iterator it_multimapS;
1103 _debugFile <<
"Boundary multimap = " << it_multimapS->first <<
" " << it_multimapS->second << endl;
1108 foreach(
const set<int>::value_type cellID ,
_elemSet.at(0) ){
1113 multimap<int,int>::iterator it_multimap;
1116 _debugFile <<
"Boundary multimap = " << it_multimap->first <<
" " << it_multimap->second << endl;
1131 for (
int n = 0; n <
_nelems.at(
id); n++)
1134 multimap<int,int>::const_iterator it;
1169 vector< int* > elemGlobal;
1170 vector< int* > distGlobal;
1172 for (
int id = 0;
id <
_nmesh;
id++){
1177 distGlobal.push_back(
new int [
_nPart.at(
id) + 1 ] );
1178 int *offsets =
new int [
_nPart.at(
id) ];
1181 MPI::COMM_WORLD.Allgather(&
_nelemsWithGhosts.at(
id), 1, MPI::INT, distGlobal.at(
id), 1, MPI::INT);
1184 for (
int p = 1; p < int(
_nPart.at(
id)); p++ ){
1185 offsets[p] = distGlobal.at(
id)[p-1] + offsets[p-1];
1190 distGlobal.at(
id), offsets, MPI::INT);
1194 for (
int i =
int(
_nPart.at(
id)); i > 0; i--)
1195 distGlobal.at(
id)[i] = distGlobal.at(
id)[i-1];
1197 distGlobal.at(
id)[0] = 0;
1200 for (
int i = 1; i <
_nPart.at(
id)+1; i++ ){
1201 distGlobal.at(
id)[i] += distGlobal.at(
id)[i-1];
1221 while ( index <
_nPart.at(
id) ){
1222 for (
int n = distGlobal.at(
id)[index]; n < distGlobal.at(
id)[index+1]; n++){
1224 _cellParts.at(
id)->add(elemGlobal.at(
id)[n],index);
1235 vector< int* > ::iterator it_int;
1236 for ( it_int = elemGlobal.begin(); it_int != elemGlobal.end(); it_int++)
1239 for ( it_int = distGlobal.begin(); it_int != distGlobal.end(); it_int++)
1261 for (
int n = 0;n <
_cellParts.at(0)->getRowDim(); n++){
1262 _debugFile <<
" row[" << n <<
"] = " << rowCellParts[n] <<
" ";
1263 int nnodes = rowCellParts[n+1] - rowCellParts[n];
1264 for (
int node = 0; node < nnodes; node++){
1265 _debugFile << colCellParts[ rowCellParts[n] + node ] <<
" ";
1278 for (
int id = 0;
id <
_nmesh;
id++){
1304 for (
int n = 0; n <
_faceParts.at(0)->getRowDim();n++){
1306 int nnodes = rowFaceParts[n+1] - rowFaceParts[n];
1307 for (
int node = 0; node < nnodes; node++){
1308 _debugFile << colFaceParts[ rowFaceParts[n] + node ] <<
" ";
1326 vector< ArrayIntPtr > indices;
1328 for (
int id = 0;
id <
_nmesh;
id++){
1342 for (
int n = n_start; n < n_start + face_count; n++){
1343 (*indices.at(
id))[indx] = col[n];
1347 int cell_count =
_nelems.at(
id);
1371 _debugFile <<
"faceCells_faceNodes : " << endl;
1377 for (
int n = 0; n < globalToLocalMap.
getLength(); n++)
1378 _debugFile <<
" globalToLocalMap[" << n <<
"] = " << globalToLocalMap[n] << endl;
1381 for (
int n = 0; n <
_nelems.at(0); n++)
1382 _debugFile <<
" localToGlobalMap[" << n <<
"] = " << localToGlobalMap[n] << endl;
1391 for (
int face = 0; face <
_faceCells.at(0)->getRowDim(); face++){
1393 int ncells =
_faceCells.at(0)->getCount(face);
1394 for (
int cell = 0; cell < ncells; cell++){
1395 _debugFile << colFaceCells[ rowFaceCells[face] + cell ] <<
" ";
1407 for (
int face = 0; face <
_faceNodes.at(0)->getRowDim(); face++){
1409 int nnodes =
_faceNodes.at(0)->getCount(face);
1410 for (
int node = 0; node < nnodes; node++){
1411 _debugFile << colFaceNodes[ rowFaceNodes[face] + node ] <<
" ";
1417 _debugFile <<
" _cellNodes(Local Numbering) : " << endl;
1423 for (
int cell = 0; cell <
_cellNodes.at(0)->getRowDim(); cell++){
1425 int nnodes =
_cellNodes.at(0)->getCount(cell);
1426 for (
int node = 0; node < nnodes; node++){
1427 _debugFile << colCellNodes[ rowCellNodes[cell] + node ] <<
" ";
1439 for (
int cell = 0; cell <
_cellCells.at(0)->getRowDim(); cell++){
1440 _debugFile <<
" row[" << cell <<
"] = " <<
" ";
1441 int nnodes =
_cellCells.at(0)->getCount(cell);
1442 for (
int node = 0; node < nnodes; node++){
1443 _debugFile << colCellCells[ rowCellCells[cell] + node ] <<
" ";
1457 MPI::COMM_WORLD.Barrier();
1460 vector< int* > ::iterator it_int;
1461 for ( it_int =
_elem.begin(); it_int !=
_elem.end(); it_int++)
1472 for (
int id = 0;
id <
_nmesh;
id++){
1474 for (
int face = 0; face < nface; face++ ){
1476 if (
_faceParts.at(
id)->getCount(face_globalID) == 2 ){
1477 int neighPart = (*
_faceParts.at(
id))(face_globalID,0) +
1480 _interfaceMap.at(
id).insert( pair<int,int>(neighPart,face) );
1495 pair<multimap<int,int>::iterator,multimap<int,int>::iterator> ret;
1500 multimap<int,int>::iterator it_multimap;
1501 for (
int part = 0; part <
_nPart.at(0); part++ ){
1503 _debugFile <<
" interface ID = " << part <<
" => ";
1504 for (it_multimap=ret.first; it_multimap!=ret.second; ++it_multimap)
1519 for (
int id = 0;
id <
_nmesh;
id++){
1527 for (
int node = 0; node < node_count; node++)
1528 (*
_coord.at(
id))[node] = global_coord[ colPartNodes[rowPartNodes[
_procID]+node] ];
1544 for (
int node = 0; node < node_count; node++){
1546 _debugFile <<
" node ID = " <<setw(10)<< node << setprecision(7) <<
", x = " << (*
_coord.at(0))[node][0] <<
1547 setprecision(7) <<
", y = " << (*
_coord.at(0))[node][1] <<
1548 setprecision(7) <<
", z = " << (*
_coord.at(0))[node][2] << endl;
1567 for (
int id = 0;
id <
_nmesh;
id++ ){
1569 for (
int face = 0; face < nface_local; face++){
1572 if ( cell_0 >=
_nelems.at(
id) )
1574 if ( cell_1 >=
_nelems.at(
id) )
1589 set<int>::const_iterator it_set;
1591 _debugFile <<
"_nonInteriorCells : " << endl;
1613 set<int> globalCellList;
1615 for (
int i = 0; i < globalToLocalList.
getLength(); i++){
1616 if ( globalToLocalList[i] != -1 ){
1617 globalCellList.insert( i );
1622 foreach(
const set<int>::value_type globalID, globalCellList ){
1623 int localID = globalToLocalList[globalID];
1627 for (
int i = 0; i < localToGlobalList.
getLength(); i++ ){
1628 const int glblID = localToGlobalList[i];
1642 _debugFile <<
"_cellToPreservedOrderCell : " << endl;
1645 _debugFile << pos.first <<
" " << pos.second << endl;
1652 _debugFile <<
"glblID = " << pos.first <<
", localID = " << pos.second << endl;
1669 for (
int id = 0;
id <
_nmesh;
id++ ){
1685 for (
int face = 0; face < nface; face++){
1694 int array_length =
_faceCells.at(
id)->getLocalToGlobalMap().getLength();
1695 assert( array_length == tot_cells );
1699 for (
int face = 0; face < nface_local; face++){
1706 if ( is_interior ) {
1716 int globalID0 =
_faceCells.at(
id)->getLocalToGlobalMap()[cell_0];
1717 int globalID1 =
_faceCells.at(
id)->getLocalToGlobalMap()[cell_1];
1723 for (
int node = 0; node < count_node; node++ )
1732 int cellID = mpos.first;
1733 int global_id =
_faceCells.at(
id)->getLocalToGlobalMap()[cellID];
1735 int orderedCellID = mpos.second;
1744 multimap<int,int>::const_iterator it_cell;
1745 pair<multimap<int,int>::const_iterator,multimap<int,int>::const_iterator> it;
1746 set<int> ::const_iterator it_set;
1747 int offset = face_track;
1750 int bndryID = *it_set;
1754 _bndryOffsets.at(
id).insert( pair<int,int>(bndryID, offset) );
1756 for ( it_cell = it.first; it_cell != it.second; it_cell++ ){
1758 int elem_1 = (*
_cellCells.at(
id))(elem_0, 0);
1759 assert( elem_0 != elem_1 );
1761 int outer_elem = cellID;
1772 for (
int node = 0; node < count_node; node++)
1783 multimap<int,int>::const_iterator it_face;
1785 int interfaceID = *it_set;
1788 for ( it_face = it.first; it_face != it.second; it_face++ ){
1789 int face_id = it_face->second;
1790 int elem_0 = (*
_faceCells.at(
id))(face_id,0);
1791 int elem_1 = (*
_faceCells.at(
id))(face_id,1);
1792 int outer_elem_id = -1;
1796 outer_elem_id = elem_1;
1799 outer_elem_id = elem_0;
1804 int global_id =
_faceCells.at(
id)->getLocalToGlobalMap()[outer_elem_id];
1805 assert( cellID >=0 && cellID < array_length );
1812 if ( outer_elem_id == elem_1 ) {
1813 for (
int node = 0; node < count_node; node++)
1816 for (
int node = count_node-1; node >= 0; node--)
1829 assert( cellID == tot_cells );
1844 _debugFile <<
" _faceCellsOrdered : " << endl;
1852 for (
int cell = 0; cell < ncells; cell++){
1853 _debugFile << colFaceCellsOrdered[ rowFaceCellsOrdered[face] + cell ] <<
" ";
1860 _debugFile <<
" _faceNodesOrdered : " << endl;
1869 for (
int node = 0; node < nnodes; node++){
1870 _debugFile << colFaceNodesOrdered[ rowFaceNodesOrdered[face] + node ]+1 <<
" ";
1883 int dim =
_meshList.at(
id)->getDimension();
1884 int cellZoneId =
_meshList.at(
id)->getCellZoneID();
1895 int nGhostCell_local = tot_cells -
_nelems.at(
id);
1910 vector<int> interfaceMeshIDs;
1911 int *recv_counts = NULL;
1913 for (
int id = 0;
id <
_nmesh;
id++){
1914 recv_counts =
new int[
_nPart.at(
id) ];
1915 displ =
new int[
_nPart.at(
id) ];
1917 int total_interface_mesh = int(
_interfaceSet.at(
id).size() );
1920 MPI::COMM_WORLD.Allgather(&total_interface_mesh, 1, MPI::INT,
_interfaceMeshCounts.at(
id)->getData(), 1, MPI::INT);
1921 MPI::COMM_WORLD.Allgather(&total_faces, 1, MPI::INT,
_procTotalInterfaces.at(
id)->getData(), 1, MPI::INT);
1925 int total_interface_global = -1;
1927 MPI::COMM_WORLD.Allreduce( &total_interface_local, &total_interface_global, 1, MPI::INT, MPI::SUM );
1928 MPI::COMM_WORLD.Allgather( &total_interface_local, 1, MPI::INT, recv_counts, 1, MPI::INT );
1929 MPI::COMM_WORLD.Allreduce( &total_faces, &
_windowSize.at(
id), 1, MPI::INT, MPI::MAX);
1940 set<int>::const_iterator it_set;
1942 int neighMeshID = *it_set;
1943 interfaceMeshIDs.push_back( neighMeshID );
1946 offset.push_back( nstart );
1948 int nend = nstart +
_interfaceMap.at(
id).count( neighMeshID );
1949 for (
int n = nstart; n < nend; n++){
1961 for (
int i = 1; i <
_nPart.at(
id); i++)
1962 displ[i] = recv_counts[i-1] + displ[i-1];
1966 MPI::COMM_WORLD.Allgatherv( &offset[0], total_interface_local, MPI::INT,
1969 MPI::COMM_WORLD.Allgatherv( &interfaceMeshIDs[0], total_interface_local, MPI::INT,
1973 interfaceMeshIDs.clear();
1975 delete [] recv_counts;
1990 for (
int proc = 0; proc <
_nPart.at(0); proc++)
1995 _debugFile <<
" offset for ghost Cells from adjacent meshes to read data from _ghostCellsGlobal : " << endl;
2000 _debugFile <<
" neightboorhood cell IDs : " << endl;
2006 _debugFile <<
"interface cells looking interior domain (global numbering) : " << endl;
2011 _debugFile <<
"interface cells looking interior domain (local numbering) : " << endl;
2022 for (
int id = 0;
id <
_nmesh;
id++){
2030 set<int>::const_iterator it_set;
2031 int interfaceIndx = 0;
2034 int neighMeshID = *it_set;
2041 int window_displ = -1;
2043 _winLocal.Get (
_fromIndices.at(
id).at(interfaceIndx)->getData(), size, MPI::INT, neighMeshID, window_displ, size, MPI::INT );
2044 _winGlobal.Get(
_toIndices.at(
id).at(interfaceIndx)->getData() , size, MPI::INT, neighMeshID, window_displ, size, MPI::INT );
2056 int neighMeshID = *it_set;
2058 map<int, int> mapKeyCount;
2059 for (
int n = 0; n < size; n++){
2061 int key = (*
_toIndices.at(
id).at(interfaceIndx))[n];
2064 if ( mapKeyCount.count( key ) > 0 ) {
2065 mapKeyCount[key] = mapKeyCount[key] + 1;
2067 mapKeyCount.insert(pair<int,int>(key,0));
2070 multimap<int,int>::const_iterator it;
2072 for (
int n_iter = 0; n_iter < mapKeyCount[key]; n_iter++)
2075 int elem_id = it->second;
2076 (*
_toIndices.at(
id).at(interfaceIndx))[n] = elem_id;
2082 for (
int i = 0; i <
_fromIndices.at(
id).at(interfaceIndx)->getLength(); i++){
2083 int elem_id = (*
_toIndices.at(
id).at(interfaceIndx))[i];
2111 for (
int id = 0;
id < nmesh;
id++ ){
2117 bounCount += bounGroupList[i]->site.getCount();
2119 count += selfCount + bounCount;
2123 int *counts =
new int[
_nPart[0] ];
2125 MPI::COMM_WORLD.Allgather( &count, 1, MPI::INT, counts, 1, MPI::INT);
2129 for (
int i = 0; i <
_procID; i++ )
2130 offset += counts[i];
2145 shared_ptr<MultiField> cellMultiField = shared_ptr<MultiField>(
new MultiField() );
2146 shared_ptr<Field> cellField = shared_ptr<Field> (
new Field(
"globalcellID") );
2148 for (
int id = 0;
id < nmesh;
id++ ){
2153 cellMultiField->addArray(ai,cIndex);
2158 int offset = globalOffset;
2159 for (
int id = 0;
id < nmesh;
id++ ){
2167 for (
int i = 0; i < selfCount; i++ ){
2168 localCell[i] = offset + i;
2169 localCell[i] = localToGlobalMappers.find(i)->second;
2172 offset += selfCount;
2177 const int ibeg = bounGroupList[i]->site.getOffset();
2178 const int iend = ibeg + bounGroupList[i]->site.
getCount();
2180 for (
int ii = ibeg; ii < iend; ii++ ){
2181 const int cellID = faceCells(ii,1);
2182 localCell[ cellID] =localToGlobalMappers.find(cellID)->second ;
2186 offset += iend-ibeg;
2191 cellMultiField->sync();
2194 for (
int id = 0;
id < nmesh;
id++ ){
2201 for (
int i = 0; i < localCell.getLength(); i++ ){
2202 localToGlobal[i] = localCell[i];
2203 assert( localCell[i] != -1 );
2208 for (
int i = 0; i < localCell.getLength(); i++ ){
2209 globalToLocal[ localToGlobal[i] ] = i;
2230 for (
int id = 0;
id < nmesh;
id++ ){
2234 for (
int i = 0; i < localToGlobal.
getLength(); i++ ){
2235 _debugFile <<
" localToGlobal[" << i <<
"] = " << localToGlobal[i] << endl;
2238 for (
int id = 0;
id < nmesh;
id++ ){
2242 foreach (
const IntMap::value_type& mpos, globalToLocal ){
2243 _debugFile <<
" globalToLocal[" << mpos.first <<
"] = " << mpos.second << endl;
2256 for (
int id = 0;
id < nmesh;
id++ ){
2263 const int ncells = cellSite.
getCount();
2264 for (
int n = 0; n < ncells; n++ ){
2265 const int iend = cellCells.
getCount(n);
2267 for (
int i = 0; i < iend; i++ ){
2268 const int localCellID = cellCells(n,i);
2269 cellCellsGlobal.insert( pair<int,int>(n, localToGlobal[localCellID] ) );
2286 for (
int id = 0;
id <
_nmesh;
id++ ){
2292 const int scatterSize = 6 * int( (ndim == 2) ? pow(selfCount,0.5) : pow(selfCount,2.0/3.0) );
2294 vector<int> scatterBuffer;
2296 vector<int> cellCellsBuffer;
2298 vector<int> cellCellsCountBuffer;
2300 scatterBuffer.reserve ( scatterSize );
2301 cellCellsCountBuffer.reserve( scatterSize );
2302 cellCellsBuffer.reserve ( 6*scatterSize);
2311 const int ibeg = faceGroupList[i]->site.getOffset();
2312 const int iend = ibeg + faceGroupList[i]->site.getCount();
2313 for (
int i = ibeg; i < iend; i++ ){
2314 const int localCellID = faceCells(i,0);
2315 const int globalCellID = localToGlobal[ localCellID ];
2316 scatterBuffer.push_back(globalCellID);
2318 for (
int j = 0; j < cellCells.
getCount(localCellID); j++ ){
2319 const int nextcellID = localToGlobal[ cellCells(localCellID,j) ];
2320 cellCellsBuffer.push_back(nextcellID);
2323 cellCellsCountBuffer.push_back(indx);
2330 int scatterGlobalSize;
2331 int cellCellsGlobalSize;
2332 int cellCellsCountGlobalSize;
2333 int sendbuffer = int( scatterBuffer.size() );
2334 MPI::COMM_WORLD.Allreduce( &sendbuffer, &scatterGlobalSize, 1, MPI::INT, MPI::SUM );
2335 sendbuffer = int( cellCellsBuffer.size() );
2336 MPI::COMM_WORLD.Allreduce( &sendbuffer, &cellCellsGlobalSize, 1, MPI::INT, MPI::SUM );
2337 sendbuffer = int( cellCellsCountBuffer.size() );
2338 MPI::COMM_WORLD.Allreduce( &sendbuffer, &cellCellsCountGlobalSize, 1, MPI::INT, MPI::SUM );
2343 int *recv_counts =
new int[
_nPart.at(
id) ];
2344 int sendcount = int( scatterBuffer.size() );
2345 MPI::COMM_WORLD.Allgather( &sendcount, 1, MPI::INT, recv_counts, 1, MPI::INT );
2347 int *displ =
new int[
_nPart.at(
id) ];
2349 for (
int i = 1; i <
_nPart.at(
id); i++)
2350 displ[i] = recv_counts[i-1] + displ[i-1];
2352 MPI::COMM_WORLD.Allgatherv( &scatterBuffer[0], sendcount , MPI::INT,
2353 scatterCellsGlobal->getData(), recv_counts, displ, MPI::INT);
2356 shared_ptr< Array<int> > cellCellsCountGlobal =
ArrayIntPtr(
new Array<int>(cellCellsCountGlobalSize ) );
2357 sendcount = int( cellCellsCountBuffer.size() );
2358 MPI::COMM_WORLD.Allgather( &sendcount, 1, MPI::INT, recv_counts, 1, MPI::INT );
2361 for (
int i = 1; i <
_nPart.at(
id); i++)
2362 displ[i] = recv_counts[i-1] + displ[i-1];
2364 MPI::COMM_WORLD.Allgatherv( &cellCellsCountBuffer[0], sendcount , MPI::INT,
2365 cellCellsCountGlobal->getData(), recv_counts, displ, MPI::INT);
2369 sendcount = int( cellCellsBuffer.size() );
2370 MPI::COMM_WORLD.Allgather( &sendcount, 1, MPI::INT, recv_counts, 1, MPI::INT );
2373 for (
int i = 1; i <
_nPart.at(
id); i++)
2374 displ[i] = recv_counts[i-1] + displ[i-1];
2376 MPI::COMM_WORLD.Allgatherv( &cellCellsBuffer[0], sendcount , MPI::INT,
2377 cellCellsGlobal->getData(), recv_counts, displ, MPI::INT);
2382 map<int,int> cellPointer;
2383 map<int,int> locaterIndx;
2384 int pointerIndx = 0;
2385 for (
int i = 0; i < scatterGlobalSize; i++ ){
2386 const int cellID = (*scatterCellsGlobal )[i];
2387 const int count = (*cellCellsCountGlobal)[i];
2388 cellPointer[cellID] = pointerIndx;
2389 pointerIndx += count;
2390 locaterIndx[cellID] = i;
2397 const int ibeg = faceGroupList[i]->site.getOffset();
2398 const int iend = ibeg + faceGroupList[i]->site.getCount();
2399 for (
int i = ibeg; i < iend; i++ ){
2400 const int localCellID = faceCells(i,1);
2401 const int globalCellID = localToGlobal[localCellID ];
2402 const int count = (*cellCellsCountGlobal)[ locaterIndx[globalCellID] ];
2403 const int offset = cellPointer[globalCellID];
2405 cellCellsMap.erase( localCellID );
2408 for (
int j = 0; j < count; j++ ){
2409 const int cellID = (*cellCellsGlobal)[offset+j];
2411 cellCellsMap.insert( pair<int,int>(localCellID,cellID) );
2415 delete [] recv_counts;
2428 for (
int id = 0 ;
id <
_nmesh ;
id++ ){
2432 const int ncells = cellSite.
getCount();
2435 for (
int n = 0; n < ncells; n++ ){
2436 _debugFile <<
" localCellID = " << n <<
" itself and cells around (global number) = ";
2437 multimap<int,int>::const_iterator it;
2438 for ( it = cellCellsGlobal.equal_range(n).first; it != cellCellsGlobal.equal_range(n).second; it++ ){
2453 for (
int id = 0;
id <
_nmesh;
id++ ){
2454 set<int> cellsLevel1;
2465 nboun += bounGroupList[n]->site.getCount();
2468 const int countNonGhostCells = selfCount + nboun;
2472 foreach (
const Mesh::GhostCellSiteMap::value_type& mpos, ghostCellSiteScatterMap ){
2474 const Array<int>& scatterArray = *(cellScatterMap.find( &siteScatter )->second);
2476 for (
int i = 0; i < siteScatter.
getCount(); i++){
2477 const int cellID0 = scatterArray[i];
2478 cellsLevel1.insert( localToGlobal[cellID0] );
2479 const int jj = cellCells.
getCount(cellID0);
2481 for (
int j = 0; j < jj; j++ ){
2484 const int cellID1 = cellCells(cellID0,j);
2485 if ( cellID1 < countNonGhostCells ){
2486 cellsLevel1.insert(localToGlobal[cellID1]);
2493 set <int>::const_iterator it = cellsLevel1.begin();
2494 for (
int i = 0; i < cellsLevel1Array->getLength(); i++){
2495 (*cellsLevel1Array)[i] = *it;
2499 int cellsLevel1GlobalSize = 0;
2500 int sendbuffer = int( cellsLevel1.size() );
2501 MPI::COMM_WORLD.Allreduce( &sendbuffer, &cellsLevel1GlobalSize, 1, MPI::INT, MPI::SUM );
2505 int *recv_counts =
new int[
_nPart.at(
id) ];
2506 int sendcount = int( cellsLevel1.size() );
2507 MPI::COMM_WORLD.Allgather( &sendcount, 1, MPI::INT, recv_counts, 1, MPI::INT );
2509 int *displ =
new int[
_nPart.at(
id) ];
2511 for (
int i = 1; i <
_nPart.at(
id); i++)
2512 displ[i] = recv_counts[i-1] + displ[i-1];
2514 MPI::COMM_WORLD.Allgatherv( cellsLevel1Array->getData(), sendcount , MPI::INT,
2515 cellsLevel1Global->getData(), recv_counts, displ, MPI::INT);
2519 int indx = recv_counts[0];
2520 for (
int i = 0; i < cellsLevel1Global->getLength(); i++ ){
2522 if ( (i == indx-1) && (procid <
_nPart.at(
id)-1) ){
2524 indx += recv_counts[++procid];
2528 delete [] recv_counts;
2546 const int globalID = mpos.first;
2547 const int partID = mpos.second;
2548 _debugFile <<
" global CellID = " << globalID <<
" partition ID = " << partID << endl;
2558 for (
int id = 0;
id <
_nmesh;
id++ ){
2567 const int ibeg = faceGroupList[i]->site.getOffset();
2568 const int iend = ibeg + faceGroupList[i]->site.getCount();
2569 for (
int i = ibeg; i < iend; i++ ){
2570 const int localCellID = faceCells(i,1);
2571 multimap<int,int>::const_iterator it;
2572 for ( it = cellCellsMap.equal_range(localCellID).first; it != cellCellsMap.equal_range(localCellID).second; it++){
2580 const int ibeg = faceGroupList[i]->site.getOffset();
2581 const int iend = ibeg + faceGroupList[i]->site.getCount();
2582 for (
int i = ibeg; i < iend; i++ ){
2606 const int globalID = mpos.first;
2607 const int partID = mpos.second;
2608 _debugFile <<
" global CellID = " << globalID <<
" partition ID = " << partID << endl;
2620 for (
int id = 0;
id <
_nmesh;
id++ ){
2623 map<int, vector<int> > gatherArrays;
2625 const int globalID = mpos.first;
2626 const int partID = mpos.second;
2627 gatherArrays[partID].push_back( globalID );
2630 vector<int> gatherProcs;
2632 foreach(
const VectorMap::value_type& pos, gatherArrays){
2633 gatherProcs.push_back( pos.first);
2638 int gatherProcsCount = gatherArrays.size();
2639 MPI::COMM_WORLD.Allgather(&gatherProcsCount, 1, MPI::INT, globalGatherProcsCount.
getData(), 1, MPI::INT);
2644 for (
int p = 1; p < int(
_nPart.at(
id)); p++ ){
2645 offsets[p] = globalGatherProcsCount[p-1] + offsets[p-1];
2648 int globalBufferSize = 0;
2649 for (
int i = 0; i < globalGatherProcsCount.getLength(); i++ ){
2650 globalBufferSize += globalGatherProcsCount[i];
2652 Array<int> globalGatherProcs( globalBufferSize );
2654 MPI::COMM_WORLD.Allgatherv(&gatherProcs[0], gatherProcs.size(), MPI::INT, globalGatherProcs.
getData(),
2655 (
const int *) globalGatherProcsCount.getData(), (
const int *)offsets.
getData(), MPI::INT);
2658 list<int> scatterProcs;
2659 for (
int i = 0; i <
_nPart.at(
id); i++ ){
2660 for (
int j = 0; j < globalGatherProcsCount[i]; j++ ){
2661 const int gatherProcID = globalGatherProcs[ offsets[i]+j];
2662 if (
_procID == gatherProcID )
2663 scatterProcs.push_back( i );
2669 MPI::Request request_send[ gatherArrays.size() ];
2672 foreach(
const VectorMap::value_type pos, gatherArrays){
2673 int to_where = pos.first;
2674 int count = int( gatherArrays[to_where].size() );
2675 int send_tag = 112233;
2676 request_send[indxSend++] =
2677 MPI::COMM_WORLD.Isend( &gatherArrays[to_where][0], count, MPI::INT, to_where, send_tag );
2681 map<int, vector<int> > scatterArrays;
2682 list<int>::iterator it;
2683 while ( !scatterProcs.empty() ){
2684 for( it = scatterProcs.begin(); it != scatterProcs.end(); ++it ){
2685 int from_where = *it;
2686 int recv_tag = 112233;
2687 MPI::Status recv_status;
2688 if( MPI::COMM_WORLD.Iprobe(from_where, recv_tag, recv_status) ){
2690 int scatter_count = recv_status.Get_count( MPI::INT );
2692 scatterArrays[from_where].resize( scatter_count);
2693 scatterProcs.remove(from_where);
2702 MPI::Request request_recv[ scatterArrays.size() ];
2703 foreach(
const VectorMap::value_type& pos, scatterArrays){
2704 int from_where = pos.first;
2705 int recv_count = int(scatterArrays[from_where].size());
2706 int recv_tag = 112233;
2707 request_recv[indxRecv++] =
2708 MPI::COMM_WORLD.Irecv( &scatterArrays[from_where][0], recv_count, MPI::INT, from_where, recv_tag );
2711 int countScatter = scatterArrays.size();
2712 int countGather = gatherArrays.size();
2713 MPI::Request::Waitall( countScatter, request_recv );
2714 MPI::Request::Waitall( countGather, request_send );
2719 map<int,int>& globalToLocal =
_meshListLocal.at(
id)->getGlobalToLocal();
2722 foreach (
const VectorMap::value_type& pos, scatterArrays ){
2723 const int toProcID = pos.first;
2724 const vector<int>& scatter_array = pos.second;
2725 const int scatterSize = int( scatter_array.size() );
2729 for (
int i = 0; i < scatterSize; i++ ){
2730 (*from_indices)[i] = globalToLocal[ scatter_array[i] ];
2734 shared_ptr<StorageSite> siteScatter(
new StorageSite(scatterSize) );
2736 siteScatter->setScatterProcID(
_procID );
2737 siteScatter->setGatherProcID ( toProcID );
2741 siteScatter->setTag( packed_info );
2743 _meshListLocal.at(
id)->createGhostCellSiteScatterLevel1( pairID, siteScatter );
2744 cellScatterMapLevel1[ siteScatter.get() ] = from_indices;
2747 int gatherIndx = cellSite.
getCount();
2749 foreach (
const VectorMap::value_type& pos, gatherArrays ){
2750 const int fromProcID = pos.first;
2751 const vector<int>& gather_array = pos.second;
2752 const int gatherSize = int( gather_array.size() );
2756 for (
int i = 0; i < gatherSize; i++ ){
2757 (*to_indices)[i] = gatherIndx;
2758 globalToLocal[gather_array[i]] = gatherIndx;
2763 shared_ptr<StorageSite> siteGather (
new StorageSite(gatherSize ) );
2765 siteGather->setScatterProcID(
_procID );
2766 siteGather->setGatherProcID ( fromProcID );
2769 siteGather->setTag( packed_info );
2771 _meshListLocal.at(
id)->createGhostCellSiteGatherLevel1 ( pairID, siteGather );
2772 cellGatherMapLevel1 [ siteGather.get() ] = to_indices;
2803 for (
int i = 0; i < nodes.
getCount(); i++ ){
2805 localToGlobalNodes[i] = globalID;
2809 set<int>& boundaryNodeSet =
_meshListLocal.at(
id)->getBoundaryNodesSet();
2813 const int nFaces = faces.
getCount();
2815 for(
int f=0; f<nFaces; f++){
2816 const int nFaceNodes = faceNodes.
getCount(f);
2817 for(
int nn=0; nn<nFaceNodes; nn++){
2818 const int n=faceNodes(f,nn);
2819 boundaryNodeSet.insert(n);
2862 const int nodeCount = nodes.
getCount();
2865 globalToLocalNodes = -1;
2866 int bMeshNodeCount=0;
2867 int bMeshFaceCount=0;
2871 const int nFaces = faces.
getCount();
2873 for(
int f=0; f<nFaces; f++){
2874 const int nFaceNodes = faceNodes.
getCount(f);
2875 for(
int nn=0; nn<nFaceNodes; nn++){
2876 const int n=faceNodes(f,nn);
2877 if (globalToLocalNodes[n] == -1){
2878 globalToLocalNodes[n] = bMeshNodeCount++;
2882 bMeshFaceCount += nFaces;
2889 bMeshFaces.
setCount( bMeshFaceCount );
2890 bMeshNodes.
setCount( bMeshNodeCount );
2897 shared_ptr<Mesh::IntArray> myCommonNodes(
new Mesh::IntArray(bMeshNodeCount));
2898 shared_ptr<Mesh::IntArray> otherCommonNodes(
new Mesh::IntArray(bMeshNodeCount));
2899 for(
int n=0; n<nodeCount; n++)
2901 const int nLocal = globalToLocalNodes[n];
2904 (*bMeshCoordPtr)[nLocal] = coords[n];
2905 (*myCommonNodes)[nLocal] = nLocal;
2906 (*otherCommonNodes)[nLocal] = n;
2909 nodesLocal.
getCommonMap()[&bMeshNodes] = myCommonNodes;
2910 bMeshNodes.
getCommonMap()[&nodesLocal] = otherCommonNodes;
2912 map<int,int>& scatterIndex = nodesLocal.
getScatterIndex()[&bMeshNodes];
2913 for (
int n = 0; n < bMeshNodeCount; n++ ){
2914 const int nodeID = (*otherCommonNodes)[n];
2915 scatterIndex[nodeID] = n;
2923 shared_ptr<CRConnectivity> bFaceNodes(
new CRConnectivity(bMeshFaces,
2926 bFaceNodes->initCount();
2933 const int nFaces = faces.
getCount();
2936 shared_ptr<Mesh::IntArray> myCommonFaces(
new Mesh::IntArray(nFaces));
2937 shared_ptr<Mesh::IntArray> otherCommonFaces(
new Mesh::IntArray(nFaces));
2939 for(
int f=0; f<nFaces; f++){
2940 const int nFaceNodes = faceNodes.
getCount(f);
2941 bFaceNodes->addCount(bMeshFaceCount,nFaceNodes);
2942 (*myCommonFaces)[f] = bMeshFaceCount;
2943 (*otherCommonFaces)[f] = f;
2948 bMeshFaces.getCommonMap()[&faces] = otherCommonFaces;
2951 bFaceNodes->finishCount();
2957 const int nFaces = faces.
getCount();
2959 for(
int f=0; f<nFaces; f++){
2960 const int nFaceNodes = faceNodes.
getCount(f);
2961 for(
int nn=0; nn<nFaceNodes; nn++){
2962 const int n=faceNodes(f,nn);
2963 const int nLocal = globalToLocalNodes[n];
2964 bFaceNodes->add(bMeshFaceCount,nLocal);
2970 bFaceNodes->finishAdd();
2974 connectivityMap[key] = bFaceNodes;
2988 for (
int id = 0;
id <
_nmesh;
id++ ){
2994 _debugFile <<
"This Mesh ID (Scatter Cells) = " <<
id << endl;
2996 foreach (
const Mesh::GhostCellSiteMap::value_type& mpos, ghostSiteScatterMapLevel1 ){
2999 const Array<int>& scatterArray = *(cellSiteScatterMapLevel1.find( &siteScatter )->second);
3000 const int neighProcID = pairID.first;
3001 const int neighMeshID = pairID.second;
3002 _debugFile <<
" neighProcID = " << neighProcID <<
" neighMeshID = " << neighMeshID << endl;
3003 for (
int i = 0; i < scatterArray.
getLength(); i++ ){
3004 _debugFile <<
" " << scatterArray[i] << endl;
3010 for (
int id = 0;
id <
_nmesh;
id++ ){
3016 _debugFile <<
"This Mesh ID (Gather Cells) = " <<
id << endl;
3018 foreach (
const Mesh::GhostCellSiteMap::value_type& mpos, ghostSiteGatherMapLevel1 ){
3021 const Array<int>& gatherArray = *(cellSiteGatherMapLevel1.find( &siteGather )->second);
3022 const int neighProcID = pairID.first;
3023 const int neighMeshID = pairID.second;
3024 _debugFile <<
" neighProcID = " << neighProcID <<
" neighMeshID = " << neighMeshID << endl;
3025 for (
int i = 0; i < gatherArray.
getLength(); i++ ){
3057 MPI::COMM_WORLD.Barrier();
3066 int window_displ = 0;
3067 for (
int i = 0; i < neigh_mesh_id; i++)
3076 return window_displ;
3082 int int_size = MPI::INT.Get_size();
3083 MPI::Aint lb, sizeofAint;
3084 MPI::INT.Get_extent(lb,sizeofAint);
3088 MPI_INFO_NULL, MPI::COMM_WORLD);
3090 MPI_INFO_NULL, MPI::COMM_WORLD);
3127 ss <<
"mesh_proc" <<
_procID <<
"_info.dat";
3128 ofstream
mesh_file( (ss.str()).c_str() );
3129 for (
int id = 0;
id <
_nmesh;
id++ ){
3136 Mesh::GhostCellSiteMap::const_iterator it_ghostScatter;
3138 for ( it_ghostScatter = ghostCellSiteScatterMap.begin(); it_ghostScatter != ghostCellSiteScatterMap.end(); it_ghostScatter++ ){
3140 int neighID = pairID.first;
3142 const StorageSite& siteScatter = *( ghostCellSiteScatterMap.find( pairID )->second );
3143 const StorageSite& siteGather = *( ghostCellSiteGatherMap.find ( pairID )->second );
3146 const Array<int>& scatterArray = *(cellScatterMap.find( &siteScatter )->second);
3147 const Array<int>& gatherArray = *(cellGatherMap.find ( &siteGather )->second);
3148 for (
int i = 0; i < siteScatter.
getCount(); i++){
3149 mesh_file <<
" neightMeshID = " << neighID <<
" "
3150 << gatherArray[i] + 1 <<
" ===> "
3151 << scatterArray[i] + 1 << endl;
3167 ss <<
"mesh_proc" <<
_procID <<
".dat";
3168 ofstream
mesh_file( (ss.str()).c_str() );
3176 mesh_file <<
"title = \" tecplot file for process Mesh \" " << endl;
3177 mesh_file <<
"variables = \"x\", \"y\", \"z\", \"cell_type\" " << endl;
3179 mesh_file <<
"variables = \"x\", \"y\", \"z\", \"cell_type\", \"color\" " << endl;
3182 stringstream zone_info;
3185 zone_info <<
" DATAPACKING = BLOCK, VARLOCATION = ([4]=CELLCENTERED), ZONETYPE=FETRIANGLE ";
3188 zone_info <<
" DATAPACKING = BLOCK, VARLOCATION = ([4]=CELLCENTERED), ZONETYPE=FEQUADRILATERAL ";
3191 zone_info <<
" DATAPACKING = BLOCK, VARLOCATION = ([4]=CELLCENTERED), ZONETYPE=FEBRICK ";
3194 zone_info <<
" DATAPACKING = BLOCK, VARLOCATION = ([4]=CELLCENTERED), ZONETYPE=FETETRAHEDRON ";
3197 mesh_file <<
"zone N = " << tot_nodes <<
" E = " << tot_elems << zone_info.str() << endl;
3200 for (
int n = 0; n < tot_nodes; n++){
3201 mesh_file << scientific << coord[n][0] <<
" " ;
3207 for (
int n= 0; n < tot_nodes; n++){
3208 mesh_file << scientific << coord[n][1] <<
" ";
3214 for (
int n = 0; n < tot_nodes; n++){
3215 mesh_file << scientific << coord[n][2] <<
" ";
3223 for (
int n = 0; n < tot_elems; n++){
3240 const Array<int>& color = mesh.getCellColors();
3241 for (
int n = 0; n < tot_elems; n++ ){
3250 for (
int n = 0; n < tot_elems; n++){
3251 int nnodes = cellNodes.
getCount(n);
3253 for (
int node = 0; node < nnodes; node++)
3254 mesh_file << cellNodes(n,node)+1 <<
" ";
3258 mesh_file << cellNodes(n,0)+1 <<
" " << cellNodes(n,1)+1 <<
3259 " " << cellNodes(n,0)+1 <<
" ";
3262 mesh_file << cellNodes(n,0)+1 <<
" " << cellNodes(n,0)+1 <<
3263 " " << cellNodes(n,1)+1 <<
" " << cellNodes(n,1)+1 <<
" ";
3266 mesh_file << cellNodes(n,0)+1 <<
" " << cellNodes(n,1)+1 <<
" "
3267 << cellNodes(n,2)+1 <<
" " << cellNodes(n,3)+1 <<
" "
3268 << cellNodes(n,0)+1 <<
" " << cellNodes(n,1)+1 <<
" "
3269 << cellNodes(n,2)+1 <<
" " << cellNodes(n,3)+1 <<
" ";
3272 mesh_file << cellNodes(n,0)+1 <<
" " << cellNodes(n,1)+1 <<
3273 " " << cellNodes(n,2)+1 <<
" " << cellNodes(n,0)+1 <<
" ";
3288 int nprocs = MPI::COMM_WORLD.Get_size();
3290 mesh_file <<
"<?xml version='1.0' ?>" << endl;
3291 mesh_file <<
"<!DOCTYPE Xdmf SYSTEM 'Xdmf.dtd' []>" << endl;
3292 mesh_file <<
"<Xdmf xmlns:xi='http://www.w3.org/2001/XInclude' Version='2.0'>" << endl;
3293 mesh_file <<
" <Domain>" << endl;
3294 for (
int i=0; i < nprocs; i++)
3295 mesh_file <<
" <xi:include href='mesh_proc" << i <<
".xmf' />" << endl;
3296 mesh_file <<
" </Domain>" << endl;
3297 mesh_file <<
"</Xdmf>" << endl;
3312 ss <<
"mesh_proc" <<
_procID <<
".xmf";
3313 ofstream
mesh_file( (ss.str()).c_str() );
3318 int tot_elems =
_nelems.at(0);
3322 mesh_file <<
"<Grid Name='Mesh-" << _procID <<
"' GridType='Uniform'>" << endl <<
" ";
3326 mesh_file <<
"<Topology TopologyType='Triangle'";
3330 mesh_file <<
"<Topology TopologyType='Quadrilateral'";
3334 mesh_file <<
"<Topology TopologyType='Hexahedron'";
3338 mesh_file <<
"<Topology TopologyType='Tetrahedron'";
3342 cout <<
"Unknown mesh type " <<
_eType.at(0) << endl;
3345 mesh_file <<
" Dimensions='" << tot_elems <<
"'>" << endl;
3346 mesh_file <<
" <DataItem Dimensions='" << tot_elems <<
" " << epn <<
"'>" << endl;
3349 for (
int n = 0; n < tot_elems; n++) {
3351 for (
int node = 0; node < cellNodes.
getCount(n); node++)
3359 mesh_file <<
" <Geometry Type='XYZ'>" << endl;
3360 mesh_file <<
" <DataItem Dimensions='" << tot_nodes <<
" 3' NumberType='Float'>" << endl;
3361 for (
int n = 0; n < tot_nodes; n++) {
3379 if ( MPI::COMM_WORLD.Get_rank() == procID ){
3380 cout << name <<
" :" << endl;
3383 for (
int i = 0; i < row.
getLength()-1; i++ ){
3384 cout <<
" i = " << i <<
", ";
3385 for (
int j = row[i]; j < row[i+1]; j++ )
3386 cout << col[j] <<
" ";
3401 for (
int i = 0; i < row.
getLength()-1; i++ ){
3403 for (
int j = row[i]; j < row[i+1]; j++ )
3413 stringstream ss(stringstream::in | stringstream::out);
3416 string fname =
"MeshPartitioner_PROC" + ss.str() +
"_" + fname_ +
".dat";
void DEBUG_parmetis_mesh()
const FaceGroupList & getBoundaryFaceGroups() const
const Array< int > & getCol() const
int getCount(const int i) const
vector< StorageSitePtr > _faceSite
void debug_file_open(const string &fname)
const Array< int > & getRow() const
vector< map< int, int > > _bndryOffsets
int getBoundaryGroupCount() const
shared_ptr< FaceGroup > FaceGroupPtr
void CRConnectivityPrintFile(const CRConnectivity &conn, const string &name)
vector< CRConnectivityPtr > _cellCells
vector< multimap< int, int > > _globalToLocalMappers
const Array< int > & getGlobalToLocalMap() const
void setWeightType(int weight_type)
void set_eptr_eind(int id)
void DEBUG_faceCells_faceNodes()
vector< ArrayVecD3Ptr > _coord
vector< int > _ncommonNodes
vector< ArrayIntPtr > _interfaceMeshCounts
vector< StorageSitePtr > _nodeSite
vector< CRConnectivityPtr > _partFaces
vector< CRConnectivityPtr > _faceParts
void mapBounIDAndCell(int id)
vector< ArrayIntPtr > _interfaceMeshIDs
vector< int * > _elemWithGhosts
const StorageSite & getNodes() const
void DEBUG_exchange_interface_meshes()
void DEBUG_compute_elem_dist()
void exchange_part_elems()
vector< set< int > > _elemSet
void DEBUG_preserve_cell_order()
void reorder(const Array< int > &indices)
void DEBUG_elem_connectivity()
const ScatterIndex & getScatterIndex() const
multiMap & getCellCellsGlobal()
shared_ptr< StorageSite > StorageSitePtr
ConnectivityMap & getConnectivityMap()
const GatherMap & getGatherMapLevel1() const
const ScatterMap & getScatterMapLevel1() const
void DEBUG_CRConnectivity_faceParts()
void setCoordinates(shared_ptr< Array< VecD3 > > x)
void non_interior_cells()
double max(double x, double y)
void set_cellcells_global()
const CRConnectivity & getFaceNodes(const StorageSite &site) const
const CommonMap & getCommonMap() const
void order_faceCells_faceNodes()
int get_local_nodes(int id)
int count_interior_faces(int id)
void globalCellID_procID_map()
void setCount(const int selfCount, const int nGhost=0)
vector< ArrayIntPtr > _procTotalInterfaces
vector< set< int > > _interfaceSet
void DEBUG_CRConnectivity_cellCells2()
vector< map< int, int > > _localToGlobalMappers
map< int, int > & getGlobalToLocal()
vector< CRConnectivityPtr > _partCells
int getInterfaceGroupCount() const
multimap< int, int > multiMap
void cleanup_follow_exchange_part_elems()
void gatherCellsLevel1_partID_map()
const StorageSite & createBoundaryFaceGroup(const int size, const int offset, const int id, const string &boundaryType)
vector< Array< int > * > _globalIndx
shared_ptr< Array< Mesh::VecD3 > > ArrayVecD3Ptr
vector< StorageSitePtr > _cellSite
void CRConnectivityPrint(const CRConnectivity &conn, int procID, const string &name)
const Array< int > & getLocalToGlobalMap() const
const CRConnectivity & getAllFaceCells() const
void CRConnectivity_faceParts()
void DEBUG_count_elems_part()
map< SSPair, shared_ptr< CRConnectivity > > ConnectivityMap
vector< CRConnectivityPtr > _faceNodes
vector< CRConnectivityPtr > _partNodes
void exchange_interface_meshes()
void DEBUG_CRConnectivity_cellParts()
const Array< VecD3 > & getNodeCoordinates() const
Array< int > & getLocalToGlobal()
virtual void * getData() const
pair< const Field *, const StorageSite * > ArrayIndex
void DEBUG_mapBounIDAndCell()
void resize(const int newLength)
void DEBUG_globalCellID_procID_map()
vector< StorageSitePtr > _partSite
void cleanup_follow_mappers()
void DEBUG_non_interior_cells()
vector< StorageSitePtr > _cellSiteGlobal
vector< ArrayIntPtr > _offsetInterfaceCells
map< int, int > _cellToPreservedOrderCell
vector< FaceGroupPtr > FaceGroupList
pair< const StorageSite *, const StorageSite * > SSPair
map< PartIDMeshIDPair, shared_ptr< StorageSite > > GhostCellSiteMap
void DEBUG_fiedler_partition()
void DEBUG_local_global()
shared_ptr< CRConnectivity > CRConnectivityPtr
void setCellZoneID(const int id)
pair< int, int > PartIDMeshIDPair
const StorageSite & getFaces() const
vector< set< int > > _boundarySet
const CRConnectivity & getCellCells() const
vector< map< int, int > > _interfaceOffsets
const StorageSite & getCells() const
map< int, int > _globalToLocal
vector< Array< int > * > _elemDist
void createLocalGlobalArray()
vector< const CRConnectivity * > _faceNodesGlobal
void preserve_cell_order()
void DEBUG_exchange_part_elems()
void DEBUG_gatherCellsLevel1_partID_map()
int getCountLevel1() const
void cellcells_global_extension()
const GhostCellSiteMap & getGhostCellSiteScatterMapLevel1() const
const ScatterMap & getScatterMap() const
map< const StorageSite *, shared_ptr< Array< int > > > ScatterMap
GhostCellSiteMap & getGhostCellSiteGatherMapLevel1()
vector< CRConnectivityPtr > _faceNodesOrdered
void DEBUG_level1_scatter_gather_cells()
MeshPartitioner(const MeshList &mesh_list, vector< int > npart, vector< int > eType)
vector< set< int > > _nonInteriorCells
void extractBoundaryMesh()
vector< int > _windowSize
void DEBUG_order_faceCells_faceNodes()
vector< CRConnectivityPtr > _faceCellsOrdered
vector< multimap< int, int > > _mapPartAndElms
int get_window_displ(int id, int neigh_mesh_id)
void faceCells_faceNodes()
shared_ptr< Array< int > > ArrayIntPtr
vector< vector< ArrayIntPtr > > _toIndices
vector< map< int, string > > _mapBounIDAndBounType
vector< int > _totElemsAndGhosts
vector< CRConnectivityPtr > _cellNodes
map< const StorageSite *, shared_ptr< Array< int > > > GatherMap
void CRConnectivity_cellParts()
void DEBUG_map_part_elms()
const FaceGroupList & getInterfaceGroups() const
vector< Mesh * > _meshListLocal
vector< multimap< int, int > > _mapBounIDAndCell
map< int, int > _cellsLevel1PartID
void construct_mesh(int id)
double min(double x, double y)
void create_window(int id)
vector< vector< int > > _cellToOrderedCell
map< int, int > _gatherCellsLevel1PartIDMap
void DEBUG_cellcells_global()
void setCountLevel1(const int countLevel1)
void level1_scatter_gather_cells()
vector< ArrayIntPtr > _ghostCellsLocal
vector< CRConnectivityPtr > _faceCells
vector< CRConnectivityPtr > _cellParts
vector< multimap< int, int > > _interfaceMap
vector< float * > _tpwgts
const CRConnectivity & getCellNodes() const
const GhostCellSiteMap & getGhostCellSiteScatterMap() const
void fiedler_order(const string &fname)
void cleanup_follow_faceCells_faceNodes()
void setNumFlag(int num_flag)
vector< int > _nelemsWithGhosts
vector< Mesh * > MeshList
vector< vector< ArrayIntPtr > > _fromIndices
vector< const CRConnectivity * > _faceCellsGlobal
vector< ArrayIntPtr > _ghostCellsGlobal