mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: renumberMesh: changed api of renumber library.
Changed API. Made bandCompression proper CutHillMcKey. Better stats.
This commit is contained in:
@ -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-2012 OpenFOAM Foundation
|
||||
\\/ M anispulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -105,6 +105,44 @@ label getBand(const labelList& owner, const labelList& neighbour)
|
||||
}
|
||||
|
||||
|
||||
// Calculate band of matrix
|
||||
void getBand
|
||||
(
|
||||
const label nCells,
|
||||
const labelList& owner,
|
||||
const labelList& neighbour,
|
||||
label& bandwidth,
|
||||
scalar& profile, // scalar to avoid overflow
|
||||
scalar& sumSqrIntersect // scalar to avoid overflow
|
||||
)
|
||||
{
|
||||
labelList cellBandwidth(nCells, 0);
|
||||
scalarField nIntersect(nCells, 0.0);
|
||||
|
||||
forAll(neighbour, faceI)
|
||||
{
|
||||
label own = owner[faceI];
|
||||
label nei = neighbour[faceI];
|
||||
|
||||
// Note: mag not necessary for correct (upper-triangular) ordering.
|
||||
label diff = nei-own;
|
||||
cellBandwidth[nei] = max(cellBandwidth[nei], diff);
|
||||
}
|
||||
|
||||
forAll(nIntersect, cellI)
|
||||
{
|
||||
for (label rowI = cellI-cellBandwidth[cellI]; rowI < cellI; rowI++)
|
||||
{
|
||||
nIntersect[rowI]++;
|
||||
}
|
||||
}
|
||||
|
||||
bandwidth = max(cellBandwidth);
|
||||
profile = sum(cellBandwidth);
|
||||
sumSqrIntersect = sum(Foam::sqr(nIntersect));
|
||||
}
|
||||
|
||||
|
||||
// Determine upper-triangular face order
|
||||
labelList getFaceOrder
|
||||
(
|
||||
@ -488,21 +526,12 @@ labelList regionRenumber
|
||||
|
||||
const fvMesh& subMesh = subsetter.subMesh();
|
||||
|
||||
labelList subReverseCellOrder = method.renumber
|
||||
labelList subCellOrder = method.renumber
|
||||
(
|
||||
subMesh,
|
||||
subMesh.cellCentres()
|
||||
);
|
||||
|
||||
labelList subCellOrder
|
||||
(
|
||||
invert
|
||||
(
|
||||
subMesh.nCells(),
|
||||
subReverseCellOrder
|
||||
)
|
||||
);
|
||||
|
||||
// Restore state
|
||||
UPstream::parRun() = oldParRun;
|
||||
|
||||
@ -556,13 +585,46 @@ int main(int argc, char *argv[])
|
||||
|
||||
const bool overwrite = args.optionFound("overwrite");
|
||||
|
||||
label band = getBand(mesh.faceOwner(), mesh.faceNeighbour());
|
||||
label band;
|
||||
scalar profile;
|
||||
scalar sumSqrIntersect;
|
||||
getBand
|
||||
(
|
||||
mesh.nCells(),
|
||||
mesh.faceOwner(),
|
||||
mesh.faceNeighbour(),
|
||||
band,
|
||||
profile,
|
||||
sumSqrIntersect
|
||||
);
|
||||
|
||||
Info<< "Mesh size: " << returnReduce(mesh.nCells(), sumOp<label>()) << nl
|
||||
<< "Band before renumbering: "
|
||||
<< returnReduce(band, maxOp<label>()) << nl << endl;
|
||||
if (band != getBand(mesh.faceOwner(), mesh.faceNeighbour()))
|
||||
{
|
||||
FatalErrorIn(args.executable())
|
||||
<< "band:" << band
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
|
||||
reduce(band, maxOp<label>());
|
||||
reduce(profile, sumOp<scalar>());
|
||||
scalar rmsFrontwidth = Foam::sqrt
|
||||
(
|
||||
returnReduce
|
||||
(
|
||||
sumSqrIntersect,
|
||||
sumOp<scalar>()
|
||||
)
|
||||
/ mesh.globalData().nTotalCells()
|
||||
);
|
||||
|
||||
Info<< "Mesh size: " << mesh.globalData().nTotalCells() << nl
|
||||
<< "Before renumbering :" << nl
|
||||
<< " band : " << band << nl
|
||||
<< " profile : " << profile << nl
|
||||
<< " rms frontwidth : " << rmsFrontwidth << nl
|
||||
<< endl;
|
||||
|
||||
bool sortCoupledFaceCells = false;
|
||||
bool writeMaps = false;
|
||||
bool orderPoints = false;
|
||||
@ -803,14 +865,13 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
else
|
||||
{
|
||||
// Detemines old to new cell ordering
|
||||
labelList reverseCellOrder = renumberPtr().renumber
|
||||
// Detemines sorted back to original cell ordering
|
||||
cellOrder = renumberPtr().renumber
|
||||
(
|
||||
mesh,
|
||||
mesh.cellCentres()
|
||||
);
|
||||
|
||||
cellOrder = invert(mesh.nCells(), reverseCellOrder);
|
||||
labelList reverseCellOrder = invert(mesh.nCells(), cellOrder);
|
||||
|
||||
|
||||
if (sortCoupledFaceCells)
|
||||
@ -969,11 +1030,36 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
|
||||
band = getBand(mesh.faceOwner(), mesh.faceNeighbour());
|
||||
|
||||
Info<< "Band after renumbering: "
|
||||
<< returnReduce(band, maxOp<label>()) << nl << endl;
|
||||
|
||||
{
|
||||
label band;
|
||||
scalar profile;
|
||||
scalar sumSqrIntersect;
|
||||
getBand
|
||||
(
|
||||
mesh.nCells(),
|
||||
mesh.faceOwner(),
|
||||
mesh.faceNeighbour(),
|
||||
band,
|
||||
profile,
|
||||
sumSqrIntersect
|
||||
);
|
||||
reduce(band, maxOp<label>());
|
||||
reduce(profile, sumOp<scalar>());
|
||||
scalar rmsFrontwidth = Foam::sqrt
|
||||
(
|
||||
returnReduce
|
||||
(
|
||||
sumSqrIntersect,
|
||||
sumOp<scalar>()
|
||||
)
|
||||
/ mesh.globalData().nTotalCells()
|
||||
);
|
||||
Info<< "After renumbering :" << nl
|
||||
<< " band : " << band << nl
|
||||
<< " profile : " << profile << nl
|
||||
<< " rms frontwidth : " << rmsFrontwidth << nl
|
||||
<< endl;
|
||||
}
|
||||
|
||||
if (orderPoints)
|
||||
{
|
||||
|
||||
@ -50,7 +50,7 @@ method CuthillMcKee;
|
||||
|
||||
manualCoeffs
|
||||
{
|
||||
// In system directory: old to new labelIOList
|
||||
// In system directory: new-to-original (i.e. order) labelIOList
|
||||
dataFile "cellMap";
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user