57 void Foam::polyTopoChange::renumberReverseMap
60 DynamicList<label>& elems
65 const label val = elems[elemI];
69 elems[elemI] = oldToNew[val];
73 const label mergedVal = -val-2;
74 elems[elemI] = -oldToNew[mergedVal]-2;
80 void Foam::polyTopoChange::renumber
88 for (
const label val : labels)
90 const label newVal = oldToNew[val];
98 labels.transfer(newSet);
103 void Foam::polyTopoChange::renumberCompact
111 for (
const label val : elems)
113 const label newVal = oldToNew[val];
117 elems[nElem++] = newVal;
120 elems.setSize(nElem);
124 void Foam::polyTopoChange::countMap
141 const label oldCelli = map[newCelli];
147 oldCelli < reverseMap.size()
148 && reverseMap[oldCelli] == newCelli
159 else if (oldCelli == -1)
171 forAll(reverseMap, oldCelli)
173 const label newCelli = reverseMap[oldCelli];
179 else if (newCelli == -1)
193 void Foam::polyTopoChange::writeMeshStats(
const polyMesh&
mesh, Ostream&
os)
207 for (
const auto& cz : czs)
209 cellZoneSizes[cz.index()] = cz.
size();
213 for (
const auto& fz : fzs)
215 faceZoneSizes[fz.index()] = fz.
size();
219 for (
const auto& pz : pzs)
221 pointZoneSizes[pz.index()] = pz.
size();
236 void Foam::polyTopoChange::getMergeSets
240 List<objectMap>& cellsFromCells
246 forAll(reverseCellMap, oldCelli)
248 const label newCelli = reverseCellMap[oldCelli];
252 label mergeCelli = -newCelli-2;
254 nMerged[mergeCelli]++;
259 labelList cellToMergeSet(cellMap.size(), -1);
265 if (nMerged[celli] > 1)
267 cellToMergeSet[celli] = nSets++;
277 cellsFromCells.setSize(nSets);
279 forAll(reverseCellMap, oldCelli)
281 const label newCelli = reverseCellMap[oldCelli];
285 const label mergeCelli = -newCelli-2;
289 const label setI = cellToMergeSet[mergeCelli];
291 objectMap& mergeSet = cellsFromCells[setI];
293 if (mergeSet.masterObjects().empty())
297 mergeSet.index() = mergeCelli;
298 mergeSet.masterObjects().setSize(nMerged[mergeCelli]);
301 mergeSet.masterObjects()[0] = cellMap[mergeCelli];
304 mergeSet.masterObjects()[1] = oldCelli;
306 nMerged[mergeCelli] = 2;
310 mergeSet.masterObjects()[nMerged[mergeCelli]++] = oldCelli;
317 bool Foam::polyTopoChange::hasValidPoints(
const face&
f)
const 319 for (
const label fp :
f)
321 if (fp < 0 || fp >= points_.size())
335 if (
f[fp] < 0 &&
f[fp] >= points_.
size())
346 void Foam::polyTopoChange::checkFace
358 if (own == -1 && zoneI != -1)
362 else if (patchi == -1 || patchi >= nPatches_)
365 <<
"Face has no neighbour (so external) but does not have" 366 <<
" a valid patch" <<
nl 368 <<
" facei(-1 if added face):" << facei
369 <<
" own:" << own <<
" nei:" << nei
370 <<
" patchi:" << patchi <<
nl;
371 if (hasValidPoints(
f))
374 <<
"points (removed points marked with " 385 <<
"Cannot both have valid patchi and neighbour" <<
nl 387 <<
" facei(-1 if added face):" << facei
388 <<
" own:" << own <<
" nei:" << nei
389 <<
" patchi:" << patchi <<
nl;
390 if (hasValidPoints(
f))
393 <<
"points (removed points marked with " 402 <<
"Owner cell label should be less than neighbour cell label" 405 <<
" facei(-1 if added face):" << facei
406 <<
" own:" << own <<
" nei:" << nei
407 <<
" patchi:" << patchi <<
nl;
408 if (hasValidPoints(
f))
411 <<
"points (removed points marked with " 421 <<
"Illegal vertices in face" 424 <<
" facei(-1 if added face):" << facei
425 <<
" own:" << own <<
" nei:" << nei
426 <<
" patchi:" << patchi <<
nl;
427 if (hasValidPoints(
f))
430 <<
"points (removed points marked with " 435 if (facei >= 0 && facei < faces_.size() && faceRemoved(facei))
438 <<
"Face already marked for removal" 441 <<
" facei(-1 if added face):" << facei
442 <<
" own:" << own <<
" nei:" << nei
443 <<
" patchi:" << patchi <<
nl;
444 if (hasValidPoints(
f))
447 <<
"points (removed points marked with " 454 if (
f[fp] < points_.
size() && pointRemoved(
f[fp]))
457 <<
"Face uses removed vertices" 460 <<
" facei(-1 if added face):" << facei
461 <<
" own:" << own <<
" nei:" << nei
462 <<
" patchi:" << patchi <<
nl;
463 if (hasValidPoints(
f))
466 <<
"points (removed points marked with " 475 void Foam::polyTopoChange::makeCells
477 const label nActiveFaces,
482 cellFaces.setSize(2*nActiveFaces);
483 cellFaceOffsets.setSize(cellMap_.size() + 1);
490 for (label facei = 0; facei < nActiveFaces; facei++)
492 if (faceOwner_[facei] < 0)
495 if (facei < faces_.size())
497 const face&
f = faces_[facei];
501 if (
f[fp] < points_.
size())
503 newPoints[fp] = points_[
f[fp]];
510 <<
"Face " << facei <<
" is active but its owner has" 511 <<
" been deleted. This is usually due to deleting cells" 512 <<
" without modifying exposed faces to be boundary faces." 515 nNbrs[faceOwner_[facei]]++;
517 for (label facei = 0; facei < nActiveFaces; facei++)
519 if (faceNeighbour_[facei] >= 0)
521 nNbrs[faceNeighbour_[facei]]++;
527 cellFaceOffsets[0] = 0;
530 cellFaceOffsets[celli+1] = cellFaceOffsets[celli] + nNbrs[celli];
538 for (label facei = 0; facei < nActiveFaces; facei++)
540 label celli = faceOwner_[facei];
542 cellFaces[cellFaceOffsets[celli] + nNbrs[celli]++] = facei;
545 for (label facei = 0; facei < nActiveFaces; facei++)
547 label celli = faceNeighbour_[facei];
551 cellFaces[cellFaceOffsets[celli] + nNbrs[celli]++] = facei;
556 cellFaces.setSize(cellFaceOffsets[cellMap_.size()]);
562 void Foam::polyTopoChange::makeCellCells
564 const label nActiveFaces,
565 CompactListList<label>& cellCells
573 for (label facei = 0; facei < nActiveFaces; facei++)
575 if (faceNeighbour_[facei] >= 0)
577 nNbrs[faceOwner_[facei]]++;
578 nNbrs[faceNeighbour_[facei]]++;
591 for (label facei = 0; facei < nActiveFaces; facei++)
593 label nei = faceNeighbour_[facei];
597 label own = faceOwner_[facei];
598 cellCells(own, nNbrs[own]++) = nei;
599 cellCells(nei, nNbrs[nei]++) = own;
607 Foam::label Foam::polyTopoChange::getCellOrder
609 const CompactListList<label>& cellCellAddressing,
613 const label nOldCells(cellCellAddressing.size());
616 bitSet unvisited(nOldCells,
true);
619 for (label celli = 0; celli < nOldCells; ++celli)
621 if (cellRemoved(celli))
623 unvisited.unset(celli);
635 DynamicList<label> nbrCells;
638 DynamicList<label> nbrOrder;
641 DynamicList<label> weights;
644 CircularBuffer<label> queuedCells(1024);
647 label cellInOrder = 0;
652 label currCelli = -1;
655 for (
const label celli : unvisited)
657 const label nbrCount = cellCellAddressing[celli].size();
659 if (minCount > nbrCount)
674 queuedCells.push_back(currCelli);
681 while (!queuedCells.empty())
684 currCelli = queuedCells.front();
685 queuedCells.pop_front();
687 if (unvisited.test(currCelli))
690 unvisited.unset(currCelli);
693 newOrder[cellInOrder] = currCelli;
697 const auto& neighbours = cellCellAddressing[currCelli];
705 for (
const label nbr : neighbours)
707 const label nbrCount = cellCellAddressing[nbr].size();
709 if (unvisited.test(nbr))
712 nbrCells.push_back(nbr);
713 weights.push_back(nbrCount);
718 nbrOrder.resize_nocopy(weights.size());
724 for (
const label nbrIdx : nbrOrder)
726 queuedCells.push_back(nbrCells[nbrIdx]);
733 newOrder.resize(cellInOrder);
736 oldToNew =
invert(nOldCells, newOrder);
745 void Foam::polyTopoChange::getFaceOrder
747 const label nActiveFaces,
756 oldToNew.setSize(faceOwner_.size());
767 label startOfCell = cellFaceOffsets[celli];
768 label nFaces = cellFaceOffsets[celli+1] - startOfCell;
773 for (label i = 0; i < nFaces; i++)
775 label facei = cellFaces[startOfCell + i];
777 label nbrCelli = faceNeighbour_[facei];
779 if (facei >= nActiveFaces)
784 else if (nbrCelli != -1)
787 if (nbrCelli == celli)
789 nbrCelli = faceOwner_[facei];
792 if (celli < nbrCelli)
812 for (
const label index : order)
814 if (nbr[index] != -1)
816 oldToNew[cellFaces[startOfCell + index]] = newFacei++;
823 patchStarts.setSize(nPatches_);
825 patchSizes.setSize(nPatches_);
830 patchStarts[0] = newFacei;
832 for (label facei = 0; facei < nActiveFaces; facei++)
834 if (region_[facei] >= 0)
836 patchSizes[region_[facei]]++;
840 label facei = patchStarts[0];
842 forAll(patchStarts, patchi)
844 patchStarts[patchi] = facei;
845 facei += patchSizes[patchi];
857 for (label facei = 0; facei < nActiveFaces; facei++)
859 if (region_[facei] >= 0)
861 oldToNew[facei] = workPatchStarts[region_[facei]]++;
866 for (label facei = nActiveFaces; facei < oldToNew.size(); facei++)
868 oldToNew[facei] = facei;
874 if (oldToNew[facei] == -1)
877 <<
"Did not determine new position" 878 <<
" for face " << facei
879 <<
" owner " << faceOwner_[facei]
880 <<
" neighbour " << faceNeighbour_[facei]
881 <<
" region " << region_[facei] <<
endl 882 <<
"This is usually caused by not specifying a patch for" 883 <<
" a boundary face." <<
nl 884 <<
"Switch on the polyTopoChange::debug flag to catch" 885 <<
" this error earlier." <<
nl;
886 if (hasValidPoints(faces_[facei]))
889 <<
"points (removed points marked with " 890 <<
vector::max <<
") " << facePoints(faces_[facei]);
899 void Foam::polyTopoChange::reorderCompactFaces
906 faces_.setCapacity(newSize);
909 region_.setCapacity(newSize);
912 faceOwner_.setCapacity(newSize);
914 reorder(oldToNew, faceNeighbour_);
915 faceNeighbour_.setCapacity(newSize);
919 faceMap_.setCapacity(newSize);
921 renumberReverseMap(oldToNew, reverseFaceMap_);
923 renumberKey(oldToNew, faceFromPoint_);
924 renumberKey(oldToNew, faceFromEdge_);
926 flipFaceFlux_.setCapacity(newSize);
927 renumberKey(oldToNew, faceZone_);
929 faceZoneFlip_.setCapacity(newSize);
930 if (faceAdditionalZones_.size())
933 faceAdditionalZones_.setSize(newSize);
944 reversePointMap_.shrink();
945 pointAdditionalZones_.shrink();
950 faceNeighbour_.shrink();
952 reverseFaceMap_.shrink();
953 faceAdditionalZones_.shrink();
956 reverseCellMap_.shrink();
958 cellAdditionalZones_.shrink();
966 void Foam::polyTopoChange::compact
968 const bool orderCells,
969 const bool orderPoints,
970 label& nInternalPoints,
978 label nActivePoints = 0;
980 labelList localPointMap(points_.size(), -1);
985 nInternalPoints = -1;
989 if (!pointRemoved(pointi) && !retiredPoints_.found(pointi))
1000 if (!pointRemoved(pointi) && !retiredPoints_.found(pointi))
1007 forAll(faceOwner_, facei)
1012 && faceOwner_[facei] >= 0
1013 && faceNeighbour_[facei] < 0
1017 const face&
f = faces_[facei];
1021 label pointi =
f[fp];
1023 if (localPointMap[pointi] == -1)
1027 pointRemoved(pointi)
1028 || retiredPoints_.found(pointi)
1032 <<
"Removed or retired point " << pointi
1034 <<
" at position " << facei <<
endl 1035 <<
"Probably face has not been adapted for" 1045 nInternalPoints = nActivePoints - nBoundaryPoints;
1048 forAll(localPointMap, pointi)
1050 if (localPointMap[pointi] != -1)
1052 localPointMap[pointi] += nInternalPoints;
1059 forAll(faceOwner_, facei)
1064 && faceOwner_[facei] >= 0
1065 && faceNeighbour_[facei] >= 0
1069 const face&
f = faces_[facei];
1073 label pointi =
f[fp];
1075 if (localPointMap[pointi] == -1)
1079 pointRemoved(pointi)
1080 || retiredPoints_.found(pointi)
1084 <<
"Removed or retired point " << pointi
1086 <<
" at position " << facei <<
endl 1087 <<
"Probably face has not been adapted for" 1104 for (
const label pointi : retiredPoints_)
1112 Pout<<
"Points : active:" << nActivePoints
1116 reorder(localPointMap, points_);
1120 reorder(localPointMap, pointMap_);
1122 renumberReverseMap(localPointMap, reversePointMap_);
1124 renumberKey(localPointMap, pointZone_);
1125 renumber(localPointMap, retiredPoints_);
1126 if (pointAdditionalZones_.size())
1128 reorder(localPointMap, pointAdditionalZones_);
1134 face&
f = faces_[facei];
1137 renumberCompact(localPointMap,
f);
1139 if (!faceRemoved(facei) &&
f.
size() < 3)
1142 <<
"Created illegal face " <<
f 1144 <<
" at position:" << facei
1145 <<
" when filtering removed points" 1154 labelList localFaceMap(faces_.size(), -1);
1159 if (!faceRemoved(facei) && faceOwner_[facei] >= 0)
1161 localFaceMap[facei] = newFacei++;
1164 nActiveFaces_ = newFacei;
1168 if (!faceRemoved(facei) && faceOwner_[facei] < 0)
1171 localFaceMap[facei] = newFacei++;
1177 Pout<<
"Faces : active:" << nActiveFaces_
1178 <<
" removed:" << faces_.size()-newFacei <<
endl;
1182 reorderCompactFaces(newFacei, localFaceMap);
1193 CompactListList<label> cellCells;
1194 makeCellCells(nActiveFaces_, cellCells);
1197 newCelli = getCellOrder(cellCells, localCellMap);
1202 localCellMap.setSize(cellMap_.size());
1208 if (!cellRemoved(celli))
1210 localCellMap[celli] = newCelli++;
1217 Pout<<
"Cells : active:" << newCelli
1218 <<
" removed:" << cellMap_.size()-newCelli <<
endl;
1222 if (orderCells || (newCelli != cellMap_.size()))
1224 reorder(localCellMap, cellMap_);
1225 cellMap_.setCapacity(newCelli);
1226 renumberReverseMap(localCellMap, reverseCellMap_);
1228 reorder(localCellMap, cellZone_);
1229 cellZone_.setCapacity(newCelli);
1230 if (cellAdditionalZones_.size())
1232 reorder(localCellMap, cellAdditionalZones_);
1233 cellAdditionalZones_.setCapacity(newCelli);
1236 renumberKey(localCellMap, cellFromPoint_);
1237 renumberKey(localCellMap, cellFromEdge_);
1238 renumberKey(localCellMap, cellFromFace_);
1242 forAll(faceOwner_, facei)
1244 label own = faceOwner_[facei];
1245 label nei = faceNeighbour_[facei];
1250 faceOwner_[facei] = localCellMap[own];
1255 faceNeighbour_[facei] = localCellMap[nei];
1260 faceNeighbour_[facei] >= 0
1261 && faceNeighbour_[facei] < faceOwner_[facei]
1264 faces_[facei].flip();
1265 std::swap(faceOwner_[facei], faceNeighbour_[facei]);
1266 flipFaceFlux_.flip(facei);
1267 faceZoneFlip_.flip(facei);
1268 if (facei < faceAdditionalZones_.size())
1270 for (
auto& zas : faceAdditionalZones_[facei])
1282 faceNeighbour_[facei] = localCellMap[nei];
1293 makeCells(nActiveFaces_, cellFaces, cellFaceOffsets);
1309 reorderCompactFaces(localFaceMap.size(), localFaceMap);
1323 const primitiveMesh&
mesh,
1325 const bool internalFacesOnly
1350 collectedFaces.
setSize(nFaces);
1360 collectedFaces[nFaces++] = facei;
1365 return collectedFaces;
1371 void Foam::polyTopoChange::calcPatchPointMap
1373 const UList<Map<label>>& oldPatchMeshPointMaps,
1379 patchPointMap.setSize(patchMap.size());
1383 const label oldPatchi = patchMap[patchi];
1385 if (oldPatchi != -1)
1389 const Map<label>& oldMeshPointMap =
1390 oldPatchMeshPointMaps[oldPatchi];
1392 labelList& curPatchPointRnb = patchPointMap[patchi];
1394 curPatchPointRnb.
setSize(meshPoints.size());
1398 if (meshPoints[i] < pointMap_.size())
1401 curPatchPointRnb[i] = oldMeshPointMap.lookup
1403 pointMap_[meshPoints[i]],
1409 curPatchPointRnb[i] = -1;
1417 void Foam::polyTopoChange::calcFaceInflationMaps
1419 const polyMesh&
mesh,
1420 List<objectMap>& facesFromPoints,
1421 List<objectMap>& facesFromEdges,
1422 List<objectMap>& facesFromFaces
1428 facesFromPoints.setSize(faceFromPoint_.size());
1430 if (faceFromPoint_.size())
1432 label nFacesFromPoints = 0;
1437 const label facei = iter.key();
1438 const label pointi = iter.val();
1441 const bool internal = (region_[facei] == -1);
1443 facesFromPoints[nFacesFromPoints++] = objectMap
1460 facesFromEdges.setSize(faceFromEdge_.size());
1462 if (faceFromEdge_.size())
1464 label nFacesFromEdges = 0;
1469 const label facei = iter.key();
1470 const label edgei = iter.val();
1473 const bool internal = (region_[facei] == -1);
1475 facesFromEdges[nFacesFromEdges++] = objectMap
1501 void Foam::polyTopoChange::calcCellInflationMaps
1503 const polyMesh&
mesh,
1504 List<objectMap>& cellsFromPoints,
1505 List<objectMap>& cellsFromEdges,
1506 List<objectMap>& cellsFromFaces,
1507 List<objectMap>& cellsFromCells
1510 cellsFromPoints.setSize(cellFromPoint_.size());
1512 if (cellFromPoint_.size())
1514 label nCellsFromPoints = 0;
1519 const label celli = iter.key();
1520 const label pointi = iter.val();
1522 cellsFromPoints[nCellsFromPoints++] = objectMap
1531 cellsFromEdges.setSize(cellFromEdge_.size());
1533 if (cellFromEdge_.size())
1535 label nCellsFromEdges = 0;
1540 const label celli = iter.key();
1541 const label edgei = iter.val();
1543 cellsFromEdges[nCellsFromEdges++] = objectMap
1552 cellsFromFaces.setSize(cellFromFace_.size());
1554 if (cellFromFace_.size())
1556 label nCellsFromFaces = 0;
1563 const label celli = iter.key();
1564 const label oldFacei = iter.val();
1570 cellsFromFaces[nCellsFromFaces++] = objectMap
1578 cellsFromFaces[nCellsFromFaces++] = objectMap
1600 void Foam::polyTopoChange::resetZones
1602 const polyMesh&
mesh,
1622 const label pointi = iter.key();
1623 const label zonei = iter.val();
1625 if (zonei < 0 || zonei >= pointZones.size())
1628 <<
"Illegal zoneID " << zonei <<
" for point " 1629 << pointi <<
" coord " <<
mesh.
points()[pointi]
1634 forAll(pointAdditionalZones_, pointi)
1636 for (
const label zonei : pointAdditionalZones_[pointi])
1638 if (zonei < 0 || zonei >= pointZones.size())
1641 <<
"Illegal zoneID " << zonei <<
" for point " 1651 forAll(addressing, zonei)
1653 addressing[zonei].setSize(
nPoints[zonei]);
1659 const label pointi = iter.key();
1660 const label zonei = iter.val();
1662 addressing[zonei][
nPoints[zonei]++] = pointi;
1664 forAll(pointAdditionalZones_, pointi)
1666 for (
const label zonei : pointAdditionalZones_[pointi])
1668 addressing[zonei][
nPoints[zonei]++] = pointi;
1672 forAll(addressing, zonei)
1679 forAll(addressing, zonei)
1681 const pointZone& oldZone = pointZones[zonei];
1682 const labelList& newZoneAddr = addressing[zonei];
1684 labelList& curPzRnb = pointZoneMap[zonei];
1685 curPzRnb.
setSize(newZoneAddr.size());
1689 if (newZoneAddr[i] < pointMap_.size())
1691 curPzRnb[i] = oldZone.whichPoint(pointMap_[newZoneAddr[i]]);
1701 newMesh.pointZones().clearAddressing();
1702 forAll(newMesh.pointZones(), zonei)
1706 Pout<<
"pointZone:" << zonei
1707 <<
" name:" << newMesh.pointZones()[zonei].
name()
1708 <<
" size:" << addressing[zonei].size()
1712 newMesh.pointZones()[zonei] = addressing[zonei];
1728 const label facei = iter.key();
1729 const label zonei = iter.val();
1731 if (zonei < 0 || zonei >= faceZones.size())
1734 <<
"Illegal zoneID " << zonei <<
" for face " 1740 forAll(faceAdditionalZones_, facei)
1742 for (
const label zoneAndSign : faceAdditionalZones_[facei])
1744 const label zonei =
mag(zoneAndSign)-1;
1745 if (zonei < 0 || zonei >= faceZones.size())
1748 <<
"Illegal zoneID " << zonei <<
" for face " 1758 forAll(addressing, zonei)
1760 addressing[zonei].setSize(nFaces[zonei]);
1761 flipMode[zonei].setSize(nFaces[zonei]);
1767 const label facei = iter.key();
1768 const label zonei = iter.val();
1770 const label index = nFaces[zonei]++;
1771 addressing[zonei][index] = facei;
1772 flipMode[zonei][index] = faceZoneFlip_.test(facei);
1774 if (facei < faceAdditionalZones_.size())
1776 for (
const label zoneAndSign : faceAdditionalZones_[facei])
1778 const label zonei =
mag(zoneAndSign)-1;
1779 const bool flip = (zoneAndSign > 0);
1781 const label index = nFaces[zonei]++;
1782 addressing[zonei][index] = facei;
1783 flipMode[zonei][index] = flip;
1789 forAll(addressing, zonei)
1793 labelList newAddressing(addressing[zonei].size());
1796 newAddressing[i] = addressing[zonei][newToOld[i]];
1798 addressing[zonei].transfer(newAddressing);
1801 boolList newFlipMode(flipMode[zonei].size());
1804 newFlipMode[i] = flipMode[zonei][newToOld[i]];
1806 flipMode[zonei].transfer(newFlipMode);
1812 forAll(addressing, zonei)
1814 const faceZone& oldZone = faceZones[zonei];
1815 const labelList& newZoneAddr = addressing[zonei];
1817 labelList& curFzFaceRnb = faceZoneFaceMap[zonei];
1819 curFzFaceRnb.
setSize(newZoneAddr.size());
1823 if (newZoneAddr[i] < faceMap_.size())
1826 oldZone.whichFace(faceMap_[newZoneAddr[i]]);
1830 curFzFaceRnb[i] = -1;
1837 newMesh.faceZones().clearAddressing();
1838 forAll(newMesh.faceZones(), zonei)
1842 Pout<<
"faceZone:" << zonei
1843 <<
" name:" << newMesh.faceZones()[zonei].
name()
1844 <<
" size:" << addressing[zonei].size()
1848 newMesh.faceZones()[zonei].resetAddressing
1868 const label zonei = cellZone_[celli];
1870 if (zonei >= cellZones.size())
1873 <<
"Illegal zoneID " << zonei <<
" for cell " 1882 forAll(cellAdditionalZones_, celli)
1884 for (
const label zonei : cellAdditionalZones_[celli])
1886 if (zonei < 0 || zonei >= cellZones.size())
1889 <<
"Illegal zoneID " << zonei <<
" for cell " 1898 forAll(addressing, zonei)
1900 addressing[zonei].setSize(nCells[zonei]);
1906 const label zonei = cellZone_[celli];
1910 addressing[zonei][nCells[zonei]++] = celli;
1913 forAll(cellAdditionalZones_, celli)
1915 for (
const label zonei : cellAdditionalZones_[celli])
1917 addressing[zonei][nCells[zonei]++] = celli;
1921 forAll(addressing, zonei)
1928 forAll(addressing, zonei)
1930 const cellZone& oldZone = cellZones[zonei];
1931 const labelList& newZoneAddr = addressing[zonei];
1933 labelList& curCellRnb = cellZoneMap[zonei];
1935 curCellRnb.
setSize(newZoneAddr.size());
1939 if (newZoneAddr[i] < cellMap_.size())
1942 oldZone.whichCell(cellMap_[newZoneAddr[i]]);
1952 newMesh.cellZones().clearAddressing();
1953 forAll(newMesh.cellZones(), zonei)
1957 Pout<<
"cellZone:" << zonei
1958 <<
" name:" << newMesh.cellZones()[zonei].
name()
1959 <<
" size:" << addressing[zonei].size()
1963 newMesh.cellZones()[zonei] = addressing[zonei];
1969 void Foam::polyTopoChange::calcFaceZonePointMap
1971 const polyMesh&
mesh,
1972 const UList<Map<label>>& oldFaceZoneMeshPointMaps,
1978 faceZonePointMap.
setSize(faceZones.size());
1982 const faceZone& newZone = faceZones[zonei];
1984 const labelList& newZoneMeshPoints = newZone.patch().meshPoints();
1986 const Map<label>& oldZoneMeshPointMap = oldFaceZoneMeshPointMaps[zonei];
1988 labelList& curFzPointRnb = faceZonePointMap[zonei];
1990 curFzPointRnb.
setSize(newZoneMeshPoints.size());
1992 forAll(newZoneMeshPoints, pointi)
1994 if (newZoneMeshPoints[pointi] < pointMap_.size())
1996 curFzPointRnb[pointi] =
1997 oldZoneMeshPointMap.lookup
1999 pointMap_[newZoneMeshPoints[pointi]],
2005 curFzPointRnb[pointi] = -1;
2012 void Foam::polyTopoChange::reorderCoupledFaces
2014 const bool syncParallel,
2015 const polyBoundaryMesh& oldBoundary,
2029 PstreamBuffers pBufs;
2034 const label oldPatchi = patchMap[patchi];
2039 && (syncParallel || !isA<processorPolyPatch>(oldBoundary[oldPatchi]))
2042 oldBoundary[oldPatchi].initOrder
2061 pBufs.finishedSends();
2066 bool anyChanged =
false;
2070 const label oldPatchi = patchMap[patchi];
2075 && (syncParallel || !isA<processorPolyPatch>(oldBoundary[oldPatchi]))
2078 labelList patchFaceMap(patchSizes[patchi], -1);
2081 const bool changed = oldBoundary[oldPatchi].order
2101 const label start = patchStarts[patchi];
2103 forAll(patchFaceMap, patchFacei)
2105 oldToNew[patchFacei + start] =
2106 start + patchFaceMap[patchFacei];
2109 forAll(patchFaceRotation, patchFacei)
2111 rotation[patchFacei + start] =
2112 patchFaceRotation[patchFacei];
2123 reorderCompactFaces(oldToNew.size(), oldToNew);
2128 if (rotation[facei] != 0)
2130 inplaceRotateList<List, label>(faces_[facei], rotation[facei]);
2137 void Foam::polyTopoChange::compactAndReorder
2139 const polyMesh&
mesh,
2141 const bool syncParallel,
2142 const bool orderCells,
2143 const bool orderPoints,
2145 label& nInternalPoints,
2149 List<objectMap>& pointsFromPoints,
2150 List<objectMap>& facesFromPoints,
2151 List<objectMap>& facesFromEdges,
2152 List<objectMap>& facesFromFaces,
2153 List<objectMap>& cellsFromPoints,
2154 List<objectMap>& cellsFromEdges,
2155 List<objectMap>& cellsFromFaces,
2156 List<objectMap>& cellsFromCells,
2157 List<Map<label>>& oldPatchMeshPointMaps,
2160 List<Map<label>>& oldFaceZoneMeshPointMaps
2163 if (patchMap.size() != nPatches_)
2166 <<
"polyTopoChange was constructed with a mesh with " 2167 << nPatches_ <<
" patches." <<
endl 2168 <<
"The mesh now provided has a different number of patches " 2170 <<
" which is illegal" <<
endl 2176 compact(orderCells, orderPoints, nInternalPoints, patchSizes, patchStarts);
2180 newPoints.transfer(points_);
2213 calcFaceInflationMaps
2221 calcCellInflationMaps
2232 faceFromPoint_.clearStorage();
2233 faceFromEdge_.clearStorage();
2235 cellFromPoint_.clearStorage();
2236 cellFromEdge_.clearStorage();
2237 cellFromFace_.clearStorage();
2251 oldPatchMeshPointMaps[patchi] =
boundary[patchi].meshPointMap();
2252 oldPatchNMeshPoints[patchi] =
boundary[patchi].meshPoints().
size();
2253 oldPatchStarts[patchi] =
boundary[patchi].start();
2265 oldFaceZoneMeshPointMaps[zonei] = oldZone.patch().meshPointMap();
2279 reversePointMap_(0),
2314 reversePointMap_(0),
2351 points_.clearStorage();
2352 pointMap_.clearStorage();
2353 reversePointMap_.clearStorage();
2354 pointZone_.clearStorage();
2355 pointAdditionalZones_.clearStorage();
2356 retiredPoints_.clearStorage();
2358 faces_.clearStorage();
2359 region_.clearStorage();
2360 faceOwner_.clearStorage();
2361 faceNeighbour_.clearStorage();
2362 faceMap_.clearStorage();
2363 reverseFaceMap_.clearStorage();
2364 faceFromPoint_.clearStorage();
2365 faceFromEdge_.clearStorage();
2366 flipFaceFlux_.clearStorage();
2367 faceZone_.clearStorage();
2368 faceZoneFlip_.clearStorage();
2369 faceAdditionalZones_.clearStorage();
2372 cellMap_.clearStorage();
2373 reverseCellMap_.clearStorage();
2374 cellZone_.clearStorage();
2375 cellAdditionalZones_.clearStorage();
2376 cellFromPoint_.clearStorage();
2377 cellFromEdge_.clearStorage();
2378 cellFromFace_.clearStorage();
2391 label maxRegion = nPatches_ - 1;
2392 for (
const label regioni : patchMap)
2394 maxRegion =
max(maxRegion, regioni);
2396 nPatches_ = maxRegion + 1;
2405 points_.setCapacity(points_.size() +
points.
size());
2406 pointMap_.setCapacity(pointMap_.size() +
points.
size());
2407 reversePointMap_.setCapacity(reversePointMap_.size() +
points.
size());
2412 forAll(newPointID, pointi)
2415 newPointID[pointi] = addPoint
2426 forAll(pointZones, zonei)
2428 for (
const label pointi : pointZones[zonei])
2431 this->pointZones(newPointID[pointi], zones);
2432 for (
auto& zonei : zones)
2434 zonei = pointZoneMap[zonei];
2437 zones.append(pointZoneMap[zonei]);
2441 points_[newPointID[pointi]],
2459 cellMap_.setCapacity(cellMap_.size() + nAllCells);
2460 reverseCellMap_.setCapacity(reverseCellMap_.size() + nAllCells);
2461 cellFromPoint_.resize(cellFromPoint_.size() + nAllCells/128);
2462 cellFromEdge_.resize(cellFromEdge_.size() + nAllCells/128);
2463 cellFromFace_.resize(cellFromFace_.size() + nAllCells/128);
2464 cellZone_.setCapacity(cellZone_.size() + nAllCells);
2469 for (label celli = 0; celli < nAllCells; celli++)
2472 newCellID[celli] = addCell(-1, -1, -1, celli, -1);
2479 for (
const label celli : cellZones[zonei])
2482 this->cellZones(newCellID[celli], zones);
2483 for (
auto& zonei : zones)
2485 zonei = cellZoneMap[zonei];
2488 zones.append(cellZoneMap[zonei]);
2489 modifyCell(newCellID[celli], zones);
2505 faces_.setCapacity(faces_.size() + nAllFaces);
2506 region_.setCapacity(region_.size() + nAllFaces);
2507 faceOwner_.setCapacity(faceOwner_.size() + nAllFaces);
2508 faceNeighbour_.setCapacity(faceNeighbour_.size() + nAllFaces);
2509 faceMap_.setCapacity(faceMap_.size() + nAllFaces);
2510 reverseFaceMap_.setCapacity(reverseFaceMap_.size() + nAllFaces);
2511 faceFromPoint_.resize(faceFromPoint_.size() + nAllFaces/128);
2512 faceFromEdge_.resize(faceFromEdge_.size() + nAllFaces/128);
2513 flipFaceFlux_.setCapacity(faces_.size() + nAllFaces);
2514 faceZone_.resize(faceZone_.size() + nAllFaces/128);
2515 faceZoneFlip_.setCapacity(faceMap_.capacity());
2524 newFaceID[facei] = addFace
2528 faceNeighbour[facei],
2544 if (
pp.start() != faces_.size())
2548 <<
"Patch " <<
pp.name() <<
" starts at " <<
pp.start()
2550 <<
"Current face counter at " << faces_.size() <<
endl 2551 <<
"Are patches in incremental order?" 2556 const label facei =
pp.start() + patchFacei;
2558 newFaceID[facei] = addFace
2581 const auto& fz = faceZones[zonei];
2585 const label facei = fz[i];
2586 const bool flip = fz.flipMap()[i];
2589 const label newFacei = newFaceID[facei];
2592 this->faceZones(newFacei, zones, flips);
2593 for (
auto& zonei : zones)
2595 zonei = faceZoneMap[zonei];
2598 zones.append(faceZoneMap[zonei]);
2605 faceOwner_[newFacei],
2606 faceNeighbour_[newFacei],
2607 flipFaceFlux_(newFacei),
2626 pointMap_.setCapacity(
nPoints);
2627 reversePointMap_.setCapacity(
nPoints);
2628 pointZone_.resize(pointZone_.size() +
nPoints/128);
2630 faces_.setCapacity(nFaces);
2631 region_.setCapacity(nFaces);
2632 faceOwner_.setCapacity(nFaces);
2633 faceNeighbour_.setCapacity(nFaces);
2634 faceMap_.setCapacity(nFaces);
2635 reverseFaceMap_.setCapacity(nFaces);
2636 faceFromPoint_.resize(faceFromPoint_.size() + nFaces/128);
2637 faceFromEdge_.resize(faceFromEdge_.size() + nFaces/128);
2638 flipFaceFlux_.setCapacity(nFaces);
2639 faceZone_.resize(faceZone_.size() + nFaces/128);
2640 faceZoneFlip_.setCapacity(nFaces);
2642 cellMap_.setCapacity(nCells);
2643 reverseCellMap_.setCapacity(nCells);
2644 cellFromPoint_.resize(cellFromPoint_.size() + nCells/128);
2645 cellFromEdge_.resize(cellFromEdge_.size() + nCells/128);
2646 cellFromFace_.resize(cellFromFace_.size() + nCells/128);
2647 cellZone_.setCapacity(nCells);
2653 if (isType<polyAddPoint>(action))
2655 const polyAddPoint& pap = refCast<const polyAddPoint>(action);
2665 else if (isType<polyModifyPoint>(action))
2679 else if (isType<polyRemovePoint>(action))
2687 else if (isType<polyAddFace>(action))
2689 const polyAddFace& paf = refCast<const polyAddFace>(action);
2705 else if (isType<polyModifyFace>(action))
2707 const polyModifyFace& pmf = refCast<const polyModifyFace>(action);
2723 else if (isType<polyRemoveFace>(action))
2725 const polyRemoveFace& prf = refCast<const polyRemoveFace>(action);
2731 else if (isType<polyAddCell>(action))
2733 const polyAddCell& pac = refCast<const polyAddCell>(action);
2744 else if (isType<polyModifyCell>(action))
2746 const polyModifyCell& pmc = refCast<const polyModifyCell>(action);
2750 modifyCell(pmc.
cellID(), -1);
2759 else if (isType<polyRemoveCell>(action))
2761 const polyRemoveCell& prc = refCast<const polyRemoveCell>(action);
2770 <<
"Unknown type of topoChange: " << action.type()
2782 const label masterPointID,
2787 const label pointi = points_.size();
2790 pointMap_.append(masterPointID);
2791 reversePointMap_.append(pointi);
2795 pointZone_.insert(pointi, zoneID);
2801 retiredPoints_.insert(pointi);
2811 const label masterPointID,
2816 const label pointi = points_.size();
2819 pointMap_.append(masterPointID);
2820 reversePointMap_.append(pointi);
2826 pointZone_.set(pointi,
zoneIDs[minIndex]);
2829 if (pointi < pointAdditionalZones_.size())
2831 pointAdditionalZones_[pointi].clear();
2844 pointAdditionalZones_(pointi).push_uniq(
zoneIDs[i]);
2851 retiredPoints_.insert(pointi);
2864 const bool multiZone
2867 if (pointi < 0 || pointi >= points_.size())
2870 <<
"illegal point label " << pointi <<
endl 2871 <<
"Valid point labels are 0 .. " << points_.size()-1
2874 if (pointRemoved(pointi) || pointMap_[pointi] == -1)
2877 <<
"point " << pointi <<
" already marked for removal" 2880 points_[pointi] = pt;
2886 pointZone_.set(pointi, zoneID);
2890 pointZone_.erase(pointi);
2892 if (pointi < pointAdditionalZones_.size())
2894 pointAdditionalZones_[pointi].clear();
2899 auto fnd = pointZone_.find(pointi);
2902 pointZone_.set(pointi, zoneID);
2905 if (pointAdditionalZones_(pointi).size())
2908 <<
"Additional zones for point:" 2909 << pointAdditionalZones_(pointi)
2913 else if (zoneID == -1)
2916 pointZone_.erase(fnd);
2917 if (pointi < pointAdditionalZones_.size())
2919 pointAdditionalZones_[pointi].clear();
2922 else if (zoneID != fnd())
2925 pointAdditionalZones_(pointi).push_uniq(zoneID);
2931 retiredPoints_.erase(pointi);
2935 retiredPoints_.insert(pointi);
2948 if (pointi < 0 || pointi >= points_.size())
2951 <<
"illegal point label " << pointi <<
endl 2952 <<
"Valid point labels are 0 .. " << points_.size()-1
2955 if (pointRemoved(pointi) || pointMap_[pointi] == -1)
2958 <<
"point " << pointi <<
" already marked for removal" 2961 points_[pointi] = pt;
2969 <<
" for point:" << pointi
2973 pointZone_.set(pointi,
zoneIDs[0]);
2974 if (pointi < pointAdditionalZones_.size())
2976 pointAdditionalZones_[pointi].clear();
2980 pointAdditionalZones_(pointi).push_uniq(
zoneIDs[i]);
2985 pointZone_.erase(pointi);
2986 if (pointi < pointAdditionalZones_.size())
2988 pointAdditionalZones_[pointi].clear();
2994 retiredPoints_.erase(pointi);
2998 retiredPoints_.insert(pointi);
3004 if (newPoints.
size() != points_.size())
3007 <<
"illegal pointField size." <<
endl 3008 <<
"Size:" << newPoints.
size() <<
endl 3009 <<
"Points in mesh:" << points_.size()
3015 points_[pointi] = newPoints[pointi];
3023 const label mergePointi
3026 if (pointi < 0 || pointi >= points_.size())
3029 <<
"illegal point label " << pointi <<
endl 3030 <<
"Valid point labels are 0 .. " << points_.size()-1
3037 && (pointRemoved(pointi) || pointMap_[pointi] == -1)
3041 <<
"point " << pointi <<
" already marked for removal" <<
nl 3042 <<
"Point:" << points_[pointi] <<
" pointMap:" << pointMap_[pointi]
3046 if (pointi == mergePointi)
3049 <<
"Cannot remove/merge point " << pointi <<
" onto itself." 3054 pointMap_[pointi] = -1;
3055 if (mergePointi >= 0)
3057 reversePointMap_[pointi] = -mergePointi-2;
3061 reversePointMap_[pointi] = -1;
3063 pointZone_.erase(pointi);
3064 if (pointi < pointAdditionalZones_.size())
3066 pointAdditionalZones_[pointi].clear();
3068 retiredPoints_.erase(pointi);
3077 const label masterPointID,
3078 const label masterEdgeID,
3079 const label masterFaceID,
3080 const bool flipFaceFlux,
3089 checkFace(
f, -1, own, nei,
patchID, zoneID);
3092 label facei = faces_.size();
3096 faceOwner_.append(own);
3097 faceNeighbour_.append(nei);
3099 if (masterPointID >= 0)
3101 faceMap_.append(-1);
3102 faceFromPoint_.insert(facei, masterPointID);
3104 else if (masterEdgeID >= 0)
3106 faceMap_.append(-1);
3107 faceFromEdge_.insert(facei, masterEdgeID);
3109 else if (masterFaceID >= 0)
3111 faceMap_.append(masterFaceID);
3120 faceMap_.append(-1);
3122 reverseFaceMap_.append(facei);
3124 flipFaceFlux_.set(facei, flipFaceFlux);
3128 faceZone_.insert(facei, zoneID);
3130 faceZoneFlip_.set(facei, zoneFlip);
3142 const label masterPointID,
3143 const label masterEdgeID,
3144 const label masterFaceID,
3145 const bool flipFaceFlux,
3155 checkFace(
f, -1, own, nei,
patchID, -1);
3158 label facei = faces_.size();
3162 faceOwner_.append(own);
3163 faceNeighbour_.append(nei);
3165 if (masterPointID >= 0)
3167 faceMap_.append(-1);
3168 faceFromPoint_.insert(facei, masterPointID);
3170 else if (masterEdgeID >= 0)
3172 faceMap_.append(-1);
3173 faceFromEdge_.insert(facei, masterEdgeID);
3175 else if (masterFaceID >= 0)
3177 faceMap_.append(masterFaceID);
3186 faceMap_.append(-1);
3188 reverseFaceMap_.append(facei);
3190 flipFaceFlux_.set(facei, flipFaceFlux);
3196 faceZone_.set(facei,
zoneIDs[minIndex]);
3197 faceZoneFlip_.set(facei, zoneFlips[minIndex]);
3200 if (facei < faceAdditionalZones_.size())
3202 faceAdditionalZones_[facei].clear();
3215 const label zoneAndSign
3221 faceAdditionalZones_(facei).push_uniq(zoneAndSign);
3236 const bool flipFaceFlux,
3239 const bool zoneFlip,
3240 const bool multiZone
3246 checkFace(
f, facei, own, nei,
patchID, zoneID);
3250 faceOwner_[facei] = own;
3251 faceNeighbour_[facei] = nei;
3254 flipFaceFlux_.set(facei, flipFaceFlux);
3263 faceZone_.erase(facei);
3264 faceZoneFlip_.set(facei, zoneFlip);
3268 faceZone_.set(facei, zoneID);
3269 faceZoneFlip_.set(facei, zoneFlip);
3271 if (facei < faceAdditionalZones_.size())
3273 faceAdditionalZones_[facei].clear();
3278 auto fnd = faceZone_.find(facei);
3281 faceZone_.set(facei, zoneID);
3282 faceZoneFlip_.set(facei, zoneFlip);
3285 if (faceAdditionalZones_(facei).size())
3288 <<
"Additional zones for face:" 3289 << faceAdditionalZones_(facei)
3293 else if (zoneID == -1)
3296 faceZone_.erase(fnd);
3297 faceZoneFlip_.set(facei,
false);
3298 if (facei < faceAdditionalZones_.size())
3300 faceAdditionalZones_[facei].clear();
3303 else if (zoneID != fnd())
3306 const label zoneAndSign
3312 faceAdditionalZones_(facei).push_uniq(zoneAndSign);
3324 const bool flipFaceFlux,
3334 checkFace(
f, facei, own, nei,
patchID, -1);
3338 faceOwner_[facei] = own;
3339 faceNeighbour_[facei] = nei;
3342 flipFaceFlux_.set(facei, flipFaceFlux);
3353 <<
" for face:" << facei
3357 faceZone_.set(facei,
zoneIDs[0]);
3358 faceZoneFlip_.set(facei, zoneFlips[0]);
3359 if (facei < faceAdditionalZones_.size())
3361 faceAdditionalZones_[facei].clear();
3365 const label zoneAndSign
3371 faceAdditionalZones_(facei).push_uniq(zoneAndSign);
3376 faceZone_.erase(facei);
3377 faceZoneFlip_.set(facei,
false);
3378 if (facei < faceAdditionalZones_.size())
3380 faceAdditionalZones_[facei].clear();
3389 const label mergeFacei
3392 if (facei < 0 || facei >= faces_.size())
3395 <<
"illegal face label " << facei <<
endl 3396 <<
"Valid face labels are 0 .. " << faces_.size()-1
3403 && (faceRemoved(facei) || faceMap_[facei] == -1)
3408 <<
" already marked for removal" 3412 faces_[facei].clear();
3413 region_[facei] = -1;
3414 faceOwner_[facei] = -1;
3415 faceNeighbour_[facei] = -1;
3416 faceMap_[facei] = -1;
3417 if (mergeFacei >= 0)
3419 reverseFaceMap_[facei] = -mergeFacei-2;
3423 reverseFaceMap_[facei] = -1;
3425 faceFromEdge_.erase(facei);
3426 faceFromPoint_.erase(facei);
3427 flipFaceFlux_.unset(facei);
3428 faceZoneFlip_.unset(facei);
3429 faceZone_.erase(facei);
3430 if (facei < faceAdditionalZones_.size())
3432 faceAdditionalZones_[facei].clear();
3439 const label masterPointID,
3440 const label masterEdgeID,
3441 const label masterFaceID,
3442 const label masterCellID,
3446 label celli = cellMap_.size();
3448 if (masterPointID >= 0)
3450 cellMap_.append(-1);
3451 cellFromPoint_.insert(celli, masterPointID);
3453 else if (masterEdgeID >= 0)
3455 cellMap_.append(-1);
3456 cellFromEdge_.insert(celli, masterEdgeID);
3458 else if (masterFaceID >= 0)
3460 cellMap_.append(-1);
3461 cellFromFace_.insert(celli, masterFaceID);
3465 cellMap_.append(masterCellID);
3467 reverseCellMap_.append(celli);
3469 cellZone_.append(zoneID);
3478 const label masterPointID,
3479 const label masterEdgeID,
3480 const label masterFaceID,
3481 const label masterCellID,
3485 label celli = cellMap_.size();
3487 if (masterPointID >= 0)
3489 cellMap_.append(-1);
3490 cellFromPoint_.insert(celli, masterPointID);
3492 else if (masterEdgeID >= 0)
3494 cellMap_.append(-1);
3495 cellFromEdge_.insert(celli, masterEdgeID);
3497 else if (masterFaceID >= 0)
3499 cellMap_.append(-1);
3500 cellFromFace_.insert(celli, masterFaceID);
3504 cellMap_.append(masterCellID);
3506 reverseCellMap_.append(celli);
3513 if (celli < cellAdditionalZones_.size())
3515 cellAdditionalZones_[celli].clear();
3520 cellAdditionalZones_(celli).push_uniq(
zoneIDs[i]);
3525 cellZone_.append(-1);
3536 const bool multiZone
3541 cellZone_[celli] = zoneID;
3542 if (celli < cellAdditionalZones_.size())
3544 cellAdditionalZones_[celli].clear();
3549 if (cellZone_[celli] == -1)
3551 cellZone_[celli] = zoneID;
3554 if (cellAdditionalZones_(celli).size())
3557 <<
"Additional zones for cell:" 3558 << cellAdditionalZones_(celli)
3567 cellZone_[celli] = zoneID;
3568 if (celli < cellAdditionalZones_.size())
3570 cellAdditionalZones_[celli].clear();
3573 else if (zoneID != cellZone_[celli])
3576 cellAdditionalZones_(celli).push_uniq(zoneID);
3589 if (celli < 0 || celli >= cellMap_.size())
3592 <<
"illegal cell label " << celli <<
endl 3593 <<
"Valid cell labels are 0 .. " << cellMap_.size()-1
3603 <<
" for cell:" << celli
3607 cellZone_[celli] =
zoneIDs[0];
3608 if (celli < cellAdditionalZones_.size())
3610 cellAdditionalZones_[celli].
clear();
3614 cellAdditionalZones_(celli).push_uniq(
zoneIDs[i]);
3619 cellZone_[celli] = -1;
3620 if (celli < cellAdditionalZones_.size())
3622 cellAdditionalZones_[celli].clear();
3631 const label mergeCelli
3634 if (celli < 0 || celli >= cellMap_.size())
3637 <<
"illegal cell label " << celli <<
endl 3638 <<
"Valid cell labels are 0 .. " << cellMap_.size()-1
3642 if (strict_ && cellMap_[celli] == -2)
3646 <<
" already marked for removal" 3650 cellMap_[celli] = -2;
3651 if (mergeCelli >= 0)
3653 reverseCellMap_[celli] = -mergeCelli-2;
3657 reverseCellMap_[celli] = -1;
3659 cellFromPoint_.erase(celli);
3660 cellFromEdge_.erase(celli);
3661 cellFromFace_.erase(celli);
3662 cellZone_[celli] = -1;
3663 if (celli < cellAdditionalZones_.size())
3665 cellAdditionalZones_[celli].clear();
3676 if (pointi < 0 || pointi >= pointMap_.size())
3679 <<
"illegal point label " << pointi <<
endl 3680 <<
"Valid point labels are 0 .. " << pointMap_.size()-1
3685 const auto fnd = pointZone_.find(pointi);
3689 if (pointi < pointAdditionalZones_.size())
3691 for (
const label zonei : pointAdditionalZones_[pointi])
3697 return zones.
size();
3708 if (facei < 0 || facei >= faceMap_.size())
3711 <<
"illegal face label " << facei <<
endl 3712 <<
"Valid face labels are 0 .. " << faceMap_.size()-1
3718 const auto fnd = faceZone_.find(facei);
3723 if (facei < faceAdditionalZones_.size())
3725 for (
const label zoneAndSign : faceAdditionalZones_[facei])
3727 const label zonei =
mag(zoneAndSign)-1;
3728 if (!zones.
found(zonei))
3736 return zones.
size();
3746 if (celli < 0 || celli >= cellMap_.size())
3749 <<
"illegal cell label " << celli <<
endl 3750 <<
"Valid cell labels are 0 .. " << cellMap_.size()-1
3754 if (cellZone_[celli] != -1)
3758 if (celli < cellAdditionalZones_.size())
3760 for (
const label zonei : cellAdditionalZones_[celli])
3765 return zones.
size();
3774 const bool syncParallel,
3775 const bool orderCells,
3776 const bool orderPoints
3781 Pout<<
"polyTopoChange::changeMesh" 3782 <<
"(polyMesh&, const bool, const bool, const bool, const bool)" 3788 Pout<<
"Old mesh:" <<
nl;
3795 label nInternalPoints;
3835 oldPatchMeshPointMaps,
3836 oldPatchNMeshPoints,
3838 oldFaceZoneMeshPointMaps
3860 const label oldPointi = pointMap_[
newPointi];
3905 retiredPoints_.clearStorage();
3906 region_.clearStorage();
3913 label nAdd, nInflate, nMerge, nRemove;
3914 countMap(pointMap_, reversePointMap_, nAdd, nInflate, nMerge, nRemove);
3916 <<
" added(from point):" << nAdd
3917 <<
" added(from nothing):" << nInflate
3918 <<
" merged(into other point):" << nMerge
3919 <<
" removed:" << nRemove
3922 countMap(faceMap_, reverseFaceMap_, nAdd, nInflate, nMerge, nRemove);
3924 <<
" added(from face):" << nAdd
3925 <<
" added(inflated):" << nInflate
3926 <<
" merged(into other face):" << nMerge
3927 <<
" removed:" << nRemove
3930 countMap(cellMap_, reverseCellMap_, nAdd, nInflate, nMerge, nRemove);
3932 <<
" added(from cell):" << nAdd
3933 <<
" added(inflated):" << nInflate
3934 <<
" merged(into other cell):" << nMerge
3935 <<
" removed:" << nRemove
3950 resetZones(
mesh,
mesh, pointZoneMap, faceZoneFaceMap, cellZoneMap);
3954 Pout<<
"New mesh:" <<
nl;
3960 pointZone_.clearStorage();
3961 faceZone_.clearStorage();
3962 faceZoneFlip_.clearStorage();
3963 cellZone_.clearStorage();
3973 oldPatchMeshPointMaps,
3981 calcFaceZonePointMap(
mesh, oldFaceZoneMeshPointMaps, faceZonePointMap);
4022 oldPatchNMeshPoints,
4038 const bool syncParallel,
4039 const bool orderCells,
4040 const bool orderPoints
const face & newFace() const
Return face.
Class containing data for face removal.
label zoneID() const
Face zone ID.
label mergePointID() const
label neighbour() const
Return owner cell ID.
void size(const label n)
Older name for setAddressableSize.
ZoneMesh< faceZone, polyMesh > faceZoneMesh
A ZoneMesh with the type faceZone.
const labelIOList & zoneIDs
List< List< bool > > boolListList
List of boolList.
label faceID() const
Return master face ID.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Class describing modification of a face.
void modifyCell(const label celli, const label zoneID, const bool multiZone=false)
Modify zone of cell. Optionally add to zone.
A face is a list of labels corresponding to mesh vertices.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
label zoneFlip() const
Face zone flip.
const face & newFace() const
Return face.
polyTopoChange(const label nPatches, const bool strict=true)
Construct without mesh. Either specify nPatches or use setNumPatches before trying to make a mesh (ma...
labelHashSet used(const bitSet &select)
Convert a bitset to a labelHashSet of the indices used.
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.
virtual const labelList & faceNeighbour() const
Return face neighbour.
labelList sortedOrder(const UList< T > &input)
Return the (stable) sort order for the list.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
IntListType renumber(const labelUList &oldToNew, const IntListType &input)
Renumber the values within a list.
constexpr char nl
The newline '\n' character (0x0a)
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.
bool inCell() const
Does the point support a cell.
label patchID() const
Boundary patch ID.
label owner() const
Return owner cell ID.
Ostream & endl(Ostream &os)
Add newline and flush stream.
bool found(const T &val, label pos=0) const
Same as contains()
label zoneID() const
Point zone ID.
label cellID() const
Cell ID.
void resetPrimitives(autoPtr< pointField > &&points, autoPtr< faceList > &&faces, autoPtr< labelList > &&owner, autoPtr< labelList > &&neighbour, const labelUList &patchSizes, const labelUList &patchStarts, const bool validBoundary=true)
Reset mesh primitive data. Assumes all patch info correct.
label zoneID() const
Face zone ID.
label masterCellID() const
Return master cell ID.
void stableSort(UList< T > &list)
Stable sort the list.
Class containing data for point addition.
label masterEdgeID() const
Return master edge ID.
label pointID() const
Point ID.
label nFaces() const noexcept
Number of mesh faces.
autoPtr< mapPolyMesh > changeMesh(polyMesh &mesh, const labelUList &patchMap, const bool inflate, const bool syncParallel=true, const bool orderCells=false, const bool orderPoints=false)
Inplace changes mesh without change of patches.
label masterPointID() const
Return master point ID.
virtual const fileName & name() const override
Get the name of the output serial stream. (eg, the name of the Fstream file name) ...
bool insert(const Key &key)
Insert a new entry, not overwriting existing entries.
labelList faceLabels(nFaceLabels)
List< labelList > labelListList
List of labelList.
Class describing modification of a cell.
A face addition data class. A face can be inflated either from a point or from another face and can e...
void clear()
Clear all storage.
bool isInternalFace(const label faceIndex) const noexcept
Return true if given face label is internal to the mesh.
UList< label > labelUList
A UList of labels.
label addCell(const label masterPointID, const label masterEdgeID, const label masterFaceID, const label masterCellID, const label zoneID)
Add cell. Return new cell label.
virtual const pointField & points() const
Return raw points.
#define forAll(list, i)
Loop across all elements in list.
bool removeFromZone() const
const point & newPoint() const
Point location.
label owner() const
Return owner cell.
HashSet< label, Hash< label > > labelHashSet
A HashSet of labels, uses label hasher.
label zoneFlip() const
Face zone flip.
label cellZones(const label celli, DynamicList< label > &zones) const
Get current cellZone(s). Return number of zones.
const labelListList & edgeCells() const
Class containing data for cell addition.
label findMin(const ListType &input, label start=0)
Linear search for the index of the min element, similar to std::min_element but for lists and returns...
bool flipFaceFlux() const
Does the face flux need to be flipped.
vectorField pointField
pointField is a vectorField.
Class containing data for cell removal.
void setSize(const label n)
Alias for resize()
label cellID() const
Return cell ID.
label addFace(const face &f, const label own, const label nei, const label masterPointID, const label masterEdgeID, const label masterFaceID, const bool flipFaceFlux, const label patchID, const label zoneID, const bool zoneFlip)
Add face to cells. Return new face label.
label faceID() const
Return face ID.
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...
bool inCell() const
Does the point support a cell.
void clear()
Clear the list, i.e. set size to zero.
const polyBoundaryMesh & boundaryMesh() const noexcept
Return boundary mesh.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
void removeCell(const label celli, const label mergeCelli)
Remove/merge cell.
label faceZones(const label facei, DynamicList< label > &zones, DynamicList< bool > &flips) const
Get current faceZone(s). Return number of zones.
label size() const noexcept
The number of entries in the list.
label mergeCellID() const
Return cell ID.
label zoneID() const
Cell zone ID.
virtual const labelList & faceOwner() const
Return face owner.
label masterFaceID() const
Return master face ID.
label masterPointID() const
Return master point ID.
void modifyFace(const face &f, const label facei, const label own, const label nei, const bool flipFaceFlux, const label patchID, const label zoneID, const bool zoneFlip, const bool multiZone=false)
Modify vertices or cell of face.
label nInternalFaces() const noexcept
Number of internal faces.
ZoneMesh< pointZone, polyMesh > pointZoneMesh
A ZoneMesh with the type pointZone.
void shrink()
Shrink storage (does not remove any elements; just compacts dynamic lists.
void append(const T &val)
Copy append an element to the end of this list.
virtual const faceList & faces() const
Return raw faces.
errorManip< error > abort(error &err)
const labelListList & pointCells() const
A virtual base class for topological actions.
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO...
void setCapacity(const label nPoints, const label nFaces, const label nCells)
Explicitly pre-size the dynamic storage for expected mesh size for if construct-without-mesh.
bool topoChanging() const noexcept
Is mesh topology changing.
label patchID() const
Boundary patch ID.
Class describing modification of a point.
void movePoints(const pointField &newPoints)
Move all points. Incompatible with other topology changes.
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
int debug
Static debugging option.
OBJstream os(runTime.globalPath()/outputName)
const faceZoneMesh & faceZones() const noexcept
Return face zone mesh.
defineTypeNameAndDebug(combustionModel, 0)
void clear() noexcept
Clear the addressed list, i.e. set the size to zero.
void setSize(const label newLen)
Same as resize()
PrimitivePatch< SubList< face >, const pointField & > primitivePatch
A PrimitivePatch with a SubList addressing for the faces, const reference for the point field...
void push_back(const T &val)
Copy append an element to the end of this list.
void resize(const label newLen)
Adjust size of PtrList.
label zoneID() const
Point zone ID.
label push_uniq(const T &val)
Append an element if not already in the list.
label zoneID() const
Cell zone ID.
labelList invert(const label len, const labelUList &map)
Create an inverse one-to-one mapping.
const pointZoneMesh & pointZones() const noexcept
Return point zone mesh.
label masterFaceID() const
Return master face ID.
void addMesh(const polyMesh &mesh, const labelUList &patchMap, const labelUList &pointZoneMap, const labelUList &faceZoneMap, const labelUList &cellZoneMap)
Add all points/faces/cells of mesh. Additional offset for patch or zone ids.
label neighbour() const
Return neighbour cell.
const wordList internal
Standard dimensioned field types (scalar, vector, tensor, etc)
label nCells() const noexcept
Number of mesh cells.
void removePoint(const label pointi, const label mergePointi)
Remove/merge point.
const polyBoundaryMesh & patches
void modifyPoint(const label pointi, const point &pt, const label zoneID, const bool inCell, const bool multiZone=false)
Modify coordinate.
const cellZoneMesh & cellZones() const noexcept
Return cell zone mesh.
label pointZones(const label pointi, DynamicList< label > &zones) const
Get current cellZone(s). Return number of zones.
const labelListList & pointFaces() const
const point & newPoint() const
New point location.
label pointID() const
Return point ID.
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.
bool flipFaceFlux() const
Does the face flux need to be flipped.
List< label > labelList
A List of labels.
static autoPtr< T > New(Args &&... args)
Construct autoPtr with forwarding arguments.
A patch is a list of labels that address the faces in the global face list.
bool returnReduceOr(const bool value, const label comm=UPstream::worldComm)
Perform logical (or) MPI Allreduce on a copy. Uses UPstream::reduceOr.
ListType reorder(const labelUList &oldToNew, const ListType &input, const bool prune=false)
Reorder the elements of a list.
void removeFace(const label facei, const label mergeFacei)
Remove/merge face.
List< bool > boolList
A List of bools.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
Class containing data for point removal.
ZoneMesh< cellZone, polyMesh > cellZoneMesh
A ZoneMesh with the type cellZone.
const labelListList & edgeFaces() const
label mergeFaceID() const
Return merge face ID.
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
forAllConstIters(mixture.phases(), phase)
label masterEdgeID() const
Return master edge ID.
const scalarField & cellVolumes() const
FlatOutput::OutputAdaptor< Container, Delimiters > flatOutput(const Container &obj, Delimiters delim)
Global flatOutput() function with specified output delimiters.
label setAction(const topoAction &action)
For compatibility with polyTopoChange: set topological action.
static constexpr const zero Zero
Global zero (0)
label masterPointID() const
Master point label.