87 Foam::label Foam::addPatchCellLayer::nbrFace
94 const labelList& eFaces = edgeFaces[edgei];
96 if (eFaces.size() == 2)
98 return (eFaces[0] != facei ? eFaces[0] : eFaces[1]);
107 void Foam::addPatchCellLayer::addVertex
120 if (
f[fp-1] != pointi &&
f[0] != pointi)
130 bool Foam::addPatchCellLayer::sameEdgeNeighbour
135 const label thisGlobalFacei,
136 const label nbrGlobalFacei,
140 const edge&
e = pp.edges()[edgei];
145 addedPoints_[
e[0]].size()
146 || addedPoints_[
e[1]].size()
149 nbrFace(globalEdgeFaces, edgei, thisGlobalFacei)
163 const label patchFacei,
164 const label globalFacei
167 const labelList& fEdges = pp.faceEdges()[patchFacei];
175 label edgei = fEdges[fp];
176 const edge&
e = pp.edges()[edgei];
181 && ( addedPoints_[
e[0]].size() || addedPoints_[
e[1]].size() )
193 label nbrGlobalFacei = nbrFace
200 if (nbrGlobalFacei == -1)
212 const label initFp = startFp;
215 label prevFp = fEdges.rcIndex(startFp);
217 if (prevFp == initFp)
219 const edge&
e = pp.edges()[fEdges[initFp]];
220 const face& localF = pp.localFaces()[patchFacei];
223 <<
"On face:" << patchFacei
224 <<
" fc:" << pp.faceCentres()[patchFacei]
225 <<
" vertices:" << localF
227 << UIndirectList<point>(pp.points(), pp[patchFacei])
228 <<
" edges:" << fEdges
229 <<
" All edges of face seem to have same neighbour " 231 <<
" starting walking from edge " <<
e 257 label nextFp = fEdges.fcIndex(endFp);
283 Foam::label Foam::addPatchCellLayer::addSideFace
288 const label newPatchID,
291 const label inflateFacei,
293 const label ownFacei,
294 const label nbrFacei,
295 const label meshEdgei,
297 const label numEdgeFaces,
299 polyTopoChange& meshMod
304 label addedFacei = -1;
318 if (addedCells[ownFacei].size() < numEdgeFaces)
320 label offset = numEdgeFaces - addedCells[ownFacei].size();
321 if (layeri <= offset)
327 layerOwn = layeri - offset;
343 addedFacei = meshMod.setAction
348 addedCells[ownFacei][layerOwn],
370 if (addedCells[ownFacei].size() > addedCells[nbrFacei].size())
373 addedCells[ownFacei].size() - addedCells[nbrFacei].size();
377 if (layeri <= offset)
383 layerNbr = layeri - offset;
386 else if (addedCells[nbrFacei].size() > addedCells[ownFacei].size())
389 addedCells[nbrFacei].size() - addedCells[ownFacei].size();
393 if (layeri <= offset)
399 layerOwn = layeri - offset;
411 label inflateEdgei = -1;
416 if (mesh_.isInternalFace(meshFaces[i]))
419 inflateEdgei = meshEdgei;
426 addedFacei = meshMod.setAction
431 addedCells[ownFacei][layerOwn],
432 addedCells[nbrFacei][layerNbr],
455 Foam::label Foam::addPatchCellLayer::findProcPatch
457 const polyMesh&
mesh,
458 const label nbrProcID
469 refCast<const processorPolyPatch>(
patches[patchi]).neighbProcNo()
480 void Foam::addPatchCellLayer::setFaceProps
482 const polyMesh&
mesh,
500 void Foam::addPatchCellLayer::setFaceProps
502 const polyMesh&
mesh,
523 if (patchI != -1 || zoneI != -1)
525 inflateFaceI = faceI;
531 const edge& ppEdge = pp.edges()[ppEdgeI];
534 pp.meshPoints()[ppEdge[0]],
535 pp.meshPoints()[ppEdge[1]]
542 const edge
e(
f[fp],
f.nextLabel(fp));
552 zoneFlip = !zoneFlip;
561 <<
"Problem: cannot find patch edge " << ppEdgeI
562 <<
" with mesh vertices " << patchEdge
564 <<
" in face " << faceI <<
" with mesh vertices " 568 <<
"Continuing with potentially incorrect faceZone orientation" 576 void Foam::addPatchCellLayer::findZoneFace
578 const bool useInternalFaces,
579 const bool useBoundaryFaces,
581 const polyMesh&
mesh,
600 label faceI = meshFaces[
k];
604 !excludeFaces.found(faceI)
624 if (zoneI != -1 || patchI != -1)
636 Foam::addPatchCellLayer::addPatchCellLayer
643 addToMesh_(addToMesh),
659 forAll(layerFaces, patchFacei)
661 const labelList& faceLabels = layerFaces[patchFacei];
663 if (faceLabels.
size())
665 labelList& added = layerCells[patchFacei];
668 for (label i = 0; i < faceLabels.
size()-1; i++)
680 return addedCells(mesh_, layerFaces_);
702 label meshEdgeI = meshEdges[edgeI];
704 const labelList& eFaces = edgeFaces[edgeI];
707 labelList& globalEFaces = globalEdgeFaces[meshEdgeI];
711 globalEFaces[i] = globalFaces.
toGlobal(pp.addressing()[eFaces[i]]);
720 ListOps::uniqueEqOp<label>(),
725 return labelListList(UIndirectList<labelList>(globalEdgeFaces, meshEdges));
729 void Foam::addPatchCellLayer::markPatchEdges
731 const polyMesh&
mesh,
737 bitSet& isPatchBoundaryEdge
746 isPatchEdge.set(meshEdges);
752 orEqOp<unsigned int>(),
757 isPatchBoundaryEdge =
false;
758 forAll(edgeGlobalFaces, edgei)
764 if (edgeGlobalFaces[edgei].size() == 1)
766 isPatchBoundaryEdge.set(meshEdges[edgei]);
774 orEqOp<unsigned int>(),
780 void Foam::addPatchCellLayer::globalEdgeInfo
782 const bool zoneFromAnyFace,
784 const polyMesh&
mesh,
785 const globalIndex& globalFaces,
793 bitSet& patchEdgeToFlip
800 bitSet isExtrudeEdge;
801 bitSet isBoundaryEdge;
815 EdgeMap<label> isBoundaryEdgeSet(pp.nEdges());
816 for (
const label edgei : isBoundaryEdge)
818 isBoundaryEdgeSet.insert(
mesh.
edges()[edgei], edgei);
820 EdgeMap<label> isExtrudeEdgeSet(pp.nEdges());
821 for (
const label edgei : isExtrudeEdge)
823 isExtrudeEdgeSet.insert(
mesh.
edges()[edgei], edgei);
832 for (
const faceZone& fz: fzs)
835 UIndirectList<label>(faceToZone, addressing) = fz.index();
840 faceToFlip[addressing[i]] = fm[i];
857 const bitSet isInternalOrCoupled
865 for (
const label facei : isInternalOrCoupled)
869 label prevPointi =
f.
last();
870 for (
const label pointi :
f)
872 const edge
e(prevPointi, pointi);
876 const auto eFnd = isExtrudeEdgeSet.cfind(
e);
879 const label edgei = eFnd();
881 if (faceToZone[facei] != -1)
884 meshEdgeToFace[edgei] = globalFaces.toGlobal(facei);
885 meshEdgeToZone[edgei] = faceToZone[facei];
890 meshEdgeToFlip[edgei] = faceToFlip[facei];
894 meshEdgeToFlip[edgei] = !faceToFlip[facei];
920 isPpFace.
set(pp.addressing());
923 for (
const polyPatch& pp :
patches)
933 const label facei = pp.start()+i;
935 if (!isPpFace[facei])
937 const face&
f = pp[i];
939 label prevPointi =
f.
last();
940 for (
const label pointi :
f)
942 const edge
e(prevPointi, pointi);
946 ? isExtrudeEdgeSet.cfind(
e)
947 : isBoundaryEdgeSet.cfind(
e)
951 const label edgei = eFnd();
952 if (meshEdgeToFace[edgei] == -1)
959 meshEdgeToFace[edgei] =
960 globalFaces.toGlobal(facei);
965 if (meshEdgeToPatch[edgei] == -1)
967 meshEdgeToPatch[edgei] = pp.index();
971 if (meshEdgeToZone[edgei] == -1)
973 meshEdgeToZone[edgei] =
979 meshEdgeToFlip[edgei] =
984 meshEdgeToFlip[edgei] =
1112 orEqOp<unsigned int>(),
1117 patchEdgeToFace = UIndirectList<label>(meshEdgeToFace, meshEdges);
1118 patchEdgeToPatch = UIndirectList<label>(meshEdgeToPatch, meshEdges);
1119 patchEdgeToZone = UIndirectList<label>(meshEdgeToZone, meshEdges);
1120 patchEdgeToFlip.setSize(meshEdges.size());
1121 patchEdgeToFlip =
false;
1124 patchEdgeToFlip[i] = meshEdgeToFlip[meshEdges[i]];
1131 const bool zoneFromAnyFace,
1133 const polyMesh&
mesh,
1134 const globalIndex& globalFaces,
1140 Map<label>& nbrProcToPatch,
1141 Map<label>& patchToNbrProc,
1153 edgePatchID.setSize(pp.nEdges());
1156 edgeZoneID.setSize(pp.nEdges());
1158 edgeFlip.setSize(pp.nEdges());
1160 inflateFaceID.setSize(pp.nEdges(), -1);
1176 forAll(globalEdgeFaces, edgei)
1178 const labelList& eGlobalFaces = globalEdgeFaces[edgei];
1181 eGlobalFaces.size() == 2
1182 && pp.edgeFaces()[edgei].size() == 1
1188 label f0 = eGlobalFaces[0];
1189 label f1 = eGlobalFaces[1];
1191 label otherProci = -1;
1192 if (globalFaces.isLocal(f0) && !globalFaces.isLocal(f1))
1194 otherProci = globalFaces.whichProcID(f1);
1196 else if (!globalFaces.isLocal(f0) && globalFaces.isLocal(f1))
1198 otherProci = globalFaces.whichProcID(f0);
1202 if (otherProci != -1)
1207 gd.topology().procPatchLookup(otherProci);
1213 procPatchi = nbrProcToPatch.lookup(otherProci, -1);
1222 nbrProcToPatch.insert(otherProci, procPatchi);
1223 patchToNbrProc.insert(procPatchi, otherProci);
1227 edgePatchID[edgei] = procPatchi;
1259 DynamicList<label> dynMeshEdgeFaces;
1263 if (edgePatchID[edgei] == -1)
1265 if (edgeFaces[edgei].size() == 2)
1270 if (globalFaces.isLocal(edgeToFace[edgei]))
1272 inflateFaceID[edgei] =
1273 globalFaces.toLocal(edgeToFace[edgei]);
1275 edgeZoneID[edgei] = edgeToZone[edgei];
1276 edgeFlip[edgei] = edgeToFlip[edgei];
1283 if (globalFaces.isLocal(edgeToFace[edgei]))
1285 inflateFaceID[edgei] =
1286 globalFaces.toLocal(edgeToFace[edgei]);
1288 edgePatchID[edgei] = edgeToPatch[edgei];
1289 edgeZoneID[edgei] = edgeToZone[edgei];
1290 edgeFlip[edgei] = edgeToFlip[edgei];
1302 if (edgeFaces[edgei].size() == 1 && edgePatchID[edgei] == -1)
1304 const edge&
e = pp.edges()[edgei];
1306 <<
"Have no sidePatchID for edge " << edgei <<
" points " 1307 << pp.points()[pp.meshPoints()[
e[0]]]
1308 << pp.points()[pp.meshPoints()[
e[1]]]
1322 edgeFaces[edgei].size() == 1
1323 && globalEdgeFaces[edgei].size() == 2
1324 && edgePatchID[edgei] != -1
1325 && inflateFaceID[edgei] == -1
1330 label myFaceI = pp.addressing()[edgeFaces[edgei][0]];
1333 label meshEdgei = meshEdges[edgei];
1342 label facei = meshFaces[
k];
1358 inflateFaceID[edgei]
1383 bitSet sameEdgeOrientation;
1394 labelList cppEdgeZoneID(cpp.nEdges(), -1);
1395 boolList cppEdgeFlip(cpp.nEdges(),
false);
1398 label cppEdgei = coupledEdges[i];
1399 label ppEdgei = patchEdges[i];
1401 cppEdgeZoneID[cppEdgei] = edgeZoneID[ppEdgei];
1402 if (sameEdgeOrientation[i])
1404 cppEdgeFlip[cppEdgei] = edgeFlip[ppEdgei];
1408 cppEdgeFlip[cppEdgei] = !edgeFlip[ppEdgei];
1413 const globalIndexAndTransform& git = gd.globalTransforms();
1414 const mapDistribute& edgeMap = gd.globalEdgeSlavesMap();
1419 gd.globalEdgeSlaves(),
1420 gd.globalEdgeTransformedSlaves(),
1429 gd.globalEdgeSlaves(),
1430 gd.globalEdgeTransformedSlaves(),
1440 label cppEdgei = coupledEdges[i];
1441 label ppEdgei = patchEdges[i];
1443 edgeZoneID[ppEdgei] = cppEdgeZoneID[cppEdgei];
1444 if (sameEdgeOrientation[i])
1446 edgeFlip[ppEdgei] = cppEdgeFlip[cppEdgei];
1450 edgeFlip[ppEdgei] = !cppEdgeFlip[cppEdgei];
1459 const globalIndex& globalFaces,
1463 const bitSet& ppFlip,
1474 polyTopoChange& meshMod
1479 Pout<<
"addPatchCellLayer::setRefinement : Adding up to " 1480 <<
gMax(nPointLayers)
1481 <<
" layers of cells to indirectPrimitivePatch with " 1482 << pp.nPoints() <<
" points" <<
endl;
1487 pp.nPoints() != firstLayerDisp.size()
1488 || pp.nPoints() != nPointLayers.size()
1489 || pp.size() != nFaceLayers.size()
1490 || pp.size() != ppFlip.size()
1494 <<
"Size of new points is not same as number of points used by" 1495 <<
" the face subset" <<
endl 1496 <<
" patch.nPoints:" << pp.nPoints()
1497 <<
" displacement:" << firstLayerDisp.size()
1498 <<
" nPointLayers:" << nPointLayers.size() <<
nl 1499 <<
" patch.nFaces:" << pp.size()
1500 <<
" flip map:" << ppFlip.size()
1501 <<
" nFaceLayers:" << nFaceLayers.size()
1510 <<
"In generating stand-alone mesh the flip map should be empty" 1511 <<
". Instead it is " << ppFlip.count()
1524 labelList stateAndFlip(mesh_.nBoundaryFaces(), 0);
1525 forAll(pp.addressing(), patchFacei)
1527 if (nFaceLayers[patchFacei] > 0)
1529 const label meshFacei = pp.addressing()[patchFacei];
1530 const label bFacei = meshFacei-mesh_.nInternalFaces();
1533 stateAndFlip[bFacei] = label(ppFlip[patchFacei]);
1538 for (
const auto&
patch : mesh_.boundaryMesh())
1540 if (!
patch.coupled())
1544 label& state = stateAndFlip[
patch.offset()+i];
1545 state = (state == 0 ? 1 : 0);
1551 forAll(pp.addressing(), patchFacei)
1553 if (nFaceLayers[patchFacei] > 0)
1555 const label meshFacei = pp.addressing()[patchFacei];
1556 const label bFacei = meshFacei-mesh_.nInternalFaces();
1559 if (stateAndFlip[bFacei] == -1)
1562 <<
"At extruded face:" << meshFacei
1563 <<
" at:" << mesh_.faceCentres()[meshFacei]
1564 <<
" locally have nLayers:" 1565 << nFaceLayers[patchFacei]
1568 else if (stateAndFlip[bFacei] == label(ppFlip[patchFacei]))
1571 <<
"At extruded face:" << meshFacei
1572 <<
" at:" << mesh_.faceCentres()[meshFacei]
1573 <<
" locally have flip:" << ppFlip[patchFacei]
1574 <<
" which is not the opposite of coupled version " 1575 << stateAndFlip[bFacei]
1586 if (nPointLayers[i] < 0)
1589 <<
"Illegal number of layers " << nPointLayers[i]
1595 if (nFaceLayers[i] < 0)
1598 <<
"Illegal number of layers " << nFaceLayers[i]
1603 forAll(globalEdgeFaces, edgei)
1605 if (globalEdgeFaces[edgei].size() > 2)
1607 const edge&
e = pp.edges()[edgei];
1609 if (nPointLayers[
e[0]] > 0 || nPointLayers[
e[1]] > 0)
1612 <<
"Trying to extrude edge " 1613 <<
e.line(pp.localPoints())
1614 <<
" which is non-manifold (has " 1615 << globalEdgeFaces[edgei].size()
1616 <<
" local or coupled faces using it)" 1618 << pp.edgeFaces()[edgei].size()
1626 const labelList& meshPoints = pp.meshPoints();
1632 bitSet isBlockedFace(mesh_.nFaces());
1633 forAll(nFaceLayers, patchFacei)
1635 if (nFaceLayers[patchFacei] > 0)
1637 isBlockedFace.set(pp.addressing()[patchFacei]);
1642 DynamicList<label> ef;
1645 const labelList meshEdges(pp.meshEdges(mesh_.edges(), mesh_.pointEdges()));
1660 label meshPointi = meshPoints[i];
1662 if (
n[meshPointi] != nPointLayers[i])
1665 <<
"At mesh point:" << meshPointi
1666 <<
" coordinate:" << mesh_.points()[meshPointi]
1667 <<
" specified nLayers:" << nPointLayers[i] <<
endl 1668 <<
"On coupled point a different nLayers:" 1669 <<
n[meshPointi] <<
" was specified." 1680 const face&
f = pp[i];
1684 label pointi =
f[fp];
1686 nFromFace[pointi] =
max(nFromFace[pointi], nFaceLayers[i]);
1699 label meshPointi = meshPoints[i];
1704 && nPointLayers[i] != nFromFace[meshPointi]
1708 <<
"At mesh point:" << meshPointi
1709 <<
" coordinate:" << mesh_.points()[meshPointi]
1710 <<
" specified nLayers:" << nPointLayers[i] <<
endl 1711 <<
"but the max nLayers of surrounding faces is:" 1712 << nFromFace[meshPointi]
1720 UIndirectList<point>(d, meshPoints) = firstLayerDisp;
1731 label meshPointi = meshPoints[i];
1733 if (
mag(d[meshPointi] - firstLayerDisp[i]) > SMALL)
1736 <<
"At mesh point:" << meshPointi
1737 <<
" coordinate:" << mesh_.points()[meshPointi]
1738 <<
" specified displacement:" << firstLayerDisp[i]
1740 <<
"On coupled point a different displacement:" 1741 << d[meshPointi] <<
" was specified." 1753 for (label edgei = pp.nInternalEdges(); edgei < pp.nEdges(); edgei++)
1755 const edge&
e = pp.edges()[edgei];
1757 if (nPointLayers[
e[0]] > 0 || nPointLayers[
e[1]] > 0)
1761 const labelList& eFaces = pp.edgeFaces()[edgei];
1764 if (eFaces.size() != 1)
1767 <<
"boundary-edge-to-be-extruded:" 1768 << pp.points()[meshPoints[
e[0]]]
1769 << pp.points()[meshPoints[
e[1]]]
1770 <<
" has more than two faces using it:" << eFaces
1824 const polyBoundaryMesh&
patches = mesh_.boundaryMesh();
1831 label meshFacei = pp.addressing()[patchFacei];
1839 addedPoints_.setSize(pp.nPoints());
1842 label nTruncated = 0;
1844 forAll(nPointLayers, patchPointi)
1846 if (nPointLayers[patchPointi] > 0)
1848 addedPoints_[patchPointi].setSize(nPointLayers[patchPointi]);
1858 Pout<<
"Not adding points at " << nTruncated <<
" out of " 1859 << pp.nPoints() <<
" points" <<
endl;
1871 faceList baseFaces(mesh_.nFaces());
1872 bitSet isAffectedCell(mesh_.nCells());
1874 const faceList& localFaces = pp.localFaces();
1875 forAll(localFaces, patchFacei)
1877 const face&
f = localFaces[patchFacei];
1880 const label patchPointi =
f[fp];
1881 if (nPointLayers[patchPointi] > 0)
1883 const label meshFacei = pp.addressing()[patchFacei];
1884 face& baseF = baseFaces[meshFacei];
1887 baseF[fp] = pp.meshPoints()[patchPointi];
1889 if (ppFlip[patchFacei])
1892 const label celli = mesh_.faceOwner()[meshFacei];
1893 isAffectedCell.set(celli);
1895 else if (mesh_.isInternalFace(meshFacei))
1898 const label celli = mesh_.faceNeighbour()[meshFacei];
1899 isAffectedCell.set(celli);
1912 Map<label> minPointValue(128);
1913 faceList oldBoundaryFaces(mesh_.nBoundaryFaces());
1917 bitSet newIsAffectedCell(mesh_.nCells());
1920 for (
const label celli : isAffectedCell)
1922 const cell& cFaces = mesh_.cells()[celli];
1926 minPointValue.
clear();
1927 for (
const label facei : cFaces)
1929 const face& baseF = baseFaces[facei];
1930 const face&
f = mesh_.faces()[facei];
1941 minPointValue.insert(
f[fp], baseF[fp]);
1953 for (
const label facei : cFaces)
1955 const face&
f = mesh_.faces()[facei];
1956 face& baseF = baseFaces[facei];
1958 const label oldNChanged = nChanged;
1961 const auto fnd = minPointValue.find(
f[fp]);
1981 if (!isBlockedFace(facei) && nChanged > oldNChanged)
1984 const label own = mesh_.faceOwner()[facei];
1985 if (!isAffectedCell[own])
1987 newIsAffectedCell.set(own);
1989 if (mesh_.isInternalFace(facei))
1991 const label nei = mesh_.faceNeighbour()[facei];
1992 if (!isAffectedCell[nei])
1994 newIsAffectedCell.set(nei);
2003 Pout<<
"isAffectedCell:" << isAffectedCell.count() <<
endl;
2004 Pout<<
"newIsAffectedCell:" << newIsAffectedCell.count()
2006 Pout<<
"nChanged:" << nChanged <<
endl;
2021 mesh_.nBoundaryFaces(),
2022 mesh_.nInternalFaces()
2024 oldBoundaryFaces = l;
2038 const labelUList& oldVts = oldBoundaryFaces[bFacei];
2039 if (baseVts != oldVts)
2041 const label facei = mesh_.nInternalFaces()+bFacei;
2042 const label own = mesh_.faceOwner()[facei];
2043 if (!isAffectedCell[own])
2045 newIsAffectedCell.set(own);
2050 isAffectedCell = newIsAffectedCell;
2063 copiedPatchPoints.
setSize(firstLayerDisp.size());
2064 forAll(firstLayerDisp, patchPointi)
2066 if (addedPoints_[patchPointi].size())
2068 label meshPointi = meshPoints[patchPointi];
2069 label zoneI = mesh_.pointZones().whichZone(meshPointi);
2070 copiedPatchPoints[patchPointi] = meshMod.setAction
2074 mesh_.points()[meshPointi],
2086 forAll(firstLayerDisp, patchPointi)
2088 if (addedPoints_[patchPointi].size())
2090 const label meshPointi = meshPoints[patchPointi];
2091 const label zoneI = mesh_.pointZones().whichZone(meshPointi);
2093 point pt = mesh_.points()[meshPointi];
2095 vector disp = firstLayerDisp[patchPointi];
2097 forAll(addedPoints_[patchPointi], i)
2101 const label addedVertI = meshMod.setAction
2106 (addToMesh_ ? meshPointi : -1),
2118 addedPoints_[patchPointi][i] = addedVertI;
2120 disp *= expansionRatio[patchPointi];
2134 if (nFaceLayers[patchFacei] > 0)
2136 const label meshFacei = pp.addressing()[patchFacei];
2138 label extrudeCelli = -2;
2143 const label ownCelli = mesh_.faceOwner()[meshFacei];
2144 extrudeZonei = mesh_.cellZones().whichZone(ownCelli);
2146 else if (!ppFlip[patchFacei])
2149 extrudeCelli = mesh_.faceOwner()[meshFacei];
2150 extrudeZonei = mesh_.cellZones().whichZone(extrudeCelli);
2152 else if (mesh_.isInternalFace(meshFacei))
2157 extrudeCelli = mesh_.faceNeighbour()[meshFacei];
2158 extrudeZonei = mesh_.cellZones().whichZone(extrudeCelli);
2161 if (extrudeCelli != -2)
2163 addedCells[patchFacei].setSize(nFaceLayers[patchFacei]);
2165 for (label i = 0; i < nFaceLayers[patchFacei]; i++)
2169 addedCells[patchFacei][i] = meshMod.setAction
2197 layerFaces_.setSize(pp.size());
2199 forAll(pp.localFaces(), patchFacei)
2201 label meshFacei = pp.addressing()[patchFacei];
2203 if (addedCells[patchFacei].size())
2205 layerFaces_[patchFacei].setSize(addedCells[patchFacei].size() + 1);
2208 const face&
f = pp.localFaces()[patchFacei];
2210 face newFace(
f.
size());
2212 forAll(addedCells[patchFacei], i)
2216 if (addedPoints_[
f[fp]].empty())
2223 : copiedPatchPoints[
f[fp]]
2230 addedPoints_[
f[fp]].size()
2231 - addedCells[patchFacei].size();
2232 newFace[fp] = addedPoints_[
f[fp]][i+offset];
2242 label own = addedCells[patchFacei][i];
2247 bool fluxFlip =
false;
2249 if (i == addedCells[patchFacei].size()-1)
2260 ? mesh_.faceNeighbour()[meshFacei]
2261 : mesh_.faceOwner()[meshFacei]
2264 if (ppFlip[patchFacei])
2266 newFace = newFace.reverseFace();
2279 zoneI = mesh_.faceZones().whichZone(meshFacei);
2282 const faceZone& fz = mesh_.faceZones()[zoneI];
2283 flip = fz.flipMap()[fz.whichFace(meshFacei)];
2289 nei = addedCells[patchFacei][i+1];
2293 if (nei != -1 && nei < own)
2296 newFace = newFace.reverseFace();
2297 std::swap(own, nei);
2310 layerFaces_[patchFacei][i+1] = meshMod.setAction
2319 (addToMesh_ ? meshFacei : -1),
2348 if (addedCells[patchFacei].size())
2350 label meshFacei = pp.addressing()[patchFacei];
2352 layerFaces_[patchFacei][0] = meshFacei;
2353 const face&
f = pp[patchFacei];
2358 ? mesh_.faceOwner()[meshFacei]
2359 : mesh_.faceNeighbour()[meshFacei]
2361 const label nei = addedCells[patchFacei][0];
2367 (ppFlip[patchFacei] ?
f.reverseFace() :
f),
2395 if (addedCells[patchFacei].size())
2397 label meshFacei = pp.addressing()[patchFacei];
2398 label zoneI = mesh_.faceZones().whichZone(meshFacei);
2399 bool zoneFlip =
false;
2402 const faceZone& fz = mesh_.faceZones()[zoneI];
2403 zoneFlip = !fz.flipMap()[fz.whichFace(meshFacei)];
2407 face
f(pp.localFaces()[patchFacei].reverseFace());
2410 f[fp] = copiedPatchPoints[
f[fp]];
2413 layerFaces_[patchFacei][0] = meshMod.setAction
2418 addedCells[patchFacei][0],
2424 exposedPatchID[patchFacei],
2440 const faceList& localFaces = pp.localFaces();
2441 const edgeList& edges = pp.edges();
2450 labelList meshEdgeLayers(mesh_.nEdges(), -1);
2454 const edge&
e = edges[edgei];
2456 label meshEdgei = meshEdges[edgei];
2458 if ((nPointLayers[
e[0]] == 0) && (nPointLayers[
e[1]] == 0))
2460 meshEdgeLayers[meshEdgei] = 0;
2464 const labelList& eFaces = pp.edgeFaces()[edgei];
2468 meshEdgeLayers[meshEdgei] =
max 2470 nFaceLayers[eFaces[i]],
2471 meshEdgeLayers[meshEdgei]
2487 edgeLayers[edgei] = meshEdgeLayers[meshEdges[edgei]];
2493 boolList doneEdge(pp.nEdges(),
false);
2500 const labelList& fEdges = faceEdges[patchFacei];
2514 globalFaces.toGlobal(pp.addressing()[patchFacei])
2523 const label startFp = indexPair[0];
2524 const label endFp = indexPair[1];
2531 const face&
f = localFaces[patchFacei];
2534 if (endFp >= startFp)
2536 stringedVerts.
setSize(endFp-startFp+2);
2540 stringedVerts.setSize(endFp+
f.
size()-startFp+2);
2545 for (label i = 0; i < stringedVerts.size()-1; i++)
2547 stringedVerts[i] =
f[fp];
2548 doneEdge[fEdges[fp]] =
true;
2551 stringedVerts.last() =
f[fp];
2561 label startEdgei = fEdges[startFp];
2563 label meshEdgei = meshEdges[startEdgei];
2565 label numEdgeSideFaces = edgeLayers[startEdgei];
2567 for (label i = 0; i < numEdgeSideFaces; i++)
2569 label vEnd = stringedVerts.
last();
2570 label vStart = stringedVerts[0];
2573 label newFp = 2*stringedVerts.size();
2579 if (addedPoints_[vEnd].size())
2582 addedPoints_[vEnd].size() - numEdgeSideFaces;
2584 if (addedPoints_[vStart].size())
2587 addedPoints_[vStart].size() - numEdgeSideFaces;
2591 face newFace(newFp);
2599 forAll(stringedVerts, stringedI)
2601 label v = stringedVerts[stringedI];
2607 : copiedPatchPoints[v]
2616 forAll(stringedVerts, stringedI)
2618 label v = stringedVerts[stringedI];
2619 if (addedPoints_[v].size())
2622 addedPoints_[v].size() - numEdgeSideFaces;
2625 addedPoints_[v][i+offset-1],
2637 : copiedPatchPoints[v]
2647 if (numEdgeSideFaces < addedPoints_[vEnd].size())
2649 if (i == 0 && addedPoints_[vEnd].size())
2652 addedPoints_[vEnd].size() - numEdgeSideFaces;
2653 for (label ioff = 0; ioff < offset; ioff++)
2657 addedPoints_[vEnd][ioff],
2667 label v = stringedVerts[stringedI];
2668 if (addedPoints_[v].size())
2671 addedPoints_[v].size() - numEdgeSideFaces;
2674 addedPoints_[v][i+offset],
2686 : copiedPatchPoints[v]
2696 if (numEdgeSideFaces < addedPoints_[vStart].size())
2698 if (i == 0 && addedPoints_[vStart].size())
2701 addedPoints_[vStart].size() - numEdgeSideFaces;
2702 for (label ioff = offset-1; ioff >= 0; ioff--)
2706 addedPoints_[vStart][ioff],
2719 newFace.setSize(newFp);
2723 if (ppFlip[patchFacei])
2725 newFace = newFace.reverseFace();
2733 if (!verts.insert(newFace[fp]))
2736 <<
"Duplicate vertex in face" 2737 <<
" to be added." <<
nl 2738 <<
"newFace:" << newFace <<
nl 2740 << UIndirectList<point>
2746 <<
" out of:" << numEdgeSideFaces <<
nl 2747 <<
"ExtrudeEdge:" << meshEdgei
2749 << mesh_.edges()[meshEdgei].line
2753 <<
"string:" << stringedVerts
2755 << UIndirectList<point>
2771 label nbrFacei = nbrFace
2778 const labelList& meshFaces = mesh_.edgeFaces
2787 bool zoneFlip =
false;
2788 if (edgeZoneID[startEdgei] != -1)
2790 zoneFlip = !edgeFlip[startEdgei];
2799 edgePatchID[startEdgei],
2800 edgeZoneID[startEdgei],
2802 inflateFaceID[startEdgei],
2827 const face&
f = mesh_.faces()[facei];
2828 const face& baseF = baseFaces[facei];
2830 if (isBlockedFace(facei) || baseF.empty())
2840 const label meshPointi =
f[fp];
2844 const label patchPointi = pp.meshPointMap()[meshPointi];
2845 const label addedPointi = addedPoints_[patchPointi].
last();
2854 newFace[fp] = addedPointi;
2870 label zoneID = mesh_.faceZones().whichZone(facei);
2871 bool zoneFlip =
false;
2874 const faceZone& fZone = mesh_.faceZones()[zoneID];
2875 zoneFlip = fZone.flipMap()[fZone.whichFace(facei)];
2879 if (mesh_.isInternalFace(facei))
2885 mesh_.faceOwner()[facei],
2886 mesh_.faceNeighbour()[facei],
2899 mesh_.faceOwner()[facei],
2914 const mapPolyMesh& morphMap,
2926 const labelList& added = addedPoints_[oldPointi];
2929 newAdded.
setSize(added.size());
2934 label
newPointi = morphMap.reversePointMap()[added[i]];
2941 newAdded.setSize(newI);
2943 addedPoints_.transfer(newAddedPoints);
2949 forAll(newLayerFaces, newFacei)
2951 label oldFacei =
faceMap[newFacei];
2953 const labelList& added = layerFaces_[oldFacei];
2955 labelList& newAdded = newLayerFaces[newFacei];
2956 newAdded.
setSize(added.size());
2961 label newFacei = morphMap.reverseFaceMap()[added[i]];
2965 newAdded[newI++] = newFacei;
2968 newAdded.setSize(newI);
2970 layerFaces_.transfer(newLayerFaces);
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
List< labelList > labelListList
A List of labelList.
void size(const label n)
Older name for setAddressableSize.
ZoneMesh< faceZone, polyMesh > faceZoneMesh
A ZoneMesh with the type faceZone.
errorManipArg< error, int > exit(error &err, const int errNo=1)
A face is a list of labels corresponding to mesh vertices.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
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.
const labelListList & pointEdges() const
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
const labelList & processorPatches() const noexcept
Return list of processor patch labels.
constexpr char nl
The newline '\n' character (0x0a)
List< face > faceList
A List of faces.
Ostream & endl(Ostream &os)
Add newline and flush stream.
static void calcExtrudeInfo(const bool zoneFromAnyFace, const polyMesh &, const globalIndex &globalFaces, const labelListList &globalEdgeFaces, const indirectPrimitivePatch &pp, labelList &edgePatchID, label &nPatches, Map< label > &nbrProcToPatch, Map< label > &patchToNbrProc, labelList &edgeZoneID, boolList &edgeFlip, labelList &inflateFaceID)
Determine extrude information per patch edge:
static bool & parRun() noexcept
Test if this a parallel run.
label k
Boltzmann constant.
label nFaces() const noexcept
Number of mesh faces.
PrimitivePatch< IndirectList< face >, const pointField & > indirectPrimitivePatch
A PrimitivePatch with an IndirectList for the faces, const reference for the point field...
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.
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
virtual const pointField & points() const
Return raw points.
#define forAll(list, i)
Loop across all elements in list.
static void syncData(List< Type > &elems, const labelListList &slaves, const labelListList &transformedSlaves, const mapDistribute &slavesMap, const globalIndexAndTransform &, const CombineOp &cop, const TransformOp &top)
Helper: synchronise data with transforms.
label fcIndex(const label i) const noexcept
The forward circular index. The next index in the list which returns to the first at the end of the l...
HashSet< label, Hash< label > > labelHashSet
A HashSet of labels, uses label hasher.
A list of faces which address into the list of points.
Calculates a unique integer (label so might not have enough room - 2G max) for processor + local inde...
vectorField pointField
pointField is a vectorField.
const dimensionedScalar e
Elementary charge.
void setSize(const label n)
Alias for resize()
List< edge > edgeList
A List of edges.
void clear()
Clear the list, i.e. set size to zero.
Adds layers of cells to outside of polyPatch. Can optionally create stand-alone extruded mesh (addToM...
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
label size() const noexcept
The number of elements in the list.
const labelListList & edgeFaces() const
Return edge-face addressing.
const globalMeshData & globalData() const
Return parallel info.
virtual const faceList & faces() const
Return raw faces.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
void setRefinement(const globalIndex &globalFaces, const labelListList &globalEdgeFaces, const scalarField &expansionRatio, const indirectPrimitivePatch &pp, const bitSet &flip, const labelList &sidePatchID, const labelList &sideZoneID, const boolList &sideFlip, const labelList &inflateFaceID, const labelList &exposedPatchID, const labelList &nFaceLayers, const labelList &nPointLayers, const vectorField &firstLayerDisp, polyTopoChange &meshMod)
Play commands into polyTopoChange to create layers on top.
errorManip< error > abort(error &err)
const T * set(const label i) const
Return const pointer to element (can be nullptr), or nullptr for out-of-range access (ie...
label nEdges() const
Number of mesh edges.
int debug
Static debugging option.
Pair< label > labelPair
A pair of labels.
Type gMax(const FieldField< Field, Type > &f)
const faceZoneMesh & faceZones() const noexcept
Return face zone mesh.
defineTypeNameAndDebug(combustionModel, 0)
T & last()
Access last element of the list, position [size()-1].
label whichZone(const label objectIndex) const
Given a global object index, return the zone it is in.
void updateMesh(const mapPolyMesh &, const labelList &faceMap, const labelList &pointMap)
Update any locally stored mesh information. Gets additional.
const edgeList & edges() const
Return mesh edges. Uses calcEdges.
label toGlobal(const label i) const
From local to global index.
UIndirectList< label > labelUIndList
UIndirectList of labels.
vector point
Point is a vector.
#define WarningInFunction
Report a warning using Foam::Warning.
void operator()(face &x, const face &y) const
labelList meshEdges(const edgeList &allEdges, const labelListList &cellEdges, const labelList &faceCells) const
Return labels of patch edges in the global edge list using cell addressing.
label whichPatch(const label faceIndex) const
Return patch index for a given mesh face index.
const polyBoundaryMesh & patches
const std::string patch
OpenFOAM patch number as a std::string.
static labelListList globalEdgeFaces(const polyMesh &, const globalIndex &globalFaces, const indirectPrimitivePatch &pp)
Per patch edge the pp faces (in global indices) using it.
labelListList addedCells() const
Added cells given current mesh & layerfaces.
Field< vector > vectorField
Specialisation of Field<T> for vector.
Mesh consisting of general polyhedral cells.
#define forAllReverse(list, i)
Reverse loop across all elements in list.
List< label > labelList
A List of labels.
bool returnReduceOr(const bool value, const label comm=UPstream::worldComm)
Perform logical (or) MPI Allreduce on a copy. Uses UPstream::reduceOr.
List< bool > boolList
A List of bools.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
const labelListList & edgeFaces() const
static int compare(const edge &a, const edge &b)
Compare edges.
static constexpr const zero Zero
Global zero (0)