diff --git a/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C b/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C index e8c2915f13..beba23a4da 100644 --- a/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C +++ b/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C @@ -58,6 +58,7 @@ Description #include "globalIndex.H" #include "IOmanip.H" #include "decompositionModel.H" +#include "fvMeshTools.H" using namespace Foam; @@ -813,6 +814,7 @@ int main(int argc, char *argv[]) readScalar(meshDict.lookup("mergeTolerance")) ); + const Switch keepPatches(meshDict.lookupOrDefault("keepPatches", false)); // Read decomposePar dictionary @@ -1517,6 +1519,12 @@ int main(int argc, char *argv[]) motionDict ); + // Remove zero sized patches originating from faceZones + if (!keepPatches && !wantSnap && !wantLayers) + { + fvMeshTools::removeEmptyPatches(mesh, true); + } + writeMesh ( "Refined mesh", @@ -1559,6 +1567,12 @@ int main(int argc, char *argv[]) snapParams ); + // Remove zero sized patches originating from faceZones + if (!keepPatches && !wantLayers) + { + fvMeshTools::removeEmptyPatches(mesh, true); + } + writeMesh ( "Snapped mesh", @@ -1609,6 +1623,12 @@ int main(int argc, char *argv[]) distributor ); + // Remove zero sized patches originating from faceZones + if (!keepPatches) + { + fvMeshTools::removeEmptyPatches(mesh, true); + } + writeMesh ( "Layer mesh", @@ -1622,6 +1642,7 @@ int main(int argc, char *argv[]) } + { // Check final mesh Info<< "Checking final mesh ..." << endl; diff --git a/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMeshDict b/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMeshDict index 5a8508d151..506a68786b 100644 --- a/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMeshDict +++ b/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMeshDict @@ -296,8 +296,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/dynamicMesh/fvMeshTools/fvMeshTools.C b/src/dynamicMesh/fvMeshTools/fvMeshTools.C index ecbe00325d..df8aaccdb4 100644 --- a/src/dynamicMesh/fvMeshTools/fvMeshTools.C +++ b/src/dynamicMesh/fvMeshTools/fvMeshTools.C @@ -355,6 +355,69 @@ void Foam::fvMeshTools::reorderPatches } +Foam::labelList Foam::fvMeshTools::removeEmptyPatches +( + fvMesh& mesh, + const bool validBoundary +) +{ + const polyBoundaryMesh& pbm = mesh.boundaryMesh(); + + labelList newToOld(pbm.size()); + labelList oldToNew(pbm.size(), -1); + label newI = 0; + + + // Assumes all non-coupled boundaries are on all processors! + forAll(pbm, patchI) + { + const polyPatch& pp = pbm[patchI]; + + if (!isA(pp)) + { + label nFaces = pp.size(); + if (validBoundary) + { + reduce(nFaces, sumOp