45 Foam::label Foam::globalPoints::countPatchPoints
56 nTotPoints +=
pp.nPoints();
63 Foam::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]),
128 void Foam::globalPoints::addToSend
131 const label patchPointi,
134 DynamicList<label>& patchFaces,
135 DynamicList<label>& indexInFace,
136 DynamicList<labelPairList>& allInfo
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));
162 bool 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);
240 Foam::label Foam::globalPoints::meshToLocalPoint
242 const Map<label>& meshToPatchPoint,
243 const label meshPointi
248 meshToPatchPoint.size() == 0
250 : meshToPatchPoint[meshPointi]
255 Foam::label Foam::globalPoints::localToMeshPoint
258 const label localPointi
263 patchToMeshPoint.size() == 0
265 : patchToMeshPoint[localPointi]
270 bool Foam::globalPoints::mergeInfo
273 const label localPointi
279 bool 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);
319 bool Foam::globalPoints::storeInitialInfo
322 const label localPointi
328 bool 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);
353 void 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];
378 void Foam::globalPoints::printProcPoints
386 printProcPoint(patchToMeshPoint, pointInfo[i]);
392 void Foam::globalPoints::initOwnPoints
394 const Map<label>& meshToPatchPoint,
399 const polyBoundaryMesh&
patches = mesh_.boundaryMesh();
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);
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);
479 void 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();
497 pBufs.initRegisterSend();
503 DynamicList<label> patchFaces;
506 DynamicList<label> indexInFace;
509 DynamicList<labelPairList> allInfo;
522 && (mergeSeparated || patchInfo[patchi].first() == -1)
525 const auto& procPatch = refCast<const processorPolyPatch>(
pp);
526 const label nbrProci = procPatch.neighbProcNo();
543 forAll(meshPoints, patchPointi)
545 label meshPointi = meshPoints[patchPointi];
546 label localPointi = meshToLocalPoint
552 if (changedPoints.found(localPointi))
554 label index = meshToProcPoint_[localPointi];
576 UOPstream toNbr(nbrProci, pBufs);
577 toNbr << patchFaces << indexInFace << allInfo;
580 pBufs.registerSend(nbrProci, !patchFaces.empty());
584 Pout<<
"Sending from " <<
pp.name() <<
" to proc:" 585 << nbrProci <<
" point information:" 586 << patchFaces.size() <<
endl;
593 pBufs.clearUnregistered();
597 void Foam::globalPoints::receivePatchPoints
599 const bool mergeSeparated,
600 const Map<label>& meshToPatchPoint,
602 PstreamBuffers& pBufs,
612 const polyBoundaryMesh&
patches = mesh_.boundaryMesh();
613 const labelPairList& patchInfo = globalTransforms_.patchTransformSign();
616 changedPoints.clear();
625 && (mergeSeparated || patchInfo[patchi].first() == -1)
628 const auto& procPatch = refCast<const processorPolyPatch>(
pp);
629 const label nbrProci = procPatch.neighbProcNo();
631 if (!pBufs.recvDataCount(nbrProci))
639 List<labelPairList> nbrInfo;
642 UIPstream fromNbr(nbrProci, pBufs);
643 fromNbr >> patchFaces >> indexInFace >> nbrInfo;
648 Pout<<
" On " <<
pp.name()
650 << nbrProci <<
" point information:" 651 << patchFaces.size() <<
endl;
656 const face&
f =
pp[patchFaces[i]];
659 label index = (
f.
size() - indexInFace[i]) %
f.
size();
662 label meshPointi =
f[index];
664 label localPointi = meshToLocalPoint
670 if (mergeInfo(nbrInfo[i], localPointi))
672 changedPoints.insert(localPointi);
679 isA<cyclicPolyPatch>(
pp)
680 && refCast<const cyclicPolyPatch>(
pp).owner()
682 && (mergeSeparated || patchInfo[patchi].first() == -1)
688 const cyclicPolyPatch& cycPatch =
689 refCast<const cyclicPolyPatch>(
pp);
694 const labelList coupledMeshPoints(reverseMeshPoints(cycPatch));
698 label meshPointA = meshPoints[i];
699 label meshPointB = coupledMeshPoints[i];
701 if (meshPointA != meshPointB)
708 label localA = meshToLocalPoint
713 label localB = meshToLocalPoint
721 const auto procPointA = meshToProcPoint_.cfind(localA);
723 if (procPointA.good())
728 procPoints_[procPointA()]
731 if (mergeInfo(infoA, localB))
733 changedPoints.insert(localB);
738 const auto procPointB = meshToProcPoint_.cfind(localB);
740 if (procPointB.good())
744 cycPatch.neighbPatchID(),
745 procPoints_[procPointB()]
748 if (mergeInfo(infoB, localA))
750 changedPoints.insert(localA);
760 void Foam::globalPoints::remove
763 const Map<label>& directNeighbours
770 Map<label> oldMeshToProcPoint(std::move(meshToProcPoint_));
771 meshToProcPoint_.reserve(oldMeshToProcPoint.size());
772 DynamicList<labelPairList> oldProcPoints(std::move(procPoints_));
773 procPoints_.setCapacity(oldProcPoints.size());
778 const label localPointi = iter.key();
781 if (pointInfo.size() == 2)
788 label proc0 = globalTransforms_.processor(pointInfo[0]);
789 label proc1 = globalTransforms_.processor(pointInfo[1]);
795 && directNeighbours.found
797 globalTransforms_.index(pointInfo[0])
802 && directNeighbours.found
804 globalTransforms_.index(pointInfo[1])
839 meshToProcPoint_.insert(localPointi, procPoints_.size());
840 procPoints_.append(pointInfo);
843 else if (pointInfo.size() == 1)
850 globalTransforms_.processor(pointInfo[0])
852 || !directNeighbours.found
854 globalTransforms_.index(pointInfo[0])
858 meshToProcPoint_.insert(localPointi, procPoints_.size());
859 procPoints_.append(pointInfo);
864 meshToProcPoint_.insert(localPointi, procPoints_.size());
865 procPoints_.append(pointInfo);
869 procPoints_.shrink();
870 meshToProcPoint_.reserve(procPoints_.size());
876 const cyclicPolyPatch&
pp 879 const cyclicPolyPatch& nbrPatch =
pp.neighbPatch();
881 faceList masterFaces(nbrPatch.size());
885 masterFaces[facei] = nbrPatch[facei].reverseFace();
896 void Foam::globalPoints::calculateSharedPoints
898 const Map<label>& meshToPatchPoint,
900 const bool keepAllPoints,
901 const bool mergeSeparated
906 Pout<<
"globalPoints::calculateSharedPoints(..) : " 907 <<
"doing processor to processor communication to get sharedPoints" 909 <<
" keepAllPoints :" << keepAllPoints <<
endl 910 <<
" mergeSeparated:" << mergeSeparated <<
endl 929 initOwnPoints(meshToPatchPoint,
true, changedPoints);
944 pBufs.allowClearRecv(
false);
956 pBufs.finishedSends();
969 Map<label> neighbourList;
972 neighbourList = meshToProcPoint_;
987 pBufs.finishedSends();
1018 remove(patchToMeshPoint, neighbourList);
1037 pointPoints_.setSize(globalIndices_.localSize());
1038 List<labelPairList> transformedPoints(globalIndices_.localSize());
1044 if (pointInfo.size() >= 2)
1047 const labelPair& masterInfo = pointInfo[0];
1052 globalTransforms_.processor(masterInfo)
1055 && (globalTransforms_.index(masterInfo) == iter.key())
1058 labelList& pPoints = pointPoints_[iter.key()];
1059 pPoints.
setSize(pointInfo.size()-1);
1061 labelPairList& trafoPPoints = transformedPoints[iter.key()];
1062 trafoPPoints.setSize(pointInfo.size()-1);
1064 label nonTransformI = 0;
1065 label transformI = 0;
1067 for (label i = 1; i < pointInfo.size(); i++)
1070 label proci = globalTransforms_.processor(info);
1071 label index = globalTransforms_.index(info);
1072 label
transform = globalTransforms_.transformIndex
1077 if (
transform == globalTransforms_.nullTransformIndex())
1079 pPoints[nonTransformI++] = globalIndices_.toGlobal
1087 trafoPPoints[transformI++] = info;
1091 pPoints.setSize(nonTransformI);
1092 trafoPPoints.setSize(transformI);
1098 List<Map<label>> compactMap;
1108 transformedPointPoints_,
1116 Pout<<
"globalPoints::calculateSharedPoints(..) : " 1117 <<
"Finished global points" <<
endl;
1124 Foam::globalPoints::globalPoints
1126 const polyMesh&
mesh,
1127 const bool keepAllPoints,
1128 const bool mergeSeparated
1132 globalIndices_(mesh_.
nPoints()),
1133 globalTransforms_(
mesh),
1134 nPatchPoints_(countPatchPoints(
mesh.boundaryMesh())),
1135 procPoints_(nPatchPoints_),
1136 meshToProcPoint_(nPatchPoints_)
1139 Map<label> meshToPatchPoint(0);
1142 calculateSharedPoints
1152 Foam::globalPoints::globalPoints
1156 const bool keepAllPoints,
1157 const bool mergeSeparated
1161 globalIndices_(coupledPatch.
nPoints()),
1162 globalTransforms_(
mesh),
1163 nPatchPoints_(coupledPatch.
nPoints()),
1164 procPoints_(nPatchPoints_),
1165 meshToProcPoint_(nPatchPoints_)
1167 calculateSharedPoints
label nPoints() const
Number of points supporting patch faces.
void size(const label n)
Older name for setAddressableSize.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
const labelList & boundaryPoints() const
Return list of boundary points, address into LOCAL point list.
Ostream & endl(Ostream &os)
Add newline and flush stream.
static bool & parRun() noexcept
Test if this a parallel run.
List< labelPair > labelPairList
List of labelPair.
static int myProcNo(const label communicator=worldComm)
Rank of this process in the communicator (starting from masterNo()). Can be negative if the process i...
static bool less(const vector &x, const vector &y)
To compare normals.
const labelList & meshPoints() const
Return labelList of mesh points in patch.
#define forAll(list, i)
Loop across all elements in list.
HashSet< label, Hash< label > > labelHashSet
A HashSet of labels, uses label hasher.
List< face > faceList
List of faces.
A list of faces which address into the list of points.
const Map< label > & meshPointMap() const
Mesh point map.
void setSize(const label n)
Alias for resize()
"scheduled" : (MPI_Send, MPI_Recv)
void sort(UList< T > &list)
Sort the list.
label find(const T &val) const
Find index of the first occurrence of the value.
void reset(const dimensionSet &ds)
Copy assign the exponents from the dimensionSet.
const labelListList & pointFaces() const
Return point-face addressing.
void clear()
Clear the patch list and all demand-driven data.
int debug
Static debugging option.
Pair< label > labelPair
A pair of labels.
defineTypeNameAndDebug(combustionModel, 0)
PrimitivePatch< List< face >, const pointField & > primitiveFacePatch
A PrimitivePatch with List storage for the faces, const reference for the point field.
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]
static commsTypes defaultCommsType
Default commsType.
const polyBoundaryMesh & patches
"nonBlocking" : (MPI_Isend, MPI_Irecv)
Mesh consisting of general polyhedral cells.
List< label > labelList
A List of labels.
dimensionSet transform(const dimensionSet &ds)
Return the argument; transformations do not change the dimensions.
bool returnReduceOr(const bool value, const label comm=UPstream::worldComm)
Perform logical (or) MPI Allreduce on a copy. Uses UPstream::reduceOr.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
forAllConstIters(mixture.phases(), phase)