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(startFe);
189 label nextFp = fEdges.fcIndex(endFe);
217 const polyMesh&
mesh,
221 const label newPatchID,
223 const label ownFacei,
224 const label nbrFacei,
226 const label numEdgeFaces,
228 polyTopoChange& meshMod
231 label masterFacei = -1;
232 label addedFacei = -1;
245 label meshFacei = pp.addressing()[ownFacei];
249 label facei = meshFaces[
k];
254 && (
patches.whichPatch(facei) == newPatchID)
269 if (addedCells[ownFacei].size() < numEdgeFaces)
271 label offset = numEdgeFaces - addedCells[ownFacei].size();
278 layerOwn = layerI -
offset;
286 addedFacei = meshMod.addFace
289 addedCells[ownFacei][layerOwn],
306 if (addedCells[ownFacei].size() > addedCells[nbrFacei].size())
309 addedCells[ownFacei].size() - addedCells[nbrFacei].size();
319 layerNbr = layerI -
offset;
322 else if (addedCells[nbrFacei].size() > addedCells[ownFacei].size())
325 addedCells[nbrFacei].size() - addedCells[ownFacei].size();
335 layerOwn = layerI -
offset;
345 addedFacei = meshMod.addFace
348 addedCells[ownFacei][layerOwn],
349 addedCells[nbrFacei][layerNbr],
362 const polyMesh&
mesh,
363 const label nbrProcID
374 refCast<const processorPolyPatch>(
patches[
patchi]).neighbProcNo()
393 addToMesh_(addToMesh),
395 pointZonesAddedPoints_(
mesh.pointZones().size()),
396 faceZonesAddedFaces_(
mesh.faceZones().size()),
397 cellZonesAddedCells_(
mesh.cellZones().size()),
412 forAll(layerFaces, patchFacei)
414 const labelList& faceLabels = layerFaces[patchFacei];
416 if (faceLabels.
size())
418 labelList& added = layerCells[patchFacei];
421 for (
label i = 0; i < faceLabels.
size()-1; i++)
436 return addedCells(
mesh, layerFaces_);
458 label meshEdgeI = meshEdges[edgeI];
460 const labelList& eFaces = edgeFaces[edgeI];
463 labelList& globalEFaces = globalEdgeFaces[meshEdgeI];
514 forAll(globalEdgeFaces, edgeI)
516 const labelList& eGlobalFaces = globalEdgeFaces[edgeI];
519 eGlobalFaces.
size() == 2
527 label f0 = eGlobalFaces[0];
528 label f1 = eGlobalFaces[1];
530 label otherProci = -1;
541 if (otherProci != -1)
543 sidePatchID[edgeI] = findProcPatch(
mesh, otherProci);
544 if (sidePatchID[edgeI] == -1)
548 if (nbrProcToPatch.
found(otherProci))
550 sidePatchID[edgeI] = nbrProcToPatch[otherProci];
575 if (edgeFaces[edgeI].size() == 1 && sidePatchID[edgeI] == -1)
582 label meshEdgeI = meshEdges[edgeI];
591 label facei = meshFaces[
k];
596 masterFacei[edgeI] = facei;
610 if (edgeFaces[edgeI].size() == 1 && sidePatchID[edgeI] == -1)
614 <<
"Have no sidePatchID for edge " << edgeI <<
" points "
628 edgeFaces[edgeI].size() == 1
629 && sidePatchID[edgeI] != -1
630 && masterFacei[edgeI] == -1
638 label meshEdgeI = meshEdges[edgeI];
647 const label facei = meshFaces[
k];
653 &&
patches.whichPatch(facei) == sidePatchID[edgeI]
657 masterFacei[edgeI] = facei;
684 Pout<<
"addPatchCellLayer::setRefinement : Adding up to "
685 <<
gMax(nPointLayers)
686 <<
" layers of cells to indirectPrimitivePatch with "
698 <<
"Size of new points is not same as number of points used by"
699 <<
" the face subset" <<
endl
700 <<
" patch.nPoints:" << pp.
nPoints()
701 <<
" displacement:" << firstLayerDisp.
size()
702 <<
" nPointLayers:" << nPointLayers.
size() <<
nl
703 <<
" patch.nFaces:" << pp.
size()
704 <<
" nFaceLayers:" << nFaceLayers.
size()
710 if (nPointLayers[i] < 0)
713 <<
"Illegal number of layers " << nPointLayers[i]
719 if (nFaceLayers[i] < 0)
722 <<
"Illegal number of layers " << nFaceLayers[i]
727 forAll(globalEdgeFaces, edgeI)
729 if (globalEdgeFaces[edgeI].size() > 2)
733 if (nPointLayers[
e[0]] > 0 || nPointLayers[
e[1]] > 0)
736 <<
"Trying to extrude edge "
738 <<
" which is non-manifold (has "
739 << globalEdgeFaces[edgeI].
size()
740 <<
" faces using it)"
768 label meshPointi = meshPoints[i];
770 if (
n[meshPointi] != nPointLayers[i])
773 <<
"At mesh point:" << meshPointi
774 <<
" coordinate:" <<
mesh.
points()[meshPointi]
775 <<
" specified nLayers:" << nPointLayers[i] <<
endl
776 <<
"On coupled point a different nLayers:"
777 <<
n[meshPointi] <<
" was specified."
788 const face&
f = pp[i];
794 nFromFace[pointi] =
max(nFromFace[pointi], nFaceLayers[i]);
807 label meshPointi = meshPoints[i];
812 && nPointLayers[i] != nFromFace[meshPointi]
816 <<
"At mesh point:" << meshPointi
817 <<
" coordinate:" <<
mesh.
points()[meshPointi]
818 <<
" specified nLayers:" << nPointLayers[i] <<
endl
819 <<
"but the max nLayers of surrounding faces is:"
820 << nFromFace[meshPointi]
839 label meshPointi = meshPoints[i];
841 if (
mag(d[meshPointi] - firstLayerDisp[i]) > small)
844 <<
"At mesh point:" << meshPointi
845 <<
" coordinate:" <<
mesh.
points()[meshPointi]
846 <<
" specified displacement:" << firstLayerDisp[i]
848 <<
"On coupled point a different displacement:"
849 << d[meshPointi] <<
" was specified."
865 if (nPointLayers[
e[0]] > 0 || nPointLayers[
e[1]] > 0)
872 if (eFaces.
size() != 1)
875 <<
"boundary-edge-to-be-extruded:"
876 << pp.
points()[meshPoints[
e[0]]]
877 << pp.
points()[meshPoints[
e[1]]]
878 <<
" has more than two faces using it:" << eFaces
884 label meshEdgeI = meshEdges[edgeI];
896 label facei = meshFaces[i];
898 if (facei != myFacei)
909 <<
"boundary-edge-to-be-extruded:"
910 << pp.
points()[meshPoints[
e[0]]]
911 << pp.
points()[meshPoints[
e[1]]]
912 <<
" has more than two boundary faces"
916 <<
" patch:" <<
patches.whichPatch(bFacei)
917 <<
" and " << facei <<
" fc:"
919 <<
" patch:" <<
patches.whichPatch(facei)
939 patchID[patchFacei] =
patches.whichPatch(meshFacei);
948 label nTruncated = 0;
950 forAll(nPointLayers, patchPointi)
952 if (nPointLayers[patchPointi] > 0)
954 addedPoints_[patchPointi].setSize(nPointLayers[patchPointi]);
964 Pout<<
"Not adding points at " << nTruncated <<
" out of "
978 forAll(firstLayerDisp, patchPointi)
980 if (addedPoints_[patchPointi].size())
982 const label meshPointi = meshPoints[patchPointi];
984 copiedPatchPoints[patchPointi] = meshMod.
addPoint
995 pointZonesAddedPoints_[zonei].insert
997 copiedPatchPoints[patchPointi]
1007 forAll(firstLayerDisp, patchPointi)
1009 if (addedPoints_[patchPointi].size())
1011 const label meshPointi = meshPoints[patchPointi];
1014 vector disp = firstLayerDisp[patchPointi];
1018 forAll(addedPoints_[patchPointi], i)
1025 (addToMesh_ ? meshPointi : -1),
1029 addedPoints_[patchPointi][i] = addedVertI;
1033 pointZonesAddedPoints_[zonei].insert(addedVertI);
1036 disp *= expansionRatio[patchPointi];
1050 if (nFaceLayers[patchFacei] > 0)
1052 addedCells[patchFacei].
setSize(nFaceLayers[patchFacei]);
1061 for (
label i = 0; i < nFaceLayers[patchFacei]; i++)
1065 addedCells[patchFacei][i] = meshMod.
addCell
1072 cellZonesAddedCells_[ownZones[zonei]].insert
1074 addedCells[patchFacei][i]
1078 if (faceCellZones.
size() && faceCellZones[patchFacei] != -1)
1080 cellZonesAddedCells_[faceCellZones[patchFacei]].insert
1082 addedCells[patchFacei][i]
1095 layerFaces_.setSize(pp.
size());
1101 if (addedCells[patchFacei].size())
1103 layerFaces_[patchFacei].
setSize(addedCells[patchFacei].size() + 1);
1110 forAll(addedCells[patchFacei], i)
1114 if (addedPoints_[
f[fp]].empty())
1121 : copiedPatchPoints[
f[fp]]
1128 addedPoints_[
f[fp]].size()
1129 - addedCells[patchFacei].
size();
1130 newFace[fp] = addedPoints_[
f[fp]][i+
offset];
1139 if (i == addedCells[patchFacei].size()-1)
1143 patchi = patchID[patchFacei];
1148 nei = addedCells[patchFacei][i+1];
1152 layerFaces_[patchFacei][i+1] = meshMod.
addFace
1155 addedCells[patchFacei][i],
1157 (addToMesh_ ? meshFacei : -1),
1174 if (addedCells[patchFacei].size())
1178 layerFaces_[patchFacei][0] = meshFacei;
1185 addedCells[patchFacei][0],
1198 if (nFaceLayers[patchFacei] > 0)
1204 f[fp] = copiedPatchPoints[
f[fp]];
1207 layerFaces_[patchFacei][0] = meshMod.
addFace
1210 addedCells[patchFacei][0],
1214 exposedPatchID[patchFacei]
1229 forAll(edgeLayers, ppEdgei)
1231 edgeLayers[ppEdgei] = 0;
1235 if (nPointLayers[
e[0]] != 0 || nPointLayers[
e[1]] != 0)
1241 edgeLayers[ppEdgei] =
max
1243 nFaceLayers[eFaces[eFacei]],
1271 const label meshEdgei = meshEdges[ppEdgei];
1278 forAll(edgeMeshFaces, edgeFacei)
1280 const label meshFacei = edgeMeshFaces[edgeFacei];
1284 if (meshFacePpFace[meshFacei] != -1)
continue;
1289 forAll(faceFaceZones, faceFaceZonei)
1291 const label faceZonei = faceFaceZones[faceFaceZonei];
1308 ppEdgeFaceZones[ppEdgei].
transfer(edgeFaceZones);
1325 forAll(ppEdgeFaceZones, ppEdgei)
1327 if (ppEdgeFaceZones[ppEdgei].empty())
continue;
1331 forAll(ppEdgeFaceZones[ppEdgei], ppEdgeFaceZonei)
1333 const label turnedZonei =
1334 ppEdgeFaceZones[ppEdgei][ppEdgeFaceZonei];
1336 faceZoneCount[
mag(turnedZonei) - 1] +=
sign(turnedZonei);
1341 forAll(faceZoneCount, faceZonei)
1343 if (faceZoneCount[faceZonei] != 0)
1347 sign(faceZoneCount[faceZonei])*(faceZonei + 1)
1352 ppEdgeFaceZones[ppEdgei].
transfer(edgeFaceZones);
1382 const label startFe = startAndEndFes[0];
1383 const label endFe = startAndEndFes[1];
1395 for (
label i = 0; i < stringedVerts.
size() - 1; i ++)
1397 stringedVerts[i] =
f[fp];
1398 doneEdge[fEdges[fp]] =
true;
1401 stringedVerts.
last() =
f[fp];
1410 const label startEdgei = fEdges[startFe];
1412 const label meshEdgei = meshEdges[startEdgei];
1414 const label numEdgeSideFaces = edgeLayers[startEdgei];
1416 for (
label i = 0; i < numEdgeSideFaces; i++)
1419 label vStart = stringedVerts[0];
1428 if (addedPoints_[vEnd].size())
1431 addedPoints_[vEnd].size() - numEdgeSideFaces;
1433 if (addedPoints_[vStart].size())
1436 addedPoints_[vStart].size() - numEdgeSideFaces;
1440 face newFace(newFp);
1448 forAll(stringedVerts, stringedI)
1450 label v = stringedVerts[stringedI];
1456 : copiedPatchPoints[v]
1465 forAll(stringedVerts, stringedI)
1467 label v = stringedVerts[stringedI];
1468 if (addedPoints_[v].size())
1471 addedPoints_[v].size() - numEdgeSideFaces;
1474 addedPoints_[v][i+
offset-1],
1486 : copiedPatchPoints[v]
1496 if (numEdgeSideFaces < addedPoints_[vEnd].size())
1498 if (i == 0 && addedPoints_[vEnd].size())
1501 addedPoints_[vEnd].size() - numEdgeSideFaces;
1506 addedPoints_[vEnd][ioff],
1516 label v = stringedVerts[stringedI];
1517 if (addedPoints_[v].size())
1520 addedPoints_[v].size() - numEdgeSideFaces;
1523 addedPoints_[v][i+
offset],
1535 : copiedPatchPoints[v]
1544 if (numEdgeSideFaces < addedPoints_[vStart].size())
1546 if (i == 0 && addedPoints_[vStart].size())
1549 addedPoints_[vStart].size() - numEdgeSideFaces;
1554 addedPoints_[vStart][ioff],
1574 if (!verts.
insert(newFace[fp]))
1577 <<
"Duplicate vertex in face"
1578 <<
" to be added." <<
nl
1579 <<
"newFace:" << newFace <<
nl
1587 <<
" out of:" << numEdgeSideFaces <<
nl
1588 <<
"ExtrudeEdge:" << meshEdgei
1594 <<
"string:" << stringedVerts
1612 const label nbrFacei =
1613 nbrFace(pp.
edgeFaces(), startEdgei, patchFacei);
1618 const label addedFacei =
1626 sidePatchID[startEdgei],
1638 auto getFaceEdgeFaceZones = [&](
const label fe)
1642 const label edgei = fEdges[fe];
1644 forAll(ppEdgeFaceZones[edgei], edgeZonei)
1648 ppEdgeFaceZones[edgei][edgeZonei]
1652 pp[patchFacei].faceEdge(fe)
1661 getFaceEdgeFaceZones(startFe);
1669 edgeStringFaceZones &=
1670 getFaceEdgeFaceZones(
f.
fcIndex(fe));
1675 faceZonesAddedFaces_[
mag(iter.key()) - 1].insert
1703 const labelList& added = addedPoints_[oldPointi];
1720 addedPoints_.transfer(newAddedPoints);
1726 forAll(newLayerFaces, newFacei)
1730 const labelList& added = layerFaces_[oldFacei];
1732 labelList& newAdded = newLayerFaces[newFacei];
1742 newAdded[newI++] = newFacei;
1747 layerFaces_.transfer(newLayerFaces);
#define forAll(list, i)
Loop across all elements in list.
#define forAllReverse(list, i)
Reverse loop across all elements in list.
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object of type.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the 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 transfer(List< T > &)
Transfer the contents of the argument List into this list.
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.
static bool & parRun()
Is this a parallel run?
label size() const
Return the number of elements in the UPtrList.
void insert(const List< labelHashSet > &zonesIndices)
Insert given indices into zones.
labelList whichZones(const label objectIndex) const
Given a global object index, return the list of zones it is in.
label localIndex(const label globalIndex) const
Map storing the local index for every global index. Used to find.
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.
static labelListList addedCells(const polyMesh &, const labelListList &layerFaces)
Helper: get added cells per patch face.
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.
void setRefinement(const polyMesh &mesh, 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.
addPatchCellLayer(const polyMesh &, const bool addToMesh=true)
Construct from mesh.
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...
static int compare(const edge &, const edge &)
Compare edges.
void insert(const List< Map< bool >> &zonesOrientedIndices)
Insert given oriented indices.
Named list of face indices representing a sub-set of the mesh faces.
const boolList & flipMap() const
Return face flip map.
bool oriented() const
Return true if the faceZone is oriented, i.e. the flipMap is set.
A face is a list of labels corresponding to mesh vertices.
int edgeDirection(const edge &) const
Return the edge direction on the face.
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.
const labelList & processorPatches() const
Return list of processor patch labels.
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.
virtual const faceList & faces() const
Return raw faces.
virtual const labelList & faceOwner() const
Return face owner.
const globalMeshData & globalData() const
Return parallel info.
const faceZoneList & faceZones() const
Return face zones.
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
virtual const labelList & faceNeighbour() const
Return face neighbour.
virtual const pointField & points() const
Return raw points.
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 vectorField & faceCentres() const
const labelListList & edgeFaces() const
bool isInternalFace(const label faceIndex) const
Return true if given face label is internal to the mesh.
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
#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.
dimensionedScalar sign(const dimensionedScalar &ds)
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.
void mag(LagrangianPatchField< scalar > &f, const LagrangianPatchField< Type > &f1)
List< labelList > labelListList
A List of labelList.
edge meshEdge(const PrimitivePatch< FaceList, PointField > &p, const label edgei)
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")
labelList identityMap(const label len)
Create identity map (map[i] == i) of given length.
void offset(label &lst, const label o)
PrimitivePatch< IndirectList< face >, const pointField & > indirectPrimitivePatch
Foam::indirectPrimitivePatch.
Type gMax(const FieldField< Field, Type > &f)
List operator to append one list onto another.