From 406f0ab8305c94b825c839f791d36be8064a7f50 Mon Sep 17 00:00:00 2001 From: Henry Weller Date: Sat, 13 Jun 2015 23:05:45 +0100 Subject: [PATCH] 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 --- .../pairPatchAgglomeration.C | 58 +++++++++++-------- 1 file changed, 34 insertions(+), 24 deletions(-) diff --git a/src/fvAgglomerationMethods/pairPatchAgglomeration/pairPatchAgglomeration.C b/src/fvAgglomerationMethods/pairPatchAgglomeration/pairPatchAgglomeration.C index e322bcc541..9931d9c31d 100644 --- a/src/fvAgglomerationMethods/pairPatchAgglomeration/pairPatchAgglomeration.C +++ b/src/fvAgglomerationMethods/pairPatchAgglomeration/pairPatchAgglomeration.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -147,6 +147,7 @@ void Foam::pairPatchAgglomeration::setEdgeWeights if (eFaces.size() == 2) { const edge edgeCommon = edge(eFaces[0], eFaces[1]); + if (facePairWeight_.found(edgeCommon)) { facePairWeight_[edgeCommon] += edgeLength; @@ -155,6 +156,7 @@ void Foam::pairPatchAgglomeration::setEdgeWeights { facePairWeight_.insert(edgeCommon, edgeLength); } + // If the fine 'pair' faces was featured edge so it is // the coarse 'pair' if (fineFeaturedFaces.found(edgeCommon)) @@ -366,7 +368,7 @@ bool Foam::pairPatchAgglomeration::agglomeratePatch void Foam::pairPatchAgglomeration:: agglomerate() { 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 nCoarseFacesOld = 0; @@ -374,9 +376,9 @@ void Foam::pairPatchAgglomeration:: agglomerate() { const bPatch& patch = patchLevels_[nCreatedLevels - 1]; tmp finalAgglomPtr(new labelField(patch.size())); - bool agglomOK = false; - while (!agglomOK) + + do { finalAgglomPtr = agglomerateOneLevel ( @@ -386,34 +388,42 @@ void Foam::pairPatchAgglomeration:: agglomerate() if (nCoarseFaces > 0) { - agglomOK = agglomeratePatch + if ( - patch, - finalAgglomPtr, - nCreatedLevels - ); - - restrictAddressing_.set(nCreatedLevels, finalAgglomPtr); - mapBaseToTopAgglom(nCreatedLevels); - setEdgeWeights(nCreatedLevels); - - if (nPairLevels % mergeLevels_) + ( + agglomOK = agglomeratePatch + ( + patch, + finalAgglomPtr, + nCreatedLevels + ) + ) + ) { - combineLevels(nCreatedLevels); - } - else - { - nCreatedLevels++; - } + restrictAddressing_.set(nCreatedLevels, finalAgglomPtr); + mapBaseToTopAgglom(nCreatedLevels); + setEdgeWeights(nCreatedLevels); - nPairLevels++; + if (nPairLevels % mergeLevels_) + { + combineLevels(nCreatedLevels); + } + else + { + nCreatedLevels++; + } + + nPairLevels++; + } } else { agglomOK = true; } + reduce(nCoarseFaces, sumOp