45 void Foam::polyTopoChange::renumberReverseMap
48 DynamicList<label>& elems
53 label val = elems[elemI];
57 elems[elemI] = map[val];
61 label mergedVal = -val-2;
62 elems[elemI] = -map[mergedVal]-2;
68 void Foam::polyTopoChange::renumber
78 label newElem = map[iter.key()];
82 newElems.insert(newElem);
86 elems.transfer(newElems);
90 void Foam::polyTopoChange::renumberCompact
100 label newVal = map[elems[elemI]];
104 elems[newElemI++] = newVal;
107 elems.setSize(newElemI);
111 void Foam::polyTopoChange::countMap
128 label oldCelli = map[newCelli];
132 if (reverseMap[oldCelli] == newCelli)
142 else if (oldCelli == -1)
154 forAll(reverseMap, oldCelli)
156 label newCelli = reverseMap[oldCelli];
162 else if (newCelli == -1)
178 const PackedBoolList& lst
193 void Foam::polyTopoChange::writeMeshStats(
const polyMesh& mesh, Ostream& os)
195 const polyBoundaryMesh&
patches = mesh.boundaryMesh();
205 os <<
" Points : " << mesh.nPoints() <<
nl
206 <<
" Faces : " << mesh.nFaces() <<
nl
207 <<
" Cells : " << mesh.nCells() <<
nl
208 <<
" PatchSizes : " << patchSizes <<
nl
209 <<
" PatchStarts : " << patchStarts <<
nl
214 void Foam::polyTopoChange::getMergeSets
218 List<objectMap>& cellsFromCells
224 forAll(reverseCellMap, oldCelli)
226 label newCelli = reverseCellMap[oldCelli];
230 label mergeCelli = -newCelli-2;
232 nMerged[mergeCelli]++;
237 labelList cellToMergeSet(cellMap.size(), -1);
243 if (nMerged[celli] > 1)
245 cellToMergeSet[celli] = nSets++;
255 cellsFromCells.setSize(nSets);
257 forAll(reverseCellMap, oldCelli)
259 label newCelli = reverseCellMap[oldCelli];
263 label mergeCelli = -newCelli-2;
267 label setI = cellToMergeSet[mergeCelli];
269 objectMap& mergeSet = cellsFromCells[setI];
271 if (mergeSet.masterObjects().empty())
275 mergeSet.index() = mergeCelli;
276 mergeSet.masterObjects().setSize(nMerged[mergeCelli]);
279 mergeSet.masterObjects()[0] = cellMap[mergeCelli];
282 mergeSet.masterObjects()[1] = oldCelli;
284 nMerged[mergeCelli] = 2;
288 mergeSet.masterObjects()[nMerged[mergeCelli]++] = oldCelli;
295 bool Foam::polyTopoChange::hasValidPoints(
const face&
f)
const
299 if (
f[fp] < 0 ||
f[fp] >= points_.
size())
313 if (
f[fp] < 0 &&
f[fp] >= points_.
size())
324 void Foam::polyTopoChange::checkFace
342 <<
"Face has no neighbour (so external) but does not have"
343 <<
" a valid patch" <<
nl
345 <<
" facei(-1 if added face):" << facei
346 <<
" own:" << own <<
" nei:" << nei
348 if (hasValidPoints(
f))
351 <<
"points (removed points marked with "
362 <<
"Cannot both have valid patchi and neighbour" <<
nl
364 <<
" facei(-1 if added face):" << facei
365 <<
" own:" << own <<
" nei:" << nei
367 if (hasValidPoints(
f))
370 <<
"points (removed points marked with "
379 <<
"Owner cell label should be less than neighbour cell label"
382 <<
" facei(-1 if added face):" << facei
383 <<
" own:" << own <<
" nei:" << nei
385 if (hasValidPoints(
f))
388 <<
"points (removed points marked with "
398 <<
"Illegal vertices in face"
401 <<
" facei(-1 if added face):" << facei
402 <<
" own:" << own <<
" nei:" << nei
404 if (hasValidPoints(
f))
407 <<
"points (removed points marked with "
412 if (facei >= 0 && facei < faces_.size() && faceRemoved(facei))
415 <<
"Face already marked for removal"
418 <<
" facei(-1 if added face):" << facei
419 <<
" own:" << own <<
" nei:" << nei
421 if (hasValidPoints(
f))
424 <<
"points (removed points marked with "
431 if (
f[fp] < points_.
size() && pointRemoved(
f[fp]))
434 <<
"Face uses removed vertices"
437 <<
" facei(-1 if added face):" << facei
438 <<
" own:" << own <<
" nei:" << nei
440 if (hasValidPoints(
f))
443 <<
"points (removed points marked with "
452 void Foam::polyTopoChange::makeCells
454 const label nActiveFaces,
459 cellFaces.setSize(2*nActiveFaces);
460 cellFaceOffsets.setSize(cellMap_.size() + 1);
467 for (
label facei = 0; facei < nActiveFaces; facei++)
469 if (faceOwner_[facei] < 0)
472 <<
"Face " << facei <<
" is active but its owner has"
473 <<
" been deleted. This is usually due to deleting cells"
474 <<
" without modifying exposed faces to be boundary faces."
477 nNbrs[faceOwner_[facei]]++;
479 for (
label facei = 0; facei < nActiveFaces; facei++)
481 if (faceNeighbour_[facei] >= 0)
483 nNbrs[faceNeighbour_[facei]]++;
489 cellFaceOffsets[0] = 0;
492 cellFaceOffsets[celli+1] = cellFaceOffsets[celli] + nNbrs[celli];
500 for (
label facei = 0; facei < nActiveFaces; facei++)
502 label celli = faceOwner_[facei];
504 cellFaces[cellFaceOffsets[celli] + nNbrs[celli]++] = facei;
507 for (
label facei = 0; facei < nActiveFaces; facei++)
509 label celli = faceNeighbour_[facei];
513 cellFaces[cellFaceOffsets[celli] + nNbrs[celli]++] = facei;
518 cellFaces.setSize(cellFaceOffsets[cellMap_.size()]);
522 void Foam::polyTopoChange::makeCellCells
524 const label nActiveFaces,
525 CompactListList<label>& cellCells
533 for (
label facei = 0; facei < nActiveFaces; facei++)
535 if (faceNeighbour_[facei] >= 0)
537 nNbrs[faceOwner_[facei]]++;
538 nNbrs[faceNeighbour_[facei]]++;
543 cellCells.setSize(nNbrs);
551 for (
label facei = 0; facei < nActiveFaces; facei++)
553 label nei = faceNeighbour_[facei];
557 label own = faceOwner_[facei];
558 cellCells.m()[cellCells.index(own, nNbrs[own]++)] = nei;
559 cellCells.m()[cellCells.index(nei, nNbrs[nei]++)] = own;
567 const CompactListList<label>& cellCellAddressing,
571 labelList newOrder(cellCellAddressing.size());
574 SLList<label> nextCell;
577 PackedBoolList visited(cellCellAddressing.size());
579 label cellInOrder = 0;
584 DynamicList<label> nbrs;
586 DynamicList<label> weights;
596 label currentCell = -1;
602 if (!cellRemoved(celli) && !visited[celli])
604 if (cellCellAddressing[celli].size() < minWeight)
606 minWeight = cellCellAddressing[celli].size();
613 if (currentCell == -1)
623 nextCell.append(currentCell);
630 while (nextCell.size())
632 currentCell = nextCell.removeHead();
634 if (!visited[currentCell])
636 visited[currentCell] = 1;
639 newOrder[cellInOrder] = currentCell;
643 const labelUList neighbours = cellCellAddressing[currentCell];
653 label nbr = neighbours[nI];
654 if (!cellRemoved(nbr) && !visited[nbr])
658 weights.append(cellCellAddressing[nbr].size());
666 nextCell.append(nbrs[i]);
673 newOrder.setSize(cellInOrder);
676 oldToNew =
invert(cellCellAddressing.size(), newOrder);
682 void Foam::polyTopoChange::getFaceOrder
684 const label nActiveFaces,
693 oldToNew.setSize(faceOwner_.size());
704 label startOfCell = cellFaceOffsets[celli];
705 label nFaces = cellFaceOffsets[celli+1] - startOfCell;
711 for (
label i = 0; i < nFaces; i++)
713 label facei = cellFaces[startOfCell + i];
715 label nbrCelli = faceNeighbour_[facei];
717 if (facei >= nActiveFaces)
722 else if (nbrCelli != -1)
725 if (nbrCelli == celli)
727 nbrCelli = faceOwner_[facei];
730 if (celli < nbrCelli)
749 order.setSize(nFaces);
763 if (nbr[index] != -1)
765 oldToNew[cellFaces[startOfCell + index]] = newFacei++;
772 patchStarts.setSize(nPatches_);
774 patchSizes.setSize(nPatches_);
779 patchStarts[0] = newFacei;
781 for (
label facei = 0; facei < nActiveFaces; facei++)
783 if (region_[facei] >= 0)
785 patchSizes[region_[facei]]++;
789 label facei = patchStarts[0];
793 patchStarts[
patchi] = facei;
794 facei += patchSizes[
patchi];
800 for (
label facei = 0; facei < nActiveFaces; facei++)
802 if (region_[facei] >= 0)
804 oldToNew[facei] = workPatchStarts[region_[facei]]++;
809 for (
label facei = nActiveFaces; facei < oldToNew.size(); facei++)
811 oldToNew[facei] = facei;
817 if (oldToNew[facei] == -1)
820 <<
"Did not determine new position"
821 <<
" for face " << facei
822 <<
" owner " << faceOwner_[facei]
823 <<
" neighbour " << faceNeighbour_[facei]
824 <<
" region " << region_[facei] <<
endl
825 <<
"This is usually caused by not specifying a patch for"
826 <<
" a boundary face." <<
nl
827 <<
"Switch on the polyTopoChange::debug flag to catch"
828 <<
" this error earlier." <<
nl;
829 if (hasValidPoints(faces_[facei]))
832 <<
"points (removed points marked with "
833 <<
vector::max <<
") " << facePoints(faces_[facei]);
841 void Foam::polyTopoChange::reorderCompactFaces
848 faces_.setCapacity(newSize);
851 region_.setCapacity(newSize);
854 faceOwner_.setCapacity(newSize);
856 reorder(oldToNew, faceNeighbour_);
857 faceNeighbour_.setCapacity(newSize);
861 faceMap_.setCapacity(newSize);
863 renumberReverseMap(oldToNew, reverseFaceMap_);
866 flipFaceFlux_.setCapacity(newSize);
870 void Foam::polyTopoChange::compact
872 const bool orderCells,
873 const bool orderPoints,
874 label& nInternalPoints,
881 reversePointMap_.shrink();
886 faceNeighbour_.shrink();
888 reverseFaceMap_.shrink();
891 reverseCellMap_.shrink();
895 label nActivePoints = 0;
897 labelList localPointMap(points_.size(), -1);
902 nInternalPoints = -1;
906 if (!pointRemoved(pointi) && !retiredPoints_.found(pointi))
917 if (!pointRemoved(pointi) && !retiredPoints_.found(pointi))
929 && faceOwner_[facei] >= 0
930 && faceNeighbour_[facei] < 0
934 const face&
f = faces_[facei];
940 if (localPointMap[pointi] == -1)
945 || retiredPoints_.found(pointi)
949 <<
"Removed or retired point " << pointi
951 <<
" at position " << facei <<
endl
952 <<
"Probably face has not been adapted for"
962 nInternalPoints = nActivePoints - nBoundaryPoints;
965 forAll(localPointMap, pointi)
967 if (localPointMap[pointi] != -1)
969 localPointMap[pointi] += nInternalPoints;
981 && faceOwner_[facei] >= 0
982 && faceNeighbour_[facei] >= 0
986 const face&
f = faces_[facei];
992 if (localPointMap[pointi] == -1)
997 || retiredPoints_.found(pointi)
1001 <<
"Removed or retired point " << pointi
1003 <<
" at position " << facei <<
endl
1004 <<
"Probably face has not been adapted for"
1023 localPointMap[iter.key()] =
newPointi++;
1029 Pout<<
"Points : active:" << nActivePoints
1033 reorder(localPointMap, points_);
1037 reorder(localPointMap, pointMap_);
1039 renumberReverseMap(localPointMap, reversePointMap_);
1041 renumberKey(localPointMap, oldPoints_);
1042 renumber(localPointMap, retiredPoints_);
1047 face&
f = faces_[facei];
1050 renumberCompact(localPointMap,
f);
1052 if (!faceRemoved(facei) &&
f.
size() < 3)
1055 <<
"Created illegal face " <<
f
1057 <<
" at position:" << facei
1058 <<
" when filtering removed points"
1067 labelList localFaceMap(faces_.size(), -1);
1072 if (!faceRemoved(facei) && faceOwner_[facei] >= 0)
1074 localFaceMap[facei] = newFacei++;
1077 nActiveFaces_ = newFacei;
1081 if (!faceRemoved(facei) && faceOwner_[facei] < 0)
1084 localFaceMap[facei] = newFacei++;
1090 Pout<<
"Faces : active:" << nActiveFaces_
1091 <<
" removed:" << faces_.size()-newFacei <<
endl;
1095 reorderCompactFaces(newFacei, localFaceMap);
1106 CompactListList<label> cellCells;
1107 makeCellCells(nActiveFaces_, cellCells);
1110 newCelli = getCellOrder(cellCells, localCellMap);
1115 localCellMap.setSize(cellMap_.size());
1121 if (!cellRemoved(celli))
1123 localCellMap[celli] = newCelli++;
1130 Pout<<
"Cells : active:" << newCelli
1131 <<
" removed:" << cellMap_.size()-newCelli <<
endl;
1135 if (orderCells || (newCelli != cellMap_.size()))
1137 reorder(localCellMap, cellMap_);
1138 cellMap_.setCapacity(newCelli);
1139 renumberReverseMap(localCellMap, reverseCellMap_);
1143 forAll(faceOwner_, facei)
1145 label own = faceOwner_[facei];
1146 label nei = faceNeighbour_[facei];
1151 faceOwner_[facei] = localCellMap[own];
1156 faceNeighbour_[facei] = localCellMap[nei];
1161 faceNeighbour_[facei] >= 0
1162 && faceNeighbour_[facei] < faceOwner_[facei]
1165 faces_[facei].flip();
1166 Swap(faceOwner_[facei], faceNeighbour_[facei]);
1167 flipFaceFlux_[facei] =
1169 flipFaceFlux_[facei]
1179 faceNeighbour_[facei] = localCellMap[nei];
1190 makeCells(nActiveFaces_, cellFaces, cellFaceOffsets);
1206 reorderCompactFaces(localFaceMap.size(), localFaceMap);
1213 const primitiveMesh& mesh,
1215 const bool internalFacesOnly
1222 label facei = faceLabels[i];
1224 if (internalFacesOnly == mesh.isInternalFace(facei))
1236 collectedFaces = faceLabels;
1240 collectedFaces.
setSize(nFaces);
1246 label facei = faceLabels[i];
1248 if (internalFacesOnly == mesh.isInternalFace(facei))
1250 collectedFaces[nFaces++] = facei;
1255 return collectedFaces;
1259 void Foam::polyTopoChange::calcPatchPointMap
1261 const List<Map<label>>& oldPatchMeshPointMaps,
1272 const Map<label>& oldMeshPointMap = oldPatchMeshPointMaps[
patchi];
1276 curPatchPointRnb.
setSize(meshPoints.size());
1280 if (meshPoints[i] < pointMap_.size())
1285 pointMap_[meshPoints[i]]
1288 if (ozmpmIter != oldMeshPointMap.end())
1290 curPatchPointRnb[i] = ozmpmIter();
1294 curPatchPointRnb[i] = -1;
1299 curPatchPointRnb[i] = -1;
1306 void Foam::polyTopoChange::reorderCoupledFaces
1308 const bool syncParallel,
1348 pBufs.finishedSends();
1353 bool anyChanged =
false;
1384 forAll(patchFaceMap, patchFacei)
1386 oldToNew[patchFacei + start] =
1387 start + patchFaceMap[patchFacei];
1390 forAll(patchFaceRotation, patchFacei)
1392 rotation[patchFacei + start] =
1393 patchFaceRotation[patchFacei];
1403 reduce(anyChanged, orOp<bool>());
1409 reorderCompactFaces(oldToNew.size(), oldToNew);
1414 if (rotation[facei] != 0)
1416 inplaceRotateList<List, label>(faces_[facei], rotation[facei]);
1423 void Foam::polyTopoChange::compactAndReorder
1425 const polyMesh& mesh,
1426 const bool syncParallel,
1427 const bool orderCells,
1428 const bool orderPoints,
1430 label& nInternalPoints,
1434 List<objectMap>& pointsFromPoints,
1435 List<objectMap>& facesFromFaces,
1436 List<objectMap>& cellsFromCells,
1437 List<Map<label>>& oldPatchMeshPointMaps,
1443 if (mesh.boundaryMesh().size() != nPatches_)
1446 <<
"polyTopoChange was constructed with a mesh with "
1447 << nPatches_ <<
" patches." <<
endl
1448 <<
"The mesh now provided has a different number of patches "
1449 << mesh.boundaryMesh().size()
1450 <<
" which is illegal" <<
endl
1456 compact(orderCells, orderPoints, nInternalPoints, patchSizes, patchStarts);
1460 newPoints.transfer(points_);
1466 mesh.boundaryMesh(),
1505 const polyBoundaryMesh&
boundary = mesh.boundaryMesh();
1531 reversePointMap_(0),
1554 nPatches_(mesh.boundaryMesh().size()),
1557 reversePointMap_(0),
1576 points_.setCapacity(points_.size() +
points.size());
1582 for (
label pointi = 0; pointi < mesh.
nPoints(); pointi++)
1600 for (
label celli = 0; celli < nAllCells; celli++)
1616 faces_.setCapacity(faces_.size() + nAllFaces);
1622 flipFaceFlux_.
setCapacity(faces_.size() + nAllFaces);
1646 if (pp.
start() != faces_.size())
1650 <<
"Patch " << pp.
name() <<
" starts at " << pp.
start()
1652 <<
"Current face counter at " << faces_.size() <<
endl
1653 <<
"Are patches in incremental order?"
1679 points_.clearStorage();
1680 pointMap_.clearStorage();
1681 reversePointMap_.clearStorage();
1682 retiredPoints_.clearStorage();
1683 oldPoints_.clearStorage();
1685 faces_.clearStorage();
1686 region_.clearStorage();
1687 faceOwner_.clearStorage();
1688 faceNeighbour_.clearStorage();
1689 faceMap_.clearStorage();
1690 reverseFaceMap_.clearStorage();
1691 flipFaceFlux_.clearStorage();
1694 cellMap_.clearStorage();
1695 reverseCellMap_.clearStorage();
1707 pointMap_.setCapacity(
nPoints);
1708 reversePointMap_.setCapacity(
nPoints);
1710 faces_.setCapacity(nFaces);
1711 region_.setCapacity(nFaces);
1712 faceOwner_.setCapacity(nFaces);
1713 faceNeighbour_.setCapacity(nFaces);
1714 faceMap_.setCapacity(nFaces);
1715 reverseFaceMap_.setCapacity(nFaces);
1716 flipFaceFlux_.setCapacity(nFaces);
1718 cellMap_.setCapacity(nCells);
1719 reverseCellMap_.setCapacity(nCells);
1726 const label masterPointID,
1730 label pointi = points_.size();
1733 pointMap_.append(masterPointID);
1734 reversePointMap_.append(pointi);
1738 retiredPoints_.insert(pointi);
1752 if (pointi < 0 || pointi >= points_.size())
1755 <<
"illegal point label " << pointi <<
endl
1756 <<
"Valid point labels are 0 .. " << points_.size()-1
1759 if (pointRemoved(pointi) || pointMap_[pointi] == -1)
1762 <<
"point " << pointi <<
" already marked for removal"
1765 points_[pointi] = pt;
1769 retiredPoints_.erase(pointi);
1773 retiredPoints_.insert(pointi);
1776 oldPoints_.erase(pointi);
1783 const label mergePointi
1786 if (pointi < 0 || pointi >= points_.size())
1789 <<
"illegal point label " << pointi <<
endl
1790 <<
"Valid point labels are 0 .. " << points_.size()-1
1797 && (pointRemoved(pointi) || pointMap_[pointi] == -1)
1801 <<
"point " << pointi <<
" already marked for removal" <<
nl
1802 <<
"Point:" << points_[pointi] <<
" pointMap:" << pointMap_[pointi]
1806 if (pointi == mergePointi)
1809 <<
"Cannot remove/merge point " << pointi <<
" onto itself."
1814 pointMap_[pointi] = -1;
1815 if (mergePointi >= 0)
1817 reversePointMap_[pointi] = -mergePointi-2;
1821 reversePointMap_[pointi] = -1;
1823 retiredPoints_.erase(pointi);
1824 oldPoints_.erase(pointi);
1833 const label masterFaceID,
1834 const bool flipFaceFlux,
1841 checkFace(
f, -1, own, nei, patchID);
1844 label facei = faces_.size();
1847 region_.append(patchID);
1848 faceOwner_.append(own);
1849 faceNeighbour_.append(nei);
1851 if (masterFaceID >= 0)
1853 faceMap_.append(masterFaceID);
1862 faceMap_.append(-1);
1864 reverseFaceMap_.append(facei);
1866 flipFaceFlux_[facei] = (flipFaceFlux ? 1 : 0);
1878 const bool flipFaceFlux,
1885 checkFace(
f, facei, own, nei, patchID);
1889 faceOwner_[facei] = own;
1890 faceNeighbour_[facei] = nei;
1891 region_[facei] = patchID;
1893 flipFaceFlux_[facei] = (flipFaceFlux ? 1 : 0);
1899 if (facei < 0 || facei >= faces_.size())
1902 <<
"illegal face label " << facei <<
endl
1903 <<
"Valid face labels are 0 .. " << faces_.size()-1
1910 && (faceRemoved(facei) || faceMap_[facei] == -1)
1915 <<
" already marked for removal"
1919 faces_[facei].setSize(0);
1920 region_[facei] = -1;
1921 faceOwner_[facei] = -1;
1922 faceNeighbour_[facei] = -1;
1923 faceMap_[facei] = -1;
1924 if (mergeFacei >= 0)
1926 reverseFaceMap_[facei] = -mergeFacei-2;
1930 reverseFaceMap_[facei] = -1;
1932 flipFaceFlux_[facei] = 0;
1938 const label celli = cellMap_.size();
1939 cellMap_.append(masterCellID);
1940 reverseCellMap_.append(celli);
1948 if (celli < 0 || celli >= cellMap_.size())
1951 <<
"illegal cell label " << celli <<
endl
1952 <<
"Valid cell labels are 0 .. " << cellMap_.size()-1
1956 if (strict_ && cellMap_[celli] == -2)
1960 <<
" already marked for removal"
1964 cellMap_[celli] = -2;
1965 if (mergeCelli >= 0)
1967 reverseCellMap_[celli] = -mergeCelli-2;
1971 reverseCellMap_[celli] = -1;
1979 const bool syncParallel,
1980 const bool orderCells,
1981 const bool orderPoints
1986 Pout<<
"polyTopoChange::changeMesh"
1987 <<
"(polyMesh&, const bool, const bool, const bool, const bool)"
1993 Pout<<
"Old mesh:" <<
nl;
1994 writeMeshStats(mesh,
Pout);
2001 label nInternalPoints;
2033 oldPatchMeshPointMaps,
2034 oldPatchNMeshPoints,
2056 move(faceNeighbour_),
2064 retiredPoints_.clearStorage();
2065 oldPoints_.clearStorage();
2066 region_.clearStorage();
2073 label nSplit, nInserted, nMerge, nRemove;
2084 <<
" added(from point):" << nSplit
2085 <<
" added(from nothing):" << nInserted
2086 <<
" merged(into other point):" << nMerge
2087 <<
" removed:" << nRemove
2090 countMap(faceMap_, reverseFaceMap_, nSplit, nInserted, nMerge, nRemove);
2092 <<
" added(from face):" << nSplit
2093 <<
" added(from nothing):" << nInserted
2094 <<
" merged(into other face):" << nMerge
2095 <<
" removed:" << nRemove
2098 countMap(cellMap_, reverseCellMap_, nSplit, nInserted, nMerge, nRemove);
2100 <<
" added(from cell):" << nSplit
2101 <<
" added(from nothing):" << nInserted
2102 <<
" merged(into other cell):" << nMerge
2103 <<
" removed:" << nRemove
2110 Pout<<
"New mesh:" <<
nl;
2111 writeMeshStats(mesh,
Pout);
2121 oldPatchMeshPointMaps,
2126 labelHashSet flipFaceFluxSet(getSetIndices(flipFaceFlux_));
2138 move(pointsFromPoints),
2141 move(facesFromFaces),
2144 move(cellsFromCells),
2146 move(reversePointMap_),
2147 move(reverseFaceMap_),
2148 move(reverseCellMap_),
2150 move(flipFaceFluxSet),
2152 move(patchPointMap),
2154 move(oldPatchSizes),
2155 move(oldPatchStarts),
2156 move(oldPatchNMeshPoints),
2158 move(oldCellVolumes)
2172 const bool syncParallel,
2173 const bool orderCells,
2174 const bool orderPoints
2179 Pout<<
"polyTopoChange::makeMesh"
2180 <<
"(autoPtr<fvMesh>&, const IOobject&, const fvMesh&"
2181 <<
", const bool, const bool, const bool)"
2187 Pout<<
"Old mesh:" <<
nl;
2188 writeMeshStats(mesh,
Pout);
2194 label nInternalPoints;
2224 oldPatchMeshPointMaps,
2225 oldPatchNMeshPoints,
2249 move(faceNeighbour_)
2252 fvMesh& newMesh = newMeshPtr();
2256 retiredPoints_.clearStorage();
2257 oldPoints_.clearStorage();
2258 region_.clearStorage();
2265 label nSplit, nInserted, nMerge, nRemove;
2277 <<
" added(from point):" << nSplit
2278 <<
" added(from nothing):" << nInserted
2279 <<
" merged(into other point):" << nMerge
2280 <<
" removed:" << nRemove
2283 countMap(faceMap_, reverseFaceMap_, nSplit, nInserted, nMerge, nRemove);
2285 <<
" added(from face):" << nSplit
2286 <<
" added(from nothing):" << nInserted
2287 <<
" merged(into other face):" << nMerge
2288 <<
" removed:" << nRemove
2291 countMap(cellMap_, reverseCellMap_, nSplit, nInserted, nMerge, nRemove);
2293 <<
" added(from cell):" << nSplit
2294 <<
" added(from nothing):" << nInserted
2295 <<
" merged(into other cell):" << nMerge
2296 <<
" removed:" << nRemove
2354 newMesh.
addZones(pZonePtrs, fZonePtrs, cZonePtrs);
2362 oldPatchMeshPointMaps,
2369 Pout<<
"New mesh:" <<
nl;
2370 writeMeshStats(mesh,
Pout);
2373 labelHashSet flipFaceFluxSet(getSetIndices(flipFaceFlux_));
2385 move(pointsFromPoints),
2388 move(facesFromFaces),
2391 move(cellsFromCells),
2393 move(reversePointMap_),
2394 move(reverseFaceMap_),
2395 move(reverseCellMap_),
2397 move(flipFaceFluxSet),
2399 move(patchPointMap),
2401 move(oldPatchSizes),
2402 move(oldPatchStarts),
2403 move(oldPatchNMeshPoints),
2405 move(oldCellVolumes)
Various functions to operate on Lists.
#define forAll(list, i)
Loop across all elements in list.
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object of type.
void setCapacity(const label)
Alter the size of the underlying storage.
friend class const_iterator
Declare friendship with the const_iterator.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
readOption readOpt() const
autoPtr< IOobject > clone() const
Clone.
void size(const label)
Override size to be inconsistent with allocated storage.
void setSize(const label)
Reset size of List.
void setCapacity(const label)
Alter the size of the underlying storage.
label size() const
Return the number of elements in the UPtrList.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
void reset(T *=nullptr)
If object pointer already set, delete object and set to given.
A face is a list of labels corresponding to mesh vertices.
Mesh data needed to do the Finite Volume discretisation.
void addFvPatches(const List< polyPatch * > &, const bool validBoundary=true)
Add boundary patches. Constructor helper.
const word & name() const
Return name.
Mesh consisting of general polyhedral cells.
const pointZoneList & pointZones() const
Return point zones.
const cellZoneList & cellZones() const
Return cell zones.
virtual const faceList & faces() const
Return raw faces.
void resetPrimitives(pointField &&points, faceList &&faces, labelList &&owner, labelList &&neighbour, const labelList &patchSizes, const labelList &patchStarts, const bool validBoundary=true)
Reset mesh primitive data. Assumes all patch info correct.
virtual const labelList & faceOwner() const
Return face owner.
const faceZoneList & faceZones() const
Return face zones.
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
virtual const labelList & faceNeighbour() const
Return face neighbour.
void addZones(const List< pointZone * > &pz, const List< faceZone * > &fz, const List< cellZone * > &cz)
Add mesh zones.
virtual const pointField & points() const
Return raw points.
A patch is a list of labels that address the faces in the global face list.
label start() const
Return start label of this patch in the polyMesh face list.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Direct mesh changes based on v1.3 polyTopoChange syntax.
void modifyPoint(const label, const point &, const bool inCell)
Modify coordinate.
void removePoint(const label, const label)
Remove point / merge points.
autoPtr< polyTopoChangeMap > makeMesh(autoPtr< fvMesh > &newMesh, const IOobject &io, const polyMesh &mesh, const bool syncParallel=true, const bool orderCells=false, const bool orderPoints=false)
Create new mesh with old mesh patches.
polyTopoChange(const label nPatches, const bool strict=true)
Construct without mesh. Either specify nPatches or use.
const DynamicList< face > & faces() const
const DynamicList< point > & points() const
Points. Shrunk after constructing mesh (or calling of compact())
void removeFace(const label, const label)
Remove face / merge faces.
void setCapacity(const label nPoints, const label nFaces, const label nCells)
Explicitly pre-size the dynamic storage for expected mesh.
label addCell(const label masterCellID)
Add cell and return new cell index.
const DynamicList< label > & faceOwner() const
autoPtr< polyTopoChangeMap > changeMesh(polyMesh &mesh, const bool syncParallel=true, const bool orderCells=false, const bool orderPoints=false)
Inplace changes mesh without change of patches.
const DynamicList< label > & faceNeighbour() const
label addPoint(const point &, const label masterPointID, const bool inCell)
Add point and return new point index.
void clear()
Clear all storage.
void removeCell(const label, const label)
Remove cell / merge cells.
void modifyFace(const face &f, const label facei, const label own, const label nei, const bool flipFaceFlux, const label patchID)
Modify vertices or cell of face.
label addFace(const face &f, const label own, const label nei, const label masterFaceID, const bool flipFaceFlux, const label patchID)
Add face to cells and return new face index.
const scalarField & cellVolumes() const
label nInternalFaces() const
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
const fvPatchList & patches
errorManipArg< error, int > exit(error &err, const int errNo=1)
List< label > labelList
A List of labels.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Ostream & endl(Ostream &os)
Add newline and flush stream.
labelList invert(const label len, const labelUList &)
Invert one-to-one map. Unmapped elements will be -1.
int order(const scalar s)
errorManip< error > abort(error &err)
ListType renumber(const labelUList &oldToNew, const ListType &)
Renumber the values (not the indices) of a list.
vectorField pointField
pointField is a vectorField.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
PrimitivePatch< SubList< face >, const pointField & > primitivePatch
Addressing for a faceList slice.
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
ListType reorder(const label size, const typename ListType::value_type &defaultValue, const labelUList &oldToNew, const ListType &lst)
List< labelList > labelListList
A List of labelList.
defineTypeNameAndDebug(combustionModel, 0)
prefixOSstream Pout(cout, "Pout")
HashSet< label, Hash< label > > labelHashSet
A HashSet with label keys.
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurrence of given element and return index,.
static const label labelMax
labelList identityMap(const label len)
Create identity map (map[i] == i) of given length.
void sortedOrder(const UList< T > &, labelList &order)
Generate the (stable) sort order for the list.
UList< label > labelUList
void inplaceReorder(const labelUList &oldToNew, ListType &)
Inplace reorder the elements of a list.
faceListList boundary(nPatches)