/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation \\/ M anipulation | Copyright (C) 2016 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 . \*---------------------------------------------------------------------------*/ #include "mergePolyMesh.H" #include "Time.H" #include "polyTopoChanger.H" #include "mapPolyMesh.H" #include "polyAddPoint.H" #include "polyAddCell.H" #include "polyAddFace.H" #include "processorPolyPatch.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // namespace Foam { defineTypeNameAndDebug(mergePolyMesh, 1); } // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // Foam::label Foam::mergePolyMesh::patchIndex(const polyPatch& p) { // 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(); bool nameFound = false; forAll(patchNames_, patchi) { if (patchNames_[patchi] == pName) { if (patchDicts_[patchi].get("type") == pType) { // Found name and types match return patchi; } else { // Found the name, but type is different nameFound = true; } } } // Patch not found. Append to the list { OStringStream os; p.write(os); patchDicts_.append(dictionary(IStringStream(os.str())())); } if (nameFound) { // Duplicate name is not allowed. Create a composite name from the // patch name and case name const word& caseName = p.boundaryMesh().mesh().time().caseName(); patchNames_.append(pName + "_" + caseName); Info<< "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 " << patchNames_.last() << endl; } else { patchNames_.append(pName); } return patchNames_.size() - 1; } Foam::label Foam::mergePolyMesh::zoneIndex ( DynamicList& names, const word& curName ) { forAll(names, zonei) { if (names[zonei] == curName) { return zonei; } } // Not found. Add new name to the list names.append(curName); return names.size() - 1; } void Foam::mergePolyMesh::sortProcessorPatches() { Info<< "Reordering processor patches last" << endl; // Updates boundaryMesh() and meshMod_ to guarantee processor patches // are last. This could be done inside the merge() but it is far easier // to do separately. // 1. Shuffle the patches in the boundaryMesh const polyBoundaryMesh& oldPatches = boundaryMesh(); DynamicList newPatches(oldPatches.size()); labelList oldToSorted(oldPatches.size()); forAll(oldPatches, patchi) { const polyPatch& pp = oldPatches[patchi]; if (!isA(pp)) { oldToSorted[patchi] = newPatches.size(); newPatches.append ( pp.clone ( oldPatches, oldToSorted[patchi], 0, nInternalFaces() ).ptr() ); } } forAll(oldPatches, patchi) { const polyPatch& pp = oldPatches[patchi]; if (isA(pp)) { oldToSorted[patchi] = newPatches.size(); newPatches.append ( pp.clone ( oldPatches, oldToSorted[patchi], 0, nInternalFaces() ).ptr() ); } } removeBoundary(); addPatches(newPatches); // Update the polyTopoChange DynamicList