/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | foam-extend: Open Source CFD \\ / O peration | Version: 3.2 \\ / A nd | Web: http://www.foam-extend.org \\/ M anipulation | For copyright notice see file Copyright ------------------------------------------------------------------------------- License This file is part of foam-extend. foam-extend is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. foam-extend is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with foam-extend. If not, see . Description Utility to create patches out of selected boundary faces. Faces come either from existing patches or from a faceSet. More specifically it: - creates new patches (from selected boundary faces). Synchronise faces on coupled patches. - synchronises points on coupled boundaries - remove patches with 0 faces in them \*---------------------------------------------------------------------------*/ #include "cyclicPolyPatch.H" #include "syncTools.H" #include "argList.H" #include "polyMesh.H" #include "Time.H" #include "SortableList.H" #include "OFstream.H" #include "meshTools.H" #include "faceSet.H" #include "IOPtrList.H" #include "mapPolyMesh.H" #include "directTopoChange.H" #include "polyModifyFace.H" using namespace Foam; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { defineTemplateTypeNameAndDebug(IOPtrList, 0); } // Combine operator to synchronise points. We choose point nearest to origin so // we can use e.g. great,great,great as null value. class nearestEqOp { public: void operator()(vector& x, const vector& y) const { if (magSqr(y) < magSqr(x)) { x = y; } } }; void changePatchID ( const polyMesh& mesh, const label faceID, const label patchID, directTopoChange& meshMod ) { const label zoneID = mesh.faceZones().whichZone(faceID); bool zoneFlip = false; if (zoneID >= 0) { const faceZone& fZone = mesh.faceZones()[zoneID]; zoneFlip = fZone.flipMap()[fZone.whichFace(faceID)]; } meshMod.setAction ( polyModifyFace ( mesh.faces()[faceID], // face faceID, // face ID mesh.faceOwner()[faceID], // owner -1, // neighbour false, // flip flux patchID, // patch ID false, // remove from zone zoneID, // zone ID zoneFlip // zone flip ) ); } // Filter out the empty patches. void filterPatches(polyMesh& mesh) { const polyBoundaryMesh& patches = mesh.boundaryMesh(); // Patches to keep DynamicList allPatches(patches.size()); label nOldPatches = returnReduce(patches.size(), sumOp