From f7d3cdc5fb94ca3ad71b573c97164a54ecc72bc7 Mon Sep 17 00:00:00 2001 From: mattijs Date: Tue, 6 Aug 2013 17:16:00 +0100 Subject: [PATCH] ENH: metis: updated to metis5.1 --- src/parallel/decompose/Allwmake | 2 +- .../decompose/metisDecomp/Make/options | 1 + .../decompose/metisDecomp/metisDecomp.C | 134 +++++++----------- 3 files changed, 54 insertions(+), 83 deletions(-) diff --git a/src/parallel/decompose/Allwmake b/src/parallel/decompose/Allwmake index 3b10cc617e..e6d0a1dee5 100755 --- a/src/parallel/decompose/Allwmake +++ b/src/parallel/decompose/Allwmake @@ -64,7 +64,7 @@ fi # Try and build metisDecomp (has own logic) -(cd metisDecomp && Allwmake) +(cd metisDecomp && ./Allwmake $makeType) wmake $makeType decompositionMethods diff --git a/src/parallel/decompose/metisDecomp/Make/options b/src/parallel/decompose/metisDecomp/Make/options index d4dfa96ba2..8acd678fd3 100644 --- a/src/parallel/decompose/metisDecomp/Make/options +++ b/src/parallel/decompose/metisDecomp/Make/options @@ -1,4 +1,5 @@ EXE_INC = \ + /* -DFULLDEBUG -g -O0 */ \ -I$(METIS_ARCH_PATH)/include \ -I../decompositionMethods/lnInclude diff --git a/src/parallel/decompose/metisDecomp/metisDecomp.C b/src/parallel/decompose/metisDecomp/metisDecomp.C index e1614a84c0..2dac90ae14 100644 --- a/src/parallel/decompose/metisDecomp/metisDecomp.C +++ b/src/parallel/decompose/metisDecomp/metisDecomp.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -58,17 +58,18 @@ Foam::label Foam::metisDecomp::decompose ) { // C style numbering - int numFlag = 0; + //int numFlag = 0; // Method of decomposition // recursive: multi-level recursive bisection (default) // k-way: multi-level k-way - word method("k-way"); + word method("recursive"); int numCells = xadj.size()-1; - // decomposition options. 0 = use defaults - List options(5, 0); + // decomposition options + List options(METIS_NOPTIONS); + METIS_SetDefaultOptions(options.begin()); // processor weights initialised with no size, only used if specified in // a file @@ -138,12 +139,12 @@ Foam::label Foam::metisDecomp::decompose if (metisCoeffs.readIfPresent("options", options)) { - if (options.size() != 5) + if (options.size() != METIS_NOPTIONS) { FatalErrorIn("metisDecomp::decompose()") << "Number of options in metisCoeffs in dictionary : " << decompositionDict_.name() - << " should be 5" + << " should be " << METIS_NOPTIONS << exit(FatalError); } @@ -192,6 +193,8 @@ Foam::label Foam::metisDecomp::decompose //} } + int ncon = 1; + int nProcs = nProcessors_; // output: cell -> processor addressing @@ -201,96 +204,56 @@ Foam::label Foam::metisDecomp::decompose int edgeCut = 0; // Vertex weight info - int wgtFlag = 0; int* vwgtPtr = NULL; int* adjwgtPtr = NULL; if (cellWeights.size()) { vwgtPtr = cellWeights.begin(); - wgtFlag += 2; // Weights on vertices } if (faceWeights.size()) { adjwgtPtr = faceWeights.begin(); - wgtFlag += 1; // Weights on edges } + if (method == "recursive") { - if (processorWeights.size()) - { - METIS_WPartGraphRecursive - ( - &numCells, // num vertices in graph - const_cast&>(xadj).begin(), // indexing into adjncy - const_cast&>(adjncy).begin(), // neighbour info - vwgtPtr, // vertexweights - adjwgtPtr, // no edgeweights - &wgtFlag, - &numFlag, - &nProcs, - processorWeights.begin(), - options.begin(), - &edgeCut, - finalDecomp.begin() - ); - } - else - { - METIS_PartGraphRecursive - ( - &numCells, // num vertices in graph - const_cast&>(xadj).begin(), // indexing into adjncy - const_cast&>(adjncy).begin(), // neighbour info - vwgtPtr, // vertexweights - adjwgtPtr, // no edgeweights - &wgtFlag, - &numFlag, - &nProcs, - options.begin(), - &edgeCut, - finalDecomp.begin() - ); - } + METIS_PartGraphRecursive + ( + &numCells, // num vertices in graph + &ncon, // num balancing constraints + const_cast&>(xadj).begin(), // indexing into adjncy + const_cast&>(adjncy).begin(), // neighbour info + cellWeights.begin(),// vertexweights + NULL, // vsize: total communication vol + faceWeights.begin(),// edgeweights + &nProcs, // nParts + processorWeights.begin(), // tpwgts + NULL, // ubvec: processor imbalance (default) + options.begin(), + &edgeCut, + finalDecomp.begin() + ); } else { - if (processorWeights.size()) - { - METIS_WPartGraphKway - ( - &numCells, // num vertices in graph - const_cast&>(xadj).begin(), // indexing into adjncy - const_cast&>(adjncy).begin(), // neighbour info - vwgtPtr, // vertexweights - adjwgtPtr, // no edgeweights - &wgtFlag, - &numFlag, - &nProcs, - processorWeights.begin(), - options.begin(), - &edgeCut, - finalDecomp.begin() - ); - } - else - { - METIS_PartGraphKway - ( - &numCells, // num vertices in graph - const_cast&>(xadj).begin(), // indexing into adjncy - const_cast&>(adjncy).begin(), // neighbour info - vwgtPtr, // vertexweights - adjwgtPtr, // no edgeweights - &wgtFlag, - &numFlag, - &nProcs, - options.begin(), - &edgeCut, - finalDecomp.begin() - ); - } + METIS_PartGraphKway + ( + &numCells, // num vertices in graph + &ncon, // num balancing constraints + const_cast&>(xadj).begin(), // indexing into adjncy + const_cast&>(adjncy).begin(), // neighbour info + cellWeights.begin(),// vertexweights + NULL, // vsize: total communication vol + faceWeights.begin(),// edgeweights + &nProcs, // nParts + processorWeights.begin(), // tpwgts + NULL, // ubvec: processor imbalance (default) + options.begin(), + &edgeCut, + finalDecomp.begin() + ); } return edgeCut; @@ -328,7 +291,14 @@ Foam::labelList Foam::metisDecomp::decompose } CompactListList