53 Foam::label Foam::addPatchCellLayer::nbrFace
60 const labelList& eFaces = edgeFaces[edgei];
62 if (eFaces.size() == 2)
64 return (eFaces[0] != facei ? eFaces[0] : eFaces[1]);
73 void Foam::addPatchCellLayer::addVertex
86 if (
f[fp-1] != pointi &&
f[0] != pointi)
96 bool Foam::addPatchCellLayer::sameEdgeNeighbour
101 const label thisGlobalFacei,
102 const label nbrGlobalFacei,
106 const edge&
e = pp.edges()[edgei];
111 addedPoints_[
e[0]].size()
112 || addedPoints_[
e[1]].size()
115 nbrFace(globalEdgeFaces, edgei, thisGlobalFacei)
129 const label patchFacei,
130 const label globalFacei
133 const labelList& fEdges = pp.faceEdges()[patchFacei];
141 label edgei = fEdges[fp];
142 const edge&
e = pp.edges()[edgei];
147 && ( addedPoints_[
e[0]].size() || addedPoints_[
e[1]].size() )
159 label nbrGlobalFacei = nbrFace
166 if (nbrGlobalFacei == -1)
178 const label initFp = startFp;
181 label prevFp = fEdges.rcIndex(startFp);
183 if (prevFp == initFp)
185 const edge&
e = pp.edges()[fEdges[initFp]];
186 const face& localF = pp.localFaces()[patchFacei];
189 <<
"On face:" << patchFacei
190 <<
" fc:" << pp.faceCentres()[patchFacei]
191 <<
" vertices:" << localF
193 << UIndirectList<point>(pp.points(), pp[patchFacei])
194 <<
" edges:" << fEdges
195 <<
" All edges of face seem to have same neighbour "
197 <<
" starting walking from edge " <<
e
223 label nextFp = fEdges.fcIndex(endFp);
249 Foam::label Foam::addPatchCellLayer::addSideFace
254 const label newPatchID,
257 const label inflateFacei,
259 const label ownFacei,
260 const label nbrFacei,
261 const label meshEdgei,
263 const label numEdgeFaces,
265 polyTopoChange& meshMod
270 label addedFacei = -1;
284 if (addedCells[ownFacei].size() < numEdgeFaces)
286 label offset = numEdgeFaces - addedCells[ownFacei].size();
287 if (layeri <= offset)
293 layerOwn = layeri - offset;
307 addedFacei = meshMod.setAction
312 addedCells[ownFacei][layerOwn],
334 if (addedCells[ownFacei].size() > addedCells[nbrFacei].size())
337 addedCells[ownFacei].size() - addedCells[nbrFacei].size();
341 if (layeri <= offset)
347 layerNbr = layeri - offset;
350 else if (addedCells[nbrFacei].size() > addedCells[ownFacei].size())
353 addedCells[nbrFacei].size() - addedCells[ownFacei].size();
357 if (layeri <= offset)
363 layerOwn = layeri - offset;
375 label inflateEdgei = -1;
380 if (mesh_.isInternalFace(meshFaces[i]))
383 inflateEdgei = meshEdgei;
390 addedFacei = meshMod.setAction
395 addedCells[ownFacei][layerOwn],
396 addedCells[nbrFacei][layerNbr],
417 Foam::label Foam::addPatchCellLayer::findProcPatch
419 const polyMesh&
mesh,
420 const label nbrProcID
431 refCast<const processorPolyPatch>(
patches[patchi]).neighbProcNo()
442 void Foam::addPatchCellLayer::setFaceProps
444 const polyMesh&
mesh,
462 void Foam::addPatchCellLayer::setFaceProps
464 const polyMesh&
mesh,
485 if (patchI != -1 || zoneI != -1)
487 inflateFaceI = faceI;
493 const edge& ppEdge = pp.edges()[ppEdgeI];
496 pp.meshPoints()[ppEdge[0]],
497 pp.meshPoints()[ppEdge[1]]
504 const edge
e(
f[fp],
f.nextLabel(fp));
514 zoneFlip = !zoneFlip;
523 <<
"Problem: cannot find patch edge " << ppEdgeI
524 <<
" with mesh vertices " << patchEdge
526 <<
" in face " << faceI <<
" with mesh vertices "
530 <<
"Continuing with potentially incorrect faceZone orientation"
538 void Foam::addPatchCellLayer::findZoneFace
540 const bool useInternalFaces,
541 const bool useBoundaryFaces,
543 const polyMesh&
mesh,
562 label faceI = meshFaces[
k];
566 !excludeFaces.found(faceI)
586 if (zoneI != -1 || patchI != -1)
598 Foam::addPatchCellLayer::addPatchCellLayer
605 addToMesh_(addToMesh),
621 forAll(layerFaces, patchFacei)
623 const labelList& faceLabels = layerFaces[patchFacei];
625 if (faceLabels.size())
627 labelList& added = layerCells[patchFacei];
628 added.
setSize(faceLabels.size()-1);
630 for (label i = 0; i < faceLabels.size()-1; i++)
642 return addedCells(mesh_, layerFaces_);
664 label meshEdgeI = meshEdges[edgeI];
666 const labelList& eFaces = edgeFaces[edgeI];
669 labelList& globalEFaces = globalEdgeFaces[meshEdgeI];
670 globalEFaces.
setSize(eFaces.size());
673 globalEFaces[i] = globalFaces.
toGlobal(pp.addressing()[eFaces[i]]);
691 void Foam::addPatchCellLayer::markPatchEdges
699 bitSet& isPatchBoundaryEdge
708 isPatchEdge.
set(meshEdges);
719 isPatchBoundaryEdge =
false;
720 forAll(edgeGlobalFaces, edgei)
726 if (edgeGlobalFaces[edgei].size() == 1)
728 isPatchBoundaryEdge.
set(meshEdges[edgei]);
736 orEqOp<unsigned int>(),
742 void Foam::addPatchCellLayer::globalEdgeInfo
744 const bool zoneFromAnyFace,
746 const polyMesh&
mesh,
747 const globalIndex& globalFaces,
755 bitSet& patchEdgeToFlip
762 bitSet isExtrudeEdge;
763 bitSet isBoundaryEdge;
777 EdgeMap<label> isBoundaryEdgeSet(pp.nEdges());
778 for (
const label edgei : isBoundaryEdge)
780 isBoundaryEdgeSet.insert(
mesh.
edges()[edgei], edgei);
782 EdgeMap<label> isExtrudeEdgeSet(pp.nEdges());
783 for (
const label edgei : isExtrudeEdge)
785 isExtrudeEdgeSet.insert(
mesh.
edges()[edgei], edgei);
794 for (
const faceZone& fz: fzs)
797 UIndirectList<label>(faceToZone, addressing) = fz.index();
802 faceToFlip[addressing[i]] = fm[i];
819 const bitSet isInternalOrCoupled
827 for (
const label facei : isInternalOrCoupled)
831 label prevPointi =
f.last();
832 for (
const label pointi :
f)
834 const edge
e(prevPointi, pointi);
838 const auto eFnd = isExtrudeEdgeSet.cfind(
e);
841 const label edgei = eFnd();
843 if (faceToZone[facei] != -1)
846 meshEdgeToFace[edgei] = globalFaces.toGlobal(facei);
847 meshEdgeToZone[edgei] = faceToZone[facei];
852 meshEdgeToFlip[edgei] = faceToFlip[facei];
856 meshEdgeToFlip[edgei] = !faceToFlip[facei];
882 isPpFace.
set(pp.addressing());
885 for (
const polyPatch& pp :
patches)
895 const label facei = pp.start()+i;
897 if (!isPpFace[facei])
899 const face&
f = pp[i];
901 label prevPointi =
f.last();
902 for (
const label pointi :
f)
904 const edge
e(prevPointi, pointi);
908 ? isExtrudeEdgeSet.cfind(
e)
909 : isBoundaryEdgeSet.cfind(
e)
913 const label edgei = eFnd();
914 if (meshEdgeToFace[edgei] == -1)
921 meshEdgeToFace[edgei] =
922 globalFaces.toGlobal(facei);
925 if (meshEdgeToPatch[edgei] == -1)
927 meshEdgeToPatch[edgei] = pp.index();
931 if (meshEdgeToZone[edgei] == -1)
933 meshEdgeToZone[edgei] =
939 meshEdgeToFlip[edgei] =
944 meshEdgeToFlip[edgei] =
1072 orEqOp<unsigned int>(),
1077 patchEdgeToFace = UIndirectList<label>(meshEdgeToFace, meshEdges);
1078 patchEdgeToPatch = UIndirectList<label>(meshEdgeToPatch, meshEdges);
1079 patchEdgeToZone = UIndirectList<label>(meshEdgeToZone, meshEdges);
1080 patchEdgeToFlip.setSize(meshEdges.size());
1081 patchEdgeToFlip =
false;
1084 patchEdgeToFlip[i] = meshEdgeToFlip[meshEdges[i]];
1091 const bool zoneFromAnyFace,
1136 forAll(globalEdgeFaces, edgei)
1138 const labelList& eGlobalFaces = globalEdgeFaces[edgei];
1141 eGlobalFaces.size() == 2
1148 label f0 = eGlobalFaces[0];
1149 label f1 = eGlobalFaces[1];
1151 label otherProci = -1;
1162 if (otherProci != -1)
1176 if (nbrProcToPatch.found(otherProci))
1178 edgePatchID[edgei] = nbrProcToPatch[otherProci];
1183 nbrProcToPatch.insert(otherProci,
nPatches);
1184 patchToNbrProc.insert(
nPatches, otherProci);
1223 if (edgePatchID[edgei] == -1)
1225 if (edgeFaces[edgei].size() == 2)
1230 if (globalFaces.
isLocal(edgeToFace[edgei]))
1232 inflateFaceID[edgei] =
1233 globalFaces.
toLocal(edgeToFace[edgei]);
1235 edgeZoneID[edgei] = edgeToZone[edgei];
1236 edgeFlip[edgei] = edgeToFlip[edgei];
1243 if (globalFaces.
isLocal(edgeToFace[edgei]))
1245 inflateFaceID[edgei] =
1246 globalFaces.
toLocal(edgeToFace[edgei]);
1248 edgePatchID[edgei] = edgeToPatch[edgei];
1249 edgeZoneID[edgei] = edgeToZone[edgei];
1250 edgeFlip[edgei] = edgeToFlip[edgei];
1262 if (edgeFaces[edgei].size() == 1 && edgePatchID[edgei] == -1)
1266 <<
"Have no sidePatchID for edge " << edgei <<
" points "
1282 edgeFaces[edgei].size() == 1
1283 && globalEdgeFaces[edgei].size() == 2
1284 && edgePatchID[edgei] != -1
1285 && inflateFaceID[edgei] == -1
1290 label myFaceI = pp.addressing()[edgeFaces[edgei][0]];
1293 label meshEdgei = meshEdges[edgei];
1302 label facei = meshFaces[
k];
1318 inflateFaceID[edgei]
1343 bitSet sameEdgeOrientation;
1358 label cppEdgei = coupledEdges[i];
1359 label ppEdgei = patchEdges[i];
1361 cppEdgeZoneID[cppEdgei] = edgeZoneID[ppEdgei];
1362 if (sameEdgeOrientation[i])
1364 cppEdgeFlip[cppEdgei] = edgeFlip[ppEdgei];
1368 cppEdgeFlip[cppEdgei] = !edgeFlip[ppEdgei];
1400 label cppEdgei = coupledEdges[i];
1401 label ppEdgei = patchEdges[i];
1403 edgeZoneID[ppEdgei] = cppEdgeZoneID[cppEdgei];
1404 if (sameEdgeOrientation[i])
1406 edgeFlip[ppEdgei] = cppEdgeFlip[cppEdgei];
1410 edgeFlip[ppEdgei] = !cppEdgeFlip[cppEdgei];
1438 Pout<<
"addPatchCellLayer::setRefinement : Adding up to "
1439 <<
gMax(nPointLayers)
1440 <<
" layers of cells to indirectPrimitivePatch with "
1446 pp.
nPoints() != firstLayerDisp.size()
1447 || pp.
nPoints() != nPointLayers.size()
1448 || pp.size() != nFaceLayers.size()
1452 <<
"Size of new points is not same as number of points used by"
1453 <<
" the face subset" <<
endl
1454 <<
" patch.nPoints:" << pp.
nPoints()
1455 <<
" displacement:" << firstLayerDisp.size()
1456 <<
" nPointLayers:" << nPointLayers.size() <<
nl
1457 <<
" patch.nFaces:" << pp.size()
1458 <<
" nFaceLayers:" << nFaceLayers.size()
1464 if (nPointLayers[i] < 0)
1467 <<
"Illegal number of layers " << nPointLayers[i]
1473 if (nFaceLayers[i] < 0)
1476 <<
"Illegal number of layers " << nFaceLayers[i]
1481 forAll(globalEdgeFaces, edgei)
1483 if (globalEdgeFaces[edgei].size() > 2)
1487 if (nPointLayers[
e[0]] > 0 || nPointLayers[
e[1]] > 0)
1490 <<
"Trying to extrude edge "
1492 <<
" which is non-manifold (has "
1493 << globalEdgeFaces[edgei].size()
1494 <<
" local or coupled faces using it)"
1525 label meshPointi = meshPoints[i];
1527 if (
n[meshPointi] != nPointLayers[i])
1530 <<
"At mesh point:" << meshPointi
1531 <<
" coordinate:" << mesh_.points()[meshPointi]
1532 <<
" specified nLayers:" << nPointLayers[i] <<
endl
1533 <<
"On coupled point a different nLayers:"
1534 <<
n[meshPointi] <<
" was specified."
1545 const face&
f = pp[i];
1549 label pointi =
f[fp];
1551 nFromFace[pointi] =
max(nFromFace[pointi], nFaceLayers[i]);
1564 label meshPointi = meshPoints[i];
1569 && nPointLayers[i] != nFromFace[meshPointi]
1573 <<
"At mesh point:" << meshPointi
1574 <<
" coordinate:" << mesh_.points()[meshPointi]
1575 <<
" specified nLayers:" << nPointLayers[i] <<
endl
1576 <<
"but the max nLayers of surrounding faces is:"
1577 << nFromFace[meshPointi]
1596 label meshPointi = meshPoints[i];
1598 if (
mag(d[meshPointi] - firstLayerDisp[i]) > SMALL)
1601 <<
"At mesh point:" << meshPointi
1602 <<
" coordinate:" << mesh_.points()[meshPointi]
1603 <<
" specified displacement:" << firstLayerDisp[i]
1605 <<
"On coupled point a different displacement:"
1606 << d[meshPointi] <<
" was specified."
1622 if (nPointLayers[
e[0]] > 0 || nPointLayers[
e[1]] > 0)
1629 if (eFaces.size() != 1)
1632 <<
"boundary-edge-to-be-extruded:"
1633 << pp.
points()[meshPoints[
e[0]]]
1634 << pp.
points()[meshPoints[
e[1]]]
1635 <<
" has more than two faces using it:" << eFaces
1639 label myFacei = pp.addressing()[eFaces[0]];
1641 label meshEdgei = meshEdges[edgei];
1644 const labelList& meshFaces = mesh_.edgeFaces(meshEdgei, ef);
1653 label facei = meshFaces[i];
1655 if (facei != myFacei)
1657 if (!mesh_.isInternalFace(facei))
1666 <<
"boundary-edge-to-be-extruded:"
1667 << pp.
points()[meshPoints[
e[0]]]
1668 << pp.
points()[meshPoints[
e[1]]]
1669 <<
" has more than two boundary faces"
1672 << mesh_.faceCentres()[bFacei]
1674 <<
" and " << facei <<
" fc:"
1675 << mesh_.faceCentres()[facei]
1694 label meshFacei = pp.addressing()[patchFacei];
1702 addedPoints_.setSize(pp.
nPoints());
1705 label nTruncated = 0;
1707 forAll(nPointLayers, patchPointi)
1709 if (nPointLayers[patchPointi] > 0)
1711 addedPoints_[patchPointi].setSize(nPointLayers[patchPointi]);
1721 Pout<<
"Not adding points at " << nTruncated <<
" out of "
1734 copiedPatchPoints.
setSize(firstLayerDisp.size());
1735 forAll(firstLayerDisp, patchPointi)
1737 label meshPointi = meshPoints[patchPointi];
1738 label zoneI = mesh_.pointZones().whichZone(meshPointi);
1739 copiedPatchPoints[patchPointi] = meshMod.
setAction
1743 mesh_.points()[meshPointi],
1754 forAll(firstLayerDisp, patchPointi)
1756 if (addedPoints_[patchPointi].size())
1758 label meshPointi = meshPoints[patchPointi];
1760 label zoneI = mesh_.pointZones().whichZone(meshPointi);
1762 point pt = mesh_.points()[meshPointi];
1764 vector disp = firstLayerDisp[patchPointi];
1766 forAll(addedPoints_[patchPointi], i)
1775 (addToMesh_ ? meshPointi : -1),
1781 addedPoints_[patchPointi][i] = addedVertI;
1783 disp *= expansionRatio[patchPointi];
1797 if (nFaceLayers[patchFacei] > 0)
1799 addedCells[patchFacei].setSize(nFaceLayers[patchFacei]);
1801 label meshFacei = pp.addressing()[patchFacei];
1803 label ownZoneI = mesh_.cellZones().whichZone
1805 mesh_.faceOwner()[meshFacei]
1808 for (label i = 0; i < nFaceLayers[patchFacei]; i++)
1812 addedCells[patchFacei][i] = meshMod.
setAction
1819 (addToMesh_ ? mesh_.faceOwner()[meshFacei] : -1),
1835 layerFaces_.setSize(pp.size());
1839 label meshFacei = pp.addressing()[patchFacei];
1841 if (addedCells[patchFacei].size())
1843 layerFaces_[patchFacei].setSize(addedCells[patchFacei].size() + 1);
1848 face newFace(
f.size());
1850 forAll(addedCells[patchFacei], i)
1854 if (addedPoints_[
f[fp]].empty())
1861 : copiedPatchPoints[
f[fp]]
1868 addedPoints_[
f[fp]].size()
1869 - addedCells[patchFacei].size();
1870 newFace[fp] = addedPoints_[
f[fp]][i+offset];
1882 if (i == addedCells[patchFacei].size()-1)
1887 zoneI = mesh_.faceZones().whichZone(meshFacei);
1890 const faceZone& fz = mesh_.faceZones()[zoneI];
1897 nei = addedCells[patchFacei][i+1];
1902 layerFaces_[patchFacei][i+1] = meshMod.
setAction
1907 addedCells[patchFacei][i],
1911 (addToMesh_ ? meshFacei : -1),
1930 if (addedCells[patchFacei].size())
1932 label meshFacei = pp.addressing()[patchFacei];
1934 layerFaces_[patchFacei][0] = meshFacei;
1942 mesh_.faceOwner()[meshFacei],
1943 addedCells[patchFacei][0],
1960 if (nFaceLayers[patchFacei] > 0)
1962 label meshFacei = pp.addressing()[patchFacei];
1963 label zoneI = mesh_.faceZones().whichZone(meshFacei);
1964 bool zoneFlip =
false;
1967 const faceZone& fz = mesh_.faceZones()[zoneI];
1975 f[fp] = copiedPatchPoints[
f[fp]];
1978 layerFaces_[patchFacei][0] = meshMod.
setAction
1983 addedCells[patchFacei][0],
1989 exposedPatchID[patchFacei],
2015 labelList meshEdgeLayers(mesh_.nEdges(), -1);
2019 const edge&
e = edges[edgei];
2021 label meshEdgei = meshEdges[edgei];
2023 if ((nPointLayers[
e[0]] == 0) && (nPointLayers[
e[1]] == 0))
2025 meshEdgeLayers[meshEdgei] = 0;
2033 meshEdgeLayers[meshEdgei] =
max
2035 nFaceLayers[eFaces[i]],
2036 meshEdgeLayers[meshEdgei]
2052 edgeLayers[edgei] = meshEdgeLayers[meshEdges[edgei]];
2065 const labelList& fEdges = faceEdges[patchFacei];
2079 globalFaces.
toGlobal(pp.addressing()[patchFacei])
2088 const label startFp = indexPair[0];
2089 const label endFp = indexPair[1];
2096 const face&
f = localFaces[patchFacei];
2099 if (endFp >= startFp)
2101 stringedVerts.
setSize(endFp-startFp+2);
2105 stringedVerts.
setSize(endFp+
f.size()-startFp+2);
2110 for (label i = 0; i < stringedVerts.size()-1; i++)
2112 stringedVerts[i] =
f[fp];
2113 doneEdge[fEdges[fp]] =
true;
2116 stringedVerts.last() =
f[fp];
2126 label startEdgei = fEdges[startFp];
2128 label meshEdgei = meshEdges[startEdgei];
2130 label numEdgeSideFaces = edgeLayers[startEdgei];
2132 for (label i = 0; i < numEdgeSideFaces; i++)
2134 label vEnd = stringedVerts.last();
2135 label vStart = stringedVerts[0];
2138 label newFp = 2*stringedVerts.size();
2144 if (addedPoints_[vEnd].size())
2147 addedPoints_[vEnd].size() - numEdgeSideFaces;
2149 if (addedPoints_[vStart].size())
2152 addedPoints_[vStart].size() - numEdgeSideFaces;
2156 face newFace(newFp);
2164 forAll(stringedVerts, stringedI)
2166 label v = stringedVerts[stringedI];
2172 : copiedPatchPoints[v]
2181 forAll(stringedVerts, stringedI)
2183 label v = stringedVerts[stringedI];
2184 if (addedPoints_[v].size())
2187 addedPoints_[v].size() - numEdgeSideFaces;
2190 addedPoints_[v][i+offset-1],
2202 : copiedPatchPoints[v]
2212 if (numEdgeSideFaces < addedPoints_[vEnd].size())
2214 if (i == 0 && addedPoints_[vEnd].size())
2217 addedPoints_[vEnd].size() - numEdgeSideFaces;
2218 for (label ioff = 0; ioff < offset; ioff++)
2222 addedPoints_[vEnd][ioff],
2232 label v = stringedVerts[stringedI];
2233 if (addedPoints_[v].size())
2236 addedPoints_[v].size() - numEdgeSideFaces;
2239 addedPoints_[v][i+offset],
2251 : copiedPatchPoints[v]
2261 if (numEdgeSideFaces < addedPoints_[vStart].size())
2263 if (i == 0 && addedPoints_[vStart].size())
2266 addedPoints_[vStart].size() - numEdgeSideFaces;
2267 for (label ioff = offset-1; ioff >= 0; ioff--)
2271 addedPoints_[vStart][ioff],
2291 if (!verts.insert(newFace[fp]))
2294 <<
"Duplicate vertex in face"
2295 <<
" to be added." <<
nl
2296 <<
"newFace:" << newFace <<
nl
2304 <<
" out of:" << numEdgeSideFaces <<
nl
2305 <<
"ExtrudeEdge:" << meshEdgei
2307 << mesh_.edges()[meshEdgei].line
2311 <<
"string:" << stringedVerts
2329 label nbrFacei = nbrFace
2336 const labelList& meshFaces = mesh_.edgeFaces
2345 bool zoneFlip =
false;
2346 if (edgeZoneID[startEdgei] != -1)
2348 zoneFlip = !edgeFlip[startEdgei];
2357 edgePatchID[startEdgei],
2358 edgeZoneID[startEdgei],
2360 inflateFaceID[startEdgei],
2392 const labelList& added = addedPoints_[oldPointi];
2395 newAdded.
setSize(added.size());
2409 addedPoints_.transfer(newAddedPoints);
2415 forAll(newLayerFaces, newFacei)
2417 label oldFacei =
faceMap[newFacei];
2419 const labelList& added = layerFaces_[oldFacei];
2421 labelList& newAdded = newLayerFaces[newFacei];
2422 newAdded.
setSize(added.size());
2431 newAdded[newI++] = newFacei;
2436 layerFaces_.transfer(newLayerFaces);