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 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 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
1469 labelList fromAllTo1Patches(allPatchNames.size(), -1);
1491 label nInternalFaces;
1514 allPatchNames.size(),
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
1687 labelList fromAllTo1Patches(allPatchNames.size(), -1);
1711 label nInternalFaces;
1728 allPatchNames.size(),
1795 labelList mesh0PatchSizes(getPatchSizes(patches0));
1796 labelList mesh0PatchStarts(getPatchStarts(patches0));
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);
1919 autoPtr<mapAddedPolyMesh> mapPtr
1921 new mapAddedPolyMesh
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));
2048 Map<label> pointToMaster(nMultiple);
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);
2189 return pointToMaster;
2203 const auto iter = pointToMaster.
cfind(pointi);
2207 if (iter.val() != pointi)
2220 const face&
f = faces[facei];
2222 bool hasMerged =
false;
2226 label pointi =
f[fp];
2228 const auto iter = pointToMaster.
cfind(pointi);
2232 if (iter.val() != pointi)
2246 label pointi =
f[fp];
2248 const auto iter = pointToMaster.
cfind(pointi);
2252 newF[fp] = iter.
val();
2259 bool zoneFlip =
false;
2264 zoneFlip = fZone.flipMap()[fZone.whichFace(facei)];
2287 Foam::label Foam::polyMeshAdder::procPatchIndex
2289 const polyBoundaryMesh& pbm,
2290 const label nbrProci,
2300 for (label patchi = pbm.nNonProcessor(); patchi < pbm.size(); patchi++)
2302 const processorPolyPatch& pp =
2303 refCast<const processorPolyPatch>(pbm[patchi]);
2304 if (pp.neighbProcNo() == nbrProci)
2349 for (label proci = 1; proci <
meshes.
size(); proci++)
2357 <<
"Patch names should be identical on all processors." 2358 <<
" Processor 0 has " << names0
2359 <<
". Processor " << proci
2372 const polyBoundaryMesh& pbm =
meshes[proci].boundaryMesh();
2376 nNeighbourProcs = 0;
2378 for (label patchi = pbm.nNonProcessor(); patchi < pbm.size(); patchi++)
2380 const processorPolyPatch& pp =
2381 refCast<const processorPolyPatch>(pbm[patchi]);
2384 const label nbrProci = pp.neighbProcNo();
2385 const label nbrPatchi = procPatchIndex
2387 meshes[nbrProci].boundaryMesh(),
2389 nNeighbourProcs[nbrProci]
2392 const auto& nbrPbm =
meshes[nbrProci].boundaryMesh();
2393 const auto& nbrPp = nbrPbm[nbrPatchi];
2394 if (pp.size() != nbrPp.size())
2397 <<
"at proc:" << proci
2398 <<
" processor patch " 2399 << pp.name() <<
" is not same size " << pp.size()
2400 <<
" as coupled patch " << nbrPp.name()
2401 <<
" on proc:" << nbrProci
2402 <<
" size:" << nbrPp.size()
2406 localPatch[proci].append(patchi);
2407 remoteProc[proci].append(nbrProci);
2408 remotePatch[proci].append(nbrPatchi);
2410 localPatch[nbrProci].append(nbrPatchi);
2411 remoteProc[nbrProci].append(proci);
2412 remotePatch[nbrProci].append(patchi);
2414 nNeighbourProcs[nbrProci]++;
2440 return meshes[0].boundaryMesh().nNonProcessor();
2476 for (
const label patchi : procPatches)
2478 nFaces += pbm[patchi].
size();
2481 labelList& procFaces = localBoundaryFace[meshi];
2482 labelList& remoteMeshes = remoteFaceMesh[meshi];
2483 labelList& remoteFaces = remoteBoundaryFace[meshi];
2493 const label patchi = procPatches[i];
2494 const label nbrMeshi = procNbrs[i];
2495 const label nbrPatchi = procNbrPatches[i];
2497 const auto& pp = pbm[patchi];
2500 const auto& nbrMesh =
meshes[nbrMeshi];
2501 const auto& nbrPp = nbrMesh.boundaryMesh()[nbrPatchi];
2502 const label nbrOffset = nbrPp.start()-nbrMesh.nInternalFaces();
2506 procFaces[nFaces] = offset+patchFacei;
2507 remoteMeshes[nFaces] = nbrMeshi;
2508 remoteFaces[nFaces] = nbrOffset+patchFacei;
2516 void Foam::polyMeshAdder::compactPoints
2518 const UPtrList<polyMesh>&
meshes,
2523 const globalIndex& globalPoints,
2545 labelList& pAddressing = pointProcAddressing[meshi];
2547 const labelList& localBFaces = localBoundaryFace[meshi];
2548 const labelList& procNbrs = remoteFaceMesh[meshi];
2549 const labelList& procNbrBFaces = remoteBoundaryFace[meshi];
2550 const labelList& procNbrIndex = remoteFaceStart[meshi];
2554 const label bFacei = localBFaces[i];
2555 const label nbrMeshi = procNbrs[i];
2556 const label nbrBFacei = procNbrBFaces[i];
2560 const face&
f = faces[facei];
2563 const auto& nbrMesh =
meshes[nbrMeshi];
2564 const label nbrFacei = nbrMesh.nInternalFaces()+nbrBFacei;
2565 const face& nbrF = nbrMesh.faces()[nbrFacei];
2568 labelList& nbrAddressing = pointProcAddressing[nbrMeshi];
2572 label nbrFp = procNbrIndex[i];
2576 label& ppPointi = pAddressing[
f[fp]];
2577 label& nbrPointi = nbrAddressing[nbrF[nbrFp]];
2590 if (ppPointi < nbrPointi)
2596 nbrPointi = ppPointi;
2599 else if (nbrPointi < ppPointi)
2605 ppPointi = nbrPointi;
2609 nbrFp = nbrF.rcIndex(nbrFp);
2625 labelList globalToCompact(globalPoints.totalSize(), -1);
2633 labelList& compactPoints = localPoints[meshi];
2637 const labelList& pAddressing = pointProcAddressing[meshi];
2638 forAll(pAddressing, pointi)
2647 const label globali = globalPoints.toGlobal(meshi, pointi);
2649 if (pAddressing[pointi] == globali)
2652 globalToCompact[globali] = nGlobal++;
2653 compactPoints[nCompact++] = pointi;
2656 compactPoints.setSize(nCompact);
2662 labelList& pAddressing = pointProcAddressing[meshi];
2663 pAddressing = UIndirectList<label>(globalToCompact, pAddressing);
2693 forAll(cellProcAddressing, meshi)
2695 cellProcAddressing[meshi].
clear();
2696 faceProcAddressing[meshi].
clear();
2697 pointProcAddressing[meshi].
clear();
2712 offsets[meshi+1] = offsets[meshi]+
nPoints;
2714 const globalIndex globalPoints(std::move(offsets));
2728 pointProcAddressing,
2749 const labelList& cellLabels = cellZones[zonei];
2751 for (
const label celli : cellLabels)
2753 if (newZoneID[celli] != -1)
2758 <<
" is in two zones:" 2759 << cellZones[newZoneID[celli]].name()
2760 <<
" and " << cellZones[zonei].name() <<
endl 2761 <<
" This is not supported." 2762 <<
" Continuing with first zone only." <<
endl;
2766 newZoneID[celli] = cellZoneMap[meshi][zonei];
2773 for (label celli = 0; celli <
mesh.
nCells(); celli++)
2776 cellProcAddressing[meshi][celli] = meshMod.
addCell 2804 forAll(pointZones, zonei)
2810 newZoneID[pointi] = pointZoneMap[meshi][zonei];
2815 const labelList& myUniquePoints = uniquePoints[meshi];
2816 for (
const label pointi : myUniquePoints)
2820 pointProcAddressing[meshi][pointi] = meshMod.
addPoint 2842 faceProcAddressing[meshi] = -1;
2861 boolList zoneFlip(faces.size(),
false);
2865 const labelList& faceLabels = faceZones[zonei];
2866 const boolList& flipMap = faceZones[zonei].flipMap();
2868 forAll(faceLabels, facei)
2870 newZoneID[faceLabels[facei]] = faceZoneMap[meshi][zonei];
2871 zoneFlip[faceLabels[facei]] = flipMap[facei];
2882 const face&
f = faces[facei];
2884 label newOwn = cellProcAddressing[meshi][faceOwner[facei]];
2885 label newNei = cellProcAddressing[meshi][faceNeighbour[facei]];
2890 newFace[fp] = pointProcAddressing[meshi][
f[fp]];
2892 bool flipFaceFlux =
false;
2893 bool flip = zoneFlip[facei];
2894 if (newNei < newOwn)
2896 Swap(newOwn, newNei);
2897 newFace = newFace.reverseFace();
2898 flipFaceFlux = !flipFaceFlux;
2902 const label newFacei = meshMod.
addFace 2916 faceProcAddressing[meshi][facei] = newFacei;
2922 const labelList& localBFaces = localBoundaryFace[meshi];
2923 const labelList& procNbrs = remoteFaceMesh[meshi];
2924 const labelList& procNbrBFaces = remoteBoundaryFace[meshi];
2928 const label bFacei = localBFaces[i];
2929 const label nbrMeshi = procNbrs[i];
2930 const label nbrBFacei = procNbrBFaces[i];
2935 const label newOwn =
2936 cellProcAddressing[meshi][faceOwner[facei]];
2939 const auto& nbrMesh =
meshes[nbrMeshi];
2940 const label nbrFacei = nbrMesh.nInternalFaces()+nbrBFacei;
2941 const label nbrOwn = nbrMesh.faceOwner()[nbrFacei];
2942 const label newNei = cellProcAddressing[nbrMeshi][nbrOwn];
2950 if (newOwn < newNei)
2955 newFace[fp] = pointProcAddressing[meshi][
f[fp]];
2957 const bool flipFaceFlux =
false;
2958 const bool flip = zoneFlip[facei];
2959 const label newFacei = meshMod.
addFace 2973 faceProcAddressing[meshi][facei] = newFacei;
2974 faceProcAddressing[nbrMeshi][nbrFacei] = newFacei;
2983 const auto& pp = pbm[patchi];
2985 if (patchi < patchMap[meshi].size())
2987 const label newPatchi = patchMap[meshi][patchi];
2993 const label facei = pp.start() + patchFacei;
2994 if (faceProcAddressing[meshi][facei] == -1)
2996 const face&
f = faces[facei];
2998 const label newOwn =
2999 cellProcAddressing[meshi][faceOwner[facei]];
3003 newFace[fp] = pointProcAddressing[meshi][
f[fp]];
3006 const label newFacei = meshMod.
addFace 3020 faceProcAddressing[meshi][facei] = newFacei;
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
const labelList & sharedPointLabels() const
Return indices of local points that are globally shared.
List< labelList > labelListList
A List of labelList.
reference val() const
Const access to referenced object (value)
void size(const label n)
Older name for setAddressableSize.
ZoneMesh< faceZone, polyMesh > faceZoneMesh
A ZoneMesh with the type faceZone.
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.
errorManipArg< error, int > exit(error &err, const int errNo=1)
labelList pointLabels(nPoints, -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.
label find(const T &val, label pos=0) const
Find index of the first occurrence of the value.
virtual const labelList & faceNeighbour() const
Return face neighbour.
labelList sortedOrder(const UList< T > &input)
Return the (stable) sort order for the list.
IntListType renumber(const labelUList &oldToNew, const IntListType &input)
Renumber the values (not the indices) of a list.
void inplaceReorder(const labelUList &oldToNew, ListType &input, const bool prune=false)
Inplace reorder the elements of a list.
label start() const noexcept
The start label of boundary faces in the polyMesh face list.
List< face > faceList
A List of faces.
Ostream & endl(Ostream &os)
Add newline and flush stream.
bool found(const T &val, label pos=0) const
True if the value if found in the list.
label appendUniq(const T &val)
Append an element if not already in the list.
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...
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< List< bool > > boolListList
A List of boolList.
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()
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, false)
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for 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)
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.
wordList names() const
Return a list of patch names.
label size() const noexcept
The number of elements 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.
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 min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
const vectorField & cellCentres() const
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...
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.
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 (not the indices) of a list.
UIndirectList< label > labelUIndList
UIndirectList of labels.
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.
#define WarningInFunction
Report a warning using Foam::Warning.
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.
label whichPatch(const label faceIndex) const
Return patch index for a given mesh face index.
label start() const
Return start label of this patch in the polyMesh face list.
const polyBoundaryMesh & patches
void Swap(DynamicList< T, SizeMinA > &a, DynamicList< T, SizeMinB > &b)
const cellZoneMesh & cellZones() const noexcept
Return cell zone mesh.
HashTable< labelList, edge, Hash< edge > > edgeLookup
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.
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.
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.
List< cell > cellList
A List of cells.
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.
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)