diff --git a/src/dynamicMesh/polyMeshAdder/polyMeshAdder.C b/src/dynamicMesh/polyMeshAdder/polyMeshAdder.C index 4137f436d6..1d0838b472 100644 --- a/src/dynamicMesh/polyMeshAdder/polyMeshAdder.C +++ b/src/dynamicMesh/polyMeshAdder/polyMeshAdder.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -25,18 +25,9 @@ License #include "polyMeshAdder.H" #include "mapAddedPolyMesh.H" -#include "IOobject.H" #include "faceCoupleInfo.H" #include "processorPolyPatch.H" -#include "SortableList.H" #include "Time.H" -#include "globalMeshData.H" -#include "polyModifyFace.H" -#include "polyRemovePoint.H" -#include "polyTopoChange.H" - -#include "pointMesh.H" -#include "facePointPatch.H" // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // @@ -191,124 +182,6 @@ Foam::labelList Foam::polyMeshAdder::getPatchSizes } -Foam::List Foam::polyMeshAdder::combinePatches -( - const polyMesh& mesh0, - const polyMesh& mesh1, - const polyBoundaryMesh& allBoundaryMesh, - const label nAllPatches, - const labelList& fromAllTo1Patches, - - const label nInternalFaces, - const labelList& nFaces, - - labelList& from0ToAllPatches, - labelList& from1ToAllPatches -) -{ - const polyBoundaryMesh& patches0 = mesh0.boundaryMesh(); - const polyBoundaryMesh& patches1 = mesh1.boundaryMesh(); - - - // Compacted new patch list. - DynamicList allPatches(nAllPatches); - - - // Map from 0 to all patches (since gets compacted) - from0ToAllPatches.setSize(patches0.size()); - from0ToAllPatches = -1; - - label startFacei = nInternalFaces; - - // Copy patches0 with new sizes. First patches always come from - // mesh0 and will always be present. - forAll(patches0, patchi) - { - // Originates from mesh0. Clone with new size & filter out empty - // patch. - label filteredPatchi; - - if (nFaces[patchi] == 0 && isA(patches0[patchi])) - { - // Pout<< "Removing zero sized mesh0 patch " - // << patches0[patchi].name() << endl; - filteredPatchi = -1; - } - else - { - filteredPatchi = allPatches.size(); - - allPatches.append - ( - patches0[patchi].clone - ( - allBoundaryMesh, - filteredPatchi, - nFaces[patchi], - startFacei - ).ptr() - ); - startFacei += nFaces[patchi]; - } - - // Record new index in allPatches - from0ToAllPatches[patchi] = filteredPatchi; - - // Check if patch was also in mesh1 and update its addressing if so. - if (fromAllTo1Patches[patchi] != -1) - { - from1ToAllPatches[fromAllTo1Patches[patchi]] = filteredPatchi; - } - } - - // Copy unique patches of mesh1. - forAll(from1ToAllPatches, patchi) - { - label allPatchi = from1ToAllPatches[patchi]; - - if (allPatchi >= patches0.size()) - { - // Patch has not been merged with any mesh0 patch. - - label filteredPatchi; - - if - ( - nFaces[allPatchi] == 0 - && isA(patches1[patchi]) - ) - { - // Pout<< "Removing zero sized mesh1 patch " - // << patches1[patchi].name() << endl; - filteredPatchi = -1; - } - else - { - filteredPatchi = allPatches.size(); - - allPatches.append - ( - patches1[patchi].clone - ( - allBoundaryMesh, - filteredPatchi, - nFaces[allPatchi], - startFacei - ).ptr() - ); - startFacei += nFaces[allPatchi]; - } - - from1ToAllPatches[patchi] = filteredPatchi; - } - } - - allPatches.shrink(); - - return move(allPatches); -} - - Foam::labelList Foam::polyMeshAdder::getFaceOrder ( const cellList& cells, @@ -1275,236 +1148,8 @@ void Foam::polyMeshAdder::addZones } - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -// Returns new mesh and sets -// - map from new cell/face/point/patch to either mesh0 or mesh1 -// -// mesh0Faces/mesh1Faces: corresponding faces on both meshes. -Foam::autoPtr Foam::polyMeshAdder::add -( - const IOobject& io, - const polyMesh& mesh0, - const polyMesh& mesh1, - const faceCoupleInfo& coupleInfo, - autoPtr& mapPtr -) -{ - const polyBoundaryMesh& patches0 = mesh0.boundaryMesh(); - const polyBoundaryMesh& patches1 = mesh1.boundaryMesh(); - - - DynamicList allPatchNames(patches0.size() + patches1.size()); - DynamicList allPatchTypes(allPatchNames.size()); - - // Patch maps - labelList from1ToAllPatches(patches1.size()); - labelList fromAllTo1Patches(allPatchNames.size(), -1); - - mergePatchNames - ( - patches0, - patches1, - allPatchNames, - allPatchTypes, - from1ToAllPatches, - fromAllTo1Patches - ); - - - // New points - pointField allPoints; - - // Map from mesh0/1 points to allPoints. - labelList from0ToAllPoints(mesh0.nPoints(), -1); - labelList from1ToAllPoints(mesh1.nPoints(), -1); - - // New faces - faceList allFaces; - label nInternalFaces; - - // New cells - labelList allOwner; - labelList allNeighbour; - label nCells; - - // Sizes per patch - labelList nFaces(allPatchNames.size(), 0); - - // Maps - labelList from0ToAllFaces(mesh0.nFaces(), -1); - labelList from1ToAllFaces(mesh1.nFaces(), -1); - - // Map - labelList from1ToAllCells(mesh1.nCells(), -1); - - mergePrimitives - ( - mesh0, - mesh1, - coupleInfo, - - allPatchNames.size(), - fromAllTo1Patches, - from1ToAllPatches, - - allPoints, - from0ToAllPoints, - from1ToAllPoints, - - allFaces, - allOwner, - allNeighbour, - nInternalFaces, - nFaces, - nCells, - - from0ToAllFaces, - from1ToAllFaces, - from1ToAllCells - ); - - - // Zones - // ~~~~~ - - DynamicList pointZoneNames; - List> pzPoints; - - DynamicList faceZoneNames; - List> fzFaces; - List> fzFlips; - - DynamicList cellZoneNames; - List> czCells; - - mergeZones - ( - allPoints.size(), - allOwner, - nCells, - - mesh0, - mesh1, - - from0ToAllPoints, - from0ToAllFaces, - - from1ToAllPoints, - from1ToAllFaces, - from1ToAllCells, - - pointZoneNames, - pzPoints, - - faceZoneNames, - fzFaces, - fzFlips, - - cellZoneNames, - czCells - ); - - - // Patches - // ~~~~~~~ - - // Map from 0 to all patches (since gets compacted) - labelList from0ToAllPatches(patches0.size(), -1); - - List allPatches - ( - combinePatches - ( - mesh0, - mesh1, - patches0, // Should be boundaryMesh() on new mesh. - allPatchNames.size(), - fromAllTo1Patches, - mesh0.nInternalFaces() - + mesh1.nInternalFaces() - + coupleInfo.masterPatch().size(), - nFaces, - - from0ToAllPatches, - from1ToAllPatches - ) - ); - - - // Map information - // ~~~~~~~~~~~~~~~ - - mapPtr.reset - ( - new mapAddedPolyMesh - ( - mesh0.nPoints(), - mesh0.nFaces(), - mesh0.nCells(), - - mesh1.nPoints(), - mesh1.nFaces(), - mesh1.nCells(), - - from0ToAllPoints, - from0ToAllFaces, - identity(mesh0.nCells()), - - from1ToAllPoints, - from1ToAllFaces, - from1ToAllCells, - - from0ToAllPatches, - from1ToAllPatches, - getPatchSizes(patches0), - getPatchStarts(patches0) - ) - ); - - - - // Now we have extracted all information from all meshes. - // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - // Construct mesh - autoPtr tmesh - ( - new polyMesh - ( - io, - move(allPoints), - move(allFaces), - move(allOwner), - move(allNeighbour) - ) - ); - polyMesh& mesh = tmesh(); - - // Add zones to new mesh. - addZones - ( - pointZoneNames, - pzPoints, - - faceZoneNames, - fzFaces, - fzFlips, - - cellZoneNames, - czCells, - mesh - ); - - // Add patches to new mesh - mesh.addPatches(allPatches); - - return tmesh; -} - - -// Inplace add mesh1 to mesh0 Foam::autoPtr Foam::polyMeshAdder::add ( polyMesh& mesh0, diff --git a/src/dynamicMesh/polyMeshAdder/polyMeshAdder.H b/src/dynamicMesh/polyMeshAdder/polyMeshAdder.H index 4731108e75..71e8592ff6 100644 --- a/src/dynamicMesh/polyMeshAdder/polyMeshAdder.H +++ b/src/dynamicMesh/polyMeshAdder/polyMeshAdder.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -74,14 +74,13 @@ private: //- Index of zone in all zones static label zoneIndex(const word&, DynamicList&); + //- ... static void mergePatchNames ( const polyBoundaryMesh& patches0, const polyBoundaryMesh& patches1, - DynamicList& allPatchNames, DynamicList& allPatchTypes, - labelList& from1ToAllPatches, labelList& fromAllTo1Patches ); @@ -92,21 +91,6 @@ private: //- Get sizes of patches static labelList getPatchSizes(const polyBoundaryMesh&); - static List combinePatches - ( - const polyMesh& mesh0, - const polyMesh& mesh1, - const polyBoundaryMesh& allBoundaryMesh, - const label nAllPatches, - const labelList& fromAllTo1Patches, - - const label nInternalFaces, - const labelList& nFaces, - - labelList& from0ToAllPatches, - labelList& from1ToAllPatches - ); - //- Determine order for internalFaces to be upper-triangular. // Does not change order of external faces. static labelList getFaceOrder @@ -232,21 +216,11 @@ private: polyMesh& mesh ); + public: - // Member Functions - //- Add two polyMeshes. Returns new polyMesh and map construct. - static autoPtr add - ( - const IOobject& io, - const polyMesh& mesh0, - const polyMesh& mesh1, - const faceCoupleInfo& coupleInfo, - autoPtr& mapPtr - ); - //- Inplace add mesh to polyMesh. Returns map construct. static autoPtr add (