From 9c13057b801aef1baf7c6313e330971c13acfb9f Mon Sep 17 00:00:00 2001 From: mattijs Date: Wed, 20 Aug 2025 15:13:09 +0100 Subject: [PATCH] ENH: createPatch: do not remove added patches. Fixes #2726 --- .../manipulation/createPatch/createPatch.C | 12 +++-- .../fvMesh/fvMeshTools/fvMeshTools.C | 44 +++++++++++++++---- .../fvMesh/fvMeshTools/fvMeshTools.H | 8 ++++ 3 files changed, 52 insertions(+), 12 deletions(-) diff --git a/applications/utilities/mesh/manipulation/createPatch/createPatch.C b/applications/utilities/mesh/manipulation/createPatch/createPatch.C index cdad1c1fc8..045a2b7b42 100644 --- a/applications/utilities/mesh/manipulation/createPatch/createPatch.C +++ b/applications/utilities/mesh/manipulation/createPatch/createPatch.C @@ -42,14 +42,14 @@ Description \*---------------------------------------------------------------------------*/ -#include "cyclicPolyPatch.H" -#include "syncTools.H" #include "argList.H" #include "Time.H" #include "OFstream.H" #include "meshTools.H" #include "faceSet.H" #include "IOPtrList.H" +#include "cyclicPolyPatch.H" +#include "syncTools.H" #include "polyTopoChange.H" #include "polyModifyFace.H" #include "polyAddFace.H" @@ -942,6 +942,9 @@ int main(int argc, char *argv[]) } + // Maintain list of added patches so we exclude them from filtering + // later on + List> allAddedPatches(meshes.size()); // Loop over all regions @@ -1036,6 +1039,7 @@ int main(int argc, char *argv[]) fvPatchFieldBase::calculatedType(), true ); + allAddedPatches[meshi].append(ppPtr->name()); } } } @@ -1087,6 +1091,7 @@ int main(int argc, char *argv[]) fvPatchFieldBase::calculatedType(), true ); + allAddedPatches[meshi].append(ppPtr->name()); } } } @@ -1116,6 +1121,7 @@ int main(int argc, char *argv[]) fvPatchFieldBase::calculatedType(), true ); + allAddedPatches[meshi].append(ppPtr->name()); } } } @@ -1453,7 +1459,7 @@ int main(int argc, char *argv[]) Info<< "Removing patches with no faces in them." << nl << endl; const wordList oldPatchNames(mesh.boundaryMesh().names()); const wordList oldPatchTypes(mesh.boundaryMesh().types()); - fvMeshTools::removeEmptyPatches(mesh, true); + fvMeshTools::removeEmptyPatches(mesh, allAddedPatches[meshi], true); forAll(oldPatchNames, patchi) { const word& pName = oldPatchNames[patchi]; diff --git a/src/finiteVolume/fvMesh/fvMeshTools/fvMeshTools.C b/src/finiteVolume/fvMesh/fvMeshTools/fvMeshTools.C index b647efca8c..aa794581a8 100644 --- a/src/finiteVolume/fvMesh/fvMeshTools/fvMeshTools.C +++ b/src/finiteVolume/fvMesh/fvMeshTools/fvMeshTools.C @@ -369,6 +369,7 @@ void Foam::fvMeshTools::reorderPatches Foam::labelList Foam::fvMeshTools::removeEmptyPatches ( fvMesh& mesh, + const wordList& keepPatches, const bool validBoundary ) { @@ -386,16 +387,24 @@ Foam::labelList Foam::fvMeshTools::removeEmptyPatches if (!isA(pp)) { - label nFaces = pp.size(); - if (validBoundary) - { - reduce(nFaces, sumOp