ENH: multiLevelDecomp : added debug statistics printing

This commit is contained in:
mattijs
2010-06-09 11:35:57 +01:00
parent e252ef2df3
commit 3137861e7e
3 changed files with 150 additions and 44 deletions

View File

@ -70,25 +70,6 @@ protected:
// (usually there is only one) // (usually there is only one)
static label masterFace(const polyMesh&, const label, const label); static label masterFace(const polyMesh&, const label, const label);
// // From mesh to compact row storage format
// // (like CompactListList)
// static void calcCSR
// (
// const polyMesh& mesh,
// List<int>& adjncy,
// List<int>& xadj
// );
//
// // From cell-cell connections to compact row storage format
// // (like CompactListList)
// static void calcCSR
// (
// const labelListList& cellCells,
// List<int>& adjncy,
// List<int>& xadj
// );
private: private:
// Private Member Functions // Private Member Functions

View File

@ -50,10 +50,14 @@ namespace Foam
// is in the cells from neighbouring processors which need to be renumbered. // is in the cells from neighbouring processors which need to be renumbered.
void Foam::multiLevelDecomp::subsetGlobalCellCells void Foam::multiLevelDecomp::subsetGlobalCellCells
( (
const label nDomains,
const label domainI,
const labelList& dist,
const labelListList& cellCells, const labelListList& cellCells,
const labelList& set, const labelList& set,
labelListList& subCellCells, labelListList& subCellCells,
label& cutConnections labelList& cutConnections
) const ) const
{ {
// Determine new index for cells by inverting subset // Determine new index for cells by inverting subset
@ -68,10 +72,14 @@ void Foam::multiLevelDecomp::subsetGlobalCellCells
List<Map<label> > compactMap; List<Map<label> > compactMap;
mapDistribute map(globalCells, subCellCells, compactMap); mapDistribute map(globalCells, subCellCells, compactMap);
map.distribute(oldToNew); map.distribute(oldToNew);
labelList allDist(dist);
map.distribute(allDist);
// Now subCellCells contains indices into oldToNew which are the // Now subCellCells contains indices into oldToNew which are the
// new locations of the neighbouring cells. // new locations of the neighbouring cells.
cutConnections.setSize(nDomains);
cutConnections = 0; cutConnections = 0;
forAll(subCellCells, subCellI) forAll(subCellCells, subCellI)
@ -85,7 +93,7 @@ void Foam::multiLevelDecomp::subsetGlobalCellCells
label subCellI = oldToNew[cCells[i]]; label subCellI = oldToNew[cCells[i]];
if (subCellI == -1) if (subCellI == -1)
{ {
cutConnections++; cutConnections[allDist[cCells[i]]]++;
} }
else else
{ {
@ -118,16 +126,6 @@ void Foam::multiLevelDecomp::decompose
) )
); );
//Pout<< "At level " << levelI << endl;
//forAll(dist, i)
//{
// Pout<< " " << i << " at:" << points[i]
// << " original:" << pointMap[i] << " dist:" << dist[i]
// << " connected to:" << pointField(points, pointPoints[i])
// << endl;
//}
//Pout<< endl;
forAll(pointMap, i) forAll(pointMap, i)
{ {
label orig = pointMap[i]; label orig = pointMap[i];
@ -146,30 +144,62 @@ void Foam::multiLevelDecomp::decompose
finalDecomp *= methods_[levelI+1].nDomains(); finalDecomp *= methods_[levelI+1].nDomains();
// Extract processor+local index from point-point addressing // Extract processor+local index from point-point addressing
if (debug && Pstream::master())
forAll(domainToPoints, domainI)
{ {
const labelList& myPoints = domainToPoints[domainI]; Pout<< "Decomposition at level " << levelI << " :" << endl;
}
for (label domainI = 0; domainI < n; domainI++)
{
// Extract elements for current domain
const labelList domainPoints(findIndices(dist, domainI));
// Subset point-wise data. // Subset point-wise data.
pointField subPoints(points, myPoints); pointField subPoints(points, domainPoints);
scalarField subWeights(pointWeights, myPoints); scalarField subWeights(pointWeights, domainPoints);
labelList subPointMap(UIndirectList<label>(pointMap, myPoints)); labelList subPointMap(UIndirectList<label>(pointMap, domainPoints));
// Subset point-point addressing (adapt global numbering) // Subset point-point addressing (adapt global numbering)
labelListList subPointPoints; labelListList subPointPoints;
label nOutsideConnections; labelList nOutsideConnections;
subsetGlobalCellCells subsetGlobalCellCells
( (
n,
domainI,
dist,
pointPoints, pointPoints,
myPoints, domainPoints,
subPointPoints, subPointPoints,
nOutsideConnections nOutsideConnections
); );
//Info<< "At level " << levelI << " domain " << domainI label nPoints = returnReduce(domainPoints.size(), plusOp<label>());
// << " have connections to other domains " Pstream::listCombineGather(nOutsideConnections, plusEqOp<label>());
// << returnReduce(nOutsideConnections, sumOp<label>()) Pstream::listCombineScatter(nOutsideConnections);
// << endl; label nPatches = 0;
label nFaces = 0;
forAll(nOutsideConnections, i)
{
if (nOutsideConnections[i] > 0)
{
nPatches++;
nFaces += nOutsideConnections[i];
}
}
string oldPrefix;
if (debug && Pstream::master())
{
Pout<< " Domain " << domainI << nl
<< " Number of cells = " << nPoints << nl
<< " Number of inter-domain patches = " << nPatches
<< nl
<< " Number of inter-domain faces = " << nFaces << nl
<< endl;
oldPrefix = Pout.prefix();
Pout.prefix() = " " + oldPrefix;
}
decompose decompose
( (
@ -181,6 +211,97 @@ void Foam::multiLevelDecomp::decompose
finalDecomp finalDecomp
); );
if (debug && Pstream::master())
{
Pout.prefix() = oldPrefix;
}
}
if (debug)
{
// Do straight decompose of two levels
label nNext = methods_[levelI+1].nDomains();
label nTotal = n*nNext;
// Retrieve original level0 dictionary and modify number of domains
dictionary::const_iterator iter = decompositionDict_.begin();
dictionary myDict = iter().dict();
myDict.set("numberOfSubdomains", nTotal);
if (debug && Pstream::master())
{
Pout<< "Reference decomposition with " << myDict << " :"
<< endl;
}
autoPtr<decompositionMethod> method0 = decompositionMethod::New
(
myDict
);
labelList dist
(
method0().decompose
(
pointPoints,
points,
pointWeights
)
);
for (label blockI = 0; blockI < n; blockI++)
{
// Count the number inbetween blocks of nNext size
label nPoints = 0;
labelList nOutsideConnections(n, 0);
forAll(pointPoints, pointI)
{
if ((dist[pointI] / nNext) == blockI)
{
nPoints++;
const labelList& pPoints = pointPoints[pointI];
forAll(pPoints, i)
{
label distBlockI = dist[pPoints[i]] / nNext;
if (distBlockI != blockI)
{
nOutsideConnections[distBlockI]++;
}
}
}
}
reduce(nPoints, plusOp<label>());
Pstream::listCombineGather
(
nOutsideConnections,
plusEqOp<label>()
);
Pstream::listCombineScatter(nOutsideConnections);
label nPatches = 0;
label nFaces = 0;
forAll(nOutsideConnections, i)
{
if (nOutsideConnections[i] > 0)
{
nPatches++;
nFaces += nOutsideConnections[i];
}
}
if (debug && Pstream::master())
{
Pout<< " Domain " << blockI << nl
<< " Number of cells = " << nPoints << nl
<< " Number of inter-domain patches = "
<< nPatches << nl
<< " Number of inter-domain faces = " << nFaces
<< nl << endl;
}
}
} }
} }
} }

View File

@ -59,10 +59,14 @@ class multiLevelDecomp
// for a (consistent) subset // for a (consistent) subset
void subsetGlobalCellCells void subsetGlobalCellCells
( (
const label nDomains,
const label domainI,
const labelList& dist,
const labelListList& cellCells, const labelListList& cellCells,
const labelList& set, const labelList& set,
labelListList& subCellCells, labelListList& subCellCells,
label& cutConnections labelList& cutConnections
) const; ) const;
//- Decompose level methodI without addressing //- Decompose level methodI without addressing