37 void Foam::referredCellList::buildReferredCellList
39 bool pointPointListBuild
42 Info <<
nl <<
"Building list of referred interaction neighbours" <<
endl;
46 DynamicList<referredCell> referredInteractionList;
49 DynamicList<label> rCellsWRRP;
52 DynamicList<label> rFacesWRRP;
55 DynamicList<label> rEdgesWRRP;
58 DynamicList<label> rPointsWRRP;
62 mesh.globalData().processorPatches().size()
65 List<vectorList> allNeighbourFaceCentres
67 mesh.globalData().processorPatches().size()
70 List<vectorList> allNeighbourFaceAreas
72 mesh.globalData().processorPatches().size()
75 label nUndecomposedPatches = 0;
79 dictionary patchDictionary;
86 mesh.time().rootPath(),
87 mesh.time().caseName().path()
90 IOobject undecomposedBoundaryHeader
93 undecomposedTime.constant(),
101 if (undecomposedBoundaryHeader.headerOk())
103 polyBoundaryMeshEntries undecomposedPatchEntries
105 undecomposedBoundaryHeader
112 undecomposedPatchEntries[
patchi].keyword()
117 undecomposedPatchEntries[
patchi]
124 <<
nl <<
"unable to read undecomposed boundary file from "
125 <<
"constant/polyMesh" <<
nl
133 "faceProcAddressing",
134 mesh.time().constant(),
145 nUndecomposedPatches = patchNames.
size();
158 const processorPolyPatch& patch = refCast<const processorPolyPatch>
160 mesh.boundaryMesh()[procPatches[pP]]
163 labelList& procPatchSegMap = processorPatchSegmentMapping[pP];
165 procPatchSegMap.
setSize(patch.size());
169 label decomposedMeshFace = patch.start() + pI;
171 label faceProcAdd = faceProcAddressing[decomposedMeshFace];
173 label globalFace = abs(faceProcAdd)-1;
179 if (patchDictionary.found(patchNames[pN]))
181 const dictionary& patchDict =
182 patchDictionary.subDict(patchNames[pN]);
188 patchDict.lookup(
"startFace")
192 label nFaces(readLabel(patchDict.lookup(
"nFaces")));
194 if (minStart < 0 || startFace < minStart)
196 minStart = startFace;
201 globalFace >= startFace
202 && globalFace < startFace + nFaces/2
205 procPatchSegMap[pI] = pN + 1;
209 globalFace >= startFace + nFaces/2
210 && globalFace < startFace + nFaces
213 procPatchSegMap[pI] = -(pN + 1);
218 if (globalFace < minStart)
220 procPatchSegMap[pI] = 0;
227 const processorPolyPatch& patch = refCast<const processorPolyPatch>
229 mesh.boundaryMesh()[procPatches[pP]]
233 OPstream toNeighbProc
239 toNeighbProc << patch.faceCentres() << patch.faceAreas();
245 const processorPolyPatch& patch = refCast<const processorPolyPatch>
247 mesh.boundaryMesh()[procPatches[pP]]
250 vectorList& neighbFaceCentres = allNeighbourFaceCentres[pP];
252 neighbFaceCentres.
setSize(patch.size());
254 vectorList& neighbFaceAreas = allNeighbourFaceAreas[pP];
256 neighbFaceAreas.
setSize(patch.size());
259 IPstream fromNeighbProc
265 fromNeighbProc >> neighbFaceCentres >> neighbFaceAreas;
277 const processorPolyPatch& patch = refCast<const processorPolyPatch>
279 mesh.boundaryMesh()[procPatches[pP]]
282 const vectorList& neighbFaceCentres = allNeighbourFaceCentres[pP];
284 const vectorList& neighbFaceAreas = allNeighbourFaceAreas[pP];
290 nUP = -nUndecomposedPatches;
291 nUP <= nUndecomposedPatches;
295 DynamicList<vector> refOff;
297 DynamicList<tensor> refTrans;
301 if (processorPatchSegmentMapping[pP][faceI] == nUP)
303 referredCell testRefCell
308 patch.faceCentres()[faceI],
309 neighbFaceCentres[faceI],
310 patch.faceNormals()[faceI],
311 neighbFaceAreas[faceI]
312 /(
mag(neighbFaceAreas[faceI]) + VSMALL)
315 refOff.append(testRefCell.offset());
317 refTrans.append(testRefCell.rotation());
329 sum(
mag(refOff-refOff[0]))/refOff.size()
331 ||
sum(
mag(refTrans-refTrans[0]))/refTrans.size()
336 <<
nl <<
"Face pairs on patch "
338 <<
", segment " << patchNames[nUP]
339 <<
" do not give the same referring "
340 <<
" transformations to within tolerance of "
342 <<
" Referring offsets:" << refOff <<
nl
343 <<
" Average sum of mag difference: "
344 <<
sum(
mag(refOff-refOff[0]))/refOff.size() <<
nl
345 <<
" Referring transforms:" << refTrans <<
nl
346 <<
" Average sum of mag difference: "
347 <<
sum(
mag(refTrans-refTrans[0]))/refTrans.size()
355 label cellsReferredThisIteration = 1;
357 label iterationNo = 0;
359 while (cellsReferredThisIteration)
361 label refIntListStartSize = referredInteractionList.size();
369 if (isA<cyclicPolyPatch>(
mesh.boundaryMesh()[patchI]))
371 const cyclicPolyPatch& patch = refCast<const cyclicPolyPatch>
373 mesh.boundaryMesh()[patchI]
378 if (iterationNo == 0)
392 List<tensor> refTrans(patch.size()/2);
396 faceL = 0, faceM = patch.size()/2;
397 faceL < patch.size()/2;
401 referredCell testRefCell
406 patch.faceCentres()[faceL],
407 patch.faceCentres()[faceM],
408 patch.faceNormals()[faceL],
409 patch.faceNormals()[faceM]
412 refOff[faceL] = testRefCell.offset();
414 refTrans[faceL] = testRefCell.rotation();
419 sum(
mag(refOff - refOff[0]))/(patch.size()/2)
421 ||
sum(
mag(refTrans - refTrans[0]))/(patch.size()/2)
426 <<
nl <<
"Face pairs on patch "
428 <<
" do not give the same referring "
429 <<
" transformations to within tolerance of "
431 <<
" Referring offsets:" << refOff <<
nl
432 <<
" Average sum of mag difference: "
433 <<
sum(
mag(refOff-refOff[0]))/refOff.size()
435 <<
" Referring transforms:" << refTrans <<
nl
436 <<
" Average sum of mag difference: "
437 <<
sum(
mag(refTrans-refTrans[0]))
449 DynamicList<label> meshFacesOnThisSegment;
451 for (faceI = 0; faceI < patch.size()/2; faceI++)
457 meshFacesOnThisSegment.append(faceI + patch.start());
460 meshFacesOnThisSegment.shrink();
462 DynamicList<label> meshEdgesOnThisSegment;
464 DynamicList<label> meshPointsOnThisSegment;
466 forAll(meshFacesOnThisSegment, mFOTS)
468 const label segFace = meshFacesOnThisSegment[mFOTS];
474 const label faceEdge(faceEdges[fE]);
480 meshEdgesOnThisSegment,
485 meshEdgesOnThisSegment.append(faceEdge);
489 const face& facePoints(
mesh.faces()[segFace]);
493 const label facePoint(facePoints[fP]);
499 meshPointsOnThisSegment,
506 meshPointsOnThisSegment.append(facePoint);
511 meshEdgesOnThisSegment.shrink();
513 meshPointsOnThisSegment.shrink();
515 if (iterationNo == 0)
525 meshFacesOnThisSegment,
526 meshEdgesOnThisSegment,
527 meshPointsOnThisSegment
531 forAll(realCellsFoundInRange,cFIR)
533 const label realCell = realCellsFoundInRange[cFIR];
535 referredCell cellToRefer
540 patch.faceCentres()[0],
541 patch.faceCentres()[patch.size()/2],
542 patch.faceNormals()[0],
543 patch.faceNormals()[patch.size()/2]
550 bool addCellToRefer =
true;
554 forAll(referredInteractionList, rIL)
558 cellToRefer.duplicate
560 referredInteractionList[rIL]
564 addCellToRefer =
false;
575 cellToRefer.duplicate
582 addCellToRefer =
false;
587 referredInteractionList.append(cellToRefer);
593 if (
findIndex (rCellsWRRP, realCell) == -1)
595 rCellsWRRP.append(realCell);
600 referredInteractionList.shrink();
606 referredInteractionList,
607 meshFacesOnThisSegment,
608 meshEdgesOnThisSegment,
609 meshPointsOnThisSegment
613 forAll(referredCellsFoundInRange,cFIR)
615 referredCell& existingRefCell =
616 referredInteractionList
618 referredCellsFoundInRange[cFIR]
621 referredCell cellToReRefer =
622 existingRefCell.reRefer
624 patch.faceCentres()[0],
625 patch.faceCentres()[patch.size()/2],
626 patch.faceNormals()[0],
627 patch.faceNormals()[patch.size()/2]
634 bool addCellToReRefer =
true;
638 forAll(referredInteractionList, rIL)
642 cellToReRefer.duplicate
644 referredInteractionList[rIL]
648 addCellToReRefer =
false;
659 cellToReRefer.duplicate
666 addCellToReRefer =
false;
669 if (addCellToReRefer)
671 referredInteractionList.append(cellToReRefer);
679 meshFacesOnThisSegment.clear();
681 for (faceI = patch.size()/2; faceI < patch.size(); faceI++)
687 meshFacesOnThisSegment.append(faceI + patch.start());
690 meshFacesOnThisSegment.shrink();
692 meshEdgesOnThisSegment.clear();
694 meshPointsOnThisSegment.clear();
696 forAll(meshFacesOnThisSegment, mFOTS)
698 const label segFace = meshFacesOnThisSegment[mFOTS];
704 const label faceEdge(faceEdges[fE]);
710 meshEdgesOnThisSegment,
717 meshEdgesOnThisSegment.append(faceEdge);
721 const face& facePoints(
mesh.faces()[segFace]);
725 const label facePoint(facePoints[fP]);
731 meshPointsOnThisSegment,
738 meshPointsOnThisSegment.append(facePoint);
743 meshEdgesOnThisSegment.shrink();
745 meshPointsOnThisSegment.shrink();
747 if (iterationNo == 0)
757 meshFacesOnThisSegment,
758 meshEdgesOnThisSegment,
759 meshPointsOnThisSegment
763 forAll(realCellsFoundInRange,cFIR)
765 const label realCell = realCellsFoundInRange[cFIR];
767 referredCell cellToRefer
772 patch.faceCentres()[patch.size()/2],
773 patch.faceCentres()[0],
774 patch.faceNormals()[patch.size()/2],
775 patch.faceNormals()[0]
782 bool addCellToRefer =
true;
786 forAll(referredInteractionList, rIL)
790 cellToRefer.duplicate
792 referredInteractionList[rIL]
796 addCellToRefer =
false;
807 cellToRefer.duplicate
814 addCellToRefer =
false;
819 referredInteractionList.append(cellToRefer);
825 if (
findIndex (rCellsWRRP, realCell) == -1)
827 rCellsWRRP.append(realCell);
832 referredInteractionList.shrink();
834 referredCellsFoundInRange =
837 referredInteractionList,
838 meshFacesOnThisSegment,
839 meshEdgesOnThisSegment,
840 meshPointsOnThisSegment
843 forAll(referredCellsFoundInRange,cFIR)
845 referredCell& existingRefCell =
846 referredInteractionList
848 referredCellsFoundInRange[cFIR]
851 referredCell cellToReRefer =
852 existingRefCell.reRefer
854 patch.faceCentres()[patch.size()/2],
855 patch.faceCentres()[0],
856 patch.faceNormals()[patch.size()/2],
857 patch.faceNormals()[0]
864 bool addCellToReRefer =
true;
868 forAll(referredInteractionList, rIL)
872 cellToReRefer.duplicate
874 referredInteractionList[rIL]
878 addCellToReRefer =
false;
889 cellToReRefer.duplicate
896 addCellToReRefer =
false;
899 if (addCellToReRefer)
901 referredInteractionList.append(cellToReRefer);
914 const processorPolyPatch& patch =
915 refCast<const processorPolyPatch>
917 mesh.boundaryMesh()[procPatches[pP]]
920 DynamicList<referredCell> referredCellsToTransfer;
923 allNeighbourFaceCentres[pP];
925 const vectorList& neighbFaceAreas = allNeighbourFaceAreas[pP];
931 nUP = -nUndecomposedPatches;
932 nUP <= nUndecomposedPatches;
945 DynamicList<label> meshFacesOnThisSegment;
949 if (processorPatchSegmentMapping[pP][faceI] == nUP)
956 meshFacesOnThisSegment.append
958 faceI + patch.start()
963 meshFacesOnThisSegment.shrink();
965 DynamicList<label> meshEdgesOnThisSegment;
967 DynamicList<label> meshPointsOnThisSegment;
969 forAll(meshFacesOnThisSegment, mFOTS)
971 const label segFace = meshFacesOnThisSegment[mFOTS];
977 const label faceEdge(faceEdges[fE]);
983 meshEdgesOnThisSegment,
990 meshEdgesOnThisSegment.append(faceEdge);
994 const face& facePoints(
mesh.faces()[segFace]);
998 const label facePoint(facePoints[fP]);
1004 meshPointsOnThisSegment,
1011 meshPointsOnThisSegment.append(facePoint);
1016 meshEdgesOnThisSegment.shrink();
1018 meshPointsOnThisSegment.shrink();
1020 if (meshFacesOnThisSegment.size())
1025 <<
nl <<
"faceT == -1 encountered but "
1026 << meshFacesOnThisSegment.size()
1027 <<
" faces found on patch segment."
1031 if (iterationNo == 0)
1041 meshFacesOnThisSegment,
1042 meshEdgesOnThisSegment,
1043 meshPointsOnThisSegment
1047 forAll(realCellsFoundInRange,cFIR)
1049 const label realCell =
1050 realCellsFoundInRange[cFIR];
1052 referredCell cellToRefer
1057 patch.faceCentres()[faceT],
1058 neighbFaceCentres[faceT],
1059 patch.faceNormals()[faceT],
1060 neighbFaceAreas[faceT]
1061 /(
mag(neighbFaceAreas[faceT]) + VSMALL)
1064 referredCellsToTransfer.append(cellToRefer);
1069 if (
findIndex (rCellsWRRP, realCell) == -1)
1071 rCellsWRRP.append(realCell);
1076 referredInteractionList.shrink();
1082 referredInteractionList,
1083 meshFacesOnThisSegment,
1084 meshEdgesOnThisSegment,
1085 meshPointsOnThisSegment
1089 forAll(referredCellsFoundInRange,cFIR)
1091 referredCell& existingRefCell =
1092 referredInteractionList
1094 referredCellsFoundInRange[cFIR]
1097 referredCell cellToReRefer =
1098 existingRefCell.reRefer
1100 patch.faceCentres()[faceT],
1101 neighbFaceCentres[faceT],
1102 patch.faceNormals()[faceT],
1103 neighbFaceAreas[faceT]
1104 /(
mag(neighbFaceAreas[faceT]) + VSMALL)
1107 referredCellsToTransfer.append(cellToReRefer);
1112 referredCellsToTransfer.shrink();
1117 OPstream toNeighbProc
1120 patch.neighbProcNo()
1123 toNeighbProc << referredCellsToTransfer;
1129 const processorPolyPatch& patch =
1130 refCast<const processorPolyPatch>
1132 mesh.boundaryMesh()[procPatches[pP]]
1137 List<referredCell> referredCellsFromNeighbour(patch.size());
1140 IPstream fromNeighbProc
1143 patch.neighbProcNo()
1146 fromNeighbProc >> referredCellsFromNeighbour;
1152 forAll(referredCellsFromNeighbour,rCFN)
1154 referredCell& cellToRefer =
1155 referredCellsFromNeighbour[rCFN];
1161 bool addCellToRefer =
true;
1165 forAll(referredInteractionList, rIL)
1167 if (cellToRefer.duplicate(referredInteractionList[rIL]))
1169 addCellToRefer =
false;
1180 cellToRefer.duplicate
1187 addCellToRefer =
false;
1192 referredInteractionList.append(cellToRefer);
1198 if (iterationNo == 0)
1204 rCellsWRRP.shrink();
1210 const label realCell(rCellsWRRP[rCWR]);
1214 mesh.cells()[realCell]
1219 const label
f(rCFaces[rCF]);
1223 rFacesWRRP.append(
f);
1229 mesh.cellEdges()[realCell]
1234 const label
e(rCEdges[rCE]);
1238 rEdgesWRRP.append(
e);
1244 mesh.cellPoints()[realCell]
1249 const label
p(rCPoints[rCP]);
1253 rPointsWRRP.append(
p);
1258 rFacesWRRP.shrink();
1260 rEdgesWRRP.shrink();
1262 rPointsWRRP.shrink();
1267 cellsReferredThisIteration =
1268 referredInteractionList.size() - refIntListStartSize;
1270 reduce(cellsReferredThisIteration, sumOp<label>());
1272 Info<<
tab <<
"Cells added this iteration: "
1273 << cellsReferredThisIteration <<
endl;
1276 referredInteractionList.shrink();
1288 referredInteractionList.size()
1291 forAll(referredInteractionList, rIL)
1293 (*this)[rIL] = referredInteractionList[rIL];
1296 Info<<
nl <<
"Finding real cells in range of referred cells" <<
endl;
1302 referredCell& refCell = (*this)[rC];
1304 DynamicList<label> realCellsFoundInRange;
1306 const vectorList& refCellPoints = refCell.vertexPositions();
1310 const label
f(rFacesWRRP[rCF]);
1314 const label cellO(
mesh.faceOwner()[
f]);
1316 if (
findIndex(realCellsFoundInRange, cellO) == -1)
1318 realCellsFoundInRange.append(cellO);
1321 if (
mesh.isInternalFace(
f))
1325 const label cellN(
mesh.faceNeighbour()[
f]);
1327 if (
findIndex(realCellsFoundInRange, cellN) == -1)
1329 realCellsFoundInRange.append(cellN);
1337 const label
p(rPointsWRRP[rCP]);
1345 const label cellI(pCells[pC]);
1347 if (
findIndex(realCellsFoundInRange, cellI) == -1)
1349 realCellsFoundInRange.append(cellI);
1356 const edgeList& refCellEdges = refCell.edges();
1360 const label edgeIIndex(rEdgesWRRP[rCE]);
1362 const edge& eI(
mesh.edges()[edgeIIndex]);
1364 forAll(refCellEdges, rCE)
1366 const edge& eJ(refCellEdges[rCE]);
1373 refCellPoints[eJ.start()],
1374 refCellPoints[eJ.end()]
1382 const label cellI(eICells[eIC]);
1384 if (
findIndex(realCellsFoundInRange, cellI) == -1)
1386 realCellsFoundInRange.append(cellI);
1424 refCell.realCells() = realCellsFoundInRange.shrink();
1434 bool pointPointListBuild
1440 buildReferredCellList(pointPointListBuild);
1449 Info<<
"Read referredCellList from disk not implemented" <<
endl;
1469 forAll(il_.cellSendingReferralLists(), cSRL)
1473 il_.cellSendingReferralLists()[cSRL]
1486 molsToReferOut[sRLI].
append
1497 molsToReferOut[sRLI].shrink();
1509 sRL.destinationProc()
1512 toInteractingProc << molsToReferOut;
1522 il_.cellReceivingReferralLists()[cSRL]
1529 referredCell& refCellToRefMolsTo = (*this)[rRL[rRLI][rC]];
1531 refCellToRefMolsTo.
referInMols(molsToReferOut[rRLI]);
1541 forAll(il_.cellReceivingReferralLists(), cRRL)
1545 il_.cellReceivingReferralLists()[cRRL]
1560 fromInteractingProc >> molsToReferIn;
1567 referredCell& refCellToRefMolsTo = (*this)[rRL[rRLI][rC]];
1569 refCellToRefMolsTo.
referInMols(molsToReferIn[rRLI]);