46 Foam::label Foam::polyMeshAdder::patchIndex
49 DynamicList<word>& allPatchNames,
50 DynamicList<word>& allPatchTypes
55 const word& pType =
p.type();
56 const word& pName =
p.name();
58 const label patchi = allPatchNames.find(pName);
63 allPatchNames.append(pName);
64 allPatchTypes.append(pType);
66 return allPatchNames.size() - 1;
68 else if (allPatchTypes[patchi] == pType)
79 const word& caseName =
p.boundaryMesh().mesh().time().caseName();
81 allPatchNames.append(pName +
"_" + caseName);
82 allPatchTypes.append(pType);
84 Pout<<
"label patchIndex(const polyPatch& p) : "
85 <<
"Patch " <<
p.index() <<
" named "
86 << pName <<
" in mesh " << caseName
87 <<
" already exists, but patch types"
88 <<
" do not match.\nCreating a composite name as "
89 << allPatchNames.last() <<
endl;
91 return allPatchNames.size() - 1;
97 Foam::label Foam::polyMeshAdder::zoneIndex
100 DynamicList<word>&
names
103 const label zoneI =
names.find(curName);
114 return names.size() - 1;
119 void Foam::polyMeshAdder::mergePatchNames
121 const polyBoundaryMesh& patches0,
122 const polyBoundaryMesh& patches1,
124 DynamicList<word>& allPatchNames,
125 DynamicList<word>& allPatchTypes,
132 allPatchNames.append(patches0.names());
133 allPatchTypes.append(patches0.types());
143 from1ToAllPatches.setSize(patches1.size());
147 from1ToAllPatches[patchi] = patchIndex
154 allPatchTypes.shrink();
155 allPatchNames.shrink();
158 fromAllTo1Patches.setSize(allPatchNames.size());
159 fromAllTo1Patches = -1;
161 forAll(from1ToAllPatches, i)
163 fromAllTo1Patches[from1ToAllPatches[i]] = i;
170 const polyBoundaryMesh&
patches
184 const polyBoundaryMesh&
patches
190 patchSizes[patchi] =
patches[patchi].size();
198 const polyMesh& mesh0,
199 const polyMesh& mesh1,
200 const polyBoundaryMesh& allBoundaryMesh,
201 const label nAllPatches,
204 const label nInternalFaces,
211 const polyBoundaryMesh& patches0 = mesh0.boundaryMesh();
212 const polyBoundaryMesh& patches1 = mesh1.boundaryMesh();
216 DynamicList<polyPatch*> allPatches(nAllPatches);
220 from0ToAllPatches.setSize(patches0.size());
221 from0ToAllPatches = -1;
223 label startFacei = nInternalFaces;
231 label filteredPatchi;
233 if (nFaces[patchi] == 0 && isA<processorPolyPatch>(patches0[patchi]))
241 filteredPatchi = allPatches.size();
245 patches0[patchi].clone
253 startFacei += nFaces[patchi];
257 from0ToAllPatches[patchi] = filteredPatchi;
260 if (fromAllTo1Patches[patchi] != -1)
262 from1ToAllPatches[fromAllTo1Patches[patchi]] = filteredPatchi;
267 forAll(from1ToAllPatches, patchi)
269 label allPatchi = from1ToAllPatches[patchi];
271 if (allPatchi >= patches0.size())
275 label filteredPatchi;
279 nFaces[allPatchi] == 0
280 && isA<processorPolyPatch>(patches1[patchi])
289 filteredPatchi = allPatches.size();
293 patches1[patchi].clone
301 startFacei += nFaces[allPatchi];
304 from1ToAllPatches[patchi] = filteredPatchi;
317 const label nInternalFaces,
325 for (label facei = nInternalFaces; facei < owner.size(); ++facei)
327 oldToNew[facei] = facei;
337 SortableList<label> nbr(cFaces.size());
341 const label facei = cFaces[i];
343 label nbrCelli = neighbour[facei];
348 if (nbrCelli == celli)
350 nbrCelli = owner[facei];
353 if (celli < nbrCelli)
377 oldToNew[cFaces[nbr.indices()[i]]] = newFacei++;
386 if (oldToNew[facei] == -1)
389 <<
"Did not determine new position"
390 <<
" for face " << facei
401 void Foam::polyMeshAdder::insertVertices
404 const Map<label>& meshToMaster,
408 DynamicList<label>& workFace,
419 label v0 = masterF[fp];
420 label v1 = masterF.nextLabel(fp);
423 workFace.append(allF[fp]);
427 const auto v0Fnd = meshToMaster.cfind(v0);
430 const auto v1Fnd = meshToMaster.cfind(v1);
436 masterToCutPoints[v0Fnd()],
437 masterToCutPoints[v1Fnd()]
440 const auto iter = cutEdgeToPoints.cfind(cutEdge);
444 const edge&
e = iter.key();
445 const labelList& addedPoints = iter.val();
448 if (
e[0] == cutEdge[0])
452 workFace.append(addedPoints[i]);
459 workFace.append(addedPoints[i]);
467 if (workFace.size() != allF.size())
469 allF.transfer(workFace);
486 void Foam::polyMeshAdder::mergePrimitives
488 const polyMesh& mesh0,
489 const polyMesh& mesh1,
490 const faceCoupleInfo& coupleInfo,
492 const label nAllPatches,
503 label& nInternalFaces,
512 const polyBoundaryMesh& patches0 = mesh0.boundaryMesh();
513 const polyBoundaryMesh& patches1 = mesh1.boundaryMesh();
524 allPoints.setSize(mesh0.nPoints() + mesh1.nPoints());
527 from0ToAllPoints.setSize(mesh0.nPoints());
528 from0ToAllPoints = -1;
529 from1ToAllPoints.setSize(mesh1.nPoints());
530 from1ToAllPoints = -1;
534 const pointField& cutPoints = coupleInfo.cutPoints();
543 coupleInfo.masterToCutPoints()
554 coupleInfo.slaveToCutPoints()
564 const labelList& masterPoints = cutToMasterPoints[i];
568 label mesh0Pointi = masterPatch.meshPoints()[masterPoints[j]];
569 from0ToAllPoints[mesh0Pointi] = allPointi;
572 const labelList& slavePoints = cutToSlavePoints[i];
576 label mesh1Pointi = slavePatch.meshPoints()[slavePoints[j]];
577 from1ToAllPoints[mesh1Pointi] = allPointi;
584 forAll(mesh0.points(), pointi)
586 if (from0ToAllPoints[pointi] == -1)
588 allPoints[allPointi] = mesh0.points()[pointi];
589 from0ToAllPoints[pointi] = allPointi;
595 forAll(mesh1.points(), pointi)
597 if (from1ToAllPoints[pointi] == -1)
599 allPoints[allPointi] = mesh1.points()[pointi];
600 from1ToAllPoints[pointi] = allPointi;
612 nFacesPerPatch.setSize(nAllPatches);
616 allFaces.setSize(mesh0.nFaces() + mesh1.nFaces());
617 allOwner.setSize(allFaces.size());
619 allNeighbour.setSize(allFaces.size());
623 from0ToAllFaces.setSize(mesh0.nFaces());
624 from0ToAllFaces = -1;
625 from1ToAllFaces.setSize(mesh1.nFaces());
626 from1ToAllFaces = -1;
629 for (label facei = 0; facei < mesh0.nInternalFaces(); facei++)
631 allFaces[allFacei] =
renumber(from0ToAllPoints, mesh0.faces()[facei]);
632 allOwner[allFacei] = mesh0.faceOwner()[facei];
633 allNeighbour[allFacei] = mesh0.faceNeighbour()[facei];
634 from0ToAllFaces[facei] = allFacei++;
639 const labelList& cutToMasterFaces = coupleInfo.cutToMasterFaces();
640 const labelList& cutToSlaveFaces = coupleInfo.cutToSlaveFaces();
644 label masterFacei = cutToMasterFaces[i];
646 label mesh0Facei = masterPatch.addressing()[masterFacei];
648 if (from0ToAllFaces[mesh0Facei] == -1)
651 from0ToAllFaces[mesh0Facei] = allFacei;
654 label patch0 = patches0.whichPatch(mesh0Facei);
655 nFacesPerPatch[patch0]--;
658 label slaveFacei = cutToSlaveFaces[i];
660 label mesh1Facei = slavePatch.addressing()[slaveFacei];
662 if (from1ToAllFaces[mesh1Facei] == -1)
664 from1ToAllFaces[mesh1Facei] = allFacei;
666 label patch1 = patches1.whichPatch(mesh1Facei);
667 nFacesPerPatch[from1ToAllPatches[patch1]]--;
672 allFaces[allFacei] = cutFaces[i];
673 allOwner[allFacei] = mesh0.faceOwner()[mesh0Facei];
674 allNeighbour[allFacei] = mesh1.faceOwner()[mesh1Facei] + mesh0.nCells();
680 for (label facei = 0; facei < mesh1.nInternalFaces(); facei++)
682 allFaces[allFacei] =
renumber(from1ToAllPoints, mesh1.faces()[facei]);
683 allOwner[allFacei] = mesh1.faceOwner()[facei] + mesh0.nCells();
684 allNeighbour[allFacei] = mesh1.faceNeighbour()[facei] + mesh0.nCells();
685 from1ToAllFaces[facei] = allFacei++;
688 nInternalFaces = allFacei;
691 for (label allPatchi = 0; allPatchi < nAllPatches; allPatchi++)
693 if (allPatchi < patches0.size())
696 const polyPatch& pp = patches0[allPatchi];
698 nFacesPerPatch[allPatchi] += pp.size();
700 label facei = pp.
start();
704 if (from0ToAllFaces[facei] == -1)
712 allOwner[allFacei] = mesh0.faceOwner()[facei];
713 allNeighbour[allFacei] = -1;
715 from0ToAllFaces[facei] = allFacei++;
720 if (fromAllTo1Patches[allPatchi] != -1)
723 const polyPatch& pp = patches1[fromAllTo1Patches[allPatchi]];
725 nFacesPerPatch[allPatchi] += pp.size();
727 label facei = pp.start();
731 if (from1ToAllFaces[facei] == -1)
740 mesh1.faceOwner()[facei]
742 allNeighbour[allFacei] = -1;
744 from1ToAllFaces[facei] = allFacei++;
750 allFaces.setSize(allFacei);
751 allOwner.setSize(allFacei);
752 allNeighbour.setSize(allFacei);
767 const edgeLookup& cutEdgeToPoints = coupleInfo.cutEdgeToPoints();
772 forAll(cutToMasterFaces, i)
774 label meshFacei = masterPatch.addressing()[cutToMasterFaces[i]];
776 masterCutFaces.insert(meshFacei);
779 DynamicList<label> workFace(100);
781 forAll(from0ToAllFaces, face0)
783 if (!masterCutFaces.found(face0))
785 label allFacei = from0ToAllFaces[face0];
790 masterPatch.meshPointMap(),
791 coupleInfo.masterToCutPoints(),
792 mesh0.faces()[face0],
803 forAll(cutToSlaveFaces, i)
805 label meshFacei = slavePatch.addressing()[cutToSlaveFaces[i]];
807 slaveCutFaces.insert(meshFacei);
810 forAll(from1ToAllFaces, face1)
812 if (!slaveCutFaces.found(face1))
814 label allFacei = from1ToAllFaces[face1];
819 slavePatch.meshPointMap(),
820 coupleInfo.slaveToCutPoints(),
821 mesh1.faces()[face1],
836 from1ToAllCells.setSize(mesh1.nCells());
837 from1ToAllCells = -1;
841 from1ToAllCells[i] = i + mesh0.nCells();
845 nCells = mesh0.nCells() + mesh1.nCells();
847 primitiveMesh::calcCells(allCells, allOwner, allNeighbour, nCells);
869 void Foam::polyMeshAdder::mergePointZones
871 const label nAllPoints,
877 DynamicList<word>& zoneNames,
879 List<DynamicList<label>>& pzPoints
882 zoneNames.setCapacity(pz0.size() + pz1.size());
883 zoneNames.append(pz0.names());
885 from1ToAll.setSize(pz1.size());
889 from1ToAll[zoneI] = zoneIndex(pz1[zoneI].
name(), zoneNames);
905 const pointZone& pz = pz0[zoneI];
909 label point0 = pz[i];
910 label allPointi = from0ToAllPoints[point0];
912 if (pointToZone[allPointi] == -1)
914 pointToZone[allPointi] = zoneI;
916 else if (pointToZone[allPointi] != zoneI)
927 const pointZone& pz = pz1[zoneI];
928 const label allZoneI = from1ToAll[zoneI];
932 label point1 = pz[i];
933 label allPointi = from1ToAllPoints[point1];
935 if (pointToZone[allPointi] == -1)
937 pointToZone[allPointi] = allZoneI;
939 else if (pointToZone[allPointi] != allZoneI)
942 pZones.appendUniq(allZoneI);
951 forAll(pointToZone, allPointi)
953 label zoneI = pointToZone[allPointi];
959 forAll(addPointToZones, allPointi)
969 pzPoints.setSize(zoneNames.size());
972 pzPoints[zoneI].setCapacity(
nPoints[zoneI]);
974 forAll(pointToZone, allPointi)
976 label zoneI = pointToZone[allPointi];
979 pzPoints[zoneI].append(allPointi);
982 forAll(addPointToZones, allPointi)
987 pzPoints[
pZones[i]].append(allPointi);
992 pzPoints[i].shrink();
998 void Foam::polyMeshAdder::mergeFaceZones
1002 const polyMesh& mesh0,
1003 const polyMesh& mesh1,
1010 DynamicList<word>& zoneNames,
1012 List<DynamicList<label>>& fzFaces,
1013 List<DynamicList<bool>>& fzFlips
1017 const labelList& owner0 = mesh0.faceOwner();
1019 const labelList& owner1 = mesh1.faceOwner();
1022 zoneNames.setCapacity(fz0.size() + fz1.size());
1023 zoneNames.
append(fz0.names());
1025 from1ToAll.setSize(fz1.size());
1029 from1ToAll[zoneI] = zoneIndex(fz1[zoneI].
name(), zoneNames);
1035 labelList faceToZone(allOwner.size(), -1);
1037 boolList faceToFlip(allOwner.size(),
false);
1043 const labelList& addressing = fz0[zoneI];
1044 const boolList& flipMap = fz0[zoneI].flipMap();
1048 label face0 = addressing[i];
1049 bool flip0 = flipMap[i];
1051 label allFacei = from0ToAllFaces[face0];
1055 label allCell0 = owner0[face0];
1056 if (allOwner[allFacei] != allCell0)
1061 if (faceToZone[allFacei] == -1)
1063 faceToZone[allFacei] = zoneI;
1064 faceToFlip[allFacei] = flip0;
1066 else if (faceToZone[allFacei] != zoneI)
1068 labelList& fZones = addFaceToZones[allFacei];
1069 boolList& flipZones = addFaceToFlips[allFacei];
1071 if (fZones.appendUniq(zoneI))
1083 const labelList& addressing = fz1[zoneI];
1084 const boolList& flipMap = fz1[zoneI].flipMap();
1086 const label allZoneI = from1ToAll[zoneI];
1090 label face1 = addressing[i];
1091 bool flip1 = flipMap[i];
1093 label allFacei = from1ToAllFaces[face1];
1097 label allCell1 = from1ToAllCells[owner1[face1]];
1098 if (allOwner[allFacei] != allCell1)
1103 if (faceToZone[allFacei] == -1)
1105 faceToZone[allFacei] = allZoneI;
1106 faceToFlip[allFacei] = flip1;
1108 else if (faceToZone[allFacei] != allZoneI)
1110 labelList& fZones = addFaceToZones[allFacei];
1111 boolList& flipZones = addFaceToFlips[allFacei];
1113 if (fZones.appendUniq(allZoneI))
1127 forAll(faceToZone, allFacei)
1129 label zoneI = faceToZone[allFacei];
1135 forAll(addFaceToZones, allFacei)
1137 const labelList& fZones = addFaceToZones[allFacei];
1140 nFaces[fZones[i]]++;
1145 fzFaces.setSize(zoneNames.size());
1146 fzFlips.setSize(zoneNames.size());
1149 fzFaces[zoneI].setCapacity(nFaces[zoneI]);
1150 fzFlips[zoneI].setCapacity(nFaces[zoneI]);
1152 forAll(faceToZone, allFacei)
1154 label zoneI = faceToZone[allFacei];
1155 bool flip = faceToFlip[allFacei];
1158 fzFaces[zoneI].append(allFacei);
1159 fzFlips[zoneI].append(flip);
1162 forAll(addFaceToZones, allFacei)
1164 const labelList& fZones = addFaceToZones[allFacei];
1165 const boolList& flipZones = addFaceToFlips[allFacei];
1169 label zoneI = fZones[i];
1170 fzFaces[zoneI].append(allFacei);
1171 fzFlips[zoneI].append(flipZones[i]);
1177 fzFaces[i].shrink();
1178 fzFlips[i].shrink();
1188 void Foam::polyMeshAdder::mergeCellZones
1190 const label nAllCells,
1196 DynamicList<word>& zoneNames,
1198 List<DynamicList<label>>& czCells
1201 zoneNames.setCapacity(cz0.size() + cz1.size());
1202 zoneNames.append(cz0.names());
1204 from1ToAll.setSize(cz1.size());
1207 from1ToAll[zoneI] = zoneIndex(cz1[zoneI].
name(), zoneNames);
1222 const cellZone& cz = cz0[zoneI];
1225 label cell0 = cz[i];
1227 if (cellToZone[cell0] == -1)
1229 cellToZone[cell0] = zoneI;
1231 else if (cellToZone[cell0] != zoneI)
1233 labelList& cZones = addCellToZones[cell0];
1242 const cellZone& cz = cz1[zoneI];
1243 const label allZoneI = from1ToAll[zoneI];
1246 label cell1 = cz[i];
1247 label allCelli = from1ToAllCells[cell1];
1249 if (cellToZone[allCelli] == -1)
1251 cellToZone[allCelli] = allZoneI;
1253 else if (cellToZone[allCelli] != allZoneI)
1255 labelList& cZones = addCellToZones[allCelli];
1265 forAll(cellToZone, allCelli)
1267 label zoneI = cellToZone[allCelli];
1273 forAll(addCellToZones, allCelli)
1275 const labelList& cZones = addCellToZones[allCelli];
1278 nCells[cZones[i]]++;
1283 czCells.setSize(zoneNames.size());
1286 czCells[zoneI].setCapacity(nCells[zoneI]);
1288 forAll(cellToZone, allCelli)
1290 label zoneI = cellToZone[allCelli];
1293 czCells[zoneI].append(allCelli);
1296 forAll(addCellToZones, allCelli)
1298 const labelList& cZones = addCellToZones[allCelli];
1301 czCells[cZones[i]].append(allCelli);
1306 czCells[i].shrink();
1312 void Foam::polyMeshAdder::mergeZones
1314 const label nAllPoints,
1316 const label nAllCells,
1318 const polyMesh& mesh0,
1319 const polyMesh& mesh1,
1327 DynamicList<word>& pointZoneNames,
1328 List<DynamicList<label>>& pzPoints,
1330 DynamicList<word>& faceZoneNames,
1331 List<DynamicList<label>>& fzFaces,
1332 List<DynamicList<bool>>& fzFlips,
1334 DynamicList<word>& cellZoneNames,
1335 List<DynamicList<label>>& czCells
1383 void Foam::polyMeshAdder::addZones
1385 const DynamicList<word>& pointZoneNames,
1386 const List<DynamicList<label>>& pzPoints,
1388 const DynamicList<word>& faceZoneNames,
1389 const List<DynamicList<label>>& fzFaces,
1390 const List<DynamicList<bool>>& fzFlips,
1392 const DynamicList<word>& cellZoneNames,
1393 const List<DynamicList<label>>& czCells,
1398 List<pointZone*>
pZones(pzPoints.size());
1401 pZones[i] =
new pointZone
1410 List<faceZone*> fZones(fzFaces.size());
1413 fZones[i] =
new faceZone
1423 List<cellZone*> cZones(czCells.size());
1426 cZones[i] =
new cellZone
1468 labelList from1ToAllPatches(patches1.size());
1469 labelList fromAllTo1Patches(allPatchNames.size(), -1);
1491 label nInternalFaces;
1514 allPatchNames.size(),
1580 labelList from0ToAllPatches(patches0.size(), -1);
1589 allPatchNames.size(),
1591 mesh0.nInternalFaces()
1592 + mesh1.nInternalFaces()
1627 getPatchSizes(patches0),
1628 getPatchStarts(patches0)
1642 std::move(allFaces),
1643 std::move(allOwner),
1644 std::move(allNeighbour)
1676 const bool validBoundary
1686 labelList from1ToAllPatches(patches1.size());
1687 labelList fromAllTo1Patches(allPatchNames.size(), -1);
1711 label nInternalFaces;
1728 allPatchNames.size(),
1795 labelList mesh0PatchSizes(getPatchSizes(patches0));
1796 labelList mesh0PatchStarts(getPatchStarts(patches0));
1799 labelList from0ToAllPatches(patches0.size(), -1);
1805 allPatches.
setSize(allPatchNames.size());
1806 labelList patchSizes(allPatches.size());
1807 labelList patchStarts(allPatches.size());
1809 label startFacei = nInternalFaces;
1813 label allPatchi = 0;
1815 forAll(from0ToAllPatches, patch0)
1820 if (nFaces[patch0] == 0 && isA<processorPolyPatch>(allPatches[patch0]))
1824 from0ToAllPatches[patch0] = -1;
1826 if (fromAllTo1Patches[patch0] != -1)
1828 from1ToAllPatches[fromAllTo1Patches[patch0]] = -1;
1839 allPatches[patch0].clone
1847 patchSizes[allPatchi] = nFaces[patch0];
1848 patchStarts[allPatchi] = startFacei;
1851 from0ToAllPatches[patch0] = allPatchi;
1854 if (fromAllTo1Patches[patch0] != -1)
1856 from1ToAllPatches[fromAllTo1Patches[patch0]] = allPatchi;
1859 startFacei += nFaces[patch0];
1866 forAll(from1ToAllPatches, patch1)
1868 label uncompactAllPatchi = from1ToAllPatches[patch1];
1870 if (uncompactAllPatchi >= from0ToAllPatches.size())
1876 nFaces[uncompactAllPatchi] == 0
1877 && isA<processorPolyPatch>(patches1[patch1])
1882 from1ToAllPatches[patch1] = -1;
1890 patches1[patch1].clone
1898 patchSizes[allPatchi] = nFaces[uncompactAllPatchi];
1899 patchStarts[allPatchi] = startFacei;
1902 from1ToAllPatches[patch1] = allPatchi;
1904 startFacei += nFaces[uncompactAllPatchi];
1911 allPatches.setSize(allPatchi);
1912 patchSizes.setSize(allPatchi);
1913 patchStarts.setSize(allPatchi);
1952 mesh0.resetMotion();
1953 mesh0.resetPrimitives
1965 mesh0.pointZones().
clear();
1966 mesh0.faceZones().clear();
1967 mesh0.cellZones().clear();
1989 const scalar mergeDist
2004 label nMultiple = 0;
2006 forAll(sharedPointLabels, i)
2008 label pointi = sharedPointLabels[i];
2010 label sharedI = sharedPointAddr[i];
2012 auto iter = sharedToMesh.find(sharedI);
2020 labelList& connectedPointLabels = iter.val();
2022 label sz = connectedPointLabels.size();
2025 if (connectedPointLabels.found(pointi))
2028 <<
"Duplicate point in sharedPoint addressing." <<
endl
2029 <<
"When trying to add point " << pointi <<
" on shared "
2030 << sharedI <<
" with connected points "
2031 << connectedPointLabels
2035 connectedPointLabels.
setSize(sz+1);
2036 connectedPointLabels[sz] = pointi;
2040 sharedToMesh.insert(sharedI,
labelList(1, pointi));
2052 const labelList& connectedPointLabels = iter.val();
2059 if (connectedPointLabels.size() > 1)
2064 connectedPointLabels
2076 if (nUnique < connectedPoints.size())
2091 const labelList& mergeSet = mergeSets[setI];
2093 if (mergeSet.size() > 1)
2100 label pointi = connectedPointLabels[mergeSet[i]];
2102 masterPointi =
min(masterPointi, pointi);
2107 label pointi = connectedPointLabels[mergeSet[i]];
2115 pointToMaster.insert(pointi, masterPointi);
2193 return pointToMaster;
2207 const auto iter = pointToMaster.cfind(pointi);
2211 if (iter.val() != pointi)
2224 const face&
f = faces[facei];
2226 bool hasMerged =
false;
2230 label pointi =
f[fp];
2232 const auto iter = pointToMaster.cfind(pointi);
2236 if (iter.val() != pointi)
2250 label pointi =
f[fp];
2252 const auto iter = pointToMaster.cfind(pointi);
2256 newF[fp] = iter.val();
2263 bool zoneFlip =
false;
2291 Foam::label Foam::polyMeshAdder::procPatchIndex
2294 const label nbrProci,
2304 for (label patchi = pbm.
nNonProcessor(); patchi < pbm.size(); patchi++)
2307 refCast<const processorPolyPatch>(pbm[patchi]);
2342 localPatch.setSize(
meshes.size());
2343 remoteProc.setSize(
meshes.size());
2344 remotePatch.setSize(
meshes.size());
2353 for (label proci = 1; proci <
meshes.size(); proci++)
2361 <<
"Patch names should be identical on all processors."
2362 <<
" Processor 0 has " << names0
2363 <<
". Processor " << proci
2380 nNeighbourProcs = 0;
2382 for (label patchi = pbm.
nNonProcessor(); patchi < pbm.size(); patchi++)
2385 refCast<const processorPolyPatch>(pbm[patchi]);
2389 const label nbrPatchi = procPatchIndex
2393 nNeighbourProcs[nbrProci]
2396 const auto& nbrPbm =
meshes[nbrProci].boundaryMesh();
2397 const auto& nbrPp = nbrPbm[nbrPatchi];
2398 if (pp.size() != nbrPp.size())
2401 <<
"at proc:" << proci
2402 <<
" processor patch "
2403 << pp.
name() <<
" is not same size " << pp.size()
2404 <<
" as coupled patch " << nbrPp.
name()
2405 <<
" on proc:" << nbrProci
2406 <<
" size:" << nbrPp.size()
2410 localPatch[proci].append(patchi);
2411 remoteProc[proci].append(nbrProci);
2412 remotePatch[proci].append(nbrPatchi);
2414 localPatch[nbrProci].append(nbrPatchi);
2415 remoteProc[nbrProci].append(proci);
2416 remotePatch[nbrProci].append(patchi);
2418 nNeighbourProcs[nbrProci]++;
2444 return meshes[0].boundaryMesh().nNonProcessor();
2480 for (
const label patchi : procPatches)
2482 nFaces += pbm[patchi].size();
2485 labelList& procFaces = localBoundaryFace[meshi];
2486 labelList& remoteMeshes = remoteFaceMesh[meshi];
2487 labelList& remoteFaces = remoteBoundaryFace[meshi];
2497 const label patchi = procPatches[i];
2498 const label nbrMeshi = procNbrs[i];
2499 const label nbrPatchi = procNbrPatches[i];
2501 const auto& pp = pbm[patchi];
2504 const auto& nbrMesh =
meshes[nbrMeshi];
2505 const auto& nbrPp = nbrMesh.boundaryMesh()[nbrPatchi];
2506 const label nbrOffset = nbrPp.start()-nbrMesh.nInternalFaces();
2510 procFaces[nFaces] = offset+patchFacei;
2511 remoteMeshes[nFaces] = nbrMeshi;
2512 remoteFaces[nFaces] = nbrOffset+patchFacei;
2520 void Foam::polyMeshAdder::compactPoints
2549 labelList& pAddressing = pointProcAddressing[meshi];
2551 const labelList& localBFaces = localBoundaryFace[meshi];
2552 const labelList& procNbrs = remoteFaceMesh[meshi];
2553 const labelList& procNbrBFaces = remoteBoundaryFace[meshi];
2554 const labelList& procNbrIndex = remoteFaceStart[meshi];
2558 const label bFacei = localBFaces[i];
2559 const label nbrMeshi = procNbrs[i];
2560 const label nbrBFacei = procNbrBFaces[i];
2564 const face&
f = faces[facei];
2567 const auto& nbrMesh =
meshes[nbrMeshi];
2568 const label nbrFacei = nbrMesh.nInternalFaces()+nbrBFacei;
2569 const face& nbrF = nbrMesh.faces()[nbrFacei];
2572 labelList& nbrAddressing = pointProcAddressing[nbrMeshi];
2576 label nbrFp = procNbrIndex[i];
2580 label& ppPointi = pAddressing[
f[fp]];
2581 label& nbrPointi = nbrAddressing[nbrF[nbrFp]];
2594 if (ppPointi < nbrPointi)
2600 nbrPointi = ppPointi;
2603 else if (nbrPointi < ppPointi)
2609 ppPointi = nbrPointi;
2613 nbrFp = nbrF.rcIndex(nbrFp);
2637 labelList& compactPoints = localPoints[meshi];
2641 const labelList& pAddressing = pointProcAddressing[meshi];
2642 forAll(pAddressing, pointi)
2651 const label globali = globalPoints.
toGlobal(meshi, pointi);
2653 if (pAddressing[pointi] == globali)
2656 globalToCompact[globali] = nGlobal++;
2657 compactPoints[nCompact++] = pointi;
2660 compactPoints.setSize(nCompact);
2666 labelList& pAddressing = pointProcAddressing[meshi];
2667 pAddressing = UIndirectList<label>(globalToCompact, pAddressing);
2697 forAll(cellProcAddressing, meshi)
2699 cellProcAddressing[meshi].
clear();
2701 pointProcAddressing[meshi].
clear();
2716 offsets[meshi+1] = offsets[meshi]+
nPoints;
2732 pointProcAddressing,
2753 const labelList& cellLabels = cellZones[zonei];
2755 for (
const label celli : cellLabels)
2757 if (newZoneID[celli] != -1)
2762 <<
" is in two zones:"
2763 << cellZones[newZoneID[celli]].name()
2764 <<
" and " << cellZones[zonei].name() <<
endl
2765 <<
" This is not supported."
2766 <<
" Continuing with first zone only." <<
endl;
2770 newZoneID[celli] = cellZoneMap[meshi][zonei];
2777 for (label celli = 0; celli <
mesh.
nCells(); celli++)
2780 cellProcAddressing[meshi][celli] = meshMod.
addCell
2808 forAll(pointZones, zonei)
2814 newZoneID[pointi] = pointZoneMap[meshi][zonei];
2819 const labelList& myUniquePoints = uniquePoints[meshi];
2820 for (
const label pointi : myUniquePoints)
2824 pointProcAddressing[meshi][pointi] = meshMod.
addPoint
2865 boolList zoneFlip(faces.size(),
false);
2869 const labelList& faceLabels = faceZones[zonei];
2870 const boolList& flipMap = faceZones[zonei].flipMap();
2872 forAll(faceLabels, facei)
2874 newZoneID[faceLabels[facei]] = faceZoneMap[meshi][zonei];
2875 zoneFlip[faceLabels[facei]] = flipMap[facei];
2886 const face&
f = faces[facei];
2888 label newOwn = cellProcAddressing[meshi][faceOwner[facei]];
2889 label newNei = cellProcAddressing[meshi][faceNeighbour[facei]];
2894 newFace[fp] = pointProcAddressing[meshi][
f[fp]];
2896 bool flipFaceFlux =
false;
2897 bool flip = zoneFlip[facei];
2898 if (newNei < newOwn)
2900 Swap(newOwn, newNei);
2902 flipFaceFlux = !flipFaceFlux;
2906 const label newFacei = meshMod.
addFace
2926 const labelList& localBFaces = localBoundaryFace[meshi];
2927 const labelList& procNbrs = remoteFaceMesh[meshi];
2928 const labelList& procNbrBFaces = remoteBoundaryFace[meshi];
2932 const label bFacei = localBFaces[i];
2933 const label nbrMeshi = procNbrs[i];
2934 const label nbrBFacei = procNbrBFaces[i];
2939 const label newOwn =
2940 cellProcAddressing[meshi][faceOwner[facei]];
2943 const auto& nbrMesh =
meshes[nbrMeshi];
2944 const label nbrFacei = nbrMesh.nInternalFaces()+nbrBFacei;
2945 const label nbrOwn = nbrMesh.faceOwner()[nbrFacei];
2946 const label newNei = cellProcAddressing[nbrMeshi][nbrOwn];
2954 if (newOwn < newNei)
2959 newFace[fp] = pointProcAddressing[meshi][
f[fp]];
2961 const bool flipFaceFlux =
false;
2962 const bool flip = zoneFlip[facei];
2963 const label newFacei = meshMod.
addFace
2987 const auto& pp = pbm[patchi];
2989 if (patchi < patchMap[meshi].size())
2991 const label newPatchi = patchMap[meshi][patchi];
2997 const label facei = pp.
start() + patchFacei;
3000 const face&
f = faces[facei];
3002 const label newOwn =
3003 cellProcAddressing[meshi][faceOwner[facei]];
3007 newFace[fp] = pointProcAddressing[meshi][
f[fp]];
3010 const label newFacei = meshMod.
addFace