/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org \\ / A nd | Copyright (C) 2011-2026 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- 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 . \*---------------------------------------------------------------------------*/ #include "polyMeshAdder.H" #include "mapAddedPolyMesh.H" #include "faceCoupleInfo.H" #include "processorPolyPatch.H" #include "Time.H" // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // Get index of patch in new set of patchnames/types Foam::label Foam::polyMeshAdder::patchIndex ( const polyPatch& p, DynamicList& allPatchNames, DynamicList& allPatchTypes ) { // Find the patch name on the list. If the patch is already there // and patch types match, return index const word& pType = p.type(); const word& pName = p.name(); label patchi = findIndex(allPatchNames, pName); if (patchi == -1) { // Patch not found. Append to the list allPatchNames.append(pName); allPatchTypes.append(pType); return allPatchNames.size() - 1; } else if (allPatchTypes[patchi] == pType) { // Found name and types match return patchi; } else { // Found the name, but type is different // Duplicate name is not allowed. Create a composite name from the // patch name and case name const word& caseName = p.mesh().time().caseName(); allPatchNames.append(pName + "_" + caseName); allPatchTypes.append(pType); Pout<< "label patchIndex(const polyPatch& p) : " << "Patch " << p.index() << " named " << pName << " in mesh " << caseName << " already exists, but patch types" << " do not match.\nCreating a composite name as " << allPatchNames.last() << endl; return allPatchNames.size() - 1; } } // Get index of zone in new set of zone names Foam::label Foam::polyMeshAdder::zoneIndex ( const word& curName, DynamicList& names ) { label zi = findIndex(names, curName); if (zi != -1) { return zi; } else { // Not found. Add new name to the list names.append(curName); return names.size() - 1; } } void Foam::polyMeshAdder::mergePatchNames ( const polyBoundaryMesh& patches0, const polyBoundaryMesh& patches1, DynamicList& allPatchNames, DynamicList& allPatchTypes, labelList& from1ToAllPatches, labelList& fromAllTo1Patches ) { // Insert the mesh0 patches and zones allPatchNames.append(patches0.names()); allPatchTypes.append(patches0.types()); // Patches // ~~~~~~~ // Patches from 0 are taken over as is; those from 1 get either merged // (if they share name and type) or appended. // Empty patches are filtered out much much later on. // Add mesh1 patches and build map both ways. from1ToAllPatches.setSize(patches1.size()); forAll(patches1, patchi) { from1ToAllPatches[patchi] = patchIndex ( patches1[patchi], allPatchNames, allPatchTypes ); } allPatchTypes.shrink(); allPatchNames.shrink(); // Invert 1 to all patch map fromAllTo1Patches.setSize(allPatchNames.size()); fromAllTo1Patches = -1; forAll(from1ToAllPatches, i) { fromAllTo1Patches[from1ToAllPatches[i]] = i; } } Foam::labelList Foam::polyMeshAdder::getPatchStarts ( const polyBoundaryMesh& patches ) { labelList patchStarts(patches.size()); forAll(patches, patchi) { patchStarts[patchi] = patches[patchi].start(); } return patchStarts; } Foam::labelList Foam::polyMeshAdder::getPatchSizes ( const polyBoundaryMesh& patches ) { labelList patchSizes(patches.size()); forAll(patches, patchi) { patchSizes[patchi] = patches[patchi].size(); } return patchSizes; } Foam::labelList Foam::polyMeshAdder::getFaceOrder ( const cellList& cells, const label nInternalFaces, const labelList& owner, const labelList& neighbour ) { labelList oldToNew(owner.size(), -1); // Leave boundary faces in order for (label facei = nInternalFaces; facei < owner.size(); ++facei) { oldToNew[facei] = facei; } // First unassigned face label newFacei = 0; forAll(cells, celli) { const labelList& cFaces = cells[celli]; SortableList