From 2d7b3363edc7ffabb092a0c5daa3543a76fe5b4b Mon Sep 17 00:00:00 2001 From: mattijs <mattijs> Date: Mon, 12 Dec 2011 16:33:11 +0000 Subject: [PATCH] ENH: patchToFace: allow patch groups in patchToFace --- .../mesh/manipulation/topoSet/topoSetDict | 3 +- .../faceSources/patchToFace/patchToFace.C | 41 ++++++++++--------- 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/applications/utilities/mesh/manipulation/topoSet/topoSetDict b/applications/utilities/mesh/manipulation/topoSet/topoSetDict index 9c910aa7ec9..5b8a4b73bbe 100644 --- a/applications/utilities/mesh/manipulation/topoSet/topoSetDict +++ b/applications/utilities/mesh/manipulation/topoSet/topoSetDict @@ -211,7 +211,8 @@ FoamFile // source patchToFace; // sourceInfo // { -// name ".*Wall"; // Name of patch, regular expressions allowed +// name ".*Wall"; // Name of patch or patch group, +// // (regular expressions allowed) // } // // // All faces of faceZone diff --git a/src/meshTools/sets/faceSources/patchToFace/patchToFace.C b/src/meshTools/sets/faceSources/patchToFace/patchToFace.C index 4ee6ead8639..4dec4263038 100644 --- a/src/meshTools/sets/faceSources/patchToFace/patchToFace.C +++ b/src/meshTools/sets/faceSources/patchToFace/patchToFace.C @@ -54,33 +54,34 @@ Foam::topoSetSource::addToUsageTable Foam::patchToFace::usage_ void Foam::patchToFace::combine(topoSet& set, const bool add) const { - bool hasMatched = false; - - forAll(mesh_.boundaryMesh(), patchI) + labelHashSet patchIDs = mesh_.boundaryMesh().patchSet + ( + List<wordRe>(1, patchName_), + true, // warn if not found + true // use patch groups if available + ); + + forAllConstIter(labelHashSet, patchIDs, iter) { - const polyPatch& pp = mesh_.boundaryMesh()[patchI]; - - if (patchName_.match(pp.name())) - { - Info<< " Found matching patch " << pp.name() - << " with " << pp.size() << " faces." << endl; + label patchI = iter.key(); - hasMatched = true; + const polyPatch& pp = mesh_.boundaryMesh()[patchI]; + Info<< " Found matching patch " << pp.name() + << " with " << pp.size() << " faces." << endl; - for - ( - label faceI = pp.start(); - faceI < pp.start() + pp.size(); - faceI++ - ) - { - addOrDelete(set, faceI, add); - } + for + ( + label faceI = pp.start(); + faceI < pp.start() + pp.size(); + faceI++ + ) + { + addOrDelete(set, faceI, add); } } - if (!hasMatched) + if (patchIDs.empty()) { WarningIn("patchToFace::combine(topoSet&, const bool)") << "Cannot find any patch named " << patchName_ << endl -- GitLab