55 const labelList& eFaces = edgeFaces[edgeI];
57 if (eFaces.size() == 2)
59 return (eFaces[0] != facei ? eFaces[0] : eFaces[1]);
68 void Foam::addPatchCellLayer::addVertex
81 if (
f[fp-1] != pointi &&
f[0] != pointi)
91 bool Foam::addPatchCellLayer::sameEdgeNeighbour
96 const label thisGlobalFacei,
97 const label nbrGlobalFacei,
101 const edge&
e = pp.edges()[edgeI];
106 addedPoints_[
e[0]].size()
107 || addedPoints_[
e[1]].size()
110 nbrFace(globalEdgeFaces, edgeI, thisGlobalFacei)
124 const label patchFacei,
125 const label globalFacei
128 const labelList& fEdges = pp.faceEdges()[patchFacei];
136 label edgeI = fEdges[fp];
137 const edge&
e = pp.edges()[edgeI];
142 && ( addedPoints_[
e[0]].size() || addedPoints_[
e[1]].size() )
154 label nbrGlobalFacei = nbrFace
161 if (nbrGlobalFacei == -1)
174 label prevFp = fEdges.rcIndex(startFp);
198 label nextFp = fEdges.fcIndex(endFp);
230 const label newPatchID,
232 const label ownFacei,
233 const label nbrFacei,
234 const label meshEdgeI,
236 const label numEdgeFaces,
238 polyTopoChange& meshMod
242 label inflateEdgeI = -1;
243 label inflateFacei = -1;
250 if (mesh_.isInternalFace(meshFaces[i]))
253 inflateEdgeI = meshEdgeI;
264 label addedFacei = -1;
271 const polyBoundaryMesh&
patches = mesh_.boundaryMesh();
277 label meshFacei = pp.addressing()[ownFacei];
281 label facei = meshFaces[
k];
286 && (
patches.whichPatch(facei) == newPatchID)
291 inflateFacei = facei;
293 zoneI = mesh_.faceZones().whichZone(facei);
296 label index = mesh_.faceZones()[zoneI].whichFace(facei);
297 flip = mesh_.faceZones()[zoneI].flipMap()[index];
309 if (addedCells[ownFacei].size() < numEdgeFaces)
311 label offset = numEdgeFaces - addedCells[ownFacei].size();
318 layerOwn = layerI -
offset;
332 addedFacei = meshMod.setAction
337 addedCells[ownFacei][layerOwn],
359 if (addedCells[ownFacei].size() > addedCells[nbrFacei].size())
362 addedCells[ownFacei].size() - addedCells[nbrFacei].size();
372 layerNbr = layerI -
offset;
375 else if (addedCells[nbrFacei].size() > addedCells[ownFacei].size())
378 addedCells[nbrFacei].size() - addedCells[ownFacei].size();
388 layerOwn = layerI -
offset;
398 addedFacei = meshMod.setAction
403 addedCells[ownFacei][layerOwn],
404 addedCells[nbrFacei][layerNbr],
427 const polyMesh& mesh,
428 const label nbrProcID
431 const polyBoundaryMesh&
patches = mesh.boundaryMesh();
433 forAll(mesh.globalData().processorPatches(), i)
435 label patchi = mesh.globalData().processorPatches()[i];
439 refCast<const processorPolyPatch>(
patches[
patchi]).neighbProcNo()
450 void Foam::addPatchCellLayer::setFaceProps
452 const polyMesh& mesh,
460 patchi = mesh.boundaryMesh().whichPatch(facei);
461 zoneI = mesh.faceZones().whichZone(facei);
464 label index = mesh.faceZones()[zoneI].whichFace(facei);
465 zoneFlip = mesh.faceZones()[zoneI].flipMap()[index];
480 addToMesh_(addToMesh),
496 forAll(layerFaces, patchFacei)
498 const labelList& faceLabels = layerFaces[patchFacei];
500 if (faceLabels.
size())
502 labelList& added = layerCells[patchFacei];
505 for (
label i = 0; i < faceLabels.
size()-1; i++)
517 return addedCells(mesh_, layerFaces_);
540 label meshEdgeI = meshEdges[edgeI];
542 const labelList& eFaces = edgeFaces[edgeI];
545 labelList& globalEFaces = globalEdgeFaces[meshEdgeI];
599 forAll(globalEdgeFaces, edgeI)
601 const labelList& eGlobalFaces = globalEdgeFaces[edgeI];
604 eGlobalFaces.
size() == 2
612 label f0 = eGlobalFaces[0];
613 label f1 = eGlobalFaces[1];
615 label otherProci = -1;
626 if (otherProci != -1)
628 sidePatchID[edgeI] = findProcPatch(mesh, otherProci);
629 if (sidePatchID[edgeI] == -1)
633 if (nbrProcToPatch.
found(otherProci))
635 sidePatchID[edgeI] = nbrProcToPatch[otherProci];
660 if (edgeFaces[edgeI].size() == 1 && sidePatchID[edgeI] == -1)
667 label meshEdgeI = meshEdges[edgeI];
676 label facei = meshFaces[
k];
689 inflateFacei[edgeI] = facei;
690 inflateEdgeI[edgeI] = -1;
705 if (edgeFaces[edgeI].size() == 1 && sidePatchID[edgeI] == -1)
709 <<
"Have no sidePatchID for edge " << edgeI <<
" points "
725 edgeFaces[edgeI].size() == 1
726 && sidePatchID[edgeI] != -1
727 && inflateFacei[edgeI] == -1
735 label meshEdgeI = meshEdges[edgeI];
744 label facei = meshFaces[
k];
746 if (facei != myFacei)
750 inflateEdgeI[edgeI] = meshEdgeI;
754 if (
patches.whichPatch(facei) == sidePatchID[edgeI])
765 inflateFacei[edgeI] = facei;
766 inflateEdgeI[edgeI] = -1;
794 Pout<<
"addPatchCellLayer::setRefinement : Adding up to "
795 <<
gMax(nPointLayers)
796 <<
" layers of cells to indirectPrimitivePatch with "
808 <<
"Size of new points is not same as number of points used by"
809 <<
" the face subset" <<
endl
810 <<
" patch.nPoints:" << pp.
nPoints()
811 <<
" displacement:" << firstLayerDisp.
size()
812 <<
" nPointLayers:" << nPointLayers.
size() <<
nl
813 <<
" patch.nFaces:" << pp.
size()
814 <<
" nFaceLayers:" << nFaceLayers.
size()
820 if (nPointLayers[i] < 0)
823 <<
"Illegal number of layers " << nPointLayers[i]
829 if (nFaceLayers[i] < 0)
832 <<
"Illegal number of layers " << nFaceLayers[i]
837 forAll(globalEdgeFaces, edgeI)
839 if (globalEdgeFaces[edgeI].size() > 2)
843 if (nPointLayers[
e[0]] > 0 || nPointLayers[
e[1]] > 0)
846 <<
"Trying to extrude edge "
848 <<
" which is non-manifold (has "
849 << globalEdgeFaces[edgeI].
size()
850 <<
" faces using it)"
878 label meshPointi = meshPoints[i];
880 if (
n[meshPointi] != nPointLayers[i])
883 <<
"At mesh point:" << meshPointi
884 <<
" coordinate:" << mesh_.points()[meshPointi]
885 <<
" specified nLayers:" << nPointLayers[i] <<
endl
886 <<
"On coupled point a different nLayers:"
887 <<
n[meshPointi] <<
" was specified."
898 const face&
f = pp[i];
904 nFromFace[pointi] =
max(nFromFace[pointi], nFaceLayers[i]);
917 label meshPointi = meshPoints[i];
922 && nPointLayers[i] != nFromFace[meshPointi]
926 <<
"At mesh point:" << meshPointi
927 <<
" coordinate:" << mesh_.points()[meshPointi]
928 <<
" specified nLayers:" << nPointLayers[i] <<
endl
929 <<
"but the max nLayers of surrounding faces is:"
930 << nFromFace[meshPointi]
949 label meshPointi = meshPoints[i];
951 if (
mag(d[meshPointi] - firstLayerDisp[i]) > small)
954 <<
"At mesh point:" << meshPointi
955 <<
" coordinate:" << mesh_.points()[meshPointi]
956 <<
" specified displacement:" << firstLayerDisp[i]
958 <<
"On coupled point a different displacement:"
959 << d[meshPointi] <<
" was specified."
975 if (nPointLayers[
e[0]] > 0 || nPointLayers[
e[1]] > 0)
982 if (eFaces.
size() != 1)
985 <<
"boundary-edge-to-be-extruded:"
986 << pp.
points()[meshPoints[
e[0]]]
987 << pp.
points()[meshPoints[
e[1]]]
988 <<
" has more than two faces using it:" << eFaces
994 label meshEdgeI = meshEdges[edgeI];
997 const labelList& meshFaces = mesh_.edgeFaces(meshEdgeI, ef);
1006 label facei = meshFaces[i];
1008 if (facei != myFacei)
1010 if (!mesh_.isInternalFace(facei))
1019 <<
"boundary-edge-to-be-extruded:"
1020 << pp.
points()[meshPoints[
e[0]]]
1021 << pp.
points()[meshPoints[
e[1]]]
1022 <<
" has more than two boundary faces"
1025 << mesh_.faceCentres()[bFacei]
1026 <<
" patch:" <<
patches.whichPatch(bFacei)
1027 <<
" and " << facei <<
" fc:"
1028 << mesh_.faceCentres()[facei]
1029 <<
" patch:" <<
patches.whichPatch(facei)
1049 patchID[patchFacei] =
patches.whichPatch(meshFacei);
1058 label nTruncated = 0;
1060 forAll(nPointLayers, patchPointi)
1062 if (nPointLayers[patchPointi] > 0)
1064 addedPoints_[patchPointi].setSize(nPointLayers[patchPointi]);
1074 Pout<<
"Not adding points at " << nTruncated <<
" out of "
1088 forAll(firstLayerDisp, patchPointi)
1090 if (addedPoints_[patchPointi].size())
1092 label meshPointi = meshPoints[patchPointi];
1093 label zoneI = mesh_.pointZones().whichZone(meshPointi);
1094 copiedPatchPoints[patchPointi] = meshMod.
setAction
1098 mesh_.points()[meshPointi],
1110 forAll(firstLayerDisp, patchPointi)
1112 if (addedPoints_[patchPointi].size())
1114 label meshPointi = meshPoints[patchPointi];
1116 label zoneI = mesh_.pointZones().whichZone(meshPointi);
1118 point pt = mesh_.points()[meshPointi];
1120 vector disp = firstLayerDisp[patchPointi];
1122 forAll(addedPoints_[patchPointi], i)
1131 (addToMesh_ ? meshPointi : -1),
1137 addedPoints_[patchPointi][i] = addedVertI;
1139 disp *= expansionRatio[patchPointi];
1153 if (nFaceLayers[patchFacei] > 0)
1155 addedCells[patchFacei].
setSize(nFaceLayers[patchFacei]);
1159 label ownZoneI = mesh_.cellZones().whichZone
1161 mesh_.faceOwner()[meshFacei]
1164 for (
label i = 0; i < nFaceLayers[patchFacei]; i++)
1168 addedCells[patchFacei][i] = meshMod.
setAction
1175 (addToMesh_ ? mesh_.faceOwner()[meshFacei] : -1),
1191 layerFaces_.setSize(pp.
size());
1197 if (addedCells[patchFacei].size())
1199 layerFaces_[patchFacei].
setSize(addedCells[patchFacei].size() + 1);
1206 forAll(addedCells[patchFacei], i)
1210 if (addedPoints_[
f[fp]].empty())
1217 : copiedPatchPoints[
f[fp]]
1224 addedPoints_[
f[fp]].size()
1225 - addedCells[patchFacei].
size();
1226 newFace[fp] = addedPoints_[
f[fp]][i+
offset];
1238 if (i == addedCells[patchFacei].size()-1)
1242 patchi = patchID[patchFacei];
1243 zoneI = mesh_.faceZones().whichZone(meshFacei);
1246 const faceZone& fz = mesh_.faceZones()[zoneI];
1253 nei = addedCells[patchFacei][i+1];
1258 layerFaces_[patchFacei][i+1] = meshMod.
setAction
1263 addedCells[patchFacei][i],
1267 (addToMesh_ ? meshFacei : -1),
1286 if (addedCells[patchFacei].size())
1290 layerFaces_[patchFacei][0] = meshFacei;
1298 mesh_.faceOwner()[meshFacei],
1299 addedCells[patchFacei][0],
1316 if (nFaceLayers[patchFacei] > 0)
1319 label zoneI = mesh_.faceZones().whichZone(meshFacei);
1320 bool zoneFlip =
false;
1323 const faceZone& fz = mesh_.faceZones()[zoneI];
1331 f[fp] = copiedPatchPoints[
f[fp]];
1334 layerFaces_[patchFacei][0] = meshMod.
setAction
1339 addedCells[patchFacei][0],
1345 exposedPatchID[patchFacei],
1371 labelList meshEdgeLayers(mesh_.nEdges(), -1);
1375 const edge&
e = edges[edgeI];
1377 label meshEdgeI = meshEdges[edgeI];
1379 if ((nPointLayers[
e[0]] == 0) && (nPointLayers[
e[1]] == 0))
1381 meshEdgeLayers[meshEdgeI] = 0;
1389 meshEdgeLayers[meshEdgeI] =
max
1391 nFaceLayers[eFaces[i]],
1392 meshEdgeLayers[meshEdgeI]
1408 edgeLayers[edgeI] = meshEdgeLayers[meshEdges[edgeI]];
1421 const labelList& fEdges = faceEdges[patchFacei];
1444 const label startFp = indexPair[0];
1445 const label endFp = indexPair[1];
1452 const face&
f = localFaces[patchFacei];
1455 if (endFp >= startFp)
1457 stringedVerts.
setSize(endFp-startFp+2);
1466 for (
label i = 0; i < stringedVerts.
size()-1; i++)
1468 stringedVerts[i] =
f[fp];
1469 doneEdge[fEdges[fp]] =
true;
1472 stringedVerts.
last() =
f[fp];
1482 label startEdgeI = fEdges[startFp];
1484 label meshEdgeI = meshEdges[startEdgeI];
1486 label numEdgeSideFaces = edgeLayers[startEdgeI];
1488 for (
label i = 0; i < numEdgeSideFaces; i++)
1491 label vStart = stringedVerts[0];
1500 if (addedPoints_[vEnd].size())
1503 addedPoints_[vEnd].size() - numEdgeSideFaces;
1505 if (addedPoints_[vStart].size())
1508 addedPoints_[vStart].size() - numEdgeSideFaces;
1512 face newFace(newFp);
1520 forAll(stringedVerts, stringedI)
1522 label v = stringedVerts[stringedI];
1528 : copiedPatchPoints[v]
1537 forAll(stringedVerts, stringedI)
1539 label v = stringedVerts[stringedI];
1540 if (addedPoints_[v].size())
1543 addedPoints_[v].size() - numEdgeSideFaces;
1546 addedPoints_[v][i+
offset-1],
1558 : copiedPatchPoints[v]
1568 if (numEdgeSideFaces < addedPoints_[vEnd].size())
1570 if (i == 0 && addedPoints_[vEnd].size())
1573 addedPoints_[vEnd].size() - numEdgeSideFaces;
1578 addedPoints_[vEnd][ioff],
1588 label v = stringedVerts[stringedI];
1589 if (addedPoints_[v].size())
1592 addedPoints_[v].size() - numEdgeSideFaces;
1595 addedPoints_[v][i+
offset],
1607 : copiedPatchPoints[v]
1617 if (numEdgeSideFaces < addedPoints_[vStart].size())
1619 if (i == 0 && addedPoints_[vStart].size())
1622 addedPoints_[vStart].size() - numEdgeSideFaces;
1627 addedPoints_[vStart][ioff],
1647 if (!verts.
insert(newFace[fp]))
1650 <<
"Duplicate vertex in face"
1651 <<
" to be added." <<
nl
1652 <<
"newFace:" << newFace <<
nl
1660 <<
" out of:" << numEdgeSideFaces <<
nl
1661 <<
"ExtrudeEdge:" << meshEdgeI
1663 << mesh_.edges()[meshEdgeI].line
1667 <<
"string:" << stringedVerts
1685 label nbrFacei = nbrFace
1692 const labelList& meshFaces = mesh_.edgeFaces
1704 sidePatchID[startEdgeI],
1736 const labelList& added = addedPoints_[oldPointi];
1753 addedPoints_.transfer(newAddedPoints);
1759 forAll(newLayerFaces, newFacei)
1763 const labelList& added = layerFaces_[oldFacei];
1765 labelList& newAdded = newLayerFaces[newFacei];
1775 newAdded[newI++] = newFacei;
1780 layerFaces_.transfer(newLayerFaces);
#define forAll(list, i)
Loop across all elements in list.
#define forAllReverse(list, i)
Reverse loop across all elements in list.
bool insert(const Key &key)
Insert a new entry.
bool insert(const Key &, const T &newElmt)
Insert a new hashedEntry.
bool found(const Key &) const
Return true if hashedEntry is found in table.
void size(const label)
Override size to be inconsistent with allocated storage.
void setSize(const label)
Reset size of List.
label nEdges() const
Return number of edges in patch.
label nPoints() const
Return number of points supporting patch faces.
const edgeList & edges() const
Return list of edges, address into LOCAL point list.
label nInternalEdges() const
Number of internal edges.
labelList meshEdges(const edgeList &allEdges, const labelListList &cellEdges, const labelList &faceCells) const
Return labels of patch edges in the global edge list using.
const labelList & meshPoints() const
Return labelList of mesh points in patch. They are constructed.
const Field< PointType > & points() const
Return reference to global points.
const List< FaceType > & localFaces() const
Return patch faces addressing into local point list.
const labelListList & edgeFaces() const
Return edge-face addressing.
const labelListList & faceEdges() const
Return face-edge addressing.
const Field< PointType > & localPoints() const
Return pointField of points in patch.
void setSize(const label)
Reset size of PtrList. If extending the PtrList, new entries are.
A List with indirect addressing.
label size() const
Return the number of elements in the list.
const List< label > & addressing() const
Return the list addressing.
label fcIndex(const label i) const
Return the forward circular index, i.e. the next index.
T & last()
Return the last element of the list.
label size() const
Return the number of elements in the UPtrList.
Adds layers of cells to outside of polyPatch. Can optionally create stand-alone extruded mesh (addToM...
static void calcSidePatch(const polyMesh &, const globalIndex &globalFaces, const labelListList &globalEdgeFaces, const indirectPrimitivePatch &pp, labelList &sidePatchID, label &nPatches, Map< label > &nbrProcToPatch, Map< label > &patchToNbrProc)
Boundary edges get extruded into boundary faces. Determine patch.
void setRefinement(const globalIndex &globalFaces, const labelListList &globalEdgeFaces, const scalarField &expansionRatio, const indirectPrimitivePatch &pp, const labelList &sidePatchID, const labelList &exposedPatchID, const labelList &nFaceLayers, const labelList &nPointLayers, const vectorField &firstLayerDisp, polyTopoChange &meshMod)
Play commands into polyTopoChange to create layers on top.
void topoChange(const polyTopoChangeMap &, const labelList &faceMap, const labelList &pointMap)
Update any locally stored mesh information. Gets additional.
addPatchCellLayer(const polyMesh &, const bool addToMesh=true)
Construct from mesh.
labelListList addedCells() const
Added cells given current mesh & layerfaces.
static labelListList globalEdgeFaces(const polyMesh &, const globalIndex &globalFaces, const indirectPrimitivePatch &pp)
Per patch edge the pp faces (in global indices) using it. Uses.
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
A subset of mesh faces organised as a primitive patch.
const boolList & flipMap() const
Return face flip map.
label whichFace(const label globalCellID) const
Helper function to re-direct to zone::localID(...)
A face is a list of labels corresponding to mesh vertices.
Calculates a unique integer (label so might not have enough room - 2G max) for processor + local inde...
label whichProcID(const label i) const
Which processor does global come from? Binary search.
label toGlobal(const label i) const
From local to global.
bool isLocal(const label i) const
Is on local processor.
Class containing data for cell addition.
A face addition data class. A face can be inflated either from a point or from another face and can e...
Class containing data for point addition.
Mesh consisting of general polyhedral cells.
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
virtual const labelList & faceNeighbour() const
Return face neighbour.
Class describing modification of a face.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
const labelList & reversePointMap() const
Reverse point map.
const labelList & reverseFaceMap() const
Reverse face map.
Direct mesh changes based on v1.3 polyTopoChange syntax.
label setAction(const topoAction &action)
For compatibility with polyTopoChange: set topological action.
const DynamicList< point > & points() const
Points. Shrunk after constructing mesh (or calling of compact())
const labelListList & pointEdges() const
const edgeList & edges() const
Return mesh edges. Uses calcEdges.
const labelListList & edgeFaces() const
bool isInternalFace(const label faceIndex) const
Return true if given face label is internal to the mesh.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
const fvPatchList & patches
#define WarningInFunction
Report a warning using Foam::Warning.
Pair< label > labelPair
Label pair.
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.
errorManip< error > abort(error &err)
List< bool > boolList
Bool container classes.
List< labelList > labelListList
A List of labelList.
dimensioned< scalar > mag(const dimensioned< Type > &)
defineTypeNameAndDebug(combustionModel, 0)
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
prefixOSstream Pout(cout, "Pout")
void offset(label &lst, const label o)
PrimitivePatch< IndirectList< face >, const pointField & > indirectPrimitivePatch
Foam::indirectPrimitivePatch.
Type gMax(const FieldField< Field, Type > &f)