diff --git a/applications/utilities/mesh/manipulation/createBaffles/createBaffles.C b/applications/utilities/mesh/manipulation/createBaffles/createBaffles.C index 1fb8cc64ef..88af3a1f29 100644 --- a/applications/utilities/mesh/manipulation/createBaffles/createBaffles.C +++ b/applications/utilities/mesh/manipulation/createBaffles/createBaffles.C @@ -43,16 +43,89 @@ Description #include "ReadFields.H" #include "volFields.H" #include "surfaceFields.H" +#include "ZoneIDs.H" using namespace Foam; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +void modifyOrAddFace +( + polyTopoChange& meshMod, + const face& f, + const label faceI, + const label own, + const bool flipFaceFlux, + const label newPatchI, + const label zoneID, + const bool zoneFlip, + + PackedBoolList& modifiedFace +) +{ + if (!modifiedFace[faceI]) + { + // First usage of face. Modify. + meshMod.setAction + ( + polyModifyFace + ( + f, // modified face + faceI, // label of face + own, // owner + -1, // neighbour + flipFaceFlux, // face flip + newPatchI, // patch for face + false, // remove from zone + zoneID, // zone for face + zoneFlip // face flip in zone + ) + ); + modifiedFace[faceI] = 1; + } + else + { + // Second or more usage of face. Add. + meshMod.setAction + ( + polyAddFace + ( + f, // modified face + own, // owner + -1, // neighbour + -1, // master point + -1, // master edge + faceI, // master face + flipFaceFlux, // face flip + newPatchI, // patch for face + zoneID, // zone for face + zoneFlip // face flip in zone + ) + ); + } +} + + +label findPatchID(const polyMesh& mesh, const word& name) +{ + label patchI = mesh.boundaryMesh().findPatchID(name); + + if (patchI == -1) + { + FatalErrorIn("findPatchID(const polyMesh&, const word&)") + << "Cannot find patch " << name << endl + << "Valid patches are " << mesh.boundaryMesh().names() + << exit(FatalError); + } + return patchI; +} + + // Main program: int main(int argc, char *argv[]) { - argList::validArgs.append("set"); + argList::validArgs.append("faceZone"); argList::validArgs.append("patch"); argList::validOptions.insert("additionalPatches", "(patch2 .. patchN)"); argList::validOptions.insert("overwrite", ""); @@ -67,30 +140,28 @@ int main(int argc, char *argv[]) const faceZoneMesh& faceZones = mesh.faceZones(); // Faces to baffle - word setName(args.additionalArgs()[0]); - Info<< "Reading faceSet from " << setName << nl << endl; - faceSet facesToSplit(mesh, setName); - // Make sure set is synchronised across couples - facesToSplit.sync(mesh); - Info<< "Read " << returnReduce(facesToSplit.size(), sumOp