63 label val = elems[elemI];
67 elems[elemI] = map[val];
71 label mergedVal = -val-2;
72 elems[elemI] = -map[mergedVal]-2;
88 label newElem = map[iter.key()];
111 label newVal = map[elems[elemI]];
115 elems[newElemI++] = newVal;
139 label oldCellI = map[newCellI];
143 if (reverseMap[oldCellI] == newCellI)
153 else if (oldCellI == -1)
165 forAll(reverseMap, oldCellI)
167 label newCellI = reverseMap[oldCellI];
173 else if (newCellI == -1)
212 patchSizes[patchI] =
patches[patchI].size();
213 patchStarts[patchI] =
patches[patchI].start();
216 os <<
" Points : " <<
mesh.nPoints() <<
nl
217 <<
" Faces : " <<
mesh.nFaces() <<
nl
218 <<
" Cells : " <<
mesh.nCells() <<
nl
219 <<
" PatchSizes : " << patchSizes <<
nl
220 <<
" PatchStarts : " << patchStarts <<
nl
235 forAll(reverseCellMap, oldCellI)
237 label newCellI = reverseCellMap[oldCellI];
241 label mergeCellI = -newCellI-2;
243 nMerged[mergeCellI]++;
254 if (nMerged[cellI] > 1)
256 cellToMergeSet[cellI] = nSets++;
268 forAll(reverseCellMap, oldCellI)
270 label newCellI = reverseCellMap[oldCellI];
274 label mergeCellI = -newCellI-2;
278 label setI = cellToMergeSet[mergeCellI];
280 objectMap& mergeSet = cellsFromCells[setI];
286 mergeSet.
index() = mergeCellI;
295 nMerged[mergeCellI] = 2;
310 if (
f[fp] < 0 ||
f[fp] >= points_.
size())
324 if (
f[fp] < 0 &&
f[fp] >= points_.
size())
347 if (own == -1 && zoneI != -1)
351 else if (patchI == -1 || patchI >= nPatches_)
354 <<
"Face has no neighbour (so external) but does not have"
355 <<
" a valid patch" <<
nl
357 <<
" faceI(-1 if added face):" << faceI
358 <<
" own:" << own <<
" nei:" << nei
359 <<
" patchI:" << patchI <<
nl;
360 if (hasValidPoints(
f))
363 <<
"points (removed points marked with "
374 <<
"Cannot both have valid patchI and neighbour" <<
nl
376 <<
" faceI(-1 if added face):" << faceI
377 <<
" own:" << own <<
" nei:" << nei
378 <<
" patchI:" << patchI <<
nl;
379 if (hasValidPoints(
f))
382 <<
"points (removed points marked with "
391 <<
"Owner cell label should be less than neighbour cell label"
394 <<
" faceI(-1 if added face):" << faceI
395 <<
" own:" << own <<
" nei:" << nei
396 <<
" patchI:" << patchI <<
nl;
397 if (hasValidPoints(
f))
400 <<
"points (removed points marked with "
410 <<
"Illegal vertices in face"
413 <<
" faceI(-1 if added face):" << faceI
414 <<
" own:" << own <<
" nei:" << nei
415 <<
" patchI:" << patchI <<
nl;
416 if (hasValidPoints(
f))
419 <<
"points (removed points marked with "
424 if (faceI >= 0 && faceI < faces_.size() && faceRemoved(faceI))
427 <<
"Face already marked for removal"
430 <<
" faceI(-1 if added face):" << faceI
431 <<
" own:" << own <<
" nei:" << nei
432 <<
" patchI:" << patchI <<
nl;
433 if (hasValidPoints(
f))
436 <<
"points (removed points marked with "
443 if (
f[fp] < points_.
size() && pointRemoved(
f[fp]))
446 <<
"Face uses removed vertices"
449 <<
" faceI(-1 if added face):" << faceI
450 <<
" own:" << own <<
" nei:" << nei
451 <<
" patchI:" << patchI <<
nl;
452 if (hasValidPoints(
f))
455 <<
"points (removed points marked with "
466 const label nActiveFaces,
471 cellFaces.
setSize(2*nActiveFaces);
472 cellFaceOffsets.
setSize(cellMap_.size() + 1);
479 for (
label faceI = 0; faceI < nActiveFaces; faceI++)
481 if (faceOwner_[faceI] < 0)
484 if (faceI < faces_.size())
486 const face&
f = faces_[faceI];
490 if (
f[fp] < points_.
size())
492 newPoints[fp] = points_[
f[fp]];
499 <<
"Face " << faceI <<
" is active but its owner has"
500 <<
" been deleted. This is usually due to deleting cells"
501 <<
" without modifying exposed faces to be boundary faces."
504 nNbrs[faceOwner_[faceI]]++;
506 for (
label faceI = 0; faceI < nActiveFaces; faceI++)
508 if (faceNeighbour_[faceI] >= 0)
510 nNbrs[faceNeighbour_[faceI]]++;
516 cellFaceOffsets[0] = 0;
519 cellFaceOffsets[cellI+1] = cellFaceOffsets[cellI] + nNbrs[cellI];
527 for (
label faceI = 0; faceI < nActiveFaces; faceI++)
529 label cellI = faceOwner_[faceI];
531 cellFaces[cellFaceOffsets[cellI] + nNbrs[cellI]++] = faceI;
534 for (
label faceI = 0; faceI < nActiveFaces; faceI++)
536 label cellI = faceNeighbour_[faceI];
540 cellFaces[cellFaceOffsets[cellI] + nNbrs[cellI]++] = faceI;
545 cellFaces.
setSize(cellFaceOffsets[cellMap_.size()]);
553 const label nActiveFaces,
562 for (
label faceI = 0; faceI < nActiveFaces; faceI++)
564 if (faceNeighbour_[faceI] >= 0)
566 nNbrs[faceOwner_[faceI]]++;
567 nNbrs[faceNeighbour_[faceI]]++;
580 for (
label faceI = 0; faceI < nActiveFaces; faceI++)
582 label nei = faceNeighbour_[faceI];
586 label own = faceOwner_[faceI];
587 cellCells.
m()[cellCells.
index(own, nNbrs[own]++)] = nei;
588 cellCells.
m()[cellCells.
index(nei, nNbrs[nei]++)] = own;
610 label cellInOrder = 0;
627 label currentCell = -1;
633 if (!cellRemoved(cellI) && !visited[cellI])
635 if (cellCellAddressing[cellI].size() < minWeight)
637 minWeight = cellCellAddressing[cellI].
size();
644 if (currentCell == -1)
654 nextCell.
append(currentCell);
661 while (nextCell.size())
665 if (!visited[currentCell])
667 visited[currentCell] = 1;
670 newOrder[cellInOrder] = currentCell;
674 const labelUList neighbours = cellCellAddressing[currentCell];
684 label nbr = neighbours[nI];
685 if (!cellRemoved(nbr) && !visited[nbr])
689 weights.
append(cellCellAddressing[nbr].size());
707 oldToNew =
invert(cellCellAddressing.
size(), newOrder);
718 const label nActiveFaces,
727 oldToNew.
setSize(faceOwner_.size());
738 label startOfCell = cellFaceOffsets[cellI];
739 label nFaces = cellFaceOffsets[cellI+1] - startOfCell;
745 for (
label i = 0; i < nFaces; i++)
747 label faceI = cellFaces[startOfCell + i];
749 label nbrCellI = faceNeighbour_[faceI];
751 if (faceI >= nActiveFaces)
756 else if (nbrCellI != -1)
759 if (nbrCellI == cellI)
761 nbrCellI = faceOwner_[faceI];
764 if (cellI < nbrCellI)
796 label index = order[i];
797 if (nbr[index] != -1)
799 oldToNew[cellFaces[startOfCell + index]] = newFaceI++;
806 patchStarts.
setSize(nPatches_);
813 patchStarts[0] = newFaceI;
815 for (
label faceI = 0; faceI < nActiveFaces; faceI++)
817 if (region_[faceI] >= 0)
819 patchSizes[region_[faceI]]++;
823 label faceI = patchStarts[0];
825 forAll(patchStarts, patchI)
827 patchStarts[patchI] = faceI;
828 faceI += patchSizes[patchI];
840 for (
label faceI = 0; faceI < nActiveFaces; faceI++)
842 if (region_[faceI] >= 0)
844 oldToNew[faceI] = workPatchStarts[region_[faceI]]++;
849 for (
label faceI = nActiveFaces; faceI < oldToNew.
size(); faceI++)
851 oldToNew[faceI] = faceI;
857 if (oldToNew[faceI] == -1)
860 <<
"Did not determine new position"
861 <<
" for face " << faceI
862 <<
" owner " << faceOwner_[faceI]
863 <<
" neighbour " << faceNeighbour_[faceI]
864 <<
" region " << region_[faceI] <<
endl
865 <<
"This is usually caused by not specifying a patch for"
866 <<
" a boundary face." <<
nl
867 <<
"Switch on the polyTopoChange::debug flag to catch"
868 <<
" this error earlier." <<
nl;
869 if (hasValidPoints(faces_[faceI]))
872 <<
"points (removed points marked with "
873 <<
vector::max <<
") " << facePoints(faces_[faceI]);
889 faces_.setCapacity(newSize);
892 region_.setCapacity(newSize);
895 faceOwner_.setCapacity(newSize);
897 reorder(oldToNew, faceNeighbour_);
898 faceNeighbour_.setCapacity(newSize);
902 faceMap_.setCapacity(newSize);
904 renumberReverseMap(oldToNew, reverseFaceMap_);
906 renumberKey(oldToNew, faceFromPoint_);
907 renumberKey(oldToNew, faceFromEdge_);
909 flipFaceFlux_.setCapacity(newSize);
910 renumberKey(oldToNew, faceZone_);
912 faceZoneFlip_.setCapacity(newSize);
922 const bool orderCells,
923 const bool orderPoints,
924 label& nInternalPoints,
931 reversePointMap_.shrink();
936 faceNeighbour_.shrink();
938 reverseFaceMap_.shrink();
941 reverseCellMap_.shrink();
946 label nActivePoints = 0;
948 labelList localPointMap(points_.size(), -1);
953 nInternalPoints = -1;
957 if (!pointRemoved(pointI) && !retiredPoints_.found(pointI))
959 localPointMap[pointI] = newPointI++;
962 nActivePoints = newPointI;
968 if (!pointRemoved(pointI) && !retiredPoints_.found(pointI))
980 && faceOwner_[faceI] >= 0
981 && faceNeighbour_[faceI] < 0
985 const face&
f = faces_[faceI];
991 if (localPointMap[pointI] == -1)
996 || retiredPoints_.found(pointI)
1000 <<
"Removed or retired point " << pointI
1002 <<
" at position " << faceI <<
endl
1003 <<
"Probably face has not been adapted for"
1006 localPointMap[pointI] = newPointI++;
1012 label nBoundaryPoints = newPointI;
1013 nInternalPoints = nActivePoints - nBoundaryPoints;
1016 forAll(localPointMap, pointI)
1018 if (localPointMap[pointI] != -1)
1020 localPointMap[pointI] += nInternalPoints;
1027 forAll(faceOwner_, faceI)
1032 && faceOwner_[faceI] >= 0
1033 && faceNeighbour_[faceI] >= 0
1037 const face&
f = faces_[faceI];
1043 if (localPointMap[pointI] == -1)
1047 pointRemoved(pointI)
1048 || retiredPoints_.found(pointI)
1052 <<
"Removed or retired point " << pointI
1054 <<
" at position " << faceI <<
endl
1055 <<
"Probably face has not been adapted for"
1058 localPointMap[pointI] = newPointI++;
1064 if (newPointI != nInternalPoints)
1069 newPointI = nActivePoints;
1074 localPointMap[iter.key()] = newPointI++;
1080 Pout<<
"Points : active:" << nActivePoints
1081 <<
" removed:" << points_.size()-newPointI <<
endl;
1084 reorder(localPointMap, points_);
1085 points_.setCapacity(newPointI);
1088 reorder(localPointMap, pointMap_);
1089 pointMap_.setCapacity(newPointI);
1090 renumberReverseMap(localPointMap, reversePointMap_);
1092 renumberKey(localPointMap, pointZone_);
1093 renumber(localPointMap, retiredPoints_);
1098 face&
f = faces_[faceI];
1101 renumberCompact(localPointMap,
f);
1103 if (!faceRemoved(faceI) &&
f.
size() < 3)
1106 <<
"Created illegal face " <<
f
1108 <<
" at position:" << faceI
1109 <<
" when filtering removed points"
1118 labelList localFaceMap(faces_.size(), -1);
1123 if (!faceRemoved(faceI) && faceOwner_[faceI] >= 0)
1125 localFaceMap[faceI] = newFaceI++;
1128 nActiveFaces_ = newFaceI;
1132 if (!faceRemoved(faceI) && faceOwner_[faceI] < 0)
1135 localFaceMap[faceI] = newFaceI++;
1141 Pout<<
"Faces : active:" << nActiveFaces_
1142 <<
" removed:" << faces_.size()-newFaceI <<
endl;
1146 reorderCompactFaces(newFaceI, localFaceMap);
1158 makeCellCells(nActiveFaces_, cellCells);
1161 newCellI = getCellOrder(cellCells, localCellMap);
1166 localCellMap.
setSize(cellMap_.size());
1172 if (!cellRemoved(cellI))
1174 localCellMap[cellI] = newCellI++;
1181 Pout<<
"Cells : active:" << newCellI
1182 <<
" removed:" << cellMap_.size()-newCellI <<
endl;
1186 if (orderCells || (newCellI != cellMap_.size()))
1188 reorder(localCellMap, cellMap_);
1189 cellMap_.setCapacity(newCellI);
1190 renumberReverseMap(localCellMap, reverseCellMap_);
1192 reorder(localCellMap, cellZone_);
1193 cellZone_.setCapacity(newCellI);
1195 renumberKey(localCellMap, cellFromPoint_);
1196 renumberKey(localCellMap, cellFromEdge_);
1197 renumberKey(localCellMap, cellFromFace_);
1201 forAll(faceOwner_, faceI)
1203 label own = faceOwner_[faceI];
1204 label nei = faceNeighbour_[faceI];
1209 faceOwner_[faceI] = localCellMap[own];
1214 faceNeighbour_[faceI] = localCellMap[nei];
1219 faceNeighbour_[faceI] >= 0
1220 && faceNeighbour_[faceI] < faceOwner_[faceI]
1223 faces_[faceI].flip();
1224 Swap(faceOwner_[faceI], faceNeighbour_[faceI]);
1225 flipFaceFlux_[faceI] =
1227 flipFaceFlux_[faceI]
1231 faceZoneFlip_[faceI] =
1233 faceZoneFlip_[faceI]
1243 faceNeighbour_[faceI] = localCellMap[nei];
1254 makeCells(nActiveFaces_, cellFaces, cellFaceOffsets);
1270 reorderCompactFaces(localFaceMap.
size(), localFaceMap);
1286 const bool internalFacesOnly
1293 label faceI = faceLabels[i];
1307 collectedFaces = faceLabels;
1311 collectedFaces.
setSize(nFaces);
1317 label faceI = faceLabels[i];
1321 collectedFaces[nFaces++] = faceI;
1326 return collectedFaces;
1345 const Map<label>& oldMeshPointMap = oldPatchMeshPointMaps[patchI];
1347 labelList& curPatchPointRnb = patchPointMap[patchI];
1353 if (meshPoints[i] < pointMap_.
size())
1358 pointMap_[meshPoints[i]]
1361 if (ozmpmIter != oldMeshPointMap.end())
1363 curPatchPointRnb[i] = ozmpmIter();
1367 curPatchPointRnb[i] = -1;
1372 curPatchPointRnb[i] = -1;
1390 facesFromPoints.
setSize(faceFromPoint_.size());
1392 if (faceFromPoint_.size())
1394 label nFacesFromPoints = 0;
1399 label newFaceI = iter.key();
1401 if (region_[newFaceI] == -1)
1404 facesFromPoints[nFacesFromPoints++] =
objectMap
1418 facesFromPoints[nFacesFromPoints++] =
objectMap
1436 facesFromEdges.
setSize(faceFromEdge_.size());
1438 if (faceFromEdge_.size())
1440 label nFacesFromEdges = 0;
1445 label newFaceI = iter.key();
1447 if (region_[newFaceI] == -1)
1450 facesFromEdges[nFacesFromEdges++] =
objectMap
1464 facesFromEdges[nFacesFromEdges++] =
objectMap
1500 cellsFromPoints.
setSize(cellFromPoint_.size());
1502 if (cellFromPoint_.size())
1504 label nCellsFromPoints = 0;
1509 cellsFromPoints[nCellsFromPoints++] =
objectMap
1518 cellsFromEdges.
setSize(cellFromEdge_.size());
1520 if (cellFromEdge_.size())
1522 label nCellsFromEdges = 0;
1527 cellsFromEdges[nCellsFromEdges++] =
objectMap
1536 cellsFromFaces.
setSize(cellFromFace_.size());
1538 if (cellFromFace_.size())
1540 label nCellsFromFaces = 0;
1547 label oldFaceI = iter();
1553 cellsFromFaces[nCellsFromFaces++] =
objectMap
1561 cellsFromFaces[nCellsFromFaces++] =
objectMap
1605 label zoneI = iter();
1607 if (zoneI < 0 || zoneI >= pointZones.size())
1610 <<
"Illegal zoneID " << zoneI <<
" for point "
1611 << iter.key() <<
" coord " <<
mesh.
points()[iter.key()]
1620 forAll(addressing, zoneI)
1628 label zoneI = iter();
1630 addressing[zoneI][
nPoints[zoneI]++] = iter.key();
1633 forAll(addressing, zoneI)
1640 forAll(addressing, zoneI)
1642 const pointZone& oldZone = pointZones[zoneI];
1643 const labelList& newZoneAddr = addressing[zoneI];
1645 labelList& curPzRnb = pointZoneMap[zoneI];
1650 if (newZoneAddr[i] < pointMap_.
size())
1652 curPzRnb[i] = oldZone.
whichPoint(pointMap_[newZoneAddr[i]]);
1667 Pout<<
"pointZone:" << zoneI
1668 <<
" name:" << newMesh.
pointZones()[zoneI].name()
1669 <<
" size:" << addressing[zoneI].
size()
1673 newMesh.
pointZones()[zoneI] = addressing[zoneI];
1689 label zoneI = iter();
1691 if (zoneI < 0 || zoneI >= faceZones.size())
1694 <<
"Illegal zoneID " << zoneI <<
" for face "
1704 forAll(addressing, zoneI)
1706 addressing[zoneI].
setSize(nFaces[zoneI]);
1707 flipMode[zoneI].
setSize(nFaces[zoneI]);
1713 label zoneI = iter();
1714 label faceI = iter.key();
1716 label index = nFaces[zoneI]++;
1718 addressing[zoneI][index] = faceI;
1719 flipMode[zoneI][index] = faceZoneFlip_[faceI];
1722 forAll(addressing, zoneI)
1727 labelList newAddressing(addressing[zoneI].size());
1730 newAddressing[i] = addressing[zoneI][newToOld[i]];
1732 addressing[zoneI].
transfer(newAddressing);
1735 boolList newFlipMode(flipMode[zoneI].size());
1738 newFlipMode[i] = flipMode[zoneI][newToOld[i]];
1740 flipMode[zoneI].
transfer(newFlipMode);
1746 forAll(addressing, zoneI)
1748 const faceZone& oldZone = faceZones[zoneI];
1749 const labelList& newZoneAddr = addressing[zoneI];
1751 labelList& curFzFaceRnb = faceZoneFaceMap[zoneI];
1757 if (newZoneAddr[i] < faceMap_.
size())
1760 oldZone.
whichFace(faceMap_[newZoneAddr[i]]);
1764 curFzFaceRnb[i] = -1;
1776 Pout<<
"faceZone:" << zoneI
1777 <<
" name:" << newMesh.
faceZones()[zoneI].name()
1778 <<
" size:" << addressing[zoneI].
size()
1782 newMesh.
faceZones()[zoneI].resetAddressing
1802 label zoneI = cellZone_[cellI];
1804 if (zoneI >= cellZones.size())
1807 <<
"Illegal zoneID " << zoneI <<
" for cell "
1818 forAll(addressing, zoneI)
1820 addressing[zoneI].
setSize(nCells[zoneI]);
1826 label zoneI = cellZone_[cellI];
1830 addressing[zoneI][nCells[zoneI]++] = cellI;
1834 forAll(addressing, zoneI)
1841 forAll(addressing, zoneI)
1843 const cellZone& oldZone = cellZones[zoneI];
1844 const labelList& newZoneAddr = addressing[zoneI];
1846 labelList& curCellRnb = cellZoneMap[zoneI];
1852 if (newZoneAddr[i] < cellMap_.
size())
1855 oldZone.
whichCell(cellMap_[newZoneAddr[i]]);
1870 Pout<<
"cellZone:" << zoneI
1871 <<
" name:" << newMesh.
cellZones()[zoneI].name()
1872 <<
" size:" << addressing[zoneI].
size()
1876 newMesh.
cellZones()[zoneI] = addressing[zoneI];
1891 faceZonePointMap.
setSize(faceZones.size());
1895 const faceZone& newZone = faceZones[zoneI];
1897 const labelList& newZoneMeshPoints = newZone().meshPoints();
1899 const Map<label>& oldZoneMeshPointMap = oldFaceZoneMeshPointMaps[zoneI];
1901 labelList& curFzPointRnb = faceZonePointMap[zoneI];
1905 forAll(newZoneMeshPoints, pointI)
1907 if (newZoneMeshPoints[pointI] < pointMap_.
size())
1910 oldZoneMeshPointMap.find
1912 pointMap_[newZoneMeshPoints[pointI]]
1915 if (ozmpmIter != oldZoneMeshPointMap.end())
1917 curFzPointRnb[pointI] = ozmpmIter();
1921 curFzPointRnb[pointI] = -1;
1926 curFzPointRnb[pointI] = -1;
1935 const bool syncParallel,
1954 if (syncParallel || !isA<processorPolyPatch>(
boundary[patchI]))
1980 bool anyChanged =
false;
1984 if (syncParallel || !isA<processorPolyPatch>(
boundary[patchI]))
1986 labelList patchFaceMap(patchSizes[patchI], -1);
1987 labelList patchFaceRotation(patchSizes[patchI], 0);
1989 bool changed =
boundary[patchI].order
2009 label start = patchStarts[patchI];
2011 forAll(patchFaceMap, patchFaceI)
2013 oldToNew[patchFaceI + start] =
2014 start + patchFaceMap[patchFaceI];
2017 forAll(patchFaceRotation, patchFaceI)
2019 rotation[patchFaceI + start] =
2020 patchFaceRotation[patchFaceI];
2036 reorderCompactFaces(oldToNew.
size(), oldToNew);
2041 if (rotation[faceI] != 0)
2043 inplaceRotateList<List, label>(faces_[faceI], rotation[faceI]);
2053 const bool syncParallel,
2054 const bool orderCells,
2055 const bool orderPoints,
2057 label& nInternalPoints,
2078 <<
"polyTopoChange was constructed with a mesh with "
2079 << nPatches_ <<
" patches." <<
endl
2080 <<
"The mesh now provided has a different number of patches "
2082 <<
" which is illegal" <<
endl
2088 compact(orderCells, orderPoints, nInternalPoints, patchSizes, patchStarts);
2092 newPoints.transfer(points_);
2124 calcFaceInflationMaps
2132 calcCellInflationMaps
2143 faceFromPoint_.clearStorage();
2144 faceFromEdge_.clearStorage();
2146 cellFromPoint_.clearStorage();
2147 cellFromEdge_.clearStorage();
2148 cellFromFace_.clearStorage();
2162 oldPatchMeshPointMaps[patchI] =
boundary[patchI].meshPointMap();
2163 oldPatchNMeshPoints[patchI] =
boundary[patchI].meshPoints().
size();
2164 oldPatchStarts[patchI] =
boundary[patchI].start();
2176 oldFaceZoneMeshPointMaps[zoneI] = oldZone().meshPointMap();
2190 reversePointMap_(0),
2225 reversePointMap_(0),
2262 points_.clearStorage();
2263 pointMap_.clearStorage();
2264 reversePointMap_.clearStorage();
2265 pointZone_.clearStorage();
2266 retiredPoints_.clearStorage();
2268 faces_.clearStorage();
2269 region_.clearStorage();
2270 faceOwner_.clearStorage();
2271 faceNeighbour_.clearStorage();
2272 faceMap_.clearStorage();
2273 reverseFaceMap_.clearStorage();
2274 faceFromPoint_.clearStorage();
2275 faceFromEdge_.clearStorage();
2276 flipFaceFlux_.clearStorage();
2277 faceZone_.clearStorage();
2278 faceZoneFlip_.clearStorage();
2281 cellMap_.clearStorage();
2282 reverseCellMap_.clearStorage();
2283 cellZone_.clearStorage();
2284 cellFromPoint_.clearStorage();
2285 cellFromEdge_.clearStorage();
2286 cellFromFace_.clearStorage();
2299 label maxRegion = nPatches_ - 1;
2302 maxRegion =
max(maxRegion, patchMap[i]);
2304 nPatches_ = maxRegion + 1;
2313 points_.setCapacity(points_.size() +
points.size());
2314 pointMap_.setCapacity(pointMap_.size() +
points.size());
2315 reversePointMap_.setCapacity(reversePointMap_.size() +
points.size());
2316 pointZone_.resize(pointZone_.size() +
points.size()/100);
2321 forAll(pointZones, zoneI)
2354 cellMap_.setCapacity(cellMap_.size() + nAllCells);
2355 reverseCellMap_.setCapacity(reverseCellMap_.size() + nAllCells);
2356 cellFromPoint_.resize(cellFromPoint_.size() + nAllCells/100);
2357 cellFromEdge_.resize(cellFromEdge_.size() + nAllCells/100);
2358 cellFromFace_.resize(cellFromFace_.size() + nAllCells/100);
2359 cellZone_.setCapacity(cellZone_.size() + nAllCells);
2367 const labelList& cellLabels = cellZones[zoneI];
2371 label cellI = cellLabels[j];
2373 if (newZoneID[cellI] != -1)
2378 <<
" is in two zones:"
2379 << cellZones[newZoneID[cellI]].name()
2380 <<
" and " << cellZones[zoneI].name() <<
endl
2381 <<
" This is not supported."
2382 <<
" Continuing with first zone only." <<
endl;
2386 newZoneID[cellI] = cellZoneMap[zoneI];
2392 for (
label cellI = 0; cellI < nAllCells; cellI++)
2395 addCell(-1, -1, -1, cellI, newZoneID[cellI]);
2410 faces_.setCapacity(faces_.size() + nAllFaces);
2411 region_.setCapacity(region_.size() + nAllFaces);
2412 faceOwner_.setCapacity(faceOwner_.size() + nAllFaces);
2413 faceNeighbour_.setCapacity(faceNeighbour_.size() + nAllFaces);
2414 faceMap_.setCapacity(faceMap_.size() + nAllFaces);
2415 reverseFaceMap_.setCapacity(reverseFaceMap_.size() + nAllFaces);
2416 faceFromPoint_.resize(faceFromPoint_.size() + nAllFaces/100);
2417 faceFromEdge_.resize(faceFromEdge_.size() + nAllFaces/100);
2418 flipFaceFlux_.setCapacity(faces_.size() + nAllFaces);
2419 faceZone_.resize(faceZone_.size() + nAllFaces/100);
2420 faceZoneFlip_.setCapacity(faces_.size() + nAllFaces);
2425 boolList zoneFlip(nAllFaces,
false);
2429 const labelList& faceLabels = faceZones[zoneI];
2430 const boolList& flipMap = faceZones[zoneI].flipMap();
2434 newZoneID[faceLabels[j]] = faceZoneMap[zoneI];
2435 zoneFlip[faceLabels[j]] = flipMap[j];
2448 faceNeighbour[faceI],
2464 if (pp.
start() != faces_.size())
2468 <<
"Patch " << pp.
name() <<
" starts at " << pp.
start()
2470 <<
"Current face counter at " << faces_.size() <<
endl
2471 <<
"Are patches in incremental order?"
2505 pointMap_.setCapacity(
nPoints);
2506 reversePointMap_.setCapacity(
nPoints);
2507 pointZone_.resize(pointZone_.size() +
nPoints/100);
2509 faces_.setCapacity(nFaces);
2510 region_.setCapacity(nFaces);
2511 faceOwner_.setCapacity(nFaces);
2512 faceNeighbour_.setCapacity(nFaces);
2513 faceMap_.setCapacity(nFaces);
2514 reverseFaceMap_.setCapacity(nFaces);
2515 faceFromPoint_.resize(faceFromPoint_.size() + nFaces/100);
2516 faceFromEdge_.resize(faceFromEdge_.size() + nFaces/100);
2517 flipFaceFlux_.setCapacity(nFaces);
2518 faceZone_.resize(faceZone_.size() + nFaces/100);
2519 faceZoneFlip_.setCapacity(nFaces);
2521 cellMap_.setCapacity(nCells);
2522 reverseCellMap_.setCapacity(nCells);
2523 cellFromPoint_.resize(cellFromPoint_.size() + nCells/100);
2524 cellFromEdge_.resize(cellFromEdge_.size() + nCells/100);
2525 cellFromFace_.resize(cellFromFace_.size() + nCells/100);
2526 cellZone_.setCapacity(nCells);
2532 if (isType<polyAddPoint>(action))
2534 const polyAddPoint& pap = refCast<const polyAddPoint>(action);
2544 else if (isType<polyModifyPoint>(action))
2558 else if (isType<polyRemovePoint>(action))
2566 else if (isType<polyAddFace>(action))
2568 const polyAddFace& paf = refCast<const polyAddFace>(action);
2584 else if (isType<polyModifyFace>(action))
2586 const polyModifyFace& pmf = refCast<const polyModifyFace>(action);
2602 else if (isType<polyRemoveFace>(action))
2604 const polyRemoveFace& prf = refCast<const polyRemoveFace>(action);
2610 else if (isType<polyAddCell>(action))
2612 const polyAddCell& pac = refCast<const polyAddCell>(action);
2623 else if (isType<polyModifyCell>(action))
2625 const polyModifyCell& pmc = refCast<const polyModifyCell>(action);
2629 modifyCell(pmc.
cellID(), -1);
2638 else if (isType<polyRemoveCell>(action))
2640 const polyRemoveCell& prc = refCast<const polyRemoveCell>(action);
2649 <<
"Unknown type of topoChange: " << action.type()
2661 const label masterPointID,
2666 label pointI = points_.size();
2669 pointMap_.append(masterPointID);
2670 reversePointMap_.append(pointI);
2674 pointZone_.insert(pointI, zoneID);
2679 retiredPoints_.insert(pointI);
2690 const label newZoneID,
2694 if (pointI < 0 || pointI >= points_.size())
2697 <<
"illegal point label " << pointI <<
endl
2698 <<
"Valid point labels are 0 .. " << points_.size()-1
2701 if (pointRemoved(pointI) || pointMap_[pointI] == -1)
2704 <<
"point " << pointI <<
" already marked for removal"
2707 points_[pointI] = pt;
2711 if (pointFnd != pointZone_.end())
2715 pointFnd() = newZoneID;
2719 pointZone_.erase(pointFnd);
2722 else if (newZoneID >= 0)
2724 pointZone_.insert(pointI, newZoneID);
2729 retiredPoints_.erase(pointI);
2733 retiredPoints_.insert(pointI);
2740 if (newPoints.size() != points_.size())
2743 <<
"illegal pointField size." <<
endl
2744 <<
"Size:" << newPoints.size() <<
endl
2745 <<
"Points in mesh:" << points_.size()
2751 points_[pointI] = newPoints[pointI];
2759 const label mergePointI
2762 if (pointI < 0 || pointI >= points_.size())
2765 <<
"illegal point label " << pointI <<
endl
2766 <<
"Valid point labels are 0 .. " << points_.size()-1
2773 && (pointRemoved(pointI) || pointMap_[pointI] == -1)
2777 <<
"point " << pointI <<
" already marked for removal" <<
nl
2778 <<
"Point:" << points_[pointI] <<
" pointMap:" << pointMap_[pointI]
2782 if (pointI == mergePointI)
2785 <<
"Cannot remove/merge point " << pointI <<
" onto itself."
2790 pointMap_[pointI] = -1;
2791 if (mergePointI >= 0)
2793 reversePointMap_[pointI] = -mergePointI-2;
2797 reversePointMap_[pointI] = -1;
2799 pointZone_.erase(pointI);
2800 retiredPoints_.erase(pointI);
2809 const label masterPointID,
2810 const label masterEdgeID,
2811 const label masterFaceID,
2812 const bool flipFaceFlux,
2813 const label patchID,
2821 checkFace(
f, -1, own, nei, patchID, zoneID);
2824 label faceI = faces_.size();
2827 region_.append(patchID);
2828 faceOwner_.append(own);
2829 faceNeighbour_.append(nei);
2831 if (masterPointID >= 0)
2833 faceMap_.append(-1);
2834 faceFromPoint_.insert(faceI, masterPointID);
2836 else if (masterEdgeID >= 0)
2838 faceMap_.append(-1);
2839 faceFromEdge_.insert(faceI, masterEdgeID);
2841 else if (masterFaceID >= 0)
2843 faceMap_.append(masterFaceID);
2852 faceMap_.append(-1);
2854 reverseFaceMap_.append(faceI);
2856 flipFaceFlux_[faceI] = (flipFaceFlux ? 1 : 0);
2860 faceZone_.insert(faceI, zoneID);
2862 faceZoneFlip_[faceI] = (zoneFlip ? 1 : 0);
2874 const bool flipFaceFlux,
2875 const label patchID,
2883 checkFace(
f, faceI, own, nei, patchID, zoneID);
2887 faceOwner_[faceI] = own;
2888 faceNeighbour_[faceI] = nei;
2889 region_[faceI] = patchID;
2891 flipFaceFlux_[faceI] = (flipFaceFlux ? 1 : 0);
2895 if (faceFnd != faceZone_.end())
2903 faceZone_.erase(faceFnd);
2906 else if (zoneID >= 0)
2908 faceZone_.insert(faceI, zoneID);
2910 faceZoneFlip_[faceI] = (zoneFlip ? 1 : 0);
2916 if (faceI < 0 || faceI >= faces_.size())
2919 <<
"illegal face label " << faceI <<
endl
2920 <<
"Valid face labels are 0 .. " << faces_.size()-1
2927 && (faceRemoved(faceI) || faceMap_[faceI] == -1)
2932 <<
" already marked for removal"
2936 faces_[faceI].setSize(0);
2937 region_[faceI] = -1;
2938 faceOwner_[faceI] = -1;
2939 faceNeighbour_[faceI] = -1;
2940 faceMap_[faceI] = -1;
2941 if (mergeFaceI >= 0)
2943 reverseFaceMap_[faceI] = -mergeFaceI-2;
2947 reverseFaceMap_[faceI] = -1;
2949 faceFromEdge_.erase(faceI);
2950 faceFromPoint_.erase(faceI);
2951 flipFaceFlux_[faceI] = 0;
2952 faceZone_.erase(faceI);
2953 faceZoneFlip_[faceI] = 0;
2959 const label masterPointID,
2960 const label masterEdgeID,
2961 const label masterFaceID,
2962 const label masterCellID,
2966 label cellI = cellMap_.size();
2968 if (masterPointID >= 0)
2970 cellMap_.append(-1);
2971 cellFromPoint_.insert(cellI, masterPointID);
2973 else if (masterEdgeID >= 0)
2975 cellMap_.append(-1);
2976 cellFromEdge_.insert(cellI, masterEdgeID);
2978 else if (masterFaceID >= 0)
2980 cellMap_.append(-1);
2981 cellFromFace_.insert(cellI, masterFaceID);
2985 cellMap_.append(masterCellID);
2987 reverseCellMap_.append(cellI);
2988 cellZone_.append(zoneID);
3000 cellZone_[cellI] = zoneID;
3006 if (cellI < 0 || cellI >= cellMap_.size())
3009 <<
"illegal cell label " << cellI <<
endl
3010 <<
"Valid cell labels are 0 .. " << cellMap_.size()-1
3014 if (strict_ && cellMap_[cellI] == -2)
3018 <<
" already marked for removal"
3022 cellMap_[cellI] = -2;
3023 if (mergeCellI >= 0)
3025 reverseCellMap_[cellI] = -mergeCellI-2;
3029 reverseCellMap_[cellI] = -1;
3031 cellFromPoint_.erase(cellI);
3032 cellFromEdge_.erase(cellI);
3033 cellFromFace_.erase(cellI);
3034 cellZone_[cellI] = -1;
3042 const bool syncParallel,
3043 const bool orderCells,
3044 const bool orderPoints
3049 Pout<<
"polyTopoChange::changeMesh"
3050 <<
"(polyMesh&, const bool, const bool, const bool, const bool)"
3056 Pout<<
"Old mesh:" <<
nl;
3063 label nInternalPoints;
3102 oldPatchMeshPointMaps,
3103 oldPatchNMeshPoints,
3105 oldFaceZoneMeshPointMaps
3123 pointField renumberedMeshPoints(newPoints.size());
3125 forAll(pointMap_, newPointI)
3127 label oldPointI = pointMap_[newPointI];
3131 renumberedMeshPoints[newPointI] =
mesh.
points()[oldPointI];
3144 faceNeighbour_.xfer(),
3162 faceNeighbour_.xfer(),
3172 retiredPoints_.clearStorage();
3173 region_.clearStorage();
3180 label nAdd, nInflate, nMerge, nRemove;
3181 countMap(pointMap_, reversePointMap_, nAdd, nInflate, nMerge, nRemove);
3183 <<
" added(from point):" << nAdd
3184 <<
" added(from nothing):" << nInflate
3185 <<
" merged(into other point):" << nMerge
3186 <<
" removed:" << nRemove
3189 countMap(faceMap_, reverseFaceMap_, nAdd, nInflate, nMerge, nRemove);
3191 <<
" added(from face):" << nAdd
3192 <<
" added(inflated):" << nInflate
3193 <<
" merged(into other face):" << nMerge
3194 <<
" removed:" << nRemove
3197 countMap(cellMap_, reverseCellMap_, nAdd, nInflate, nMerge, nRemove);
3199 <<
" added(from cell):" << nAdd
3200 <<
" added(inflated):" << nInflate
3201 <<
" merged(into other cell):" << nMerge
3202 <<
" removed:" << nRemove
3209 Pout<<
"New mesh:" <<
nl;
3224 resetZones(
mesh,
mesh, pointZoneMap, faceZoneFaceMap, cellZoneMap);
3228 pointZone_.clearStorage();
3229 faceZone_.clearStorage();
3230 faceZoneFlip_.clearStorage();
3231 cellZone_.clearStorage();
3241 oldPatchMeshPointMaps,
3248 calcFaceZonePointMap(
mesh, oldFaceZoneMeshPointMaps, faceZonePointMap);
3250 labelHashSet flipFaceFluxSet(getSetIndices(flipFaceFlux_));
3291 oldPatchNMeshPoints,
3309 const bool syncParallel,
3310 const bool orderCells,
3311 const bool orderPoints
3316 Pout<<
"polyTopoChange::changeMesh"
3317 <<
"(autoPtr<fvMesh>&, const IOobject&, const fvMesh&"
3318 <<
", const bool, const bool, const bool)"
3324 Pout<<
"Old mesh:" <<
nl;
3331 label nInternalPoints;
3371 oldPatchMeshPointMaps,
3372 oldPatchNMeshPoints,
3374 oldFaceZoneMeshPointMaps
3396 faceNeighbour_.xfer()
3399 fvMesh& newMesh = newMeshPtr();
3403 retiredPoints_.clearStorage();
3404 region_.clearStorage();
3411 label nAdd, nInflate, nMerge, nRemove;
3412 countMap(pointMap_, reversePointMap_, nAdd, nInflate, nMerge, nRemove);
3414 <<
" added(from point):" << nAdd
3415 <<
" added(from nothing):" << nInflate
3416 <<
" merged(into other point):" << nMerge
3417 <<
" removed:" << nRemove
3420 countMap(faceMap_, reverseFaceMap_, nAdd, nInflate, nMerge, nRemove);
3422 <<
" added(from face):" << nAdd
3423 <<
" added(inflated):" << nInflate
3424 <<
" merged(into other face):" << nMerge
3425 <<
" removed:" << nRemove
3428 countMap(cellMap_, reverseCellMap_, nAdd, nInflate, nMerge, nRemove);
3430 <<
" added(from cell):" << nAdd
3431 <<
" added(inflated):" << nInflate
3432 <<
" merged(into other cell):" << nMerge
3433 <<
" removed:" << nRemove
3444 forAll(oldPatches, patchI)
3446 newBoundary[patchI] = oldPatches[patchI].
clone
3469 oldPointZones[i].
name(),
3484 oldFaceZones[i].
name(),
3500 oldCellZones[i].
name(),
3508 newMesh.
addZones(pZonePtrs, fZonePtrs, cZonePtrs);
3517 resetZones(
mesh, newMesh, pointZoneMap, faceZoneFaceMap, cellZoneMap);
3521 pointZone_.clearStorage();
3522 faceZone_.clearStorage();
3523 faceZoneFlip_.clearStorage();
3524 cellZone_.clearStorage();
3533 oldPatchMeshPointMaps,
3540 calcFaceZonePointMap(newMesh, oldFaceZoneMeshPointMaps, faceZonePointMap);
3544 Pout<<
"New mesh:" <<
nl;
3548 labelHashSet flipFaceFluxSet(getSetIndices(flipFaceFlux_));
3589 oldPatchNMeshPoints,