diff --git a/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMeshDict b/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMeshDict index 3d982e052b..fca79d1f5c 100644 --- a/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMeshDict +++ b/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMeshDict @@ -290,8 +290,18 @@ castellatedMeshControls locationInMesh (5 0.28 0.43); // Whether any faceZones (as specified in the refinementSurfaces) - // are only on the boundary of corresponding cellZones or also allow - // free-standing zone faces. Not used if there are no faceZones. + // are only on the boundary of corresponding cellZones. + // Not used if there are no faceZones. The behaviour has changed + // with respect to previous versions: + // true : all intersections with surface are put in faceZone + // (same behaviour as before) + // false : depending on the type of surface intersected: + // - if intersecting surface has faceZone only (so no cellZone) + // leave in faceZone (so behave as if set to true) (= changed + // behaviour) + // - if intersecting surface has faceZone and cellZone + // remove if inbetween same cellZone or if on boundary + // (same behaviour as before) allowFreeStandingZoneFaces true; diff --git a/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinementBaffles.C b/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinementBaffles.C index 11a4ca4035..fc9fb59fd4 100644 --- a/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinementBaffles.C +++ b/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinementBaffles.C @@ -2069,15 +2069,21 @@ void Foam::meshRefinement::findCellZoneTopo } -// Make namedSurfaceIndex consistent with cellToZone - clear out any blocked -// faces inbetween same cell zone. void Foam::meshRefinement::makeConsistentFaceIndex ( - const labelList& zoneToNamedSurface, + const labelList& surfaceMap, const labelList& cellToZone, labelList& namedSurfaceIndex ) const { + // Make namedSurfaceIndex consistent with cellToZone - clear out any + // blocked faces inbetween same cell zone (or background (=-1)) + // Do not do this for surfaces relating to 'pure' faceZones i.e. + // faceZones without a cellZone. Note that we cannot check here + // for different cellZones on either side but no namedSurfaceIndex + // since cellZones can now originate from locationsInMesh as well + // (instead of only through named surfaces) + const labelList& faceOwner = mesh_.faceOwner(); const labelList& faceNeighbour = mesh_.faceNeighbour(); @@ -2088,22 +2094,13 @@ void Foam::meshRefinement::makeConsistentFaceIndex if ( - namedSurfaceIndex[faceI] != -1 - && ownZone == neiZone - && ownZone != -1 - && zoneToNamedSurface[ownZone] != -1 + ownZone == neiZone + && namedSurfaceIndex[faceI] != -1 + && surfaceMap[namedSurfaceIndex[faceI]] == -1 ) { namedSurfaceIndex[faceI] = -1; } - //else if (ownZone != neiZone && namedSurfaceIndex[faceI] == -1) - //{ - // FatalErrorIn("meshRefinement::zonify()") - // << "Different cell zones on either side of face " << faceI - // << " at " << mesh_.faceCentres()[faceI] - // << " but face not marked with a surface." - // << abort(FatalError); - //} } const polyBoundaryMesh& patches = mesh_.boundaryMesh(); @@ -2128,22 +2125,13 @@ void Foam::meshRefinement::makeConsistentFaceIndex if ( - namedSurfaceIndex[faceI] != -1 - && ownZone == neiZone - && ownZone != -1 - && zoneToNamedSurface[ownZone] != -1 + ownZone == neiZone + && namedSurfaceIndex[faceI] != -1 + && surfaceMap[namedSurfaceIndex[faceI]] == -1 ) { namedSurfaceIndex[faceI] = -1; } - //else if (ownZone != neiZone && namedSurfaceIndex[faceI] == -1) - //{ - // FatalErrorIn("meshRefinement::zonify()") - // << "Different cell zones on either side of face " - // << faceI << " at " << mesh_.faceCentres()[faceI] - // << " but face not marked with a surface." - // << abort(FatalError); - //} } } else @@ -2152,7 +2140,15 @@ void Foam::meshRefinement::makeConsistentFaceIndex forAll(pp, i) { label faceI = pp.start()+i; - namedSurfaceIndex[faceI] = -1; + + if + ( + namedSurfaceIndex[faceI] != -1 + && surfaceMap[namedSurfaceIndex[faceI]] == -1 + ) + { + namedSurfaceIndex[faceI] = -1; + } } } } @@ -2526,21 +2522,26 @@ void Foam::meshRefinement::zonify Info<< "Only keeping zone faces inbetween different cellZones." << nl << endl; - // Map from cellZone to named surface (or -1) - labelList zoneToNamedSurface(mesh_.cellZones().size(), -1); - forAll(namedSurfaces, i) + // Surfaces with faceZone but no cellZone + labelList standaloneNamedSurfaces + ( + surfaceZonesInfo::getStandaloneNamedSurfaces + ( + surfZones + ) + ); + + // Construct map from surface index to index in + // standaloneNamedSurfaces (or -1) + labelList surfaceMap(surfZones.size(), -1); + forAll(standaloneNamedSurfaces, i) { - label surfI = namedSurfaces[i]; - label zoneI = surfaceToCellZone[i]; - if (zoneI >= 0) - { - zoneToNamedSurface[zoneI] = surfI; - } + surfaceMap[standaloneNamedSurfaces[i]] = i; } makeConsistentFaceIndex ( - zoneToNamedSurface, + surfaceMap, cellToZone, namedSurfaceIndex ); diff --git a/src/mesh/autoMesh/autoHexMesh/refinementSurfaces/surfaceZonesInfo.C b/src/mesh/autoMesh/autoHexMesh/refinementSurfaces/surfaceZonesInfo.C index 771f826d8b..92ea200978 100644 --- a/src/mesh/autoMesh/autoHexMesh/refinementSurfaces/surfaceZonesInfo.C +++ b/src/mesh/autoMesh/autoHexMesh/refinementSurfaces/surfaceZonesInfo.C @@ -228,6 +228,32 @@ Foam::labelList Foam::surfaceZonesInfo::getNamedSurfaces } +Foam::labelList Foam::surfaceZonesInfo::getStandaloneNamedSurfaces +( + const PtrList& surfList +) +{ + labelList namedSurfaces(surfList.size()); + + label namedI = 0; + forAll(surfList, surfI) + { + if + ( + surfList.set(surfI) + && surfList[surfI].faceZoneName().size() + && !surfList[surfI].cellZoneName().size() + ) + { + namedSurfaces[namedI++] = surfI; + } + } + namedSurfaces.setSize(namedI); + + return namedSurfaces; +} + + Foam::labelList Foam::surfaceZonesInfo::getClosedNamedSurfaces ( const PtrList& surfList, diff --git a/src/mesh/autoMesh/autoHexMesh/refinementSurfaces/surfaceZonesInfo.H b/src/mesh/autoMesh/autoHexMesh/refinementSurfaces/surfaceZonesInfo.H index 3b5a73c3f5..a6af0f2411 100644 --- a/src/mesh/autoMesh/autoHexMesh/refinementSurfaces/surfaceZonesInfo.H +++ b/src/mesh/autoMesh/autoHexMesh/refinementSurfaces/surfaceZonesInfo.H @@ -191,6 +191,12 @@ public: const PtrList& surfList ); + //- Get indices of named surfaces without a cellZone + static labelList getStandaloneNamedSurfaces + ( + const PtrList& surfList + ); + //- Get indices of surfaces with a cellZone that are closed and // have 'inside' or 'outside' selection. static labelList getClosedNamedSurfaces