GAMGAgglomeration: Add support for nCellsInCoarsestLevel = 1 and better agglomeration termination

Patch provided by Mattijs Janssens
Resolves bug-report http://bugs.openfoam.org/view.php?id=2226
This commit is contained in:
Henry Weller
2016-09-06 13:29:05 +01:00
parent 41eeaaede4
commit 427f2c65b9
3 changed files with 17 additions and 6 deletions

View File

@ -206,13 +206,20 @@ void Foam::GAMGAgglomeration::compactLevels(const label nCreatedLevels)
bool Foam::GAMGAgglomeration::continueAgglomerating
(
const label nFineCells,
const label nCoarseCells
) const
{
// Check the need for further agglomeration on all processors
bool contAgg = nCoarseCells >= nCellsInCoarsestLevel_;
mesh().reduce(contAgg, andOp<bool>());
return contAgg;
const label nTotalCoarseCells = returnReduce(nCoarseCells, sumOp<label>());
if (nTotalCoarseCells >= Pstream::nProcs()*nCellsInCoarsestLevel_)
{
return true;
}
else
{
const label nTotalFineCells = returnReduce(nFineCells, sumOp<label>());
return nTotalCoarseCells < nTotalFineCells;
}
}

View File

@ -152,7 +152,11 @@ protected:
void compactLevels(const label nCreatedLevels);
//- Check the need for further agglomeration
bool continueAgglomerating(const label nCoarseCells) const;
bool continueAgglomerating
(
const label nCells,
const label nCoarseCells
) const;
//- Gather value from all procIDs onto procIDs[0]
template<class Type>

View File

@ -54,7 +54,7 @@ void Foam::pairGAMGAgglomeration::agglomerate
*faceWeightsPtr
);
if (continueAgglomerating(nCoarseCells))
if (continueAgglomerating(finalAgglomPtr().size(), nCoarseCells))
{
nCells_[nCreatedLevels] = nCoarseCells;
restrictAddressing_.set(nCreatedLevels, finalAgglomPtr);