38 template<
class T,
class CombineOp>
39 void Foam::syncTools::combine
47 auto iter = pointValues.find(index);
55 pointValues.insert(index, val);
60 template<
class T,
class CombineOp>
61 void Foam::syncTools::combine
63 EdgeMap<T>& edgeValues,
69 auto iter = edgeValues.find(index);
77 edgeValues.insert(index, val);
82 template<
class T,
class CombineOp,
class TransformOp>
88 const TransformOp& top
97 Map<T> sharedPointValues(0);
107 sharedPointValues.resize(sharedPtAddr.size());
112 const auto fnd = pointValues.cfind(sharedPtLabels[i]);
136 if (isA<processorPolyPatch>(pp) && pp.nPoints() > 0)
139 refCast<const processorPolyPatch>(pp);
148 Map<T> patchInfo(meshPts.size() / 20);
152 const auto iter = pointValues.cfind(meshPts[i]);
156 patchInfo.insert(nbrPts[i], *iter);
161 toNeighb << patchInfo;
171 if (isA<processorPolyPatch>(pp) && pp.nPoints() > 0)
174 refCast<const processorPolyPatch>(pp);
177 Map<T> nbrPatchInfo(fromNbr);
180 top(procPatch, nbrPatchInfo);
191 meshPts[nbrIter.key()],
202 if (isA<cyclicPolyPatch>(pp))
205 refCast<const cyclicPolyPatch>(pp);
207 if (cycPatch.
owner())
217 Map<T> half0Values(meshPtsA.size() / 20);
218 Map<T> half1Values(half0Values.size());
222 const edge&
e = coupledPoints[i];
224 const auto point0Fnd = pointValues.cfind(meshPtsA[
e[0]]);
226 if (point0Fnd.found())
228 half0Values.insert(i, *point0Fnd);
231 const auto point1Fnd = pointValues.cfind(meshPtsB[
e[1]]);
233 if (point1Fnd.found())
235 half1Values.insert(i, *point1Fnd);
240 top(cycPatch, half1Values);
241 top(nbrPatch, half0Values);
245 const edge&
e = coupledPoints[i];
247 const auto half0Fnd = half0Values.cfind(i);
249 if (half0Fnd.found())
260 const auto half1Fnd = half1Values.cfind(i);
262 if (half1Fnd.found())
295 Map<T> nbrValues(fromSlave);
314 toSlave << sharedPointValues;
326 toMaster << sharedPointValues;
335 fromMaster >> sharedPointValues;
345 Map<label> sharedToMeshPoint(2*sharedPtAddr.size());
348 sharedToMeshPoint.insert(sharedPtAddr[i], sharedPtLabels[i]);
354 const auto sharedFnd = sharedPointValues.cfind(iter.key());
356 if (sharedFnd.found())
358 pointValues.set(*iter, *sharedFnd);
365 template<
class T,
class CombineOp,
class TransformOp>
370 const CombineOp& cop,
371 const TransformOp& top
392 if (isA<processorPolyPatch>(pp) && pp.nEdges() > 0)
395 refCast<const processorPolyPatch>(pp);
406 for (
const edge&
e : edges)
408 const edge meshEdge(meshPts[
e[0]], meshPts[
e[1]]);
410 const auto iter = edgeValues.
cfind(meshEdge);
414 const edge nbrEdge(nbrPts[
e[0]], nbrPts[
e[1]]);
415 patchInfo.insert(nbrEdge, *iter);
420 toNeighb << patchInfo;
430 if (isA<processorPolyPatch>(pp) && pp.nEdges() > 0)
433 refCast<const processorPolyPatch>(pp);
438 fromNbr >> nbrPatchInfo;
442 top(procPatch, nbrPatchInfo);
450 const edge&
e = nbrIter.key();
451 const edge meshEdge(meshPts[
e[0]], meshPts[
e[1]]);
471 if (isA<cyclicPolyPatch>(pp))
474 refCast<const cyclicPolyPatch>(pp);
476 if (cycPatch.
owner())
488 Map<T> half0Values(edgesA.size() / 20);
489 Map<T> half1Values(half0Values.size());
493 const edge& twoEdges = coupledEdges[i];
496 const edge& e0 = edgesA[twoEdges[0]];
497 const edge meshEdge0(meshPtsA[e0[0]], meshPtsA[e0[1]]);
499 const auto iter = edgeValues.
cfind(meshEdge0);
503 half0Values.insert(i, *iter);
507 const edge& e1 = edgesB[twoEdges[1]];
508 const edge meshEdge1(meshPtsB[e1[0]], meshPtsB[e1[1]]);
510 const auto iter = edgeValues.
cfind(meshEdge1);
514 half1Values.insert(i, *iter);
520 top(cycPatch, half1Values);
521 top(nbrPatch, half0Values);
528 const edge& twoEdges = coupledEdges[i];
530 const auto half1Fnd = half1Values.cfind(i);
532 if (half1Fnd.found())
534 const edge& e0 = edgesA[twoEdges[0]];
535 const edge meshEdge0(meshPtsA[e0[0]], meshPtsA[e0[1]]);
546 const auto half0Fnd = half0Values.cfind(i);
548 if (half0Fnd.found())
550 const edge& e1 = edgesB[twoEdges[1]];
551 const edge meshEdge1(meshPtsB[e1[0]], meshPtsB[e1[1]]);
576 Map<label> meshToShared(2*sharedPtLabels.size());
579 meshToShared.insert(sharedPtLabels[i], sharedPtAddr[i]);
583 EdgeMap<T> sharedEdgeValues(meshToShared.size());
598 const label v0 =
f[fp];
599 const label v1 =
f[
f.fcIndex(fp)];
601 const auto v0Fnd = meshToShared.cfind(v0);
605 const auto v1Fnd = meshToShared.cfind(v1);
609 const edge meshEdge(v0, v1);
612 const edge sharedEdge(*v0Fnd, *v1Fnd);
615 potentialSharedEdge.insert(sharedEdge, meshEdge);
617 const auto edgeFnd = edgeValues.
cfind(meshEdge);
669 toSlave << sharedEdgeValues;
681 toMaster << sharedEdgeValues;
690 fromMaster >> sharedEdgeValues;
702 const edge& sharedEdge = iter.key();
703 const edge& meshEdge = iter.val();
706 const auto sharedFnd = sharedEdgeValues.cfind(sharedEdge);
708 if (sharedFnd.found())
722 template<
class T,
class CombineOp,
class TransformOp>
727 const CombineOp& cop,
729 const TransformOp& top
735 <<
"Number of values " << pointValues.size()
736 <<
" is not equal to the number of points in the mesh "
744 template<
class T,
class CombineOp,
class TransformOp>
750 const CombineOp& cop,
752 const TransformOp& top
755 if (pointValues.size() != meshPoints.
size())
758 <<
"Number of values " << pointValues.size()
759 <<
" is not equal to the number of meshPoints "
770 const auto iter = mpm.cfind(meshPoints[i]);
774 cppFld[*iter] = pointValues[i];
791 const auto iter = mpm.cfind(meshPoints[i]);
795 pointValues[i] = cppFld[*iter];
801 template<
class T,
class CombineOp,
class TransformOp>
806 const CombineOp& cop,
808 const TransformOp& top
814 <<
"Number of values " << edgeValues.size()
815 <<
" is not equal to the number of edges in the mesh "
840 edgeValues[meshEdges[i]] = cppFld[i];
845 template<
class T,
class CombineOp,
class TransformOp>
851 const CombineOp& cop,
853 const TransformOp& top
856 if (edgeValues.size() != meshEdges.size())
859 <<
"Number of values " << edgeValues.size()
860 <<
" is not equal to the number of meshEdges "
871 const auto iter = mpm.cfind(meshEdges[i]);
875 cppFld[*iter] = edgeValues[i];
892 const auto iter = mpm.cfind(meshEdges[i]);
896 edgeValues[i] = cppFld[*iter];
902 template<
class T,
class CombineOp,
class TransformOp>
907 const CombineOp& cop,
908 const TransformOp& top,
918 <<
"Number of values " << faceValues.
size()
919 <<
" is not equal to the number of boundary faces in the mesh "
934 if (isA<processorPolyPatch>(pp) && pp.size() > 0)
937 refCast<const processorPolyPatch>(pp);
939 const label patchStart = procPatch.
start()-boundaryOffset;
943 toNbr<< SubList<T>(faceValues, procPatch.size(), patchStart);
955 if (isA<processorPolyPatch>(pp) && pp.size() > 0)
958 refCast<const processorPolyPatch>(pp);
965 top(procPatch, nbrVals);
967 label bFacei = procPatch.
start()-boundaryOffset;
969 for (
T& nbrVal : nbrVals)
971 cop(faceValues[bFacei++], nbrVal);
980 if (isA<cyclicPolyPatch>(pp))
983 refCast<const cyclicPolyPatch>(pp);
985 if (cycPatch.
owner())
990 const label patchSize = cycPatch.size();
991 const label ownStart = cycPatch.
start()-boundaryOffset;
992 const label nbrStart = nbrPatch.
start()-boundaryOffset;
996 top(nbrPatch, ownVals);
999 top(cycPatch, nbrVals);
1001 label bFacei = ownStart;
1002 for (
T& nbrVal : nbrVals)
1004 cop(faceValues[bFacei++], nbrVal);
1008 for (
T& ownVal : ownVals)
1010 cop(faceValues[bFacei++], ownVal);
1020 template<
unsigned W
idth,
class CombineOp>
1024 const bool isBoundaryOnly,
1026 const CombineOp& cop,
1040 <<
"Number of values " << faceValues.
size()
1041 <<
" is not equal to the number of "
1042 << (isBoundaryOnly ?
"boundary" :
"mesh") <<
" faces "
1057 if (isA<processorPolyPatch>(pp) && pp.size())
1060 refCast<const processorPolyPatch>(pp);
1064 procPatch.
start()-boundaryOffset,
1070 toNbr<< PackedList<Width>(faceValues,
range);
1081 if (isA<processorPolyPatch>(pp) && pp.size())
1084 refCast<const processorPolyPatch>(pp);
1086 const label patchSize = procPatch.size();
1092 fromNbr >> recvInfo;
1096 label bFacei = procPatch.
start()-boundaryOffset;
1097 for (label i = 0; i < patchSize; ++i)
1099 unsigned int recvVal = recvInfo[i];
1100 unsigned int faceVal = faceValues[bFacei];
1102 cop(faceVal, recvVal);
1103 faceValues.
set(bFacei, faceVal);
1115 if (isA<cyclicPolyPatch>(pp))
1118 refCast<const cyclicPolyPatch>(pp);
1120 if (cycPatch.
owner())
1125 const label patchSize = cycPatch.size();
1127 label face0 = cycPatch.
start()-boundaryOffset;
1128 label face1 = nbrPatch.
start()-boundaryOffset;
1129 for (label i = 0; i < patchSize; ++i)
1131 unsigned int val0 = faceValues[face0];
1132 unsigned int val1 = faceValues[face1];
1134 unsigned int t = val0;
1136 faceValues[face0] = t;
1139 faceValues[face1] = val1;
1161 <<
"Number of cell values " << cellData.
size()
1162 <<
" is not equal to the number of cells in the mesh "
1178 neighbourCellData[bFacei] = cellData[celli];
1186 template<
unsigned W
idth,
class CombineOp>
1191 const CombineOp& cop,
1195 syncFaceList(
mesh,
false, faceValues, cop, parRun);
1199 template<
unsigned W
idth,
class CombineOp>
1204 const CombineOp& cop,
1208 syncFaceList(
mesh,
true, faceValues, cop, parRun);
1212 template<
unsigned W
idth>
1223 template<
unsigned W
idth>
1234 template<
unsigned W
idth,
class CombineOp>
1239 const CombineOp& cop,
1240 const unsigned int nullValue
1246 <<
"Number of values " << pointValues.
size()
1247 <<
" is not equal to the number of points in the mesh "
1257 cppFld[i] = pointValues[meshPoints[i]];
1272 pointValues[meshPoints[i]] = cppFld[i];
1277 template<
unsigned W
idth,
class CombineOp>
1282 const CombineOp& cop,
1283 const unsigned int nullValue
1289 <<
"Number of values " << edgeValues.
size()
1290 <<
" is not equal to the number of edges in the mesh "
1300 cppFld[i] = edgeValues[meshEdges[i]];
1315 edgeValues[meshEdges[i]] = cppFld[i];