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,
2032 PstreamBuffers pBufs;
2037 const label oldPatchi = patchMap[patchi];
2042 && (syncParallel || !isA<processorPolyPatch>(oldBoundary[oldPatchi]))
2045 oldBoundary[oldPatchi].initOrder
2064 pBufs.finishedSends();
2069 bool anyChanged =
false;
2073 const label oldPatchi = patchMap[patchi];
2078 && (syncParallel || !isA<processorPolyPatch>(oldBoundary[oldPatchi]))
2081 labelList patchFaceMap(patchSizes[patchi], -1);
2084 const bool changed = oldBoundary[oldPatchi].order
2104 const label start = patchStarts[patchi];
2106 forAll(patchFaceMap, patchFacei)
2108 oldToNew[patchFacei + start] =
2109 start + patchFaceMap[patchFacei];
2112 forAll(patchFaceRotation, patchFacei)
2114 rotation[patchFacei + start] =
2115 patchFaceRotation[patchFacei];
2126 reorderCompactFaces(oldToNew.size(), oldToNew);
2131 if (rotation[facei] != 0)
2133 inplaceRotateList<List, label>(faces_[facei], rotation[facei]);
2143 void Foam::polyTopoChange::compactAndReorder
2145 const polyMesh&
mesh,
2147 const bool syncParallel,
2148 const bool orderCells,
2149 const bool orderPoints,
2151 label& nInternalPoints,
2155 List<objectMap>& pointsFromPoints,
2156 List<objectMap>& facesFromPoints,
2157 List<objectMap>& facesFromEdges,
2158 List<objectMap>& facesFromFaces,
2159 List<objectMap>& cellsFromPoints,
2160 List<objectMap>& cellsFromEdges,
2161 List<objectMap>& cellsFromFaces,
2162 List<objectMap>& cellsFromCells,
2163 List<Map<label>>& oldPatchMeshPointMaps,
2166 List<Map<label>>& oldFaceZoneMeshPointMaps
2169 if (patchMap.size() != nPatches_)
2172 <<
"polyTopoChange was constructed with a mesh with " 2173 << nPatches_ <<
" patches." <<
endl 2174 <<
"The mesh now provided has a different number of patches " 2176 <<
" which is illegal" <<
endl 2182 compact(orderCells, orderPoints, nInternalPoints, patchSizes, patchStarts);
2186 newPoints.transfer(points_);
2219 calcFaceInflationMaps
2227 calcCellInflationMaps
2238 faceFromPoint_.clearStorage();
2239 faceFromEdge_.clearStorage();
2241 cellFromPoint_.clearStorage();
2242 cellFromEdge_.clearStorage();
2243 cellFromFace_.clearStorage();
2257 oldPatchMeshPointMaps[patchi] =
boundary[patchi].meshPointMap();
2258 oldPatchNMeshPoints[patchi] =
boundary[patchi].meshPoints().
size();
2259 oldPatchStarts[patchi] =
boundary[patchi].start();
2271 oldFaceZoneMeshPointMaps[zonei] = oldZone.patch().meshPointMap();
2285 reversePointMap_(0),
2320 reversePointMap_(0),
2357 points_.clearStorage();
2358 pointMap_.clearStorage();
2359 reversePointMap_.clearStorage();
2360 pointZone_.clearStorage();
2361 pointAdditionalZones_.clearStorage();
2362 retiredPoints_.clearStorage();
2364 faces_.clearStorage();
2365 region_.clearStorage();
2366 faceOwner_.clearStorage();
2367 faceNeighbour_.clearStorage();
2368 faceMap_.clearStorage();
2369 reverseFaceMap_.clearStorage();
2370 faceFromPoint_.clearStorage();
2371 faceFromEdge_.clearStorage();
2372 flipFaceFlux_.clearStorage();
2373 faceZone_.clearStorage();
2374 faceZoneFlip_.clearStorage();
2375 faceAdditionalZones_.clearStorage();
2378 cellMap_.clearStorage();
2379 reverseCellMap_.clearStorage();
2380 cellZone_.clearStorage();
2381 cellAdditionalZones_.clearStorage();
2382 cellFromPoint_.clearStorage();
2383 cellFromEdge_.clearStorage();
2384 cellFromFace_.clearStorage();
2397 label maxRegion = nPatches_ - 1;
2398 for (
const label regioni : patchMap)
2400 maxRegion =
max(maxRegion, regioni);
2402 nPatches_ = maxRegion + 1;
2411 points_.setCapacity(points_.size() +
points.
size());
2412 pointMap_.setCapacity(pointMap_.size() +
points.
size());
2413 reversePointMap_.setCapacity(reversePointMap_.size() +
points.
size());
2418 forAll(newPointID, pointi)
2421 newPointID[pointi] = addPoint
2432 forAll(pointZones, zonei)
2434 for (
const label pointi : pointZones[zonei])
2437 this->pointZones(newPointID[pointi], zones);
2438 for (
auto& zonei : zones)
2440 zonei = pointZoneMap[zonei];
2443 zones.append(pointZoneMap[zonei]);
2447 points_[newPointID[pointi]],
2465 cellMap_.setCapacity(cellMap_.size() + nAllCells);
2466 reverseCellMap_.setCapacity(reverseCellMap_.size() + nAllCells);
2467 cellFromPoint_.resize(cellFromPoint_.size() + nAllCells/128);
2468 cellFromEdge_.resize(cellFromEdge_.size() + nAllCells/128);
2469 cellFromFace_.resize(cellFromFace_.size() + nAllCells/128);
2470 cellZone_.setCapacity(cellZone_.size() + nAllCells);
2475 for (label celli = 0; celli < nAllCells; celli++)
2478 newCellID[celli] = addCell(-1, -1, -1, celli, -1);
2485 for (
const label celli : cellZones[zonei])
2488 this->cellZones(newCellID[celli], zones);
2489 for (
auto& zonei : zones)
2491 zonei = cellZoneMap[zonei];
2494 zones.append(cellZoneMap[zonei]);
2495 modifyCell(newCellID[celli], zones);
2511 faces_.setCapacity(faces_.size() + nAllFaces);
2512 region_.setCapacity(region_.size() + nAllFaces);
2513 faceOwner_.setCapacity(faceOwner_.size() + nAllFaces);
2514 faceNeighbour_.setCapacity(faceNeighbour_.size() + nAllFaces);
2515 faceMap_.setCapacity(faceMap_.size() + nAllFaces);
2516 reverseFaceMap_.setCapacity(reverseFaceMap_.size() + nAllFaces);
2517 faceFromPoint_.resize(faceFromPoint_.size() + nAllFaces/128);
2518 faceFromEdge_.resize(faceFromEdge_.size() + nAllFaces/128);
2519 flipFaceFlux_.setCapacity(faces_.size() + nAllFaces);
2520 faceZone_.resize(faceZone_.size() + nAllFaces/128);
2521 faceZoneFlip_.setCapacity(faceMap_.capacity());
2530 newFaceID[facei] = addFace
2534 faceNeighbour[facei],
2550 if (
pp.start() != faces_.size())
2554 <<
"Patch " <<
pp.name() <<
" starts at " <<
pp.start()
2556 <<
"Current face counter at " << faces_.size() <<
endl 2557 <<
"Are patches in incremental order?" 2562 const label facei =
pp.start() + patchFacei;
2564 newFaceID[facei] = addFace
2587 const auto& fz = faceZones[zonei];
2591 const label facei = fz[i];
2592 const bool flip = fz.flipMap()[i];
2595 const label newFacei = newFaceID[facei];
2598 this->faceZones(newFacei, zones, flips);
2599 for (
auto& zonei : zones)
2601 zonei = faceZoneMap[zonei];
2604 zones.append(faceZoneMap[zonei]);
2611 faceOwner_[newFacei],
2612 faceNeighbour_[newFacei],
2613 flipFaceFlux_(newFacei),
2632 pointMap_.setCapacity(
nPoints);
2633 reversePointMap_.setCapacity(
nPoints);
2634 pointZone_.resize(pointZone_.size() +
nPoints/128);
2636 faces_.setCapacity(nFaces);
2637 region_.setCapacity(nFaces);
2638 faceOwner_.setCapacity(nFaces);
2639 faceNeighbour_.setCapacity(nFaces);
2640 faceMap_.setCapacity(nFaces);
2641 reverseFaceMap_.setCapacity(nFaces);
2642 faceFromPoint_.resize(faceFromPoint_.size() + nFaces/128);
2643 faceFromEdge_.resize(faceFromEdge_.size() + nFaces/128);
2644 flipFaceFlux_.setCapacity(nFaces);
2645 faceZone_.resize(faceZone_.size() + nFaces/128);
2646 faceZoneFlip_.setCapacity(nFaces);
2648 cellMap_.setCapacity(nCells);
2649 reverseCellMap_.setCapacity(nCells);
2650 cellFromPoint_.resize(cellFromPoint_.size() + nCells/128);
2651 cellFromEdge_.resize(cellFromEdge_.size() + nCells/128);
2652 cellFromFace_.resize(cellFromFace_.size() + nCells/128);
2653 cellZone_.setCapacity(nCells);
2659 if (isType<polyAddPoint>(action))
2661 const polyAddPoint& pap = refCast<const polyAddPoint>(action);
2671 else if (isType<polyModifyPoint>(action))
2685 else if (isType<polyRemovePoint>(action))
2693 else if (isType<polyAddFace>(action))
2695 const polyAddFace& paf = refCast<const polyAddFace>(action);
2711 else if (isType<polyModifyFace>(action))
2713 const polyModifyFace& pmf = refCast<const polyModifyFace>(action);
2729 else if (isType<polyRemoveFace>(action))
2731 const polyRemoveFace& prf = refCast<const polyRemoveFace>(action);
2737 else if (isType<polyAddCell>(action))
2739 const polyAddCell& pac = refCast<const polyAddCell>(action);
2750 else if (isType<polyModifyCell>(action))
2752 const polyModifyCell& pmc = refCast<const polyModifyCell>(action);
2756 modifyCell(pmc.
cellID(), -1);
2765 else if (isType<polyRemoveCell>(action))
2767 const polyRemoveCell& prc = refCast<const polyRemoveCell>(action);
2776 <<
"Unknown type of topoChange: " << action.type()
2788 const label masterPointID,
2793 const label pointi = points_.size();
2796 pointMap_.append(masterPointID);
2797 reversePointMap_.append(pointi);
2801 pointZone_.insert(pointi, zoneID);
2807 retiredPoints_.insert(pointi);
2817 const label masterPointID,
2822 const label pointi = points_.size();
2825 pointMap_.append(masterPointID);
2826 reversePointMap_.append(pointi);
2832 pointZone_.set(pointi,
zoneIDs[minIndex]);
2835 if (pointi < pointAdditionalZones_.size())
2837 pointAdditionalZones_[pointi].clear();
2850 pointAdditionalZones_(pointi).push_uniq(
zoneIDs[i]);
2857 retiredPoints_.insert(pointi);
2870 const bool multiZone
2873 if (pointi < 0 || pointi >= points_.size())
2876 <<
"illegal point label " << pointi <<
endl 2877 <<
"Valid point labels are 0 .. " << points_.size()-1
2880 if (pointRemoved(pointi) || pointMap_[pointi] == -1)
2883 <<
"point " << pointi <<
" already marked for removal" 2886 points_[pointi] = pt;
2892 pointZone_.set(pointi, zoneID);
2896 pointZone_.erase(pointi);
2898 if (pointi < pointAdditionalZones_.size())
2900 pointAdditionalZones_[pointi].clear();
2905 auto fnd = pointZone_.find(pointi);
2908 pointZone_.set(pointi, zoneID);
2911 if (pointAdditionalZones_(pointi).size())
2914 <<
"Additional zones for point:" 2915 << pointAdditionalZones_(pointi)
2919 else if (zoneID == -1)
2922 pointZone_.erase(fnd);
2923 if (pointi < pointAdditionalZones_.size())
2925 pointAdditionalZones_[pointi].clear();
2928 else if (zoneID != fnd())
2931 pointAdditionalZones_(pointi).push_uniq(zoneID);
2937 retiredPoints_.erase(pointi);
2941 retiredPoints_.insert(pointi);
2954 if (pointi < 0 || pointi >= points_.size())
2957 <<
"illegal point label " << pointi <<
endl 2958 <<
"Valid point labels are 0 .. " << points_.size()-1
2961 if (pointRemoved(pointi) || pointMap_[pointi] == -1)
2964 <<
"point " << pointi <<
" already marked for removal" 2967 points_[pointi] = pt;
2975 <<
" for point:" << pointi
2979 pointZone_.set(pointi,
zoneIDs[0]);
2980 if (pointi < pointAdditionalZones_.size())
2982 pointAdditionalZones_[pointi].clear();
2986 pointAdditionalZones_(pointi).push_uniq(
zoneIDs[i]);
2991 pointZone_.erase(pointi);
2992 if (pointi < pointAdditionalZones_.size())
2994 pointAdditionalZones_[pointi].clear();
3000 retiredPoints_.erase(pointi);
3004 retiredPoints_.insert(pointi);
3010 if (newPoints.
size() != points_.size())
3013 <<
"illegal pointField size." <<
endl 3014 <<
"Size:" << newPoints.
size() <<
endl 3015 <<
"Points in mesh:" << points_.size()
3021 points_[pointi] = newPoints[pointi];
3029 const label mergePointi
3032 if (pointi < 0 || pointi >= points_.size())
3035 <<
"illegal point label " << pointi <<
endl 3036 <<
"Valid point labels are 0 .. " << points_.size()-1
3043 && (pointRemoved(pointi) || pointMap_[pointi] == -1)
3047 <<
"point " << pointi <<
" already marked for removal" <<
nl 3048 <<
"Point:" << points_[pointi] <<
" pointMap:" << pointMap_[pointi]
3052 if (pointi == mergePointi)
3055 <<
"Cannot remove/merge point " << pointi <<
" onto itself." 3060 pointMap_[pointi] = -1;
3061 if (mergePointi >= 0)
3063 reversePointMap_[pointi] = -mergePointi-2;
3067 reversePointMap_[pointi] = -1;
3069 pointZone_.erase(pointi);
3070 if (pointi < pointAdditionalZones_.size())
3072 pointAdditionalZones_[pointi].clear();
3074 retiredPoints_.erase(pointi);
3083 const label masterPointID,
3084 const label masterEdgeID,
3085 const label masterFaceID,
3086 const bool flipFaceFlux,
3095 checkFace(
f, -1, own, nei,
patchID, zoneID);
3098 label facei = faces_.size();
3102 faceOwner_.append(own);
3103 faceNeighbour_.append(nei);
3105 if (masterPointID >= 0)
3107 faceMap_.append(-1);
3108 faceFromPoint_.insert(facei, masterPointID);
3110 else if (masterEdgeID >= 0)
3112 faceMap_.append(-1);
3113 faceFromEdge_.insert(facei, masterEdgeID);
3115 else if (masterFaceID >= 0)
3117 faceMap_.append(masterFaceID);
3126 faceMap_.append(-1);
3128 reverseFaceMap_.append(facei);
3130 flipFaceFlux_.set(facei, flipFaceFlux);
3134 faceZone_.insert(facei, zoneID);
3136 faceZoneFlip_.set(facei, zoneFlip);
3148 const label masterPointID,
3149 const label masterEdgeID,
3150 const label masterFaceID,
3151 const bool flipFaceFlux,
3161 checkFace(
f, -1, own, nei,
patchID, -1);
3164 label facei = faces_.size();
3168 faceOwner_.append(own);
3169 faceNeighbour_.append(nei);
3171 if (masterPointID >= 0)
3173 faceMap_.append(-1);
3174 faceFromPoint_.insert(facei, masterPointID);
3176 else if (masterEdgeID >= 0)
3178 faceMap_.append(-1);
3179 faceFromEdge_.insert(facei, masterEdgeID);
3181 else if (masterFaceID >= 0)
3183 faceMap_.append(masterFaceID);
3192 faceMap_.append(-1);
3194 reverseFaceMap_.append(facei);
3196 flipFaceFlux_.set(facei, flipFaceFlux);
3202 faceZone_.set(facei,
zoneIDs[minIndex]);
3203 faceZoneFlip_.set(facei, zoneFlips[minIndex]);
3206 if (facei < faceAdditionalZones_.size())
3208 faceAdditionalZones_[facei].clear();
3221 const label zoneAndSign
3227 faceAdditionalZones_(facei).push_uniq(zoneAndSign);
3242 const bool flipFaceFlux,
3245 const bool zoneFlip,
3246 const bool multiZone
3252 checkFace(
f, facei, own, nei,
patchID, zoneID);
3256 faceOwner_[facei] = own;
3257 faceNeighbour_[facei] = nei;
3260 flipFaceFlux_.set(facei, flipFaceFlux);
3269 faceZone_.erase(facei);
3270 faceZoneFlip_.set(facei, zoneFlip);
3274 faceZone_.set(facei, zoneID);
3275 faceZoneFlip_.set(facei, zoneFlip);
3277 if (facei < faceAdditionalZones_.size())
3279 faceAdditionalZones_[facei].clear();
3284 auto fnd = faceZone_.find(facei);
3287 faceZone_.set(facei, zoneID);
3288 faceZoneFlip_.set(facei, zoneFlip);
3291 if (faceAdditionalZones_(facei).size())
3294 <<
"Additional zones for face:" 3295 << faceAdditionalZones_(facei)
3299 else if (zoneID == -1)
3302 faceZone_.erase(fnd);
3303 faceZoneFlip_.set(facei,
false);
3304 if (facei < faceAdditionalZones_.size())
3306 faceAdditionalZones_[facei].clear();
3309 else if (zoneID != fnd())
3312 const label zoneAndSign
3318 faceAdditionalZones_(facei).push_uniq(zoneAndSign);
3330 const bool flipFaceFlux,
3340 checkFace(
f, facei, own, nei,
patchID, -1);
3344 faceOwner_[facei] = own;
3345 faceNeighbour_[facei] = nei;
3348 flipFaceFlux_.set(facei, flipFaceFlux);
3359 <<
" for face:" << facei
3363 faceZone_.set(facei,
zoneIDs[0]);
3364 faceZoneFlip_.set(facei, zoneFlips[0]);
3365 if (facei < faceAdditionalZones_.size())
3367 faceAdditionalZones_[facei].clear();
3371 const label zoneAndSign
3377 faceAdditionalZones_(facei).push_uniq(zoneAndSign);
3382 faceZone_.erase(facei);
3383 faceZoneFlip_.set(facei,
false);
3384 if (facei < faceAdditionalZones_.size())
3386 faceAdditionalZones_[facei].clear();
3395 const label mergeFacei
3398 if (facei < 0 || facei >= faces_.size())
3401 <<
"illegal face label " << facei <<
endl 3402 <<
"Valid face labels are 0 .. " << faces_.size()-1
3409 && (faceRemoved(facei) || faceMap_[facei] == -1)
3414 <<
" already marked for removal" 3418 faces_[facei].clear();
3419 region_[facei] = -1;
3420 faceOwner_[facei] = -1;
3421 faceNeighbour_[facei] = -1;
3422 faceMap_[facei] = -1;
3423 if (mergeFacei >= 0)
3425 reverseFaceMap_[facei] = -mergeFacei-2;
3429 reverseFaceMap_[facei] = -1;
3431 faceFromEdge_.erase(facei);
3432 faceFromPoint_.erase(facei);
3433 flipFaceFlux_.unset(facei);
3434 faceZoneFlip_.unset(facei);
3435 faceZone_.erase(facei);
3436 if (facei < faceAdditionalZones_.size())
3438 faceAdditionalZones_[facei].clear();
3445 const label masterPointID,
3446 const label masterEdgeID,
3447 const label masterFaceID,
3448 const label masterCellID,
3452 label celli = cellMap_.size();
3454 if (masterPointID >= 0)
3456 cellMap_.append(-1);
3457 cellFromPoint_.insert(celli, masterPointID);
3459 else if (masterEdgeID >= 0)
3461 cellMap_.append(-1);
3462 cellFromEdge_.insert(celli, masterEdgeID);
3464 else if (masterFaceID >= 0)
3466 cellMap_.append(-1);
3467 cellFromFace_.insert(celli, masterFaceID);
3471 cellMap_.append(masterCellID);
3473 reverseCellMap_.append(celli);
3475 cellZone_.append(zoneID);
3484 const label masterPointID,
3485 const label masterEdgeID,
3486 const label masterFaceID,
3487 const label masterCellID,
3491 label celli = cellMap_.size();
3493 if (masterPointID >= 0)
3495 cellMap_.append(-1);
3496 cellFromPoint_.insert(celli, masterPointID);
3498 else if (masterEdgeID >= 0)
3500 cellMap_.append(-1);
3501 cellFromEdge_.insert(celli, masterEdgeID);
3503 else if (masterFaceID >= 0)
3505 cellMap_.append(-1);
3506 cellFromFace_.insert(celli, masterFaceID);
3510 cellMap_.append(masterCellID);
3512 reverseCellMap_.append(celli);
3519 if (celli < cellAdditionalZones_.size())
3521 cellAdditionalZones_[celli].clear();
3526 cellAdditionalZones_(celli).push_uniq(
zoneIDs[i]);
3531 cellZone_.append(-1);
3542 const bool multiZone
3547 cellZone_[celli] = zoneID;
3548 if (celli < cellAdditionalZones_.size())
3550 cellAdditionalZones_[celli].clear();
3555 if (cellZone_[celli] == -1)
3557 cellZone_[celli] = zoneID;
3560 if (cellAdditionalZones_(celli).size())
3563 <<
"Additional zones for cell:" 3564 << cellAdditionalZones_(celli)
3573 cellZone_[celli] = zoneID;
3574 if (celli < cellAdditionalZones_.size())
3576 cellAdditionalZones_[celli].clear();
3579 else if (zoneID != cellZone_[celli])
3582 cellAdditionalZones_(celli).push_uniq(zoneID);
3595 if (celli < 0 || celli >= cellMap_.size())
3598 <<
"illegal cell label " << celli <<
endl 3599 <<
"Valid cell labels are 0 .. " << cellMap_.size()-1
3609 <<
" for cell:" << celli
3613 cellZone_[celli] =
zoneIDs[0];
3614 if (celli < cellAdditionalZones_.size())
3616 cellAdditionalZones_[celli].
clear();
3620 cellAdditionalZones_(celli).push_uniq(
zoneIDs[i]);
3625 cellZone_[celli] = -1;
3626 if (celli < cellAdditionalZones_.size())
3628 cellAdditionalZones_[celli].clear();
3637 const label mergeCelli
3640 if (celli < 0 || celli >= cellMap_.size())
3643 <<
"illegal cell label " << celli <<
endl 3644 <<
"Valid cell labels are 0 .. " << cellMap_.size()-1
3648 if (strict_ && cellMap_[celli] == -2)
3652 <<
" already marked for removal" 3656 cellMap_[celli] = -2;
3657 if (mergeCelli >= 0)
3659 reverseCellMap_[celli] = -mergeCelli-2;
3663 reverseCellMap_[celli] = -1;
3665 cellFromPoint_.erase(celli);
3666 cellFromEdge_.erase(celli);
3667 cellFromFace_.erase(celli);
3668 cellZone_[celli] = -1;
3669 if (celli < cellAdditionalZones_.size())
3671 cellAdditionalZones_[celli].clear();
3682 if (pointi < 0 || pointi >= pointMap_.size())
3685 <<
"illegal point label " << pointi <<
endl 3686 <<
"Valid point labels are 0 .. " << pointMap_.size()-1
3691 const auto fnd = pointZone_.find(pointi);
3695 if (pointi < pointAdditionalZones_.size())
3697 for (
const label zonei : pointAdditionalZones_[pointi])
3703 return zones.
size();
3714 if (facei < 0 || facei >= faceMap_.size())
3717 <<
"illegal face label " << facei <<
endl 3718 <<
"Valid face labels are 0 .. " << faceMap_.size()-1
3724 const auto fnd = faceZone_.find(facei);
3729 if (facei < faceAdditionalZones_.size())
3731 for (
const label zoneAndSign : faceAdditionalZones_[facei])
3733 const label zonei =
mag(zoneAndSign)-1;
3734 if (!zones.
found(zonei))
3742 return zones.
size();
3752 if (celli < 0 || celli >= cellMap_.size())
3755 <<
"illegal cell label " << celli <<
endl 3756 <<
"Valid cell labels are 0 .. " << cellMap_.size()-1
3760 if (cellZone_[celli] != -1)
3764 if (celli < cellAdditionalZones_.size())
3766 for (
const label zonei : cellAdditionalZones_[celli])
3771 return zones.
size();
3780 const bool syncParallel,
3781 const bool orderCells,
3782 const bool orderPoints
3787 Pout<<
"polyTopoChange::changeMesh" 3788 <<
"(polyMesh&, const bool, const bool, const bool, const bool)" 3794 Pout<<
"Old mesh:" <<
nl;
3801 label nInternalPoints;
3841 oldPatchMeshPointMaps,
3842 oldPatchNMeshPoints,
3844 oldFaceZoneMeshPointMaps
3866 const label oldPointi = pointMap_[
newPointi];
3911 retiredPoints_.clearStorage();
3912 region_.clearStorage();
3919 label nAdd, nInflate, nMerge, nRemove;
3920 countMap(pointMap_, reversePointMap_, nAdd, nInflate, nMerge, nRemove);
3922 <<
" added(from point):" << nAdd
3923 <<
" added(from nothing):" << nInflate
3924 <<
" merged(into other point):" << nMerge
3925 <<
" removed:" << nRemove
3928 countMap(faceMap_, reverseFaceMap_, nAdd, nInflate, nMerge, nRemove);
3930 <<
" added(from face):" << nAdd
3931 <<
" added(inflated):" << nInflate
3932 <<
" merged(into other face):" << nMerge
3933 <<
" removed:" << nRemove
3936 countMap(cellMap_, reverseCellMap_, nAdd, nInflate, nMerge, nRemove);
3938 <<
" added(from cell):" << nAdd
3939 <<
" added(inflated):" << nInflate
3940 <<
" merged(into other cell):" << nMerge
3941 <<
" removed:" << nRemove
3956 resetZones(
mesh,
mesh, pointZoneMap, faceZoneFaceMap, cellZoneMap);
3960 Pout<<
"New mesh:" <<
nl;
3966 pointZone_.clearStorage();
3967 faceZone_.clearStorage();
3968 faceZoneFlip_.clearStorage();
3969 cellZone_.clearStorage();
3979 oldPatchMeshPointMaps,
3987 calcFaceZonePointMap(
mesh, oldFaceZoneMeshPointMaps, faceZonePointMap);
4028 oldPatchNMeshPoints,
4044 const bool syncParallel,
4045 const bool orderCells,
4046 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.
static int incrMsgType(int val=1) noexcept
Increment the message tag for standard messages.
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.
void setSize(const label n)
Same as resize()
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.
static int & msgType() noexcept
Message tag of standard messages.
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.
bool returnReduceOr(const bool value, const int communicator=UPstream::worldComm)
Perform logical (or) MPI Allreduce on a copy. Uses UPstream::reduceOr.
errorManip< error > abort(error &err)
const labelListList & pointCells() const
A virtual base class for topological actions.
A polyBoundaryMesh is a polyPatch list with registered IO, a reference to the associated polyMesh...
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.
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.
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.