pairPatchAgglomeration: Do not use the result agglomeratePatch if the return indicates it is not valid

Resolves bug-report http://www.openfoam.org/mantisbt/view.php?id=1157
This commit is contained in:
Henry Weller
2015-06-13 23:05:45 +01:00
parent e9f35a9d19
commit 406f0ab830

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-2013 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -147,6 +147,7 @@ void Foam::pairPatchAgglomeration::setEdgeWeights
if (eFaces.size() == 2) if (eFaces.size() == 2)
{ {
const edge edgeCommon = edge(eFaces[0], eFaces[1]); const edge edgeCommon = edge(eFaces[0], eFaces[1]);
if (facePairWeight_.found(edgeCommon)) if (facePairWeight_.found(edgeCommon))
{ {
facePairWeight_[edgeCommon] += edgeLength; facePairWeight_[edgeCommon] += edgeLength;
@ -155,6 +156,7 @@ void Foam::pairPatchAgglomeration::setEdgeWeights
{ {
facePairWeight_.insert(edgeCommon, edgeLength); facePairWeight_.insert(edgeCommon, edgeLength);
} }
// If the fine 'pair' faces was featured edge so it is // If the fine 'pair' faces was featured edge so it is
// the coarse 'pair' // the coarse 'pair'
if (fineFeaturedFaces.found(edgeCommon)) if (fineFeaturedFaces.found(edgeCommon))
@ -366,7 +368,7 @@ bool Foam::pairPatchAgglomeration::agglomeratePatch
void Foam::pairPatchAgglomeration:: agglomerate() void Foam::pairPatchAgglomeration:: agglomerate()
{ {
label nPairLevels = 0; label nPairLevels = 0;
label nCreatedLevels = 1; //0 level is the base patch label nCreatedLevels = 1; // 0 level is the base patch
label nCoarseFaces = 0; label nCoarseFaces = 0;
label nCoarseFacesOld = 0; label nCoarseFacesOld = 0;
@ -374,9 +376,9 @@ void Foam::pairPatchAgglomeration:: agglomerate()
{ {
const bPatch& patch = patchLevels_[nCreatedLevels - 1]; const bPatch& patch = patchLevels_[nCreatedLevels - 1];
tmp<labelField> finalAgglomPtr(new labelField(patch.size())); tmp<labelField> finalAgglomPtr(new labelField(patch.size()));
bool agglomOK = false; bool agglomOK = false;
while (!agglomOK)
do
{ {
finalAgglomPtr = agglomerateOneLevel finalAgglomPtr = agglomerateOneLevel
( (
@ -386,34 +388,42 @@ void Foam::pairPatchAgglomeration:: agglomerate()
if (nCoarseFaces > 0) if (nCoarseFaces > 0)
{ {
agglomOK = agglomeratePatch if
( (
patch, (
finalAgglomPtr, agglomOK = agglomeratePatch
nCreatedLevels (
); patch,
finalAgglomPtr,
restrictAddressing_.set(nCreatedLevels, finalAgglomPtr); nCreatedLevels
mapBaseToTopAgglom(nCreatedLevels); )
setEdgeWeights(nCreatedLevels); )
)
if (nPairLevels % mergeLevels_)
{ {
combineLevels(nCreatedLevels); restrictAddressing_.set(nCreatedLevels, finalAgglomPtr);
} mapBaseToTopAgglom(nCreatedLevels);
else setEdgeWeights(nCreatedLevels);
{
nCreatedLevels++;
}
nPairLevels++; if (nPairLevels % mergeLevels_)
{
combineLevels(nCreatedLevels);
}
else
{
nCreatedLevels++;
}
nPairLevels++;
}
} }
else else
{ {
agglomOK = true; agglomOK = true;
} }
reduce(nCoarseFaces, sumOp<label>()); reduce(nCoarseFaces, sumOp<label>());
}
} while (!agglomOK);
nFaces_[nCreatedLevels] = nCoarseFaces; nFaces_[nCreatedLevels] = nCoarseFaces;
@ -456,7 +466,7 @@ Foam::tmp<Foam::labelField> Foam::pairPatchAgglomeration::agglomerateOneLevel
label matchFaceNeibNo = -1; label matchFaceNeibNo = -1;
scalar maxFaceWeight = -GREAT; scalar maxFaceWeight = -GREAT;
// check faces to find ungrouped neighbour with largest face weight // Check faces to find ungrouped neighbour with largest face weight
forAll(fFaces, i) forAll(fFaces, i)
{ {
label faceNeig = fFaces[i]; label faceNeig = fFaces[i];