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 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;
93 Foam::label Foam::polyMeshAdder::zoneIndex
96 DynamicList<word>&
names 113 void Foam::polyMeshAdder::mergePatchNames
115 const polyBoundaryMesh& patches0,
116 const polyBoundaryMesh& patches1,
118 DynamicList<word>& allPatchNames,
119 DynamicList<word>& allPatchTypes,
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;
164 const polyMesh& mesh0,
165 const polyMesh& mesh1,
166 const polyBoundaryMesh& allBoundaryMesh,
167 const label nAllPatches,
170 const label nInternalFaces,
177 const polyBoundaryMesh& patches0 = mesh0.boundaryMesh();
178 const polyBoundaryMesh& patches1 = mesh1.boundaryMesh();
182 DynamicList<polyPatch*> allPatches(nAllPatches);
186 from0ToAllPatches.setSize(patches0.size());
187 from0ToAllPatches = -1;
189 label startFacei = nInternalFaces;
197 label filteredPatchi;
199 if (nFaces[patchi] == 0 && isA<processorPolyPatch>(patches0[patchi]))
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
246 && isA<processorPolyPatch>(patches1[patchi])
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;
303 SortableList<label> nbr(cFaces.size());
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
367 void Foam::polyMeshAdder::insertVertices
369 const EdgeMap<labelList>& cutEdgeToPoints,
370 const Map<label>& meshToMaster,
374 DynamicList<label>& workFace,
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);
452 void Foam::polyMeshAdder::mergePrimitives
454 const polyMesh& mesh0,
455 const polyMesh& mesh1,
456 const faceCoupleInfo& coupleInfo,
458 const label nAllPatches,
469 label& nInternalFaces,
478 const polyBoundaryMesh& patches0 = mesh0.boundaryMesh();
479 const polyBoundaryMesh& patches1 = mesh1.boundaryMesh();
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())
662 const polyPatch&
pp = patches0[allPatchi];
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);
733 const EdgeMap<labelList>& cutEdgeToPoints
734 = coupleInfo.cutEdgeToPoints();
739 forAll(cutToMasterFaces, i)
741 label meshFacei = masterPatch.addressing()[cutToMasterFaces[i]];
743 masterCutFaces.insert(meshFacei);
746 DynamicList<label> workFace(100);
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);
836 void Foam::polyMeshAdder::mergePointZones
838 const label nAllPoints,
844 DynamicList<word>& zoneNames,
846 List<DynamicList<label>>& pzPoints
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);
872 const pointZone& pz = pz0[zoneI];
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);
893 const pointZone& pz = pz1[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)
952 pzPoints[
pZones[i]].append(allPointi);
957 pzPoints[i].shrink();
963 void Foam::polyMeshAdder::mergeFaceZones
967 const polyMesh& mesh0,
968 const polyMesh& mesh1,
975 DynamicList<word>& zoneNames,
977 List<DynamicList<label>>& fzFaces,
978 List<DynamicList<bool>>& fzFlips
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();
1147 void Foam::polyMeshAdder::mergeCellZones
1149 const label nAllCells,
1155 DynamicList<word>& zoneNames,
1157 List<DynamicList<label>>& czCells
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);
1181 const cellZone& cz = cz0[zoneI];
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);
1200 const cellZone& cz = cz1[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();
1269 void Foam::polyMeshAdder::mergeZones
1271 const label nAllPoints,
1273 const label nAllCells,
1275 const polyMesh& mesh0,
1276 const polyMesh& mesh1,
1284 DynamicList<word>& pointZoneNames,
1285 List<DynamicList<label>>& pzPoints,
1287 DynamicList<word>& faceZoneNames,
1288 List<DynamicList<label>>& fzFaces,
1289 List<DynamicList<bool>>& fzFlips,
1291 DynamicList<word>& cellZoneNames,
1292 List<DynamicList<label>>& czCells
1340 void Foam::polyMeshAdder::addZones
1342 const DynamicList<word>& pointZoneNames,
1343 const List<DynamicList<label>>& pzPoints,
1345 const DynamicList<word>& faceZoneNames,
1346 const List<DynamicList<label>>& fzFaces,
1347 const List<DynamicList<bool>>& fzFlips,
1349 const DynamicList<word>& cellZoneNames,
1350 const List<DynamicList<label>>& czCells,
1355 List<pointZone*>
pZones(pzPoints.size());
1358 pZones[i] =
new pointZone
1367 List<faceZone*> fZones(fzFaces.size());
1370 fZones[i] =
new faceZone
1380 List<cellZone*> cZones(czCells.size());
1383 cZones[i] =
new cellZone
1426 labelList fromAllTo1Patches(allPatchNames.size(), -1);
1448 label nInternalFaces;
1471 allPatchNames.size(),
1546 allPatchNames.
size(),
1548 mesh0.nInternalFaces()
1549 + mesh1.nInternalFaces()
1599 std::move(allFaces),
1600 std::move(allOwner),
1601 std::move(allNeighbour)
1633 const bool validBoundary
1644 labelList fromAllTo1Patches(allPatchNames.size(), -1);
1668 label nInternalFaces;
1685 allPatchNames.size(),
1762 allPatches.
setSize(allPatchNames.size());
1763 labelList patchSizes(allPatches.size());
1764 labelList patchStarts(allPatches.size());
1766 label startFacei = nInternalFaces;
1770 label allPatchi = 0;
1772 forAll(from0ToAllPatches, patch0)
1777 if (nFaces[patch0] == 0 && isA<processorPolyPatch>(allPatches[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
1834 && isA<processorPolyPatch>(patches1[patch1])
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);
1876 autoPtr<mapAddedPolyMesh> mapPtr
1878 new mapAddedPolyMesh
1909 mesh0.resetMotion();
1910 mesh0.resetPrimitives
1922 mesh0.pointZones().
clear();
1923 mesh0.faceZones().clear();
1924 mesh0.cellZones().clear();
1946 const scalar mergeDist
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));
2005 Map<label> pointToMaster(nMultiple);
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)];
2244 Foam::label Foam::polyMeshAdder::procPatchIndex
2246 const polyBoundaryMesh&
pbm,
2247 const label nbrProci,
2259 const processorPolyPatch&
pp =
2260 refCast<const processorPolyPatch>(
pbm[patchi]);
2261 if (
pp.neighbProcNo() == nbrProci)
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;
2337 const processorPolyPatch&
pp =
2338 refCast<const processorPolyPatch>(
pbm[patchi]);
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();
2433 for (
const label patchi : procPatches)
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];
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;
2473 void Foam::polyMeshAdder::compactPoints
2475 const UPtrList<polyMesh>&
meshes,
2480 const globalIndex& globalPoints,
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;
2566 nbrFp = nbrF.rcIndex(nbrFp);
2582 labelList globalToCompact(globalPoints.totalSize(), -1);
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];
2620 pAddressing = UIndirectList<label>(globalToCompact, pAddressing);
2650 forAll(cellProcAddressing, meshi)
2652 cellProcAddressing[meshi].
clear();
2653 faceProcAddressing[meshi].
clear();
2654 pointProcAddressing[meshi].
clear();
2669 offsets[meshi+1] = offsets[meshi]+
nPoints;
2671 const globalIndex globalPoints(std::move(offsets));
2685 pointProcAddressing,
2703 DynamicList<label> zones;
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];
2737 DynamicList<label> zones;
2738 for (
const label pointi : myUniquePoints)
2741 pointZones.whichZones(pointi, zones);
2745 pointProcAddressing[meshi][pointi] = meshMod.
addPoint 2767 faceProcAddressing[meshi] = -1;
2784 DynamicList<label> zones;
2785 DynamicList<bool> flips;
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)
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;
const labelList & sharedPointLabels() const
Return indices of local points that are globally shared.
const polyBoundaryMesh & pbm
reference val() const
Const access to referenced object (value)
labelList patchSizes() const
Return a list of patch sizes.
void size(const label n)
Older name for setAddressableSize.
ZoneMesh< faceZone, polyMesh > faceZoneMesh
A ZoneMesh with the type faceZone.
List< List< bool > > boolListList
List of boolList.
List< word > names(const UPtrList< T > &list, const UnaryMatchPredicate &matcher)
List of names generated by calling name() for each list item and filtered for matches.
List< cell > cellList
List of cell.
errorManipArg< error, int > exit(error &err, const int errNo=1)
label nPoints() const noexcept
Number of mesh points.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
void append(const T &val)
Append an element at the end of the list.
virtual const labelList & faceNeighbour() const
Return face neighbour.
labelList sortedOrder(const UList< T > &input)
Return the (stable) sort order for the list.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
IntListType renumber(const labelUList &oldToNew, const IntListType &input)
Renumber the values within a list.
void inplaceReorder(const labelUList &oldToNew, ListType &input, const bool prune=false)
Inplace reorder the elements of a list.
UIndirectList< label > labelUIndList
UIndirectList of labels.
Ostream & endl(Ostream &os)
Add newline and flush stream.
bool found(const T &val, label pos=0) const
Same as contains()
void clear() noexcept
Same as reset(nullptr)
Class containing mesh-to-mesh mapping information after a mesh addition where we add a mesh ('added m...
void stableSort(UList< T > &list)
Stable sort the list.
const primitiveFacePatch & cutFaces() const
Addressing engine for combined set of faces.
label nFaces() const noexcept
Number of mesh faces.
PrimitivePatch< IndirectList< face >, const pointField & > indirectPrimitivePatch
A PrimitivePatch with an IndirectList for the faces, const reference for the point field...
void push_back(const T &val)
Append an element at the end of the list.
List< labelList > labelListList
List of labelList.
label addCell(const label masterPointID, const label masterEdgeID, const label masterFaceID, const label masterCellID, const label zoneID)
Add cell. Return new cell label.
Container for information needed to couple to meshes. When constructed from two meshes and a geometri...
virtual const pointField & points() const
Return raw points.
#define forAll(list, i)
Loop across all elements in list.
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...
void reset(T *p=nullptr) noexcept
Delete managed object and set to new given pointer.
HashSet< label, Hash< label > > labelHashSet
A HashSet of labels, uses label hasher.
bool insert(const Key &key, const T &obj)
Copy insert a new entry, not overwriting existing entries.
List< face > faceList
List of faces.
A List obtained as a section of another List.
vectorField pointField
pointField is a vectorField.
const dimensionedScalar e
Elementary charge.
void setSize(const label n)
Alias for resize()
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
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.
Foam::autoPtr< Foam::dynamicFvMesh > meshPtr
labelListList invertOneToMany(const label len, const labelUList &map)
Invert one-to-many map. Unmapped elements will be size 0.
const_iterator cfind(const Key &key) const
Find and return an const_iterator set at the hashed entry.
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...
static void mergePoints(const polyMesh &, const Map< label > &pointToMaster, polyTopoChange &meshMod)
Helper: Merge points.
void clear()
Clear the list, i.e. set size to zero.
const polyBoundaryMesh & boundaryMesh() const noexcept
Return boundary mesh.
wordList names() const
Return a list of patch names.
label size() const noexcept
The number of entries in the list.
void addZones(PtrList< pointZone > &&pz, PtrList< faceZone > &&fz, PtrList< cellZone > &&cz)
Add mesh zones.
Foam::PtrList< Foam::fvMesh > meshes(regionNames.size())
virtual const labelList & faceOwner() const
Return face owner.
const globalMeshData & globalData() const
Return parallel info (demand-driven)
label nInternalFaces() const noexcept
Number of internal faces.
ZoneMesh< pointZone, polyMesh > pointZoneMesh
A ZoneMesh with the type pointZone.
virtual const faceList & faces() const
Return raw faces.
label whichPatch(const label meshFacei) const
Return patch index for a given mesh face index. Uses binary search.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
A list of pointers to objects of type <T>, without allocation/deallocation management of the pointers...
errorManip< error > abort(error &err)
const T * set(const label i) const
Return const pointer to element (can be nullptr), or nullptr for out-of-range access (ie...
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
label find(const T &val) const
Find index of the first occurrence of the value.
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.
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO...
const faceZoneMesh & faceZones() const noexcept
Return face zone mesh.
Geometric merging of points. See below.
void setSize(const label newLen)
Same as resize()
PrimitivePatch< List< face >, const pointField & > primitiveFacePatch
A PrimitivePatch with List storage for the faces, const reference for the point field.
labelList patchStarts() const
Return a list of patch start face indices.
label whichZone(const label objectIndex) const
Given a global object index, return the zone it is in.
const pointZoneMesh & pointZones() const noexcept
Return point zone mesh.
void inplaceRenumber(const labelUList &oldToNew, IntListType &input)
Inplace renumber the values within a list.
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.
label nCells() const noexcept
Number of mesh cells.
void removePoint(const label pointi, const label mergePointi)
Remove/merge point.
Direct mesh changes based on v1.3 polyTopoChange syntax.
const cellZoneMesh & cellZones() const noexcept
Return cell zone mesh.
Mesh consisting of general polyhedral cells.
label addPoint(const point &pt, const label masterPointID, const label zoneID, const bool inCell)
Add point. Return new point label.
#define forAllReverse(list, i)
Reverse loop across all elements in list.
List< label > labelList
A List of labels.
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, IOobject::NO_REGISTER)
static autoPtr< T > New(Args &&... args)
Construct autoPtr with forwarding arguments.
label nNonProcessor() const
The number of patches before the first processor patch.
void addPatches(polyPatchList &plist, const bool validBoundary=true)
Add boundary patches.
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.
const labelList & sharedPointAddr() const
Return addressing into the complete globally shared points list.
Defines the attributes of an object for which implicit objectRegistry management is supported...
List< bool > boolList
A List of bools.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
ZoneMesh< cellZone, polyMesh > cellZoneMesh
A ZoneMesh with the type cellZone.
static Map< label > findSharedPoints(const polyMesh &, const scalar mergeTol)
Find topologically and geometrically shared points.
UIndirectList< bool > boolUIndList
UIndirectList of bools.
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
forAllConstIters(mixture.phases(), phase)
IOporosityModelList pZones(mesh)
A HashTable to objects of type <T> with a label key.
label setAction(const topoAction &action)
For compatibility with polyTopoChange: set topological action.
static constexpr const zero Zero
Global zero (0)