diff --git a/src/autoMesh/autoHexMesh/meshRefinement/meshRefinement.H b/src/autoMesh/autoHexMesh/meshRefinement/meshRefinement.H index d3eb52b7c4..da533c4d13 100644 --- a/src/autoMesh/autoHexMesh/meshRefinement/meshRefinement.H +++ b/src/autoMesh/autoHexMesh/meshRefinement/meshRefinement.H @@ -382,10 +382,12 @@ private: //- Finds zone per cell for cells inside closed named surfaces. // (uses geometric test for insideness) + // Adapts namedSurfaceIndex so all faces on boundary of cellZone + // have corresponding faceZone. void findCellZoneGeometric ( const labelList& closedNamedSurfaces, - const labelList& namedSurfaceIndex, + labelList& namedSurfaceIndex, const labelList& surfaceToCellZone, labelList& cellToZone ) const; diff --git a/src/autoMesh/autoHexMesh/meshRefinement/meshRefinementBaffles.C b/src/autoMesh/autoHexMesh/meshRefinement/meshRefinementBaffles.C index 7b2ecfc395..fdcd15f0e9 100644 --- a/src/autoMesh/autoHexMesh/meshRefinement/meshRefinementBaffles.C +++ b/src/autoMesh/autoHexMesh/meshRefinement/meshRefinementBaffles.C @@ -47,6 +47,7 @@ License #include "motionSmoother.H" #include "polyMeshGeometry.H" #include "IOmanip.H" +#include "cellSet.H" // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // @@ -1490,7 +1491,7 @@ Foam::autoPtr Foam::meshRefinement::mergeBaffles void Foam::meshRefinement::findCellZoneGeometric ( const labelList& closedNamedSurfaces, // indices of closed surfaces - const labelList& namedSurfaceIndex, // per face index of named surface + labelList& namedSurfaceIndex, // per face index of named surface const labelList& surfaceToCellZone, // cell zone index per surface labelList& cellToZone @@ -1627,6 +1628,76 @@ void Foam::meshRefinement::findCellZoneGeometric } } } + + + // Adapt the namedSurfaceIndex + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~ + // for if any cells were not completely covered. + + for (label faceI = 0; faceI < mesh_.nInternalFaces(); faceI++) + { + label ownZone = cellToZone[mesh_.faceOwner()[faceI]]; + label neiZone = cellToZone[mesh_.faceNeighbour()[faceI]]; + + if (namedSurfaceIndex[faceI] == -1 && (ownZone != neiZone)) + { + // Give face the zone of the owner + namedSurfaceIndex[faceI] = findIndex + ( + surfaceToCellZone, + max(ownZone, neiZone) + ); + } + } + + labelList neiCellZone(mesh_.nFaces()-mesh_.nInternalFaces()); + for + ( + label faceI = mesh_.nInternalFaces(); + faceI < mesh_.nFaces(); + faceI++ + ) + { + label own = mesh_.faceOwner()[faceI]; + neiCellZone[faceI-mesh_.nInternalFaces()] = cellToZone[own]; + } + syncTools::swapBoundaryFaceList(mesh_, neiCellZone, false); + + const polyBoundaryMesh& patches = mesh_.boundaryMesh(); + + forAll(patches, patchI) + { + const polyPatch& pp = patches[patchI]; + + if (pp.coupled()) + { + forAll(pp, i) + { + label faceI = pp.start()+i; + label ownZone = cellToZone[mesh_.faceOwner()[faceI]]; + label neiZone = neiCellZone[faceI-mesh_.nInternalFaces()]; + + if (namedSurfaceIndex[faceI] == -1 && (ownZone != neiZone)) + { + // Give face the zone of the owner + namedSurfaceIndex[faceI] = findIndex + ( + surfaceToCellZone, + max(ownZone, neiZone) + ); + } + } + } + } + + // Sync + syncTools::syncFaceList + ( + mesh_, + namedSurfaceIndex, + maxEqOp