46Foam::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 label patchi = allPatchNames.find(pName);
63 patchi = allPatchNames.size();
65 allPatchNames.push_back(pName);
66 allPatchTypes.push_back(pType);
68 else if (allPatchTypes[patchi] != pType)
71 patchi = allPatchNames.size();
75 const word& caseName =
p.boundaryMesh().mesh().time().caseName();
77 allPatchNames.push_back(pName +
"_" + caseName);
78 allPatchTypes.push_back(pType);
80 Pout<<
"label patchIndex(const polyPatch& p) : "
81 <<
"Patch " <<
p.index() <<
" named "
82 << pName <<
" in mesh " << caseName
83 <<
" already exists, but patch types"
84 <<
" do not match.\nCreating a composite name as "
85 << allPatchNames.back() <<
endl;
93Foam::label Foam::polyMeshAdder::zoneIndex
99 label zonei =
names.find(curName);
104 zonei =
names.size();
106 names.push_back(curName);
113void Foam::polyMeshAdder::mergePatchNames
126 allPatchNames.push_back(patches0.names());
127 allPatchTypes.push_back(patches0.types());
137 from1ToAllPatches.setSize(patches1.size());
141 from1ToAllPatches[patchi] = patchIndex
148 allPatchTypes.shrink();
149 allPatchNames.shrink();
152 fromAllTo1Patches.setSize(allPatchNames.size());
153 fromAllTo1Patches = -1;
155 forAll(from1ToAllPatches, i)
157 fromAllTo1Patches[from1ToAllPatches[i]] = i;
162Foam::List<Foam::polyPatch*> Foam::polyMeshAdder::combinePatches
167 const label nAllPatches,
170 const label nInternalFaces,
186 from0ToAllPatches.setSize(patches0.size());
187 from0ToAllPatches = -1;
189 label startFacei = nInternalFaces;
197 label filteredPatchi;
207 filteredPatchi = allPatches.size();
211 patches0[patchi].clone
219 startFacei += nFaces[patchi];
223 from0ToAllPatches[patchi] = filteredPatchi;
226 if (fromAllTo1Patches[patchi] != -1)
228 from1ToAllPatches[fromAllTo1Patches[patchi]] = filteredPatchi;
233 forAll(from1ToAllPatches, patchi)
235 label allPatchi = from1ToAllPatches[patchi];
237 if (allPatchi >= patches0.size())
241 label filteredPatchi;
245 nFaces[allPatchi] == 0
255 filteredPatchi = allPatches.size();
259 patches1[patchi].clone
267 startFacei += nFaces[allPatchi];
270 from1ToAllPatches[patchi] = filteredPatchi;
283 const label nInternalFaces,
291 for (label facei = nInternalFaces; facei < owner.size(); ++facei)
293 oldToNew[facei] = facei;
307 const label facei = cFaces[i];
309 label nbrCelli = neighbour[facei];
314 if (nbrCelli == celli)
316 nbrCelli = owner[facei];
319 if (celli < nbrCelli)
343 oldToNew[cFaces[nbr.indices()[i]]] = newFacei++;
352 if (oldToNew[facei] == -1)
355 <<
"Did not determine new position"
356 <<
" for face " << facei
367void Foam::polyMeshAdder::insertVertices
385 label v0 = masterF[fp];
386 label v1 = masterF.nextLabel(fp);
389 workFace.append(allF[fp]);
393 const auto v0Fnd = meshToMaster.cfind(v0);
396 const auto v1Fnd = meshToMaster.cfind(v1);
402 masterToCutPoints[v0Fnd()],
403 masterToCutPoints[v1Fnd()]
406 const auto iter = cutEdgeToPoints.cfind(cutEdge);
410 const edge&
e = iter.key();
411 const labelList& addedPoints = iter.val();
414 if (
e[0] == cutEdge[0])
418 workFace.append(addedPoints[i]);
425 workFace.append(addedPoints[i]);
433 if (workFace.size() != allF.size())
435 allF.transfer(workFace);
452void Foam::polyMeshAdder::mergePrimitives
458 const label nAllPatches,
469 label& nInternalFaces,
490 allPoints.setSize(mesh0.nPoints() + mesh1.nPoints());
493 from0ToAllPoints.setSize(mesh0.nPoints());
494 from0ToAllPoints = -1;
495 from1ToAllPoints.setSize(mesh1.nPoints());
496 from1ToAllPoints = -1;
500 const pointField& cutPoints = coupleInfo.cutPoints();
509 coupleInfo.masterToCutPoints()
520 coupleInfo.slaveToCutPoints()
530 const labelList& masterPoints = cutToMasterPoints[i];
534 label mesh0Pointi = masterPatch.meshPoints()[masterPoints[j]];
535 from0ToAllPoints[mesh0Pointi] = allPointi;
538 const labelList& slavePoints = cutToSlavePoints[i];
542 label mesh1Pointi = slavePatch.meshPoints()[slavePoints[j]];
543 from1ToAllPoints[mesh1Pointi] = allPointi;
550 forAll(mesh0.points(), pointi)
552 if (from0ToAllPoints[pointi] == -1)
554 allPoints[allPointi] = mesh0.points()[pointi];
555 from0ToAllPoints[pointi] = allPointi;
561 forAll(mesh1.points(), pointi)
563 if (from1ToAllPoints[pointi] == -1)
565 allPoints[allPointi] = mesh1.points()[pointi];
566 from1ToAllPoints[pointi] = allPointi;
578 nFacesPerPatch.setSize(nAllPatches);
582 allFaces.setSize(mesh0.nFaces() + mesh1.nFaces());
583 allOwner.setSize(allFaces.size());
585 allNeighbour.setSize(allFaces.size());
589 from0ToAllFaces.setSize(mesh0.nFaces());
590 from0ToAllFaces = -1;
591 from1ToAllFaces.setSize(mesh1.nFaces());
592 from1ToAllFaces = -1;
595 for (label facei = 0; facei < mesh0.nInternalFaces(); facei++)
597 allFaces[allFacei] =
renumber(from0ToAllPoints, mesh0.faces()[facei]);
598 allOwner[allFacei] = mesh0.faceOwner()[facei];
599 allNeighbour[allFacei] = mesh0.faceNeighbour()[facei];
600 from0ToAllFaces[facei] = allFacei++;
605 const labelList& cutToMasterFaces = coupleInfo.cutToMasterFaces();
606 const labelList& cutToSlaveFaces = coupleInfo.cutToSlaveFaces();
610 label masterFacei = cutToMasterFaces[i];
612 label mesh0Facei = masterPatch.addressing()[masterFacei];
614 if (from0ToAllFaces[mesh0Facei] == -1)
617 from0ToAllFaces[mesh0Facei] = allFacei;
620 label patch0 = patches0.whichPatch(mesh0Facei);
621 nFacesPerPatch[patch0]--;
624 label slaveFacei = cutToSlaveFaces[i];
626 label mesh1Facei = slavePatch.addressing()[slaveFacei];
628 if (from1ToAllFaces[mesh1Facei] == -1)
630 from1ToAllFaces[mesh1Facei] = allFacei;
632 label patch1 = patches1.whichPatch(mesh1Facei);
633 nFacesPerPatch[from1ToAllPatches[patch1]]--;
638 allFaces[allFacei] = cutFaces[i];
639 allOwner[allFacei] = mesh0.faceOwner()[mesh0Facei];
640 allNeighbour[allFacei] = mesh1.faceOwner()[mesh1Facei] + mesh0.nCells();
646 for (label facei = 0; facei < mesh1.nInternalFaces(); facei++)
648 allFaces[allFacei] =
renumber(from1ToAllPoints, mesh1.faces()[facei]);
649 allOwner[allFacei] = mesh1.faceOwner()[facei] + mesh0.nCells();
650 allNeighbour[allFacei] = mesh1.faceNeighbour()[facei] + mesh0.nCells();
651 from1ToAllFaces[facei] = allFacei++;
654 nInternalFaces = allFacei;
657 for (label allPatchi = 0; allPatchi < nAllPatches; allPatchi++)
659 if (allPatchi < patches0.size())
664 nFacesPerPatch[allPatchi] +=
pp.
size();
666 label facei =
pp.start();
670 if (from0ToAllFaces[facei] == -1)
678 allOwner[allFacei] = mesh0.faceOwner()[facei];
679 allNeighbour[allFacei] = -1;
681 from0ToAllFaces[facei] = allFacei++;
686 if (fromAllTo1Patches[allPatchi] != -1)
689 const polyPatch&
pp = patches1[fromAllTo1Patches[allPatchi]];
691 nFacesPerPatch[allPatchi] +=
pp.
size();
693 label facei =
pp.start();
697 if (from1ToAllFaces[facei] == -1)
706 mesh1.faceOwner()[facei]
708 allNeighbour[allFacei] = -1;
710 from1ToAllFaces[facei] = allFacei++;
716 allFaces.setSize(allFacei);
717 allOwner.setSize(allFacei);
718 allNeighbour.setSize(allFacei);
734 = coupleInfo.cutEdgeToPoints();
739 forAll(cutToMasterFaces, i)
741 label meshFacei = masterPatch.addressing()[cutToMasterFaces[i]];
743 masterCutFaces.insert(meshFacei);
748 forAll(from0ToAllFaces, face0)
750 if (!masterCutFaces.found(face0))
752 label allFacei = from0ToAllFaces[face0];
757 masterPatch.meshPointMap(),
758 coupleInfo.masterToCutPoints(),
759 mesh0.faces()[face0],
770 forAll(cutToSlaveFaces, i)
772 label meshFacei = slavePatch.addressing()[cutToSlaveFaces[i]];
774 slaveCutFaces.insert(meshFacei);
777 forAll(from1ToAllFaces, face1)
779 if (!slaveCutFaces.found(face1))
781 label allFacei = from1ToAllFaces[face1];
786 slavePatch.meshPointMap(),
787 coupleInfo.slaveToCutPoints(),
788 mesh1.faces()[face1],
803 from1ToAllCells.setSize(mesh1.nCells());
804 from1ToAllCells = -1;
808 from1ToAllCells[i] = i + mesh0.nCells();
812 nCells = mesh0.nCells() + mesh1.nCells();
814 primitiveMesh::calcCells(allCells, allOwner, allNeighbour, nCells);
836void Foam::polyMeshAdder::mergePointZones
838 const label nAllPoints,
849 zoneNames.setCapacity(pz0.size() + pz1.size());
850 zoneNames.append(pz0.names());
852 from1ToAll.setSize(pz1.size());
856 from1ToAll[zoneI] = zoneIndex(pz1[zoneI].
name(), zoneNames);
876 label point0 = pz[i];
877 label allPointi = from0ToAllPoints[point0];
879 if (pointToZone[allPointi] == -1)
881 pointToZone[allPointi] = zoneI;
883 else if (pointToZone[allPointi] != zoneI)
885 addPointToZones[allPointi].push_uniq(zoneI);
894 const label allZoneI = from1ToAll[zoneI];
898 label point1 = pz[i];
899 label allPointi = from1ToAllPoints[point1];
901 if (pointToZone[allPointi] == -1)
903 pointToZone[allPointi] = allZoneI;
905 else if (pointToZone[allPointi] != allZoneI)
907 addPointToZones[allPointi].push_uniq(allZoneI);
916 forAll(pointToZone, allPointi)
918 label zoneI = pointToZone[allPointi];
924 forAll(addPointToZones, allPointi)
934 pzPoints.
setSize(zoneNames.size());
937 pzPoints[zoneI].setCapacity(
nPoints[zoneI]);
939 forAll(pointToZone, allPointi)
941 label zoneI = pointToZone[allPointi];
944 pzPoints[zoneI].append(allPointi);
947 forAll(addPointToZones, allPointi)
957 pzPoints[i].shrink();
963void Foam::polyMeshAdder::mergeFaceZones
982 const labelList& owner0 = mesh0.faceOwner();
984 const labelList& owner1 = mesh1.faceOwner();
987 zoneNames.setCapacity(fz0.size() + fz1.size());
988 zoneNames.append(fz0.names());
990 from1ToAll.setSize(fz1.size());
994 from1ToAll[zoneI] = zoneIndex(fz1[zoneI].
name(), zoneNames);
1000 labelList faceToZone(allOwner.size(), -1);
1002 boolList faceToFlip(allOwner.size(),
false);
1008 const labelList& addressing = fz0[zoneI];
1009 const boolList& flipMap = fz0[zoneI].flipMap();
1013 label face0 = addressing[i];
1014 bool flip0 = flipMap[i];
1016 label allFacei = from0ToAllFaces[face0];
1020 label allCell0 = owner0[face0];
1021 if (allOwner[allFacei] != allCell0)
1026 if (faceToZone[allFacei] == -1)
1028 faceToZone[allFacei] = zoneI;
1029 faceToFlip[allFacei] = flip0;
1031 else if (faceToZone[allFacei] != zoneI)
1033 if (addFaceToZones[allFacei].push_uniq(zoneI))
1035 addFaceToFlips[allFacei].push_back(flip0);
1045 const labelList& addressing = fz1[zoneI];
1046 const boolList& flipMap = fz1[zoneI].flipMap();
1048 const label allZoneI = from1ToAll[zoneI];
1052 label face1 = addressing[i];
1053 bool flip1 = flipMap[i];
1055 label allFacei = from1ToAllFaces[face1];
1059 label allCell1 = from1ToAllCells[owner1[face1]];
1060 if (allOwner[allFacei] != allCell1)
1065 if (faceToZone[allFacei] == -1)
1067 faceToZone[allFacei] = allZoneI;
1068 faceToFlip[allFacei] = flip1;
1070 else if (faceToZone[allFacei] != allZoneI)
1072 if (addFaceToZones[allFacei].push_uniq(allZoneI))
1074 addFaceToFlips[allFacei].push_back(flip1);
1086 forAll(faceToZone, allFacei)
1088 label zoneI = faceToZone[allFacei];
1094 forAll(addFaceToZones, allFacei)
1096 const labelList& fZones = addFaceToZones[allFacei];
1099 nFaces[fZones[i]]++;
1104 fzFaces.setSize(zoneNames.size());
1105 fzFlips.setSize(zoneNames.size());
1108 fzFaces[zoneI].setCapacity(nFaces[zoneI]);
1109 fzFlips[zoneI].setCapacity(nFaces[zoneI]);
1111 forAll(faceToZone, allFacei)
1113 label zoneI = faceToZone[allFacei];
1114 bool flip = faceToFlip[allFacei];
1117 fzFaces[zoneI].append(allFacei);
1118 fzFlips[zoneI].append(flip);
1121 forAll(addFaceToZones, allFacei)
1123 const labelList& fZones = addFaceToZones[allFacei];
1124 const boolList& flipZones = addFaceToFlips[allFacei];
1128 label zoneI = fZones[i];
1129 fzFaces[zoneI].append(allFacei);
1130 fzFlips[zoneI].append(flipZones[i]);
1136 fzFaces[i].shrink();
1137 fzFlips[i].shrink();
1147void Foam::polyMeshAdder::mergeCellZones
1149 const label nAllCells,
1160 zoneNames.setCapacity(cz0.size() + cz1.size());
1161 zoneNames.append(cz0.names());
1163 from1ToAll.setSize(cz1.size());
1166 from1ToAll[zoneI] = zoneIndex(cz1[zoneI].
name(), zoneNames);
1184 label cell0 = cz[i];
1186 if (cellToZone[cell0] == -1)
1188 cellToZone[cell0] = zoneI;
1190 else if (cellToZone[cell0] != zoneI)
1192 addCellToZones[cell0].push_uniq(zoneI);
1201 const label allZoneI = from1ToAll[zoneI];
1204 label cell1 = cz[i];
1205 label allCelli = from1ToAllCells[cell1];
1207 if (cellToZone[allCelli] == -1)
1209 cellToZone[allCelli] = allZoneI;
1211 else if (cellToZone[allCelli] != allZoneI)
1213 addCellToZones[allCelli].push_uniq(allZoneI);
1222 forAll(cellToZone, allCelli)
1224 label zoneI = cellToZone[allCelli];
1230 forAll(addCellToZones, allCelli)
1232 const labelList& cZones = addCellToZones[allCelli];
1235 nCells[cZones[i]]++;
1240 czCells.setSize(zoneNames.size());
1243 czCells[zoneI].setCapacity(nCells[zoneI]);
1245 forAll(cellToZone, allCelli)
1247 label zoneI = cellToZone[allCelli];
1250 czCells[zoneI].append(allCelli);
1253 forAll(addCellToZones, allCelli)
1255 const labelList& cZones = addCellToZones[allCelli];
1258 czCells[cZones[i]].append(allCelli);
1263 czCells[i].shrink();
1269void Foam::polyMeshAdder::mergeZones
1271 const label nAllPoints,
1273 const label nAllCells,
1340void Foam::polyMeshAdder::addZones
1448 label nInternalFaces;
1471 allPatchNames.
size(),
1546 allPatchNames.
size(),
1598 std::move(allPoints),
1599 std::move(allFaces),
1600 std::move(allOwner),
1601 std::move(allNeighbour)
1633 const bool validBoundary
1668 label nInternalFaces;
1685 allPatchNames.
size(),
1766 label startFacei = nInternalFaces;
1770 label allPatchi = 0;
1772 forAll(from0ToAllPatches, patch0)
1781 from0ToAllPatches[patch0] = -1;
1783 if (fromAllTo1Patches[patch0] != -1)
1785 from1ToAllPatches[fromAllTo1Patches[patch0]] = -1;
1796 allPatches[patch0].clone
1804 patchSizes[allPatchi] = nFaces[patch0];
1805 patchStarts[allPatchi] = startFacei;
1808 from0ToAllPatches[patch0] = allPatchi;
1811 if (fromAllTo1Patches[patch0] != -1)
1813 from1ToAllPatches[fromAllTo1Patches[patch0]] = allPatchi;
1816 startFacei += nFaces[patch0];
1823 forAll(from1ToAllPatches, patch1)
1825 label uncompactAllPatchi = from1ToAllPatches[patch1];
1827 if (uncompactAllPatchi >= from0ToAllPatches.
size())
1833 nFaces[uncompactAllPatchi] == 0
1839 from1ToAllPatches[patch1] = -1;
1847 patches1[patch1].clone
1855 patchSizes[allPatchi] = nFaces[uncompactAllPatchi];
1856 patchStarts[allPatchi] = startFacei;
1859 from1ToAllPatches[patch1] = allPatchi;
1861 startFacei += nFaces[uncompactAllPatchi];
1868 allPatches.
setSize(allPatchi);
1869 patchSizes.
setSize(allPatchi);
1870 patchStarts.
setSize(allPatchi);
1946 const scalar mergeDist
1949 const labelList& sharedPointLabels =
mesh.globalData().sharedPointLabels();
1950 const labelList& sharedPointAddr =
mesh.globalData().sharedPointAddr();
1961 label nMultiple = 0;
1963 forAll(sharedPointLabels, i)
1965 label pointi = sharedPointLabels[i];
1967 label sharedI = sharedPointAddr[i];
1969 auto iter = sharedToMesh.
find(sharedI);
1977 labelList& connectedPointLabels = iter.val();
1979 label sz = connectedPointLabels.
size();
1982 if (connectedPointLabels.
found(pointi))
1985 <<
"Duplicate point in sharedPoint addressing." <<
endl
1986 <<
"When trying to add point " << pointi <<
" on shared "
1987 << sharedI <<
" with connected points "
1988 << connectedPointLabels
1992 connectedPointLabels.
setSize(sz+1);
1993 connectedPointLabels[sz] = pointi;
1997 sharedToMesh.insert(sharedI,
labelList(1, pointi));
2009 const labelList& connectedPointLabels = iter.val();
2016 if (connectedPointLabels.size() > 1)
2021 connectedPointLabels
2033 if (nUnique < connectedPoints.size())
2048 const labelList& mergeSet = mergeSets[setI];
2050 if (mergeSet.size() > 1)
2057 label pointi = connectedPointLabels[mergeSet[i]];
2059 masterPointi =
min(masterPointi, pointi);
2064 label pointi = connectedPointLabels[mergeSet[i]];
2072 pointToMaster.insert(pointi, masterPointi);
2146 return pointToMaster;
2160 const auto iter = pointToMaster.
cfind(pointi);
2164 if (iter.val() != pointi)
2177 const face&
f = faces[facei];
2179 bool hasMerged =
false;
2183 label pointi =
f[fp];
2185 const auto iter = pointToMaster.
cfind(pointi);
2189 if (iter.val() != pointi)
2203 label pointi =
f[fp];
2205 const auto iter = pointToMaster.
cfind(pointi);
2209 newF[fp] = iter.val();
2216 bool zoneFlip =
false;
2221 zoneFlip = fZone.flipMap()[fZone.whichFace(facei)];
2244Foam::label Foam::polyMeshAdder::procPatchIndex
2247 const label nbrProci,
2261 if (
pp.neighbProcNo() == nbrProci)
2295 localPatch.setSize(
meshes.size());
2296 remoteProc.setSize(
meshes.size());
2297 remotePatch.setSize(
meshes.size());
2306 for (label proci = 1; proci <
meshes.size(); proci++)
2314 <<
"Patch names should be identical on all processors."
2315 <<
" Processor 0 has " << names0
2316 <<
". Processor " << proci
2329 const polyBoundaryMesh&
pbm =
meshes[proci].boundaryMesh();
2333 nNeighbourProcs = 0;
2335 for (label patchi =
pbm.nNonProcessor(); patchi <
pbm.size(); patchi++)
2337 const processorPolyPatch&
pp =
2341 const label nbrProci =
pp.neighbProcNo();
2342 const label nbrPatchi = procPatchIndex
2344 meshes[nbrProci].boundaryMesh(),
2346 nNeighbourProcs[nbrProci]
2349 const auto& nbrPbm =
meshes[nbrProci].boundaryMesh();
2350 const auto& nbrPp = nbrPbm[nbrPatchi];
2351 if (
pp.size() != nbrPp.size())
2354 <<
"at proc:" << proci
2355 <<
" processor patch "
2356 <<
pp.name() <<
" is not same size " <<
pp.size()
2357 <<
" as coupled patch " << nbrPp.name()
2358 <<
" on proc:" << nbrProci
2359 <<
" size:" << nbrPp.size()
2363 localPatch[proci].append(patchi);
2364 remoteProc[proci].append(nbrProci);
2365 remotePatch[proci].append(nbrPatchi);
2367 localPatch[nbrProci].append(nbrPatchi);
2368 remoteProc[nbrProci].append(proci);
2369 remotePatch[nbrProci].append(patchi);
2371 nNeighbourProcs[nbrProci]++;
2397 return meshes[0].boundaryMesh().nNonProcessor();
2426 const labelUList& procPatches = localPatch[meshi];
2427 const labelUList& procNbrs = remoteMesh[meshi];
2428 const labelUList& procNbrPatches = remotePatch[meshi];
2433 for (
const label patchi : procPatches)
2435 nFaces +=
pbm[patchi].size();
2438 labelList& procFaces = localBoundaryFace[meshi];
2439 labelList& remoteMeshes = remoteFaceMesh[meshi];
2440 labelList& remoteFaces = remoteBoundaryFace[meshi];
2450 const label patchi = procPatches[i];
2451 const label nbrMeshi = procNbrs[i];
2452 const label nbrPatchi = procNbrPatches[i];
2454 const auto&
pp =
pbm[patchi];
2455 const label offset =
pp.start()-
mesh.nInternalFaces();
2457 const auto& nbrMesh =
meshes[nbrMeshi];
2458 const auto& nbrPp = nbrMesh.boundaryMesh()[nbrPatchi];
2459 const label nbrOffset = nbrPp.start()-nbrMesh.nInternalFaces();
2463 procFaces[nFaces] = offset+patchFacei;
2464 remoteMeshes[nFaces] = nbrMeshi;
2465 remoteFaces[nFaces] = nbrOffset+patchFacei;
2473void Foam::polyMeshAdder::compactPoints
2502 labelList& pAddressing = pointProcAddressing[meshi];
2504 const labelList& localBFaces = localBoundaryFace[meshi];
2505 const labelList& procNbrs = remoteFaceMesh[meshi];
2506 const labelList& procNbrBFaces = remoteBoundaryFace[meshi];
2507 const labelList& procNbrIndex = remoteFaceStart[meshi];
2511 const label bFacei = localBFaces[i];
2512 const label nbrMeshi = procNbrs[i];
2513 const label nbrBFacei = procNbrBFaces[i];
2517 const face&
f = faces[facei];
2520 const auto& nbrMesh =
meshes[nbrMeshi];
2521 const label nbrFacei = nbrMesh.nInternalFaces()+nbrBFacei;
2522 const face& nbrF = nbrMesh.faces()[nbrFacei];
2525 labelList& nbrAddressing = pointProcAddressing[nbrMeshi];
2529 label nbrFp = procNbrIndex[i];
2533 label& ppPointi = pAddressing[
f[fp]];
2534 label& nbrPointi = nbrAddressing[nbrF[nbrFp]];
2547 if (ppPointi < nbrPointi)
2553 nbrPointi = ppPointi;
2556 else if (nbrPointi < ppPointi)
2562 ppPointi = nbrPointi;
2590 labelList& compactPoints = localPoints[meshi];
2594 const labelList& pAddressing = pointProcAddressing[meshi];
2595 forAll(pAddressing, pointi)
2604 const label globali =
globalPoints.toGlobal(meshi, pointi);
2606 if (pAddressing[pointi] == globali)
2609 globalToCompact[globali] = nGlobal++;
2610 compactPoints[nCompact++] = pointi;
2613 compactPoints.setSize(nCompact);
2619 labelList& pAddressing = pointProcAddressing[meshi];
2627 const UPtrList<polyMesh>&
meshes,
2628 const UList<labelList>& patchMap,
2635 const UList<labelList>& pointZoneMap,
2636 const UList<labelList>& faceZoneMap,
2637 const UList<labelList>& cellZoneMap,
2639 polyTopoChange& meshMod,
2646 cellProcAddressing.setSize(
meshes.size());
2647 faceProcAddressing.setSize(
meshes.size());
2648 pointProcAddressing.setSize(
meshes.size());
2650 forAll(cellProcAddressing, meshi)
2652 cellProcAddressing[meshi].clear();
2653 faceProcAddressing[meshi].clear();
2654 pointProcAddressing[meshi].clear();
2669 offsets[meshi+1] = offsets[meshi]+
nPoints;
2685 pointProcAddressing,
2704 for (label celli = 0; celli <
mesh.
nCells(); celli++)
2707 cellZones.whichZones(celli, zones);
2710 cellProcAddressing[meshi][celli] = meshMod.addCell
2736 const labelList& myUniquePoints = uniquePoints[meshi];
2738 for (
const label pointi : myUniquePoints)
2741 pointZones.whichZones(pointi, zones);
2745 pointProcAddressing[meshi][pointi] = meshMod.addPoint
2767 faceProcAddressing[meshi] = -1;
2794 const face&
f = faces[facei];
2796 label newOwn = cellProcAddressing[meshi][faceOwner[facei]];
2797 label newNei = cellProcAddressing[meshi][faceNeighbour[facei]];
2802 newFace[fp] = pointProcAddressing[meshi][
f[fp]];
2806 faceZones.whichZones(facei, zones);
2810 const label zonei = zones[i];
2811 const label index = faceZones[zonei].localID(facei);
2812 flips.append(faceZones[zonei].flipMap()[index]);
2816 bool flipFaceFlux =
false;
2817 if (newNei < newOwn)
2819 std::swap(newOwn, newNei);
2821 flipFaceFlux = !flipFaceFlux;
2822 for (
bool& flip : flips)
2828 const label newFacei = meshMod.addFace
2842 faceProcAddressing[meshi][facei] = newFacei;
2848 const labelList& localBFaces = localBoundaryFace[meshi];
2849 const labelList& procNbrs = remoteFaceMesh[meshi];
2850 const labelList& procNbrBFaces = remoteBoundaryFace[meshi];
2854 const label bFacei = localBFaces[i];
2855 const label nbrMeshi = procNbrs[i];
2856 const label nbrBFacei = procNbrBFaces[i];
2861 const label newOwn =
2862 cellProcAddressing[meshi][faceOwner[facei]];
2864 faceZones.whichZones(facei, zones);
2868 const label zonei = zones[i];
2869 const label index = faceZones[zonei].localID(facei);
2870 flips.append(faceZones[zonei].flipMap()[index]);
2876 const auto& nbrMesh =
meshes[nbrMeshi];
2877 const label nbrFacei = nbrMesh.nInternalFaces()+nbrBFacei;
2878 const label nbrOwn = nbrMesh.faceOwner()[nbrFacei];
2879 const label newNei = cellProcAddressing[nbrMeshi][nbrOwn];
2887 if (newOwn < newNei)
2889 newFace.setSize(
f.
size());
2892 newFace[fp] = pointProcAddressing[meshi][
f[fp]];
2894 const bool flipFaceFlux =
false;
2895 const label newFacei = meshMod.addFace
2909 faceProcAddressing[meshi][facei] = newFacei;
2910 faceProcAddressing[nbrMeshi][nbrFacei] = newFacei;
2919 const auto&
pp =
pbm[patchi];
2921 if (patchi < patchMap[meshi].size())
2923 const label newPatchi = patchMap[meshi][patchi];
2929 const label facei =
pp.start() + patchFacei;
2930 if (faceProcAddressing[meshi][facei] == -1)
2932 const face&
f = faces[facei];
2934 const label newOwn =
2935 cellProcAddressing[meshi][faceOwner[facei]];
2939 newFace[fp] = pointProcAddressing[meshi][
f[fp]];
2942 faceZones.whichZones(facei, zones);
2946 const label zonei = zones[i];
2948 faceZones[zonei].localID(facei);
2949 flips.append(faceZones[zonei].flipMap()[index]);
2954 const label newFacei = meshMod.addFace
2968 faceProcAddressing[meshi][facei] = newFacei;
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
const polyBoundaryMesh & pbm
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
void clear() noexcept
Clear the addressed list, i.e. set the size to zero.
void append(const T &val)
Copy append an element to the end of this list.
Map from edge (expressed as its endpoints) to value. Hashing (and ==) on an edge is symmetric.
const_iterator cfind(const Key &key) const
Find and return an const_iterator set at the hashed entry.
bool insert(const Key &key, const T &obj)
Copy insert a new entry, not overwriting existing entries.
iterator find(const Key &key)
Find and return an iterator set at the hashed entry.
Defines the attributes of an object for which implicit objectRegistry management is supported,...
label size() const noexcept
The number of elements in the list.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void setSize(label n)
Alias for resize().
void clear()
Clear the list, i.e. set size to zero.
A HashTable to objects of type <T> with a label key.
const T * set(const label i) const
Return const pointer to element (can be nullptr), or nullptr for out-of-range access (ie,...
void setSize(const label n)
Same as resize().
void append(autoPtr< T > &ptr)
Move append an element to the end of the list.
A list that is sorted upon construction or when explicitly requested with the sort() method.
A non-owning sub-view of a List (allocated or unallocated storage).
A List with indirect addressing. Like IndirectList but does not store addressing.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
bool found(const T &val, label pos=0) const
Same as contains().
label rcIndex(const label i) const noexcept
The reverse circular index. The previous index in the list which returns to the last at the beginning...
void size(const label n)
Older name for setAddressableSize.
label find(const T &val) const
Find index of the first occurrence of the value.
A list of pointers to objects of type <T>, without allocation/deallocation management of the pointers...
label size() const noexcept
The number of entries in the list.
label whichZones(const label objectIndex, DynamicList< label > &zones) const
Given a global object index, return (in argument) its zones.
void clear()
Clear the zones.
label whichZone(const label objectIndex) const
Given a global object index, return the zone it is in.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
void reset(T *p=nullptr) noexcept
Delete managed object and set to new given pointer.
static autoPtr< T > New(Args &&... args)
Construct autoPtr with forwarding arguments.
Addressing for all faces on surface of mesh. Can either be read from polyMesh or from triSurface....
An edge is a list of two vertex labels. This can correspond to a directed graph edge or an edge on a ...
Container for information needed to couple to meshes. When constructed from two meshes and a geometri...
const primitiveFacePatch & cutFaces() const
Addressing engine for combined set of faces.
A subset of mesh faces organised as a primitive patch.
label whichFace(const label meshFaceID) const
The local index of the given mesh face, -1 if not in the zone.
const boolList & flipMap() const noexcept
Return face flip map.
A face is a list of labels corresponding to mesh vertices.
void flip()
Flip the face in-place.
Calculates a non-overlapping list of offsets based on an input size (eg, number of cells) from differ...
Calculates points shared by more than two processor patches or cyclic patches.
Class containing mesh-to-mesh mapping information after a mesh addition where we add a mesh ('added m...
A polyBoundaryMesh is a polyPatch list with registered IO, a reference to the associated polyMesh,...
label nNonProcessor() const
The number of patches before the first processor patch.
labelList patchStarts() const
Return a list of patch start face indices.
label whichPatch(const label meshFacei) const
Return patch index for a given mesh face index. Uses binary search.
labelList patchSizes() const
Return a list of patch sizes.
wordList names() const
Return a list of patch names.
static autoPtr< polyMesh > add(const IOobject &io, const polyMesh &mesh0, const polyMesh &mesh1, const faceCoupleInfo &coupleInfo, autoPtr< mapAddedPolyMesh > &mapPtr)
Add two polyMeshes. Returns new polyMesh and map construct.
static void mergePoints(const polyMesh &, const Map< label > &pointToMaster, polyTopoChange &meshMod)
Helper: Merge points.
static void patchFacePairs(const UPtrList< polyMesh > &meshes, const List< DynamicList< label > > &localPatch, const List< DynamicList< label > > &remoteMesh, const List< DynamicList< label > > &remotePatch, labelListList &localBoundaryFace, labelListList &remoteFaceMesh, labelListList &remoteBoundaryFace)
Helper: expand list of coupled patches into pairs of coupled faces.
static Map< label > findSharedPoints(const polyMesh &, const scalar mergeTol)
Find topologically and geometrically shared points.
static label procPatchPairs(const UPtrList< polyMesh > &meshes, List< DynamicList< label > > &localPatch, List< DynamicList< label > > &remoteMesh, List< DynamicList< label > > &remotePatch)
Helper: find pairs of processor patches. Return number of non-processor patches.
Mesh consisting of general polyhedral cells.
const polyBoundaryMesh & boundaryMesh() const noexcept
Return boundary mesh.
const faceZoneMesh & faceZones() const noexcept
Return face zone mesh.
virtual const faceList & faces() const
Return raw faces.
virtual const labelList & faceOwner() const
Return face owner.
void resetMotion() const
Reset motion.
const cellZoneMesh & cellZones() const noexcept
Return cell zone mesh.
void addZones(PtrList< pointZone > &&pz, PtrList< faceZone > &&fz, PtrList< cellZone > &&cz)
Add mesh zones.
virtual const labelList & faceNeighbour() const
Return face neighbour.
const pointZoneMesh & pointZones() const noexcept
Return point zone mesh.
virtual const pointField & points() const
Return raw points.
void resetPrimitives(autoPtr< pointField > &&points, autoPtr< faceList > &&faces, autoPtr< labelList > &&owner, autoPtr< labelList > &&neighbour, const labelUList &patchSizes, const labelUList &patchStarts, const bool validBoundary=true)
Reset mesh primitive data. Assumes all patch info correct.
Class describing modification of a face.
A patch is a list of labels that address the faces in the global face list.
Direct mesh changes based on v1.3 polyTopoChange syntax.
label addPoint(const point &pt, const label masterPointID, const label zoneID, const bool inCell)
Add point. Return new point label.
label setAction(const topoAction &action)
For compatibility with polyTopoChange: set topological action.
label addCell(const label masterPointID, const label masterEdgeID, const label masterFaceID, const label masterCellID, const label zoneID)
Add cell. Return new cell label.
void removePoint(const label pointi, const label mergePointi)
Remove/merge point.
label addFace(const face &f, const label own, const label nei, const label masterPointID, const label masterEdgeID, const label masterFaceID, const bool flipFaceFlux, const label patchID, const label zoneID, const bool zoneFlip)
Add face to cells. Return new face label.
label nInternalFaces() const noexcept
Number of internal faces.
label nPoints() const noexcept
Number of mesh points.
label nCells() const noexcept
Number of mesh cells.
label nFaces() const noexcept
Number of mesh faces.
Neighbour processor patch.
A class for handling words, derived from Foam::string.
Foam::autoPtr< Foam::dynamicFvMesh > meshPtr
Foam::PtrList< Foam::fvMesh > meshes(regionNames.size())
IOporosityModelList pZones(mesh)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Geometric merging of points. See below.
Type & refCast(U &obj)
A dynamic_cast (for references) to Type reference.
List< word > wordList
List of word.
void inplaceRenumber(const labelUList &oldToNew, IntListType &input)
Inplace renumber the values within a list.
ZoneMesh< pointZone, polyMesh > pointZoneMesh
A ZoneMesh with pointZone content on a polyMesh.
List< labelList > labelListList
List of labelList.
List< label > labelList
A List of labels.
HashSet< label, Hash< label > > labelHashSet
A HashSet of labels, uses label hasher.
UIndirectList< label > labelUIndList
UIndirectList of labels.
IntListType renumber(const labelUList &oldToNew, const IntListType &input)
Renumber the values within a list.
ZoneMesh< faceZone, polyMesh > faceZoneMesh
A ZoneMesh with faceZone content on a polyMesh.
List< face > faceList
List of faces.
label mergePoints(const PointList &points, labelList &pointToUnique, labelList &uniquePoints, const scalar mergeTol=SMALL, const bool verbose=false)
Calculate merge mapping, preserving the original point order. All points closer/equal mergeTol are to...
Ostream & endl(Ostream &os)
Add newline and flush stream.
PrimitivePatch< List< face >, const pointField & > primitiveFacePatch
A PrimitivePatch with List storage for the faces, const reference for the point field.
void inplaceReorder(const labelUList &oldToNew, ListType &input, const bool prune=false)
Inplace reorder the elements of a list.
List< cell > cellList
List of cell.
const Type * isA(const U &obj)
Attempt dynamic_cast to Type.
ZoneMesh< cellZone, polyMesh > cellZoneMesh
A ZoneMesh with cellZone content on a polyMesh.
labelList sortedOrder(const UList< T > &input)
Return the (stable) sort order for the list.
PrimitivePatch< IndirectList< face >, const pointField & > indirectPrimitivePatch
A PrimitivePatch with an IndirectList for the faces, const reference for the point field.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
List< List< bool > > boolListList
List of boolList.
labelList identity(const label len, label start=0)
Return an identity map of the given length with (map[i] == i), works like std::iota() but returning a...
errorManip< error > abort(error &err)
List< bool > boolList
A List of bools.
UIndirectList< bool > boolUIndList
UIndirectList of bools.
static constexpr const zero Zero
Global zero (0).
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
vectorField pointField
pointField is a vectorField.
labelListList invertOneToMany(const label len, const labelUList &map)
Invert one-to-many map. Unmapped elements will be size 0.
errorManipArg< error, int > exit(error &err, const int errNo=1)
UList< label > labelUList
A UList of labels.
void stableSort(UList< T > &list)
Stable sort the list.
#define forAll(list, i)
Loop across all elements in list.
#define forAllReverse(list, i)
Reverse loop across all elements in list.
#define forAllConstIters(container, iter)
Iterate across all elements of the container object with const access.