00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include "globalPoints.H"
00028 #include "processorPolyPatch.H"
00029 #include "cyclicPolyPatch.H"
00030 #include "polyMesh.H"
00031
00032
00033
00034 defineTypeNameAndDebug(Foam::globalPoints, 0);
00035
00036
00037
00038
00039
00040
00041 Foam::label Foam::globalPoints::countPatchPoints
00042 (
00043 const polyBoundaryMesh& patches
00044 )
00045 {
00046 label nTotPoints = 0;
00047
00048 forAll(patches, patchI)
00049 {
00050 const polyPatch& pp = patches[patchI];
00051
00052 if
00053 (
00054 (Pstream::parRun() && isA<processorPolyPatch>(pp))
00055 || isA<cyclicPolyPatch>(pp)
00056 )
00057 {
00058 nTotPoints += pp.nPoints();
00059 }
00060 }
00061
00062 return nTotPoints;
00063 }
00064
00065
00066
00067
00068
00069 void Foam::globalPoints::addToSend
00070 (
00071 const primitivePatch& pp,
00072 const label patchPointI,
00073 const procPointList& knownInfo,
00074
00075 DynamicList<label>& patchFaces,
00076 DynamicList<label>& indexInFace,
00077 DynamicList<procPointList>& allInfo
00078 )
00079 {
00080 label meshPointI = pp.meshPoints()[patchPointI];
00081
00082
00083
00084 const labelList& pFaces = pp.pointFaces()[patchPointI];
00085
00086 forAll(pFaces, i)
00087 {
00088 label patchFaceI = pFaces[i];
00089
00090 const face& f = pp[patchFaceI];
00091
00092 patchFaces.append(patchFaceI);
00093 indexInFace.append(findIndex(f, meshPointI));
00094 allInfo.append(knownInfo);
00095 }
00096 }
00097
00098
00099
00100
00101
00102 bool Foam::globalPoints::mergeInfo
00103 (
00104 const procPointList& nbrInfo,
00105 procPointList& myInfo
00106 )
00107 {
00108
00109 DynamicList<label> newInfo(nbrInfo.size());
00110
00111 forAll(nbrInfo, i)
00112 {
00113 const procPoint& info = nbrInfo[i];
00114
00115
00116 label index = -1;
00117
00118 forAll(myInfo, j)
00119 {
00120 if (myInfo[j] == info)
00121 {
00122
00123
00124 index = j;
00125
00126 break;
00127 }
00128 }
00129
00130 if (index == -1)
00131 {
00132
00133 newInfo.append(i);
00134 }
00135 }
00136
00137 newInfo.shrink();
00138
00139
00140
00141 label index = myInfo.size();
00142
00143 myInfo.setSize(index + newInfo.size());
00144
00145 forAll(newInfo, i)
00146 {
00147 myInfo[index++] = nbrInfo[newInfo[i]];
00148 }
00149
00150
00151 return newInfo.size() > 0;
00152 }
00153
00154
00155
00156
00157 bool Foam::globalPoints::storeInfo
00158 (
00159 const procPointList& nbrInfo,
00160 const label meshPointI
00161 )
00162 {
00163 label infoChanged = false;
00164
00165
00166 Map<label>::iterator iter = meshToProcPoint_.find(meshPointI);
00167
00168 if (iter != meshToProcPoint_.end())
00169 {
00170 procPointList& knownInfo = procPoints_[iter()];
00171
00172 if (mergeInfo(nbrInfo, knownInfo))
00173 {
00174 infoChanged = true;
00175 }
00176 }
00177 else
00178 {
00179 procPointList knownInfo(1);
00180 knownInfo[0][0] = Pstream::myProcNo();
00181 knownInfo[0][1] = meshPointI;
00182
00183 if (mergeInfo(nbrInfo, knownInfo))
00184 {
00185
00186 meshToProcPoint_.insert(meshPointI, procPoints_.size());
00187
00188 procPoints_.append(knownInfo);
00189
00190 infoChanged = true;
00191 }
00192 }
00193 return infoChanged;
00194 }
00195
00196
00197
00198 void Foam::globalPoints::initOwnPoints
00199 (
00200 const bool allPoints,
00201 labelHashSet& changedPoints
00202 )
00203 {
00204 const polyBoundaryMesh& patches = mesh_.boundaryMesh();
00205
00206 forAll(patches, patchI)
00207 {
00208 const polyPatch& pp = patches[patchI];
00209
00210 if
00211 (
00212 (Pstream::parRun() && isA<processorPolyPatch>(pp))
00213 || isA<cyclicPolyPatch>(pp)
00214 )
00215 {
00216 const labelList& meshPoints = pp.meshPoints();
00217
00218 if (allPoints)
00219 {
00220
00221 forAll(meshPoints, i)
00222 {
00223 label meshPointI = meshPoints[i];
00224
00225 procPointList knownInfo(1);
00226 knownInfo[0][0] = Pstream::myProcNo();
00227 knownInfo[0][1] = meshPointI;
00228
00229
00230 meshToProcPoint_.insert(meshPointI, procPoints_.size());
00231
00232 procPoints_.append(knownInfo);
00233
00234
00235 changedPoints.insert(meshPointI);
00236 }
00237 }
00238 else
00239 {
00240
00241 const labelList& boundaryPoints = pp.boundaryPoints();
00242
00243 forAll(boundaryPoints, i)
00244 {
00245 label meshPointI = meshPoints[boundaryPoints[i]];
00246
00247 procPointList knownInfo(1);
00248 knownInfo[0][0] = Pstream::myProcNo();
00249 knownInfo[0][1] = meshPointI;
00250
00251
00252 meshToProcPoint_.insert(meshPointI, procPoints_.size());
00253
00254 procPoints_.append(knownInfo);
00255
00256
00257 changedPoints.insert(meshPointI);
00258 }
00259 }
00260 }
00261 }
00262 }
00263
00264
00265
00266 void Foam::globalPoints::sendPatchPoints(const labelHashSet& changedPoints)
00267 const
00268 {
00269 const polyBoundaryMesh& patches = mesh_.boundaryMesh();
00270
00271 forAll(patches, patchI)
00272 {
00273 const polyPatch& pp = patches[patchI];
00274
00275 if (Pstream::parRun() && isA<processorPolyPatch>(pp))
00276 {
00277
00278
00279 DynamicList<label> patchFaces(pp.nPoints());
00280
00281 DynamicList<label> indexInFace(pp.nPoints());
00282
00283 DynamicList<procPointList> allInfo(pp.nPoints());
00284
00285
00286
00287
00288
00289
00290 const labelList& meshPoints = pp.meshPoints();
00291
00292 forAll(meshPoints, patchPointI)
00293 {
00294 label meshPointI = meshPoints[patchPointI];
00295
00296 if (changedPoints.found(meshPointI))
00297 {
00298 label index = meshToProcPoint_[meshPointI];
00299
00300 const procPointList& knownInfo = procPoints_[index];
00301
00302
00303 addToSend
00304 (
00305 pp,
00306 patchPointI,
00307 knownInfo,
00308
00309 patchFaces,
00310 indexInFace,
00311 allInfo
00312 );
00313 }
00314 }
00315 patchFaces.shrink();
00316 indexInFace.shrink();
00317 allInfo.shrink();
00318
00319
00320 {
00321 const processorPolyPatch& procPatch =
00322 refCast<const processorPolyPatch>(pp);
00323
00324 if (debug)
00325 {
00326 Pout<< " Sending to "
00327 << procPatch.neighbProcNo() << " point information:"
00328 << patchFaces.size() << endl;
00329 }
00330
00331 OPstream toNeighbour
00332 (
00333 Pstream::blocking,
00334 procPatch.neighbProcNo()
00335 );
00336
00337 toNeighbour << patchFaces << indexInFace << allInfo;
00338 }
00339 }
00340 }
00341 }
00342
00343
00344
00345
00346
00347
00348
00349 void Foam::globalPoints::receivePatchPoints(labelHashSet& changedPoints)
00350 {
00351 const polyBoundaryMesh& patches = mesh_.boundaryMesh();
00352
00353
00354 changedPoints.clear();
00355
00356 forAll(patches, patchI)
00357 {
00358 const polyPatch& pp = patches[patchI];
00359
00360 if (Pstream::parRun() && isA<processorPolyPatch>(pp))
00361 {
00362 const processorPolyPatch& procPatch =
00363 refCast<const processorPolyPatch>(pp);
00364
00365 labelList patchFaces;
00366 labelList indexInFace;
00367 List<procPointList> nbrInfo;
00368
00369 {
00370 IPstream fromNeighbour
00371 (
00372 Pstream::blocking,
00373 procPatch.neighbProcNo()
00374 );
00375 fromNeighbour >> patchFaces >> indexInFace >> nbrInfo;
00376 }
00377
00378 if (debug)
00379 {
00380 Pout<< " Received from "
00381 << procPatch.neighbProcNo() << " point information:"
00382 << patchFaces.size() << endl;
00383 }
00384
00385 forAll(patchFaces, i)
00386 {
00387 const face& f = pp[patchFaces[i]];
00388
00389
00390 label index = (f.size() - indexInFace[i]) % f.size();
00391
00392
00393 label meshPointI = f[index];
00394
00395
00396
00397
00398
00399
00400
00401
00402
00403
00404
00405 if (storeInfo(nbrInfo[i], meshPointI))
00406 {
00407 changedPoints.insert(meshPointI);
00408 }
00409 }
00410 }
00411 else if (isA<cyclicPolyPatch>(pp))
00412 {
00413
00414
00415
00416 const cyclicPolyPatch& cycPatch =
00417 refCast<const cyclicPolyPatch>(pp);
00418
00419 const labelList& meshPoints = pp.meshPoints();
00420
00421
00422 const edgeList connections(coupledPoints(cycPatch));
00423
00424 forAll(connections, i)
00425 {
00426 const edge& e = connections[i];
00427
00428 label meshPointA = meshPoints[e[0]];
00429 label meshPointB = meshPoints[e[1]];
00430
00431
00432 Map<label>::iterator procPointA =
00433 meshToProcPoint_.find(meshPointA);
00434
00435 if (procPointA != meshToProcPoint_.end())
00436 {
00437
00438 if (storeInfo(procPoints_[procPointA()], meshPointB))
00439 {
00440 changedPoints.insert(meshPointB);
00441 }
00442 }
00443
00444
00445 Map<label>::iterator procPointB =
00446 meshToProcPoint_.find(meshPointB);
00447
00448 if (procPointB != meshToProcPoint_.end())
00449 {
00450
00451 if (storeInfo(procPoints_[procPointB()], meshPointA))
00452 {
00453 changedPoints.insert(meshPointA);
00454 }
00455 }
00456 }
00457 }
00458 }
00459 }
00460
00461
00462
00463
00464 void Foam::globalPoints::remove(const Map<label>& directNeighbours)
00465 {
00466
00467 Map<label> oldMeshToProcPoint(meshToProcPoint_);
00468 meshToProcPoint_.clear();
00469
00470 List<procPointList> oldProcPoints;
00471 oldProcPoints.transfer(procPoints_);
00472
00473
00474 for
00475 (
00476 Map<label>::const_iterator iter = oldMeshToProcPoint.begin();
00477 iter != oldMeshToProcPoint.end();
00478 ++iter
00479 )
00480 {
00481 label meshPointI = iter.key();
00482 const procPointList& pointInfo = oldProcPoints[iter()];
00483
00484 if (pointInfo.size() == 2)
00485 {
00486
00487
00488
00489
00490
00491 const procPoint& a = pointInfo[0];
00492 const procPoint& b = pointInfo[1];
00493
00494 if
00495 (
00496 (a[0] == Pstream::myProcNo() && directNeighbours.found(a[1]))
00497 || (b[0] == Pstream::myProcNo() && directNeighbours.found(b[1]))
00498 )
00499 {
00500
00501 if (a[0] == Pstream::myProcNo())
00502 {
00503
00504
00505
00506 }
00507 else if (b[0] == Pstream::myProcNo())
00508 {
00509
00510
00511
00512 }
00513 }
00514 else
00515 {
00516
00517
00518
00519
00520
00521
00522
00523
00524
00525
00526
00527
00528 meshToProcPoint_.insert(meshPointI, procPoints_.size());
00529 procPoints_.append(pointInfo);
00530 }
00531 }
00532 else if (pointInfo.size() == 1)
00533 {
00534
00535
00536
00537 if
00538 (
00539 pointInfo[0][0] != Pstream::myProcNo()
00540 || !directNeighbours.found(pointInfo[0][1])
00541 )
00542 {
00543 meshToProcPoint_.insert(meshPointI, procPoints_.size());
00544 procPoints_.append(pointInfo);
00545 }
00546 }
00547 else
00548 {
00549 meshToProcPoint_.insert(meshPointI, procPoints_.size());
00550 procPoints_.append(pointInfo);
00551 }
00552 }
00553
00554 procPoints_.shrink();
00555 }
00556
00557
00558
00559
00560
00561 Foam::labelList Foam::globalPoints::getMasterPoints() const
00562 {
00563 labelList masterPoints(nPatchPoints_);
00564 label nMaster = 0;
00565
00566
00567 for
00568 (
00569 Map<label>::const_iterator iter = meshToProcPoint_.begin();
00570 iter != meshToProcPoint_.end();
00571 ++iter
00572 )
00573 {
00574 label meshPointI = iter.key();
00575 const procPointList& pointInfo = procPoints_[iter()];
00576
00577 if (pointInfo.size() < 2)
00578 {
00579
00580
00581
00582 Pout<< "MeshPoint:" << meshPointI
00583 << " coord:" << mesh_.points()[meshPointI]
00584 << " has no corresponding point on a neighbouring processor"
00585 << endl;
00586 FatalErrorIn("globalPoints::getMasterPoints()")
00587 << '[' << Pstream::myProcNo() << ']'
00588 << " MeshPoint:" << meshPointI
00589 << " coord:" << mesh_.points()[meshPointI]
00590 << " has no corresponding point on a neighbouring processor"
00591 << abort(FatalError);
00592 }
00593 else
00594 {
00595
00596 label lowestProcI = labelMax;
00597 label lowestPointI = labelMax;
00598
00599 forAll(pointInfo, i)
00600 {
00601 label proc = pointInfo[i][0];
00602
00603 if (proc < lowestProcI)
00604 {
00605 lowestProcI = proc;
00606 lowestPointI = pointInfo[i][1];
00607 }
00608 else if (proc == lowestProcI)
00609 {
00610 lowestPointI = min(lowestPointI, pointInfo[i][1]);
00611 }
00612 }
00613
00614 if
00615 (
00616 lowestProcI == Pstream::myProcNo()
00617 && lowestPointI == meshPointI
00618 )
00619 {
00620
00621 masterPoints[nMaster++] = meshPointI;
00622 }
00623 }
00624 }
00625
00626 masterPoints.setSize(nMaster);
00627
00628 return masterPoints;
00629 }
00630
00631
00632
00633 void Foam::globalPoints::sendSharedPoints(const labelList& changedIndices) const
00634 {
00635 const polyBoundaryMesh& patches = mesh_.boundaryMesh();
00636
00637 forAll(patches, patchI)
00638 {
00639 const polyPatch& pp = patches[patchI];
00640
00641 if (Pstream::parRun() && isA<processorPolyPatch>(pp))
00642 {
00643 const processorPolyPatch& procPatch =
00644 refCast<const processorPolyPatch>(pp);
00645
00646 OPstream toNeighbour(Pstream::blocking, procPatch.neighbProcNo());
00647
00648 if (debug)
00649 {
00650 Pout<< "Sending to " << procPatch.neighbProcNo()
00651 << " changed sharedPoints info:"
00652 << changedIndices.size() << endl;
00653 }
00654
00655 toNeighbour
00656 << UIndirectList<label>(sharedPointAddr_, changedIndices)()
00657 << UIndirectList<label>(sharedPointLabels_, changedIndices)();
00658 }
00659 }
00660 }
00661
00662
00663
00664
00665
00666
00667 void Foam::globalPoints::receiveSharedPoints(labelList& changedIndices)
00668 {
00669 changedIndices.setSize(sharedPointAddr_.size());
00670 label nChanged = 0;
00671
00672 const polyBoundaryMesh& patches = mesh_.boundaryMesh();
00673
00674
00675 forAll(patches, patchI)
00676 {
00677 const polyPatch& pp = patches[patchI];
00678
00679 if (Pstream::parRun() && isA<processorPolyPatch>(pp))
00680 {
00681 const processorPolyPatch& procPatch =
00682 refCast<const processorPolyPatch>(pp);
00683
00684
00685 Map<label> nbrSharedPoints(sharedPointAddr_.size());
00686
00687 {
00688
00689
00690
00691 labelList nbrSharedPointAddr;
00692 labelList nbrSharedPointLabels;
00693
00694 {
00695 IPstream fromNeighbour
00696 (
00697 Pstream::blocking,
00698 procPatch.neighbProcNo()
00699 );
00700 fromNeighbour >> nbrSharedPointAddr >> nbrSharedPointLabels;
00701 }
00702
00703
00704 forAll(nbrSharedPointLabels, i)
00705 {
00706 nbrSharedPoints.insert
00707 (
00708 nbrSharedPointLabels[i],
00709 nbrSharedPointAddr[i]
00710 );
00711 }
00712 }
00713
00714
00715
00716 for
00717 (
00718 Map<label>::const_iterator iter = meshToProcPoint_.begin();
00719 iter != meshToProcPoint_.end();
00720 ++iter
00721 )
00722 {
00723 label meshPointI = iter.key();
00724 label index = iter();
00725
00726 if (sharedPointAddr_[index] == -1)
00727 {
00728
00729
00730 const procPointList& knownInfo = procPoints_[index];
00731
00732
00733
00734 forAll(knownInfo, j)
00735 {
00736 const procPoint& info = knownInfo[j];
00737
00738 if
00739 (
00740 (info[0] == procPatch.neighbProcNo())
00741 && nbrSharedPoints.found(info[1])
00742 )
00743 {
00744
00745 label sharedPointI = nbrSharedPoints[info[1]];
00746
00747 sharedPointAddr_[index] = sharedPointI;
00748 sharedPointLabels_[index] = meshPointI;
00749 changedIndices[nChanged++] = index;
00750
00751 break;
00752 }
00753 }
00754 }
00755 }
00756 }
00757 else if (isA<cyclicPolyPatch>(pp))
00758 {
00759 const cyclicPolyPatch& cycPatch =
00760 refCast<const cyclicPolyPatch>(pp);
00761
00762
00763 Map<label> meshToSharedPoint(sharedPointAddr_.size());
00764 forAll(sharedPointLabels_, i)
00765 {
00766 label meshPointI = sharedPointLabels_[i];
00767
00768 meshToSharedPoint.insert(meshPointI, sharedPointAddr_[i]);
00769 }
00770
00771
00772
00773 const edgeList connections(coupledPoints(cycPatch));
00774
00775 forAll(connections, i)
00776 {
00777 const edge& e = connections[i];
00778
00779 label meshPointA = pp.meshPoints()[e[0]];
00780 label meshPointB = pp.meshPoints()[e[1]];
00781
00782
00783 Map<label>::iterator fndA = meshToSharedPoint.find(meshPointA);
00784 Map<label>::iterator fndB = meshToSharedPoint.find(meshPointB);
00785
00786 if (fndA != meshToSharedPoint.end())
00787 {
00788 if (fndB != meshToSharedPoint.end())
00789 {
00790 if (fndA() != fndB())
00791 {
00792 FatalErrorIn
00793 (
00794 "globalPoints::receiveSharedPoints"
00795 "(labelList&)"
00796 ) << "On patch " << pp.name()
00797 << " connected points " << meshPointA
00798 << ' ' << mesh_.points()[meshPointA]
00799 << " and " << meshPointB
00800 << ' ' << mesh_.points()[meshPointB]
00801 << " are mapped to different shared points: "
00802 << fndA() << " and " << fndB()
00803 << abort(FatalError);
00804 }
00805 }
00806 else
00807 {
00808
00809 label sharedPointI = fndA();
00810
00811
00812 label index = meshToProcPoint_[meshPointB];
00813
00814 sharedPointAddr_[index] = sharedPointI;
00815 sharedPointLabels_[index] = meshPointB;
00816 changedIndices[nChanged++] = index;
00817 }
00818 }
00819 else
00820 {
00821
00822 if (fndB != meshToSharedPoint.end())
00823 {
00824 label sharedPointI = fndB();
00825
00826
00827 label index = meshToProcPoint_[meshPointA];
00828
00829 sharedPointAddr_[index] = sharedPointI;
00830 sharedPointLabels_[index] = meshPointA;
00831 changedIndices[nChanged++] = index;
00832 }
00833 }
00834 }
00835 }
00836 }
00837
00838 changedIndices.setSize(nChanged);
00839 }
00840
00841
00842 Foam::edgeList Foam::globalPoints::coupledPoints(const cyclicPolyPatch& pp)
00843 {
00844
00845
00846
00847
00848
00849
00850 labelList coupledPoint(pp.nPoints(), -1);
00851
00852 for (label patchFaceA = 0; patchFaceA < pp.size()/2; patchFaceA++)
00853 {
00854 const face& fA = pp.localFaces()[patchFaceA];
00855
00856 forAll(fA, indexA)
00857 {
00858 label patchPointA = fA[indexA];
00859
00860 if (coupledPoint[patchPointA] == -1)
00861 {
00862 const face& fB = pp.localFaces()[patchFaceA + pp.size()/2];
00863
00864 label indexB = (fB.size() - indexA) % fB.size();
00865
00866 coupledPoint[patchPointA] = fB[indexB];
00867 }
00868 }
00869 }
00870
00871 edgeList connected(pp.nPoints());
00872
00873
00874 label connectedI = 0;
00875
00876 forAll(coupledPoint, i)
00877 {
00878 if (coupledPoint[i] != -1)
00879 {
00880 connected[connectedI++] = edge(i, coupledPoint[i]);
00881 }
00882 }
00883
00884 connected.setSize(connectedI);
00885
00886 return connected;
00887 }
00888
00889
00890
00891
00892
00893 Foam::globalPoints::globalPoints(const polyMesh& mesh)
00894 :
00895 mesh_(mesh),
00896 nPatchPoints_(countPatchPoints(mesh.boundaryMesh())),
00897 procPoints_(nPatchPoints_),
00898 meshToProcPoint_(nPatchPoints_),
00899 sharedPointAddr_(0),
00900 sharedPointLabels_(0),
00901 nGlobalPoints_(0)
00902 {
00903 if (debug)
00904 {
00905 Pout<< "globalPoints::globalPoints(const polyMesh&) : "
00906 << "doing processor to processor communication to get sharedPoints"
00907 << endl;
00908 }
00909
00910 labelHashSet changedPoints(nPatchPoints_);
00911
00912
00913
00914
00915
00916
00917
00918
00919
00920
00921
00922
00923
00924 initOwnPoints(true, changedPoints);
00925
00926
00927 sendPatchPoints(changedPoints);
00928 receivePatchPoints(changedPoints);
00929
00930
00931
00932 Map<label> neighbourList(meshToProcPoint_);
00933
00934
00935
00936 bool changed = false;
00937
00938 do
00939 {
00940 sendPatchPoints(changedPoints);
00941 receivePatchPoints(changedPoints);
00942
00943 changed = changedPoints.size() > 0;
00944 reduce(changed, orOp<bool>());
00945
00946 } while (changed);
00947
00948
00949
00950 remove(neighbourList);
00951
00952
00953
00954
00955
00956
00957
00958
00959
00960
00961
00962
00963
00964
00965
00966
00967
00968
00969
00970
00971
00972
00973
00974
00975
00976
00977
00978
00979
00980
00981
00982
00983
00984
00985 sharedPointAddr_.setSize(meshToProcPoint_.size());
00986 sharedPointAddr_ = -1;
00987 sharedPointLabels_.setSize(meshToProcPoint_.size());
00988 sharedPointLabels_ = -1;
00989
00990
00991
00992 labelList masterPoints(getMasterPoints());
00993
00994
00995
00996 labelList sharedPointSizes(Pstream::nProcs());
00997 sharedPointSizes[Pstream::myProcNo()] = masterPoints.size();
00998
00999 Pstream::gatherList(sharedPointSizes);
01000 Pstream::scatterList(sharedPointSizes);
01001
01002 if (debug)
01003 {
01004 Pout<< "sharedPointSizes:" << sharedPointSizes << endl;
01005 }
01006
01007
01008 nGlobalPoints_ = 0;
01009 forAll(sharedPointSizes, procI)
01010 {
01011 nGlobalPoints_ += sharedPointSizes[procI];
01012 }
01013
01014
01015
01016
01017
01018
01019
01020 label sharedPointI = 0;
01021 for (label procI = 0; procI < Pstream::myProcNo(); procI++)
01022 {
01023 sharedPointI += sharedPointSizes[procI];
01024 }
01025
01026 forAll(masterPoints, i)
01027 {
01028 label meshPointI = masterPoints[i];
01029
01030 label index = meshToProcPoint_[meshPointI];
01031
01032 sharedPointLabels_[index] = meshPointI;
01033 sharedPointAddr_[index] = sharedPointI++;
01034 }
01035
01036
01037
01038
01039
01040
01041
01042 labelList changedIndices(sharedPointAddr_.size());
01043 label nChanged = 0;
01044
01045 forAll(sharedPointAddr_, i)
01046 {
01047 if (sharedPointAddr_[i] != -1)
01048 {
01049 changedIndices[nChanged++] = i;
01050 }
01051 }
01052 changedIndices.setSize(nChanged);
01053
01054 changed = false;
01055
01056 do
01057 {
01058 if (debug)
01059 {
01060 Pout<< "Determined " << changedIndices.size() << " shared points."
01061 << " Exchanging them" << endl;
01062 }
01063 sendSharedPoints(changedIndices);
01064 receiveSharedPoints(changedIndices);
01065
01066 changed = changedIndices.size() > 0;
01067 reduce(changed, orOp<bool>());
01068
01069 } while (changed);
01070
01071
01072 forAll(sharedPointLabels_, i)
01073 {
01074 if (sharedPointLabels_[i] == -1)
01075 {
01076 FatalErrorIn("globalPoints::globalPoints(const polyMesh& mesh)")
01077 << "Problem: shared point on processor " << Pstream::myProcNo()
01078 << " not set at index " << sharedPointLabels_[i] << endl
01079 << "This might mean the individual processor domains are not"
01080 << " connected and the overall domain consists of multiple"
01081 << " regions. You can check this with checkMesh"
01082 << abort(FatalError);
01083 }
01084 }
01085
01086 if (debug)
01087 {
01088 Pout<< "globalPoints::globalPoints(const polyMesh&) : "
01089 << "Finished global points" << endl;
01090 }
01091 }
01092
01093
01094