54 nTotPoints += pp.nPoints();
67 const label proci = globalTransforms_.processor(info);
68 const label index = globalTransforms_.index(info);
74 globalTransforms_.processor(allInfo[i]) == proci
75 && globalTransforms_.index(allInfo[i]) == index
91 scalar tol = refCast<const coupledPolyPatch>
93 mesh_.boundaryMesh()[
patchi]
109 sendInfo[i] = globalTransforms_.encode
111 globalTransforms_.processor(info[i]),
112 globalTransforms_.index(info[i]),
113 globalTransforms_.addToTransformIndex
115 globalTransforms_.transformIndex(info[i]),
126 void Foam::globalPoints::addToSend
129 const label patchPointi,
132 DynamicList<label>& patchFaces,
133 DynamicList<label>& indexInFace,
134 DynamicList<labelPairList>& allInfo
141 label meshPointi = pp.meshPoints()[patchPointi];
151 const face&
f = pp[patchFacei];
153 patchFaces.
append(patchFacei);
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);
242 const Map<label>& meshToPatchPoint,
243 const label meshPointi
248 meshToPatchPoint.size() == 0
250 : meshToPatchPoint[meshPointi]
258 const label localPointi
263 patchToMeshPoint.size() == 0
265 : patchToMeshPoint[localPointi]
270 bool Foam::globalPoints::mergeInfo
273 const label localPointi
279 label infoChanged =
false;
284 if (iter != meshToProcPoint_.end())
286 if (mergeInfo(nbrInfo, localPointi, procPoints_[iter()]))
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 label infoChanged =
false;
333 if (iter != meshToProcPoint_.end())
335 if (mergeInfo(nbrInfo, localPointi, procPoints_[iter()]))
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,
395 const bool allPoints,
399 const polyBoundaryMesh&
patches = mesh_.boundaryMesh();
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);
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();
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;
566 void 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();
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]];
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
685 meshToProcPoint_.find(localA);
687 if (procPointA != meshToProcPoint_.end())
692 procPoints_[procPointA()]
695 if (mergeInfo(infoA, localB))
697 changedPoints.insert(localB);
703 meshToProcPoint_.find(localB);
705 if (procPointB != meshToProcPoint_.end())
709 cycPatch.nbrPatchIndex(),
710 procPoints_[procPointB()]
713 if (mergeInfo(infoB, localA))
715 changedPoints.insert(localA);
725 void Foam::globalPoints::remove
728 const Map<label>& directNeighbours
735 Map<label> oldMeshToProcPoint(move(meshToProcPoint_));
736 meshToProcPoint_.resize(oldMeshToProcPoint.size());
737 DynamicList<labelPairList> oldProcPoints(move(procPoints_));
738 procPoints_.setCapacity(oldProcPoints.size());
743 label localPointi = iter.key();
746 if (pointInfo.size() == 2)
753 label proc0 = globalTransforms_.processor(pointInfo[0]);
754 label proc1 = globalTransforms_.processor(pointInfo[1]);
760 && directNeighbours.found
762 globalTransforms_.index(pointInfo[0])
767 && directNeighbours.found
769 globalTransforms_.index(pointInfo[1])
804 meshToProcPoint_.insert(localPointi, procPoints_.size());
805 procPoints_.append(pointInfo);
808 else if (pointInfo.size() == 1)
815 globalTransforms_.processor(pointInfo[0])
817 || !directNeighbours.found
819 globalTransforms_.index(pointInfo[0])
823 meshToProcPoint_.insert(localPointi, procPoints_.size());
824 procPoints_.append(pointInfo);
829 meshToProcPoint_.insert(localPointi, procPoints_.size());
830 procPoints_.append(pointInfo);
834 procPoints_.shrink();
835 meshToProcPoint_.resize(2*procPoints_.size());
841 const cyclicPolyPatch& pp
844 const cyclicPolyPatch& nbrPatch = pp.nbrPatch();
846 faceList masterFaces(nbrPatch.size());
850 masterFaces[facei] = nbrPatch[facei].reverseFace();
861 void Foam::globalPoints::calculateSharedPoints
863 const Map<label>& meshToPatchPoint,
865 const bool keepAllPoints,
866 const bool mergeSeparated
871 Pout<<
"globalPoints::calculateSharedPoints(..) : "
872 <<
"doing processor to processor communication to get sharedPoints"
874 <<
" keepAllPoints :" << keepAllPoints <<
endl
875 <<
" mergeSeparated:" << mergeSeparated <<
endl
894 initOwnPoints(meshToPatchPoint,
true, changedPoints);
916 pBufs.finishedSends();
928 Map<label> neighbourList;
931 neighbourList = meshToProcPoint_;
935 bool changed =
false;
954 pBufs.finishedSends();
964 changed = changedPoints.size() > 0;
965 reduce(changed, orOp<bool>());
987 remove(patchToMeshPoint, neighbourList);
1006 pointPoints_.setSize(globalIndices_.localSize());
1007 List<labelPairList> transformedPoints(globalIndices_.localSize());
1012 if (pointInfo.size() >= 2)
1015 const labelPair& masterInfo = pointInfo[0];
1020 globalTransforms_.processor(masterInfo)
1023 && (globalTransforms_.index(masterInfo) == iter.key())
1026 labelList& pPoints = pointPoints_[iter.key()];
1027 pPoints.
setSize(pointInfo.size()-1);
1029 labelPairList& trafoPPoints = transformedPoints[iter.key()];
1030 trafoPPoints.setSize(pointInfo.size()-1);
1032 label nonTransformI = 0;
1033 label transformI = 0;
1035 for (
label i = 1; i < pointInfo.size(); i++)
1038 label proci = globalTransforms_.processor(info);
1039 label index = globalTransforms_.index(info);
1045 if (
transform == globalTransforms_.nullTransformIndex())
1047 pPoints[nonTransformI++] = globalIndices_.toGlobal
1055 trafoPPoints[transformI++] = info;
1059 pPoints.setSize(nonTransformI);
1060 trafoPPoints.setSize(transformI);
1066 List<Map<label>> compactMap;
1076 transformedPointPoints_,
1084 Pout<<
"globalPoints::calculateSharedPoints(..) : "
1085 <<
"Finished global points" <<
endl;
1095 const bool keepAllPoints,
1096 const bool mergeSeparated
1100 globalIndices_(mesh_.
nPoints()),
1101 globalTransforms_(mesh),
1102 nPatchPoints_(countPatchPoints(mesh.boundaryMesh())),
1103 procPoints_(nPatchPoints_),
1104 meshToProcPoint_(nPatchPoints_)
1110 calculateSharedPoints
1124 const bool keepAllPoints,
1125 const bool mergeSeparated
1129 globalIndices_(coupledPatch.
nPoints()),
1130 globalTransforms_(mesh),
1131 nPatchPoints_(coupledPatch.
nPoints()),
1132 procPoints_(nPatchPoints_),
1133 meshToProcPoint_(nPatchPoints_)
1135 calculateSharedPoints
#define forAll(list, i)
Loop across all elements in list.
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object of type.
friend class iterator
Declare friendship with the iterator.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void append(const T &)
Append an element at the end of the list.
void size(const label)
Override size to be inconsistent with allocated storage.
void setSize(const label)
Reset size of List.
virtual const fileName & name() const
Return the name of the stream.
const Map< label > & meshPointMap() const
Mesh point map. Given the global point index find its.
const labelList & meshPoints() const
Return labelList of mesh points in patch. They are constructed.
static bool & parRun()
Is this a parallel run?
static commsTypes defaultCommsType
Default commsType.
static int myProcNo(const label communicator=0)
Number of this process (starting from masterNo() = 0)
void reset(const dimensionSet &)
Calculates points shared by more than two processor patches or cyclic patches.
globalPoints(const polyMesh &mesh, const bool keepAllPoints, const bool mergeSeparated)
Construct from mesh.
Mesh consisting of general polyhedral cells.
const fvPatchList & patches
List< labelPair > labelPairList
List of labelPairs.
Pair< label > labelPair
Label pair.
List< label > labelList
A List of labels.
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.
labelList first(const UList< labelPair > &p)
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
dimensionSet transform(const dimensionSet &)
defineTypeNameAndDebug(combustionModel, 0)
static bool less(const vector &x, const vector &y)
To compare normals.
prefixOSstream Pout(cout, "Pout")
HashSet< label, Hash< label > > labelHashSet
A HashSet with label keys.
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurrence of given element and return index,.
PrimitivePatch< List< face >, const pointField & > primitiveFacePatch
Foam::primitiveFacePatch.
Info<< "Finished reading KIVA file"<< endl;cellShapeList cellShapes(nPoints);labelList cellZoning(nPoints, -1);const cellModel &hex=*(cellModeller::lookup("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]=cellShape(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, &mergedCyclicPolyPatch::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]