00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include "syncTools.H"
00028 #include "parMetisDecomp.H"
00029 #include "metisDecomp.H"
00030 #include "addToRunTimeSelectionTable.H"
00031 #include "floatScalar.H"
00032 #include "polyMesh.H"
00033 #include "Time.H"
00034 #include "labelIOField.H"
00035 #include "globalIndex.H"
00036
00037 #include <mpi.h>
00038
00039 extern "C"
00040 {
00041 # include "parmetis.h"
00042 }
00043
00044
00045
00046 namespace Foam
00047 {
00048 defineTypeNameAndDebug(parMetisDecomp, 0);
00049
00050 addToRunTimeSelectionTable
00051 (
00052 decompositionMethod,
00053 parMetisDecomp,
00054 dictionaryMesh
00055 );
00056 }
00057
00058
00059
00060
00061
00062 Foam::label Foam::parMetisDecomp::decompose
00063 (
00064 Field<int>& xadj,
00065 Field<int>& adjncy,
00066 const pointField& cellCentres,
00067 Field<int>& cellWeights,
00068 Field<int>& faceWeights,
00069 const List<int>& options,
00070
00071 List<int>& finalDecomp
00072 )
00073 {
00074
00075 int numFlag = 0;
00076
00077
00078 int nDims = 3;
00079
00080
00081 if (cellCentres.size() != xadj.size()-1)
00082 {
00083 FatalErrorIn("parMetisDecomp::decompose(..)")
00084 << "cellCentres:" << cellCentres.size()
00085 << " xadj:" << xadj.size()
00086 << abort(FatalError);
00087 }
00088
00089
00090
00091 List<int> nLocalCells(Pstream::nProcs());
00092 nLocalCells[Pstream::myProcNo()] = xadj.size()-1;
00093 Pstream::gatherList(nLocalCells);
00094 Pstream::scatterList(nLocalCells);
00095
00096
00097 List<int> cellOffsets(Pstream::nProcs()+1);
00098 int nGlobalCells = 0;
00099 forAll(nLocalCells, procI)
00100 {
00101 cellOffsets[procI] = nGlobalCells;
00102 nGlobalCells += nLocalCells[procI];
00103 }
00104 cellOffsets[Pstream::nProcs()] = nGlobalCells;
00105
00106
00107 Field<floatScalar> xyz(3*cellCentres.size());
00108 int compI = 0;
00109 forAll(cellCentres, cellI)
00110 {
00111 const point& cc = cellCentres[cellI];
00112 xyz[compI++] = float(cc.x());
00113 xyz[compI++] = float(cc.y());
00114 xyz[compI++] = float(cc.z());
00115 }
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126 List<int> nSendCells(Pstream::nProcs(), 0);
00127
00128 for (label procI = nLocalCells.size()-1; procI >=1; procI--)
00129 {
00130 if (nLocalCells[procI]-nSendCells[procI] < 1)
00131 {
00132 nSendCells[procI-1] = nSendCells[procI]-nLocalCells[procI]+1;
00133 }
00134 }
00135
00136
00137
00138 if (Pstream::myProcNo() >= 1 && nSendCells[Pstream::myProcNo()-1] > 0)
00139 {
00140
00141 IPstream fromPrevProc(Pstream::blocking, Pstream::myProcNo()-1);
00142
00143 Field<int> prevXadj(fromPrevProc);
00144 Field<int> prevAdjncy(fromPrevProc);
00145 Field<floatScalar> prevXyz(fromPrevProc);
00146 Field<int> prevCellWeights(fromPrevProc);
00147 Field<int> prevFaceWeights(fromPrevProc);
00148
00149 if (prevXadj.size() != nSendCells[Pstream::myProcNo()-1])
00150 {
00151 FatalErrorIn("parMetisDecomp::decompose(..)")
00152 << "Expected from processor " << Pstream::myProcNo()-1
00153 << " connectivity for " << nSendCells[Pstream::myProcNo()-1]
00154 << " nCells but only received " << prevXadj.size()
00155 << abort(FatalError);
00156 }
00157
00158
00159 prepend(prevAdjncy, adjncy);
00160
00161 xadj += prevAdjncy.size();
00162 prepend(prevXadj, xadj);
00163
00164 prepend(prevXyz, xyz);
00165
00166 prepend(prevCellWeights, cellWeights);
00167 prepend(prevFaceWeights, faceWeights);
00168 }
00169
00170
00171
00172
00173 if (nSendCells[Pstream::myProcNo()] > 0)
00174 {
00175
00176 OPstream toNextProc(Pstream::blocking, Pstream::myProcNo()+1);
00177
00178 int nCells = nSendCells[Pstream::myProcNo()];
00179 int startCell = xadj.size()-1 - nCells;
00180 int startFace = xadj[startCell];
00181 int nFaces = adjncy.size()-startFace;
00182
00183
00184
00185 toNextProc
00186 << Field<int>::subField(xadj, nCells, startCell)-startFace
00187 << Field<int>::subField(adjncy, nFaces, startFace)
00188 << SubField<floatScalar>(xyz, nDims*nCells, nDims*startCell)
00189 <<
00190 (
00191 cellWeights.size()
00192 ? static_cast<const Field<int>&>
00193 (
00194 Field<int>::subField(cellWeights, nCells, startCell)
00195 )
00196 : Field<int>(0)
00197 )
00198 <<
00199 (
00200 faceWeights.size()
00201 ? static_cast<const Field<int>&>
00202 (
00203 Field<int>::subField(faceWeights, nFaces, startFace)
00204 )
00205 : Field<int>(0)
00206 );
00207
00208
00209 if (faceWeights.size())
00210 {
00211 faceWeights.setSize(faceWeights.size()-nFaces);
00212 }
00213 if (cellWeights.size())
00214 {
00215 cellWeights.setSize(cellWeights.size()-nCells);
00216 }
00217 xyz.setSize(xyz.size()-nDims*nCells);
00218 adjncy.setSize(adjncy.size()-nFaces);
00219 xadj.setSize(xadj.size() - nCells);
00220 }
00221
00222
00223
00224
00225 forAll(nSendCells, procI)
00226 {
00227
00228 nLocalCells[procI] -= nSendCells[procI];
00229
00230 if (procI >= 1)
00231 {
00232
00233 nLocalCells[procI] += nSendCells[procI-1];
00234 }
00235 }
00236
00237 nGlobalCells = 0;
00238 forAll(nLocalCells, procI)
00239 {
00240 cellOffsets[procI] = nGlobalCells;
00241 nGlobalCells += nLocalCells[procI];
00242 }
00243
00244
00245 if (nLocalCells[Pstream::myProcNo()] != (xadj.size()-1))
00246 {
00247 FatalErrorIn("parMetisDecomp::decompose(..)")
00248 << "Have connectivity for " << xadj.size()-1
00249 << " cells but nLocalCells:" << nLocalCells[Pstream::myProcNo()]
00250 << abort(FatalError);
00251 }
00252
00253
00254 int wgtFlag = 0;
00255 int* vwgtPtr = NULL;
00256 int* adjwgtPtr = NULL;
00257
00258 if (cellWeights.size())
00259 {
00260 vwgtPtr = cellWeights.begin();
00261 wgtFlag += 2;
00262 }
00263 if (faceWeights.size())
00264 {
00265 adjwgtPtr = faceWeights.begin();
00266 wgtFlag += 1;
00267 }
00268
00269
00270
00271 int nCon = 1;
00272
00273 Field<floatScalar> tpwgts(nCon*nProcessors_, 1./nProcessors_);
00274
00275 Field<floatScalar> ubvec(nCon, 1.02);
00276 if (nProcessors_ == 1)
00277 {
00278
00279 ubvec[0] = 1;
00280 }
00281
00282 MPI_Comm comm = MPI_COMM_WORLD;
00283
00284
00285 finalDecomp.setSize(nLocalCells[Pstream::myProcNo()]);
00286
00287
00288 int edgeCut = 0;
00289
00290
00291 ParMETIS_V3_PartGeomKway
00292 (
00293 cellOffsets.begin(),
00294 xadj.begin(),
00295 adjncy.begin(),
00296 vwgtPtr,
00297 adjwgtPtr,
00298 &wgtFlag,
00299 &numFlag,
00300 &nDims,
00301 xyz.begin(),
00302 &nCon,
00303 &nProcessors_,
00304 tpwgts.begin(),
00305 ubvec.begin(),
00306 const_cast<List<int>&>(options).begin(),
00307 &edgeCut,
00308 finalDecomp.begin(),
00309 &comm
00310 );
00311
00312
00313
00314
00315
00316
00317 if (nSendCells[Pstream::myProcNo()] > 0)
00318 {
00319 IPstream fromNextProc(Pstream::blocking, Pstream::myProcNo()+1);
00320
00321 List<int> nextFinalDecomp(fromNextProc);
00322
00323 if (nextFinalDecomp.size() != nSendCells[Pstream::myProcNo()])
00324 {
00325 FatalErrorIn("parMetisDecomp::decompose(..)")
00326 << "Expected from processor " << Pstream::myProcNo()+1
00327 << " decomposition for " << nSendCells[Pstream::myProcNo()]
00328 << " nCells but only received " << nextFinalDecomp.size()
00329 << abort(FatalError);
00330 }
00331
00332 append(nextFinalDecomp, finalDecomp);
00333 }
00334
00335
00336 if (Pstream::myProcNo() >= 1 && nSendCells[Pstream::myProcNo()-1] > 0)
00337 {
00338 OPstream toPrevProc(Pstream::blocking, Pstream::myProcNo()-1);
00339
00340 int nToPrevious = nSendCells[Pstream::myProcNo()-1];
00341
00342 toPrevProc <<
00343 SubList<int>
00344 (
00345 finalDecomp,
00346 nToPrevious,
00347 finalDecomp.size()-nToPrevious
00348 );
00349
00350
00351 finalDecomp.setSize(finalDecomp.size()-nToPrevious);
00352 }
00353
00354 return edgeCut;
00355 }
00356
00357
00358
00359
00360 Foam::parMetisDecomp::parMetisDecomp
00361 (
00362 const dictionary& decompositionDict,
00363 const polyMesh& mesh
00364 )
00365 :
00366 decompositionMethod(decompositionDict),
00367 mesh_(mesh)
00368 {}
00369
00370
00371
00372
00373 Foam::labelList Foam::parMetisDecomp::decompose(const pointField& points)
00374 {
00375 if (points.size() != mesh_.nCells())
00376 {
00377 FatalErrorIn("parMetisDecomp::decompose(const pointField&)")
00378 << "Can use this decomposition method only for the whole mesh"
00379 << endl
00380 << "and supply one coordinate (cellCentre) for every cell." << endl
00381 << "The number of coordinates " << points.size() << endl
00382 << "The number of cells in the mesh " << mesh_.nCells()
00383 << exit(FatalError);
00384 }
00385
00386
00387 if (Pstream::nProcs() <= 1)
00388 {
00389 return metisDecomp(decompositionDict_, mesh_).decompose(points);
00390 }
00391
00392
00393
00394
00395
00396 List<int> nLocalCells(Pstream::nProcs());
00397 nLocalCells[Pstream::myProcNo()] = mesh_.nCells();
00398 Pstream::gatherList(nLocalCells);
00399 Pstream::scatterList(nLocalCells);
00400
00401
00402 List<int> cellOffsets(Pstream::nProcs()+1);
00403 int nGlobalCells = 0;
00404 forAll(nLocalCells, procI)
00405 {
00406 cellOffsets[procI] = nGlobalCells;
00407 nGlobalCells += nLocalCells[procI];
00408 }
00409 cellOffsets[Pstream::nProcs()] = nGlobalCells;
00410
00411 int myOffset = cellOffsets[Pstream::myProcNo()];
00412
00413
00414
00415
00416
00417
00418
00419
00420
00421
00422 const labelList& faceOwner = mesh_.faceOwner();
00423 const labelList& faceNeighbour = mesh_.faceNeighbour();
00424 const polyBoundaryMesh& patches = mesh_.boundaryMesh();
00425
00426
00427
00428
00429
00430 List<int> globalNeighbour(mesh_.nFaces()-mesh_.nInternalFaces());
00431
00432 forAll(patches, patchI)
00433 {
00434 const polyPatch& pp = patches[patchI];
00435
00436 if (pp.coupled())
00437 {
00438 label faceI = pp.start();
00439 label bFaceI = pp.start() - mesh_.nInternalFaces();
00440
00441 forAll(pp, i)
00442 {
00443 globalNeighbour[bFaceI++] = faceOwner[faceI++] + myOffset;
00444 }
00445 }
00446 }
00447
00448
00449 syncTools::swapBoundaryFaceList(mesh_, globalNeighbour, false);
00450
00451
00452
00453
00454
00455
00456 List<int> nFacesPerCell(mesh_.nCells(), 0);
00457
00458
00459 label nCoupledFaces = 0;
00460
00461 for (label faceI = 0; faceI < mesh_.nInternalFaces(); faceI++)
00462 {
00463 nFacesPerCell[faceOwner[faceI]]++;
00464 nFacesPerCell[faceNeighbour[faceI]]++;
00465 }
00466
00467 forAll(patches, patchI)
00468 {
00469 const polyPatch& pp = patches[patchI];
00470
00471 if (pp.coupled())
00472 {
00473 label faceI = pp.start();
00474
00475 forAll(pp, i)
00476 {
00477 nCoupledFaces++;
00478 nFacesPerCell[faceOwner[faceI++]]++;
00479 }
00480 }
00481 }
00482
00483
00484
00485
00486
00487 Field<int> xadj(mesh_.nCells()+1, -1);
00488
00489 int freeAdj = 0;
00490
00491 for (label cellI = 0; cellI < mesh_.nCells(); cellI++)
00492 {
00493 xadj[cellI] = freeAdj;
00494
00495 freeAdj += nFacesPerCell[cellI];
00496 }
00497 xadj[mesh_.nCells()] = freeAdj;
00498
00499
00500
00501
00502
00503
00504 Field<int> adjncy(2*mesh_.nInternalFaces() + nCoupledFaces, -1);
00505
00506 nFacesPerCell = 0;
00507
00508
00509 for (label faceI = 0; faceI < mesh_.nInternalFaces(); faceI++)
00510 {
00511 label own = faceOwner[faceI];
00512 label nei = faceNeighbour[faceI];
00513
00514 adjncy[xadj[own] + nFacesPerCell[own]++] = nei + myOffset;
00515 adjncy[xadj[nei] + nFacesPerCell[nei]++] = own + myOffset;
00516 }
00517
00518 forAll(patches, patchI)
00519 {
00520 const polyPatch& pp = patches[patchI];
00521
00522 if (pp.coupled())
00523 {
00524 label faceI = pp.start();
00525 label bFaceI = pp.start()-mesh_.nInternalFaces();
00526
00527 forAll(pp, i)
00528 {
00529 label own = faceOwner[faceI];
00530 adjncy[xadj[own] + nFacesPerCell[own]++] =
00531 globalNeighbour[bFaceI];
00532
00533 faceI++;
00534 bFaceI++;
00535 }
00536 }
00537 }
00538
00539
00540
00541
00542 List<int> options(3, 0);
00543
00544
00545
00546
00547
00548 Field<int> cellWeights;
00549
00550
00551 Field<int> faceWeights;
00552
00553
00554 if (decompositionDict_.found("metisCoeffs"))
00555 {
00556 const dictionary& metisCoeffs =
00557 decompositionDict_.subDict("metisCoeffs");
00558 word weightsFile;
00559
00560 if (metisCoeffs.readIfPresent("cellWeightsFile", weightsFile))
00561 {
00562 Info<< "parMetisDecomp : Using cell-based weights read from "
00563 << weightsFile << endl;
00564
00565 labelIOField cellIOWeights
00566 (
00567 IOobject
00568 (
00569 weightsFile,
00570 mesh_.time().timeName(),
00571 mesh_,
00572 IOobject::MUST_READ,
00573 IOobject::AUTO_WRITE
00574 )
00575 );
00576 cellWeights.transfer(cellIOWeights);
00577
00578 if (cellWeights.size() != mesh_.nCells())
00579 {
00580 FatalErrorIn("parMetisDecomp::decompose(const pointField&)")
00581 << "Number of cell weights " << cellWeights.size()
00582 << " read from " << cellIOWeights.objectPath()
00583 << " does not equal number of cells " << mesh_.nCells()
00584 << exit(FatalError);
00585 }
00586 }
00587
00588 if (metisCoeffs.readIfPresent("faceWeightsFile", weightsFile))
00589 {
00590 Info<< "parMetisDecomp : Using face-based weights read from "
00591 << weightsFile << endl;
00592
00593 labelIOField weights
00594 (
00595 IOobject
00596 (
00597 weightsFile,
00598 mesh_.time().timeName(),
00599 mesh_,
00600 IOobject::MUST_READ,
00601 IOobject::AUTO_WRITE
00602 )
00603 );
00604
00605 if (weights.size() != mesh_.nFaces())
00606 {
00607 FatalErrorIn("parMetisDecomp::decompose(const pointField&)")
00608 << "Number of face weights " << weights.size()
00609 << " does not equal number of internal and boundary faces "
00610 << mesh_.nFaces()
00611 << exit(FatalError);
00612 }
00613
00614 faceWeights.setSize(2*mesh_.nInternalFaces()+nCoupledFaces);
00615
00616
00617 nFacesPerCell = 0;
00618
00619
00620 for (label faceI = 0; faceI < mesh_.nInternalFaces(); faceI++)
00621 {
00622 label w = weights[faceI];
00623
00624 label own = faceOwner[faceI];
00625 label nei = faceNeighbour[faceI];
00626
00627 faceWeights[xadj[own] + nFacesPerCell[own]++] = w;
00628 faceWeights[xadj[nei] + nFacesPerCell[nei]++] = w;
00629 }
00630
00631 forAll(patches, patchI)
00632 {
00633 const polyPatch& pp = patches[patchI];
00634
00635 if (pp.coupled())
00636 {
00637 label faceI = pp.start();
00638
00639 forAll(pp, i)
00640 {
00641 label w = weights[faceI];
00642 label own = faceOwner[faceI];
00643 adjncy[xadj[own] + nFacesPerCell[own]++] = w;
00644 faceI++;
00645 }
00646 }
00647 }
00648 }
00649
00650 if (metisCoeffs.readIfPresent("options", options))
00651 {
00652 Info<< "Using Metis options " << options
00653 << nl << endl;
00654
00655 if (options.size() != 3)
00656 {
00657 FatalErrorIn("parMetisDecomp::decompose(const pointField&)")
00658 << "Number of options " << options.size()
00659 << " should be three." << exit(FatalError);
00660 }
00661 }
00662 }
00663
00664
00665
00666 List<int> finalDecomp;
00667 decompose
00668 (
00669 xadj,
00670 adjncy,
00671 points,
00672 cellWeights,
00673 faceWeights,
00674 options,
00675
00676 finalDecomp
00677 );
00678
00679
00680 labelList decomp(finalDecomp.size());
00681 forAll(decomp, i)
00682 {
00683 decomp[i] = finalDecomp[i];
00684 }
00685 return decomp;
00686 }
00687
00688
00689 Foam::labelList Foam::parMetisDecomp::decompose
00690 (
00691 const labelList& cellToRegion,
00692 const pointField& regionPoints
00693 )
00694 {
00695 const labelList& faceOwner = mesh_.faceOwner();
00696 const labelList& faceNeighbour = mesh_.faceNeighbour();
00697 const polyBoundaryMesh& patches = mesh_.boundaryMesh();
00698
00699 if (cellToRegion.size() != mesh_.nCells())
00700 {
00701 FatalErrorIn
00702 (
00703 "parMetisDecomp::decompose(const labelList&, const pointField&)"
00704 ) << "Size of cell-to-coarse map " << cellToRegion.size()
00705 << " differs from number of cells in mesh " << mesh_.nCells()
00706 << exit(FatalError);
00707 }
00708
00709
00710
00711 globalIndex globalRegions(regionPoints.size());
00712
00713
00714
00715
00716
00717 List<int> globalNeighbour(mesh_.nFaces()-mesh_.nInternalFaces());
00718
00719 forAll(patches, patchI)
00720 {
00721 const polyPatch& pp = patches[patchI];
00722
00723 if (pp.coupled())
00724 {
00725 label faceI = pp.start();
00726 label bFaceI = pp.start() - mesh_.nInternalFaces();
00727
00728 forAll(pp, i)
00729 {
00730 label ownRegion = cellToRegion[faceOwner[faceI]];
00731 globalNeighbour[bFaceI++] = globalRegions.toGlobal(ownRegion);
00732 faceI++;
00733 }
00734 }
00735 }
00736
00737
00738 syncTools::swapBoundaryFaceList(mesh_, globalNeighbour, false);
00739
00740
00741
00742
00743
00744 labelListList globalRegionRegions;
00745 {
00746 List<DynamicList<label> > dynRegionRegions(regionPoints.size());
00747
00748
00749 forAll(faceNeighbour, faceI)
00750 {
00751 label ownRegion = cellToRegion[faceOwner[faceI]];
00752 label neiRegion = cellToRegion[faceNeighbour[faceI]];
00753
00754 if (ownRegion != neiRegion)
00755 {
00756 label globalOwn = globalRegions.toGlobal(ownRegion);
00757 label globalNei = globalRegions.toGlobal(neiRegion);
00758
00759 if (findIndex(dynRegionRegions[ownRegion], globalNei) == -1)
00760 {
00761 dynRegionRegions[ownRegion].append(globalNei);
00762 }
00763 if (findIndex(dynRegionRegions[neiRegion], globalOwn) == -1)
00764 {
00765 dynRegionRegions[neiRegion].append(globalOwn);
00766 }
00767 }
00768 }
00769
00770
00771 forAll(patches, patchI)
00772 {
00773 const polyPatch& pp = patches[patchI];
00774
00775 if (pp.coupled())
00776 {
00777 label faceI = pp.start();
00778 label bFaceI = pp.start() - mesh_.nInternalFaces();
00779
00780 forAll(pp, i)
00781 {
00782 label ownRegion = cellToRegion[faceOwner[faceI]];
00783 label globalNei = globalNeighbour[bFaceI++];
00784 faceI++;
00785
00786 if (findIndex(dynRegionRegions[ownRegion], globalNei) == -1)
00787 {
00788 dynRegionRegions[ownRegion].append(globalNei);
00789 }
00790 }
00791 }
00792 }
00793
00794 globalRegionRegions.setSize(dynRegionRegions.size());
00795 forAll(dynRegionRegions, i)
00796 {
00797 globalRegionRegions[i].transfer(dynRegionRegions[i]);
00798 }
00799 }
00800
00801 labelList regionDecomp(decompose(globalRegionRegions, regionPoints));
00802
00803
00804 labelList cellDistribution(cellToRegion.size());
00805
00806 forAll(cellDistribution, cellI)
00807 {
00808 cellDistribution[cellI] = regionDecomp[cellToRegion[cellI]];
00809 }
00810 return cellDistribution;
00811 }
00812
00813
00814 Foam::labelList Foam::parMetisDecomp::decompose
00815 (
00816 const labelListList& globalCellCells,
00817 const pointField& cellCentres
00818 )
00819 {
00820 if (cellCentres.size() != globalCellCells.size())
00821 {
00822 FatalErrorIn
00823 (
00824 "parMetisDecomp::decompose(const labelListList&, const pointField&)"
00825 ) << "Inconsistent number of cells (" << globalCellCells.size()
00826 << ") and number of cell centres (" << cellCentres.size()
00827 << ")." << exit(FatalError);
00828 }
00829
00830
00831 if (Pstream::nProcs() <= 1)
00832 {
00833 return metisDecomp(decompositionDict_, mesh_)
00834 .decompose(globalCellCells, cellCentres);
00835 }
00836
00837
00838
00839
00840
00841 Field<int> adjncy;
00842
00843 Field<int> xadj;
00844 metisDecomp::calcMetisCSR(globalCellCells, adjncy, xadj);
00845
00846
00847 List<int> options(3, 0);
00848
00849
00850
00851
00852
00853 Field<int> cellWeights;
00854
00855
00856 Field<int> faceWeights;
00857
00858
00859 if (decompositionDict_.found("metisCoeffs"))
00860 {
00861 const dictionary& metisCoeffs =
00862 decompositionDict_.subDict("metisCoeffs");
00863 word weightsFile;
00864
00865 if (metisCoeffs.readIfPresent("cellWeightsFile", weightsFile))
00866 {
00867 Info<< "parMetisDecomp : Using cell-based weights read from "
00868 << weightsFile << endl;
00869
00870 labelIOField cellIOWeights
00871 (
00872 IOobject
00873 (
00874 weightsFile,
00875 mesh_.time().timeName(),
00876 mesh_,
00877 IOobject::MUST_READ,
00878 IOobject::AUTO_WRITE
00879 )
00880 );
00881 cellWeights.transfer(cellIOWeights);
00882
00883 if (cellWeights.size() != cellCentres.size())
00884 {
00885 FatalErrorIn
00886 (
00887 "parMetisDecomp::decompose"
00888 "(const labelListList&, const pointField&)"
00889 ) << "Number of cell weights " << cellWeights.size()
00890 << " read from " << cellIOWeights.objectPath()
00891 << " does not equal number of cells " << cellCentres.size()
00892 << exit(FatalError);
00893 }
00894 }
00895
00896
00897
00898
00899
00900
00901
00902
00903
00904
00905
00906
00907
00908
00909
00910
00911
00912
00913
00914
00915
00916
00917
00918
00919
00920
00921
00922
00923
00924
00925
00926
00927
00928
00929
00930
00931
00932
00933
00934
00935
00936
00937
00938
00939
00940
00941
00942
00943
00944
00945
00946
00947
00948
00949
00950
00951
00952
00953
00954
00955
00956
00957
00958
00959 if (metisCoeffs.readIfPresent("options", options))
00960 {
00961 Info<< "Using Metis options " << options
00962 << nl << endl;
00963
00964 if (options.size() != 3)
00965 {
00966 FatalErrorIn
00967 (
00968 "parMetisDecomp::decompose"
00969 "(const labelListList&, const pointField&)"
00970 ) << "Number of options " << options.size()
00971 << " should be three." << exit(FatalError);
00972 }
00973 }
00974 }
00975
00976
00977
00978 List<int> finalDecomp;
00979 decompose
00980 (
00981 xadj,
00982 adjncy,
00983 cellCentres,
00984 cellWeights,
00985 faceWeights,
00986 options,
00987
00988 finalDecomp
00989 );
00990
00991
00992 labelList decomp(finalDecomp.size());
00993 forAll(decomp, i)
00994 {
00995 decomp[i] = finalDecomp[i];
00996 }
00997 return decomp;
00998 }
00999
01000
01001