62 referPatchIndex_(referPatchID),
63 referNbrPatchIndex_(referNbrPatchID)
69 if (nbrProc_[a] < nbrProc_[
b])
73 else if (nbrProc_[a] > nbrProc_[
b])
79 else if (referPatchIndex_[a] == -1)
83 else if (referPatchIndex_[
b] == -1)
93 return referPatchIndex_[a] < referPatchIndex_[
b];
97 return referNbrPatchIndex_[a] < referNbrPatchIndex_[
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 const label facei = mesh_.nInternalFaces() + bFacei;
546 mesh_.faces()[facei],
548 mesh_.faceOwner()[facei],
561 PtrList<FieldField<fvsPatchField, scalar>> sFields;
562 saveBoundaryFields<scalar, surfaceMesh>(sFields);
563 PtrList<FieldField<fvsPatchField, vector>> vFields;
564 saveBoundaryFields<vector, surfaceMesh>(vFields);
565 PtrList<FieldField<fvsPatchField, sphericalTensor>> sptFields;
566 saveBoundaryFields<sphericalTensor, surfaceMesh>(sptFields);
567 PtrList<FieldField<fvsPatchField, symmTensor>> sytFields;
568 saveBoundaryFields<symmTensor, surfaceMesh>(sytFields);
569 PtrList<FieldField<fvsPatchField, tensor>> tFields;
570 saveBoundaryFields<tensor, surfaceMesh>(tFields);
580 autoPtr<polyTopoChangeMap> map = meshMod.changeMesh(mesh_,
true);
583 mesh_.topoChangeZones(map);
586 mesh_.mapFields(map);
590 mapBoundaryFields<scalar, surfaceMesh>(map, sFields);
591 mapBoundaryFields<vector, surfaceMesh>(map, vFields);
592 mapBoundaryFields<sphericalTensor, surfaceMesh>(map, sptFields);
593 mapBoundaryFields<symmTensor, surfaceMesh>(map, sytFields);
594 mapBoundaryFields<tensor, surfaceMesh>(map, tFields);
605 <<
"reverseFaceMap contains -1 at index:"
607 <<
"This means that the repatch operation was not just"
612 forAll(constructFaceMap, proci)
614 inplaceRenumberWithFlip
616 map().reverseFaceMap(),
619 constructFaceMap[proci]
638 forAll(pointToGlobalMaster, pointi)
640 if (pointToGlobalMaster[pointi] != -1)
646 Map<label> globalMasterToLocalMaster(2*nShared);
647 Map<label> pointToMaster(2*nShared);
649 forAll(pointToGlobalMaster, pointi)
651 label globali = pointToGlobalMaster[pointi];
659 if (iter == globalMasterToLocalMaster.end())
662 globalMasterToLocalMaster.insert(globali, pointi);
663 pointToMaster.insert(pointi, pointi);
667 pointToMaster.insert(pointi, iter());
672 if (
returnReduce(pointToMaster.size(), sumOp<label>()) == 0)
674 return autoPtr<polyTopoChangeMap>(
nullptr);
678 polyTopoChange meshMod(mesh_);
681 forAll(mesh_.points(), pointi)
685 if (iter != pointToMaster.end())
687 if (iter() != pointi)
689 meshMod.removePoint(pointi, iter());
696 const faceList& faces = mesh_.faces();
700 const face&
f = faces[facei];
702 bool hasMerged =
false;
710 if (iter != pointToMaster.end())
712 if (iter() != pointi)
729 pointToMaster.find(pointi);
731 if (iter != pointToMaster.end())
737 label patchID = mesh_.boundaryMesh().whichPatch(facei);
738 label nei = (patchID == -1 ? mesh_.faceNeighbour()[facei] : -1);
744 mesh_.faceOwner()[facei],
755 autoPtr<polyTopoChangeMap> map = meshMod.changeMesh(mesh_,
true);
758 mesh_.topoChangeZones(map);
761 mesh_.mapFields(map);
764 forAll(constructPointMap, proci)
766 labelList& constructMap = constructPointMap[proci];
770 label oldPointi = constructMap[i];
785 <<
"Problem. oldPointi:" << oldPointi
795 void Foam::fvMeshDistribute::getCouplingData
809 label nBnd = mesh_.nFaces() - mesh_.nInternalFaces();
810 sourceFace.setSize(nBnd);
811 sourceProc.setSize(nBnd);
812 sourcePatch.setSize(nBnd);
813 sourceNbrPatch.setSize(nBnd);
814 sourceNewNbrProc.setSize(nBnd);
816 const polyBoundaryMesh&
patches = mesh_.boundaryMesh();
828 label offset = pp.start() - mesh_.nInternalFaces();
834 nbrFaces[bndI] = pp.start()+i;
838 SubList<label>(nbrNewNbrProc, pp.size(),
offset) =
839 UIndirectList<label>(distribution, pp.faceCells())();
852 label offset = pp.start() - mesh_.nInternalFaces();
854 if (isA<processorPolyPatch>(pp))
856 const processorPolyPatch& procPatch =
857 refCast<const processorPolyPatch>(pp);
861 if (procPatch.owner())
867 sourceFace[bndI] = pp.start()+i;
869 sourceNewNbrProc[bndI] = nbrNewNbrProc[bndI];
878 sourceFace[bndI] = nbrFaces[bndI];
879 sourceProc[bndI] = procPatch.neighbProcNo();
880 sourceNewNbrProc[bndI] = nbrNewNbrProc[bndI];
886 if (isA<processorCyclicPolyPatch>(pp))
889 refCast<const processorCyclicPolyPatch>(pp)
900 sourcePatch[bndI] =
patchi;
901 sourceNbrPatch[bndI] = nbrPatchi;
904 else if (isA<cyclicPolyPatch>(pp))
906 const cyclicPolyPatch& cpp = refCast<const cyclicPolyPatch>(pp);
913 sourceFace[bndI] = pp.start()+i;
915 sourcePatch[bndI] =
patchi;
916 sourceNbrPatch[bndI] = cpp.nbrPatchIndex();
917 sourceNewNbrProc[bndI] = nbrNewNbrProc[bndI];
925 sourceFace[bndI] = nbrFaces[bndI];
927 sourcePatch[bndI] =
patchi;
928 sourceNbrPatch[bndI] = cpp.nbrPatchIndex();
929 sourceNewNbrProc[bndI] = nbrNewNbrProc[bndI];
939 sourceFace[bndI] = -1;
940 sourceProc[bndI] = -1;
941 sourcePatch[bndI] =
patchi;
942 sourceNbrPatch[bndI] = -1;
943 sourceNewNbrProc[bndI] = -1;
950 sourcePointMaster.setSize(mesh_.nPoints());
951 sourcePointMaster = -1;
954 const globalIndex globalPoints(mesh_.nPoints());
956 const globalMeshData& gmd = mesh_.globalData();
958 const labelList& meshPoints = cpp.meshPoints();
959 const distributionMap& slavesMap = gmd.globalCoPointSlavesMap();
962 labelList elems(slavesMap.constructSize(), -1);
963 forAll(meshPoints, pointi)
971 label globalPointi = globalPoints.toGlobal(meshPoints[pointi]);
972 elems[pointi] = globalPointi;
975 label sloti = slots[i];
976 if (sloti >= meshPoints.size())
980 elems[slots[i]] = globalPointi;
987 slavesMap.reverseDistribute(elems.size(), elems,
false);
990 forAll(meshPoints, pointi)
992 sourcePointMaster[meshPoints[pointi]] = elems[pointi];
998 void Foam::fvMeshDistribute::subsetCouplingData
1008 const label oldInternalFaces,
1025 subFace.setSize(mesh.nFaces() - mesh.nInternalFaces());
1026 subProc.setSize(mesh.nFaces() - mesh.nInternalFaces());
1027 subPatch.setSize(mesh.nFaces() - mesh.nInternalFaces());
1028 subNbrPatch.setSize(mesh.nFaces() - mesh.nInternalFaces());
1029 subNewNbrProc.setSize(mesh.nFaces() - mesh.nInternalFaces());
1031 forAll(subFace, newBFacei)
1033 label newFacei = newBFacei + mesh.nInternalFaces();
1038 if (oldFacei < oldInternalFaces)
1040 subFace[newBFacei] = oldFacei;
1042 subPatch[newBFacei] = -1;
1044 label oldOwn = oldFaceOwner[oldFacei];
1045 label oldNei = oldFaceNeighbour[oldFacei];
1047 if (oldOwn == cellMap[mesh.faceOwner()[newFacei]])
1050 subNewNbrProc[newBFacei] = oldDistribution[oldNei];
1055 subNewNbrProc[newBFacei] = oldDistribution[oldOwn];
1061 label oldBFacei = oldFacei - oldInternalFaces;
1063 subFace[newBFacei] = sourceFace[oldBFacei];
1064 subProc[newBFacei] = sourceProc[oldBFacei];
1065 subPatch[newBFacei] = sourcePatch[oldBFacei];
1066 subNbrPatch[newBFacei] = sourceNbrPatch[oldBFacei];
1067 subNewNbrProc[newBFacei] = sourceNewNbrProc[oldBFacei];
1072 subPointMaster = UIndirectList<label>(sourcePointMaster, pointMap);
1076 void Foam::fvMeshDistribute::findCouples
1078 const primitiveMesh& mesh,
1084 const primitiveMesh& domainMesh,
1095 HashTable<label, labelPair, labelPair::Hash<>> map(domainFace.size());
1097 forAll(domainProc, bFacei)
1099 if (domainProc[bFacei] != -1 && domainPatch[bFacei] == -1)
1103 labelPair(domainFace[bFacei], domainProc[bFacei]),
1112 masterCoupledFaces.setSize(domainFace.size());
1113 slaveCoupledFaces.setSize(domainFace.size());
1116 forAll(sourceFace, bFacei)
1118 if (sourceProc[bFacei] != -1 && sourcePatch[bFacei] == -1)
1120 labelPair myData(sourceFace[bFacei], sourceProc[bFacei]);
1122 HashTable<label, labelPair, labelPair::Hash<>>::const_iterator
1123 iter = map.find(myData);
1125 if (iter != map.end())
1127 label nbrBFacei = iter();
1129 masterCoupledFaces[coupledI] = mesh.nInternalFaces() + bFacei;
1130 slaveCoupledFaces[coupledI] =
1131 domainMesh.nInternalFaces()
1139 masterCoupledFaces.setSize(coupledI);
1140 slaveCoupledFaces.setSize(coupledI);
1144 Pout<<
"findCouples : found " << coupledI
1145 <<
" faces that will be stitched" <<
nl <<
endl;
1152 const primitiveMesh& mesh,
1153 const mapAddedPolyMesh& map,
1155 const label nInternalFaces1,
1159 labelList newBoundaryData(mesh.nFaces() - mesh.nInternalFaces());
1161 forAll(boundaryData0, oldBFacei)
1163 label newFacei = map.oldFaceMap()[oldBFacei + map.nOldInternalFaces()];
1166 if (newFacei >= 0 && newFacei >= mesh.nInternalFaces())
1168 newBoundaryData[newFacei - mesh.nInternalFaces()] =
1169 boundaryData0[oldBFacei];
1173 forAll(boundaryData1, addedBFacei)
1175 label newFacei = map.addedFaceMap()[addedBFacei + nInternalFaces1];
1177 if (newFacei >= 0 && newFacei >= mesh.nInternalFaces())
1179 newBoundaryData[newFacei - mesh.nInternalFaces()] =
1180 boundaryData1[addedBFacei];
1184 return newBoundaryData;
1190 const primitiveMesh& mesh,
1191 const mapAddedPolyMesh& map,
1196 labelList newBoundaryData(mesh.nPoints());
1198 forAll(boundaryData0, oldPointi)
1205 newBoundaryData[
newPointi] = boundaryData0[oldPointi];
1209 forAll(boundaryData1, addedPointi)
1215 newBoundaryData[
newPointi] = boundaryData1[addedPointi];
1219 return newBoundaryData;
1226 const label oldInternalPatchi
1230 polyTopoChange meshMod(mesh_);
1234 removeCells cellRemover(mesh_,
false);
1237 labelList exposedFaces(cellRemover.getExposedFaces(cellsToRemove));
1240 cellRemover.setRefinement
1244 labelList(exposedFaces.size(), oldInternalPatchi),
1251 PtrList<Field<scalar>> sFields;
1252 PtrList<Field<vector>> vFields;
1253 PtrList<Field<sphericalTensor>> sptFields;
1254 PtrList<Field<symmTensor>> sytFields;
1255 PtrList<Field<tensor>> tFields;
1256 initMapExposedFaces(sFields);
1257 initMapExposedFaces(vFields);
1258 initMapExposedFaces(sptFields);
1259 initMapExposedFaces(sytFields);
1260 initMapExposedFaces(tFields);
1264 autoPtr<polyTopoChangeMap> map = meshMod.changeMesh(mesh_,
false);
1267 mesh_.topoChangeZones(map);
1270 mesh_.mapFields(map);
1275 mapExposedFaces(map(), sFields);
1276 mapExposedFaces(map(), vFields);
1277 mapExposedFaces(map(), sptFields);
1278 mapExposedFaces(map(), sytFields);
1279 mapExposedFaces(map(), tFields);
1285 void Foam::fvMeshDistribute::addProcPatches
1290 List<Map<label>>& procPatchID
1306 lessProcPatches(nbrProc, referPatchID, referNbrPatchID)
1313 label bFacei = indices[i];
1314 label proci = nbrProc[bFacei];
1318 if (!procPatchID[proci].
found(referPatchID[bFacei]))
1323 if (referPatchID[bFacei] == -1)
1327 processorPolyPatch pp
1331 mesh_.boundaryMesh().size(),
1332 mesh_.boundaryMesh(),
1337 procPatchID[proci].insert
1339 referPatchID[bFacei],
1352 const coupledPolyPatch& pcPatch =
1353 refCast<const coupledPolyPatch>
1355 mesh_.boundaryMesh()[referPatchID[bFacei]]
1357 processorCyclicPolyPatch pp
1361 mesh_.boundaryMesh().size(),
1362 mesh_.boundaryMesh(),
1368 procPatchID[proci].insert
1370 referPatchID[bFacei],
1387 void Foam::fvMeshDistribute::addNccProcPatches()
1389 forAll(mesh_.boundaryMesh(), nccPatchi)
1391 const polyPatch& pp = mesh_.boundaryMesh()[nccPatchi];
1393 if (!isA<nonConformalCyclicPolyPatch>(pp))
continue;
1395 const nonConformalCyclicPolyPatch& nccPp =
1396 refCast<const nonConformalCyclicPolyPatch>(pp);
1397 const polyPatch& origPp = nccPp.origPatch();
1399 const nonConformalCyclicPolyPatch& nbrNccPp = nccPp.nbrPatch();
1400 const polyPatch& nbrOrigPp = nbrNccPp.origPatch();
1402 if (!nccPp.owner())
continue;
1414 auto add = [&](
const bool owner,
const bool first)
1417 owner ? procHasOrig : procHasNbrOrig;
1419 owner ? procHasNbrOrig : procHasOrig;
1423 forAll(procHasPatchB, proci)
1431 && procHasPatchB[proci]
1437 nonConformalProcessorCyclicPolyPatch
1441 mesh_.boundaryMesh().size(),
1442 mesh_.boundaryMesh(),
1445 owner ? nccPp.name() : nbrNccPp.name(),
1446 owner ? origPp.name() : nbrOrigPp.name()
1449 nonConformalProcessorCyclicFvPatchField<scalar>::
1470 const List<Map<label>>& procPatchID
1479 label origPatchi = referPatchID[bFacei];
1480 patchIDs[bFacei] = origPatchi;
1482 else if (nbrProc[bFacei] != -1)
1484 label origPatchi = referPatchID[bFacei];
1485 patchIDs[bFacei] = procPatchID[nbrProc[bFacei]][origPatchi];
1489 patchIDs[bFacei] = -1;
1496 void Foam::fvMeshDistribute::sendMesh
1516 Pout<<
"Sending to domain " << domain <<
nl
1517 <<
" nPoints:" << mesh.nPoints() <<
nl
1518 <<
" nFaces:" << mesh.nFaces() <<
nl
1519 <<
" nCells:" << mesh.nCells() <<
nl
1520 <<
" nPatches:" << mesh.boundaryMesh().size() <<
nl
1526 CompactListList<label> zonePoints;
1528 const pointZoneList& pointZones = mesh.pointZones();
1530 labelList rowSizes(pointZoneNames.size(), 0);
1532 forAll(pointZoneNames, nameI)
1534 label myZoneID = pointZones.findIndex(pointZoneNames[nameI]);
1538 rowSizes[nameI] = pointZones[myZoneID].size();
1541 zonePoints.setSize(rowSizes);
1543 forAll(pointZoneNames, nameI)
1545 label myZoneID = pointZones.findIndex(pointZoneNames[nameI]);
1549 zonePoints[nameI].deepCopy(pointZones[myZoneID]);
1555 CompactListList<label> zoneFaces;
1556 CompactListList<bool> zoneFaceFlip;
1558 const faceZoneList& faceZones = mesh.faceZones();
1560 labelList rowSizes(faceZoneNames.size(), 0);
1562 forAll(faceZoneNames, nameI)
1564 label myZoneID = faceZones.findIndex(faceZoneNames[nameI]);
1568 rowSizes[nameI] = faceZones[myZoneID].size();
1572 zoneFaces.setSize(rowSizes);
1573 zoneFaceFlip.setSize(rowSizes);
1575 forAll(faceZoneNames, nameI)
1577 label myZoneID = faceZones.findIndex(faceZoneNames[nameI]);
1581 zoneFaces[nameI].deepCopy(faceZones[myZoneID]);
1582 zoneFaceFlip[nameI].deepCopy(faceZones[myZoneID].flipMap());
1588 CompactListList<label> zoneCells;
1590 const cellZoneList& cellZones = mesh.cellZones();
1592 labelList rowSizes(cellZoneNames.size(), 0);
1594 forAll(cellZoneNames, nameI)
1596 label myZoneID = cellZones.findIndex(cellZoneNames[nameI]);
1600 rowSizes[nameI] = cellZones[myZoneID].size();
1604 zoneCells.setSize(rowSizes);
1606 forAll(cellZoneNames, nameI)
1608 label myZoneID = cellZones.findIndex(cellZoneNames[nameI]);
1612 zoneCells[nameI].deepCopy(cellZones[myZoneID]);
1634 << CompactListList<label>(mesh.faces())
1636 << mesh.faceNeighbour()
1637 << mesh.boundaryMesh()
1653 << sourcePointMaster;
1658 Pout<<
"Started sending mesh to domain " << domain
1670 const Time& runTime,
1681 faceList domainFaces = CompactListList<label>(fromNbr).list<face>();
1684 PtrList<entry> patchEntries(fromNbr);
1686 CompactListList<label> zonePoints(fromNbr);
1687 CompactListList<label> zoneFaces(fromNbr);
1688 CompactListList<bool> zoneFaceFlip(fromNbr);
1689 CompactListList<label> zoneCells(fromNbr);
1694 >> domainSourcePatch
1695 >> domainSourceNbrPatch
1696 >> domainSourceNewNbrProc
1697 >> domainSourcePointMaster;
1700 autoPtr<fvMesh> domainMeshPtr
1713 move(domainAllOwner),
1714 move(domainAllNeighbour),
1718 fvMesh& domainMesh = domainMeshPtr();
1720 List<polyPatch*>
patches(patchEntries.size());
1726 patchEntries[
patchi].keyword(),
1729 domainMesh.boundaryMesh()
1733 domainMesh.addFvPatches(
patches,
false);
1736 List<pointZone*> pZonePtrs(pointZoneNames.size());
1739 pZonePtrs[i] =
new pointZone
1743 domainMesh.pointZones()
1747 List<faceZone*> fZonePtrs(faceZoneNames.size());
1750 fZonePtrs[i] =
new faceZone
1755 domainMesh.faceZones()
1759 List<cellZone*> cZonePtrs(cellZoneNames.size());
1762 cZonePtrs[i] =
new cellZone
1766 domainMesh.cellZones()
1769 domainMesh.addZones(pZonePtrs, fZonePtrs, cZonePtrs);
1771 return domainMeshPtr;
1800 <<
"At index " << celli <<
" distribution:" << newProc
1818 <<
"Size of distribution:"
1819 <<
distribution.size() <<
" mesh nCells:" << mesh_.nCells()
1827 if (
patches.checkParallelSync(
true))
1830 <<
"This application requires all non-processor patches"
1831 <<
" to be present in the same order on all patches" <<
nl
1832 <<
"followed by the processor patches (which of course are unique)."
1834 <<
"Local patches:" << mesh_.boundaryMesh().names()
1839 const label nOldPoints(mesh_.nPoints());
1840 const label nOldFaces(mesh_.nFaces());
1841 const label nOldCells(mesh_.nCells());
1864 move(oldPatchStarts),
1865 move(oldPatchNMeshPoints),
1882 const wordList pointZoneNames(mergeWordList(mesh_.pointZones().toc()));
1883 const wordList faceZoneNames(mergeWordList(mesh_.faceZones().toc()));
1884 const wordList cellZoneNames(mergeWordList(mesh_.cellZones().toc()));
1946 mesh_.resetMotion();
2038 const label oldInternalPatchi =
2040 ? findInternalPatch()
2041 : findNonEmptyPatch();
2048 deleteProcPatches(oldInternalPatchi);
2051 repatchFaceMap = repatchMap().faceMap();
2058 repatchMap().reverseFaceMap(),
2059 mesh_.nFaces() - mesh_.nInternalFaces(),
2060 mesh_.nInternalFaces()
2062 - mesh_.nInternalFaces()
2076 Pout<<
nl <<
"MESH WITH PROC PATCHES DELETED:" <<
endl;
2077 printMeshInfo(mesh_);
2078 printFieldInfo<volScalarField>(mesh_);
2079 printFieldInfo<volVectorField>(mesh_);
2080 printFieldInfo<volSphericalTensorField>(mesh_);
2081 printFieldInfo<volSymmTensorField>(mesh_);
2082 printFieldInfo<volTensorField>(mesh_);
2083 printFieldInfo<surfaceScalarField>(mesh_);
2084 printFieldInfo<surfaceVectorField>(mesh_);
2085 printFieldInfo<surfaceSphericalTensorField>(mesh_);
2086 printFieldInfo<surfaceSymmTensorField>(mesh_);
2087 printFieldInfo<surfaceTensorField>(mesh_);
2088 printFieldInfo<pointScalarField>(mesh_);
2089 printFieldInfo<pointVectorField>(mesh_);
2090 printFieldInfo<pointSphericalTensorField>(mesh_);
2091 printFieldInfo<pointSymmTensorField>(mesh_);
2092 printFieldInfo<pointTensorField>(mesh_);
2144 <<
"SUBSETTING FOR DOMAIN " << recvProc
2145 <<
" cells to send:"
2166 subCellMap[recvProc] = subsetter.
cellMap();
2168 inplaceRenumberWithFlip
2173 subFaceMap[recvProc]
2175 subPointMap[recvProc] = subsetter.
pointMap();
2176 subPatchMap[recvProc] = subsetter.
patchMap();
2196 mesh_.faceNeighbour(),
2197 mesh_.nInternalFaces(),
2210 procSourceNewNbrProc,
2211 procSourcePointMaster
2229 procSourceNewNbrProc,
2230 procSourcePointMaster,
2236 sendFields<volScalarField>(recvProc, volScalars, subsetter, str);
2237 sendFields<volVectorField>(recvProc, volVectors, subsetter, str);
2238 sendFields<volSphericalTensorField>
2245 sendFields<volSymmTensorField>
2252 sendFields<volTensorField>(recvProc, volTensors, subsetter, str);
2255 sendFields<surfaceScalarField>
2262 sendFields<surfaceVectorField>
2269 sendFields<surfaceSphericalTensorField>
2276 sendFields<surfaceSymmTensorField>
2283 sendFields<surfaceTensorField>
2292 sendFields<pointScalarField>
2299 sendFields<pointVectorField>
2306 sendFields<pointSphericalTensorField>
2313 sendFields<pointSymmTensorField>
2320 sendFields<pointTensorField>
2329 sendFields<volScalarField::Internal>
2336 sendFields<volVectorField::Internal>
2343 sendFields<volSphericalTensorField::Internal>
2350 sendFields<volSymmTensorField::Internal>
2357 sendFields<volTensorField::Internal>
2380 const labelList oldFaceOwner(mesh_.faceOwner());
2381 const labelList oldFaceNeighbour(mesh_.faceNeighbour());
2382 const label oldInternalFaces = mesh_.nInternalFaces();
2410 label facei = iter.key();
2434 subMap().pointMap(),
2453 domainSourceNbrPatch,
2454 domainSourceNewNbrProc,
2455 domainSourcePointMaster
2458 sourceFace.
transfer(domainSourceFace);
2459 sourceProc.
transfer(domainSourceProc);
2460 sourcePatch.
transfer(domainSourcePatch);
2461 sourceNbrPatch.
transfer(domainSourceNbrPatch);
2462 sourceNewNbrProc.
transfer(domainSourceNewNbrProc);
2463 sourcePointMaster.
transfer(domainSourcePointMaster);
2471 printMeshInfo(mesh_);
2472 printFieldInfo<volScalarField>(mesh_);
2473 printFieldInfo<volVectorField>(mesh_);
2474 printFieldInfo<volSphericalTensorField>(mesh_);
2475 printFieldInfo<volSymmTensorField>(mesh_);
2476 printFieldInfo<volTensorField>(mesh_);
2477 printFieldInfo<surfaceScalarField>(mesh_);
2478 printFieldInfo<surfaceVectorField>(mesh_);
2479 printFieldInfo<surfaceSphericalTensorField>(mesh_);
2480 printFieldInfo<surfaceSymmTensorField>(mesh_);
2481 printFieldInfo<surfaceTensorField>(mesh_);
2482 printFieldInfo<pointScalarField>(mesh_);
2483 printFieldInfo<pointVectorField>(mesh_);
2484 printFieldInfo<pointSphericalTensorField>(mesh_);
2485 printFieldInfo<pointSymmTensorField>(mesh_);
2486 printFieldInfo<pointTensorField>(mesh_);
2498 forAll(nSendCells, sendProc)
2510 <<
"RECEIVING FROM DOMAIN " << sendProc
2511 <<
" cells to receive:"
2558 domainMeshPtr = receiveMesh
2565 const_cast<Time&
>(mesh_.time()),
2569 domainSourceNbrPatch,
2570 domainSourceNewNbrProc,
2571 domainSourcePointMaster,
2574 fvMesh& domainMesh = domainMeshPtr();
2584 receiveFields<volScalarField>
2592 receiveFields<volVectorField>
2600 receiveFields<volSphericalTensorField>
2608 receiveFields<volSymmTensorField>
2616 receiveFields<volTensorField>
2626 receiveFields<surfaceScalarField>
2634 receiveFields<surfaceVectorField>
2642 receiveFields<surfaceSphericalTensorField>
2650 receiveFields<surfaceSymmTensorField>
2658 receiveFields<surfaceTensorField>
2670 receiveFields<pointScalarField>
2678 receiveFields<pointVectorField>
2686 receiveFields<pointSphericalTensorField>
2694 receiveFields<pointSymmTensorField>
2702 receiveFields<pointTensorField>
2712 receiveFields<volScalarField::Internal>
2723 receiveFields<volVectorField::Internal>
2734 receiveFields<volSphericalTensorField::Internal>
2746 receiveFields<volSymmTensorField::Internal>
2757 receiveFields<volTensorField::Internal>
2769 const fvMesh& domainMesh = domainMeshPtr();
2775 constructPatchMap[sendProc] =
2782 Pout<<
nl <<
"RECEIVED MESH FROM:" << sendProc <<
endl;
2783 printMeshInfo(domainMesh);
2784 printFieldInfo<volScalarField>(domainMesh);
2785 printFieldInfo<volVectorField>(domainMesh);
2786 printFieldInfo<volSphericalTensorField>(domainMesh);
2787 printFieldInfo<volSymmTensorField>(domainMesh);
2788 printFieldInfo<volTensorField>(domainMesh);
2789 printFieldInfo<surfaceScalarField>(domainMesh);
2790 printFieldInfo<surfaceVectorField>(domainMesh);
2791 printFieldInfo<surfaceSphericalTensorField>(domainMesh);
2792 printFieldInfo<surfaceSymmTensorField>(domainMesh);
2793 printFieldInfo<surfaceTensorField>(domainMesh);
2794 printFieldInfo<pointScalarField>(domainMesh);
2795 printFieldInfo<pointVectorField>(domainMesh);
2796 printFieldInfo<pointSphericalTensorField>(domainMesh);
2797 printFieldInfo<pointSymmTensorField>(domainMesh);
2798 printFieldInfo<pointTensorField>(domainMesh);
2852 sourceFace = mapBoundaryData
2860 sourceProc = mapBoundaryData
2868 sourcePatch = mapBoundaryData
2876 sourceNbrPatch = mapBoundaryData
2882 domainSourceNbrPatch
2884 sourceNewNbrProc = mapBoundaryData
2890 domainSourceNewNbrProc
2893 sourcePointMaster = mapPointData
2898 domainSourcePointMaster
2904 const labelList& oldCellMap = map().oldCellMap();
2905 const labelList& oldFaceMap = map().oldFaceMap();
2906 const labelList& oldPointMap = map().oldPointMap();
2907 const labelList& oldPatchMap = map().oldPatchMap();
2910 forAll(constructPatchMap, proci)
2912 if (proci != sendProc && constructPatchMap[proci].size())
2916 inplaceRenumberWithFlip
2921 constructFaceMap[proci]
2934 flippedAddedFaces.
resize(nBnd/4);
2939 domainFacei < domainMesh.
nFaces();
2943 label newFacei = map().addedFaceMap()[domainFacei];
2944 label newCellI = mesh_.faceOwner()[newFacei];
2948 if (newCellI != map().addedCellMap()[domainCellI])
2950 flippedAddedFaces.
insert(domainFacei);
2961 label domainFacei = iter.key();
2962 label& val = constructFaceMap[sendProc][domainFacei];
2965 inplaceRenumberWithFlip
2967 map().addedFaceMap(),
2970 constructFaceMap[sendProc]
2977 Pout<<
nl <<
"MERGED MESH FROM:" << sendProc <<
endl;
2978 printMeshInfo(mesh_);
2979 printFieldInfo<volScalarField>(mesh_);
2980 printFieldInfo<volVectorField>(mesh_);
2981 printFieldInfo<volSphericalTensorField>(mesh_);
2982 printFieldInfo<volSymmTensorField>(mesh_);
2983 printFieldInfo<volTensorField>(mesh_);
2984 printFieldInfo<surfaceScalarField>(mesh_);
2985 printFieldInfo<surfaceVectorField>(mesh_);
2986 printFieldInfo<surfaceSphericalTensorField>(mesh_);
2987 printFieldInfo<surfaceSymmTensorField>(mesh_);
2988 printFieldInfo<surfaceTensorField>(mesh_);
2989 printFieldInfo<pointScalarField>(mesh_);
2990 printFieldInfo<pointVectorField>(mesh_);
2991 printFieldInfo<pointSphericalTensorField>(mesh_);
2992 printFieldInfo<pointSymmTensorField>(mesh_);
2993 printFieldInfo<pointTensorField>(mesh_);
3005 printMeshInfo(mesh_);
3006 printFieldInfo<volScalarField>(mesh_);
3007 printFieldInfo<volVectorField>(mesh_);
3008 printFieldInfo<volSphericalTensorField>(mesh_);
3009 printFieldInfo<volSymmTensorField>(mesh_);
3010 printFieldInfo<volTensorField>(mesh_);
3011 printFieldInfo<surfaceScalarField>(mesh_);
3012 printFieldInfo<surfaceVectorField>(mesh_);
3013 printFieldInfo<surfaceSphericalTensorField>(mesh_);
3014 printFieldInfo<surfaceSymmTensorField>(mesh_);
3015 printFieldInfo<surfaceTensorField>(mesh_);
3016 printFieldInfo<pointScalarField>(mesh_);
3017 printFieldInfo<pointVectorField>(mesh_);
3018 printFieldInfo<pointSphericalTensorField>(mesh_);
3019 printFieldInfo<pointSymmTensorField>(mesh_);
3020 printFieldInfo<pointTensorField>(mesh_);
3027 mergeSharedPoints(sourcePointMaster, constructPointMap);
3039 addProcPatches(sourceNewNbrProc, sourcePatch, sourceNbrPatch, procPatchID);
3058 repatch(newPatchID, constructFaceMap);
3063 addNccProcPatches();
3066 correctCoupledPatchFields<volScalarField>();
3067 correctCoupledPatchFields<volVectorField>();
3068 correctCoupledPatchFields<volSphericalTensorField>();
3069 correctCoupledPatchFields<volSymmTensorField>();
3070 correctCoupledPatchFields<volTensorField>();
3072 mesh_.setInstance(mesh_.time().name());
3079 printMeshInfo(mesh_);
3080 printFieldInfo<volScalarField>(mesh_);
3081 printFieldInfo<volVectorField>(mesh_);
3082 printFieldInfo<volSphericalTensorField>(mesh_);
3083 printFieldInfo<volSymmTensorField>(mesh_);
3084 printFieldInfo<volTensorField>(mesh_);
3085 printFieldInfo<surfaceScalarField>(mesh_);
3086 printFieldInfo<surfaceVectorField>(mesh_);
3087 printFieldInfo<surfaceSphericalTensorField>(mesh_);
3088 printFieldInfo<surfaceSymmTensorField>(mesh_);
3089 printFieldInfo<surfaceTensorField>(mesh_);
3090 printFieldInfo<pointScalarField>(mesh_);
3091 printFieldInfo<pointVectorField>(mesh_);
3092 printFieldInfo<pointSphericalTensorField>(mesh_);
3093 printFieldInfo<pointSymmTensorField>(mesh_);
3094 printFieldInfo<pointTensorField>(mesh_);
3108 move(oldPatchStarts),
3109 move(oldPatchNMeshPoints),
3116 move(constructPointMap),
3117 move(constructFaceMap),
3118 move(constructCellMap),
3119 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 word &name, const polyMesh &mesh)
Construct and return the named DemandDrivenMeshObject.
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.
friend class const_iterator
Declare friendship with the const_iterator.
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.
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.
label size() const
Return the number of elements in the UList.
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.
const word & name() const
Return name.
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.
Base class for statistical distributions.
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...
const pointZoneList & pointZones() const
Return point zones.
const cellZoneList & cellZones() const
Return cell zones.
static word defaultRegion
Return the default region name.
virtual const labelList & faceOwner() const
Return face owner.
const faceZoneList & faceZones() const
Return face zones.
const polyBoundaryMesh & boundaryMesh() const
Return boundary 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.
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
#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)
ListType renumber(const labelUList &oldToNew, const ListType &)
Renumber the values (not the indices) of a list.
vectorField pointField
pointField is a vectorField.
List< bool > boolList
Bool container classes.
labelList first(const UList< labelPair > &p)
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)
void add(FieldField< Field1, typename typeOfSum< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
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,.
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.