66void Foam::createShellMesh::syncEdges
68 const globalMeshData& globalData,
70 const labelList& patchEdges,
71 const labelList& coupledEdges,
72 const bitSet& sameEdgeOrientation,
73 const bool syncNonCollocated,
75 bitSet& isChangedEdge,
76 DynamicList<label>& changedEdges,
77 labelPairList& allEdgeData
80 const mapDistribute& map = globalData.globalEdgeSlavesMap();
81 const bitSet& cppOrientation = globalData.globalEdgeOrientation();
92 label patchEdgeI = patchEdges[i];
93 label coupledEdgeI = coupledEdges[i];
95 if (isChangedEdge[patchEdgeI])
97 const labelPair& data = allEdgeData[patchEdgeI];
102 if (sameEdgeOrientation[i] == cppOrientation[coupledEdgeI])
104 cppEdgeData[coupledEdgeI] = data;
108 cppEdgeData[coupledEdgeI] =
labelPair(data[1], data[0]);
117 globalData.globalEdgeSlaves(),
120 ? globalData.globalEdgeTransformedSlaves()
130 label patchEdgeI = patchEdges[i];
131 label coupledEdgeI = coupledEdges[i];
135 const labelPair& data = cppEdgeData[coupledEdgeI];
137 if (sameEdgeOrientation[i] == cppOrientation[coupledEdgeI])
139 allEdgeData[patchEdgeI] = data;
143 allEdgeData[patchEdgeI] =
labelPair(data[1], data[0]);
146 if (!isChangedEdge[patchEdgeI])
148 changedEdges.append(patchEdgeI);
149 isChangedEdge.set(patchEdgeI);
160 const bitSet& nonManifoldEdge,
161 const bool syncNonCollocated,
173 bitSet sameEdgeOrientation;
190 label nMaxRegions = 0;
191 forAll(patch.localFaces(), facei)
193 const face&
f = patch.localFaces()[facei];
194 nMaxRegions +=
f.
size();
202 pointGlobalRegions.
setSize(patch.size());
203 forAll(pointGlobalRegions, facei)
205 const face&
f = patch.localFaces()[facei];
206 labelList& pRegions = pointGlobalRegions[facei];
210 pRegions[fp] = globalRegions.
toGlobal(nRegions++);
217 bitSet isChangedEdge(patch.nEdges());
223 forAll(patch.edgeFaces(), edgeI)
225 if (!nonManifoldEdge[edgeI])
228 const edge&
e = patch.edges()[edgeI];
229 label facei = patch.edgeFaces()[edgeI][0];
230 const face&
f = patch.localFaces()[facei];
236 pointGlobalRegions[facei][fp0],
237 pointGlobalRegions[facei][fp1]
239 if (!isChangedEdge[edgeI])
241 changedEdges.
append(edgeI);
242 isChangedEdge.
set(edgeI);
273 bitSet isChangedFace(patch.size());
275 forAll(changedEdges, changedI)
277 label edgeI = changedEdges[changedI];
278 const labelPair& edgeData = allEdgeData[edgeI];
280 const edge&
e = patch.edges()[edgeI];
281 const labelList& eFaces = patch.edgeFaces()[edgeI];
285 label facei = eFaces[i];
286 const face&
f = patch.localFaces()[facei];
290 if (pointGlobalRegions[facei][fp0] > edgeData[0])
292 pointGlobalRegions[facei][fp0] = edgeData[0];
293 if (!isChangedFace[facei])
295 isChangedFace.
set(facei);
296 changedFaces.
append(facei);
301 if (pointGlobalRegions[facei][fp1] > edgeData[1])
303 pointGlobalRegions[facei][fp1] = edgeData[1];
304 if (!isChangedFace[facei])
306 isChangedFace.
set(facei);
307 changedFaces.
append(facei);
315 if (nChangedFaces == 0)
324 isChangedEdge =
false;
325 changedEdges.
clear();
329 label facei = changedFaces[i];
330 const face&
f = patch.localFaces()[facei];
331 const labelList& fEdges = patch.faceEdges()[facei];
335 label edgeI = fEdges[fp];
337 if (!nonManifoldEdge[edgeI])
339 const edge&
e = patch.edges()[edgeI];
341 label region0 = pointGlobalRegions[facei][fp0];
343 label region1 = pointGlobalRegions[facei][fp1];
347 (allEdgeData[edgeI][0] > region0)
348 || (allEdgeData[edgeI][1] > region1)
351 allEdgeData[edgeI] =
labelPair(region0, region1);
352 if (!isChangedEdge[edgeI])
354 changedEdges.
append(edgeI);
355 isChangedEdge.
set(edgeI);
378 if (nChangedEdges == 0)
390 pointLocalRegions.
setSize(patch.size());
393 forAll(patch.localFaces(), facei)
395 const face&
f = patch.localFaces()[facei];
396 face& pRegions = pointLocalRegions[facei];
400 label globalRegionI = pointGlobalRegions[facei][fp];
402 const auto fnd = globalToLocalRegion.
cfind(globalRegionI);
407 pRegions[fp] = fnd();
412 label localRegionI = globalToLocalRegion.
size();
413 pRegions[fp] = localRegionI;
414 globalToLocalRegion.
insert(globalRegionI, localRegionI);
415 dynLocalToGlobalRegion.
append(globalRegionI);
419 localToGlobalRegion.
transfer(dynLocalToGlobalRegion);
433 pointRegions_(pointRegions),
434 regionPoints_(regionPoints)
436 if (pointRegions_.
size() != patch_.size())
439 <<
"nFaces:" << patch_.size()
440 <<
" pointRegions:" << pointRegions.
size()
451 const scalar expansionRatio,
459 if (firstLayerDisp.
size() != regionPoints_.size())
462 <<
"nRegions:" << regionPoints_.size()
463 <<
" firstLayerDisp:" << firstLayerDisp.
size()
469 topPatchID.
size() != patch_.size()
470 && bottomPatchID.
size() != patch_.size()
474 <<
"nFaces:" << patch_.size()
475 <<
" topPatchID:" << topPatchID.
size()
476 <<
" bottomPatchID:" << bottomPatchID.
size()
480 if (extrudeEdgePatches.
size() != patch_.nEdges())
483 <<
"nEdges:" << patch_.nEdges()
484 <<
" extrudeEdgePatches:" << extrudeEdgePatches.
size()
495 (nLayers+1)*(patch_.size()+patch_.nEdges())
506 labelList addedCells(nLayers*patch_.size());
509 for (label layerI = 0; layerI < nLayers; layerI++)
511 addedCells[nLayers*facei+layerI] = meshMod.
addCell
516 cellToFaceMap.
size(),
519 cellToFaceMap.
append(facei);
528 forAll(patch_.localPoints(), pointi)
533 patch_.localPoints()[pointi],
534 pointToPointMap.
size(),
538 pointToPointMap.
append(pointi);
550 labelList addedPoints(nLayers*regionPoints_.size());
551 forAll(regionPoints_, regionI)
553 label pointi = regionPoints_[regionI];
555 point pt = patch_.localPoints()[pointi];
556 point disp = firstLayerDisp[regionI];
557 for (label layerI = 0; layerI < nLayers; layerI++)
561 addedPoints[nLayers*regionI+layerI] = meshMod.
addPoint
564 pointToPointMap.
size(),
568 pointToPointMap.
append(pointi);
570 disp *= expansionRatio;
576 forAll(patch_.localFaces(), facei)
580 patch_.localFaces()[facei].reverseFace(),
581 addedCells[nLayers*facei],
585 faceToFaceMap.
size(),
587 bottomPatchID[facei],
591 faceToFaceMap.
append(-facei-1);
605 forAll(patch_.localFaces(), facei)
608 const face&
f = patch_.localFaces()[facei];
612 for (label layerI = 0; layerI < nLayers; layerI++)
617 label region = pointRegions_[facei][fp];
618 newF[fp] = addedPoints[region*nLayers+layerI];
621 label own = addedCells[facei*nLayers+layerI];
624 if (layerI == nLayers-1)
627 patchi = topPatchID[facei];
631 nei = addedCells[facei*nLayers+layerI+1];
642 faceToFaceMap.
size(),
648 faceToFaceMap.
append(facei+1);
668 forAll(extrudeEdgePatches, edgeI)
670 const labelList& eFaces = patch_.edgeFaces()[edgeI];
671 const labelList& ePatches = extrudeEdgePatches[edgeI];
673 if (ePatches.
size() == 0)
676 if (eFaces.
size() != 2)
680 <<
" not internal but does not have side-patches defined."
686 if (eFaces.
size() != ePatches.
size())
689 <<
"external/feature edge:" << edgeI
690 <<
" has " << eFaces.
size() <<
" connected extruded faces "
691 <<
" but only " << ePatches.
size()
699 const face&
f = patch_.localFaces()[eFaces[0]];
700 const edge&
e = patch_.edges()[edgeI];
713 for (label layerI = 0; layerI < nLayers; layerI++)
715 label region0 = pointRegions_[eFaces[0]][fp0];
716 label region1 = pointRegions_[eFaces[0]][fp1];
723 newF[2] = addedPoints[nLayers*region1+layerI];
724 newF[3] = addedPoints[nLayers*region0+layerI];
728 newF[0] = addedPoints[nLayers*region0+layerI-1];
729 newF[1] = addedPoints[nLayers*region1+layerI-1];
730 newF[2] = addedPoints[nLayers*region1+layerI];
731 newF[3] = addedPoints[nLayers*region0+layerI];
742 for (label i = 0; i < newF.
size()-1; i++)
744 newF[i] = newF[newF.
fcIndex(i)];
750 label minCelli = addedCells[nLayers*eFaces[0]+layerI];
753 if (ePatches.
size() == 0)
755 maxCelli = addedCells[nLayers*eFaces[1]+layerI];
756 if (minCelli > maxCelli)
759 std::swap(minCelli, maxCelli);
767 patchi = ePatches[0];
793 faceToFaceMap.
size(),
800 faceToEdgeMap.
append(edgeI);
805 forAll(extrudeEdgePatches, edgeI)
807 const labelList& eFaces = patch_.edgeFaces()[edgeI];
808 const labelList& ePatches = extrudeEdgePatches[edgeI];
810 if (ePatches.
size() >= 2)
812 for (label i = 1; i < ePatches.
size(); i++)
815 label minFacei = eFaces[i];
818 const face&
f = patch_.localFaces()[minFacei];
820 const edge&
e = patch_.edges()[edgeI];
831 for (label layerI = 0; layerI < nLayers; layerI++)
833 label region0 = pointRegions_[minFacei][fp0];
834 label region1 = pointRegions_[minFacei][fp1];
840 newF[2] = addedPoints[nLayers*region1+layerI];
841 newF[3] = addedPoints[nLayers*region0+layerI];
845 newF[0] = addedPoints[nLayers*region0+layerI-1];
846 newF[1] = addedPoints[nLayers*region1+layerI-1];
847 newF[2] = addedPoints[nLayers*region1+layerI];
848 newF[3] = addedPoints[nLayers*region0+layerI];
860 for (label i = 0; i < newF.
size()-1; i++)
862 newF[i] = newF[newF.
fcIndex(i)];
884 addedCells[nLayers*minFacei+layerI],
888 faceToFaceMap.
size(),
895 faceToEdgeMap.
append(edgeI);
902 cellToFaceMap_.transfer(cellToFaceMap);
903 faceToFaceMap_.transfer(faceToFaceMap);
904 faceToEdgeMap_.transfer(faceToEdgeMap);
905 pointToPointMap_.transfer(pointToPointMap);
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
void clear() noexcept
Clear the addressed list, i.e. set the size to zero.
void append(const T &val)
Copy append an element to the end of this list.
const_iterator cfind(const Key &key) const
Find and return an const_iterator set at the hashed entry.
bool insert(const Key &key, const T &obj)
Copy insert a new entry, not overwriting existing entries.
label size() const noexcept
The number of elements in table.
void transfer(List< T > &list)
void setSize(const label n)
Alias for resize()
A HashTable to objects of type <T> with a label key.
A list of faces which address into the list of points.
label find(const T &val, label pos=0) const
Find index of the first occurrence of the value.
label rcIndex(const label i) const noexcept
void size(const label n)
Older name for setAddressableSize.
T & last()
Return the last element of the list.
label fcIndex(const label i) const noexcept
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
void set(const bitSet &bitset)
Set specified bits from another bitset.
Creates mesh by extruding a patch.
static void calcPointRegions(const globalMeshData &globalData, const primitiveFacePatch &patch, const bitSet &nonManifoldEdge, const bool syncNonCollocated, faceList &pointGlobalRegions, faceList &pointLocalRegions, labelList &localToGlobalRegion)
Helper: calculate point regions. The point region is the.
void setRefinement(const pointField &firstLayerThickness, const scalar expansionRatio, const label nLayers, const labelList &topPatchID, const labelList &bottomPatchID, const labelListList &extrudeEdgePatches, polyTopoChange &meshMod)
Play commands into polyTopoChange to create layer mesh.
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.
void flip()
Flip the face in-place.
Calculates a unique integer (label so might not have enough room - 2G max) for processor + local inde...
label localSize() const
My local size.
label toGlobal(const label i) const
From local to global index.
Various mesh related information for a parallel run. Upon construction, constructs all info using par...
const indirectPrimitivePatch & coupledPatch() const
Return patch of all coupled faces.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
const labelList & reverseCellMap() const
Reverse cell map.
const labelList & reversePointMap() const
Reverse point map.
const labelList & reverseFaceMap() const
Reverse face map.
void operator()(labelPair &x, const labelPair &y) const
void updateMesh()
Update for new mesh topology.
Direct mesh changes based on v1.3 polyTopoChange syntax.
label addPoint(const point &pt, const label masterPointID, const label zoneID, const bool inCell)
Add point. Return new point label.
label addCell(const label masterPointID, const label masterEdgeID, const label masterFaceID, const label masterCellID, const label zoneID)
Add cell. Return new cell label.
label addFace(const face &f, const label own, const label nei, const label masterPointID, const label masterEdgeID, const label masterFaceID, const bool flipFaceFlux, const label patchID, const label zoneID, const bool zoneFlip)
Add face to cells. Return new face label.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Pair< label > labelPair
A pair of labels.
List< labelPair > labelPairList
List of labelPairs.
void inplaceReorder(const labelUList &oldToNew, ListType &input, const bool prune=false)
Inplace reorder the elements of a list.
List< labelList > labelListList
A List of labelList.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
T returnReduce(const T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Reduce (copy) and return value.
errorManipArg< error, int > exit(error &err, const int errNo=1)
#define forAll(list, i)
Loop across all elements in list.