ENH: metis: updated to metis5.1

This commit is contained in:
mattijs
2013-08-06 17:16:00 +01:00
parent 4df81a990b
commit f7d3cdc5fb
3 changed files with 54 additions and 83 deletions

View File

@ -64,7 +64,7 @@ fi
# Try and build metisDecomp (has own logic) # Try and build metisDecomp (has own logic)
(cd metisDecomp && Allwmake) (cd metisDecomp && ./Allwmake $makeType)
wmake $makeType decompositionMethods wmake $makeType decompositionMethods

View File

@ -1,4 +1,5 @@
EXE_INC = \ EXE_INC = \
/* -DFULLDEBUG -g -O0 */ \
-I$(METIS_ARCH_PATH)/include \ -I$(METIS_ARCH_PATH)/include \
-I../decompositionMethods/lnInclude -I../decompositionMethods/lnInclude

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -58,17 +58,18 @@ Foam::label Foam::metisDecomp::decompose
) )
{ {
// C style numbering // C style numbering
int numFlag = 0; //int numFlag = 0;
// Method of decomposition // Method of decomposition
// recursive: multi-level recursive bisection (default) // recursive: multi-level recursive bisection (default)
// k-way: multi-level k-way // k-way: multi-level k-way
word method("k-way"); word method("recursive");
int numCells = xadj.size()-1; int numCells = xadj.size()-1;
// decomposition options. 0 = use defaults // decomposition options
List<int> options(5, 0); List<int> options(METIS_NOPTIONS);
METIS_SetDefaultOptions(options.begin());
// processor weights initialised with no size, only used if specified in // processor weights initialised with no size, only used if specified in
// a file // a file
@ -138,12 +139,12 @@ Foam::label Foam::metisDecomp::decompose
if (metisCoeffs.readIfPresent("options", options)) if (metisCoeffs.readIfPresent("options", options))
{ {
if (options.size() != 5) if (options.size() != METIS_NOPTIONS)
{ {
FatalErrorIn("metisDecomp::decompose()") FatalErrorIn("metisDecomp::decompose()")
<< "Number of options in metisCoeffs in dictionary : " << "Number of options in metisCoeffs in dictionary : "
<< decompositionDict_.name() << decompositionDict_.name()
<< " should be 5" << " should be " << METIS_NOPTIONS
<< exit(FatalError); << exit(FatalError);
} }
@ -192,6 +193,8 @@ Foam::label Foam::metisDecomp::decompose
//} //}
} }
int ncon = 1;
int nProcs = nProcessors_; int nProcs = nProcessors_;
// output: cell -> processor addressing // output: cell -> processor addressing
@ -201,74 +204,33 @@ Foam::label Foam::metisDecomp::decompose
int edgeCut = 0; int edgeCut = 0;
// Vertex weight info // Vertex weight info
int wgtFlag = 0;
int* vwgtPtr = NULL; int* vwgtPtr = NULL;
int* adjwgtPtr = NULL; int* adjwgtPtr = NULL;
if (cellWeights.size()) if (cellWeights.size())
{ {
vwgtPtr = cellWeights.begin(); vwgtPtr = cellWeights.begin();
wgtFlag += 2; // Weights on vertices
} }
if (faceWeights.size()) if (faceWeights.size())
{ {
adjwgtPtr = faceWeights.begin(); adjwgtPtr = faceWeights.begin();
wgtFlag += 1; // Weights on edges
} }
if (method == "recursive") if (method == "recursive")
{
if (processorWeights.size())
{
METIS_WPartGraphRecursive
(
&numCells, // num vertices in graph
const_cast<List<int>&>(xadj).begin(), // indexing into adjncy
const_cast<List<int>&>(adjncy).begin(), // neighbour info
vwgtPtr, // vertexweights
adjwgtPtr, // no edgeweights
&wgtFlag,
&numFlag,
&nProcs,
processorWeights.begin(),
options.begin(),
&edgeCut,
finalDecomp.begin()
);
}
else
{ {
METIS_PartGraphRecursive METIS_PartGraphRecursive
( (
&numCells, // num vertices in graph &numCells, // num vertices in graph
&ncon, // num balancing constraints
const_cast<List<int>&>(xadj).begin(), // indexing into adjncy const_cast<List<int>&>(xadj).begin(), // indexing into adjncy
const_cast<List<int>&>(adjncy).begin(), // neighbour info const_cast<List<int>&>(adjncy).begin(), // neighbour info
vwgtPtr, // vertexweights cellWeights.begin(),// vertexweights
adjwgtPtr, // no edgeweights NULL, // vsize: total communication vol
&wgtFlag, faceWeights.begin(),// edgeweights
&numFlag, &nProcs, // nParts
&nProcs, processorWeights.begin(), // tpwgts
options.begin(), NULL, // ubvec: processor imbalance (default)
&edgeCut,
finalDecomp.begin()
);
}
}
else
{
if (processorWeights.size())
{
METIS_WPartGraphKway
(
&numCells, // num vertices in graph
const_cast<List<int>&>(xadj).begin(), // indexing into adjncy
const_cast<List<int>&>(adjncy).begin(), // neighbour info
vwgtPtr, // vertexweights
adjwgtPtr, // no edgeweights
&wgtFlag,
&numFlag,
&nProcs,
processorWeights.begin(),
options.begin(), options.begin(),
&edgeCut, &edgeCut,
finalDecomp.begin() finalDecomp.begin()
@ -279,19 +241,20 @@ Foam::label Foam::metisDecomp::decompose
METIS_PartGraphKway METIS_PartGraphKway
( (
&numCells, // num vertices in graph &numCells, // num vertices in graph
&ncon, // num balancing constraints
const_cast<List<int>&>(xadj).begin(), // indexing into adjncy const_cast<List<int>&>(xadj).begin(), // indexing into adjncy
const_cast<List<int>&>(adjncy).begin(), // neighbour info const_cast<List<int>&>(adjncy).begin(), // neighbour info
vwgtPtr, // vertexweights cellWeights.begin(),// vertexweights
adjwgtPtr, // no edgeweights NULL, // vsize: total communication vol
&wgtFlag, faceWeights.begin(),// edgeweights
&numFlag, &nProcs, // nParts
&nProcs, processorWeights.begin(), // tpwgts
NULL, // ubvec: processor imbalance (default)
options.begin(), options.begin(),
&edgeCut, &edgeCut,
finalDecomp.begin() finalDecomp.begin()
); );
} }
}
return edgeCut; return edgeCut;
} }
@ -328,7 +291,14 @@ Foam::labelList Foam::metisDecomp::decompose
} }
CompactListList<label> cellCells; CompactListList<label> cellCells;
calcCellCells(mesh, identity(mesh.nCells()), mesh.nCells(), cellCells); calcCellCells
(
mesh,
identity(mesh.nCells()),
mesh.nCells(),
false,
cellCells
);
// Decompose using default weights // Decompose using default weights
labelList decomp; labelList decomp;
@ -362,7 +332,7 @@ Foam::labelList Foam::metisDecomp::decompose
// xadj(celli) : start of information in adjncy for celli // xadj(celli) : start of information in adjncy for celli
CompactListList<label> cellCells; CompactListList<label> cellCells;
calcCellCells(mesh, agglom, agglomPoints.size(), cellCells); calcCellCells(mesh, agglom, agglomPoints.size(), false, cellCells);
// Decompose using default weights // Decompose using default weights
labelList finalDecomp; labelList finalDecomp;