69 referPatchID_(referPatchID)
74 if (nbrProc_[a] < nbrProc_[
b])
78 else if (nbrProc_[a] > nbrProc_[
b])
85 return referPatchID_[a] < referPatchID_[
b];
94void Foam::fvMeshDistribute::inplaceRenumberWithFlip
96 const labelUList& oldToNew,
97 const bool oldToNewHasFlip,
98 const bool lstHasFlip,
102 if (!lstHasFlip && !oldToNewHasFlip)
113 label val = lst[elemI];
129 <<
"Problem : zero value " << val
130 <<
" at index " << elemI <<
" out of " << lst.size()
137 label newVal = oldToNew[val];
153 <<
"Problem : zero value " << newVal
154 <<
" at index " << elemI <<
" out of "
162 lst[elemI] =
sign*(newVal+1);
170 const bool selectEqual,
179 if (selectEqual == (values[i] == value))
190 if (selectEqual == (values[i] == value))
207 DynamicList<word> mergedNames;
210 mergedNames = procNames;
211 for (
const wordList& names : allNames)
213 for (
const word&
name : names)
215 mergedNames.appendUniq(
name);
227 Pout<<
"Primitives:" <<
nl
241 Pout<<
" " << patchi <<
" name:" << pp.
name()
242 <<
" size:" << pp.size()
243 <<
" start:" << pp.
start()
244 <<
" type:" << pp.type()
254 Pout<<
" " << zoneI <<
" name:" << pz.
name()
255 <<
" size:" << pz.
size()
265 Pout<<
" " << zoneI <<
" name:" << fz.
name()
266 <<
" size:" << fz.
size()
276 Pout<<
" " << zoneI <<
" name:" << cz.
name()
277 <<
" size:" << cz.
size()
294 <<
"Current coupling info:"
297 forAll(sourceFace, bFacei)
301 Pout<<
" meshFace:" << meshFacei
303 <<
" connects to proc:" << sourceProc[bFacei]
304 <<
"/face:" << sourceFace[bFacei]
305 <<
" which will move to proc:" << sourceNewNbrProc[bFacei]
311Foam::label Foam::fvMeshDistribute::findNonEmptyPatch()
const
325 const auto* cpp = isA<cyclicACMIPolyPatch>(pp);
329 isCoupledPatch.set(patchi);
330 const label dupPatchID = cpp->nonOverlapPatchID();
331 if (dupPatchID != -1)
333 isCoupledPatch.set(dupPatchID);
338 isCoupledPatch.set(patchi);
342 label nonEmptyPatchi = -1;
346 const polyPatch& pp =
patches[patchi];
350 !isA<emptyPolyPatch>(pp)
351 && !isCoupledPatch(patchi)
352 && !isA<mappedPatchBase>(pp)
355 nonEmptyPatchi = patchi;
360 if (nonEmptyPatchi == -1)
363 <<
"Cannot find a patch which is neither of type empty nor"
365 <<
"There has to be at least one such patch for"
371 Pout<<
"findNonEmptyPatch : using patch " << nonEmptyPatchi
373 <<
" type:" <<
patches[nonEmptyPatchi].type()
374 <<
" to put exposed faces into." <<
endl;
380 label procPatchi = -1;
384 if (isA<processorPolyPatch>(
patches[patchi]))
388 else if (procPatchi != -1)
391 <<
"Processor patches should be at end of patch list."
393 <<
"Have processor patch " << procPatchi
394 <<
" followed by non-processor patch " << patchi
400 return nonEmptyPatchi;
433 fld[facei] = (
n[facei] & testNormal);
446 newPfld[i] = (nBf[patchi][i] & testNormal);
465 scalar
cos = (
n[facei] & testNormal);
471 <<
"On internal face " << facei <<
" at "
473 <<
" the field value is " <<
fld[facei]
474 <<
" whereas cos angle of " << testNormal
475 <<
" with mesh normal " <<
n[facei]
488 scalar
cos = (np[i] & testNormal);
495 <<
"On face " << facei
498 <<
" the field value is " << fvp[i]
499 <<
" whereas cos angle of " << testNormal
500 <<
" with mesh normal " << np[i]
512 const label destinationPatch
520 labelList newPatchID(mesh_.nBoundaryFaces(), -1);
524 if (isA<processorPolyPatch>(pp))
528 Pout<<
"Moving all faces of patch " << pp.
name()
529 <<
" into patch " << destinationPatch
538 ) = destinationPatch;
546 autoPtr<mapPolyMesh> map = repatch(newPatchID, dummyFaceMaps);
554 forAll(mesh_.boundaryMesh(), patchi)
556 if (!isA<processorPolyPatch>(mesh_.boundaryMesh()[patchi]))
558 oldToNew[patchi] = newi++;
561 label nNonProcPatches = newi;
564 forAll(mesh_.boundaryMesh(), patchi)
566 if (isA<processorPolyPatch>(mesh_.boundaryMesh()[patchi]))
568 oldToNew[patchi] = newi++;
584 polyTopoChange meshMod(mesh_);
586 forAll(newPatchID, bFacei)
588 if (newPatchID[bFacei] != -1)
590 label facei = mesh_.nInternalFaces() + bFacei;
592 label
zoneID = mesh_.faceZones().whichZone(facei);
593 bool zoneFlip =
false;
597 const faceZone& fZone = mesh_.faceZones()[
zoneID];
598 zoneFlip = fZone.flipMap()[fZone.whichFace(facei)];
605 mesh_.faces()[facei],
607 mesh_.faceOwner()[facei],
624 PtrList<FieldField<fvsPatchField, scalar>> sFlds;
625 saveBoundaryFields<scalar, surfaceMesh>(sFlds);
626 PtrList<FieldField<fvsPatchField, vector>> vFlds;
627 saveBoundaryFields<vector, surfaceMesh>(vFlds);
628 PtrList<FieldField<fvsPatchField, sphericalTensor>> sptFlds;
629 saveBoundaryFields<sphericalTensor, surfaceMesh>(sptFlds);
630 PtrList<FieldField<fvsPatchField, symmTensor>> sytFlds;
631 saveBoundaryFields<symmTensor, surfaceMesh>(sytFlds);
632 PtrList<FieldField<fvsPatchField, tensor>> tFlds;
633 saveBoundaryFields<tensor, surfaceMesh>(tFlds);
644 const bool oldMoving = mesh_.moving(
false);
645 autoPtr<mapPolyMesh> mapPtr = meshMod.changeMesh(mesh_,
false,
true);
646 mesh_.moving(oldMoving);
647 mapPolyMesh& map = *mapPtr;
651 mesh_.updateMesh(map);
655 mapBoundaryFields<scalar, surfaceMesh>(map, sFlds);
656 mapBoundaryFields<vector, surfaceMesh>(map, vFlds);
657 mapBoundaryFields<sphericalTensor, surfaceMesh>(map, sptFlds);
658 mapBoundaryFields<symmTensor, surfaceMesh>(map, sytFlds);
659 mapBoundaryFields<tensor, surfaceMesh>(map, tFlds);
663 if (map.hasMotionPoints())
665 mesh_.movePoints(map.preMotionPoints());
672 label index = map.reverseFaceMap().find(-1);
677 <<
"reverseFaceMap contains -1 at index:"
679 <<
"This means that the repatch operation was not just"
684 forAll(constructFaceMap, proci)
686 inplaceRenumberWithFlip
688 map.reverseFaceMap(),
691 constructFaceMap[proci]
714 forAll(pointToGlobalMaster, pointi)
716 if (pointToGlobalMaster[pointi] != -1)
724 Pout<<
"mergeSharedPoints : found " << nShared
725 <<
" points on processor boundaries" <<
nl <<
endl;
728 Map<label> globalMasterToLocalMaster(2*nShared);
729 Map<label> pointToMaster(2*nShared);
732 forAll(pointToGlobalMaster, pointi)
734 label globali = pointToGlobalMaster[pointi];
737 const auto iter = globalMasterToLocalMaster.cfind(globali);
742 pointToMaster.insert(pointi, *iter);
748 globalMasterToLocalMaster.insert(globali, pointi);
749 pointToMaster.insert(pointi, pointi);
754 reduce(nMatch, sumOp<label>());
758 Pout<<
"mergeSharedPoints : found "
759 << nMatch <<
" mergeable points" <<
nl <<
endl;
769 polyTopoChange meshMod(mesh_);
777 const bool oldMoving = mesh_.moving(
false);
778 autoPtr<mapPolyMesh> mapPtr = meshMod.changeMesh(mesh_,
false,
true);
779 mesh_.moving(oldMoving);
780 mapPolyMesh& map = *mapPtr;
783 mesh_.updateMesh(map);
786 forAll(constructPointMap, proci)
788 labelList& constructMap = constructPointMap[proci];
792 label oldPointi = constructMap[i];
794 label
newPointi = map.reversePointMap()[oldPointi];
807 <<
"Problem. oldPointi:" << oldPointi
817void Foam::fvMeshDistribute::getCouplingData
830 const label nBnd = mesh_.nBoundaryFaces();
831 sourceFace.setSize(nBnd);
832 sourceProc.setSize(nBnd);
833 sourcePatch.setSize(nBnd);
834 sourceNewNbrProc.setSize(nBnd);
836 const polyBoundaryMesh&
patches = mesh_.boundaryMesh();
844 const polyPatch& pp =
patches[patchi];
848 label offset = pp.
start() - mesh_.nInternalFaces();
853 label bndI = offset + i;
854 nbrFaces[bndI] = pp.start()+i;
858 SubList<label>(nbrNewNbrProc, pp.size(), offset) =
871 const polyPatch& pp =
patches[patchi];
872 label offset = pp.
start() - mesh_.nInternalFaces();
874 if (isA<processorPolyPatch>(pp))
876 const processorPolyPatch& procPatch =
877 refCast<const processorPolyPatch>(pp);
881 if (procPatch.owner())
886 label bndI = offset + i;
887 sourceFace[bndI] = pp.start()+i;
889 sourceNewNbrProc[bndI] = nbrNewNbrProc[bndI];
897 label bndI = offset + i;
898 sourceFace[bndI] = nbrFaces[bndI];
899 sourceProc[bndI] = procPatch.neighbProcNo();
900 sourceNewNbrProc[bndI] = nbrNewNbrProc[bndI];
906 if (isA<processorCyclicPolyPatch>(pp))
908 patchi = refCast<const processorCyclicPolyPatch>
916 label bndI = offset + i;
917 sourcePatch[bndI] = patchi;
920 else if (isA<cyclicPolyPatch>(pp))
922 const cyclicPolyPatch& cpp = refCast<const cyclicPolyPatch>(pp);
928 label bndI = offset + i;
929 sourceFace[bndI] = pp.start()+i;
931 sourcePatch[bndI] = patchi;
932 sourceNewNbrProc[bndI] = nbrNewNbrProc[bndI];
939 label bndI = offset + i;
940 sourceFace[bndI] = nbrFaces[bndI];
942 sourcePatch[bndI] = patchi;
943 sourceNewNbrProc[bndI] = nbrNewNbrProc[bndI];
952 label bndI = offset + i;
953 sourceFace[bndI] = -1;
954 sourceProc[bndI] = -1;
955 sourcePatch[bndI] = patchi;
956 sourceNewNbrProc[bndI] = -1;
963 sourcePointMaster.setSize(mesh_.nPoints());
964 sourcePointMaster = -1;
967 const globalIndex globalPoints(mesh_.nPoints());
969 const globalMeshData& gmd = mesh_.globalData();
971 const labelList& meshPoints = cpp.meshPoints();
972 const mapDistribute& slavesMap = gmd.globalCoPointSlavesMap();
975 labelList elems(slavesMap.constructSize(), -1);
976 forAll(meshPoints, pointi)
984 label globalPointi = globalPoints.toGlobal(meshPoints[pointi]);
985 elems[pointi] = globalPointi;
988 label sloti = slots[i];
989 if (sloti >= meshPoints.size())
993 elems[slots[i]] = globalPointi;
1000 slavesMap.reverseDistribute(elems.size(), elems,
false);
1003 forAll(meshPoints, pointi)
1005 sourcePointMaster[meshPoints[pointi]] = elems[pointi];
1012void Foam::fvMeshDistribute::subsetCouplingData
1022 const label oldInternalFaces,
1042 forAll(subFace, newBFacei)
1046 label oldFacei =
faceMap[newFacei];
1049 if (oldFacei < oldInternalFaces)
1051 subFace[newBFacei] = oldFacei;
1053 subPatch[newBFacei] = -1;
1055 label oldOwn = oldFaceOwner[oldFacei];
1056 label oldNei = oldFaceNeighbour[oldFacei];
1061 subNewNbrProc[newBFacei] = oldDistribution[oldNei];
1066 subNewNbrProc[newBFacei] = oldDistribution[oldOwn];
1072 label oldBFacei = oldFacei - oldInternalFaces;
1074 subFace[newBFacei] = sourceFace[oldBFacei];
1075 subProc[newBFacei] = sourceProc[oldBFacei];
1076 subPatch[newBFacei] = sourcePatch[oldBFacei];
1077 subNewNbrProc[newBFacei] = sourceNewNbrProc[oldBFacei];
1082 subPointMaster = UIndirectList<label>(sourcePointMaster, pointMap);
1088void Foam::fvMeshDistribute::findCouples
1090 const primitiveMesh&
mesh,
1096 const primitiveMesh& domainMesh,
1109 forAll(domainProc, bFacei)
1111 if (domainProc[bFacei] != -1 && domainPatch[bFacei] == -1)
1115 labelPair(domainFace[bFacei], domainProc[bFacei]),
1124 masterCoupledFaces.setSize(domainFace.size());
1125 slaveCoupledFaces.setSize(domainFace.size());
1128 forAll(sourceFace, bFacei)
1130 if (sourceProc[bFacei] != -1 && sourcePatch[bFacei] == -1)
1132 labelPair myData(sourceFace[bFacei], sourceProc[bFacei]);
1134 const auto iter = map.cfind(myData);
1138 label nbrBFacei = *iter;
1141 slaveCoupledFaces[coupledI] =
1142 domainMesh.nInternalFaces()
1150 masterCoupledFaces.setSize(coupledI);
1151 slaveCoupledFaces.setSize(coupledI);
1155 Pout<<
"findCouples : found " << coupledI
1156 <<
" faces that will be stitched" <<
nl <<
endl;
1161void Foam::fvMeshDistribute::findCouples
1163 const UPtrList<polyMesh>&
meshes,
1164 const PtrList<labelList>& domainSourceFaces,
1165 const PtrList<labelList>& domainSourceProcs,
1166 const PtrList<labelList>& domainSourcePatchs,
1182 const labelList& domainProc = domainSourceProcs[meshi];
1183 const labelList& domainPatch = domainSourcePatchs[meshi];
1185 forAll(domainProc, bFacei)
1187 if (domainProc[bFacei] != -1 && domainPatch[bFacei] == -1)
1189 nProcFaces[meshi]++;
1197 Pout<<
"fvMeshDistribute::findCouples : nProcFaces:"
1211 dynLocalFace[meshi].setCapacity(nProcFaces[meshi]);
1212 dynRemoteProc[meshi].setCapacity(nProcFaces[meshi]);
1213 dynRemoteFace[meshi].setCapacity(nProcFaces[meshi]);
1219 LabelPairMap<labelPair> map(2*
sum(nProcFaces));
1227 const labelList& domainFace = domainSourceFaces[meshi];
1228 const labelList& domainProc = domainSourceProcs[meshi];
1229 const labelList& domainPatch = domainSourcePatchs[meshi];
1231 forAll(domainProc, bFacei)
1233 if (domainProc[bFacei] != -1 && domainPatch[bFacei] == -1)
1240 auto fnd = map.find(key);
1245 map.emplace(key, meshi, bFacei);
1250 const label matchProci = fnd().first();
1251 const label matchFacei = fnd().second();
1253 dynLocalFace[meshi].append(bFacei);
1254 dynRemoteProc[meshi].append(matchProci);
1255 dynRemoteFace[meshi].append(matchFacei);
1256 nProcFaces[meshi]++;
1258 dynLocalFace[matchProci].append(matchFacei);
1259 dynRemoteProc[matchProci].append(meshi);
1260 dynRemoteFace[matchProci].append(bFacei);
1261 nProcFaces[matchProci]++;
1270 Pout<<
"fvMeshDistribute::findCouples : stored procFaces:"
1271 << map.size() <<
endl;
1281 localBoundaryFace[meshi] = std::move(dynLocalFace[meshi]);
1282 remoteFaceProc[meshi] = std::move(dynRemoteProc[meshi]);
1283 remoteBoundaryFace[meshi] = std::move(dynRemoteFace[meshi]);
1290 Pout<<
"fvMeshDistribute::findCouples : found matches:"
1299 const primitiveMesh&
mesh,
1300 const mapAddedPolyMesh& map,
1302 const label nInternalFaces1,
1308 forAll(boundaryData0, oldBFacei)
1310 label newFacei = map.oldFaceMap()[oldBFacei + map.nOldInternalFaces()];
1316 boundaryData0[oldBFacei];
1320 forAll(boundaryData1, addedBFacei)
1322 label newFacei = map.addedFaceMap()[addedBFacei + nInternalFaces1];
1327 boundaryData1[addedBFacei];
1331 return newBoundaryData;
1337 const primitiveMesh&
mesh,
1338 const mapAddedPolyMesh& map,
1345 forAll(boundaryData0, oldPointi)
1347 label
newPointi = map.oldPointMap()[oldPointi];
1352 newBoundaryData[
newPointi] = boundaryData0[oldPointi];
1356 forAll(boundaryData1, addedPointi)
1358 label
newPointi = map.addedPointMap()[addedPointi];
1362 newBoundaryData[
newPointi] = boundaryData1[addedPointi];
1366 return newBoundaryData;
1374 const label oldInternalPatchi
1378 polyTopoChange meshMod(mesh_);
1382 removeCells cellRemover(mesh_,
false);
1385 labelList exposedFaces(cellRemover.getExposedFaces(cellsToRemove));
1388 cellRemover.setRefinement
1392 labelList(exposedFaces.size(), oldInternalPatchi),
1403 PtrList<Field<scalar>> sFlds;
1404 saveInternalFields(sFlds);
1405 PtrList<Field<vector>> vFlds;
1406 saveInternalFields(vFlds);
1407 PtrList<Field<sphericalTensor>> sptFlds;
1408 saveInternalFields(sptFlds);
1409 PtrList<Field<symmTensor>> sytFlds;
1410 saveInternalFields(sytFlds);
1411 PtrList<Field<tensor>> tFlds;
1412 saveInternalFields(tFlds);
1418 const bool oldMoving = mesh_.moving(
false);
1419 autoPtr<mapPolyMesh> map = meshMod.changeMesh(mesh_,
false,
false);
1420 mesh_.moving(oldMoving);
1423 mesh_.updateMesh(map());
1430 mapExposedFaces(map(), sFlds);
1431 mapExposedFaces(map(), vFlds);
1432 mapExposedFaces(map(), sptFlds);
1433 mapExposedFaces(map(), sytFlds);
1434 mapExposedFaces(map(), tFlds);
1442 if (map().hasMotionPoints())
1444 mesh_.movePoints(map().preMotionPoints());
1454void Foam::fvMeshDistribute::addProcPatches
1458 List<Map<label>>& procPatchID
1470 sortedOrder(nbrProc, indices, lessProcPatches(nbrProc, referPatchID));
1476 label bFacei = indices[i];
1477 label proci = nbrProc[bFacei];
1481 if (!procPatchID[proci].
found(referPatchID[bFacei]))
1486 if (referPatchID[bFacei] == -1)
1490 processorPolyPatch pp
1494 mesh_.boundaryMesh().size(),
1495 mesh_.boundaryMesh(),
1500 procPatchID[proci].insert
1502 referPatchID[bFacei],
1515 const coupledPolyPatch& pcPatch
1516 = refCast<const coupledPolyPatch>
1518 mesh_.boundaryMesh()[referPatchID[bFacei]]
1520 processorCyclicPolyPatch pp
1524 mesh_.boundaryMesh().size(),
1525 mesh_.boundaryMesh(),
1532 procPatchID[proci].insert
1534 referPatchID[bFacei],
1556 const List<Map<label>>& procPatchID
1565 label origPatchi = referPatchID[bFacei];
1566 patchIDs[bFacei] = origPatchi;
1568 else if (nbrProc[bFacei] != -1)
1570 label origPatchi = referPatchID[bFacei];
1571 patchIDs[bFacei] = procPatchID[nbrProc[bFacei]][origPatchi];
1575 patchIDs[bFacei] = -1;
1583void Foam::fvMeshDistribute::sendMesh
1602 Pout<<
"Sending to domain " << domain <<
nl
1612 CompactListList<label> zonePoints;
1618 forAll(pointZoneNames, nameI)
1620 label myZoneID = pointZones.findZoneID(pointZoneNames[nameI]);
1624 rowSizes[nameI] = pointZones[myZoneID].size();
1627 zonePoints.setSize(rowSizes);
1629 forAll(pointZoneNames, nameI)
1631 label myZoneID = pointZones.findZoneID(pointZoneNames[nameI]);
1635 zonePoints[nameI].deepCopy(pointZones[myZoneID]);
1641 CompactListList<label> zoneFaces;
1642 CompactListList<bool> zoneFaceFlip;
1648 forAll(faceZoneNames, nameI)
1650 label myZoneID = faceZones.findZoneID(faceZoneNames[nameI]);
1654 rowSizes[nameI] = faceZones[myZoneID].size();
1658 zoneFaces.setSize(rowSizes);
1659 zoneFaceFlip.setSize(rowSizes);
1661 forAll(faceZoneNames, nameI)
1663 label myZoneID = faceZones.findZoneID(faceZoneNames[nameI]);
1667 zoneFaces[nameI].deepCopy(faceZones[myZoneID]);
1668 zoneFaceFlip[nameI].deepCopy(faceZones[myZoneID].flipMap());
1674 CompactListList<label> zoneCells;
1680 forAll(cellZoneNames, nameI)
1682 label myZoneID = cellZones.findZoneID(cellZoneNames[nameI]);
1686 rowSizes[nameI] = cellZones[myZoneID].size();
1690 zoneCells.setSize(rowSizes);
1692 forAll(cellZoneNames, nameI)
1694 label myZoneID = cellZones.findZoneID(cellZoneNames[nameI]);
1698 zoneCells[nameI].deepCopy(cellZones[myZoneID]);
1721 << CompactListList<label>::pack<face>(
mesh.
faces())
1735 << sourcePointMaster;
1740 Pout<<
"Started sending mesh to domain " << domain
1764 faceList domainFaces = CompactListList<label>(fromNbr).unpack<face>();
1767 PtrList<entry> patchEntries(fromNbr);
1769 CompactListList<label> zonePoints(fromNbr);
1770 CompactListList<label> zoneFaces(fromNbr);
1771 CompactListList<bool> zoneFaceFlip(fromNbr);
1772 CompactListList<label> zoneCells(fromNbr);
1777 >> domainSourcePatch
1778 >> domainSourceNewNbrProc
1779 >> domainSourcePointMaster;
1791 std::move(domainPoints),
1792 std::move(domainFaces),
1793 std::move(domainAllOwner),
1794 std::move(domainAllNeighbour),
1797 fvMesh& domainMesh = *domainMeshPtr;
1799 List<polyPatch*>
patches(patchEntries.size());
1801 forAll(patchEntries, patchi)
1805 patchEntries[patchi].keyword(),
1806 patchEntries[patchi].
dict(),
1808 domainMesh.boundaryMesh()
1812 domainMesh.addFvPatches(
patches,
false);
1815 List<pointZone*> pZonePtrs(pointZoneNames.size());
1818 pZonePtrs[i] =
new pointZone
1823 domainMesh.pointZones()
1827 List<faceZone*> fZonePtrs(faceZoneNames.size());
1830 fZonePtrs[i] =
new faceZone
1836 domainMesh.faceZones()
1840 List<cellZone*> cZonePtrs(cellZoneNames.size());
1843 cZonePtrs[i] =
new cellZone
1848 domainMesh.cellZones()
1851 domainMesh.addZones(pZonePtrs, fZonePtrs, cZonePtrs);
1853 return domainMeshPtr;
1882 <<
"At index " << celli <<
" distribution:" << newProc
1900 <<
"Size of distribution:"
1912 <<
"This application requires all non-processor patches"
1913 <<
" to be present in the same order on all patches" <<
nl
1914 <<
"followed by the processor patches (which of course are unique)."
1916 <<
"Local patches:" << mesh_.boundaryMesh().names()
1921 const label nOldPoints(mesh_.nPoints());
1922 const label nOldFaces(mesh_.nFaces());
1923 const label nOldCells(mesh_.nCells());
1929 oldPatchNMeshPoints[patchi] =
patches[patchi].nPoints();
1945 std::move(oldPatchStarts),
1946 std::move(oldPatchNMeshPoints),
1964 const wordList pointZoneNames(mergeWordList(mesh_.pointZones().names()));
1965 reorderZones<pointZone>(pointZoneNames, mesh_.pointZones());
1967 const wordList faceZoneNames(mergeWordList(mesh_.faceZones().names()));
1968 reorderZones<faceZone>(faceZoneNames, mesh_.faceZones());
1970 const wordList cellZoneNames(mergeWordList(mesh_.cellZones().names()));
1971 reorderZones<cellZone>(cellZoneNames, mesh_.cellZones());
2034 mesh_.resetMotion();
2040 getFieldNames<volScalarField>(mesh_, allFieldNames);
2041 getFieldNames<volVectorField>(mesh_, allFieldNames);
2042 getFieldNames<volSphericalTensorField>(mesh_, allFieldNames);
2043 getFieldNames<volSymmTensorField>(mesh_, allFieldNames);
2044 getFieldNames<volTensorField>(mesh_, allFieldNames);
2046 getFieldNames<surfaceScalarField>(mesh_, allFieldNames);
2047 getFieldNames<surfaceVectorField>(mesh_, allFieldNames);
2048 getFieldNames<surfaceSphericalTensorField>(mesh_, allFieldNames);
2049 getFieldNames<surfaceSymmTensorField>(mesh_, allFieldNames);
2050 getFieldNames<surfaceTensorField>(mesh_, allFieldNames);
2052 getFieldNames<volScalarField::Internal>
2058 getFieldNames<volVectorField::Internal>
2064 getFieldNames<volSphericalTensorField::Internal>
2070 getFieldNames<volSymmTensorField::Internal>
2076 getFieldNames<volTensorField::Internal>
2085 const label oldInternalPatchi = findNonEmptyPatch();
2095 repatchFaceMap = repatchMap().faceMap();
2102 repatchMap().reverseFaceMap(),
2103 mesh_.nBoundaryFaces(),
2104 mesh_.nInternalFaces()
2106 - mesh_.nInternalFaces()
2120 Pout<<
nl <<
"MESH WITH PROC PATCHES DELETED:" <<
endl;
2121 printMeshInfo(mesh_);
2122 printFieldInfo<volScalarField>(mesh_);
2123 printFieldInfo<volVectorField>(mesh_);
2124 printFieldInfo<volSphericalTensorField>(mesh_);
2125 printFieldInfo<volSymmTensorField>(mesh_);
2126 printFieldInfo<volTensorField>(mesh_);
2127 printFieldInfo<surfaceScalarField>(mesh_);
2128 printFieldInfo<surfaceVectorField>(mesh_);
2129 printFieldInfo<surfaceSphericalTensorField>(mesh_);
2130 printFieldInfo<surfaceSymmTensorField>(mesh_);
2131 printFieldInfo<surfaceTensorField>(mesh_);
2132 printIntFieldInfo<volScalarField::Internal>(mesh_);
2133 printIntFieldInfo<volVectorField::Internal>(mesh_);
2134 printIntFieldInfo<volSphericalTensorField::Internal>(mesh_);
2135 printIntFieldInfo<volSymmTensorField::Internal>(mesh_);
2136 printIntFieldInfo<volTensorField::Internal>(mesh_);
2171 forAll(nSendCells, recvProc)
2180 <<
"SUBSETTING FOR DOMAIN " << recvProc
2181 <<
" cells to send:"
2182 << nSendCells[recvProc]
2200 subCellMap[recvProc] = subsetter.
cellMap();
2202 inplaceRenumberWithFlip
2207 subFaceMap[recvProc]
2209 subPointMap[recvProc] = subsetter.
pointMap();
2210 subPatchMap[recvProc] = subsetter.
patchMap();
2229 mesh_.faceNeighbour(),
2230 mesh_.nInternalFaces(),
2241 procSourceNewNbrProc,
2242 procSourcePointMaster
2259 procSourceNewNbrProc,
2260 procSourcePointMaster,
2266 sendFields<volScalarField>
2273 sendFields<volVectorField>
2280 sendFields<volSphericalTensorField>
2287 sendFields<volSymmTensorField>
2294 sendFields<volTensorField>
2303 sendFields<surfaceScalarField>
2310 sendFields<surfaceVectorField>
2317 sendFields<surfaceSphericalTensorField>
2324 sendFields<surfaceSymmTensorField>
2331 sendFields<surfaceTensorField>
2340 sendFields<volScalarField::Internal>
2347 sendFields<volVectorField::Internal>
2354 sendFields<volSphericalTensorField::Internal>
2361 sendFields<volSymmTensorField::Internal>
2368 sendFields<volTensorField::Internal>
2394 Pout<<
"Finished sending and receiving : " <<
flatOutput(recvSizes)
2405 const labelList oldFaceOwner(mesh_.faceOwner());
2406 const labelList oldFaceNeighbour(mesh_.faceNeighbour());
2407 const label oldInternalFaces = mesh_.nInternalFaces();
2433 for (
const label facei : flip)
2450 subMap().pointMap(),
2468 domainSourceNewNbrProc,
2469 domainSourcePointMaster
2472 sourceFace.
transfer(domainSourceFace);
2473 sourceProc.
transfer(domainSourceProc);
2474 sourcePatch.
transfer(domainSourcePatch);
2475 sourceNewNbrProc.
transfer(domainSourceNewNbrProc);
2476 sourcePointMaster.
transfer(domainSourcePointMaster);
2484 printMeshInfo(mesh_);
2485 printFieldInfo<volScalarField>(mesh_);
2486 printFieldInfo<volVectorField>(mesh_);
2487 printFieldInfo<volSphericalTensorField>(mesh_);
2488 printFieldInfo<volSymmTensorField>(mesh_);
2489 printFieldInfo<volTensorField>(mesh_);
2490 printFieldInfo<surfaceScalarField>(mesh_);
2491 printFieldInfo<surfaceVectorField>(mesh_);
2492 printFieldInfo<surfaceSphericalTensorField>(mesh_);
2493 printFieldInfo<surfaceSymmTensorField>(mesh_);
2494 printFieldInfo<surfaceTensorField>(mesh_);
2495 printIntFieldInfo<volScalarField::Internal>(mesh_);
2496 printIntFieldInfo<volVectorField::Internal>(mesh_);
2497 printIntFieldInfo<volSphericalTensorField::Internal>(mesh_);
2498 printIntFieldInfo<volSymmTensorField::Internal>(mesh_);
2499 printIntFieldInfo<volTensorField::Internal>(mesh_);
2546 forAll(nRevcCells, sendProc)
2554 <<
"RECEIVING FROM DOMAIN " << sendProc
2555 <<
" cells to receive:"
2556 << nRevcCells[sendProc]
2567 labelList& domainSourceFace = domainSourceFaces[sendProc];
2570 labelList& domainSourceProc = domainSourceProcs[sendProc];
2573 labelList& domainSourcePatch = domainSourcePatchs[sendProc];
2575 domainSourceNewNbrProcs.
set(sendProc,
new labelList(0));
2577 domainSourceNewNbrProcs[sendProc];
2579 domainSourcePointMasters.
set(sendProc,
new labelList(0));
2581 domainSourcePointMasters[sendProc];
2592 const_cast<Time&
>(mesh_.time()),
2596 domainSourceNewNbrProc,
2597 domainSourcePointMaster,
2600 domainMeshPtrs.
set(sendProc, domainMeshPtr.
ptr());
2601 fvMesh& domainMesh = domainMeshPtrs[sendProc];
2612 receiveFields<volScalarField>
2621 receiveFields<volVectorField>
2634 receiveFields<volSphericalTensorField>
2643 receiveFields<volSymmTensorField>
2652 receiveFields<volTensorField>
2663 receiveFields<surfaceScalarField>
2672 receiveFields<surfaceVectorField>
2685 receiveFields<surfaceSphericalTensorField>
2694 receiveFields<surfaceSymmTensorField>
2703 receiveFields<surfaceTensorField>
2718 receiveFields<volScalarField::Internal>
2731 receiveFields<volVectorField::Internal>
2744 receiveFields<volSphericalTensorField::Internal>
2757 receiveFields<volSymmTensorField::Internal>
2770 receiveFields<volTensorField::Internal>
2789 forAll(domainMeshPtrs, proci)
2791 if (domainMeshPtrs.
set(proci))
2793 meshes.
set(proci, &domainMeshPtrs[proci]);
2794 fvMeshes.
set(proci, &domainMeshPtrs[proci]);
2840 const label nOldInternalFaces = mesh_.nInternalFaces();
2841 const labelList oldFaceOwner(mesh_.faceOwner());
2845 const bool oldMoving = mesh_.moving(
false);
2864 mesh_.moving(oldMoving);
2870 printMeshInfo(mesh_);
2871 printFieldInfo<volScalarField>(mesh_);
2872 printFieldInfo<volVectorField>(mesh_);
2873 printFieldInfo<volSphericalTensorField>(mesh_);
2874 printFieldInfo<volSymmTensorField>(mesh_);
2875 printFieldInfo<volTensorField>(mesh_);
2876 printFieldInfo<surfaceScalarField>(mesh_);
2877 printFieldInfo<surfaceVectorField>(mesh_);
2878 printFieldInfo<surfaceSphericalTensorField>(mesh_);
2879 printFieldInfo<surfaceSymmTensorField>(mesh_);
2880 printFieldInfo<surfaceTensorField>(mesh_);
2881 printIntFieldInfo<volScalarField::Internal>(mesh_);
2882 printIntFieldInfo<volVectorField::Internal>(mesh_);
2883 printIntFieldInfo<volSphericalTensorField::Internal>(mesh_);
2884 printIntFieldInfo<volSymmTensorField::Internal>(mesh_);
2885 printIntFieldInfo<volTensorField::Internal>(mesh_);
2891 sourceProc.
setSize(mesh_.nBoundaryFaces());
2893 sourcePatch.
setSize(mesh_.nBoundaryFaces());
2895 sourceFace.
setSize(mesh_.nBoundaryFaces());
2897 sourceNewNbrProc.
setSize(mesh_.nBoundaryFaces());
2898 sourceNewNbrProc = -1;
2899 sourcePointMaster.
setSize(mesh_.nPoints());
2900 sourcePointMaster = -1;
2902 if (mesh_.nPoints() > 0)
2906 if (domainSourceFaces.
set(meshi))
2908 const label nIntFaces =
2912 :
meshes[meshi].nInternalFaces()
2918 :
meshes[meshi].faceOwner()
2922 const labelList& cellMap = constructCellMap[meshi];
2925 domainSourceFaces[meshi];
2927 domainSourceProcs[meshi];
2929 domainSourcePatchs[meshi];
2931 domainSourceNewNbrProcs[meshi];
2935 constructPointMap[meshi]
2936 ) = domainSourcePointMasters[meshi];
2939 forAll(domainSourceFace, bFacei)
2941 const label oldFacei = bFacei+nIntFaces;
2942 const label allFacei =
faceMap[oldFacei];
2943 const label allbFacei = allFacei-mesh_.nInternalFaces();
2947 sourceProc[allbFacei] = domainSourceProc[bFacei];
2948 sourcePatch[allbFacei] = domainSourcePatch[bFacei];
2949 sourceFace[allbFacei] = domainSourceFace[bFacei];
2950 sourceNewNbrProc[allbFacei] =
2951 domainSourceNewNbr[bFacei];
2959 const label allFacei =
faceMap[oldFacei];
2960 const label allOwn = mesh_.faceOwner()[allFacei];
2962 if (cellMap[faceOwner[oldFacei]] == allOwn)
2986 printMeshInfo(mesh_);
2987 printFieldInfo<volScalarField>(mesh_);
2988 printFieldInfo<volVectorField>(mesh_);
2989 printFieldInfo<volSphericalTensorField>(mesh_);
2990 printFieldInfo<volSymmTensorField>(mesh_);
2991 printFieldInfo<volTensorField>(mesh_);
2992 printFieldInfo<surfaceScalarField>(mesh_);
2993 printFieldInfo<surfaceVectorField>(mesh_);
2994 printFieldInfo<surfaceSphericalTensorField>(mesh_);
2995 printFieldInfo<surfaceSymmTensorField>(mesh_);
2996 printFieldInfo<surfaceTensorField>(mesh_);
2997 printIntFieldInfo<volScalarField::Internal>(mesh_);
2998 printIntFieldInfo<volVectorField::Internal>(mesh_);
2999 printIntFieldInfo<volSphericalTensorField::Internal>(mesh_);
3000 printIntFieldInfo<volSymmTensorField::Internal>(mesh_);
3001 printIntFieldInfo<volTensorField::Internal>(mesh_);
3008 mergeSharedPoints(sourcePointMaster, constructPointMap);
3020 addProcPatches(sourceNewNbrProc, sourcePatch, procPatchID);
3039 repatch(newPatchID, constructFaceMap);
3043 initPatchFields<volScalarField, processorFvPatchField<scalar>>
3047 initPatchFields<volVectorField, processorFvPatchField<vector>>
3059 initPatchFields<volSymmTensorField, processorFvPatchField<symmTensor>>
3063 initPatchFields<volTensorField, processorFvPatchField<tensor>>
3069 mesh_.setInstance(mesh_.time().timeName());
3076 printMeshInfo(mesh_);
3077 printFieldInfo<volScalarField>(mesh_);
3078 printFieldInfo<volVectorField>(mesh_);
3079 printFieldInfo<volSphericalTensorField>(mesh_);
3080 printFieldInfo<volSymmTensorField>(mesh_);
3081 printFieldInfo<volTensorField>(mesh_);
3082 printFieldInfo<surfaceScalarField>(mesh_);
3083 printFieldInfo<surfaceVectorField>(mesh_);
3084 printFieldInfo<surfaceSphericalTensorField>(mesh_);
3085 printFieldInfo<surfaceSymmTensorField>(mesh_);
3086 printFieldInfo<surfaceTensorField>(mesh_);
3087 printIntFieldInfo<volScalarField::Internal>(mesh_);
3088 printIntFieldInfo<volVectorField::Internal>(mesh_);
3089 printIntFieldInfo<volSphericalTensorField::Internal>(mesh_);
3090 printIntFieldInfo<volSymmTensorField::Internal>(mesh_);
3091 printIntFieldInfo<volTensorField::Internal>(mesh_);
3103 std::move(oldPatchStarts),
3104 std::move(oldPatchNMeshPoints),
3106 std::move(subPointMap),
3107 std::move(subFaceMap),
3108 std::move(subCellMap),
3109 std::move(subPatchMap),
3111 std::move(constructPointMap),
3112 std::move(constructFaceMap),
3113 std::move(constructCellMap),
3114 std::move(constructPatchMap),
Various functions to operate on Lists.
Info<< nl<< "Wrote faMesh in vtk format: "<< writer.output().name()<< nl;}{ vtk::lineWriter writer(aMesh.points(), aMesh.edges(), fileName(aMesh.mesh().time().globalPath()/"finiteArea-edges"));writer.writeGeometry();writer.beginCellData(4);writer.writeProcIDs();{ Field< scalar > fld(faMeshTools::flattenEdgeField(aMesh.magLe(), true))
A HashTable similar to std::unordered_map.
label size() const noexcept
The number of elements in table.
Defines the attributes of an object for which implicit objectRegistry management is supported,...
const word & name() const noexcept
Return the object name.
void transfer(List< T > &list)
void setSize(const label n)
Alias for resize()
virtual const fileName & name() const
Get the name of the stream.
Buffers for inter-processor communications streams (UOPstream, UIPstream).
label nProcs() const noexcept
Number of ranks associated with PstreamBuffers.
void finishedSends(const bool wait=true)
Mark sends as done.
void clear()
Clear individual buffers and reset states.
static void gatherList(const List< commsStruct > &comms, List< T > &values, const int tag, const label comm)
static void scatter(const List< commsStruct > &comms, T &value, const int tag, const label comm)
Broadcast data: Distribute without modification.
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
const T * set(const label i) const
A List obtained as a section of another List.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
static autoPtr< Time > New()
Construct (dummy) Time - no functionObjects or libraries.
static word timeName(const scalar t, const int precision=precision_)
A List with indirect addressing. Like IndirectList but does not store addressing.
void size(const label n)
Older name for setAddressableSize.
@ nonBlocking
"nonBlocking"
static void allToAll(const UList< int32_t > &sendData, UList< int32_t > &recvData, const label communicator=worldComm)
Exchange integer data with all processors (in the communicator).
static bool & parRun() noexcept
Test if this a parallel run.
A list of pointers to objects of type <T>, without allocation/deallocation management of the pointers...
const T * set(const label i) const
label size() const noexcept
The number of elements in the list.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
T * ptr() noexcept
Same as release().
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
A bounding box defined in terms of min/max extrema points.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Accumulating histogram of values. Specified bin resolution automatic generation of bins.
A subset of mesh faces organised as a primitive patch.
Sums a given list of (at least two or more) fields and outputs the result into a new field,...
Sends/receives parts of mesh+fvfields to neighbouring processors. Used in load balancing.
static void printCoupleInfo(const primitiveMesh &, const labelList &, const labelList &, const labelList &, const labelList &)
Print some info on coupling data.
static void printMeshInfo(const fvMesh &)
Print some info on mesh.
static labelList countCells(const labelList &)
Helper function: count cells per processor in wanted distribution.
static tmp< surfaceScalarField > generateTestField(const fvMesh &)
Generate a test field on faces.
autoPtr< mapDistributePolyMesh > distribute(const labelList &dist)
Send cells to neighbours according to distribution.
static void testField(const surfaceScalarField &)
Check whether field consistent with face orientation.
Holds a reference to the original mesh (the baseMesh) and optionally to a subset of that mesh (the su...
const labelList & faceMap() const
Return face map.
const labelList & cellMap() const
Return cell map.
const labelList & faceFlipMap() const
Return face map with sign to encode flipped faces.
const fvMesh & subMesh() const
Return reference to subset mesh.
const labelList & patchMap() const
Return patch map.
const labelList & pointMap() const
Return point map.
Mesh data needed to do the Finite Volume discretisation.
const fvBoundaryMesh & boundary() const
Return reference to boundary mesh.
const Time & time() const
Return the top-level database.
const surfaceVectorField & Sf() const
Return cell face area vectors.
const surfaceScalarField & magSf() const
Return cell face area magnitudes.
virtual const word & name() const
Return name.
virtual label start() const
Return start label of this patch in the polyMesh face list.
const fvPatch & patch() const
Return patch.
Less function class that can be used for sorting processor patches.
bool operator()(const label a, const label b)
lessProcPatches(const labelList &nbrProc, const labelList &referPatchID)
A class representing the concept of 1 (one) that can be used to avoid manipulating objects known to b...
const word & name() const noexcept
The patch name.
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO.
label start() const noexcept
The start label of boundary faces in the polyMesh face list.
wordList names() const
Return a list of patch names.
bool checkParallelSync(const bool report=false) const
Check whether all procs have all patches and in same order.
static void mergePoints(const polyMesh &, const Map< label > &pointToMaster, polyTopoChange &meshMod)
Helper: Merge points.
const faceZoneMesh & faceZones() const noexcept
Return face zone mesh.
static word defaultRegion
Return the default region name.
virtual const faceList & faces() const
Return raw faces.
virtual const labelList & faceOwner() const
Return face owner.
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
const cellZoneMesh & cellZones() const noexcept
Return cell zone mesh.
virtual const labelList & faceNeighbour() const
Return face neighbour.
const pointZoneMesh & pointZones() const noexcept
Return point zone mesh.
virtual const pointField & points() const
Return raw points.
A patch is a list of labels that address the faces in the global face list.
virtual bool coupled() const
Return true if this patch is geometrically coupled (i.e. faces and.
label start() const
Return start label of this patch in the polyMesh face list.
const polyBoundaryMesh & boundaryMesh() const
Return boundaryMesh reference.
Cell-face mesh analysis engine.
label nBoundaryFaces() const noexcept
Number of boundary faces (== nFaces - nInternalFaces)
const vectorField & faceCentres() const
label nInternalFaces() const noexcept
Number of internal faces.
label nPoints() const noexcept
Number of mesh points.
label nCells() const noexcept
Number of mesh cells.
label nFaces() const noexcept
Number of mesh faces.
int myProcNo() const noexcept
Return processor number.
This boundary condition enables processor communication across patches.
void repatch()
Re-patch the mesh.
splitCell * master() const
A class for managing temporary objects.
const word & name() const noexcept
The zone name.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
const polyBoundaryMesh & patches
Foam::PtrList< Foam::fvMesh > meshes(regionNames.size())
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
const labelIOList & zoneID
A HashTable to objects of type <T> with a labelPair key. The hashing is based on labelPair (FixedList...
#define WarningInFunction
Report a warning using Foam::Warning.
auto key(const Type &t) -> typename std::enable_if< std::is_enum< Type >::value, typename std::underlying_type< Type >::type >::type
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
Pair< label > labelPair
A pair of labels.
List< word > wordList
A List of words.
const dimensionSet dimless
Dimensionless.
labelList identity(const label len, label start=0)
Return an identity map of the given length with (map[i] == i)
void inplaceRenumber(const labelUList &oldToNew, IntListType &input)
Inplace renumber the values (not the indices) of a list.
dimensionedScalar sign(const dimensionedScalar &ds)
List< label > labelList
A List of labels.
quaternion normalised(const quaternion &q)
Return the normalised (unit) quaternion of the given quaternion.
ZoneMesh< cellZone, polyMesh > cellZoneMesh
A ZoneMesh with the type cellZone.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
ZoneMesh< pointZone, polyMesh > pointZoneMesh
A ZoneMesh with the type pointZone.
IntListType renumber(const labelUList &oldToNew, const IntListType &input)
Renumber the values (not the indices) of a list.
vectorField pointField
pointField is a vectorField.
ZoneMesh< faceZone, polyMesh > faceZoneMesh
A ZoneMesh with the type faceZone.
Ostream & endl(Ostream &os)
Add newline and flush stream.
HashTable< label, labelPair, Foam::Hash< labelPair > > labelPairLookup
This is a Map of a labelPair to a label. Used for e.g. for face1, face2 to shared edge....
void inplaceReorder(const labelUList &oldToNew, ListType &input, const bool prune=false)
Inplace reorder the elements of a list.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
List< labelList > labelListList
A List of labelList.
void reduce(const List< UPstream::commsStruct > &comms, T &value, const BinaryOp &bop, const int tag, const label comm)
labelList sortedOrder(const UList< T > &input)
Return the (stable) sort order for the list.
GeometricField< sphericalTensor, fvPatchField, volMesh > volSphericalTensorField
FlatOutput::OutputAdaptor< Container, Delimiters > flatOutput(const Container &obj, Delimiters delim)
Global flatOutput() function with specified output delimiters.
errorManip< error > abort(error &err)
static constexpr const zero Zero
Global zero (0)
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
List< face > faceList
A List of faces.
PrimitivePatch< IndirectList< face >, const pointField & > indirectPrimitivePatch
A PrimitivePatch with an IndirectList for the faces, const reference for the point field.
errorManipArg< error, int > exit(error &err, const int errNo=1)
UIndirectList< label > labelUIndList
UIndirectList of labels.
dimensionedScalar cos(const dimensionedScalar &ds)
constexpr char nl
The newline '\n' character (0x0a)
#define forAll(list, i)
Loop across all elements in list.
#define forAllReverse(list, i)
Reverse loop across all elements in list.
static const char *const typeName
The type name used in ensight case files.