51 const labelList& eFaces = edgeFaces[edgeI];
53 if (eFaces.size() == 2)
55 return (eFaces[0] != facei ? eFaces[0] : eFaces[1]);
64 void Foam::addPatchCellLayer::addVertex
77 if (
f[fp-1] != pointi &&
f[0] != pointi)
85 bool Foam::addPatchCellLayer::sameEdgeNeighbour
90 const label thisGlobalFacei,
91 const label nbrGlobalFacei,
95 const edge&
e = pp.edges()[edgeI];
100 addedPoints_[
e[0]].size()
101 || addedPoints_[
e[1]].size()
104 nbrFace(globalEdgeFaces, edgeI, thisGlobalFacei)
115 const label patchFacei,
116 const label globalFacei
119 const labelList& fEdges = pp.faceEdges()[patchFacei];
127 label edgeI = fEdges[fp];
128 const edge&
e = pp.edges()[edgeI];
133 && ( addedPoints_[
e[0]].size() || addedPoints_[
e[1]].size() )
145 label nbrGlobalFacei = nbrFace
152 if (nbrGlobalFacei == -1)
165 label prevFp = fEdges.rcIndex(startFp);
189 label nextFp = fEdges.fcIndex(endFp);
220 const label newPatchID,
222 const label ownFacei,
223 const label nbrFacei,
225 const label numEdgeFaces,
227 polyTopoChange& meshMod
230 label masterFacei = -1;
231 label addedFacei = -1;
238 const polyBoundaryMesh&
patches = mesh_.boundaryMesh();
244 label meshFacei = pp.addressing()[ownFacei];
248 label facei = meshFaces[
k];
253 && (
patches.whichPatch(facei) == newPatchID)
268 if (addedCells[ownFacei].size() < numEdgeFaces)
270 label offset = numEdgeFaces - addedCells[ownFacei].size();
277 layerOwn = layerI -
offset;
285 addedFacei = meshMod.addFace
288 addedCells[ownFacei][layerOwn],
305 if (addedCells[ownFacei].size() > addedCells[nbrFacei].size())
308 addedCells[ownFacei].size() - addedCells[nbrFacei].size();
318 layerNbr = layerI -
offset;
321 else if (addedCells[nbrFacei].size() > addedCells[ownFacei].size())
324 addedCells[nbrFacei].size() - addedCells[ownFacei].size();
334 layerOwn = layerI -
offset;
344 addedFacei = meshMod.addFace
347 addedCells[ownFacei][layerOwn],
348 addedCells[nbrFacei][layerNbr],
361 const polyMesh& mesh,
362 const label nbrProcID
365 const polyBoundaryMesh&
patches = mesh.boundaryMesh();
367 forAll(mesh.globalData().processorPatches(), i)
369 label patchi = mesh.globalData().processorPatches()[i];
373 refCast<const processorPolyPatch>(
patches[
patchi]).neighbProcNo()
393 addToMesh_(addToMesh),
395 pointZonesAddedPoints_(mesh.pointZones().size()),
396 cellZonesAddedCells_(mesh.cellZones().size()),
411 forAll(layerFaces, patchFacei)
413 const labelList& faceLabels = layerFaces[patchFacei];
415 if (faceLabels.
size())
417 labelList& added = layerCells[patchFacei];
420 for (
label i = 0; i < faceLabels.
size()-1; i++)
432 return addedCells(mesh_, layerFaces_);
454 label meshEdgeI = meshEdges[edgeI];
456 const labelList& eFaces = edgeFaces[edgeI];
459 labelList& globalEFaces = globalEdgeFaces[meshEdgeI];
510 forAll(globalEdgeFaces, edgeI)
512 const labelList& eGlobalFaces = globalEdgeFaces[edgeI];
515 eGlobalFaces.
size() == 2
523 label f0 = eGlobalFaces[0];
524 label f1 = eGlobalFaces[1];
526 label otherProci = -1;
537 if (otherProci != -1)
539 sidePatchID[edgeI] = findProcPatch(mesh, otherProci);
540 if (sidePatchID[edgeI] == -1)
544 if (nbrProcToPatch.
found(otherProci))
546 sidePatchID[edgeI] = nbrProcToPatch[otherProci];
571 if (edgeFaces[edgeI].size() == 1 && sidePatchID[edgeI] == -1)
578 label meshEdgeI = meshEdges[edgeI];
587 label facei = meshFaces[
k];
592 masterFacei[edgeI] = facei;
606 if (edgeFaces[edgeI].size() == 1 && sidePatchID[edgeI] == -1)
610 <<
"Have no sidePatchID for edge " << edgeI <<
" points "
624 edgeFaces[edgeI].size() == 1
625 && sidePatchID[edgeI] != -1
626 && masterFacei[edgeI] == -1
634 label meshEdgeI = meshEdges[edgeI];
643 const label facei = meshFaces[
k];
649 &&
patches.whichPatch(facei) == sidePatchID[edgeI]
653 masterFacei[edgeI] = facei;
679 Pout<<
"addPatchCellLayer::setRefinement : Adding up to "
680 <<
gMax(nPointLayers)
681 <<
" layers of cells to indirectPrimitivePatch with "
693 <<
"Size of new points is not same as number of points used by"
694 <<
" the face subset" <<
endl
695 <<
" patch.nPoints:" << pp.
nPoints()
696 <<
" displacement:" << firstLayerDisp.
size()
697 <<
" nPointLayers:" << nPointLayers.
size() <<
nl
698 <<
" patch.nFaces:" << pp.
size()
699 <<
" nFaceLayers:" << nFaceLayers.
size()
705 if (nPointLayers[i] < 0)
708 <<
"Illegal number of layers " << nPointLayers[i]
714 if (nFaceLayers[i] < 0)
717 <<
"Illegal number of layers " << nFaceLayers[i]
722 forAll(globalEdgeFaces, edgeI)
724 if (globalEdgeFaces[edgeI].size() > 2)
728 if (nPointLayers[
e[0]] > 0 || nPointLayers[
e[1]] > 0)
731 <<
"Trying to extrude edge "
733 <<
" which is non-manifold (has "
734 << globalEdgeFaces[edgeI].
size()
735 <<
" faces using it)"
763 label meshPointi = meshPoints[i];
765 if (
n[meshPointi] != nPointLayers[i])
768 <<
"At mesh point:" << meshPointi
769 <<
" coordinate:" << mesh_.points()[meshPointi]
770 <<
" specified nLayers:" << nPointLayers[i] <<
endl
771 <<
"On coupled point a different nLayers:"
772 <<
n[meshPointi] <<
" was specified."
783 const face&
f = pp[i];
789 nFromFace[pointi] =
max(nFromFace[pointi], nFaceLayers[i]);
802 label meshPointi = meshPoints[i];
807 && nPointLayers[i] != nFromFace[meshPointi]
811 <<
"At mesh point:" << meshPointi
812 <<
" coordinate:" << mesh_.points()[meshPointi]
813 <<
" specified nLayers:" << nPointLayers[i] <<
endl
814 <<
"but the max nLayers of surrounding faces is:"
815 << nFromFace[meshPointi]
834 label meshPointi = meshPoints[i];
836 if (
mag(d[meshPointi] - firstLayerDisp[i]) > small)
839 <<
"At mesh point:" << meshPointi
840 <<
" coordinate:" << mesh_.points()[meshPointi]
841 <<
" specified displacement:" << firstLayerDisp[i]
843 <<
"On coupled point a different displacement:"
844 << d[meshPointi] <<
" was specified."
860 if (nPointLayers[
e[0]] > 0 || nPointLayers[
e[1]] > 0)
867 if (eFaces.
size() != 1)
870 <<
"boundary-edge-to-be-extruded:"
871 << pp.
points()[meshPoints[
e[0]]]
872 << pp.
points()[meshPoints[
e[1]]]
873 <<
" has more than two faces using it:" << eFaces
879 label meshEdgeI = meshEdges[edgeI];
882 const labelList& meshFaces = mesh_.edgeFaces(meshEdgeI, ef);
891 label facei = meshFaces[i];
893 if (facei != myFacei)
895 if (!mesh_.isInternalFace(facei))
904 <<
"boundary-edge-to-be-extruded:"
905 << pp.
points()[meshPoints[
e[0]]]
906 << pp.
points()[meshPoints[
e[1]]]
907 <<
" has more than two boundary faces"
910 << mesh_.faceCentres()[bFacei]
911 <<
" patch:" <<
patches.whichPatch(bFacei)
912 <<
" and " << facei <<
" fc:"
913 << mesh_.faceCentres()[facei]
914 <<
" patch:" <<
patches.whichPatch(facei)
934 patchID[patchFacei] =
patches.whichPatch(meshFacei);
943 label nTruncated = 0;
945 forAll(nPointLayers, patchPointi)
947 if (nPointLayers[patchPointi] > 0)
949 addedPoints_[patchPointi].setSize(nPointLayers[patchPointi]);
959 Pout<<
"Not adding points at " << nTruncated <<
" out of "
973 forAll(firstLayerDisp, patchPointi)
975 if (addedPoints_[patchPointi].size())
977 const label meshPointi = meshPoints[patchPointi];
979 copiedPatchPoints[patchPointi] = meshMod.
addPoint
981 mesh_.points()[meshPointi],
986 forAll(mesh_.pointZones(), zonei)
988 if (mesh_.pointZones()[zonei].localIndex(meshPointi) != -1)
990 pointZonesAddedPoints_[zonei].insert
992 copiedPatchPoints[patchPointi]
1002 forAll(firstLayerDisp, patchPointi)
1004 if (addedPoints_[patchPointi].size())
1006 const label meshPointi = meshPoints[patchPointi];
1008 point pt = mesh_.points()[meshPointi];
1009 vector disp = firstLayerDisp[patchPointi];
1011 const labelList zones(mesh_.pointZones().whichZones(meshPointi));
1013 forAll(addedPoints_[patchPointi], i)
1020 (addToMesh_ ? meshPointi : -1),
1024 addedPoints_[patchPointi][i] = addedVertI;
1028 pointZonesAddedPoints_[zonei].insert(addedVertI);
1031 disp *= expansionRatio[patchPointi];
1045 if (nFaceLayers[patchFacei] > 0)
1047 addedCells[patchFacei].
setSize(nFaceLayers[patchFacei]);
1053 mesh_.cellZones().whichZones(mesh_.faceOwner()[meshFacei])
1056 for (
label i = 0; i < nFaceLayers[patchFacei]; i++)
1060 addedCells[patchFacei][i] = meshMod.
addCell
1062 (addToMesh_ ? mesh_.faceOwner()[meshFacei] : -1)
1067 cellZonesAddedCells_[ownZones[zonei]].insert
1069 addedCells[patchFacei][i]
1073 if (faceCellZones.
size() && faceCellZones[patchFacei] != -1)
1075 cellZonesAddedCells_[faceCellZones[patchFacei]].insert
1077 addedCells[patchFacei][i]
1090 layerFaces_.setSize(pp.
size());
1096 if (addedCells[patchFacei].size())
1098 layerFaces_[patchFacei].
setSize(addedCells[patchFacei].size() + 1);
1105 forAll(addedCells[patchFacei], i)
1109 if (addedPoints_[
f[fp]].empty())
1116 : copiedPatchPoints[
f[fp]]
1123 addedPoints_[
f[fp]].size()
1124 - addedCells[patchFacei].
size();
1125 newFace[fp] = addedPoints_[
f[fp]][i+
offset];
1134 if (i == addedCells[patchFacei].size()-1)
1138 patchi = patchID[patchFacei];
1143 nei = addedCells[patchFacei][i+1];
1147 layerFaces_[patchFacei][i+1] = meshMod.
addFace
1150 addedCells[patchFacei][i],
1152 (addToMesh_ ? meshFacei : -1),
1168 if (addedCells[patchFacei].size())
1172 layerFaces_[patchFacei][0] = meshFacei;
1178 mesh_.faceOwner()[meshFacei],
1179 addedCells[patchFacei][0],
1192 if (nFaceLayers[patchFacei] > 0)
1198 f[fp] = copiedPatchPoints[
f[fp]];
1201 layerFaces_[patchFacei][0] = meshMod.
addFace
1204 addedCells[patchFacei][0],
1208 exposedPatchID[patchFacei]
1231 labelList meshEdgeLayers(mesh_.nEdges(), -1);
1235 const edge&
e = edges[edgeI];
1237 label meshEdgeI = meshEdges[edgeI];
1239 if ((nPointLayers[
e[0]] == 0) && (nPointLayers[
e[1]] == 0))
1241 meshEdgeLayers[meshEdgeI] = 0;
1249 meshEdgeLayers[meshEdgeI] =
max
1251 nFaceLayers[eFaces[i]],
1252 meshEdgeLayers[meshEdgeI]
1268 edgeLayers[edgeI] = meshEdgeLayers[meshEdges[edgeI]];
1281 const labelList& fEdges = faceEdges[patchFacei];
1304 const label startFp = indexPair[0];
1305 const label endFp = indexPair[1];
1312 const face&
f = localFaces[patchFacei];
1315 if (endFp >= startFp)
1317 stringedVerts.
setSize(endFp-startFp+2);
1326 for (
label i = 0; i < stringedVerts.
size()-1; i++)
1328 stringedVerts[i] =
f[fp];
1329 doneEdge[fEdges[fp]] =
true;
1332 stringedVerts.
last() =
f[fp];
1342 label startEdgeI = fEdges[startFp];
1344 label meshEdgeI = meshEdges[startEdgeI];
1346 label numEdgeSideFaces = edgeLayers[startEdgeI];
1348 for (
label i = 0; i < numEdgeSideFaces; i++)
1351 label vStart = stringedVerts[0];
1360 if (addedPoints_[vEnd].size())
1363 addedPoints_[vEnd].size() - numEdgeSideFaces;
1365 if (addedPoints_[vStart].size())
1368 addedPoints_[vStart].size() - numEdgeSideFaces;
1372 face newFace(newFp);
1380 forAll(stringedVerts, stringedI)
1382 label v = stringedVerts[stringedI];
1388 : copiedPatchPoints[v]
1397 forAll(stringedVerts, stringedI)
1399 label v = stringedVerts[stringedI];
1400 if (addedPoints_[v].size())
1403 addedPoints_[v].size() - numEdgeSideFaces;
1406 addedPoints_[v][i+
offset-1],
1418 : copiedPatchPoints[v]
1428 if (numEdgeSideFaces < addedPoints_[vEnd].size())
1430 if (i == 0 && addedPoints_[vEnd].size())
1433 addedPoints_[vEnd].size() - numEdgeSideFaces;
1438 addedPoints_[vEnd][ioff],
1448 label v = stringedVerts[stringedI];
1449 if (addedPoints_[v].size())
1452 addedPoints_[v].size() - numEdgeSideFaces;
1455 addedPoints_[v][i+
offset],
1467 : copiedPatchPoints[v]
1477 if (numEdgeSideFaces < addedPoints_[vStart].size())
1479 if (i == 0 && addedPoints_[vStart].size())
1482 addedPoints_[vStart].size() - numEdgeSideFaces;
1487 addedPoints_[vStart][ioff],
1507 if (!verts.
insert(newFace[fp]))
1510 <<
"Duplicate vertex in face"
1511 <<
" to be added." <<
nl
1512 <<
"newFace:" << newFace <<
nl
1520 <<
" out of:" << numEdgeSideFaces <<
nl
1521 <<
"ExtrudeEdge:" << meshEdgeI
1523 << mesh_.edges()[meshEdgeI].line
1527 <<
"string:" << stringedVerts
1545 label nbrFacei = nbrFace
1552 const labelList& meshFaces = mesh_.edgeFaces
1564 sidePatchID[startEdgeI],
1595 const labelList& added = addedPoints_[oldPointi];
1612 addedPoints_.transfer(newAddedPoints);
1618 forAll(newLayerFaces, newFacei)
1622 const labelList& added = layerFaces_[oldFacei];
1624 labelList& newAdded = newLayerFaces[newFacei];
1634 newAdded[newI++] = newFacei;
1639 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.
void insert(const List< labelHashSet > &zonesIndices)
Insert given indices into zones.
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, const labelList &faceCellZones, polyTopoChange &meshMod)
Play commands into polyTopoChange to create layers on top.
void updateZones(polyMesh &mesh)
Update the mesh zones.
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 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.
label whichPatch(const label faceIndex) const
Return patch index for a given face label.
Mesh consisting of general polyhedral cells.
const pointZoneList & pointZones() const
Return point zones.
const cellZoneList & cellZones() const
Return cell zones.
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
virtual const labelList & faceNeighbour() const
Return face neighbour.
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.
const DynamicList< point > & points() const
Points. Shrunk after constructing mesh (or calling of compact())
label addCell(const label masterCellID)
Add cell and return new cell index.
label addPoint(const point &, const label masterPointID, const bool inCell)
Add point and return new point index.
void modifyFace(const face &f, const label facei, const label own, const label nei, const bool flipFaceFlux, const label patchID)
Modify vertices or cell of face.
label addFace(const face &f, const label own, const label nei, const label masterFaceID, const bool flipFaceFlux, const label patchID)
Add face to cells and return new face index.
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)