51 const word& pType =
p.type();
52 const word& pName =
p.name();
59 allPatchNames.
append(pName);
60 allPatchTypes.
append(pType);
62 return allPatchNames.size() - 1;
64 else if (allPatchTypes[patchI] == pType)
75 const word& caseName =
p.boundaryMesh().mesh().time().caseName();
77 allPatchNames.
append(pName +
"_" + caseName);
78 allPatchTypes.
append(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.last() <<
endl;
87 return allPatchNames.size() - 1;
110 return names.size() - 1;
143 from1ToAllPatches[patchI] = patchIndex
154 fromAllTo1Patches.
setSize(allPatchNames.size());
155 fromAllTo1Patches = -1;
157 forAll(from1ToAllPatches, i)
159 fromAllTo1Patches[from1ToAllPatches[i]] = i;
172 patchStarts[patchI] =
patches[patchI].start();
186 patchSizes[patchI] =
patches[patchI].size();
197 const label nAllPatches,
200 const label nInternalFaces,
217 from0ToAllPatches = -1;
219 label startFaceI = nInternalFaces;
227 label filteredPatchI;
229 if (nFaces[patchI] == 0 && isA<processorPolyPatch>(patches0[patchI]))
237 filteredPatchI = allPatches.size();
241 patches0[patchI].clone
249 startFaceI += nFaces[patchI];
253 from0ToAllPatches[patchI] = filteredPatchI;
256 if (fromAllTo1Patches[patchI] != -1)
258 from1ToAllPatches[fromAllTo1Patches[patchI]] = filteredPatchI;
263 forAll(from1ToAllPatches, patchI)
265 label allPatchI = from1ToAllPatches[patchI];
267 if (allPatchI >= patches0.
size())
271 label filteredPatchI;
275 nFaces[allPatchI] == 0
276 && isA<processorPolyPatch>(patches1[patchI])
285 filteredPatchI = allPatches.size();
289 patches1[patchI].clone
297 startFaceI += nFaces[allPatchI];
300 from1ToAllPatches[patchI] = filteredPatchI;
313 const label nInternalFaces,
321 for (
label faceI = nInternalFaces; faceI < owner.
size(); ++faceI)
323 oldToNew[faceI] = faceI;
337 label faceI = cFaces[i];
339 label nbrCellI = neighbour[faceI];
344 if (nbrCellI == cellI)
346 nbrCellI = owner[faceI];
349 if (cellI < nbrCellI)
373 oldToNew[cFaces[nbr.
indices()[i]]] = newFaceI++;
382 if (oldToNew[faceI] == -1)
385 <<
"Did not determine new position"
386 <<
" for face " << faceI
415 label v0 = masterF[fp];
419 workFace.
append(allF[fp]);
424 if (v0Fnd != meshToMaster.end())
427 if (v1Fnd != meshToMaster.end())
432 masterToCutPoints[v0Fnd()],
433 masterToCutPoints[v1Fnd()]
436 edgeLookup::const_iterator iter = cutEdgeToPoints.
find(cutEdge);
438 if (iter != cutEdgeToPoints.end())
440 const edge&
e = iter.key();
444 if (
e[0] == cutEdge[0])
448 workFace.
append(addedPoints[i]);
455 workFace.
append(addedPoints[i]);
463 if (workFace.size() != allF.
size())
488 const label nAllPatches,
499 label& nInternalFaces,
524 from0ToAllPoints = -1;
526 from1ToAllPoints = -1;
560 const labelList& masterPoints = cutToMasterPoints[i];
565 from0ToAllPoints[mesh0PointI] = allPointI;
568 const labelList& slavePoints = cutToSlavePoints[i];
573 from1ToAllPoints[mesh1PointI] = allPointI;
582 if (from0ToAllPoints[pointI] == -1)
585 from0ToAllPoints[pointI] = allPointI;
593 if (from1ToAllPoints[pointI] == -1)
596 from1ToAllPoints[pointI] = allPointI;
608 nFacesPerPatch.
setSize(nAllPatches);
620 from0ToAllFaces = -1;
622 from1ToAllFaces = -1;
627 allFaces[allFaceI] =
renumber(from0ToAllPoints, mesh0.
faces()[faceI]);
628 allOwner[allFaceI] = mesh0.
faceOwner()[faceI];
630 from0ToAllFaces[faceI] = allFaceI++;
640 label masterFaceI = cutToMasterFaces[i];
642 label mesh0FaceI = masterPatch.addressing()[masterFaceI];
644 if (from0ToAllFaces[mesh0FaceI] == -1)
647 from0ToAllFaces[mesh0FaceI] = allFaceI;
651 nFacesPerPatch[patch0]--;
654 label slaveFaceI = cutToSlaveFaces[i];
656 label mesh1FaceI = slavePatch.addressing()[slaveFaceI];
658 if (from1ToAllFaces[mesh1FaceI] == -1)
660 from1ToAllFaces[mesh1FaceI] = allFaceI;
663 nFacesPerPatch[from1ToAllPatches[patch1]]--;
668 allFaces[allFaceI] = cutFaces[i];
669 allOwner[allFaceI] = mesh0.
faceOwner()[mesh0FaceI];
670 allNeighbour[allFaceI] = mesh1.
faceOwner()[mesh1FaceI] + mesh0.
nCells();
678 allFaces[allFaceI] =
renumber(from1ToAllPoints, mesh1.
faces()[faceI]);
681 from1ToAllFaces[faceI] = allFaceI++;
684 nInternalFaces = allFaceI;
687 for (
label allPatchI = 0; allPatchI < nAllPatches; allPatchI++)
689 if (allPatchI < patches0.
size())
692 const polyPatch& pp = patches0[allPatchI];
694 nFacesPerPatch[allPatchI] += pp.size();
700 if (from0ToAllFaces[faceI] == -1)
708 allOwner[allFaceI] = mesh0.
faceOwner()[faceI];
709 allNeighbour[allFaceI] = -1;
711 from0ToAllFaces[faceI] = allFaceI++;
716 if (fromAllTo1Patches[allPatchI] != -1)
719 const polyPatch& pp = patches1[fromAllTo1Patches[allPatchI]];
721 nFacesPerPatch[allPatchI] += pp.size();
727 if (from1ToAllFaces[faceI] == -1)
738 allNeighbour[allFaceI] = -1;
740 from1ToAllFaces[faceI] = allFaceI++;
748 allNeighbour.
setSize(allFaceI);
768 forAll(cutToMasterFaces, i)
770 label meshFaceI = masterPatch.addressing()[cutToMasterFaces[i]];
772 masterCutFaces.
insert(meshFaceI);
777 forAll(from0ToAllFaces, face0)
779 if (!masterCutFaces.
found(face0))
781 label allFaceI = from0ToAllFaces[face0];
788 mesh0.
faces()[face0],
799 forAll(cutToSlaveFaces, i)
801 label meshFaceI = slavePatch.addressing()[cutToSlaveFaces[i]];
803 slaveCutFaces.
insert(meshFaceI);
806 forAll(from1ToAllFaces, face1)
808 if (!slaveCutFaces.
found(face1))
810 label allFaceI = from1ToAllFaces[face1];
817 mesh1.
faces()[face1],
833 from1ToAllCells = -1;
837 from1ToAllCells[i] = i + mesh0.
nCells();
843 primitiveMesh::calcCells(allCells, allOwner, allNeighbour, nCells);
867 const label nAllPoints,
881 from1ToAll.
setSize(pz1.size());
885 from1ToAll[zoneI] = zoneIndex(pz1[zoneI].
name(), zoneNames);
905 label point0 = pz[i];
906 label allPointI = from0ToAllPoints[point0];
908 if (pointToZone[allPointI] == -1)
910 pointToZone[allPointI] = zoneI;
912 else if (pointToZone[allPointI] != zoneI)
927 const label allZoneI = from1ToAll[zoneI];
931 label point1 = pz[i];
932 label allPointI = from1ToAllPoints[point1];
934 if (pointToZone[allPointI] == -1)
936 pointToZone[allPointI] = allZoneI;
938 else if (pointToZone[allPointI] != allZoneI)
953 forAll(pointToZone, allPointI)
955 label zoneI = pointToZone[allPointI];
961 forAll(addPointToZones, allPointI)
971 pzPoints.setSize(zoneNames.size());
974 pzPoints[zoneI].setCapacity(
nPoints[zoneI]);
976 forAll(pointToZone, allPointI)
978 label zoneI = pointToZone[allPointI];
981 pzPoints[zoneI].
append(allPointI);
984 forAll(addPointToZones, allPointI)
989 pzPoints[
pZones[i]].append(allPointI);
994 pzPoints[i].shrink();
1027 from1ToAll.
setSize(fz1.size());
1031 from1ToAll[zoneI] = zoneIndex(fz1[zoneI].
name(), zoneNames);
1045 const labelList& addressing = fz0[zoneI];
1046 const boolList& flipMap = fz0[zoneI].flipMap();
1050 label face0 = addressing[i];
1051 bool flip0 = flipMap[i];
1053 label allFaceI = from0ToAllFaces[face0];
1057 label allCell0 = owner0[face0];
1058 if (allOwner[allFaceI] != allCell0)
1063 if (faceToZone[allFaceI] == -1)
1065 faceToZone[allFaceI] = zoneI;
1066 faceToFlip[allFaceI] = flip0;
1068 else if (faceToZone[allFaceI] != zoneI)
1070 labelList& fZones = addFaceToZones[allFaceI];
1071 boolList& flipZones = addFaceToFlips[allFaceI];
1086 const labelList& addressing = fz1[zoneI];
1087 const boolList& flipMap = fz1[zoneI].flipMap();
1089 const label allZoneI = from1ToAll[zoneI];
1093 label face1 = addressing[i];
1094 bool flip1 = flipMap[i];
1096 label allFaceI = from1ToAllFaces[face1];
1100 label allCell1 = from1ToAllCells[owner1[face1]];
1101 if (allOwner[allFaceI] != allCell1)
1106 if (faceToZone[allFaceI] == -1)
1108 faceToZone[allFaceI] = allZoneI;
1109 faceToFlip[allFaceI] = flip1;
1111 else if (faceToZone[allFaceI] != allZoneI)
1113 labelList& fZones = addFaceToZones[allFaceI];
1114 boolList& flipZones = addFaceToFlips[allFaceI];
1131 forAll(faceToZone, allFaceI)
1133 label zoneI = faceToZone[allFaceI];
1139 forAll(addFaceToZones, allFaceI)
1141 const labelList& fZones = addFaceToZones[allFaceI];
1144 nFaces[fZones[i]]++;
1149 fzFaces.
setSize(zoneNames.size());
1150 fzFlips.setSize(zoneNames.size());
1153 fzFaces[zoneI].setCapacity(nFaces[zoneI]);
1154 fzFlips[zoneI].setCapacity(nFaces[zoneI]);
1156 forAll(faceToZone, allFaceI)
1158 label zoneI = faceToZone[allFaceI];
1159 bool flip = faceToFlip[allFaceI];
1162 fzFaces[zoneI].
append(allFaceI);
1163 fzFlips[zoneI].append(flip);
1166 forAll(addFaceToZones, allFaceI)
1168 const labelList& fZones = addFaceToZones[allFaceI];
1169 const boolList& flipZones = addFaceToFlips[allFaceI];
1173 label zoneI = fZones[i];
1174 fzFaces[zoneI].
append(allFaceI);
1175 fzFlips[zoneI].append(flipZones[i]);
1181 fzFaces[i].shrink();
1182 fzFlips[i].shrink();
1194 const label nAllCells,
1208 from1ToAll.
setSize(cz1.size());
1211 from1ToAll[zoneI] = zoneIndex(cz1[zoneI].
name(), zoneNames);
1229 label cell0 = cz[i];
1231 if (cellToZone[cell0] == -1)
1233 cellToZone[cell0] = zoneI;
1235 else if (cellToZone[cell0] != zoneI)
1237 labelList& cZones = addCellToZones[cell0];
1250 const label allZoneI = from1ToAll[zoneI];
1253 label cell1 = cz[i];
1254 label allCellI = from1ToAllCells[cell1];
1256 if (cellToZone[allCellI] == -1)
1258 cellToZone[allCellI] = allZoneI;
1260 else if (cellToZone[allCellI] != allZoneI)
1262 labelList& cZones = addCellToZones[allCellI];
1275 forAll(cellToZone, allCellI)
1277 label zoneI = cellToZone[allCellI];
1283 forAll(addCellToZones, allCellI)
1285 const labelList& cZones = addCellToZones[allCellI];
1288 nCells[cZones[i]]++;
1293 czCells.
setSize(zoneNames.size());
1296 czCells[zoneI].setCapacity(nCells[zoneI]);
1298 forAll(cellToZone, allCellI)
1300 label zoneI = cellToZone[allCellI];
1303 czCells[zoneI].
append(allCellI);
1306 forAll(addCellToZones, allCellI)
1308 const labelList& cZones = addCellToZones[allCellI];
1311 czCells[cZones[i]].append(allCellI);
1316 czCells[i].shrink();
1324 const label nAllPoints,
1326 const label nAllCells,
1479 labelList fromAllTo1Patches(allPatchNames.size(), -1);
1501 label nInternalFaces;
1509 labelList nFaces(allPatchNames.size(), 0);
1524 allPatchNames.size(),
1599 allPatchNames.size(),
1637 getPatchSizes(patches0),
1638 getPatchStarts(patches0)
1677 mesh.addPatches(allPatches);
1689 const bool validBoundary
1700 labelList fromAllTo1Patches(allPatchNames.size(), -1);
1724 label nInternalFaces;
1726 labelList nFaces(allPatchNames.size(), 0);
1741 allPatchNames.size(),
1808 labelList mesh0PatchSizes(getPatchSizes(patches0));
1809 labelList mesh0PatchStarts(getPatchStarts(patches0));
1818 allPatches.
setSize(allPatchNames.size());
1822 label startFaceI = nInternalFaces;
1826 label allPatchI = 0;
1828 forAll(from0ToAllPatches, patch0)
1833 if (nFaces[patch0] == 0 && isA<processorPolyPatch>(allPatches[patch0]))
1837 from0ToAllPatches[patch0] = -1;
1839 if (fromAllTo1Patches[patch0] != -1)
1841 from1ToAllPatches[fromAllTo1Patches[patch0]] = -1;
1852 allPatches[patch0].clone
1860 patchSizes[allPatchI] = nFaces[patch0];
1861 patchStarts[allPatchI] = startFaceI;
1864 from0ToAllPatches[patch0] = allPatchI;
1867 if (fromAllTo1Patches[patch0] != -1)
1869 from1ToAllPatches[fromAllTo1Patches[patch0]] = allPatchI;
1872 startFaceI += nFaces[patch0];
1879 forAll(from1ToAllPatches, patch1)
1881 label uncompactAllPatchI = from1ToAllPatches[patch1];
1883 if (uncompactAllPatchI >= from0ToAllPatches.
size())
1889 nFaces[uncompactAllPatchI] == 0
1890 && isA<processorPolyPatch>(patches1[patch1])
1895 from1ToAllPatches[patch1] = -1;
1903 patches1[patch1].clone
1911 patchSizes[allPatchI] = nFaces[uncompactAllPatchI];
1912 patchStarts[allPatchI] = startFaceI;
1915 from1ToAllPatches[patch1] = allPatchI;
1917 startFaceI += nFaces[uncompactAllPatchI];
1924 allPatches.
setSize(allPatchI);
1925 patchSizes.
setSize(allPatchI);
1926 patchStarts.
setSize(allPatchI);
2002 const scalar mergeDist
2005 const labelList& sharedPointLabels =
mesh.globalData().sharedPointLabels();
2006 const labelList& sharedPointAddr =
mesh.globalData().sharedPointAddr();
2017 label nMultiple = 0;
2019 forAll(sharedPointLabels, i)
2021 label pointI = sharedPointLabels[i];
2023 label sharedI = sharedPointAddr[i];
2027 if (iter != sharedToMesh.end())
2033 labelList& connectedPointLabels = iter();
2038 if (
findIndex(connectedPointLabels, pointI) != -1)
2041 <<
"Duplicate point in sharedPoint addressing." <<
endl
2042 <<
"When trying to add point " << pointI <<
" on shared "
2043 << sharedI <<
" with connected points "
2044 << connectedPointLabels
2048 connectedPointLabels.
setSize(sz+1);
2049 connectedPointLabels[sz] = pointI;
2053 sharedToMesh.insert(sharedI,
labelList(1, pointI));
2065 const labelList& connectedPointLabels = iter();
2072 if (connectedPointLabels.
size() > 1)
2077 connectedPointLabels
2089 if (nUnique < connectedPoints.size())
2104 const labelList& mergeSet = mergeSets[setI];
2106 if (mergeSet.
size() > 1)
2113 label pointI = connectedPointLabels[mergeSet[i]];
2115 masterPointI =
min(masterPointI, pointI);
2120 label pointI = connectedPointLabels[mergeSet[i]];
2129 pointToMaster.insert(pointI, masterPointI);
2207 return pointToMaster;
2223 if (iter != pointToMaster.end())
2225 if (iter() != pointI)
2238 const face&
f = faces[faceI];
2240 bool hasMerged =
false;
2248 if (iter != pointToMaster.end())
2250 if (iter() != pointI)
2268 if (iter != pointToMaster.end())
2274 label patchID =
mesh.boundaryMesh().whichPatch(faceI);
2275 label nei = (patchID == -1 ?
mesh.faceNeighbour()[faceI] : -1);
2276 label zoneID =
mesh.faceZones().whichZone(faceI);
2277 bool zoneFlip =
false;
2291 mesh.faceOwner()[faceI],