diff --git a/src/autoMesh/autoHexMesh/autoHexMeshDriver/autoSnapDriver.C b/src/autoMesh/autoHexMesh/autoHexMeshDriver/autoSnapDriver.C index fdf89f4123..f24117e15f 100644 --- a/src/autoMesh/autoHexMesh/autoHexMeshDriver/autoSnapDriver.C +++ b/src/autoMesh/autoHexMesh/autoHexMeshDriver/autoSnapDriver.C @@ -218,7 +218,8 @@ Foam::label Foam::autoSnapDriver::getCollocatedPoints // Calculate displacement as average of patch points. Foam::pointField Foam::autoSnapDriver::smoothPatchDisplacement ( - const motionSmoother& meshMover + const motionSmoother& meshMover, + const List& baffles ) const { const indirectPrimitivePatch& pp = meshMover.patch(); @@ -253,6 +254,34 @@ Foam::pointField Foam::autoSnapDriver::smoothPatchDisplacement const pointField& points = pp.points(); const polyMesh& mesh = meshMover.mesh(); + // Get labels of faces to count (master of coupled faces and baffle pairs) + PackedList<1> isMasterFace(syncTools::getMasterFaces(mesh)); + + { + forAll(baffles, i) + { + label f0 = baffles[i].first(); + label f1 = baffles[i].second(); + + if (isMasterFace.get(f0) == 1) + { + // Make f1 a slave + isMasterFace.set(f1, 0); + } + else if (isMasterFace.get(f1) == 1) + { + isMasterFace.set(f0, 0); + } + else + { + FatalErrorIn("autoSnapDriver::smoothPatchDisplacement(..)") + << "Both sides of baffle consisting of faces " << f0 + << " and " << f1 << " are already slave faces." + << abort(FatalError); + } + } + } + // Get average position of boundary face centres // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -266,9 +295,14 @@ Foam::pointField Foam::autoSnapDriver::smoothPatchDisplacement forAll(pFaces, pfI) { - avgBoundary[patchPointI] += pp[pFaces[pfI]].centre(points); + label faceI = pFaces[pfI]; + + if (isMasterFace.get(pp.addressing()[faceI]) == 1) + { + avgBoundary[patchPointI] += pp[faceI].centre(points); + nBoundary[patchPointI]++; + } } - nBoundary[patchPointI] = pFaces.size(); } syncTools::syncPointList @@ -886,7 +920,7 @@ void Foam::autoSnapDriver::preSmoothPatch checkFaces[faceI] = faceI; } - pointField patchDisp(smoothPatchDisplacement(meshMover)); + pointField patchDisp(smoothPatchDisplacement(meshMover, baffles)); // The current mesh is the starting mesh to smooth from. meshMover.setDisplacement(patchDisp); @@ -1008,9 +1042,11 @@ Foam::vectorField Foam::autoSnapDriver::calcNearestSurface // Displacement per patch point vectorField patchDisp(localPoints.size(), vector::zero); - if (returnReduce(localPoints.size(), sumOp