From 14b68a7f059647ed88aae8b6ad7d838b6734bc13 Mon Sep 17 00:00:00 2001 From: mattijs Date: Mon, 18 Aug 2025 13:36:50 +0100 Subject: [PATCH] ENH: createPatch: late adding patchfields. Fixes #3410 Thanks to Alexey Matveichev --- .../manipulation/createPatch/createPatch.C | 28 +++++++++++++------ 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/applications/utilities/mesh/manipulation/createPatch/createPatch.C b/applications/utilities/mesh/manipulation/createPatch/createPatch.C index b255fcf58f..cdad1c1fc8 100644 --- a/applications/utilities/mesh/manipulation/createPatch/createPatch.C +++ b/applications/utilities/mesh/manipulation/createPatch/createPatch.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2016-2024 OpenCFD Ltd. + Copyright (C) 2016-2025 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -1476,14 +1476,11 @@ int main(int argc, char *argv[]) { ++runTime; } - else - { - forAll(meshes, meshi) - { - fvMesh& mesh = meshes[meshi]; - mesh.setInstance(oldInstances[meshi]); - } + forAll(meshes, meshi) + { + fvMesh& mesh = meshes[meshi]; + mesh.setInstance(overwrite ? oldInstances[meshi] : runTime.timeName()); } // More precision (for points data) @@ -1493,6 +1490,21 @@ int main(int argc, char *argv[]) forAll(meshes, meshi) { fvMesh& mesh = meshes[meshi]; + + // Override bcs with explicitly provided info. Done late so there + // are already patch faces + forAll(patchInfoDicts[meshi], sourcei) + { + const dictionary& patchDict = patchInfoDicts[meshi][sourcei]; + const word& patchName = patchNames[meshi][sourcei]; + const label patchID = mesh.boundary().findPatchID(patchName); + if (patchID != -1 && patchDict.found("patchFields")) + { + const dictionary& pfd = patchDict.subDict("patchFields"); + fvMeshTools::setPatchFields(mesh, patchID, pfd); + } + } + Info<< "\n\nWriting repatched mesh " << mesh.name() << " to " << runTime.timeName() << nl << endl; mesh.clearOut(); // remove meshPhi