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();
312 if (layerI <= offset)
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();
366 if (layerI <= offset)
372 layerNbr = layerI - offset;
375 else if (addedCells[nbrFacei].size() > addedCells[ownFacei].size())
378 addedCells[nbrFacei].size() - addedCells[ownFacei].size();
382 if (layerI <= offset)
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];
473 Foam::addPatchCellLayer::addPatchCellLayer
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];
549 globalEFaces[i] = globalFaces.
toGlobal(pp.addressing()[eFaces[i]]);
597 nPatches = patches.
size();
599 forAll(globalEdgeFaces, edgeI)
601 const labelList& eGlobalFaces = globalEdgeFaces[edgeI];
604 eGlobalFaces.
size() == 2
612 label f0 = eGlobalFaces[0];
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];
640 nbrProcToPatch.
insert(otherProci, nPatches);
641 patchToNbrProc.
insert(nPatches, otherProci);
660 if (edgeFaces[edgeI].size() == 1 && sidePatchID[edgeI] == -1)
664 label myFacei = pp.addressing()[edgeFaces[edgeI][0]];
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
732 label myFacei = pp.addressing()[edgeFaces[edgeI][0]];
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 " 804 || pp.size() != nFaceLayers.
size()
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];
902 label pointi = f[fp];
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
992 label myFacei = pp.addressing()[eFaces[0]];
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]
1027 <<
" and " << facei <<
" fc:" 1028 << mesh_.faceCentres()[facei]
1047 label meshFacei = pp.addressing()[patchFacei];
1049 patchID[patchFacei] = patches.
whichPatch(meshFacei);
1055 addedPoints_.setSize(pp.
nPoints());
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]);
1157 label meshFacei = pp.addressing()[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());
1195 label meshFacei = pp.addressing()[patchFacei];
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())
1288 label meshFacei = pp.addressing()[patchFacei];
1290 layerFaces_[patchFacei][0] = meshFacei;
1298 mesh_.faceOwner()[meshFacei],
1299 addedCells[patchFacei][0],
1316 if (nFaceLayers[patchFacei] > 0)
1318 label meshFacei = pp.addressing()[patchFacei];
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];
1435 globalFaces.
toGlobal(pp.addressing()[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;
1574 for (
label ioff = 0; ioff < offset; ioff++)
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;
1623 for (
label ioff = offset-1; ioff >= 0; ioff--)
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)
1761 label oldFacei = faceMap[newFacei];
1763 const labelList& added = layerFaces_[oldFacei];
1765 labelList& newAdded = newLayerFaces[newFacei];
1775 newAdded[newI++] = newFacei;
1780 layerFaces_.transfer(newLayerFaces);
const DynamicList< point > & points() const
Points. Shrunk after constructing mesh (or calling of compact())
static const Vector< scalar > max
List< labelList > labelListList
A List of labelList.
label nPoints() const
Return number of points supporting patch faces.
linePointRef line(const pointField &) const
Return edge line.
#define forAll(list, i)
Loop across all elements in list.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
label toGlobal(const label i) const
From local to global.
const boolList & flipMap() const
Return face flip map.
Class describing modification of a face.
A face is a list of labels corresponding to mesh vertices.
const labelList & meshPoints() const
Return labelList of mesh points in patch. They are constructed.
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
const List< Face > & localFaces() const
Return patch faces addressing into local point list.
const edgeList & edges() const
Return mesh edges. Uses calcEdges.
void size(const label)
Override size to be inconsistent with allocated storage.
Ostream & endl(Ostream &os)
Add newline and flush stream.
const Field< PointType > & points() const
Return reference to global points.
#define forAllReverse(list, i)
Reverse loop across all elements in list.
Class containing data for point addition.
label k
Boltzmann constant.
bool isInternalFace(const label faceIndex) const
Return true if given face label is internal to the mesh.
PrimitivePatch< face, IndirectList, const pointField & > indirectPrimitivePatch
Foam::indirectPrimitivePatch.
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
A face addition data class. A face can be inflated either from a point or from another face and can e...
const labelListList & edgeFaces() const
label fcIndex(const label i) const
Return the forward circular index, i.e. the next index.
List< bool > boolList
Bool container classes.
bool insert(const Key &, const T &newElmt)
Insert a new hashedEntry.
label whichFace(const label globalCellID) const
Helper function to re-direct to zone::localID(...)
Class containing data for cell addition.
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...
An ordered pair of two objects of type <T> with first() and second() elements.
const labelList & reverseFaceMap() const
Reverse face map.
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
const labelListList & faceEdges() const
Return face-edge addressing.
const edgeList & edges() const
Return list of edges, address into LOCAL point list.
label whichProcID(const label i) const
Which processor does global come from? Binary search.
Pair< label > labelPair
Label pair.
List< label > labelList
A List of labels.
const labelListList & pointEdges() const
labelListList addedCells() const
Added cells given current mesh & layerfaces.
errorManip< error > abort(error &err)
bool found(const Key &) const
Return true if hashedEntry is found in table.
prefixOSstream Pout(cout,"Pout")
Type gMax(const FieldField< Field, Type > &f)
defineTypeNameAndDebug(combustionModel, 0)
label nEdges() const
Return number of edges in patch.
void updateMesh(const mapPolyMesh &, const labelList &faceMap, const labelList &pointMap)
Update any locally stored mesh information. Gets additional.
void setSize(const label)
Reset size of List.
virtual const labelList & faceNeighbour() const
Return face neighbour.
#define WarningInFunction
Report a warning using Foam::Warning.
label whichPatch(const label faceIndex) const
Return patch index for a given face label.
label nInternalEdges() const
Number of internal edges.
A List with indirect addressing.
Direct mesh changes based on v1.3 polyTopoChange syntax.
dimensioned< scalar > mag(const dimensioned< Type > &)
static labelListList globalEdgeFaces(const polyMesh &, const globalIndex &globalFaces, const indirectPrimitivePatch &pp)
Per patch edge the pp faces (in global indices) using it. Uses.
const labelListList & edgeFaces() const
Return edge-face addressing.
Mesh consisting of general polyhedral cells.
A subset of mesh faces organised as a primitive patch.
bool isLocal(const label i) const
Is on local processor.
T & last()
Return the last element of the list.
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.
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.
labelList meshEdges(const edgeList &allEdges, const labelListList &cellEdges, const labelList &faceCells) const
Return labels of patch edges in the global edge list using.
const Field< PointType > & localPoints() const
Return pointField of points in patch.
label size() const
Return the number of elements in the UPtrList.
const labelList & reversePointMap() const
Reverse point map.
label setAction(const topoAction &action)
For compatibility with polyTopoChange: set topological action.