62 referPatchID_(referPatchID),
63 referNbrPatchID_(referNbrPatchID)
69 if (nbrProc_[a] < nbrProc_[
b])
73 else if (nbrProc_[a] > nbrProc_[
b])
79 else if (referPatchID_[a] == -1)
83 else if (referPatchID_[
b] == -1)
93 return referPatchID_[a] < referPatchID_[
b];
97 return referNbrPatchID_[a] < referNbrPatchID_[
b];
107 void Foam::fvMeshDistribute::inplaceRenumberWithFlip
110 const bool oldToNewHasFlip,
111 const bool lstHasFlip,
115 if (!lstHasFlip && !oldToNewHasFlip)
126 label val = lst[elemI];
142 <<
"Problem : zero value " << val
143 <<
" at index " << elemI <<
" out of " << lst.size()
150 label newVal = oldToNew[val];
166 <<
"Problem : zero value " << newVal
167 <<
" at index " << elemI <<
" out of "
175 lst[elemI] =
sign*(newVal+1);
183 const bool selectEqual,
192 if (selectEqual == (values[i] == value))
203 if (selectEqual == (values[i] == value))
214 const word& typeName,
225 nFields += checkEqualWordList(typeName,
fieldNames);
232 Foam::label Foam::fvMeshDistribute::checkEqualWordList
234 const word& typeName,
245 if (allNames[proci] != allNames[0])
248 <<
"When checking for equal numbers of " << typeName
250 <<
"processor0 has:" << allNames[0] <<
nl
251 <<
"processor" << proci <<
" has:" << allNames[proci] <<
nl
252 << typeName <<
" need to be synchronised on all processors."
268 HashSet<word> mergedNames;
271 forAll(allNames[proci], i)
273 mergedNames.insert(allNames[proci][i]);
276 return mergedNames.toc();
282 Pout<<
"Primitives:" <<
nl
286 <<
" faces :" << mesh.
nFaces() <<
nl
287 <<
" cells :" << mesh.
nCells() <<
nl;
297 <<
" size:" << pp.size()
298 <<
" start:" << pp.
start()
299 <<
" type:" << pp.type()
309 Pout<<
" " << zoneI <<
" name:" << pz.
name()
310 <<
" size:" << pz.
size()
320 Pout<<
" " << zoneI <<
" name:" << fz.
name()
321 <<
" size:" << fz.
size()
331 Pout<<
" " << zoneI <<
" name:" << cz.
name()
332 <<
" size:" << cz.
size()
349 <<
"Current coupling info:"
352 forAll(sourceFace, bFacei)
356 Pout<<
" meshFace:" << meshFacei
358 <<
" connects to proc:" << sourceProc[bFacei]
359 <<
"/face:" << sourceFace[bFacei]
360 <<
" which will move to proc:" << sourceNewNbrProc[bFacei]
366 Foam::label Foam::fvMeshDistribute::findInternalPatch()
const
370 label internalPatchi = -1;
376 if (isA<internalPolyPatch>(pp))
383 if (internalPatchi == -1)
386 <<
"Cannot find a internal patch in " <<
patches.names() <<
nl
388 <<
" An internal patch must be provided for the exposed "
394 Pout<<
"findInternalPatch : using patch " << internalPatchi
395 <<
" name:" <<
patches[internalPatchi].name()
396 <<
" type:" <<
patches[internalPatchi].type()
397 <<
" for the exposed internal faces." <<
endl;
402 label procPatchi = -1;
410 else if (procPatchi != -1)
413 <<
"Processor patches should be at end of patch list."
415 <<
"Have processor patch " << procPatchi
416 <<
" followed by non-processor patch " <<
patchi
417 <<
" in patches " <<
patches.names()
422 return internalPatchi;
425 Foam::label Foam::fvMeshDistribute::findNonEmptyPatch()
const
427 const polyBoundaryMesh&
patches = mesh_.boundaryMesh();
429 label nonEmptyPatchi = -1;
435 if (!isA<emptyPolyPatch>(pp) && !pp.coupled())
442 if (nonEmptyPatchi == -1)
445 <<
"Cannot find a non-empty patch in " <<
patches.names() <<
nl
447 <<
" An non-empty patch must be provided for the exposed "
453 Pout<<
"findNonEmptyPatch : using patch " << nonEmptyPatchi
454 <<
" name:" <<
patches[nonEmptyPatchi].name()
455 <<
" type:" <<
patches[nonEmptyPatchi].type()
456 <<
" for the exposed non-empty faces." <<
endl;
459 return nonEmptyPatchi;
465 const label destinationPatch
470 labelList newPatchID(mesh_.nFaces() - mesh_.nInternalFaces(), -1);
474 const polyPatch& pp = mesh_.boundaryMesh()[
patchi];
476 if (isA<processorPolyPatch>(pp))
480 Pout<<
"Moving all faces of patch " << pp.
name()
481 <<
" into patch " << destinationPatch
485 label offset = pp.start() - mesh_.nInternalFaces();
489 newPatchID[
offset+i] = destinationPatch;
498 autoPtr<polyTopoChangeMap> map = repatch(newPatchID, dummyFaceMaps);
508 if (!isA<processorPolyPatch>(mesh_.boundaryMesh()[
patchi]))
510 oldToNew[
patchi] = newI++;
513 label nNonProcPatches = newI;
518 if (isA<processorPolyPatch>(mesh_.boundaryMesh()[
patchi]))
520 oldToNew[
patchi] = newI++;
536 polyTopoChange meshMod(mesh_);
538 forAll(newPatchID, bFacei)
540 if (newPatchID[bFacei] != -1)
542 label facei = mesh_.nInternalFaces() + bFacei;
544 label zoneID = mesh_.faceZones().whichZone(facei);
545 bool zoneFlip =
false;
549 const faceZone& fZone = mesh_.faceZones()[zoneID];
550 zoneFlip = fZone.flipMap()[fZone.whichFace(facei)];
557 mesh_.faces()[facei],
559 mesh_.faceOwner()[facei],
576 PtrList<FieldField<fvsPatchField, scalar>> sFields;
577 saveBoundaryFields<scalar, surfaceMesh>(sFields);
578 PtrList<FieldField<fvsPatchField, vector>> vFields;
579 saveBoundaryFields<vector, surfaceMesh>(vFields);
580 PtrList<FieldField<fvsPatchField, sphericalTensor>> sptFields;
581 saveBoundaryFields<sphericalTensor, surfaceMesh>(sptFields);
582 PtrList<FieldField<fvsPatchField, symmTensor>> sytFields;
583 saveBoundaryFields<symmTensor, surfaceMesh>(sytFields);
584 PtrList<FieldField<fvsPatchField, tensor>> tFields;
585 saveBoundaryFields<tensor, surfaceMesh>(tFields);
594 autoPtr<polyTopoChangeMap> map = meshMod.changeMesh(mesh_,
false,
true);
597 mesh_.mapFields(map);
601 mapBoundaryFields<scalar, surfaceMesh>(map, sFields);
602 mapBoundaryFields<vector, surfaceMesh>(map, vFields);
603 mapBoundaryFields<sphericalTensor, surfaceMesh>(map, sptFields);
604 mapBoundaryFields<symmTensor, surfaceMesh>(map, sytFields);
605 mapBoundaryFields<tensor, surfaceMesh>(map, tFields);
616 <<
"reverseFaceMap contains -1 at index:"
618 <<
"This means that the repatch operation was not just"
623 forAll(constructFaceMap, proci)
625 inplaceRenumberWithFlip
627 map().reverseFaceMap(),
630 constructFaceMap[proci]
649 forAll(pointToGlobalMaster, pointi)
651 if (pointToGlobalMaster[pointi] != -1)
657 Map<label> globalMasterToLocalMaster(2*nShared);
658 Map<label> pointToMaster(2*nShared);
660 forAll(pointToGlobalMaster, pointi)
662 label globali = pointToGlobalMaster[pointi];
670 if (iter == globalMasterToLocalMaster.end())
673 globalMasterToLocalMaster.insert(globali, pointi);
674 pointToMaster.insert(pointi, pointi);
678 pointToMaster.insert(pointi, iter());
683 if (
returnReduce(pointToMaster.size(), sumOp<label>()) == 0)
685 return autoPtr<polyTopoChangeMap>(
nullptr);
689 polyTopoChange meshMod(mesh_);
692 forAll(mesh_.points(), pointi)
696 if (iter != pointToMaster.end())
698 if (iter() != pointi)
700 meshMod.removePoint(pointi, iter());
707 const faceList& faces = mesh_.faces();
711 const face&
f = faces[facei];
713 bool hasMerged =
false;
721 if (iter != pointToMaster.end())
723 if (iter() != pointi)
740 pointToMaster.find(pointi);
742 if (iter != pointToMaster.end())
748 label patchID = mesh_.boundaryMesh().whichPatch(facei);
749 label nei = (patchID == -1 ? mesh_.faceNeighbour()[facei] : -1);
750 label zoneID = mesh_.faceZones().whichZone(facei);
751 bool zoneFlip =
false;
755 const faceZone& fZone = mesh_.faceZones()[zoneID];
756 zoneFlip = fZone.flipMap()[fZone.whichFace(facei)];
765 mesh_.faceOwner()[facei],
779 autoPtr<polyTopoChangeMap> map = meshMod.changeMesh(mesh_,
false,
true);
782 mesh_.mapFields(map);
785 forAll(constructPointMap, proci)
787 labelList& constructMap = constructPointMap[proci];
791 label oldPointi = constructMap[i];
806 <<
"Problem. oldPointi:" << oldPointi
816 void Foam::fvMeshDistribute::getCouplingData
830 label nBnd = mesh_.nFaces() - mesh_.nInternalFaces();
831 sourceFace.setSize(nBnd);
832 sourceProc.setSize(nBnd);
833 sourcePatch.setSize(nBnd);
834 sourceNbrPatch.setSize(nBnd);
835 sourceNewNbrProc.setSize(nBnd);
837 const polyBoundaryMesh&
patches = mesh_.boundaryMesh();
849 label offset = pp.start() - mesh_.nInternalFaces();
855 nbrFaces[bndI] = pp.start()+i;
859 SubList<label>(nbrNewNbrProc, pp.size(),
offset) =
860 UIndirectList<label>(distribution, pp.faceCells())();
873 label offset = pp.start() - mesh_.nInternalFaces();
875 if (isA<processorPolyPatch>(pp))
877 const processorPolyPatch& procPatch =
878 refCast<const processorPolyPatch>(pp);
882 if (procPatch.owner())
888 sourceFace[bndI] = pp.start()+i;
890 sourceNewNbrProc[bndI] = nbrNewNbrProc[bndI];
899 sourceFace[bndI] = nbrFaces[bndI];
900 sourceProc[bndI] = procPatch.neighbProcNo();
901 sourceNewNbrProc[bndI] = nbrNewNbrProc[bndI];
907 if (isA<processorCyclicPolyPatch>(pp))
910 refCast<const processorCyclicPolyPatch>(pp)
921 sourcePatch[bndI] =
patchi;
922 sourceNbrPatch[bndI] = nbrPatchi;
925 else if (isA<cyclicPolyPatch>(pp))
927 const cyclicPolyPatch& cpp = refCast<const cyclicPolyPatch>(pp);
934 sourceFace[bndI] = pp.start()+i;
936 sourcePatch[bndI] =
patchi;
937 sourceNbrPatch[bndI] = cpp.nbrPatchID();
938 sourceNewNbrProc[bndI] = nbrNewNbrProc[bndI];
946 sourceFace[bndI] = nbrFaces[bndI];
948 sourcePatch[bndI] =
patchi;
949 sourceNbrPatch[bndI] = cpp.nbrPatchID();
950 sourceNewNbrProc[bndI] = nbrNewNbrProc[bndI];
960 sourceFace[bndI] = -1;
961 sourceProc[bndI] = -1;
962 sourcePatch[bndI] =
patchi;
963 sourceNbrPatch[bndI] = -1;
964 sourceNewNbrProc[bndI] = -1;
971 sourcePointMaster.setSize(mesh_.nPoints());
972 sourcePointMaster = -1;
975 const globalIndex globalPoints(mesh_.nPoints());
977 const globalMeshData& gmd = mesh_.globalData();
979 const labelList& meshPoints = cpp.meshPoints();
980 const distributionMap& slavesMap = gmd.globalCoPointSlavesMap();
983 labelList elems(slavesMap.constructSize(), -1);
984 forAll(meshPoints, pointi)
992 label globalPointi = globalPoints.toGlobal(meshPoints[pointi]);
993 elems[pointi] = globalPointi;
996 label sloti = slots[i];
997 if (sloti >= meshPoints.size())
1001 elems[slots[i]] = globalPointi;
1008 slavesMap.reverseDistribute(elems.size(), elems,
false);
1011 forAll(meshPoints, pointi)
1013 sourcePointMaster[meshPoints[pointi]] = elems[pointi];
1019 void Foam::fvMeshDistribute::subsetCouplingData
1029 const label oldInternalFaces,
1046 subFace.setSize(mesh.nFaces() - mesh.nInternalFaces());
1047 subProc.setSize(mesh.nFaces() - mesh.nInternalFaces());
1048 subPatch.setSize(mesh.nFaces() - mesh.nInternalFaces());
1049 subNbrPatch.setSize(mesh.nFaces() - mesh.nInternalFaces());
1050 subNewNbrProc.setSize(mesh.nFaces() - mesh.nInternalFaces());
1052 forAll(subFace, newBFacei)
1054 label newFacei = newBFacei + mesh.nInternalFaces();
1059 if (oldFacei < oldInternalFaces)
1061 subFace[newBFacei] = oldFacei;
1063 subPatch[newBFacei] = -1;
1065 label oldOwn = oldFaceOwner[oldFacei];
1066 label oldNei = oldFaceNeighbour[oldFacei];
1068 if (oldOwn == cellMap[mesh.faceOwner()[newFacei]])
1071 subNewNbrProc[newBFacei] = oldDistribution[oldNei];
1076 subNewNbrProc[newBFacei] = oldDistribution[oldOwn];
1082 label oldBFacei = oldFacei - oldInternalFaces;
1084 subFace[newBFacei] = sourceFace[oldBFacei];
1085 subProc[newBFacei] = sourceProc[oldBFacei];
1086 subPatch[newBFacei] = sourcePatch[oldBFacei];
1087 subNbrPatch[newBFacei] = sourceNbrPatch[oldBFacei];
1088 subNewNbrProc[newBFacei] = sourceNewNbrProc[oldBFacei];
1093 subPointMaster = UIndirectList<label>(sourcePointMaster, pointMap);
1097 void Foam::fvMeshDistribute::findCouples
1099 const primitiveMesh& mesh,
1105 const primitiveMesh& domainMesh,
1116 HashTable<label, labelPair, labelPair::Hash<>> map(domainFace.size());
1118 forAll(domainProc, bFacei)
1120 if (domainProc[bFacei] != -1 && domainPatch[bFacei] == -1)
1124 labelPair(domainFace[bFacei], domainProc[bFacei]),
1133 masterCoupledFaces.setSize(domainFace.size());
1134 slaveCoupledFaces.setSize(domainFace.size());
1137 forAll(sourceFace, bFacei)
1139 if (sourceProc[bFacei] != -1 && sourcePatch[bFacei] == -1)
1141 labelPair myData(sourceFace[bFacei], sourceProc[bFacei]);
1143 HashTable<label, labelPair, labelPair::Hash<>>::const_iterator
1144 iter = map.find(myData);
1146 if (iter != map.end())
1148 label nbrBFacei = iter();
1150 masterCoupledFaces[coupledI] = mesh.nInternalFaces() + bFacei;
1151 slaveCoupledFaces[coupledI] =
1152 domainMesh.nInternalFaces()
1160 masterCoupledFaces.setSize(coupledI);
1161 slaveCoupledFaces.setSize(coupledI);
1165 Pout<<
"findCouples : found " << coupledI
1166 <<
" faces that will be stitched" <<
nl <<
endl;
1173 const primitiveMesh& mesh,
1174 const mapAddedPolyMesh& map,
1176 const label nInternalFaces1,
1180 labelList newBoundaryData(mesh.nFaces() - mesh.nInternalFaces());
1182 forAll(boundaryData0, oldBFacei)
1184 label newFacei = map.oldFaceMap()[oldBFacei + map.nOldInternalFaces()];
1187 if (newFacei >= 0 && newFacei >= mesh.nInternalFaces())
1189 newBoundaryData[newFacei - mesh.nInternalFaces()] =
1190 boundaryData0[oldBFacei];
1194 forAll(boundaryData1, addedBFacei)
1196 label newFacei = map.addedFaceMap()[addedBFacei + nInternalFaces1];
1198 if (newFacei >= 0 && newFacei >= mesh.nInternalFaces())
1200 newBoundaryData[newFacei - mesh.nInternalFaces()] =
1201 boundaryData1[addedBFacei];
1205 return newBoundaryData;
1211 const primitiveMesh& mesh,
1212 const mapAddedPolyMesh& map,
1217 labelList newBoundaryData(mesh.nPoints());
1219 forAll(boundaryData0, oldPointi)
1226 newBoundaryData[
newPointi] = boundaryData0[oldPointi];
1230 forAll(boundaryData1, addedPointi)
1236 newBoundaryData[
newPointi] = boundaryData1[addedPointi];
1240 return newBoundaryData;
1247 const label oldInternalPatchi
1251 polyTopoChange meshMod(mesh_);
1255 removeCells cellRemover(mesh_,
false);
1258 labelList exposedFaces(cellRemover.getExposedFaces(cellsToRemove));
1261 cellRemover.setRefinement
1265 labelList(exposedFaces.size(), oldInternalPatchi),
1272 PtrList<Field<scalar>> sFields;
1273 PtrList<Field<vector>> vFields;
1274 PtrList<Field<sphericalTensor>> sptFields;
1275 PtrList<Field<symmTensor>> sytFields;
1276 PtrList<Field<tensor>> tFields;
1277 initMapExposedFaces(sFields);
1278 initMapExposedFaces(vFields);
1279 initMapExposedFaces(sptFields);
1280 initMapExposedFaces(sytFields);
1281 initMapExposedFaces(tFields);
1284 autoPtr<polyTopoChangeMap> map = meshMod.changeMesh(mesh_,
false,
false);
1287 mesh_.mapFields(map);
1292 mapExposedFaces(map(), sFields);
1293 mapExposedFaces(map(), vFields);
1294 mapExposedFaces(map(), sptFields);
1295 mapExposedFaces(map(), sytFields);
1296 mapExposedFaces(map(), tFields);
1302 void Foam::fvMeshDistribute::addProcPatches
1307 List<Map<label>>& procPatchID
1323 lessProcPatches(nbrProc, referPatchID, referNbrPatchID)
1330 label bFacei = indices[i];
1331 label proci = nbrProc[bFacei];
1335 if (!procPatchID[proci].
found(referPatchID[bFacei]))
1340 if (referPatchID[bFacei] == -1)
1344 processorPolyPatch pp
1348 mesh_.boundaryMesh().size(),
1349 mesh_.boundaryMesh(),
1354 procPatchID[proci].insert
1356 referPatchID[bFacei],
1369 const coupledPolyPatch& pcPatch
1370 = refCast<const coupledPolyPatch>
1372 mesh_.boundaryMesh()[referPatchID[bFacei]]
1374 processorCyclicPolyPatch pp
1378 mesh_.boundaryMesh().size(),
1379 mesh_.boundaryMesh(),
1385 procPatchID[proci].insert
1387 referPatchID[bFacei],
1408 const List<Map<label>>& procPatchID
1417 label origPatchi = referPatchID[bFacei];
1418 patchIDs[bFacei] = origPatchi;
1420 else if (nbrProc[bFacei] != -1)
1422 label origPatchi = referPatchID[bFacei];
1423 patchIDs[bFacei] = procPatchID[nbrProc[bFacei]][origPatchi];
1427 patchIDs[bFacei] = -1;
1434 void Foam::fvMeshDistribute::sendMesh
1454 Pout<<
"Sending to domain " << domain <<
nl
1455 <<
" nPoints:" << mesh.nPoints() <<
nl
1456 <<
" nFaces:" << mesh.nFaces() <<
nl
1457 <<
" nCells:" << mesh.nCells() <<
nl
1458 <<
" nPatches:" << mesh.boundaryMesh().size() <<
nl
1464 CompactListList<label> zonePoints;
1468 labelList rowSizes(pointZoneNames.size(), 0);
1470 forAll(pointZoneNames, nameI)
1472 label myZoneID = pointZones.findZoneID(pointZoneNames[nameI]);
1476 rowSizes[nameI] = pointZones[myZoneID].size();
1479 zonePoints.setSize(rowSizes);
1481 forAll(pointZoneNames, nameI)
1483 label myZoneID = pointZones.findZoneID(pointZoneNames[nameI]);
1487 zonePoints[nameI].deepCopy(pointZones[myZoneID]);
1493 CompactListList<label> zoneFaces;
1494 CompactListList<bool> zoneFaceFlip;
1498 labelList rowSizes(faceZoneNames.size(), 0);
1500 forAll(faceZoneNames, nameI)
1502 label myZoneID = faceZones.findZoneID(faceZoneNames[nameI]);
1506 rowSizes[nameI] = faceZones[myZoneID].size();
1510 zoneFaces.setSize(rowSizes);
1511 zoneFaceFlip.setSize(rowSizes);
1513 forAll(faceZoneNames, nameI)
1515 label myZoneID = faceZones.findZoneID(faceZoneNames[nameI]);
1519 zoneFaces[nameI].deepCopy(faceZones[myZoneID]);
1520 zoneFaceFlip[nameI].deepCopy(faceZones[myZoneID].flipMap());
1526 CompactListList<label> zoneCells;
1530 labelList rowSizes(cellZoneNames.size(), 0);
1532 forAll(cellZoneNames, nameI)
1534 label myZoneID = cellZones.findZoneID(cellZoneNames[nameI]);
1538 rowSizes[nameI] = cellZones[myZoneID].size();
1542 zoneCells.setSize(rowSizes);
1544 forAll(cellZoneNames, nameI)
1546 label myZoneID = cellZones.findZoneID(cellZoneNames[nameI]);
1550 zoneCells[nameI].deepCopy(cellZones[myZoneID]);
1572 << CompactListList<label>(mesh.faces())
1574 << mesh.faceNeighbour()
1575 << mesh.boundaryMesh()
1591 << sourcePointMaster;
1596 Pout<<
"Started sending mesh to domain " << domain
1608 const Time& runTime,
1619 faceList domainFaces = CompactListList<label>(fromNbr).list<face>();
1622 PtrList<entry> patchEntries(fromNbr);
1624 CompactListList<label> zonePoints(fromNbr);
1625 CompactListList<label> zoneFaces(fromNbr);
1626 CompactListList<bool> zoneFaceFlip(fromNbr);
1627 CompactListList<label> zoneCells(fromNbr);
1632 >> domainSourcePatch
1633 >> domainSourceNbrPatch
1634 >> domainSourceNewNbrProc
1635 >> domainSourcePointMaster;
1638 autoPtr<fvMesh> domainMeshPtr
1651 move(domainAllOwner),
1652 move(domainAllNeighbour),
1656 fvMesh& domainMesh = domainMeshPtr();
1658 List<polyPatch*>
patches(patchEntries.size());
1664 patchEntries[
patchi].keyword(),
1667 domainMesh.boundaryMesh()
1671 domainMesh.addFvPatches(
patches,
false);
1674 List<pointZone*> pZonePtrs(pointZoneNames.size());
1677 pZonePtrs[i] =
new pointZone
1682 domainMesh.pointZones()
1686 List<faceZone*> fZonePtrs(faceZoneNames.size());
1689 fZonePtrs[i] =
new faceZone
1695 domainMesh.faceZones()
1699 List<cellZone*> cZonePtrs(cellZoneNames.size());
1702 cZonePtrs[i] =
new cellZone
1707 domainMesh.cellZones()
1710 domainMesh.addZones(pZonePtrs, fZonePtrs, cZonePtrs);
1712 return domainMeshPtr;
1741 <<
"At index " << celli <<
" distribution:" << newProc
1759 <<
"Size of distribution:"
1768 if (
patches.checkParallelSync(
true))
1771 <<
"This application requires all non-processor patches"
1772 <<
" to be present in the same order on all patches" <<
nl
1773 <<
"followed by the processor patches (which of course are unique)."
1775 <<
"Local patches:" << mesh_.boundaryMesh().names()
1780 const label nOldPoints(mesh_.nPoints());
1781 const label nOldFaces(mesh_.nFaces());
1782 const label nOldCells(mesh_.nCells());
1805 move(oldPatchStarts),
1806 move(oldPatchNMeshPoints),
1823 const wordList pointZoneNames(mergeWordList(mesh_.pointZones().names()));
1824 const wordList faceZoneNames(mergeWordList(mesh_.faceZones().names()));
1825 const wordList cellZoneNames(mergeWordList(mesh_.cellZones().names()));
1887 mesh_.resetMotion();
1979 const label oldInternalPatchi =
1981 ? findInternalPatch()
1982 : findNonEmptyPatch();
1989 deleteProcPatches(oldInternalPatchi);
1992 repatchFaceMap = repatchMap().faceMap();
1999 repatchMap().reverseFaceMap(),
2000 mesh_.nFaces() - mesh_.nInternalFaces(),
2001 mesh_.nInternalFaces()
2003 - mesh_.nInternalFaces()
2018 Pout<<
nl <<
"MESH WITH PROC PATCHES DELETED:" <<
endl;
2019 printMeshInfo(mesh_);
2020 printFieldInfo<volScalarField>(mesh_);
2021 printFieldInfo<volVectorField>(mesh_);
2022 printFieldInfo<volSphericalTensorField>(mesh_);
2023 printFieldInfo<volSymmTensorField>(mesh_);
2024 printFieldInfo<volTensorField>(mesh_);
2025 printFieldInfo<surfaceScalarField>(mesh_);
2026 printFieldInfo<surfaceVectorField>(mesh_);
2027 printFieldInfo<surfaceSphericalTensorField>(mesh_);
2028 printFieldInfo<surfaceSymmTensorField>(mesh_);
2029 printFieldInfo<surfaceTensorField>(mesh_);
2030 printFieldInfo<pointScalarField>(mesh_);
2031 printFieldInfo<pointVectorField>(mesh_);
2032 printFieldInfo<pointSphericalTensorField>(mesh_);
2033 printFieldInfo<pointSymmTensorField>(mesh_);
2034 printFieldInfo<pointTensorField>(mesh_);
2086 <<
"SUBSETTING FOR DOMAIN " << recvProc
2087 <<
" cells to send:"
2108 subCellMap[recvProc] = subsetter.
cellMap();
2110 inplaceRenumberWithFlip
2115 subFaceMap[recvProc]
2117 subPointMap[recvProc] = subsetter.
pointMap();
2118 subPatchMap[recvProc] = subsetter.
patchMap();
2138 mesh_.faceNeighbour(),
2139 mesh_.nInternalFaces(),
2152 procSourceNewNbrProc,
2153 procSourcePointMaster
2171 procSourceNewNbrProc,
2172 procSourcePointMaster,
2178 sendFields<volScalarField>(recvProc, volScalars, subsetter, str);
2179 sendFields<volVectorField>(recvProc, volVectors, subsetter, str);
2180 sendFields<volSphericalTensorField>
2187 sendFields<volSymmTensorField>
2194 sendFields<volTensorField>(recvProc, volTensors, subsetter, str);
2197 sendFields<surfaceScalarField>
2204 sendFields<surfaceVectorField>
2211 sendFields<surfaceSphericalTensorField>
2218 sendFields<surfaceSymmTensorField>
2225 sendFields<surfaceTensorField>
2234 sendFields<pointScalarField>
2241 sendFields<pointVectorField>
2248 sendFields<pointSphericalTensorField>
2255 sendFields<pointSymmTensorField>
2262 sendFields<pointTensorField>
2271 sendFields<volScalarField::Internal>
2278 sendFields<volVectorField::Internal>
2285 sendFields<volSphericalTensorField::Internal>
2292 sendFields<volSymmTensorField::Internal>
2299 sendFields<volTensorField::Internal>
2322 const labelList oldFaceOwner(mesh_.faceOwner());
2323 const labelList oldFaceNeighbour(mesh_.faceNeighbour());
2324 const label oldInternalFaces = mesh_.nInternalFaces();
2352 label facei = iter.key();
2376 subMap().pointMap(),
2395 domainSourceNbrPatch,
2396 domainSourceNewNbrProc,
2397 domainSourcePointMaster
2400 sourceFace.
transfer(domainSourceFace);
2401 sourceProc.
transfer(domainSourceProc);
2402 sourcePatch.
transfer(domainSourcePatch);
2403 sourceNbrPatch.
transfer(domainSourceNbrPatch);
2404 sourceNewNbrProc.
transfer(domainSourceNewNbrProc);
2405 sourcePointMaster.
transfer(domainSourcePointMaster);
2413 printMeshInfo(mesh_);
2414 printFieldInfo<volScalarField>(mesh_);
2415 printFieldInfo<volVectorField>(mesh_);
2416 printFieldInfo<volSphericalTensorField>(mesh_);
2417 printFieldInfo<volSymmTensorField>(mesh_);
2418 printFieldInfo<volTensorField>(mesh_);
2419 printFieldInfo<surfaceScalarField>(mesh_);
2420 printFieldInfo<surfaceVectorField>(mesh_);
2421 printFieldInfo<surfaceSphericalTensorField>(mesh_);
2422 printFieldInfo<surfaceSymmTensorField>(mesh_);
2423 printFieldInfo<surfaceTensorField>(mesh_);
2424 printFieldInfo<pointScalarField>(mesh_);
2425 printFieldInfo<pointVectorField>(mesh_);
2426 printFieldInfo<pointSphericalTensorField>(mesh_);
2427 printFieldInfo<pointSymmTensorField>(mesh_);
2428 printFieldInfo<pointTensorField>(mesh_);
2440 forAll(nSendCells, sendProc)
2452 <<
"RECEIVING FROM DOMAIN " << sendProc
2453 <<
" cells to receive:"
2500 domainMeshPtr = receiveMesh
2507 const_cast<Time&
>(mesh_.time()),
2511 domainSourceNbrPatch,
2512 domainSourceNewNbrProc,
2513 domainSourcePointMaster,
2516 fvMesh& domainMesh = domainMeshPtr();
2526 receiveFields<volScalarField>
2534 receiveFields<volVectorField>
2542 receiveFields<volSphericalTensorField>
2550 receiveFields<volSymmTensorField>
2558 receiveFields<volTensorField>
2568 receiveFields<surfaceScalarField>
2576 receiveFields<surfaceVectorField>
2584 receiveFields<surfaceSphericalTensorField>
2592 receiveFields<surfaceSymmTensorField>
2600 receiveFields<surfaceTensorField>
2612 receiveFields<pointScalarField>
2620 receiveFields<pointVectorField>
2628 receiveFields<pointSphericalTensorField>
2636 receiveFields<pointSymmTensorField>
2644 receiveFields<pointTensorField>
2654 receiveFields<volScalarField::Internal>
2665 receiveFields<volVectorField::Internal>
2676 receiveFields<volSphericalTensorField::Internal>
2688 receiveFields<volSymmTensorField::Internal>
2699 receiveFields<volTensorField::Internal>
2711 const fvMesh& domainMesh = domainMeshPtr();
2717 constructPatchMap[sendProc] =
2724 Pout<<
nl <<
"RECEIVED MESH FROM:" << sendProc <<
endl;
2725 printMeshInfo(domainMesh);
2726 printFieldInfo<volScalarField>(domainMesh);
2727 printFieldInfo<volVectorField>(domainMesh);
2728 printFieldInfo<volSphericalTensorField>(domainMesh);
2729 printFieldInfo<volSymmTensorField>(domainMesh);
2730 printFieldInfo<volTensorField>(domainMesh);
2731 printFieldInfo<surfaceScalarField>(domainMesh);
2732 printFieldInfo<surfaceVectorField>(domainMesh);
2733 printFieldInfo<surfaceSphericalTensorField>(domainMesh);
2734 printFieldInfo<surfaceSymmTensorField>(domainMesh);
2735 printFieldInfo<surfaceTensorField>(domainMesh);
2736 printFieldInfo<pointScalarField>(domainMesh);
2737 printFieldInfo<pointVectorField>(domainMesh);
2738 printFieldInfo<pointSphericalTensorField>(domainMesh);
2739 printFieldInfo<pointSymmTensorField>(domainMesh);
2740 printFieldInfo<pointTensorField>(domainMesh);
2794 sourceFace = mapBoundaryData
2802 sourceProc = mapBoundaryData
2810 sourcePatch = mapBoundaryData
2818 sourceNbrPatch = mapBoundaryData
2824 domainSourceNbrPatch
2826 sourceNewNbrProc = mapBoundaryData
2832 domainSourceNewNbrProc
2835 sourcePointMaster = mapPointData
2840 domainSourcePointMaster
2846 const labelList& oldCellMap = map().oldCellMap();
2847 const labelList& oldFaceMap = map().oldFaceMap();
2848 const labelList& oldPointMap = map().oldPointMap();
2849 const labelList& oldPatchMap = map().oldPatchMap();
2852 forAll(constructPatchMap, proci)
2854 if (proci != sendProc && constructPatchMap[proci].size())
2858 inplaceRenumberWithFlip
2863 constructFaceMap[proci]
2876 flippedAddedFaces.
resize(nBnd/4);
2881 domainFacei < domainMesh.
nFaces();
2885 label newFacei = map().addedFaceMap()[domainFacei];
2886 label newCellI = mesh_.faceOwner()[newFacei];
2890 if (newCellI != map().addedCellMap()[domainCellI])
2892 flippedAddedFaces.
insert(domainFacei);
2903 label domainFacei = iter.key();
2904 label& val = constructFaceMap[sendProc][domainFacei];
2907 inplaceRenumberWithFlip
2909 map().addedFaceMap(),
2912 constructFaceMap[sendProc]
2919 Pout<<
nl <<
"MERGED MESH FROM:" << sendProc <<
endl;
2920 printMeshInfo(mesh_);
2921 printFieldInfo<volScalarField>(mesh_);
2922 printFieldInfo<volVectorField>(mesh_);
2923 printFieldInfo<volSphericalTensorField>(mesh_);
2924 printFieldInfo<volSymmTensorField>(mesh_);
2925 printFieldInfo<volTensorField>(mesh_);
2926 printFieldInfo<surfaceScalarField>(mesh_);
2927 printFieldInfo<surfaceVectorField>(mesh_);
2928 printFieldInfo<surfaceSphericalTensorField>(mesh_);
2929 printFieldInfo<surfaceSymmTensorField>(mesh_);
2930 printFieldInfo<surfaceTensorField>(mesh_);
2931 printFieldInfo<pointScalarField>(mesh_);
2932 printFieldInfo<pointVectorField>(mesh_);
2933 printFieldInfo<pointSphericalTensorField>(mesh_);
2934 printFieldInfo<pointSymmTensorField>(mesh_);
2935 printFieldInfo<pointTensorField>(mesh_);
2947 printMeshInfo(mesh_);
2948 printFieldInfo<volScalarField>(mesh_);
2949 printFieldInfo<volVectorField>(mesh_);
2950 printFieldInfo<volSphericalTensorField>(mesh_);
2951 printFieldInfo<volSymmTensorField>(mesh_);
2952 printFieldInfo<volTensorField>(mesh_);
2953 printFieldInfo<surfaceScalarField>(mesh_);
2954 printFieldInfo<surfaceVectorField>(mesh_);
2955 printFieldInfo<surfaceSphericalTensorField>(mesh_);
2956 printFieldInfo<surfaceSymmTensorField>(mesh_);
2957 printFieldInfo<surfaceTensorField>(mesh_);
2958 printFieldInfo<pointScalarField>(mesh_);
2959 printFieldInfo<pointVectorField>(mesh_);
2960 printFieldInfo<pointSphericalTensorField>(mesh_);
2961 printFieldInfo<pointSymmTensorField>(mesh_);
2962 printFieldInfo<pointTensorField>(mesh_);
2969 mergeSharedPoints(sourcePointMaster, constructPointMap);
2981 addProcPatches(sourceNewNbrProc, sourcePatch, sourceNbrPatch, procPatchID);
3000 repatch(newPatchID, constructFaceMap);
3003 correctCoupledPatchFields<volScalarField>();
3004 correctCoupledPatchFields<volVectorField>();
3005 correctCoupledPatchFields<volSphericalTensorField>();
3006 correctCoupledPatchFields<volSymmTensorField>();
3007 correctCoupledPatchFields<volTensorField>();
3009 mesh_.setInstance(mesh_.time().name());
3015 printMeshInfo(mesh_);
3016 printFieldInfo<volScalarField>(mesh_);
3017 printFieldInfo<volVectorField>(mesh_);
3018 printFieldInfo<volSphericalTensorField>(mesh_);
3019 printFieldInfo<volSymmTensorField>(mesh_);
3020 printFieldInfo<volTensorField>(mesh_);
3021 printFieldInfo<surfaceScalarField>(mesh_);
3022 printFieldInfo<surfaceVectorField>(mesh_);
3023 printFieldInfo<surfaceSphericalTensorField>(mesh_);
3024 printFieldInfo<surfaceSymmTensorField>(mesh_);
3025 printFieldInfo<surfaceTensorField>(mesh_);
3026 printFieldInfo<pointScalarField>(mesh_);
3027 printFieldInfo<pointVectorField>(mesh_);
3028 printFieldInfo<pointSphericalTensorField>(mesh_);
3029 printFieldInfo<pointSymmTensorField>(mesh_);
3030 printFieldInfo<pointTensorField>(mesh_);
3044 move(oldPatchStarts),
3045 move(oldPatchNMeshPoints),
3052 move(constructPointMap),
3053 move(constructFaceMap),
3054 move(constructCellMap),
3055 move(constructPatchMap),
#define forAll(list, i)
Loop across all elements in list.
#define forAllReverse(list, i)
Reverse loop across all elements in list.
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object of type.
static pointMesh & New(const polyMesh &mesh)
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
static const char *const typeName
bool insert(const Key &key)
Insert a new entry.
label size() const
Return number of elements in table.
void resize(const label newSize)
Resize the hash table for efficiency.
void transfer(List< T > &)
Transfer the contents of the argument List into this list.
void size(const label)
Override size to be inconsistent with allocated storage.
HashTable< label, label, Hash< label > >::const_iterator const_iterator
virtual const fileName & name() const
Return the name of the stream.
Buffers for inter-processor communications streams (UOPstream, UIPstream).
void finishedSends(const bool block=true)
Mark all sends as having been done. This will start receives.
static void scatterList(const List< commsStruct > &comms, List< T > &Values, const int tag, const label comm)
Scatter data. Reverse of gatherList.
static void gatherList(const List< commsStruct > &comms, List< T > &Values, const int tag, const label comm)
Gather data but keep individual values separate.
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
A List obtained as a section of another List.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Input inter-processor communications stream operating on external buffer.
Output inter-processor communications stream operating on external buffer.
static label nProcs(const label communicator=0)
Number of processes in parallel run.
static bool & parRun()
Is this a parallel run?
static int myProcNo(const label communicator=0)
Number of this process (starting from masterNo() = 0)
label size() const
Return the number of elements in the UPtrList.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
A bounding box defined in terms of the points at its extremities.
A list of keyword definitions, which are a keyword followed by any number of values (e....
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
Accumulating histogram of values. Specified bin resolution automatic generation of bins.
Container for information needed to couple to meshes. When constructed from two meshes and a list of ...
A subset of mesh faces organised as a primitive patch.
static autoPtr< mapAddedPolyMesh > add(fvMesh &mesh0, const fvMesh &mesh1, const faceCoupleInfo &coupleInfo, const bool validBoundary=true)
Inplace add mesh to fvMesh. Maps all stored fields. Returns map.
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.
fvMeshDistribute(fvMesh &mesh)
Construct from mesh.
autoPtr< polyDistributionMap > distribute(const labelList &dist)
Send cells to neighbours according to distribution.
static void printMeshInfo(const fvMesh &)
Print some info on mesh.
static labelList countCells(const labelList &)
Helper function: count cells per processor in wanted distribution.
Post-processing mesh subset tool. Given the original mesh and the list of selected cells,...
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.
void setLargeCellSubset(const labelList ®ion, const label currentRegion, const label patchID=-1, const bool syncCouples=true)
Set the subset from all cells with region == currentRegion.
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.
static const HashSet< word > geometryFields
Set of names of registered geometric fields.
Less function class that can be used for sorting processor patches.
lessProcPatches(const labelList &nbrProc, const labelList &referPatchID, const labelList &referNbrPatchID)
bool operator()(const label a, const label b)
const word & name() const
Return name.
Mesh representing a set of points created from polyMesh.
A subset of mesh points. The labels of points in the zone can be obtained from the addressing() list.
Class containing mesh-to-mesh mapping information after a mesh distribution where we send parts of me...
static word defaultRegion
Return the default region name.
const meshFaceZones & faceZones() const
Return face zones.
virtual const labelList & faceOwner() const
Return face owner.
const meshPointZones & pointZones() const
Return point zones.
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
virtual const pointField & points() const
Return raw points.
const meshCellZones & cellZones() const
Return cell zones.
A patch is a list of labels that address the faces in the global face list.
static autoPtr< polyPatch > New(const word &patchType, const word &name, const label size, const label start, const label index, const polyBoundaryMesh &bm)
Return a pointer to a new patch created on freestore from.
label start() const
Return start label of this patch in the polyMesh face list.
Cell-face mesh analysis engine.
const vectorField & faceCentres() const
label nInternalFaces() const
const word & name() const
Return name.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
static List< word > fieldNames
const fvPatchList & patches
errorManipArg< error, int > exit(error &err, const int errNo=1)
List< word > wordList
A List of words.
Pair< label > labelPair
Label pair.
List< label > labelList
A List of labels.
dimensionedScalar sign(const dimensionedScalar &ds)
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Ostream & endl(Ostream &os)
Add newline and flush stream.
errorManip< error > abort(error &err)
MeshZones< cellZone, polyMesh > meshCellZones
A MeshZones with the type cellZone.
ListType renumber(const labelUList &oldToNew, const ListType &)
Renumber the values (not the indices) of a list.
vectorField pointField
pointField is a vectorField.
MeshZones< pointZone, polyMesh > meshPointZones
A MeshZones with the type pointZone.
List< labelList > labelListList
A List of labelList.
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
defineTypeNameAndDebug(combustionModel, 0)
void inplaceRenumber(const labelUList &oldToNew, ListType &)
Inplace renumber the values of a list.
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
prefixOSstream Pout(cout, "Pout")
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurrence of given element and return index,.
MeshZones< faceZone, polyMesh > meshFaceZones
A MeshZones with the type faceZone.
labelList identityMap(const label len)
Create identity map (map[i] == i) of given length.
void sortedOrder(const UList< T > &, labelList &order)
Generate the (stable) sort order for the list.
void offset(label &lst, const label o)
PrimitivePatch< IndirectList< face >, const pointField & > indirectPrimitivePatch
Foam::indirectPrimitivePatch.
UList< label > labelUList
void inplaceReorder(const labelUList &oldToNew, ListType &)
Inplace reorder the elements of a list.