37 void Foam::syncTools::separateList
46 void Foam::syncTools::separateList
55 void Foam::syncTools::separateList
64 template <
class T,
class CombineOp>
73 typename Map<T>::iterator iter = pointValues.find(index);
75 if (iter != pointValues.end())
81 pointValues.insert(index, val);
87 template <
class T,
class CombineOp>
90 EdgeMap<T>& edgeValues,
96 typename EdgeMap<T>::iterator iter = edgeValues.find(index);
98 if (iter != edgeValues.end())
104 edgeValues.insert(index, val);
109 template <
class T,
class CombineOp>
114 const CombineOp& cop,
115 const bool applySeparation
120 if (!hasCouples(patches))
126 bool hasTransformation =
false;
136 isA<processorPolyPatch>(patches[patchI])
137 && patches[patchI].
nPoints() > 0
141 refCast<const processorPolyPatch>(patches[patchI]);
150 Map<T> patchInfo(meshPts.size() / 20);
155 pointValues.
find(meshPts[i]);
157 if (iter != pointValues.
end())
161 patchInfo.insert(nbrPts[i], iter());
167 toNeighb << patchInfo;
178 isA<processorPolyPatch>(patches[patchI])
179 && patches[patchI].
nPoints() > 0
183 refCast<const processorPolyPatch>(patches[patchI]);
184 checkTransform(procPatch, applySeparation);
187 Map<T> nbrPatchInfo(fromNb);
191 hasTransformation =
true;
194 else if (applySeparation && procPatch.
separated())
196 hasTransformation =
true;
197 separateList(-procPatch.
separation(), nbrPatchInfo);
215 meshPts[nbrIter.key()],
226 if (isA<cyclicPolyPatch>(patches[patchI]))
229 refCast<const cyclicPolyPatch>(patches[patchI]);
230 checkTransform(cycPatch, applySeparation);
241 const edge&
e = coupledPoints[i];
244 pointValues.
find(meshPts[e[0]]);
246 if (point0Fnd != pointValues.
end())
248 half0Values.insert(i, point0Fnd());
252 pointValues.
find(meshPts[e[1]]);
254 if (point1Fnd != pointValues.
end())
256 half1Values.insert(i, point1Fnd());
262 hasTransformation =
true;
266 else if (applySeparation && cycPatch.
separated())
268 hasTransformation =
true;
270 const vectorField& v = cycPatch.coupledPolyPatch::separation();
271 separateList(v, half0Values);
272 separateList(-v, half1Values);
277 const edge&
e = coupledPoints[i];
281 if (half1Fnd != half1Values.end())
294 if (half0Fnd != half0Values.end())
317 if (hasTransformation)
321 "syncTools<class T, class CombineOp>::syncPointMap"
322 "(const polyMesh&, Map<T>&, const CombineOp&"
324 ) <<
"There are decomposed cyclics in this mesh with"
325 <<
" transformations." <<
endl
326 <<
"This is not supported. The result will be incorrect"
335 Map<T> sharedPointValues(sharedPtAddr.
size());
341 label meshPointI = sharedPtLabels[i];
344 pointValues.
find(meshPointI);
346 if (fnd != pointValues.
end())
373 Map<T> nbrValues(fromSlave);
397 toSlave << sharedPointValues;
409 toMaster << sharedPointValues;
418 fromMaster >> sharedPointValues;
431 sharedToMeshPoint.insert(sharedPtAddr[i], sharedPtLabels[i]);
438 sharedPointValues.find(iter.key());
440 if (sharedFnd != sharedPointValues.end())
455 template <
class T,
class CombineOp>
460 const CombineOp& cop,
461 const bool applySeparation
466 if (!hasCouples(patches))
487 isA<processorPolyPatch>(patches[patchI])
488 && patches[patchI].nEdges() > 0
492 refCast<const processorPolyPatch>(patches[patchI]);
504 const edge&
e = edges[i];
505 const edge meshEdge(meshPts[e[0]], meshPts[e[1]]);
508 edgeValues.
find(meshEdge);
510 if (iter != edgeValues.
end())
512 const edge nbrEdge(nbrPts[e[0]], nbrPts[e[1]]);
514 if (nbrEdge[0] >= 0 && nbrEdge[1] >= 0)
516 patchInfo.insert(nbrEdge, iter());
522 toNeighb << patchInfo;
533 isA<processorPolyPatch>(patches[patchI])
534 && patches[patchI].nEdges() > 0
538 refCast<const processorPolyPatch>(patches[patchI]);
539 checkTransform(procPatch, applySeparation);
550 else if (applySeparation && procPatch.
separated())
552 separateList(-procPatch.
separation(), nbrPatchInfo);
564 const edge&
e = nbrIter.key();
565 const edge meshEdge(meshPts[e[0]], meshPts[e[1]]);
585 if (isA<cyclicPolyPatch>(patches[patchI]))
588 refCast<const cyclicPolyPatch>(patches[patchI]);
589 checkTransform(cycPatch, applySeparation);
601 const edge& twoEdges = coupledEdges[i];
604 const edge& e0 = edges[twoEdges[0]];
605 const edge meshEdge0(meshPts[e0[0]], meshPts[e0[1]]);
608 edgeValues.
find(meshEdge0);
610 if (iter != edgeValues.
end())
612 half0Values.insert(i, iter());
616 const edge& e1 = edges[twoEdges[1]];
617 const edge meshEdge1(meshPts[e1[0]], meshPts[e1[1]]);
620 edgeValues.
find(meshEdge1);
622 if (iter != edgeValues.
end())
624 half1Values.insert(i, iter());
637 else if (applySeparation && cycPatch.
separated())
639 const vectorField& v = cycPatch.coupledPolyPatch::separation();
640 separateList(v, half0Values);
641 separateList(-v, half1Values);
649 const edge& twoEdges = coupledEdges[i];
654 if (half1Fnd != half1Values.end())
656 const edge& e0 = edges[twoEdges[0]];
657 const edge meshEdge0(meshPts[e0[0]], meshPts[e0[1]]);
670 if (half0Fnd != half0Values.end())
672 const edge& e1 = edges[twoEdges[1]];
673 const edge meshEdge1(meshPts[e1[0]], meshPts[e1[1]]);
700 meshToShared.insert(sharedPtLabels[i], sharedPtAddr[i]);
704 EdgeMap<T> sharedEdgeValues(meshToShared.size());
724 if (v0Fnd != meshToShared.
end())
728 if (v1Fnd != meshToShared.
end())
730 const edge meshEdge(v0, v1);
733 const edge sharedEdge(v0Fnd(), v1Fnd());
736 potentialSharedEdge.insert(sharedEdge, meshEdge);
739 edgeValues.
find(meshEdge);
741 if (edgeFnd != edgeValues.
end())
802 toSlave << sharedEdgeValues;
810 toMaster << sharedEdgeValues;
815 fromMaster >> sharedEdgeValues;
827 const edge& sharedEdge = iter.key();
828 const edge& meshEdge = iter();
832 sharedEdgeValues.
find(sharedEdge);
834 if (sharedFnd != sharedEdgeValues.
end())
848 template <
class T,
class CombineOp>
853 const CombineOp& cop,
855 const bool applySeparation
862 "syncTools<class T, class CombineOp>::syncPointList"
863 "(const polyMesh&, UList<T>&, const CombineOp&, const T&"
865 ) <<
"Number of values " << pointValues.
size()
866 <<
" is not equal to the number of points in the mesh "
872 if (!hasCouples(patches))
878 bool hasTransformation =
false;
888 isA<processorPolyPatch>(patches[patchI])
889 && patches[patchI].
nPoints() > 0
893 refCast<const processorPolyPatch>(patches[patchI]);
903 label nbrPointI = nbrPts[pointI];
904 if (nbrPointI >= 0 && nbrPointI < patchInfo.size())
906 patchInfo[nbrPointI] = pointValues[meshPts[pointI]];
922 isA<processorPolyPatch>(patches[patchI])
923 && patches[patchI].
nPoints() > 0
927 refCast<const processorPolyPatch>(patches[patchI]);
928 checkTransform(procPatch, applySeparation);
939 fromNbr >> nbrPatchInfo;
942 nbrPatchInfo.setSize(procPatch.
nPoints(), nullValue);
946 hasTransformation =
true;
949 else if (applySeparation && procPatch.
separated())
951 hasTransformation =
true;
952 separateList(-procPatch.
separation(), nbrPatchInfo);
959 label meshPointI = meshPts[pointI];
960 cop(pointValues[meshPointI], nbrPatchInfo[pointI]);
969 if (isA<cyclicPolyPatch>(patches[patchI]))
972 refCast<const cyclicPolyPatch>(patches[patchI]);
974 checkTransform(cycPatch, applySeparation);
984 const edge&
e = coupledPoints[i];
986 label point0 = meshPts[e[0]];
987 label point1 = meshPts[e[1]];
989 half0Values[i] = pointValues[point0];
990 half1Values[i] = pointValues[point1];
995 hasTransformation =
true;
999 else if (applySeparation && cycPatch.
separated())
1001 hasTransformation =
true;
1002 const vectorField& v = cycPatch.coupledPolyPatch::separation();
1003 separateList(v, half0Values);
1004 separateList(-v, half1Values);
1009 const edge&
e = coupledPoints[i];
1011 label point0 = meshPts[e[0]];
1012 label point1 = meshPts[e[1]];
1014 cop(pointValues[point0], half1Values[i]);
1015 cop(pointValues[point1], half0Values[i]);
1029 if (hasTransformation)
1033 "syncTools<class T, class CombineOp>::syncPointList"
1034 "(const polyMesh&, UList<T>&, const CombineOp&, const T&"
1036 ) <<
"There are decomposed cyclics in this mesh with"
1037 <<
" transformations." <<
endl
1038 <<
"This is not supported. The result will be incorrect"
1068 template <
class T,
class CombineOp>
1074 const CombineOp& cop,
1076 const bool applySeparation
1079 if (pointValues.
size() != meshPoints.
size())
1083 "syncTools<class T, class CombineOp>::syncPointList"
1084 "(const polyMesh&, const labelList&, UList<T>&, const CombineOp&"
1085 ", const T&, const bool)"
1086 ) <<
"Number of values " << pointValues.
size()
1087 <<
" is not equal to the number of points "
1100 meshValues[meshPoints[i]] = pointValues[i];
1114 pointValues[i] = meshValues[meshPoints[i]];
1119 template <
class T,
class CombineOp>
1124 const CombineOp& cop,
1126 const bool applySeparation
1133 "syncTools<class T, class CombineOp>::syncEdgeList"
1134 "(const polyMesh&, UList<T>&, const CombineOp&, const T&"
1136 ) <<
"Number of values " << edgeValues.
size()
1137 <<
" is not equal to the number of edges in the mesh "
1143 if (!hasCouples(patches))
1149 bool hasTransformation =
false;
1159 isA<processorPolyPatch>(patches[patchI])
1160 && patches[patchI].nEdges() > 0
1164 refCast<const processorPolyPatch>(patches[patchI]);
1172 forAll(neighbEdges, edgeI)
1174 label nbrEdgeI = neighbEdges[edgeI];
1176 if (nbrEdgeI >= 0 && nbrEdgeI < patchInfo.size())
1178 patchInfo[nbrEdgeI] = edgeValues[meshEdges[edgeI]];
1193 isA<processorPolyPatch>(patches[patchI])
1194 && patches[patchI].nEdges() > 0
1198 refCast<const processorPolyPatch>(patches[patchI]);
1200 checkTransform(procPatch, applySeparation);
1214 fromNeighb >> nbrPatchInfo;
1217 nbrPatchInfo.setSize(procPatch.
nEdges(), nullValue);
1221 hasTransformation =
true;
1224 else if (applySeparation && procPatch.
separated())
1226 hasTransformation =
true;
1227 separateList(-procPatch.
separation(), nbrPatchInfo);
1232 label meshEdgeI = meshEdges[edgeI];
1234 cop(edgeValues[meshEdgeI], nbrPatchInfo[edgeI]);
1243 if (isA<cyclicPolyPatch>(patches[patchI]))
1246 refCast<const cyclicPolyPatch>(patches[patchI]);
1248 checkTransform(cycPatch, applySeparation);
1258 const edge&
e = coupledEdges[i];
1260 label meshEdge0 = meshEdges[e[0]];
1261 label meshEdge1 = meshEdges[e[1]];
1263 half0Values[i] = edgeValues[meshEdge0];
1264 half1Values[i] = edgeValues[meshEdge1];
1269 hasTransformation =
true;
1273 else if (applySeparation && cycPatch.
separated())
1275 hasTransformation =
true;
1277 const vectorField& v = cycPatch.coupledPolyPatch::separation();
1278 separateList(v, half0Values);
1279 separateList(-v, half1Values);
1284 const edge&
e = coupledEdges[i];
1286 label meshEdge0 = meshEdges[e[0]];
1287 label meshEdge1 = meshEdges[e[1]];
1289 cop(edgeValues[meshEdge0], half1Values[i]);
1290 cop(edgeValues[meshEdge1], half0Values[i]);
1304 if (hasTransformation)
1308 "syncTools<class T, class CombineOp>::syncEdgeList"
1309 "(const polyMesh&, UList<T>&, const CombineOp&, const T&"
1311 ) <<
"There are decomposed cyclics in this mesh with"
1312 <<
" transformations." <<
endl
1313 <<
"This is not supported. The result will be incorrect"
1343 template <
class T,
class CombineOp>
1348 const CombineOp& cop,
1349 const bool applySeparation
1354 if (faceValues.
size() != nBFaces)
1358 "syncTools<class T, class CombineOp>::syncBoundaryFaceList"
1359 "(const polyMesh&, UList<T>&, const CombineOp&"
1361 ) <<
"Number of values " << faceValues.
size()
1362 <<
" is not equal to the number of boundary faces in the mesh "
1368 if (!hasCouples(patches))
1382 isA<processorPolyPatch>(patches[patchI])
1383 && patches[patchI].size() > 0
1387 refCast<const processorPolyPatch>(patches[patchI]);
1391 if (contiguous<T>())
1397 reinterpret_cast<const char*
>(&faceValues[patchStart]),
1398 procPatch.size()*
sizeof(
T)
1405 SubList<T>(faceValues, procPatch.size(), patchStart);
1417 isA<processorPolyPatch>(patches[patchI])
1418 && patches[patchI].size() > 0
1422 refCast<const processorPolyPatch>(patches[patchI]);
1424 List<T> nbrPatchInfo(procPatch.size());
1426 if (contiguous<T>())
1432 reinterpret_cast<char*
>(nbrPatchInfo.begin()),
1433 nbrPatchInfo.byteSize()
1443 fromNeighb >> nbrPatchInfo;
1450 else if (applySeparation && procPatch.
separated())
1452 separateList(-procPatch.
separation(), nbrPatchInfo);
1460 cop(faceValues[bFaceI++], nbrPatchInfo[i]);
1469 if (isA<cyclicPolyPatch>(patches[patchI]))
1472 refCast<const cyclicPolyPatch>(patches[patchI]);
1476 label half = cycPatch.size()/2;
1477 label half1Start = patchStart+half;
1487 else if (applySeparation && cycPatch.
separated())
1489 const vectorField& v = cycPatch.coupledPolyPatch::separation();
1490 separateList(v, half0Values);
1491 separateList(-v, half1Values);
1494 label i0 = patchStart;
1497 cop(faceValues[i0++], half1Values[i]);
1500 label i1 = half1Start;
1503 cop(faceValues[i1++], half0Values[i]);
1510 template <
class T,
class CombineOp>
1515 const CombineOp& cop,
1516 const bool applySeparation
1523 "syncTools<class T, class CombineOp>::syncFaceList"
1524 "(const polyMesh&, UList<T>&, const CombineOp&"
1526 ) <<
"Number of values " << faceValues.
size()
1527 <<
" is not equal to the number of faces in the mesh "
1538 syncBoundaryFaceList
1553 const bool applySeparation
1556 syncBoundaryFaceList(mesh, faceValues,
eqOp<T>(), applySeparation);
1565 const bool applySeparation
1568 syncFaceList(mesh, faceValues,
eqOp<T>(), applySeparation);
1572 template <
unsigned nBits,
class CombineOp>
1577 const CombineOp& cop
1584 "syncTools<unsigned nBits, class CombineOp>::syncFaceList"
1585 "(const polyMesh&, PackedList<nBits>&, const CombineOp&)"
1586 ) <<
"Number of values " << faceValues.
size()
1587 <<
" is not equal to the number of faces in the mesh "
1593 if (!hasCouples(patches))
1609 isA<processorPolyPatch>(patches[patchI])
1610 && patches[patchI].size() > 0
1614 refCast<const processorPolyPatch>(patches[patchI]);
1616 patchValues[patchI].setSize(procPatch.size());
1619 patchValues[patchI][i] =
1620 faceValues.
get(procPatch.
start()+i);
1624 toNbr << patchValues[patchI];
1635 isA<processorPolyPatch>(patches[patchI])
1636 && patches[patchI].size() > 0
1640 refCast<const processorPolyPatch>(patches[patchI]);
1648 fromNbr >> patchValues[patchI];
1654 unsigned int patchVal = patchValues[patchI][i];
1655 label meshFaceI = procPatch.
start()+i;
1656 unsigned int faceVal = faceValues.
get(meshFaceI);
1657 cop(faceVal, patchVal);
1658 faceValues.
set(meshFaceI, faceVal);
1667 if (isA<cyclicPolyPatch>(patches[patchI]))
1670 refCast<const cyclicPolyPatch>(patches[patchI]);
1672 label half = cycPatch.size()/2;
1674 for (label i = 0; i < half; i++)
1676 label meshFace0 = cycPatch.
start()+i;
1677 unsigned int val0 = faceValues.
get(meshFace0);
1678 label meshFace1 = meshFace0 + half;
1679 unsigned int val1 = faceValues.
get(meshFace1);
1681 unsigned int t = val0;
1683 faceValues.
set(meshFace0, t);
1686 faceValues.
set(meshFace1, val1);
1693 template <
unsigned nBits>
1704 template <
unsigned nBits,
class CombineOp>
1709 const CombineOp& cop,
1710 const unsigned int nullValue
1717 "syncTools<unsigned nBits, class CombineOp>::syncPointList"
1718 "(const polyMesh&, PackedList<nBits>&, const CombineOp&"
1719 ", const unsigned int&)"
1720 ) <<
"Number of values " << pointValues.
size()
1721 <<
" is not equal to the number of points in the mesh "
1727 if (!hasCouples(patches))
1743 isA<processorPolyPatch>(patches[patchI])
1744 && patches[patchI].
nPoints() > 0
1748 refCast<const processorPolyPatch>(patches[patchI]);
1750 patchValues[patchI].setSize(procPatch.
nPoints());
1751 patchValues[patchI] = nullValue;
1758 label nbrPointI = nbrPts[pointI];
1759 if (nbrPointI >= 0 && nbrPointI < procPatch.
nPoints())
1761 patchValues[patchI][nbrPointI] =
1762 pointValues.
get(meshPts[pointI]);
1767 toNbr << patchValues[patchI];
1778 isA<processorPolyPatch>(patches[patchI])
1779 && patches[patchI].
nPoints() > 0
1783 refCast<const processorPolyPatch>(patches[patchI]);
1793 fromNbr >> patchValues[patchI];
1797 patchValues[patchI].setSize(procPatch.
nPoints(), nullValue);
1803 label meshPointI = meshPts[pointI];
1804 unsigned int pointVal = pointValues.
get(meshPointI);
1805 cop(pointVal, patchValues[patchI][pointI]);
1806 pointValues.
set(meshPointI, pointVal);
1815 if (isA<cyclicPolyPatch>(patches[patchI]))
1818 refCast<const cyclicPolyPatch>(patches[patchI]);
1825 const edge&
e = coupledPoints[i];
1827 label point0 = meshPts[e[0]];
1828 label point1 = meshPts[e[1]];
1830 unsigned int val0 = pointValues.
get(point0);
1831 unsigned int t = val0;
1832 unsigned int val1 = pointValues.
get(point1);
1835 pointValues.
set(point0, t);
1837 pointValues.
set(point1, val1);
1872 template <
unsigned nBits,
class CombineOp>
1877 const CombineOp& cop,
1878 const unsigned int nullValue
1885 "syncTools<unsigned nBits, class CombineOp>::syncEdgeList"
1886 "(const polyMesh&, PackedList<nBits>&, const CombineOp&"
1887 ", const unsigned int&)"
1888 ) <<
"Number of values " << edgeValues.
size()
1889 <<
" is not equal to the number of edges in the mesh "
1895 if (!hasCouples(patches))
1911 isA<processorPolyPatch>(patches[patchI])
1912 && patches[patchI].nEdges() > 0
1916 refCast<const processorPolyPatch>(patches[patchI]);
1918 patchValues[patchI].setSize(procPatch.
nEdges(), nullValue);
1923 forAll(neighbEdges, edgeI)
1925 label nbrEdgeI = neighbEdges[edgeI];
1926 if (nbrEdgeI >= 0 && nbrEdgeI < procPatch.
nEdges())
1928 patchValues[patchI][nbrEdgeI] =
1929 edgeValues.
get(meshEdges[edgeI]);
1934 toNbr << patchValues[patchI];
1945 isA<processorPolyPatch>(patches[patchI])
1946 && patches[patchI].nEdges() > 0
1950 refCast<const processorPolyPatch>(patches[patchI]);
1958 fromNeighb >> patchValues[patchI];
1961 patchValues[patchI].setSize(procPatch.
nEdges(), nullValue);
1967 unsigned int patchVal = patchValues[patchI][edgeI];
1968 label meshEdgeI = meshEdges[edgeI];
1969 unsigned int edgeVal = edgeValues.
get(meshEdgeI);
1970 cop(edgeVal, patchVal);
1971 edgeValues.
set(meshEdgeI, edgeVal);
1980 if (isA<cyclicPolyPatch>(patches[patchI]))
1983 refCast<const cyclicPolyPatch>(patches[patchI]);
1990 const edge&
e = coupledEdges[i];
1992 label edge0 = meshEdges[e[0]];
1993 label edge1 = meshEdges[e[1]];
1995 unsigned int val0 = edgeValues.
get(edge0);
1996 unsigned int t = val0;
1997 unsigned int val1 = edgeValues.
get(edge1);
2000 edgeValues.
set(edge0, t);
2002 edgeValues.
set(edge1, val1);