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 if (addedPoints_[patchPointi].size())
1739 label meshPointi = meshPoints[patchPointi];
1740 label zoneI = mesh_.pointZones().whichZone(meshPointi);
1741 copiedPatchPoints[patchPointi] = meshMod.
setAction
1745 mesh_.points()[meshPointi],
1757 forAll(firstLayerDisp, patchPointi)
1759 if (addedPoints_[patchPointi].size())
1761 label meshPointi = meshPoints[patchPointi];
1763 label zoneI = mesh_.pointZones().whichZone(meshPointi);
1765 point pt = mesh_.points()[meshPointi];
1767 vector disp = firstLayerDisp[patchPointi];
1769 forAll(addedPoints_[patchPointi], i)
1778 (addToMesh_ ? meshPointi : -1),
1784 addedPoints_[patchPointi][i] = addedVertI;
1786 disp *= expansionRatio[patchPointi];
1800 if (nFaceLayers[patchFacei] > 0)
1802 addedCells[patchFacei].setSize(nFaceLayers[patchFacei]);
1804 label meshFacei = pp.addressing()[patchFacei];
1806 label ownZoneI = mesh_.cellZones().whichZone
1808 mesh_.faceOwner()[meshFacei]
1811 for (label i = 0; i < nFaceLayers[patchFacei]; i++)
1815 addedCells[patchFacei][i] = meshMod.
setAction
1822 (addToMesh_ ? mesh_.faceOwner()[meshFacei] : -1),
1838 layerFaces_.setSize(pp.size());
1842 label meshFacei = pp.addressing()[patchFacei];
1844 if (addedCells[patchFacei].size())
1846 layerFaces_[patchFacei].setSize(addedCells[patchFacei].size() + 1);
1851 face newFace(
f.size());
1853 forAll(addedCells[patchFacei], i)
1857 if (addedPoints_[
f[fp]].empty())
1864 : copiedPatchPoints[
f[fp]]
1871 addedPoints_[
f[fp]].size()
1872 - addedCells[patchFacei].size();
1873 newFace[fp] = addedPoints_[
f[fp]][i+offset];
1885 if (i == addedCells[patchFacei].size()-1)
1890 zoneI = mesh_.faceZones().whichZone(meshFacei);
1893 const faceZone& fz = mesh_.faceZones()[zoneI];
1900 nei = addedCells[patchFacei][i+1];
1905 layerFaces_[patchFacei][i+1] = meshMod.
setAction
1910 addedCells[patchFacei][i],
1914 (addToMesh_ ? meshFacei : -1),
1933 if (addedCells[patchFacei].size())
1935 label meshFacei = pp.addressing()[patchFacei];
1937 layerFaces_[patchFacei][0] = meshFacei;
1945 mesh_.faceOwner()[meshFacei],
1946 addedCells[patchFacei][0],
1963 if (nFaceLayers[patchFacei] > 0)
1965 label meshFacei = pp.addressing()[patchFacei];
1966 label zoneI = mesh_.faceZones().whichZone(meshFacei);
1967 bool zoneFlip =
false;
1970 const faceZone& fz = mesh_.faceZones()[zoneI];
1978 f[fp] = copiedPatchPoints[
f[fp]];
1981 layerFaces_[patchFacei][0] = meshMod.
setAction
1986 addedCells[patchFacei][0],
1992 exposedPatchID[patchFacei],
2018 labelList meshEdgeLayers(mesh_.nEdges(), -1);
2022 const edge&
e = edges[edgei];
2024 label meshEdgei = meshEdges[edgei];
2026 if ((nPointLayers[
e[0]] == 0) && (nPointLayers[
e[1]] == 0))
2028 meshEdgeLayers[meshEdgei] = 0;
2036 meshEdgeLayers[meshEdgei] =
max
2038 nFaceLayers[eFaces[i]],
2039 meshEdgeLayers[meshEdgei]
2055 edgeLayers[edgei] = meshEdgeLayers[meshEdges[edgei]];
2068 const labelList& fEdges = faceEdges[patchFacei];
2082 globalFaces.
toGlobal(pp.addressing()[patchFacei])
2091 const label startFp = indexPair[0];
2092 const label endFp = indexPair[1];
2099 const face&
f = localFaces[patchFacei];
2102 if (endFp >= startFp)
2104 stringedVerts.
setSize(endFp-startFp+2);
2108 stringedVerts.
setSize(endFp+
f.size()-startFp+2);
2113 for (label i = 0; i < stringedVerts.size()-1; i++)
2115 stringedVerts[i] =
f[fp];
2116 doneEdge[fEdges[fp]] =
true;
2119 stringedVerts.last() =
f[fp];
2129 label startEdgei = fEdges[startFp];
2131 label meshEdgei = meshEdges[startEdgei];
2133 label numEdgeSideFaces = edgeLayers[startEdgei];
2135 for (label i = 0; i < numEdgeSideFaces; i++)
2137 label vEnd = stringedVerts.last();
2138 label vStart = stringedVerts[0];
2141 label newFp = 2*stringedVerts.size();
2147 if (addedPoints_[vEnd].size())
2150 addedPoints_[vEnd].size() - numEdgeSideFaces;
2152 if (addedPoints_[vStart].size())
2155 addedPoints_[vStart].size() - numEdgeSideFaces;
2159 face newFace(newFp);
2167 forAll(stringedVerts, stringedI)
2169 label v = stringedVerts[stringedI];
2175 : copiedPatchPoints[v]
2184 forAll(stringedVerts, stringedI)
2186 label v = stringedVerts[stringedI];
2187 if (addedPoints_[v].size())
2190 addedPoints_[v].size() - numEdgeSideFaces;
2193 addedPoints_[v][i+offset-1],
2205 : copiedPatchPoints[v]
2215 if (numEdgeSideFaces < addedPoints_[vEnd].size())
2217 if (i == 0 && addedPoints_[vEnd].size())
2220 addedPoints_[vEnd].size() - numEdgeSideFaces;
2221 for (label ioff = 0; ioff < offset; ioff++)
2225 addedPoints_[vEnd][ioff],
2235 label v = stringedVerts[stringedI];
2236 if (addedPoints_[v].size())
2239 addedPoints_[v].size() - numEdgeSideFaces;
2242 addedPoints_[v][i+offset],
2254 : copiedPatchPoints[v]
2264 if (numEdgeSideFaces < addedPoints_[vStart].size())
2266 if (i == 0 && addedPoints_[vStart].size())
2269 addedPoints_[vStart].size() - numEdgeSideFaces;
2270 for (label ioff = offset-1; ioff >= 0; ioff--)
2274 addedPoints_[vStart][ioff],
2294 if (!verts.insert(newFace[fp]))
2297 <<
"Duplicate vertex in face"
2298 <<
" to be added." <<
nl
2299 <<
"newFace:" << newFace <<
nl
2307 <<
" out of:" << numEdgeSideFaces <<
nl
2308 <<
"ExtrudeEdge:" << meshEdgei
2310 << mesh_.edges()[meshEdgei].line
2314 <<
"string:" << stringedVerts
2332 label nbrFacei = nbrFace
2339 const labelList& meshFaces = mesh_.edgeFaces
2348 bool zoneFlip =
false;
2349 if (edgeZoneID[startEdgei] != -1)
2351 zoneFlip = !edgeFlip[startEdgei];
2360 edgePatchID[startEdgei],
2361 edgeZoneID[startEdgei],
2363 inflateFaceID[startEdgei],
2395 const labelList& added = addedPoints_[oldPointi];
2398 newAdded.
setSize(added.size());
2412 addedPoints_.transfer(newAddedPoints);
2418 forAll(newLayerFaces, newFacei)
2420 label oldFacei =
faceMap[newFacei];
2422 const labelList& added = layerFaces_[oldFacei];
2424 labelList& newAdded = newLayerFaces[newFacei];
2425 newAdded.
setSize(added.size());
2434 newAdded[newI++] = newFacei;
2439 layerFaces_.transfer(newLayerFaces);