ENH: createPatch: do not remove added patches. Fixes #2726

This commit is contained in:
mattijs
2025-08-20 15:13:09 +01:00
parent 8357b7e28b
commit 9c13057b80
3 changed files with 52 additions and 12 deletions

View File

@ -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<processorPolyPatch>(pp))
{
label nFaces = pp.size();
if (validBoundary)
{
reduce(nFaces, sumOp<label>());
}
if (nFaces > 0)
if (keepPatches.found(pp.name()))
{
newToOld[newI] = patchI;
oldToNew[patchI] = newI++;
oldToNew[patchI] = newI++;
}
else
{
label nFaces = pp.size();
if (validBoundary)
{
reduce(nFaces, sumOp<label>());
}
if (nFaces > 0)
{
newToOld[newI] = patchI;
oldToNew[patchI] = newI++;
}
}
}
}
@ -405,7 +414,14 @@ Foam::labelList Foam::fvMeshTools::removeEmptyPatches
{
const polyPatch& pp = pbm[patchI];
if (isA<processorPolyPatch>(pp) && pp.size())
if
(
isA<processorPolyPatch>(pp)
&& (
pp.size()
|| keepPatches.found(pp.name())
)
)
{
newToOld[newI] = patchI;
oldToNew[patchI] = newI++;
@ -429,6 +445,16 @@ Foam::labelList Foam::fvMeshTools::removeEmptyPatches
}
Foam::labelList Foam::fvMeshTools::removeEmptyPatches
(
fvMesh& mesh,
const bool validBoundary
)
{
return removeEmptyPatches(mesh, wordList::null(), validBoundary);
}
void Foam::fvMeshTools::setBasicGeometry(fvMesh& mesh)
{
// Set the fvGeometryScheme to basic since it does not require

View File

@ -156,6 +156,14 @@ public:
// to old patches
static labelList removeEmptyPatches(fvMesh&, const bool validBoundary);
//- Remove zero sized patches unless explicitly forced to preserve.
// See above.
static labelList removeEmptyPatches
(
fvMesh&,
const wordList& keepPatches,
const bool validBoundary
);
//- Set the fvGeometryScheme to basic (to avoid parallel communication)
static void setBasicGeometry(fvMesh& mesh);