40 template<
class T,
class CombineOp>
41 void Foam::syncTools::combine
49 auto iter = pointValues.find(index);
57 pointValues.insert(index, val);
62 template<
class T,
class CombineOp>
63 void Foam::syncTools::combine
65 EdgeMap<T>& edgeValues,
71 auto iter = edgeValues.find(index);
79 edgeValues.insert(index, val);
84 template<
class T,
class CombineOp,
class TransformOp>
90 const TransformOp& top
99 Map<T> sharedPointValues(0);
109 sharedPointValues.resize(sharedPtAddr.size());
114 const auto fnd = pointValues.cfind(sharedPtLabels[i]);
138 if (isA<processorPolyPatch>(pp) && pp.nPoints() > 0)
141 refCast<const processorPolyPatch>(pp);
150 Map<T> patchInfo(meshPts.size() / 20);
154 const auto iter = pointValues.cfind(meshPts[i]);
158 patchInfo.insert(nbrPts[i], *iter);
163 toNeighb << patchInfo;
173 if (isA<processorPolyPatch>(pp) && pp.nPoints() > 0)
176 refCast<const processorPolyPatch>(pp);
179 Map<T> nbrPatchInfo(fromNbr);
182 top(procPatch, nbrPatchInfo);
193 meshPts[nbrIter.key()],
204 if (isA<cyclicPolyPatch>(pp))
207 refCast<const cyclicPolyPatch>(pp);
209 if (cycPatch.
owner())
219 Map<T> half0Values(meshPtsA.size() / 20);
220 Map<T> half1Values(half0Values.size());
224 const edge&
e = coupledPoints[i];
226 const auto point0Fnd = pointValues.cfind(meshPtsA[
e[0]]);
228 if (point0Fnd.found())
230 half0Values.insert(i, *point0Fnd);
233 const auto point1Fnd = pointValues.cfind(meshPtsB[
e[1]]);
235 if (point1Fnd.found())
237 half1Values.insert(i, *point1Fnd);
242 top(cycPatch, half1Values);
243 top(nbrPatch, half0Values);
247 const edge&
e = coupledPoints[i];
249 const auto half0Fnd = half0Values.cfind(i);
251 if (half0Fnd.found())
262 const auto half1Fnd = half1Values.cfind(i);
264 if (half1Fnd.found())
302 Map<T> nbrValues(fromSlave);
326 toSlave << sharedPointValues;
338 toMaster << sharedPointValues;
347 fromMaster >> sharedPointValues;
357 Map<label> sharedToMeshPoint(2*sharedPtAddr.size());
360 sharedToMeshPoint.insert(sharedPtAddr[i], sharedPtLabels[i]);
366 const auto sharedFnd = sharedPointValues.cfind(iter.key());
368 if (sharedFnd.found())
370 pointValues.set(*iter, *sharedFnd);
377 template<
class T,
class CombineOp,
class TransformOp>
382 const CombineOp& cop,
383 const TransformOp& top
404 if (isA<processorPolyPatch>(pp) && pp.nEdges() > 0)
407 refCast<const processorPolyPatch>(pp);
418 for (
const edge&
e : edges)
420 const edge meshEdge(meshPts[
e[0]], meshPts[
e[1]]);
422 const auto iter = edgeValues.
cfind(meshEdge);
426 const edge nbrEdge(nbrPts[
e[0]], nbrPts[
e[1]]);
427 patchInfo.insert(nbrEdge, *iter);
432 toNeighb << patchInfo;
442 if (isA<processorPolyPatch>(pp) && pp.nEdges() > 0)
445 refCast<const processorPolyPatch>(pp);
450 fromNbr >> nbrPatchInfo;
454 top(procPatch, nbrPatchInfo);
462 const edge&
e = nbrIter.key();
463 const edge meshEdge(meshPts[
e[0]], meshPts[
e[1]]);
483 if (isA<cyclicPolyPatch>(pp))
486 refCast<const cyclicPolyPatch>(pp);
488 if (cycPatch.
owner())
500 Map<T> half0Values(edgesA.size() / 20);
501 Map<T> half1Values(half0Values.size());
505 const edge& twoEdges = coupledEdges[i];
508 const edge& e0 = edgesA[twoEdges[0]];
509 const edge meshEdge0(meshPtsA[e0[0]], meshPtsA[e0[1]]);
511 const auto iter = edgeValues.
cfind(meshEdge0);
515 half0Values.insert(i, *iter);
519 const edge& e1 = edgesB[twoEdges[1]];
520 const edge meshEdge1(meshPtsB[e1[0]], meshPtsB[e1[1]]);
522 const auto iter = edgeValues.
cfind(meshEdge1);
526 half1Values.insert(i, *iter);
532 top(cycPatch, half1Values);
533 top(nbrPatch, half0Values);
540 const edge& twoEdges = coupledEdges[i];
542 const auto half1Fnd = half1Values.cfind(i);
544 if (half1Fnd.found())
546 const edge& e0 = edgesA[twoEdges[0]];
547 const edge meshEdge0(meshPtsA[e0[0]], meshPtsA[e0[1]]);
558 const auto half0Fnd = half0Values.cfind(i);
560 if (half0Fnd.found())
562 const edge& e1 = edgesB[twoEdges[1]];
563 const edge meshEdge1(meshPtsB[e1[0]], meshPtsB[e1[1]]);
588 Map<label> meshToShared(2*sharedPtLabels.size());
591 meshToShared.insert(sharedPtLabels[i], sharedPtAddr[i]);
595 EdgeMap<T> sharedEdgeValues(meshToShared.size());
610 const label v0 =
f[fp];
611 const label v1 =
f[
f.fcIndex(fp)];
613 const auto v0Fnd = meshToShared.cfind(v0);
617 const auto v1Fnd = meshToShared.cfind(v1);
621 const edge meshEdge(v0, v1);
624 const edge sharedEdge(*v0Fnd, *v1Fnd);
627 potentialSharedEdge.insert(sharedEdge, meshEdge);
629 const auto edgeFnd = edgeValues.
cfind(meshEdge);
692 toSlave << sharedEdgeValues;
704 toMaster << sharedEdgeValues;
713 fromMaster >> sharedEdgeValues;
725 const edge& sharedEdge = iter.key();
726 const edge& meshEdge = iter.val();
729 const auto sharedFnd = sharedEdgeValues.cfind(sharedEdge);
731 if (sharedFnd.found())
745 template<
class T,
class CombineOp,
class TransformOp>
750 const CombineOp& cop,
752 const TransformOp& top
758 <<
"Number of values " << pointValues.size()
759 <<
" is not equal to the number of points in the mesh "
767 template<
class T,
class CombineOp,
class TransformOp>
773 const CombineOp& cop,
775 const TransformOp& top
778 if (pointValues.size() != meshPoints.
size())
781 <<
"Number of values " << pointValues.size()
782 <<
" is not equal to the number of meshPoints "
793 const auto iter = mpm.cfind(meshPoints[i]);
797 cppFld[*iter] = pointValues[i];
814 const auto iter = mpm.cfind(meshPoints[i]);
818 pointValues[i] = cppFld[*iter];
824 template<
class T,
class CombineOp,
class TransformOp>
829 const CombineOp& cop,
831 const TransformOp& top
837 <<
"Number of values " << edgeValues.size()
838 <<
" is not equal to the number of edges in the mesh "
863 edgeValues[meshEdges[i]] = cppFld[i];
868 template<
class T,
class CombineOp,
class TransformOp>
874 const CombineOp& cop,
876 const TransformOp& top
879 if (edgeValues.size() != meshEdges.size())
882 <<
"Number of values " << edgeValues.size()
883 <<
" is not equal to the number of meshEdges "
894 const auto iter = mpm.cfind(meshEdges[i]);
898 cppFld[*iter] = edgeValues[i];
915 const auto iter = mpm.cfind(meshEdges[i]);
919 edgeValues[i] = cppFld[*iter];
925 template<
class T,
class CombineOp,
class TransformOp>
930 const CombineOp& cop,
931 const TransformOp& top,
941 <<
"Number of values " << faceValues.
size()
942 <<
" is not equal to the number of boundary faces in the mesh "
957 if (isA<processorPolyPatch>(pp) && pp.size() > 0)
960 refCast<const processorPolyPatch>(pp);
962 const label patchStart = procPatch.
start()-boundaryOffset;
966 toNbr<< SubList<T>(faceValues, procPatch.size(), patchStart);
978 if (isA<processorPolyPatch>(pp) && pp.size() > 0)
981 refCast<const processorPolyPatch>(pp);
988 top(procPatch, nbrVals);
990 label bFacei = procPatch.
start()-boundaryOffset;
992 for (
T& nbrVal : nbrVals)
994 cop(faceValues[bFacei++], nbrVal);
1003 if (isA<cyclicPolyPatch>(pp))
1006 refCast<const cyclicPolyPatch>(pp);
1008 if (cycPatch.
owner())
1013 const label patchSize = cycPatch.size();
1014 const label ownStart = cycPatch.
start()-boundaryOffset;
1015 const label nbrStart = nbrPatch.
start()-boundaryOffset;
1019 top(nbrPatch, ownVals);
1022 top(cycPatch, nbrVals);
1024 label bFacei = ownStart;
1025 for (
T& nbrVal : nbrVals)
1027 cop(faceValues[bFacei++], nbrVal);
1031 for (
T& ownVal : ownVals)
1033 cop(faceValues[bFacei++], ownVal);
1043 template<
unsigned W
idth,
class CombineOp>
1047 const bool isBoundaryOnly,
1049 const CombineOp& cop,
1063 <<
"Number of values " << faceValues.
size()
1064 <<
" is not equal to the number of "
1065 << (isBoundaryOnly ?
"boundary" :
"mesh") <<
" faces "
1080 if (isA<processorPolyPatch>(pp) && pp.size())
1083 refCast<const processorPolyPatch>(pp);
1087 procPatch.
start()-boundaryOffset,
1093 toNbr<< PackedList<Width>(faceValues,
range);
1104 if (isA<processorPolyPatch>(pp) && pp.size())
1107 refCast<const processorPolyPatch>(pp);
1109 const label patchSize = procPatch.size();
1115 fromNbr >> recvInfo;
1119 label bFacei = procPatch.
start()-boundaryOffset;
1120 for (label i = 0; i < patchSize; ++i)
1122 unsigned int recvVal = recvInfo[i];
1123 unsigned int faceVal = faceValues[bFacei];
1125 cop(faceVal, recvVal);
1126 faceValues.
set(bFacei, faceVal);
1138 if (isA<cyclicPolyPatch>(pp))
1141 refCast<const cyclicPolyPatch>(pp);
1143 if (cycPatch.
owner())
1148 const label patchSize = cycPatch.size();
1150 label face0 = cycPatch.
start()-boundaryOffset;
1151 label face1 = nbrPatch.
start()-boundaryOffset;
1152 for (label i = 0; i < patchSize; ++i)
1154 unsigned int val0 = faceValues[face0];
1155 unsigned int val1 = faceValues[face1];
1157 unsigned int t = val0;
1159 faceValues[face0] = t;
1162 faceValues[face1] = val1;
1184 <<
"Number of cell values " << cellData.
size()
1185 <<
" is not equal to the number of cells in the mesh "
1201 neighbourCellData[bFacei] = cellData[celli];
1209 template<
unsigned W
idth,
class CombineOp>
1214 const CombineOp& cop,
1218 syncFaceList(
mesh,
false, faceValues, cop, parRun);
1222 template<
unsigned W
idth,
class CombineOp>
1227 const CombineOp& cop,
1231 syncFaceList(
mesh,
true, faceValues, cop, parRun);
1235 template<
unsigned W
idth>
1246 template<
unsigned W
idth>
1257 template<
unsigned W
idth,
class CombineOp>
1262 const CombineOp& cop,
1263 const unsigned int nullValue
1269 <<
"Number of values " << pointValues.
size()
1270 <<
" is not equal to the number of points in the mesh "
1280 cppFld[i] = pointValues[meshPoints[i]];
1295 pointValues[meshPoints[i]] = cppFld[i];
1300 template<
unsigned W
idth,
class CombineOp>
1305 const CombineOp& cop,
1306 const unsigned int nullValue
1312 <<
"Number of values " << edgeValues.
size()
1313 <<
" is not equal to the number of edges in the mesh "
1323 cppFld[i] = edgeValues[meshEdges[i]];
1338 edgeValues[meshEdges[i]] = cppFld[i];