From 35dba48db1adf676adb0f9023164b781cc748c88 Mon Sep 17 00:00:00 2001 From: Henry Weller Date: Sun, 29 May 2016 22:51:15 +0100 Subject: [PATCH] createBaffles: filter zero-sized patches Resolves patch request http://bugs.openfoam.org/view.php?id=2103 Patch contributed by Mattijs Janssens --- .../createBaffles/createBaffles.C | 75 +++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git a/applications/utilities/mesh/manipulation/createBaffles/createBaffles.C b/applications/utilities/mesh/manipulation/createBaffles/createBaffles.C index 59b81d8e0c..f041be1c12 100644 --- a/applications/utilities/mesh/manipulation/createBaffles/createBaffles.C +++ b/applications/utilities/mesh/manipulation/createBaffles/createBaffles.C @@ -34,6 +34,7 @@ Description - if the patch already exists will not override it nor its fields - if the patch does not exist it will be created together with 'calculated' patchfields unless the field is mentioned in the patchFields section. + - any 0-sized patches (since faces have been moved out) will get removed \*---------------------------------------------------------------------------*/ @@ -106,6 +107,75 @@ label addPatch } +// Filter out the empty patches. +void filterPatches(fvMesh& mesh, const HashSet& addedPatchNames) +{ + // Remove any zero-sized ones. Assumes + // - processor patches are already only there if needed + // - all other patches are available on all processors + // - but coupled ones might still be needed, even if zero-size + // (e.g. processorCyclic) + // See also logic in createPatch. + const polyBoundaryMesh& pbm = mesh.boundaryMesh(); + + labelList oldToNew(pbm.size(), -1); + label newPatchi = 0; + forAll(pbm, patchi) + { + const polyPatch& pp = pbm[patchi]; + + if (!isA(pp)) + { + if + ( + isA(pp) + || returnReduce(pp.size(), sumOp