45Foam::label Foam::globalPoints::countPatchPoints
52 for (
const polyPatch& pp :
patches)
56 nTotPoints += pp.nPoints();
63Foam::label Foam::globalPoints::findSamePoint
69 const label proci = globalTransforms_.processor(info);
70 const label index = globalTransforms_.index(info);
76 globalTransforms_.processor(allInfo[i]) == proci
77 && globalTransforms_.index(allInfo[i]) == index
93 scalar tol = refCast<const coupledPolyPatch>
95 mesh_.boundaryMesh()[patchi]
111 sendInfo[i] = globalTransforms_.encode
113 globalTransforms_.processor(info[i]),
114 globalTransforms_.index(info[i]),
115 globalTransforms_.addToTransformIndex
117 globalTransforms_.transformIndex(info[i]),
128void Foam::globalPoints::addToSend
131 const label patchPointi,
134 DynamicList<label>& patchFaces,
135 DynamicList<label>& indexInFace,
136 DynamicList<labelPairList>& allInfo
143 const label meshPointi = pp.meshPoints()[patchPointi];
149 for (
const label patchFacei :
pFaces)
151 const face&
f = pp[patchFacei];
153 patchFaces.
append(patchFacei);
154 indexInFace.append(
f.
find(meshPointi));
157 allInfo.append(addSendTransform(pp.index(), knownInfo));
162bool Foam::globalPoints::mergeInfo
165 const label localPointi,
172 bool anyChanged =
false;
176 label newI = newInfo.size();
177 newInfo.setSize(newI + nbrInfo.size());
187 label index = findSamePoint(myInfo, nbrInfo[i]);
192 newInfo[newI++] = nbrInfo[i];
201 if (myInfo[index] == nbrInfo[i])
207 label myTransform = globalTransforms_.transformIndex
211 label nbrTransform = globalTransforms_.transformIndex
217 label minTransform = globalTransforms_.minimumTransformIndex
223 if (minTransform != myTransform)
226 newInfo[index] = nbrInfo[i];
233 newInfo.setSize(newI);
234 myInfo.transfer(newInfo);
240Foam::label Foam::globalPoints::meshToLocalPoint
242 const Map<label>& meshToPatchPoint,
243 const label meshPointi
248 meshToPatchPoint.size() == 0
250 : meshToPatchPoint[meshPointi]
255Foam::label Foam::globalPoints::localToMeshPoint
258 const label localPointi
263 patchToMeshPoint.size() == 0
265 : patchToMeshPoint[localPointi]
270bool Foam::globalPoints::mergeInfo
273 const label localPointi
279 label infoChanged =
false;
282 const auto iter = meshToProcPoint_.cfind(localPointi);
286 if (mergeInfo(nbrInfo, localPointi, procPoints_[iter.val()]))
297 globalTransforms_.encode
301 globalTransforms_.nullTransformIndex()
305 if (mergeInfo(nbrInfo, localPointi, knownInfo))
308 meshToProcPoint_.insert(localPointi, procPoints_.size());
310 procPoints_.append(knownInfo);
319bool Foam::globalPoints::storeInitialInfo
322 const label localPointi
328 label infoChanged =
false;
331 const auto iter = meshToProcPoint_.find(localPointi);
335 if (mergeInfo(nbrInfo, localPointi, procPoints_[iter.val()]))
343 meshToProcPoint_.insert(localPointi, procPoints_.size());
345 procPoints_.append(nbrInfo);
353void Foam::globalPoints::printProcPoint
359 label proci = globalTransforms_.processor(pointInfo);
360 label index = globalTransforms_.index(pointInfo);
361 label trafoI = globalTransforms_.transformIndex(pointInfo);
363 Pout<<
" proc:" << proci;
364 Pout<<
" localpoint:";
366 Pout<<
" through transform:"
367 << trafoI <<
" bits:"
368 << globalTransforms_.decodeTransformIndex(trafoI);
372 label meshPointi = localToMeshPoint(patchToMeshPoint, index);
373 Pout<<
" at:" << mesh_.points()[meshPointi];
378void Foam::globalPoints::printProcPoints
386 printProcPoint(patchToMeshPoint, pointInfo[i]);
392void Foam::globalPoints::initOwnPoints
394 const Map<label>& meshToPatchPoint,
395 const bool allPoints,
399 const polyBoundaryMesh&
patches = mesh_.boundaryMesh();
403 const polyPatch& pp =
patches[patchi];
407 const labelList& meshPoints = pp.meshPoints();
412 forAll(meshPoints, patchPointi)
414 label meshPointi = meshPoints[patchPointi];
415 label localPointi = meshToLocalPoint
424 globalTransforms_.encode
428 globalTransforms_.nullTransformIndex()
437 if (storeInitialInfo(knownInfo, localPointi))
439 changedPoints.insert(localPointi);
446 const labelList& boundaryPoints = pp.boundaryPoints();
450 label meshPointi = meshPoints[boundaryPoints[i]];
451 label localPointi = meshToLocalPoint
460 globalTransforms_.encode
464 globalTransforms_.nullTransformIndex()
468 if (storeInitialInfo(knownInfo, localPointi))
470 changedPoints.insert(localPointi);
479void Foam::globalPoints::sendPatchPoints
481 const bool mergeSeparated,
482 const Map<label>& meshToPatchPoint,
483 PstreamBuffers& pBufs,
487 const polyBoundaryMesh&
patches = mesh_.boundaryMesh();
488 const labelPairList& patchInfo = globalTransforms_.patchTransformSign();
492 const polyPatch& pp =
patches[patchi];
500 && (mergeSeparated || patchInfo[patchi].first() == -1)
503 const processorPolyPatch& procPatch =
504 refCast<const processorPolyPatch>(pp);
508 DynamicList<label> patchFaces(pp.nPoints());
510 DynamicList<label> indexInFace(pp.nPoints());
512 DynamicList<labelPairList> allInfo(pp.nPoints());
519 const labelList& meshPoints = pp.meshPoints();
521 forAll(meshPoints, patchPointi)
523 label meshPointi = meshPoints[patchPointi];
524 label localPointi = meshToLocalPoint
530 if (changedPoints.found(localPointi))
532 label index = meshToProcPoint_[localPointi];
554 Pout<<
" Sending from " << pp.
name() <<
" to "
555 << procPatch.neighbProcNo() <<
" point information:"
556 << patchFaces.size() <<
endl;
559 UOPstream toNeighbour(procPatch.neighbProcNo(), pBufs);
560 toNeighbour << patchFaces << indexInFace << allInfo;
566void Foam::globalPoints::receivePatchPoints
568 const bool mergeSeparated,
569 const Map<label>& meshToPatchPoint,
571 PstreamBuffers& pBufs,
581 const polyBoundaryMesh&
patches = mesh_.boundaryMesh();
582 const labelPairList& patchInfo = globalTransforms_.patchTransformSign();
585 changedPoints.clear();
589 const polyPatch& pp =
patches[patchi];
594 && (mergeSeparated || patchInfo[patchi].first() == -1)
597 const processorPolyPatch& procPatch =
598 refCast<const processorPolyPatch>(pp);
602 List<labelPairList> nbrInfo;
605 UIPstream fromNeighbour(procPatch.neighbProcNo(), pBufs);
606 fromNeighbour >> patchFaces >> indexInFace >> nbrInfo;
613 << procPatch.neighbProcNo() <<
" point information:"
614 << patchFaces.size() <<
endl;
619 const face&
f = pp[patchFaces[i]];
622 label index = (
f.
size() - indexInFace[i]) %
f.
size();
625 label meshPointi =
f[index];
627 label localPointi = meshToLocalPoint
633 if (mergeInfo(nbrInfo[i], localPointi))
635 changedPoints.insert(localPointi);
642 isA<cyclicPolyPatch>(pp)
643 && refCast<const cyclicPolyPatch>(pp).owner()
645 && (mergeSeparated || patchInfo[patchi].first() == -1)
651 const cyclicPolyPatch& cycPatch =
652 refCast<const cyclicPolyPatch>(pp);
656 const labelList& meshPoints = pp.meshPoints();
657 const labelList coupledMeshPoints(reverseMeshPoints(cycPatch));
661 label meshPointA = meshPoints[i];
662 label meshPointB = coupledMeshPoints[i];
664 if (meshPointA != meshPointB)
671 label localA = meshToLocalPoint
676 label localB = meshToLocalPoint
684 const auto procPointA = meshToProcPoint_.cfind(localA);
686 if (procPointA.found())
691 procPoints_[procPointA()]
694 if (mergeInfo(infoA, localB))
696 changedPoints.insert(localB);
701 const auto procPointB = meshToProcPoint_.cfind(localB);
703 if (procPointB.found())
707 cycPatch.neighbPatchID(),
708 procPoints_[procPointB()]
711 if (mergeInfo(infoB, localA))
713 changedPoints.insert(localA);
726 const Map<label>& directNeighbours
733 Map<label> oldMeshToProcPoint(std::move(meshToProcPoint_));
734 meshToProcPoint_.resize(oldMeshToProcPoint.size());
735 DynamicList<labelPairList> oldProcPoints(std::move(procPoints_));
736 procPoints_.setCapacity(oldProcPoints.size());
741 const label localPointi = iter.key();
744 if (pointInfo.size() == 2)
751 label proc0 = globalTransforms_.processor(pointInfo[0]);
752 label proc1 = globalTransforms_.processor(pointInfo[1]);
758 && directNeighbours.found
760 globalTransforms_.index(pointInfo[0])
765 && directNeighbours.found
767 globalTransforms_.index(pointInfo[1])
802 meshToProcPoint_.insert(localPointi, procPoints_.size());
803 procPoints_.append(pointInfo);
806 else if (pointInfo.size() == 1)
813 globalTransforms_.processor(pointInfo[0])
815 || !directNeighbours.found
817 globalTransforms_.index(pointInfo[0])
821 meshToProcPoint_.insert(localPointi, procPoints_.size());
822 procPoints_.append(pointInfo);
827 meshToProcPoint_.insert(localPointi, procPoints_.size());
828 procPoints_.append(pointInfo);
832 procPoints_.shrink();
833 meshToProcPoint_.resize(2*procPoints_.size());
839 const cyclicPolyPatch& pp
842 const cyclicPolyPatch& nbrPatch = pp.neighbPatch();
844 faceList masterFaces(nbrPatch.size());
848 masterFaces[facei] = nbrPatch[facei].reverseFace();
859void Foam::globalPoints::calculateSharedPoints
861 const Map<label>& meshToPatchPoint,
863 const bool keepAllPoints,
864 const bool mergeSeparated
869 Pout<<
"globalPoints::calculateSharedPoints(..) : "
870 <<
"doing processor to processor communication to get sharedPoints"
872 <<
" keepAllPoints :" << keepAllPoints <<
endl
873 <<
" mergeSeparated:" << mergeSeparated <<
endl
892 initOwnPoints(meshToPatchPoint,
true, changedPoints);
914 pBufs.finishedSends();
926 Map<label> neighbourList;
929 neighbourList = meshToProcPoint_;
933 bool changed =
false;
952 pBufs.finishedSends();
962 changed = changedPoints.size() > 0;
963 reduce(changed, orOp<bool>());
985 remove(patchToMeshPoint, neighbourList);
996 sort(pointInfo, globalIndexAndTransform::less(globalTransforms_));
1004 pointPoints_.setSize(globalIndices_.localSize());
1005 List<labelPairList> transformedPoints(globalIndices_.localSize());
1011 if (pointInfo.size() >= 2)
1014 const labelPair& masterInfo = pointInfo[0];
1019 globalTransforms_.processor(masterInfo)
1022 && (globalTransforms_.index(masterInfo) == iter.key())
1025 labelList& pPoints = pointPoints_[iter.key()];
1026 pPoints.
setSize(pointInfo.size()-1);
1028 labelPairList& trafoPPoints = transformedPoints[iter.key()];
1029 trafoPPoints.setSize(pointInfo.size()-1);
1031 label nonTransformI = 0;
1032 label transformI = 0;
1034 for (label i = 1; i < pointInfo.size(); i++)
1037 label proci = globalTransforms_.processor(info);
1038 label index = globalTransforms_.index(info);
1039 label
transform = globalTransforms_.transformIndex
1044 if (
transform == globalTransforms_.nullTransformIndex())
1046 pPoints[nonTransformI++] = globalIndices_.toGlobal
1054 trafoPPoints[transformI++] = info;
1058 pPoints.setSize(nonTransformI);
1059 trafoPPoints.setSize(transformI);
1065 List<Map<label>> compactMap;
1075 transformedPointPoints_,
1083 Pout<<
"globalPoints::calculateSharedPoints(..) : "
1084 <<
"Finished global points" <<
endl;
1094 const bool keepAllPoints,
1095 const bool mergeSeparated
1099 globalIndices_(mesh_.
nPoints()),
1100 globalTransforms_(
mesh),
1102 procPoints_(nPatchPoints_),
1103 meshToProcPoint_(nPatchPoints_)
1109 calculateSharedPoints
1123 const bool keepAllPoints,
1124 const bool mergeSeparated
1128 globalIndices_(coupledPatch.
nPoints()),
1129 globalTransforms_(
mesh),
1130 nPatchPoints_(coupledPatch.
nPoints()),
1131 procPoints_(nPatchPoints_),
1132 meshToProcPoint_(nPatchPoints_)
1134 calculateSharedPoints
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void setSize(const label n)
Alias for resize()
void append(const T &val)
Append an element at the end of the list.
A HashTable to objects of type <T> with a label key.
virtual const fileName & name() const
Get the name of the stream.
unsigned int remove()
Remove and return the last element.
A list of faces which address into the list of points.
const Map< label > & meshPointMap() const
Mesh point map.
const labelList & meshPoints() const
Return labelList of mesh points in patch.
label find(const T &val, label pos=0) const
Find index of the first occurrence of the value.
void size(const label n)
Older name for setAddressableSize.
@ nonBlocking
"nonBlocking"
static commsTypes defaultCommsType
Default commsType.
static bool & parRun() noexcept
Test if this a parallel run.
Addressing for all faces on surface of mesh. Can either be read from polyMesh or from triSurface....
void reset(const dimensionSet &ds)
Copy assign the exponents from the dimensionSet.
Calculates points shared by more than two processor patches or cyclic patches.
Mesh consisting of general polyhedral cells.
int myProcNo() const noexcept
Return processor number.
const labelList & reverseMeshPoints() const
Return mesh points in the correct order for the receiving side.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
const polyBoundaryMesh & patches
Pair< label > labelPair
A pair of labels.
List< labelPair > labelPairList
List of labelPairs.
dimensionSet transform(const dimensionSet &ds)
Return the argument; transformations do not change the dimensions.
List< label > labelList
A List of labels.
Ostream & endl(Ostream &os)
Add newline and flush stream.
void reduce(const List< UPstream::commsStruct > &comms, T &value, const BinaryOp &bop, const int tag, const label comm)
void sort(UList< T > &list)
Sort the list.
HashSet< label, Hash< label > > labelHashSet
A HashSet of labels, uses label hasher.
PrimitivePatch< List< face >, const pointField & > primitiveFacePatch
A PrimitivePatch with List storage for the faces, const reference for the point field.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
List< face > faceList
A List of faces.
Info<< "Finished reading KIVA file"<< endl;cellShapeList cellShapes(nPoints);labelList cellZoning(nPoints, -1);const cellModel &hex=cellModel::ref(cellModel::HEX);labelList hexLabels(8);label activeCells=0;labelList pointMap(nPoints);forAll(pointMap, i){ pointMap[i]=i;}for(label i=0;i< nPoints;i++){ if(f[i] > 0.0) { hexLabels[0]=i;hexLabels[1]=i1tab[i];hexLabels[2]=i3tab[i1tab[i]];hexLabels[3]=i3tab[i];hexLabels[4]=i8tab[i];hexLabels[5]=i1tab[i8tab[i]];hexLabels[6]=i3tab[i1tab[i8tab[i]]];hexLabels[7]=i3tab[i8tab[i]];cellShapes[activeCells].reset(hex, hexLabels);edgeList edges=cellShapes[activeCells].edges();forAll(edges, ei) { if(edges[ei].mag(points)< SMALL) { label start=pointMap[edges[ei].start()];while(start !=pointMap[start]) { start=pointMap[start];} label end=pointMap[edges[ei].end()];while(end !=pointMap[end]) { end=pointMap[end];} label minLabel=min(start, end);pointMap[start]=pointMap[end]=minLabel;} } cellZoning[activeCells]=idreg[i];activeCells++;}}cellShapes.setSize(activeCells);cellZoning.setSize(activeCells);forAll(cellShapes, celli){ cellShape &cs=cellShapes[celli];forAll(cs, i) { cs[i]=pointMap[cs[i]];} cs.collapse();}label bcIDs[11]={-1, 0, 2, 4, -1, 5, -1, 6, 7, 8, 9};const label nBCs=12;const word *kivaPatchTypes[nBCs]={ &wallPolyPatch::typeName, &wallPolyPatch::typeName, &wallPolyPatch::typeName, &wallPolyPatch::typeName, &symmetryPolyPatch::typeName, &wedgePolyPatch::typeName, &polyPatch::typeName, &polyPatch::typeName, &polyPatch::typeName, &polyPatch::typeName, &symmetryPolyPatch::typeName, &oldCyclicPolyPatch::typeName};enum patchTypeNames{ PISTON, VALVE, LINER, CYLINDERHEAD, AXIS, WEDGE, INFLOW, OUTFLOW, PRESIN, PRESOUT, SYMMETRYPLANE, CYCLIC};const char *kivaPatchNames[nBCs]={ "piston", "valve", "liner", "cylinderHead", "axis", "wedge", "inflow", "outflow", "presin", "presout", "symmetryPlane", "cyclic"};List< SLList< face > > pFaces[nBCs]
#define forAll(list, i)
Loop across all elements in list.
#define forAllConstIters(container, iter)
Iterate across all elements of the container object with const access.