/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2016-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. OpenFOAM 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. OpenFOAM 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 OpenFOAM. If not, see . Application subsetMesh Group grpMeshManipulationUtilities Description Create a mesh subset for a particular region of interest based on a cellSet or cellZone. See setSet/topoSet utilities on how to define select cells based on various shapes. Will subset all points, faces and cells needed to make a sub-mesh, but not preserve attached boundary types. \*---------------------------------------------------------------------------*/ #include "fvMeshSubsetter.H" // Not fvMeshSubset (need two-step subsetting) #include "argList.H" #include "IOobjectList.H" #include "volFields.H" #include "topoDistanceData.H" #include "FaceCellWave.H" #include "cellSet.H" #include "faceSet.H" #include "pointSet.H" #include "ReadFields.H" #include "processorMeshes.H" using namespace Foam; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // Get the exposed patchId or define the exposedPatchName in fvMeshSubset label getExposedPatchId(const polyMesh& mesh, const word& patchName) { const label patchId = mesh.boundaryMesh().findPatchID(patchName); if (patchId == -1) { fvMeshSubset::exposedPatchName = patchName; } Info<< "Adding exposed internal faces to " << (patchId == -1 ? "new" : "existing") << " patch: " << patchName << nl << endl; return patchId; } labelList nearestPatch(const polyMesh& mesh, const labelList& patchIDs) { const polyBoundaryMesh& pbm = mesh.boundaryMesh(); // Count number of faces in exposedPatchIDs label nFaces = 0; for (const label patchi : patchIDs) { nFaces += pbm[patchi].size(); } // Field on cells and faces. List> cellData(mesh.nCells()); List> faceData(mesh.nFaces()); // Start of changes labelList patchFaces(nFaces); List> patchData(nFaces); nFaces = 0; for (const label patchi : patchIDs) { const polyPatch& pp = pbm[patchi]; forAll(pp, i) { patchFaces[nFaces] = pp.start()+i; patchData[nFaces] = topoDistanceData