66 void Foam::createShellMesh::syncEdges
72 const bitSet& sameEdgeOrientation,
73 const bool syncNonCollocated,
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]);
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);
158 const globalMeshData& globalData,
160 const bitSet& nonManifoldEdge,
161 const bool syncNonCollocated,
173 bitSet sameEdgeOrientation;
190 label nMaxRegions = 0;
193 const face&
f =
patch.localFaces()[facei];
194 nMaxRegions +=
f.
size();
197 const globalIndex globalRegions(nMaxRegions);
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++);
215 DynamicList<label> changedEdges(
patch.nEdges());
217 bitSet isChangedEdge(
patch.nEdges());
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);
272 DynamicList<label> changedFaces(
patch.size());
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];
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);
323 isChangedEdge =
false;
324 changedEdges.
clear();
328 label facei = changedFaces[i];
329 const face&
f =
patch.localFaces()[facei];
334 label edgeI = fEdges[fp];
336 if (!nonManifoldEdge[edgeI])
338 const edge&
e =
patch.edges()[edgeI];
340 label region0 = pointGlobalRegions[facei][fp0];
342 label region1 = pointGlobalRegions[facei][fp1];
346 (allEdgeData[edgeI][0] > region0)
347 || (allEdgeData[edgeI][1] > region1)
350 allEdgeData[edgeI] =
labelPair(region0, region1);
351 if (!isChangedEdge[edgeI])
353 changedEdges.
append(edgeI);
354 isChangedEdge.
set(edgeI);
388 pointLocalRegions.setSize(
patch.size());
389 Map<label> globalToLocalRegion(globalRegions.localSize()/4);
390 DynamicList<label> dynLocalToGlobalRegion(globalToLocalRegion.size());
393 const face&
f =
patch.localFaces()[facei];
394 face& pRegions = pointLocalRegions[facei];
395 pRegions.setSize(
f.
size());
398 label globalRegionI = pointGlobalRegions[facei][fp];
400 const auto fnd = globalToLocalRegion.cfind(globalRegionI);
405 pRegions[fp] = fnd();
410 label localRegionI = globalToLocalRegion.size();
411 pRegions[fp] = localRegionI;
412 globalToLocalRegion.insert(globalRegionI, localRegionI);
413 dynLocalToGlobalRegion.append(globalRegionI);
417 localToGlobalRegion.transfer(dynLocalToGlobalRegion);
423 Foam::createShellMesh::createShellMesh
431 pointRegions_(pointRegions),
432 regionPoints_(regionPoints)
434 if (pointRegions_.
size() != patch_.size())
437 <<
"nFaces:" << patch_.size()
438 <<
" pointRegions:" << pointRegions.
size()
449 const scalar expansionRatio,
454 polyTopoChange& meshMod
457 if (firstLayerDisp.size() != regionPoints_.size())
460 <<
"nRegions:" << regionPoints_.size()
461 <<
" firstLayerDisp:" << firstLayerDisp.size()
467 topPatchID.size() != patch_.size()
468 && bottomPatchID.size() != patch_.size()
472 <<
"nFaces:" << patch_.size()
473 <<
" topPatchID:" << topPatchID.size()
474 <<
" bottomPatchID:" << bottomPatchID.size()
478 if (extrudeEdgePatches.size() != patch_.nEdges())
481 <<
"nEdges:" << patch_.nEdges()
482 <<
" extrudeEdgePatches:" << extrudeEdgePatches.size()
489 DynamicList<label> cellToFaceMap(nLayers*patch_.size());
491 DynamicList<label> faceToFaceMap
493 (nLayers+1)*(patch_.size()+patch_.nEdges())
496 DynamicList<label> faceToEdgeMap(nLayers*(patch_.nEdges()+patch_.nEdges()));
498 DynamicList<label> pointToPointMap((nLayers+1)*patch_.nPoints());
504 labelList addedCells(nLayers*patch_.size());
507 for (label layerI = 0; layerI < nLayers; layerI++)
509 addedCells[nLayers*facei+layerI] = meshMod.addCell
514 cellToFaceMap.size(),
517 cellToFaceMap.append(facei);
526 forAll(patch_.localPoints(), pointi)
531 patch_.localPoints()[pointi],
532 pointToPointMap.size(),
536 pointToPointMap.append(pointi);
548 labelList addedPoints(nLayers*regionPoints_.size());
549 forAll(regionPoints_, regionI)
551 label pointi = regionPoints_[regionI];
553 point pt = patch_.localPoints()[pointi];
554 point disp = firstLayerDisp[regionI];
555 for (label layerI = 0; layerI < nLayers; layerI++)
559 addedPoints[nLayers*regionI+layerI] = meshMod.addPoint
562 pointToPointMap.size(),
566 pointToPointMap.append(pointi);
568 disp *= expansionRatio;
574 forAll(patch_.localFaces(), facei)
578 patch_.localFaces()[facei].reverseFace(),
579 addedCells[nLayers*facei],
583 faceToFaceMap.size(),
585 bottomPatchID[facei],
589 faceToFaceMap.append(-facei-1);
590 faceToEdgeMap.append(-1);
603 forAll(patch_.localFaces(), facei)
606 const face&
f = patch_.localFaces()[facei];
610 for (label layerI = 0; layerI < nLayers; layerI++)
615 label region = pointRegions_[facei][fp];
616 newF[fp] = addedPoints[region*nLayers+layerI];
619 label own = addedCells[facei*nLayers+layerI];
622 if (layerI == nLayers-1)
625 patchi = topPatchID[facei];
629 nei = addedCells[facei*nLayers+layerI+1];
640 faceToFaceMap.size(),
646 faceToFaceMap.append(facei+1);
647 faceToEdgeMap.append(-1);
666 forAll(extrudeEdgePatches, edgeI)
668 const labelList& eFaces = patch_.edgeFaces()[edgeI];
669 const labelList& ePatches = extrudeEdgePatches[edgeI];
671 if (ePatches.size() == 0)
674 if (eFaces.size() != 2)
678 <<
" not internal but does not have side-patches defined." 684 if (eFaces.size() != ePatches.size())
687 <<
"external/feature edge:" << edgeI
688 <<
" has " << eFaces.size() <<
" connected extruded faces " 689 <<
" but only " << ePatches.size()
697 const face&
f = patch_.localFaces()[eFaces[0]];
698 const edge&
e = patch_.edges()[edgeI];
711 for (label layerI = 0; layerI < nLayers; layerI++)
713 label region0 = pointRegions_[eFaces[0]][fp0];
714 label region1 = pointRegions_[eFaces[0]][fp1];
721 newF[2] = addedPoints[nLayers*region1+layerI];
722 newF[3] = addedPoints[nLayers*region0+layerI];
726 newF[0] = addedPoints[nLayers*region0+layerI-1];
727 newF[1] = addedPoints[nLayers*region1+layerI-1];
728 newF[2] = addedPoints[nLayers*region1+layerI];
729 newF[3] = addedPoints[nLayers*region0+layerI];
740 for (label i = 0; i < newF.size()-1; i++)
742 newF[i] = newF[newF.fcIndex(i)];
748 label minCelli = addedCells[nLayers*eFaces[0]+layerI];
751 if (ePatches.size() == 0)
753 maxCelli = addedCells[nLayers*eFaces[1]+layerI];
754 if (minCelli > maxCelli)
757 std::swap(minCelli, maxCelli);
765 patchi = ePatches[0];
791 faceToFaceMap.size(),
797 faceToFaceMap.append(0);
798 faceToEdgeMap.append(edgeI);
803 forAll(extrudeEdgePatches, edgeI)
805 const labelList& eFaces = patch_.edgeFaces()[edgeI];
806 const labelList& ePatches = extrudeEdgePatches[edgeI];
808 if (ePatches.size() >= 2)
810 for (label i = 1; i < ePatches.size(); i++)
813 label minFacei = eFaces[i];
816 const face&
f = patch_.localFaces()[minFacei];
818 const edge&
e = patch_.edges()[edgeI];
829 for (label layerI = 0; layerI < nLayers; layerI++)
831 label region0 = pointRegions_[minFacei][fp0];
832 label region1 = pointRegions_[minFacei][fp1];
838 newF[2] = addedPoints[nLayers*region1+layerI];
839 newF[3] = addedPoints[nLayers*region0+layerI];
843 newF[0] = addedPoints[nLayers*region0+layerI-1];
844 newF[1] = addedPoints[nLayers*region1+layerI-1];
845 newF[2] = addedPoints[nLayers*region1+layerI];
846 newF[3] = addedPoints[nLayers*region0+layerI];
858 for (label i = 0; i < newF.size()-1; i++)
860 newF[i] = newF[newF.fcIndex(i)];
882 addedCells[nLayers*minFacei+layerI],
886 faceToFaceMap.size(),
892 faceToFaceMap.append(0);
893 faceToEdgeMap.append(edgeI);
900 cellToFaceMap_.transfer(cellToFaceMap);
901 faceToFaceMap_.transfer(faceToFaceMap);
902 faceToEdgeMap_.transfer(faceToEdgeMap);
903 pointToPointMap_.transfer(pointToPointMap);
void size(const label n)
Older name for setAddressableSize.
void set(const bitSet &bitset)
Set specified bits from another bitset.
errorManipArg< error, int > exit(error &err, const int errNo=1)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
const mapDistribute & globalEdgeSlavesMap() const
Various mesh related information for a parallel run. Upon construction, constructs all info using par...
void inplaceReorder(const labelUList &oldToNew, ListType &input, const bool prune=false)
Inplace reorder the elements of a list.
bool empty() const noexcept
True if List is empty (ie, size() is zero)
const bitSet & globalEdgeOrientation() const
Is my edge same orientation as master edge.
label constructSize() const noexcept
Constructed data size.
List< labelPair > labelPairList
List of labelPair.
const labelListList & globalEdgeSlaves() const
PrimitivePatch< IndirectList< face >, const pointField & > indirectPrimitivePatch
A PrimitivePatch with an IndirectList for the faces, const reference for the point field...
List< labelList > labelListList
List of labelList.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
#define forAll(list, i)
Loop across all elements in list.
static void syncData(List< Type > &elems, const labelListList &slaves, const labelListList &transformedSlaves, const mapDistribute &slavesMap, const globalIndexAndTransform &, const CombineOp &cop, const TransformOp &top)
Helper: synchronise data with transforms.
const labelList & reverseFaceMap() const noexcept
Reverse face map.
label fcIndex(const label i) const noexcept
The forward circular index. The next index in the list which returns to the first at the end of the l...
List< face > faceList
List of faces.
A list of faces which address into the list of points.
bool returnReduceAnd(const bool value, const label comm=UPstream::worldComm)
Perform logical (and) MPI Allreduce on a copy. Uses UPstream::reduceAnd.
vectorField pointField
pointField is a vectorField.
const dimensionedScalar e
Elementary charge.
void setSize(const label n)
Alias for resize()
const labelList & reverseCellMap() const noexcept
Reverse cell map.
Creates mesh by extruding a patch.
const labelList & reversePointMap() const noexcept
Reverse point map.
void append(const T &val)
Copy append an element to the end of this list.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
label find(const T &val) const
Find index of the first occurrence of the value.
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.
Pair< label > labelPair
A pair of labels.
void updateMesh(const mapPolyMesh &)
Update any locally stored mesh information.
defineTypeNameAndDebug(combustionModel, 0)
void clear() noexcept
Clear the addressed list, i.e. set the size to zero.
PrimitivePatch< List< face >, const pointField & > primitiveFacePatch
A PrimitivePatch with List storage for the faces, const reference for the point field.
T & last()
Access last element of the list, position [size()-1].
void operator()(T &x, const T &y) const
Class containing processor-to-processor mapping information.
vector point
Point is a vector.
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
const std::string patch
OpenFOAM patch number as a std::string.
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.
List< label > labelList
A List of labels.
label rcIndex(const label i) const noexcept
The reverse circular index. The previous index in the list which returns to the last at the beginning...
const labelListList & globalEdgeTransformedSlaves() const