25 _meshList(mesh_list), _nPart(nPart), _eType(eType), _options(0)
27 if ( !MPI::Is_initialized() ) MPI::Init();
36 MPI::COMM_WORLD.Barrier();
38 vector< Array<int>* > ::iterator it_array;
46 vector< int* > ::iterator it_int;
47 for ( it_int =
_ePtr.begin(); it_int !=
_ePtr.end(); it_int++)
50 for ( it_int =
_eInd.begin(); it_int !=
_eInd.end(); it_int++)
53 for ( it_int =
_eElm.begin(); it_int !=
_eElm.end(); it_int++)
59 for ( it_int =
_row.begin(); it_int !=
_row.end(); it_int++)
62 for ( it_int =
_col.begin(); it_int !=
_col.end(); it_int++)
65 for ( it_int =
_elem.begin(); it_int !=
_elem.end(); it_int++)
69 vector< float* > ::iterator it_float;
70 for ( it_float =
_tpwgts.begin(); it_float !=
_tpwgts.end(); it_float++)
73 for ( it_float =
_ubvec.begin(); it_float !=
_ubvec.end(); it_float++)
75 vector< int* > ::iterator it_int;
76 for ( it_int =
_part.begin(); it_int !=
_part.end(); it_int++)
85 vector< Mesh* >::iterator it_mesh;
132 MPI::COMM_WORLD.Barrier();
142 for (
int n = 0; n < tot_elems; n++ ){
144 cout <<
" elem = " << n <<
", ";
145 for (
int node = 0; node < nnodes; node++ )
146 cout << cellNodes(n,node) <<
" ";
153 for (
int node = 0; node < tot_nodes; node++)
154 cout <<
" nodeID = " << node <<
" x = " << coord[node][0] <<
" y = " << coord[node][1] <<
" z = " << coord[node][2] << endl;
160 MPI::Status status_row;
161 MPI::Status status_col;
165 ofstream part_file(
"partiton.dat" );
167 int *row =
new int[tot_elems];
168 int *col =
new int[8*tot_elems];
171 part_file <<
"title = \" tecplot file for partionoing \" " << endl;
172 part_file <<
"variables = \"x\", \"y\", \"z\", \"partID\" " << endl;
173 part_file <<
"zone N = " << tot_nodes <<
" E = " << tot_elems <<
174 " DATAPACKING = BLOCK, VARLOCATION = ([4]=CELLCENTERED), ZONETYPE=FETRIANGLE " << endl;
177 for (
int n = 0; n < tot_nodes; n++){
178 part_file << scientific << coord[n][0] <<
" " ;
179 if ( n % 5 == 0 ) part_file << endl;
183 for (
int n= 0; n < tot_nodes; n++){
184 part_file << scientific << coord[n][1] <<
" ";
185 if ( n % 5 == 0 ) part_file << endl;
189 for (
int n = 0; n < tot_nodes; n++){
190 part_file << scientific << coord[n][2] <<
" ";
191 if ( n % 5 == 0) part_file << endl;
195 for (
int elem = 0; elem <
_nelems.at(0); elem++){
196 part_file << 0 <<
" ";
197 if ( elem % 10 == 0 ) part_file << endl;
200 vector< shared_ptr< Array<int> > > row_root;
201 vector< shared_ptr< Array<int> > > col_root;
207 for (
int r = 0; r <
_nelems.at(0)+1; r++)
208 (*row_root.at(0))[r] =
_row.at(0)[r];
210 for (
int c = 0; c <
_colDim.at(0); c++)
211 (*col_root.at(0))[c] =
_col.at(0)[c];
214 for (
int p = 1; p <
_nPart.at(0); p++){
215 MPI::COMM_WORLD.Recv( row, tot_elems, MPI::INT, p, tag_row, status_row);
216 MPI::COMM_WORLD.Recv( col, 8*tot_elems, MPI::INT, p, tag_col, status_col);
218 int nelems = status_row.Get_count(MPI::INT) - 1;
219 int col_dim = status_col.Get_count(MPI::INT);
223 for (
int r = 0; r < nelems+1; r++)
224 (*row_root.at(p))[r] = row[r];
226 for (
int c = 0; c < col_dim; c++)
227 (*col_root.at(p))[c] = col[c];
229 for (
int elem = 0; elem < nelems; elem++){
230 part_file << p <<
" ";
231 if ( elem % 10 == 0 ) part_file << endl;
237 for (
int p = 0; p <
_nPart.at(0); p++){
239 int nelems = row_root.at(p)->getLength() - 1;
240 for (
int elem = 0; elem < nelems; elem++){
241 int node_start = (*row_root.at(p))[elem];
242 int node_end = (*row_root.at(p))[elem+1];
243 for (
int node = node_start; node < node_end; node++)
244 part_file << setw(6) << (*col_root.at(p))[node]+1 <<
" ";
257 MPI::COMM_WORLD.Send(
_row.at(0),
_nelems.at(0)+1, MPI::INT, 0, tag_row);
258 MPI::COMM_WORLD.Send(
_col.at(0),
_colDim.at(0) , MPI::INT, 0, tag_col);
274 ss <<
"proc" <<
_procID <<
"_debug_print.dat";
275 ofstream debug_file( (ss.str()).c_str() );
278 for (
int id = 0;
id <
_nmesh;
id++){
279 debug_file <<
" procID = " << _procID << endl;
280 debug_file <<
" npart = " <<
_nPart.at(
id) << endl;
285 for (
int n = 0; n <
_nPart.at(
id); n++)
286 debug_file <<
" elemDist[" << n <<
"] = " << (*
_elemDist.at(
id))[n] << endl;
291 for (
int n = 0; n <=
_nPart.at(
id); n++)
292 debug_file <<
" n = " << n <<
" globalIndx[" << n <<
"] = " << (*
_globalIndx.at(
id))[n] << endl;
297 int mesh_nlocal = (*
_elemDist.at(
id))[_procID];
298 for (
int i = 0; i <= mesh_nlocal; i++)
299 debug_file <<
" eptr[" << i <<
"] = " <<
_ePtr.at(
id)[i] << endl;
304 for (
int i = 0; i < mesh_nlocal; i++)
305 debug_file <<
" eelm[" << i <<
"] = " <<
_eElm.at(
id)[i] << endl;
310 int nlocal_elem = (*
_elemDist.at(
id))[_procID];
312 for (
int i = 0; i < nlocal_elem; i++){
313 int nnodes =
_ePtr.at(
id)[i+1] -
_ePtr.at(
id)[i];
314 debug_file <<
" elemID = " << i <<
", ";
315 for (
int j = 0; j < nnodes; j++){
316 debug_file <<
" eind[" << indx <<
"]=" <<
_eInd.at(
id)[indx] <<
" ";
325 for (
int i = 0; i < nlocal_elem; i++){
326 debug_file <<
" elmwgt[" << i <<
"]=" <<
_elmWght.at(
id)[i] << endl;
332 debug_file <<
" wgtflag = " <<
_wghtFlag.at(
id) << endl;
337 debug_file <<
" numflag = " <<
_numFlag.at(
id) << endl;
342 debug_file <<
" ncon = " <<
_ncon.at(
id) << endl;
346 debug_file <<
" ncommonnodes = " <<
_ncommonNodes.at(
id) << endl;
348 debug_file <<
" nparts = " <<
_nPart.at(
id) << endl;
351 for (
int i = 0; i <
_nPart.at(
id); i++)
352 debug_file <<
"tpwgts[" << i <<
"] = " <<
_tpwgts.at(
id)[i] << endl;
354 for (
int i = 0; i <
_ncon.at(
id); i++)
355 debug_file <<
" ubvec = " <<
_ubvec.at(
id)[i] << endl;
358 debug_file <<
" options = " <<
_options << endl;
361 debug_file <<
" edgecut = " <<
_edgecut.at(
id) << endl;
364 for (
int i = 0; i < nlocal_elem; i++){
365 debug_file <<
" elem = " << (*
_globalIndx.at(
id))[_procID] + i <<
" partion = " <<
_part.at(
id)[i] << endl;
368 for (
int p = 0; p <
_nPart.at(
id); p++){
369 multimap<int,int>::iterator it, itlow, itup;
372 for( it = itlow; it != itup; it++)
373 debug_file <<
" partID = " << it->first <<
" elemID = " << it->second << endl;
377 debug_file <<
" total elements = " <<
_nelems.at(
id) << endl;
380 debug_file <<
" total dim of col = " <<
_colDim.at(
id) << endl;
383 for (
int n = 0; n <
_nelems.at(
id)+1; n++){
384 debug_file <<
" _row[" << n <<
"] = " <<
_row.at(
id)[n] << endl;
389 for (
int n = 0; n <
_nelems.at(
id); n++){
390 debug_file <<
" _elem[" << n <<
"] = " <<
_elem.at(
id)[n] << endl;
396 debug_file <<
" _elemWithGhosts[" << n <<
"] = " <<
_elemWithGhosts.at(
id)[n] << endl;
402 for (
int n = 0; n <
_colDim.at(
id); n++){
403 debug_file <<
" _col[" << n <<
"] = " <<
_col.at(
id)[n] << endl;
407 debug_file <<
" _cellParts : " << endl;
408 debug_file <<
" _cellParts->getRowDim() = " <<
_cellParts.at(
id)->getRowDim() << endl;
409 debug_file <<
" _cellParts->getColDim() = " <<
_cellParts.at(
id)->getColDim() << endl;
413 for (
int cell = 0; cell <
_cellParts.at(
id)->getRowDim(); cell++){
414 debug_file <<
" row[" << cell<<
"] = " << rowCellParts[cell] <<
" ";
415 int nnodes = rowCellParts[cell+1] - rowCellParts[cell];
416 for (
int node = 0; node < nnodes; node++){
417 debug_file << colCellParts[ rowCellParts[cell] + node ] <<
" ";
424 multimap<int,int>::iterator it_multimap;
427 debug_file <<
"Boundary multimap = " << it_multimap->first <<
" " << it_multimap->second << endl;
428 multimap<int,string>::iterator it_multimapS;
431 debug_file <<
"Boundary multimap = " << it_multimapS->first <<
" " << it_multimapS->second << endl;
435 debug_file <<
" _faceParts : " << endl;
436 debug_file <<
" _faceParts->getRowDim() = " <<
_faceParts.at(
id)->getRowDim() << endl;
437 debug_file <<
" _faceParts->getColDim() = " <<
_faceParts.at(
id)->getColDim() << endl;
441 for (
int cell = 0; cell <
_faceParts.at(
id)->getRowDim(); cell++){
442 debug_file <<
" row[" << cell<<
"] = " << rowFaceParts[cell] <<
" ";
443 int nnodes = rowFaceParts[cell+1] - rowFaceParts[cell];
444 for (
int node = 0; node < nnodes; node++){
445 debug_file << colFaceParts[ rowFaceParts[cell] + node ] <<
" ";
453 debug_file <<
" _faceCells : " << endl;
454 debug_file <<
" _faceCells->getRowDim() = " <<
_faceCells.at(
id)->getRowDim() << endl;
455 debug_file <<
" _faceCells->getColDim() = " <<
_faceCells.at(
id)->getColDim() << endl;
460 debug_file <<
" globalToLocalMap.length() = " << globalToLocalMap.
getLength() << endl;
462 for (
int n = 0; n < globalToLocalMap.
getLength(); n++)
463 debug_file <<
" globalToLocalMap[" << n <<
"] = " << globalToLocalMap[n] << endl;
465 debug_file <<
" localToGlobalMap.length() = " << localToGlobalMap.
getLength() << endl;
466 for (
int n = 0; n < localToGlobalMap.
getLength(); n++)
467 debug_file <<
" localToGlobalMap[" << n <<
"] = " << localToGlobalMap[n] << endl;
472 for (
int face = 0; face <
_faceCells.at(
id)->getRowDim(); face++){
473 debug_file <<
" row[" << face+1 <<
"] = " << (*
_partFaces.at(
id))(_procID,face)+1 <<
" ";
474 int ncells =
_faceCells.at(
id)->getCount(face);
475 for (
int cell = 0; cell < ncells; cell++){
476 debug_file << colFaceCells[ rowFaceCells[face] + cell ] + 1 <<
" ";
484 debug_file <<
" _faceNodes : " << endl;
485 debug_file <<
" _faceNodes->getRowDim() = " <<
_faceNodes.at(
id)->getRowDim() << endl;
486 debug_file <<
" _faceNodes->getColDim() = " <<
_faceNodes.at(
id)->getColDim() << endl;
490 for (
int face = 0; face <
_faceNodes.at(
id)->getRowDim(); face++){
491 debug_file <<
" row[" << face+1<<
"] = " << (*
_partFaces.at(
id))(_procID,face)+1 <<
" ";
492 int nnodes =
_faceNodes.at(
id)->getCount(face);
493 for (
int node = 0; node < nnodes; node++){
494 debug_file << colFaceNodes[ rowFaceNodes[face] + node ]+1 <<
" ";
503 debug_file <<
" _cellNodes(Local Numbering) : " << endl;
504 debug_file <<
" _cellNodes->getRowDim() = " <<
_cellNodes.at(
id)->getRowDim() << endl;
505 debug_file <<
" _cellNodes->getColDim() = " <<
_cellNodes.at(
id)->getColDim() << endl;
509 for (
int cell = 0; cell <
_cellNodes.at(
id)->getRowDim(); cell++){
510 debug_file <<
" row[" << cell+1 <<
"] = " ;
511 int nnodes =
_cellNodes.at(
id)->getCount(cell);
512 for (
int node = 0; node < nnodes; node++){
513 debug_file << colCellNodes[ rowCellNodes[cell] + node ]+1 <<
" ";
522 debug_file <<
" _cellCells : " << endl;
523 debug_file <<
" _cellCells->getRowDim() = " <<
_cellCells.at(
id)->getRowDim() << endl;
524 debug_file <<
" _cellCells->getColDim() = " <<
_cellCells.at(
id)->getColDim() << endl;
528 for (
int cell = 0; cell <
_cellCells.at(
id)->getRowDim(); cell++){
529 debug_file <<
" row[" << cell+1<<
"] = " <<
" ";
530 int nnodes =
_cellCells.at(
id)->getCount(cell);
531 for (
int node = 0; node < nnodes; node++){
532 debug_file << colCellCells[ rowCellCells[cell] + node ]+1 <<
" ";
540 int node_count =
_partNodes.at(
id)->getCount( _procID );
543 for (
int node = 0; node < node_count; node++){
546 debug_file <<
" node ID = " <<setw(10)<< node+1 << setprecision(7) <<
", x = " << (*
_coord.at(
id))[node][0] <<
547 setprecision(7) <<
", y = " << (*
_coord.at(
id))[node][1] <<
548 setprecision(7) <<
", z = " << (*
_coord.at(
id))[node][2] << endl;
556 pair<multimap<int,int>::iterator,multimap<int,int>::iterator> ret;
557 debug_file <<
" _interfaceMap.size() = " <<
_interfaceMap.at(
id).size() << endl;
558 for (
int part = 0; part <
_nPart.at(
id); part++){
562 debug_file <<
" interface ID = " << part <<
" => ";
563 for (it_multimap=ret.first; it_multimap!=ret.second; ++it_multimap)
564 debug_file << (*
_partFaces.at(
id))(_procID, (*it_multimap).second) + 1 <<
" ";
575 set<int>::const_iterator it_set;
576 debug_file <<
" total interior cells = " <<
_elemLocal.at(
id).size() << endl;
578 debug_file <<
" " << *it_set << endl;
583 debug_file <<
" total non-interior cells = " <<
_nonInteriorCells.at(
id).size() << endl;
585 debug_file <<
" " << *it_set << endl;
590 debug_file <<
" bndry group ID = " << it_multimap->first <<
" offsets = " << it_multimap->second << endl;
595 debug_file <<
" interface ID = " << it_multimap->first <<
" offsets = " << it_multimap->second << endl;
600 debug_file <<
" _faceCellsOrdered : " << endl;
601 debug_file <<
" _faceCellsOrdered->getRowDim() = " <<
_faceCellsOrdered.at(
id)->getRowDim() << endl;
602 debug_file <<
" _faceCellsOrdered->getColDim() = " <<
_faceCellsOrdered.at(
id)->getColDim() << endl;
607 debug_file <<
" row[" << face <<
"] = " ;
609 for (
int cell = 0; cell < ncells; cell++){
610 debug_file << colFaceCellsOrdered[ rowFaceCellsOrdered[face] + cell ] + 1 <<
" ";
618 debug_file <<
" _faceNodesOrdered : " << endl;
619 debug_file <<
" _faceNodesOrdered->getRowDim() = " <<
_faceNodesOrdered.at(
id)->getRowDim() << endl;
620 debug_file <<
" _faceNodesOrdered->getColDim() = " <<
_faceNodesOrdered.at(
id)->getColDim() << endl;
625 debug_file <<
" row[" << face<<
"] = " ;
627 debug_file << nnodes <<
" ";
628 for (
int node = 0; node < nnodes; node++){
629 debug_file << colFaceNodesOrdered[ rowFaceNodesOrdered[face] + node ]+1 <<
" ";
638 for (
int proc = 0; proc <
_nPart.at(
id); proc++)
644 debug_file <<
" offset for ghost Cells from adjacent meshes to read data from _ghostCellsGlobal : " << endl;
646 debug_file <<
" n = " << n <<
" offsetInterfaceCells = " << (*
_offsetInterfaceCells.at(
id))[n] << endl;
650 debug_file <<
" neightboorhood cell IDs : " << endl;
652 debug_file <<
" n = " << n <<
" interfaced Mesh ID = " << (*
_interfaceMeshIDs.at(
id))[n] << endl;
657 debug_file <<
"interface cells looking interior domain (global numbering) : " << endl;
659 debug_file <<
" n = " << n <<
" cell ID = " << (*
_ghostCellsGlobal.at(
id))[n] << endl;
662 debug_file <<
"interface cells looking interior domain (local numbering) : " << endl;
664 debug_file <<
" n = " << n <<
" interfaced Mesh ID = " << (*
_ghostCellsLocal.at(
id))[n] << endl;
682 for (
int id = 0;
id <
_nmesh;
id++)
690 for (
int id = 0;
id <
_nmesh;
id++)
701 _procID = MPI::COMM_WORLD.Get_rank();
732 for (
int id = 0;
id <
_nmesh;
id++){
745 for (
int n = 0; n <
_ncon.at(
id); n++)
764 cout <<
" ONLY TRIANGLE, TETRAHEDRAL, HEXAHEDRAL and QUADRILATERAL elements must be chose " <<
770 _tpwgts.push_back(
new float[ ncon_by_nparts ] );
771 for (
int n = 0; n < ncon_by_nparts; n++){
772 _tpwgts.at(
id)[n] = 1.0f / float( ncon_by_nparts );
792 for (
int id = 0;
id <
_nmesh;
id++){
796 int nremainder = nelems % npart;
797 int init_dist = (nelems - nremainder) / npart;
803 while ( nremainder != 0 ){
811 for (
int n = 1; n <= npart; n++){
823 for (
int id = 0;
id <
_nmesh;
id++){
826 _ePtr.push_back(
new int[mesh_nlocal+1] );
827 _eElm.push_back(
new int[mesh_nlocal+1] );
830 if ( !
_meshList.at(
id)->isMergedMesh() ){
832 for (
int n = 0; n <
_ncon.at(
id)*mesh_nlocal; n++)
838 for (
int n =0; n < mesh_nlocal; n++ ){
839 for (
int i = 0; i <
_meshList.at(
id)->getNumOfAssembleMesh(); i++ ){
854 _part.push_back(
new int[mesh_nlocal] );
855 for (
int n = 0; n < mesh_nlocal; n++)
856 _part.at(
id)[n] = -1;
872 for (
int n = nstart; n < npart; n++)
873 local_nodes += cellNodes.
getCount(n);
888 _ePtr.at(
id)[indxPtr] = 0;
889 for (
int elem = elem_start; elem < elem_finish; elem++ ){
890 _eElm.at(
id)[indxPtr] = elem;
895 for (
int node = 0; node < cellNodes.
getCount(elem); node++ )
896 _eInd.at(
id)[indxInd++] = cellNodes(elem,node);
900 for (
int node = cellNodes.
getCount(elem)-1; node >=0; node-- )
901 _eInd.at(
id)[indxInd++] = cellNodes(elem,node);
912 MPI_Comm comm_world = MPI::COMM_WORLD;
913 for (
int id = 0;
id <
_nmesh;
id++){
928 for (
int id = 0;
id <
_nmesh;
id++){
931 for (
int elm = 0; elm < nlocal_elem; elm++){
932 int partID =
_part.at(
id)[elm];
943 for (
int id = 0;
id <
_nmesh;
id++){
944 for (
int partID = 0; partID <
_nPart.at(
id); partID++){
948 multimap<int,int>::const_iterator it =
_mapPartAndElms.at(
id).find(partID);
949 multimap<int,int>::const_iterator itlow =
_mapPartAndElms.at(
id).lower_bound(partID);
950 multimap<int,int>::const_iterator itup =
_mapPartAndElms.at(
id).upper_bound(partID);
952 for ( it = itlow; it != itup; it++){
953 int pos = it->second;
954 ncol_local +=
_ePtr.at(
id)[pos+1] -
_ePtr.at(
id)[pos];
957 MPI::COMM_WORLD.Reduce(&nelems_local, &
_nelems.at(
id), 1, MPI::INT, MPI::SUM, partID);
958 MPI::COMM_WORLD.Reduce(&ncol_local, &
_colDim.at(
id), 1, MPI::INT, MPI::SUM, partID);
965 for (
int n = 0; n <
_nelems.at(
id)+1; n++ )
967 for (
int n = 0; n <
_colDim.at(
id); n++)
969 for (
int n = 0; n <
_nelems.at(
id); n++)
970 _elem.at(
id)[n] = -1;
981 for (
int id = 0;
id <
_nmesh;
id++){
983 int *countsRow =
new int[
_nPart.at(
id)];
984 int *countsCol =
new int[
_nPart.at(
id)];
985 int *offsetsRow =
new int[
_nPart.at(
id)];
986 int *offsetsCol =
new int[
_nPart.at(
id)];
989 for (
int partID = 0; partID <
_nPart.at(
id); partID++){
991 int *row_local =
new int[nelems_local];
992 int *elem_local =
new int[nelems_local];
994 multimap<int,int>::const_iterator it =
_mapPartAndElms.at(
id).find(partID);
995 multimap<int,int>::const_iterator itlow =
_mapPartAndElms.at(
id).lower_bound(partID);
996 multimap<int,int>::const_iterator itup =
_mapPartAndElms.at(
id).upper_bound(partID);
1001 for ( it = itlow; it != itup; it++){
1002 int pos = it->second;
1003 ncol_local +=
_ePtr.at(
id)[pos+1] -
_ePtr.at(
id)[pos];
1004 row_local[indx] =
_ePtr.at(
id)[pos+1]-
_ePtr.at(
id)[pos];
1005 elem_local[indx] =
_eElm.at(
id)[pos];
1010 int *col_local =
new int[ncol_local];
1012 for ( it = itlow; it != itup; it++ ){
1013 int elID = it->second;
1014 int node_start =
_ePtr.at(
id)[elID];
1015 int node_end =
_ePtr.at(
id)[elID+1];
1016 for (
int node = node_start; node < node_end; node++){
1017 col_local[indx++] =
_eInd.at(
id)[node];
1022 int nrow_local = nelems_local;
1023 MPI::COMM_WORLD.Allgather(&nrow_local, 1, MPI::INT, countsRow, 1, MPI::INT);
1024 MPI::COMM_WORLD.Allgather(&ncol_local, 1, MPI::INT, countsCol, 1, MPI::INT);
1030 for (
int p = 1; p < int(
_nPart.at(
id)); p++ ){
1031 offsetsRow[p] = countsRow[p-1] + offsetsRow[p-1];
1032 offsetsCol[p] = countsCol[p-1] + offsetsCol[p-1];
1036 MPI::COMM_WORLD.Gatherv(row_local, countsRow[
_procID], MPI::INT,
_row.at(
id),
1037 countsRow, offsetsRow, MPI::INT, partID);
1039 MPI::COMM_WORLD.Gatherv(col_local, countsCol[_procID], MPI::INT,
_col.at(
id),
1040 countsCol, offsetsCol, MPI::INT, partID);
1042 MPI::COMM_WORLD.Gatherv(elem_local, countsRow[_procID], MPI::INT,
_elem.at(
id),
1043 countsRow, offsetsRow, MPI::INT, partID);
1046 delete [] row_local;
1047 delete [] col_local;
1048 delete [] elem_local;
1052 delete [] countsRow ;
1053 delete [] countsCol ;
1054 delete [] offsetsRow;
1055 delete [] offsetsCol;
1072 for (
int id = 0;
id <
_nmesh;
id++){
1074 for (
int n =
_nelems.at(
id); n > 0; n--)
1078 for (
int n = 1; n <
_nelems.at(
id)+1; n++ )
1079 _row.at(
id)[n] +=
_row.at(
id)[n-1];
1090 MPI::COMM_WORLD.Barrier();
1091 vector< int* > ::iterator it_int;
1092 for ( it_int =
_ePtr.begin(); it_int !=
_ePtr.end(); it_int++)
1095 for ( it_int =
_eInd.begin(); it_int !=
_eInd.end(); it_int++)
1098 for ( it_int =
_eElm.begin(); it_int !=
_eElm.end(); it_int++)
1104 for ( it_int =
_row.begin(); it_int !=
_row.end(); it_int++)
1107 for ( it_int =
_col.begin(); it_int !=
_col.end(); it_int++)
1117 for (
int id = 0;
id <
_nmesh;
id++){
1122 set<int>::const_iterator it_set;
1124 int bndryID = *it_set;
1129 _meshListLocal.at(
id)->createBoundaryFaceGroup( size, offset, bndryID, boundaryType);
1136 int interfaceID = *it_set;
1139 _meshListLocal.at(
id)->createInterfaceGroup( size, offset, interfaceID );
1140 shared_ptr<StorageSite> siteGather (
new StorageSite(size) );
1141 shared_ptr<StorageSite> siteScatter(
new StorageSite(size) );
1142 siteGather->setScatterProcID(
_procID );
1143 siteGather->setGatherProcID ( interfaceID );
1144 siteScatter->setScatterProcID(
_procID );
1145 siteScatter->setGatherProcID ( interfaceID );
1147 siteScatter->setTag( packed_info );
1151 _meshListLocal.at(
id)->createGhostCellSiteScatter( pairID, siteScatter );
1152 _meshListLocal.at(
id)->createGhostCellSiteGather ( pairID, siteScatter );
1159 if (
_meshList.at(
id)->isMergedMesh() ){
1173 int nmesh =
_meshList.at(0)->getNumOfAssembleMesh();
1185 int glblID = localToGlobalMappers.find(i)->second;
1186 colorLocal[i] = colorGlbl[ glblID ];
1192 int acrossCellID = cellCells(i,0);
1193 colorLocal[i] = colorLocal[ acrossCellID ];
1197 for (
int i = 0; i < cellSite.
getCount(); i++ ){
1198 int glblID = localToGlobalMappers.find(i)->second;
1199 colorOtherLocal[i] = colorGlbl[ glblID ];
1210 for (
int id = 0;
id <
_nmesh;
id++){
1226 vector< int* > elemGlobal;
1227 vector< int* > distGlobal;
1229 for (
int id = 0;
id <
_nmesh;
id++){
1234 distGlobal.push_back(
new int [
_nPart.at(
id) + 1 ] );
1235 int *offsets =
new int [
_nPart.at(
id) ];
1237 MPI::COMM_WORLD.Allgather(&
_nelemsWithGhosts.at(
id), 1, MPI::INT, distGlobal.at(
id), 1, MPI::INT);
1240 for (
int p = 1; p < int(
_nPart.at(
id)); p++ ){
1241 offsets[p] = distGlobal.at(
id)[p-1] + offsets[p-1];
1246 distGlobal.at(
id), offsets, MPI::INT);
1249 for (
int i =
int(
_nPart.at(
id)); i > 0; i--)
1250 distGlobal.at(
id)[i] = distGlobal.at(
id)[i-1];
1252 distGlobal.at(
id)[0] = 0;
1255 for (
int i = 1; i <
_nPart.at(
id)+1; i++ ){
1256 distGlobal.at(
id)[i] += distGlobal.at(
id)[i-1];
1274 while ( index <
_nPart.at(
id) ){
1275 for (
int n = distGlobal.at(
id)[index]; n < distGlobal.at(
id)[index+1]; n++){
1277 _cellParts.at(
id)->add(elemGlobal.at(
id)[n],index);
1287 vector< int* > ::iterator it_int;
1288 for ( it_int = elemGlobal.begin(); it_int != elemGlobal.end(); it_int++)
1291 for ( it_int = distGlobal.begin(); it_int != distGlobal.end(); it_int++)
1312 for (
int bounID = 0; bounID < int(boundaryFaceGroups.size()); bounID++){
1313 int group_id = boundaryFaceGroups.at(bounID)->id;
1315 string boun_type( boundaryFaceGroups.at(bounID)->groupType );
1319 int nBounElm = boundaryFaceGroups.at(bounID)->site.getCount();
1321 for (
int n = 0; n < nBounElm; n++){
1322 mapBounIDAndCell.insert( pair<int,int>(group_id, indx) );
1328 for (
int n = 0; n <
_nelems.at(
id); n++ )
1331 multimap<int,int>::const_iterator it;
1333 for ( it = mapBounIDAndCell.begin(); it != mapBounIDAndCell.end(); it++ ){
1334 int boun_cell_id = it->second;
1335 int neigh_id = cellCells(boun_cell_id,0);
1336 if (
_elemSet.at(
id).count( neigh_id ) > 0 )
1374 for (
int n = 0; n <
_nelems.at(
id); n++)
1377 multimap<int,int>::const_iterator it;
1393 vector< ArrayIntPtr > indices;
1394 vector< CRConnectivityPtr > faceCells;
1395 vector< CRConnectivityPtr > cellCells;
1397 for (
int id = 0;
id <
_nmesh;
id++){
1411 for (
int n = n_start; n < n_start + face_count; n++){
1412 (*indices.at(
id))[indx] = col[n];
1416 int cell_count =
_nelems.at(
id);
1422 cellCells.push_back( ( faceCells.at(
id)->getTranspose())->multiply(*faceCells.at(
id),
true) );
1425 *cellCells.at(
id) ) );
1440 MPI::COMM_WORLD.Barrier();
1443 vector< int* > ::iterator it_int;
1444 for ( it_int =
_elem.begin(); it_int !=
_elem.end(); it_int++)
1459 for (
int id = 0;
id <
_nmesh;
id++){
1461 for (
int face = 0; face < nface; face++ ){
1464 if (
_faceParts.at(
id)->getCount(face_globalID) == 2 ){
1465 int neighPart = (*
_faceParts.at(
id))(face_globalID,0) +
1468 _interfaceMap.at(
id).insert( pair<int,int>(neighPart,face) );
1481 for (
int id = 0;
id <
_nmesh;
id++){
1489 for (
int node = 0; node < node_count; node++)
1490 (*
_coord.at(
id))[node] = global_coord[ colPartNodes[rowPartNodes[
_procID]+node] ];
1509 for (
int id = 0;
id <
_nmesh;
id++){
1511 for (
int n = 0; n <
_nelems.at(
id); n++){
1512 int local_elem_id = globalToLocal[
_elem.at(
id)[n] ];
1522 multimap<int,int>::const_iterator it;
1523 for (
int id = 0;
id <
_nmesh;
id++){
1526 int local_cell_id =
_faceCells.at(
id)->getGlobalToLocalMap()[it->second];
1531 int cell_0 = (*
_faceCells.at(
id))(it->second,0);
1532 int cell_1 = (*
_faceCells.at(
id))(it->second,1);
1549 for (
int id = 0;
id <
_nmesh;
id++ ){
1551 for (
int face = 0; face < nface_local; face++){
1556 if ( cell_0 >=
_nelems.at(
id) )
1558 if ( cell_1 >=
_nelems.at(
id) )
1583 for (
int id = 0;
id <
_nmesh;
id++ ){
1598 for (
int face = 0; face < nface; face++){
1607 int array_length =
_faceCells.at(
id)->getLocalToGlobalMap().getLength();
1608 assert( array_length == tot_cells );
1616 for (
int face = 0; face < nface_local; face++){
1623 if ( is_interior ) {
1628 int global_id =
_faceCells.at(
id)->getLocalToGlobalMap()[cell_0];
1642 int global_id =
_faceCells.at(
id)->getLocalToGlobalMap()[cell_1];
1653 for (
int node = 0; node < count_node; node++ )
1663 int max_sur_cells = 0;
1664 for (
int elem = 0; elem <
_cellCells.at(
id)->getRowDim(); elem++ )
1666 assert( max_sur_cells <= 6 );
1668 for (
int elem = 0; elem <
_cellCells.at(
id)->getRowDim(); elem++ ){
1671 _cellToOrderedCell[id][elem] = cellID;
1672 int global_id =
_faceCells.at(
id)->getLocalToGlobalMap()[elem];
1682 multimap<int,int>::const_iterator it_cell;
1683 pair<multimap<int,int>::const_iterator,multimap<int,int>::const_iterator> it;
1684 set<int> ::const_iterator it_set;
1685 int offset = face_track;
1688 int bndryID = *it_set;
1692 _bndryOffsets.at(
id).insert( pair<int,int>(bndryID, offset) );
1694 for ( it_cell = it.first; it_cell != it.second; it_cell++ ){
1695 int elem_0 =
_faceCells.at(
id)->getGlobalToLocalMap()[it_cell->second];
1696 assert(elem_0 > 0 );
1697 int elem_1 = (*
_cellCells.at(
id))(elem_0, 0);
1698 assert( elem_0 != elem_1 );
1700 int outer_elem = cellID;
1713 for (
int node = 0; node < count_node; node++)
1724 multimap<int,int>::const_iterator it_face;
1726 int interfaceID = *it_set;
1729 for ( it_face = it.first; it_face != it.second; it_face++ ){
1730 int face_id = it_face->second;
1731 int elem_0 = (*
_faceCells.at(
id))(face_id,0);
1732 int elem_1 = (*
_faceCells.at(
id))(face_id,1);
1733 int outer_elem_id = -1;
1737 outer_elem_id = elem_1;
1740 outer_elem_id = elem_0;
1745 int global_id =
_faceCells.at(
id)->getLocalToGlobalMap()[outer_elem_id];
1746 assert( cellID >=0 && cellID < array_length );
1754 if ( outer_elem_id == elem_1 ) {
1755 for (
int node = 0; node < count_node; node++)
1758 for (
int node = count_node-1; node >= 0; node--)
1772 assert( cellID == tot_cells );
1805 int dim =
_meshList.at(
id)->getDimension();
1818 int nGhostCell_local = tot_cells -
_nelems.at(
id);
1832 vector<int> interfaceMeshIDs;
1833 int *recv_counts = NULL;
1835 for (
int id = 0;
id <
_nmesh;
id++){
1836 recv_counts =
new int[
_nPart.at(
id) ];
1837 displ =
new int[
_nPart.at(
id) ];
1839 int total_interface_mesh = int(
_interfaceSet.at(
id).size() );
1842 MPI::COMM_WORLD.Allgather(&total_interface_mesh, 1, MPI::INT,
_interfaceMeshCounts.at(
id)->getData(), 1, MPI::INT);
1843 MPI::COMM_WORLD.Allgather(&total_faces, 1, MPI::INT,
_procTotalInterfaces.at(
id)->getData(), 1, MPI::INT);
1847 int total_interface_global = -1;
1849 MPI::COMM_WORLD.Allreduce( &total_interface_local, &total_interface_global, 1, MPI::INT, MPI::SUM );
1850 MPI::COMM_WORLD.Allgather( &total_interface_local, 1, MPI::INT, recv_counts, 1, MPI::INT );
1851 MPI::COMM_WORLD.Allreduce( &total_faces, &
_windowSize.at(
id), 1, MPI::INT, MPI::MAX);
1862 set<int>::const_iterator it_set;
1864 int neighMeshID = *it_set;
1865 interfaceMeshIDs.push_back( neighMeshID );
1868 offset.push_back( nstart );
1870 int nend = nstart +
_interfaceMap.at(
id).count( neighMeshID );
1871 for (
int n = nstart; n < nend; n++){
1873 assert( elem_local_id >= 0 && elem_local_id <
_localToGlobalMap.at(
id)->getLength() );
1885 for (
int i = 1; i <
_nPart.at(
id); i++)
1886 displ[i] = recv_counts[i-1] + displ[i-1];
1890 MPI::COMM_WORLD.Allgatherv( &offset[0], total_interface_local, MPI::INT,
1893 MPI::COMM_WORLD.Allgatherv( &interfaceMeshIDs[0], total_interface_local, MPI::INT,
1897 interfaceMeshIDs.clear();
1899 delete [] recv_counts;
1911 for (
int id = 0;
id <
_nmesh;
id++){
1919 set<int>::const_iterator it_set;
1920 int interfaceIndx = 0;
1923 int neighMeshID = *it_set;
1930 int window_displ = -1;
1932 _winLocal.Get (
_fromIndices.at(
id).at(interfaceIndx)->getData(), size, MPI::INT, neighMeshID, window_displ, size, MPI::INT );
1933 _winGlobal.Get(
_toIndices.at(
id).at(interfaceIndx)->getData() , size, MPI::INT, neighMeshID, window_displ, size, MPI::INT );
1945 int neighMeshID = *it_set;
1947 map<int, int> mapKeyCount;
1948 for (
int n = 0; n < size; n++){
1950 int key = (*
_toIndices.at(
id).at(interfaceIndx))[n];
1953 if ( mapKeyCount.count( key ) > 0 ) {
1954 mapKeyCount[key] = mapKeyCount[key] + 1;
1956 mapKeyCount.insert(pair<int,int>(key,0));
1959 multimap<int,int>::const_iterator it;
1961 for (
int n_iter = 0; n_iter < mapKeyCount[key]; n_iter++)
1964 int elem_id = it->second;
1965 (*
_toIndices.at(
id).at(interfaceIndx))[n] = elem_id;
1983 for (
int i = 0; i <
_fromIndices.at(
id).at(interfaceIndx)->getLength(); i++){
1984 int elem_id = (*
_toIndices.at(
id).at(interfaceIndx))[i];
2006 MPI::COMM_WORLD.Barrier();
2016 int window_displ = 0;
2017 for (
int i = 0; i < neigh_mesh_id; i++)
2026 return window_displ;
2032 int int_size = MPI::INT.Get_size();
2033 MPI::Aint lb, sizeofAint;
2034 MPI::INT.Get_extent(lb,sizeofAint);
2038 MPI_INFO_NULL, MPI::COMM_WORLD);
2040 MPI_INFO_NULL, MPI::COMM_WORLD);
2077 ss <<
"mesh_proc" <<
_procID <<
"_info.dat";
2078 ofstream
mesh_file( (ss.str()).c_str() );
2079 for (
int id = 0;
id <
_nmesh;
id++ ){
2086 Mesh::GhostCellSiteMap::const_iterator it_ghostScatter;
2088 for ( it_ghostScatter = ghostCellSiteScatterMap.begin(); it_ghostScatter != ghostCellSiteScatterMap.end(); it_ghostScatter++ ){
2090 int neighID = pairID.first;
2092 const StorageSite& siteScatter = *( ghostCellSiteScatterMap.find( pairID )->second );
2093 const StorageSite& siteGather = *( ghostCellSiteGatherMap.find ( pairID )->second );
2096 const Array<int>& scatterArray = *(cellScatterMap.find( &siteScatter )->second);
2097 const Array<int>& gatherArray = *(cellGatherMap.find ( &siteGather )->second);
2098 for (
int i = 0; i < siteScatter.
getCount(); i++){
2099 mesh_file <<
" neightMeshID = " << neighID <<
" "
2100 << gatherArray[i] + 1 <<
" ===> "
2101 << scatterArray[i] + 1 << endl;
2117 ss <<
"mesh_proc" <<
_procID <<
".dat";
2118 ofstream
mesh_file( (ss.str()).c_str() );
2126 mesh_file <<
"title = \" tecplot file for process Mesh \" " << endl;
2127 mesh_file <<
"variables = \"x\", \"y\", \"z\", \"cell_type\" " << endl;
2129 mesh_file <<
"variables = \"x\", \"y\", \"z\", \"cell_type\", \"color\" " << endl;
2132 stringstream zone_info;
2135 zone_info <<
" DATAPACKING = BLOCK, VARLOCATION = ([4]=CELLCENTERED), ZONETYPE=FETRIANGLE ";
2138 zone_info <<
" DATAPACKING = BLOCK, VARLOCATION = ([4]=CELLCENTERED), ZONETYPE=FEQUADRILATERAL ";
2141 zone_info <<
" DATAPACKING = BLOCK, VARLOCATION = ([4]=CELLCENTERED), ZONETYPE=FEBRICK ";
2144 zone_info <<
" DATAPACKING = BLOCK, VARLOCATION = ([4]=CELLCENTERED), ZONETYPE=FETETRAHEDRON ";
2147 mesh_file <<
"zone N = " << tot_nodes <<
" E = " << tot_elems << zone_info.str() << endl;
2150 for (
int n = 0; n < tot_nodes; n++){
2151 mesh_file << scientific << coord[n][0] <<
" " ;
2157 for (
int n= 0; n < tot_nodes; n++){
2158 mesh_file << scientific << coord[n][1] <<
" ";
2164 for (
int n = 0; n < tot_nodes; n++){
2165 mesh_file << scientific << coord[n][2] <<
" ";
2173 for (
int n = 0; n < tot_elems; n++){
2190 const Array<int>& color = mesh.getCellColors();
2191 for (
int n = 0; n < tot_elems; n++ ){
2200 for (
int n = 0; n < tot_elems; n++){
2201 int nnodes = cellNodes.
getCount(n);
2203 for (
int node = 0; node < nnodes; node++)
2204 mesh_file << cellNodes(n,node)+1 <<
" ";
2208 mesh_file << cellNodes(n,0)+1 <<
" " << cellNodes(n,1)+1 <<
2209 " " << cellNodes(n,0)+1 <<
" ";
2212 mesh_file << cellNodes(n,0)+1 <<
" " << cellNodes(n,0)+1 <<
2213 " " << cellNodes(n,1)+1 <<
" " << cellNodes(n,1)+1 <<
" ";
2216 mesh_file << cellNodes(n,0)+1 <<
" " << cellNodes(n,1)+1 <<
" "
2217 << cellNodes(n,2)+1 <<
" " << cellNodes(n,3)+1 <<
" "
2218 << cellNodes(n,0)+1 <<
" " << cellNodes(n,1)+1 <<
" "
2219 << cellNodes(n,2)+1 <<
" " << cellNodes(n,3)+1 <<
" ";
2222 mesh_file << cellNodes(n,0)+1 <<
" " << cellNodes(n,1)+1 <<
2223 " " << cellNodes(n,2)+1 <<
" " << cellNodes(n,0)+1 <<
" ";
2238 int nprocs = MPI::COMM_WORLD.Get_size();
2240 mesh_file <<
"<?xml version='1.0' ?>" << endl;
2241 mesh_file <<
"<!DOCTYPE Xdmf SYSTEM 'Xdmf.dtd' []>" << endl;
2242 mesh_file <<
"<Xdmf xmlns:xi='http://www.w3.org/2001/XInclude' Version='2.0'>" << endl;
2243 mesh_file <<
" <Domain>" << endl;
2244 for (
int i=0; i < nprocs; i++)
2245 mesh_file <<
" <xi:include href='mesh_proc" << i <<
".xmf' />" << endl;
2246 mesh_file <<
" </Domain>" << endl;
2247 mesh_file <<
"</Xdmf>" << endl;
2262 ss <<
"mesh_proc" <<
_procID <<
".xmf";
2263 ofstream
mesh_file( (ss.str()).c_str() );
2268 int tot_elems =
_nelems.at(0);
2272 mesh_file <<
"<Grid Name='Mesh-" << _procID <<
"' GridType='Uniform'>" << endl <<
" ";
2276 mesh_file <<
"<Topology TopologyType='Triangle'";
2280 mesh_file <<
"<Topology TopologyType='Quadrilateral'";
2284 mesh_file <<
"<Topology TopologyType='Hexahedron'";
2288 mesh_file <<
"<Topology TopologyType='Tetrahedron'";
2292 cout <<
"Unknown mesh type " <<
_eType.at(0) << endl;
2295 mesh_file <<
" Dimensions='" << tot_elems <<
"'>" << endl;
2296 mesh_file <<
" <DataItem Dimensions='" << tot_elems <<
" " << epn <<
"'>" << endl;
2299 for (
int n = 0; n < tot_elems; n++) {
2301 for (
int node = 0; node < cellNodes.
getCount(n); node++)
2309 mesh_file <<
" <Geometry Type='XYZ'>" << endl;
2310 mesh_file <<
" <DataItem Dimensions='" << tot_nodes <<
" 3' NumberType='Float'>" << endl;
2311 for (
int n = 0; n < tot_nodes; n++) {
void set_eptr_eind(int id)
int get_window_displ(int id, int neigh_mesh_id)
int getCount(const int i) const
vector< map< int, string > > _mapBounIDAndBounType
void order_faceCells_faceNodes()
vector< StorageSitePtr > _partSite
vector< StorageSitePtr > _nodeSite
vector< map< int, int > > _localToGlobalMappers
vector< CRConnectivityPtr > _cellCells
vector< CRConnectivityPtr > _partNodes
vector< int > _totElemsAndGhosts
vector< CRConnectivityPtr > _faceParts
void setNumFlag(int num_flag)
void non_interior_cells()
vector< int > _ncommonNodes
vector< set< int > > _interfaceSet
double max(double x, double y)
void CRConnectivity_cellParts()
shared_ptr< StorageSite > StorageSitePtr
void setCount(const int selfCount, const int nGhost=0)
vector< vector< int > > _cellToOrderedCell
vector< CRConnectivityPtr > _faceNodes
vector< set< int > > _elemSet
void cleanup_follow_mappers()
void local_number_elems()
void setWeightType(int weight_type)
vector< ArrayIntPtr > _ghostCellsLocal
PartMesh(const MeshList &mesh_list, vector< int > npart, vector< int > eType)
void cleanup_follow_faceCells_faceNodes()
vector< Mesh * > _meshListLocal
vector< int > _windowSize
shared_ptr< Array< Mesh::VecD3 > > ArrayVecD3Ptr
void exchange_interface_meshes()
vector< int * > _elemWithGhosts
vector< Array< int > * > _elemDist
const Array< VecD3 > & getNodeCoordinates() const
vector< float * > _tpwgts
vector< multimap< int, int > > _globalToLocalMappers
vector< ArrayIntPtr > _interfaceMeshCounts
vector< ArrayIntPtr > _interfaceMeshIDs
vector< int > _nelemsWithGhosts
void faceCells_faceNodes()
vector< FaceGroupPtr > FaceGroupList
vector< ArrayIntPtr > _procTotalInterfaces
map< PartIDMeshIDPair, shared_ptr< StorageSite > > GhostCellSiteMap
vector< ArrayIntPtr > _ghostCellsGlobal
pair< int, int > PartIDMeshIDPair
vector< multimap< int, int > > _mapBounIDAndCell
vector< map< int, int > > _interfaceOffsets
vector< StorageSitePtr > _cellSite
vector< multimap< int, int > > _mapPartAndElms
vector< CRConnectivityPtr > _faceNodesOrdered
vector< set< int > > _elemLocal
map< const StorageSite *, shared_ptr< Array< int > > > ScatterMap
void non_interior_cells2()
vector< set< int > > _boundarySet
vector< CRConnectivityPtr > _partCells
void exchange_part_elems()
vector< map< int, int > > _bndryOffsets
vector< vector< ArrayIntPtr > > _toIndices
void create_window(int id)
void mapBounIDAndCell(int id)
vector< CRConnectivityPtr > _cellParts
vector< Array< int > * > _globalIndx
map< const StorageSite *, shared_ptr< Array< int > > > GatherMap
void construct_mesh(int id)
void cleanup_follow_exchange_part_elems()
vector< StorageSitePtr > _cellSiteGlobal
shared_ptr< Array< int > > ArrayIntPtr
double min(double x, double y)
int count_interior_faces(int id)
vector< set< int > > _nonInteriorCells
void CRConnectivity_faceParts()
vector< ArrayIntPtr > _offsetInterfaceCells
vector< StorageSitePtr > _faceSite
vector< CRConnectivityPtr > _cellNodes
const CRConnectivity & getCellNodes() const
vector< vector< ArrayIntPtr > > _fromIndices
vector< CRConnectivityPtr > _faceCellsOrdered
vector< const CRConnectivity * > _faceCellsGlobal
vector< multimap< int, int > > _interfaceMap
vector< const CRConnectivity * > _faceNodesGlobal
shared_ptr< CRConnectivity > CRConnectivityPtr
vector< ArrayVecD3Ptr > _coord
vector< Mesh * > MeshList
vector< ArrayIntPtr > _localToGlobalMap
vector< CRConnectivityPtr > _partFaces
vector< CRConnectivityPtr > _faceCells