44 template<
class Type,
class TrackingData>
47 template<
class Type,
class TrackingData>
50 template<
class Type,
class TrackingData>
56 template<
class Type,
class TrackingData>
86 if (
y.valid(solver_.
data()))
91 meshFacei = patch_.
start() + facei;
113 template<
class Type,
class TrackingData>
117 const label neighbourFacei,
118 const Type& neighbourInfo,
133 const bool propagate =
146 if (changedCell_.set(celli))
148 changedCells_.append(celli);
161 template<
class Type,
class TrackingData>
165 const label neighbourCelli,
166 const Type& neighbourInfo,
179 const bool wasValid = faceInfo.valid(td_);
181 const bool propagate =
194 if (changedFace_.set(facei))
196 changedFaces_.append(facei);
200 if (!wasValid && faceInfo.valid(td_))
209 template<
class Type,
class TrackingData>
213 const Type& neighbourInfo,
226 const bool wasValid = faceInfo.valid(td_);
228 const bool propagate =
240 if (changedFace_.set(facei))
242 changedFaces_.append(facei);
246 if (!wasValid && faceInfo.valid(td_))
255 template<
class Type,
class TrackingData>
268 const label i1 =
patch.start() + patchFacei;
269 const label i2 = nbrPatch.
start() + patchFacei;
273 !allFaceInfo_[i1].sameGeometry
283 <<
" faceInfo:" << allFaceInfo_[i1]
284 <<
" otherfaceInfo:" << allFaceInfo_[i2]
288 if (changedFace_.test(i1) != changedFace_.test(i2))
291 <<
" faceInfo:" << allFaceInfo_[i1]
292 <<
" otherfaceInfo:" << allFaceInfo_[i2]
293 <<
" changedFace:" << changedFace_.test(i1)
294 <<
" otherchangedFace:" << changedFace_.test(i2)
301 template<
class Type,
class TrackingData>
302 template<
class PatchType>
305 for (
const polyPatch&
p : mesh_.boundaryMesh())
307 if (isA<PatchType>(
p))
316 template<
class Type,
class TrackingData>
323 const bool wasValid = allFaceInfo_[facei].valid(td_);
326 allFaceInfo_[facei] = faceInfo;
329 if (!wasValid && allFaceInfo_[facei].valid(td_))
335 changedFace_.set(facei);
336 changedFaces_.append(facei);
340 template<
class Type,
class TrackingData>
347 forAll(changedFaces, changedFacei)
349 const label facei = changedFaces[changedFacei];
351 const bool wasValid = allFaceInfo_[facei].valid(td_);
354 allFaceInfo_[facei] = changedFacesInfo[changedFacei];
357 if (!wasValid && allFaceInfo_[facei].valid(td_))
363 changedFace_.
set(facei);
364 changedFaces_.append(facei);
369 template<
class Type,
class TrackingData>
380 for (label changedFacei = 0; changedFacei < nFaces; ++changedFacei)
382 const Type& newInfo = changedFacesInfo[changedFacei];
383 const label patchFacei = changedFaces[changedFacei];
385 const label meshFacei =
patch.start() + patchFacei;
387 Type& currInfo = allFaceInfo_[meshFacei];
389 if (!currInfo.equal(newInfo, td_))
403 template<
class Type,
class TrackingData>
407 const label startFacei,
418 for (label i = 0; i < nFaces; ++i)
420 const label patchFacei = i + startFacei;
421 const label meshFacei =
patch.start() + patchFacei;
423 if (changedFace_.test(meshFacei))
425 changedPatchFaces[nChanged] = patchFacei;
426 changedPatchFacesInfo[nChanged] = allFaceInfo_[meshFacei];
435 template<
class Type,
class TrackingData>
448 for (label i = 0; i < nFaces; ++i)
450 const label patchFacei = faceLabels[i];
451 const label meshFacei =
patch.start() + patchFacei;
453 faceInfo[i].leaveDomain(mesh_,
patch, patchFacei, fc[meshFacei], td_);
458 template<
class Type,
class TrackingData>
471 for (label i = 0; i < nFaces; ++i)
473 const label patchFacei = faceLabels[i];
474 const label meshFacei =
patch.start() + patchFacei;
476 faceInfo[i].enterDomain(mesh_,
patch, patchFacei, fc[meshFacei], td_);
481 template<
class Type,
class TrackingData>
491 if (rotTensor.size() == 1)
493 const tensor&
T = rotTensor[0];
495 for (label facei = 0; facei < nFaces; ++facei)
497 faceInfo[facei].transform(mesh_,
T, td_);
502 for (label facei = 0; facei < nFaces; ++facei)
504 faceInfo[facei].transform(mesh_, rotTensor[facei], td_);
510 template<
class Type,
class TrackingData>
514 const label cycOffset,
522 for (label facei = 0; facei < nFaces; ++facei)
524 faces[facei] += cycOffset;
529 template<
class Type,
class TrackingData>
543 for (
const label patchi : procPatches)
546 refCast<const processorPolyPatch>(mesh_.boundaryMesh()[patchi]);
554 nSendFaces = getChangedPatchFaces
574 Pout<<
" Processor patch " << patchi <<
' ' << procPatch.
name()
576 <<
" Sending:" << nSendFaces
591 for (
const label patchi : procPatches)
594 refCast<const processorPolyPatch>(mesh_.boundaryMesh()[patchi]);
602 fromNeighbour >> receiveFaces >> receiveFacesInfo;
607 Pout<<
" Processor patch " << patchi <<
' ' << procPatch.
name()
609 <<
" Receiving:" << receiveFaces.size()
645 template<
class Type,
class TrackingData>
656 const auto& cycPatch = *cpp;
665 nReceiveFaces = getChangedPatchFaces
683 if (!cycPatch.parallel())
696 Pout<<
" Cyclic patch "
697 << cycPatch.index() <<
' ' << cycPatch.
name()
698 <<
" Changed : " << nReceiveFaces
722 checkCyclic(cycPatch);
729 template<
class Type,
class TrackingData>
740 const auto& cycPatch = *cpp;
755 if (!nbrPatch.parallel() || nbrPatch.separated())
761 sendInfo[i].leaveDomain(mesh_, nbrPatch, i, fc[i], td_);
768 if (cycPatch.applyLowWeightCorrection())
772 cycPatch.patchInternalList(allCellInfo_)
775 cycPatch.interpolate(sendInfo, cmb, receiveInfo, defVals);
779 cycPatch.interpolate(sendInfo, cmb, receiveInfo);
784 if (!cycPatch.parallel())
794 if (!cycPatch.parallel() || cycPatch.separated())
800 receiveInfo[i].enterDomain(mesh_, cycPatch, i, fc[i], td_);
807 const label meshFacei = cycPatch.start()+i;
809 const Type& newInfo = receiveInfo[i];
811 Type& currInfo = allFaceInfo_[meshFacei];
813 if (newInfo.valid(td_) && !currInfo.equal(newInfo, td_))
829 template<
class Type,
class TrackingData>
832 changedBaffles_.clear();
835 for (
const labelPair& baffle : explicitConnections_)
837 const label f0 = baffle.first();
838 const label f1 = baffle.second();
840 if (changedFace_.test(f0))
846 if (changedFace_.test(f1))
858 const label tgtFace = updated.first;
859 const Type& newInfo = updated.second;
861 Type& currInfo = allFaceInfo_[tgtFace];
863 if (!currInfo.equal(newInfo, td_))
875 changedBaffles_.clear();
881 template<
class Type,
class TrackingData>
891 explicitConnections_(),
892 allFaceInfo_(allFaceInfo),
893 allCellInfo_(allCellInfo),
895 changedFace_(mesh_.nFaces(),
false),
896 changedCell_(mesh_.nCells(),
false),
897 changedFaces_(mesh_.nFaces()),
898 changedCells_(mesh_.nCells()),
899 changedBaffles_(2*explicitConnections_.size()),
900 hasCyclicPatches_(hasPatch<cyclicPolyPatch>()),
906 nUnvisitedCells_(mesh_.nCells()),
907 nUnvisitedFaces_(mesh_.nFaces())
911 allFaceInfo.
size() != mesh_.nFaces()
912 || allCellInfo.
size() != mesh_.nCells()
916 <<
"face and cell storage not the size of mesh faces, cells:" <<
nl
917 <<
" allFaceInfo :" << allFaceInfo.
size() <<
nl
918 <<
" mesh_.nFaces():" << mesh_.nFaces() <<
nl
919 <<
" allCellInfo :" << allCellInfo.
size() <<
nl
920 <<
" mesh_.nCells():" << mesh_.nCells() <<
endl
926 template<
class Type,
class TrackingData>
939 explicitConnections_(),
940 allFaceInfo_(allFaceInfo),
941 allCellInfo_(allCellInfo),
943 changedFace_(mesh_.nFaces(),
false),
944 changedCell_(mesh_.nCells(),
false),
945 changedFaces_(mesh_.nFaces()),
946 changedCells_(mesh_.nCells()),
947 changedBaffles_(2*explicitConnections_.size()),
948 hasCyclicPatches_(hasPatch<cyclicPolyPatch>()),
954 nUnvisitedCells_(mesh_.nCells()),
955 nUnvisitedFaces_(mesh_.nFaces())
959 allFaceInfo.
size() != mesh_.nFaces()
960 || allCellInfo.
size() != mesh_.nCells()
964 <<
"face and cell storage not the size of mesh faces, cells:" <<
nl
965 <<
" allFaceInfo :" << allFaceInfo.
size() <<
nl
966 <<
" mesh_.nFaces():" << mesh_.nFaces() <<
nl
967 <<
" allCellInfo :" << allCellInfo.
size() <<
nl
968 <<
" mesh_.nCells():" << mesh_.nCells() <<
endl
973 setFaceInfo(changedFaces, changedFacesInfo);
976 const label iter = iterate(maxIter);
978 if ((maxIter > 0) && (iter >= maxIter))
981 <<
"Maximum number of iterations reached. Increase maxIter." <<
nl
982 <<
" maxIter:" << maxIter <<
nl
983 <<
" nChangedCells:" << changedCells_.size() <<
nl
984 <<
" nChangedFaces:" << changedFaces_.size() <<
endl
990 template<
class Type,
class TrackingData>
995 const bool handleCyclicAMI,
1000 const label maxIter,
1005 explicitConnections_(explicitConnections),
1006 allFaceInfo_(allFaceInfo),
1007 allCellInfo_(allCellInfo),
1009 changedFace_(mesh_.nFaces(),
false),
1010 changedCell_(mesh_.nCells(),
false),
1011 changedFaces_(mesh_.nFaces()),
1012 changedCells_(mesh_.nCells()),
1013 changedBaffles_(2*explicitConnections_.size()),
1014 hasCyclicPatches_(hasPatch<cyclicPolyPatch>()),
1015 hasCyclicAMIPatches_
1021 nUnvisitedCells_(mesh_.nCells()),
1022 nUnvisitedFaces_(mesh_.nFaces())
1026 allFaceInfo.
size() != mesh_.nFaces()
1027 || allCellInfo.
size() != mesh_.nCells()
1031 <<
"face and cell storage not the size of mesh faces, cells:" <<
nl
1032 <<
" allFaceInfo :" << allFaceInfo.
size() <<
nl
1033 <<
" mesh_.nFaces():" << mesh_.nFaces() <<
nl
1034 <<
" allCellInfo :" << allCellInfo.
size() <<
nl
1035 <<
" mesh_.nCells():" << mesh_.nCells() <<
endl
1040 setFaceInfo(changedFaces, changedFacesInfo);
1043 const label iter = iterate(maxIter);
1045 if ((maxIter > 0) && (iter >= maxIter))
1048 <<
"Maximum number of iterations reached. Increase maxIter." <<
nl
1049 <<
" maxIter:" << maxIter <<
nl
1050 <<
" nChangedCells:" << changedCells_.size() <<
nl
1051 <<
" nChangedFaces:" << changedFaces_.size() <<
endl
1059 template<
class Type,
class TrackingData>
1062 return nUnvisitedCells_;
1066 template<
class Type,
class TrackingData>
1069 return nUnvisitedFaces_;
1073 template<
class Type,
class TrackingData>
1078 const labelList& owner = mesh_.faceOwner();
1079 const labelList& neighbour = mesh_.faceNeighbour();
1080 const label nInternalFaces = mesh_.nInternalFaces();
1082 for (
const label facei : changedFaces_)
1084 if (!changedFace_.test(facei))
1088 <<
" not marked as having been changed"
1092 const Type& newInfo = allFaceInfo_[facei];
1098 const label celli = owner[facei];
1099 Type& currInfo = allCellInfo_[celli];
1101 if (!currInfo.equal(newInfo, td_))
1115 if (facei < nInternalFaces)
1117 const label celli = neighbour[facei];
1118 Type& currInfo = allCellInfo_[celli];
1120 if (!currInfo.equal(newInfo, td_))
1134 changedFace_.unset(facei);
1138 changedFaces_.clear();
1142 Pout<<
" Changed cells : " << changedCells_.size() <<
endl;
1150 template<
class Type,
class TrackingData>
1157 for (
const label celli : changedCells_)
1159 if (!changedCell_.test(celli))
1162 <<
"Cell " << celli <<
" not marked as having been changed"
1166 const Type& newInfo = allCellInfo_[celli];
1171 for (
const label facei : faceLabels)
1173 Type& currInfo = allFaceInfo_[facei];
1175 if (!currInfo.equal(newInfo, td_))
1189 changedCell_.unset(celli);
1193 changedCells_.clear();
1197 handleExplicitConnections();
1199 if (hasCyclicPatches_)
1201 handleCyclicPatches();
1204 if (hasCyclicAMIPatches_)
1206 handleAMICyclicPatches();
1209 if (Pstream::parRun())
1211 handleProcPatches();
1216 Pout<<
" Changed faces : " << changedFaces_.size() <<
endl;
1226 template<
class Type,
class TrackingData>
1234 if (hasCyclicPatches_)
1236 handleCyclicPatches();
1239 if (hasCyclicAMIPatches_)
1241 handleAMICyclicPatches();
1244 if (Pstream::parRun())
1246 handleProcPatches();
1251 for (; iter < maxIter; ++iter)
1255 Info<<
" Iteration " << iter <<
endl;
1260 const label nFaces = nCells ? cellToFace() : 0;
1264 Info<<
" Total evaluations : "
1266 <<
" Changed cells / faces : "
1267 << nCells <<
" / " << nFaces <<
nl
1268 <<
" Pending cells / faces : "
1269 << nUnvisitedCells_ <<
" / " << nUnvisitedFaces_ <<
nl;
1272 if (!nCells || !nFaces)