50 const List<Type>& faceInfo,
55 if (os.format() == IOstream::ASCII)
59 for(label i = 0; i < nFaces; i++)
61 os <<
' ' << faceLabels[i];
63 for(label i = 0; i < nFaces; i++)
65 os <<
' ' << faceInfo[i];
72 for(label i = 0; i < nFaces; i++)
76 for(label i = 0; i < nFaces; i++)
97 for(label i = 0; i < nFaces; i++)
101 for(label i = 0; i < nFaces; i++)
116 template <
class Type>
120 const label neighbourFaceI,
121 const Type& neighbourInfo,
128 bool wasValid = cellInfo.valid();
142 if (!changedCell_[cellI])
144 changedCell_[cellI] =
true;
145 changedCells_[nChangedCells_++] = cellI;
149 if (!wasValid && cellInfo.valid())
163 template <
class Type>
167 const label neighbourCellI,
168 const Type& neighbourInfo,
175 bool wasValid = faceInfo.valid();
189 if (!changedFace_[faceI])
191 changedFace_[faceI] =
true;
192 changedFaces_[nChangedFaces_++] = faceI;
196 if (!wasValid && faceInfo.valid())
210 template <
class Type>
214 const Type& neighbourInfo,
221 bool wasValid = faceInfo.valid();
234 if (!changedFace_[faceI])
236 changedFace_[faceI] =
true;
237 changedFaces_[nChangedFaces_++] = faceI;
241 if (!wasValid && faceInfo.valid())
251 template <
class Type>
254 label cycOffset = patch.size()/2;
256 for(label patchFaceI = 0; patchFaceI < cycOffset; patchFaceI++)
258 label i1 = patch.start() + patchFaceI;
259 label i2 = i1 + cycOffset;
261 if (!allFaceInfo_[i1].sameGeometry(mesh_, allFaceInfo_[i2], geomTol_))
263 FatalErrorIn(
"FaceCellWave<Type>::checkCyclic(const polyPatch&)")
264 <<
"problem: i:" << i1 <<
" otheri:" << i2
265 <<
" faceInfo:" << allFaceInfo_[i1]
266 <<
" otherfaceInfo:" << allFaceInfo_[i2]
270 if (changedFace_[i1] != changedFace_[i2])
272 FatalErrorIn(
"FaceCellWave<Type>::checkCyclic(const polyPatch&)")
273 <<
" problem: i:" << i1 <<
" otheri:" << i2
274 <<
" faceInfo:" << allFaceInfo_[i1]
275 <<
" otherfaceInfo:" << allFaceInfo_[i2]
276 <<
" changedFace:" << changedFace_[i1]
277 <<
" otherchangedFace:" << changedFace_[i2]
285 template <
class Type>
288 forAll(mesh_.boundaryMesh(), patchI)
290 if (isA<cyclicPolyPatch>(mesh_.boundaryMesh()[patchI]))
300 template <
class Type>
307 forAll(changedFaces, changedFaceI)
309 label faceI = changedFaces[changedFaceI];
311 bool wasValid = allFaceInfo_[faceI].valid();
314 allFaceInfo_[faceI] = changedFacesInfo[changedFaceI];
317 if (!wasValid && allFaceInfo_[faceI].valid())
324 changedFace_[faceI] =
true;
325 changedFaces_[nChangedFaces_++] = faceI;
331 template <
class Type>
341 for(label changedFaceI = 0; changedFaceI < nFaces; changedFaceI++)
343 const Type& neighbourWallInfo = changedFacesInfo[changedFaceI];
344 label patchFaceI = changedFaces[changedFaceI];
346 label meshFaceI = patch.
start() + patchFaceI;
348 Type& currentWallInfo = allFaceInfo_[meshFaceI];
350 if (currentWallInfo != neighbourWallInfo)
367 template <
class Type>
370 const polyPatch& patch,
371 const label startFaceI,
374 List<Type>& changedPatchFacesInfo
377 label nChangedPatchFaces = 0;
379 for(label i = 0; i < nFaces; i++)
381 label patchFaceI = i + startFaceI;
383 label meshFaceI = patch.start() + patchFaceI;
385 if (changedFace_[meshFaceI])
387 changedPatchFaces[nChangedPatchFaces] = patchFaceI;
388 changedPatchFacesInfo[nChangedPatchFaces] = allFaceInfo_[meshFaceI];
389 nChangedPatchFaces++;
392 return nChangedPatchFaces;
397 template <
class Type>
400 const polyPatch& patch,
408 for(label i = 0; i < nFaces; i++)
410 label patchFaceI = faceLabels[i];
412 label meshFaceI = patch.start() + patchFaceI;
413 faceInfo[i].leaveDomain(mesh_, patch, patchFaceI, fc[meshFaceI]);
419 template <
class Type>
422 const polyPatch& patch,
430 for(label i = 0; i < nFaces; i++)
432 label patchFaceI = faceLabels[i];
434 label meshFaceI = patch.start() + patchFaceI;
435 faceInfo[i].enterDomain(mesh_, patch, patchFaceI, fc[meshFaceI]);
441 template <
class Type>
449 if (rotTensor.size() == 1)
451 const tensor&
T = rotTensor[0];
453 for(label faceI = 0; faceI < nFaces; faceI++)
455 faceInfo[faceI].transform(mesh_, T);
460 for(label faceI = 0; faceI < nFaces; faceI++)
462 faceInfo[faceI].transform(mesh_, rotTensor[faceI]);
469 template <
class Type>
472 const label neighbour,
475 const List<Type>& faceInfo
478 OPstream toNeighbour(Pstream::blocking, neighbour);
480 writeFaces(nFaces, faceLabels, faceInfo, toNeighbour);
485 template <
class Type>
488 const label neighbour,
493 IPstream fromNeighbour(Pstream::blocking, neighbour);
496 readFaces(nFaces, faceLabels, faceInfo, fromNeighbour);
503 template <
class Type>
507 const label cycOffset,
512 for(label faceI = 0; faceI < nFaces; faceI++)
514 faces[faceI] += cycOffset;
520 template <
class Type>
525 forAll(mesh_.boundaryMesh(), patchI)
527 const polyPatch& patch = mesh_.boundaryMesh()[patchI];
529 if (isA<processorPolyPatch>(patch))
534 List<Type> sendFacesInfo(patch.size());
537 nSendFaces = getChangedPatchFaces
555 const processorPolyPatch& procPatch =
556 refCast<const processorPolyPatch>(patch);
560 Pout<<
" Processor patch " << patchI <<
' ' << patch.
name()
561 <<
" communicating with " << procPatch.neighbProcNo()
562 <<
" Sending:" << nSendFaces
568 procPatch.neighbProcNo(),
578 forAll(mesh_.boundaryMesh(), patchI)
580 const polyPatch& patch = mesh_.boundaryMesh()[patchI];
582 if (isA<processorPolyPatch>(patch))
584 const processorPolyPatch& procPatch =
585 refCast<const processorPolyPatch>(patch);
590 List<Type> receiveFacesInfo(patch.size());
592 nReceiveFaces = receivePatchInfo
594 procPatch.neighbProcNo(),
601 Pout<<
" Processor patch " << patchI <<
' ' << patch.
name()
602 <<
" communicating with " << procPatch.neighbProcNo()
603 <<
" Receiving:" << nReceiveFaces
608 if (!procPatch.parallel())
612 procPatch.forwardT(),
644 template <
class Type>
647 forAll(mesh_.boundaryMesh(), patchI)
649 const polyPatch& patch = mesh_.boundaryMesh()[patchI];
651 if (isA<cyclicPolyPatch>(patch))
653 label halfSize = patch.size()/2;
658 List<Type> sendFacesInfo(halfSize);
662 List<Type> receiveFacesInfo(halfSize);
665 nSendFaces = getChangedPatchFaces
675 nReceiveFaces = getChangedPatchFaces
711 offset(patch, halfSize, nSendFaces, sendFaces);
714 offset(patch, -halfSize, nReceiveFaces, receiveFaces);
717 const cyclicPolyPatch& cycPatch =
718 refCast<const cyclicPolyPatch>(patch);
720 if (!cycPatch.parallel())
741 Pout<<
" Cyclic patch " << patchI <<
' ' << patch.
name()
742 <<
" Changed on first half : " << nSendFaces
743 <<
" Changed on second half : " << nReceiveFaces
796 template <
class Type>
805 allFaceInfo_(allFaceInfo),
806 allCellInfo_(allCellInfo),
807 changedFace_(mesh_.nFaces(),
false),
808 changedFaces_(mesh_.nFaces()),
810 changedCell_(mesh_.nCells(),
false),
811 changedCells_(mesh_.nCells()),
813 hasCyclicPatches_(hasCyclicPatch()),
815 nUnvisitedCells_(mesh_.nCells()),
816 nUnvisitedFaces_(mesh_.nFaces()),
823 template <
class Type>
835 allFaceInfo_(allFaceInfo),
836 allCellInfo_(allCellInfo),
837 changedFace_(mesh_.nFaces(),
false),
838 changedFaces_(mesh_.nFaces()),
840 changedCell_(mesh_.nCells(),
false),
841 changedCells_(mesh_.nCells()),
843 hasCyclicPatches_(hasCyclicPatch()),
845 nUnvisitedCells_(mesh_.nCells()),
846 nUnvisitedFaces_(mesh_.nFaces()),
850 setFaceInfo(changedFaces, changedFacesInfo);
855 if ((maxIter > 0) && (iter_ >= maxIter))
859 "FaceCellWave<Type>::FaceCellWave"
860 "(const polyMesh&, const labelList&, const List<Type>,"
861 " UList<Type>&, UList<Type>&, const label maxIter)"
863 <<
"Maximum number of iterations reached. Increase maxIter." <<
endl
864 <<
" maxIter:" << maxIter <<
endl
865 <<
" nChangedCells:" << nChangedCells_ <<
endl
866 <<
" nChangedFaces:" << nChangedFaces_ <<
endl
875 template <
class Type>
878 return nUnvisitedCells_;
882 template <
class Type>
885 return nUnvisitedFaces_;
891 template <
class Type>
894 const labelList& owner = mesh_.faceOwner();
895 const labelList& neighbour = mesh_.faceNeighbour();
896 label nInternalFaces = mesh_.nInternalFaces();
900 label changedFaceI = 0;
901 changedFaceI < nChangedFaces_;
905 label faceI = changedFaces_[changedFaceI];
906 if (!changedFace_[faceI])
910 <<
" not marked as having been changed"
915 const Type& neighbourWallInfo = allFaceInfo_[faceI];
920 label cellI = owner[faceI];
921 Type& currentWallInfo = allCellInfo_[cellI];
923 if (currentWallInfo != neighbourWallInfo)
936 if (faceI < nInternalFaces)
938 cellI = neighbour[faceI];
939 Type& currentWallInfo2 = allCellInfo_[cellI];
941 if (currentWallInfo2 != neighbourWallInfo)
955 changedFace_[faceI] =
false;
963 Pout<<
" Changed cells : " << nChangedCells_ <<
endl;
967 label totNChanged = nChangedCells_;
976 template <
class Type>
983 label changedCellI = 0;
984 changedCellI < nChangedCells_;
988 label cellI = changedCells_[changedCellI];
989 if (!changedCell_[cellI])
991 FatalErrorIn(
"FaceCellWave<Type>::cellToFace()") <<
"Cell " << cellI
992 <<
" not marked as having been changed"
996 const Type& neighbourWallInfo = allCellInfo_[cellI];
1000 const labelList& faceLabels = cells[cellI];
1001 forAll(faceLabels, faceLabelI)
1003 label faceI = faceLabels[faceLabelI];
1004 Type& currentWallInfo = allFaceInfo_[faceI];
1006 if (currentWallInfo != neighbourWallInfo)
1020 changedCell_[cellI] =
false;
1026 if (hasCyclicPatches_)
1029 handleCyclicPatches();
1031 if (Pstream::parRun())
1034 handleProcPatches();
1039 Pout<<
" Changed faces : " << nChangedFaces_ <<
endl;
1043 label totNChanged = nChangedFaces_;
1052 template <
class Type>
1055 if (hasCyclicPatches_)
1058 handleCyclicPatches();
1060 if (Pstream::parRun())
1063 handleProcPatches();
1066 while(iter_ < maxIter)
1070 Pout<<
" Iteration " << iter_ <<
endl;
1079 Pout<<
" Total changed cells : " << nCells <<
endl;
1091 Pout<<
" Total changed faces : " << nFaces <<
nl
1092 <<
" Total evaluations : " << nEvals_ <<
nl
1093 <<
" Remaining unvisited cells: " << nUnvisitedCells_ <<
nl
1094 <<
" Remaining unvisited faces: " << nUnvisitedFaces_ <<
endl;
1105 return nUnvisitedCells_;