71 referPatchID_(referPatchID),
72 referNbrPatchID_(referNbrPatchID)
78 if (nbrProc_[a] < nbrProc_[
b])
82 else if (nbrProc_[a] > nbrProc_[
b])
88 else if (referPatchID_[a] == -1)
92 else if (referPatchID_[
b] == -1)
102 return referPatchID_[a] < referPatchID_[
b];
106 return referNbrPatchID_[a] < referNbrPatchID_[
b];
116 void Foam::fvMeshDistribute::inplaceRenumberWithFlip
119 const bool oldToNewHasFlip,
120 const bool lstHasFlip,
124 if (!lstHasFlip && !oldToNewHasFlip)
135 label val = lst[elemI];
151 <<
"Problem : zero value " << val
152 <<
" at index " << elemI <<
" out of " << lst.size()
159 label newVal = oldToNew[val];
175 <<
"Problem : zero value " << newVal
176 <<
" at index " << elemI <<
" out of "
184 lst[elemI] =
sign*(newVal+1);
192 const bool selectEqual,
201 if (selectEqual == (values[i] == value))
212 if (selectEqual == (values[i] == value))
221 Foam::label Foam::fvMeshDistribute::checkEqualWordList
234 if (allNames[proci] != allNames[0])
237 <<
"When checking for equal " << msg.c_str() <<
" :" <<
endl
238 <<
"processor0 has:" << allNames[0] <<
endl
239 <<
"processor" << proci <<
" has:" << allNames[proci] <<
endl
240 << msg.c_str() <<
" need to be synchronised on all processors."
256 HashSet<word> mergedNames;
259 forAll(allNames[proci], i)
261 mergedNames.insert(allNames[proci][i]);
264 return mergedNames.toc();
270 Pout<<
"Primitives:" <<
nl
274 <<
" faces :" << mesh.
nFaces() <<
nl
275 <<
" cells :" << mesh.
nCells() <<
nl;
285 <<
" size:" << pp.size()
286 <<
" start:" << pp.
start()
287 <<
" type:" << pp.type()
297 Pout<<
" " << zoneI <<
" name:" << pz.
name()
298 <<
" size:" << pz.
size()
308 Pout<<
" " << zoneI <<
" name:" << fz.
name()
309 <<
" size:" << fz.
size()
319 Pout<<
" " << zoneI <<
" name:" << cz.
name()
320 <<
" size:" << cz.
size()
337 <<
"Current coupling info:"
340 forAll(sourceFace, bFacei)
344 Pout<<
" meshFace:" << meshFacei
346 <<
" connects to proc:" << sourceProc[bFacei]
347 <<
"/face:" << sourceFace[bFacei]
348 <<
" which will move to proc:" << sourceNewNbrProc[bFacei]
354 Foam::label Foam::fvMeshDistribute::findInternalPatch()
const
358 label internalPatchi = -1;
364 if (isA<internalPolyPatch>(pp))
371 if (internalPatchi == -1)
374 <<
"Cannot find a internal patch in " <<
patches.names() <<
nl
376 <<
" An internal patch must be provided for the exposed "
382 Pout<<
"findInternalPatch : using patch " << internalPatchi
383 <<
" name:" <<
patches[internalPatchi].name()
384 <<
" type:" <<
patches[internalPatchi].type()
385 <<
" for the exposed internal faces." <<
endl;
390 label procPatchi = -1;
398 else if (procPatchi != -1)
401 <<
"Processor patches should be at end of patch list."
403 <<
"Have processor patch " << procPatchi
404 <<
" followed by non-processor patch " <<
patchi
405 <<
" in patches " <<
patches.names()
410 return internalPatchi;
413 Foam::label Foam::fvMeshDistribute::findNonEmptyPatch()
const
415 const polyBoundaryMesh&
patches = mesh_.boundaryMesh();
417 label nonEmptyPatchi = -1;
423 if (!isA<emptyPolyPatch>(pp) && !pp.coupled())
430 if (nonEmptyPatchi == -1)
433 <<
"Cannot find a non-empty patch in " <<
patches.names() <<
nl
435 <<
" An non-empty patch must be provided for the exposed "
441 Pout<<
"findNonEmptyPatch : using patch " << nonEmptyPatchi
442 <<
" name:" <<
patches[nonEmptyPatchi].name()
443 <<
" type:" <<
patches[nonEmptyPatchi].type()
444 <<
" for the exposed non-empty faces." <<
endl;
447 return nonEmptyPatchi;
453 const label destinationPatch
458 labelList newPatchID(mesh_.nFaces() - mesh_.nInternalFaces(), -1);
462 const polyPatch& pp = mesh_.boundaryMesh()[
patchi];
464 if (isA<processorPolyPatch>(pp))
468 Pout<<
"Moving all faces of patch " << pp.
name()
469 <<
" into patch " << destinationPatch
473 label offset = pp.start() - mesh_.nInternalFaces();
477 newPatchID[
offset+i] = destinationPatch;
486 autoPtr<polyTopoChangeMap> map = repatch(newPatchID, dummyFaceMaps);
496 if (!isA<processorPolyPatch>(mesh_.boundaryMesh()[
patchi]))
498 oldToNew[
patchi] = newI++;
501 label nNonProcPatches = newI;
506 if (isA<processorPolyPatch>(mesh_.boundaryMesh()[
patchi]))
508 oldToNew[
patchi] = newI++;
524 polyTopoChange meshMod(mesh_);
526 forAll(newPatchID, bFacei)
528 if (newPatchID[bFacei] != -1)
530 label facei = mesh_.nInternalFaces() + bFacei;
532 label zoneID = mesh_.faceZones().whichZone(facei);
533 bool zoneFlip =
false;
537 const faceZone& fZone = mesh_.faceZones()[zoneID];
538 zoneFlip = fZone.flipMap()[fZone.whichFace(facei)];
545 mesh_.faces()[facei],
547 mesh_.faceOwner()[facei],
564 PtrList<FieldField<fvsPatchField, scalar>> sFlds;
565 saveBoundaryFields<scalar, surfaceMesh>(sFlds);
566 PtrList<FieldField<fvsPatchField, vector>> vFlds;
567 saveBoundaryFields<vector, surfaceMesh>(vFlds);
568 PtrList<FieldField<fvsPatchField, sphericalTensor>> sptFlds;
569 saveBoundaryFields<sphericalTensor, surfaceMesh>(sptFlds);
570 PtrList<FieldField<fvsPatchField, symmTensor>> sytFlds;
571 saveBoundaryFields<symmTensor, surfaceMesh>(sytFlds);
572 PtrList<FieldField<fvsPatchField, tensor>> tFlds;
573 saveBoundaryFields<tensor, surfaceMesh>(tFlds);
582 autoPtr<polyTopoChangeMap> map = meshMod.changeMesh(mesh_,
false,
true);
585 mesh_.mapFields(map);
589 mapBoundaryFields<scalar, surfaceMesh>(map, sFlds);
590 mapBoundaryFields<vector, surfaceMesh>(map, vFlds);
591 mapBoundaryFields<sphericalTensor, surfaceMesh>(map, sptFlds);
592 mapBoundaryFields<symmTensor, surfaceMesh>(map, sytFlds);
593 mapBoundaryFields<tensor, surfaceMesh>(map, tFlds);
604 <<
"reverseFaceMap contains -1 at index:"
606 <<
"This means that the repatch operation was not just"
611 forAll(constructFaceMap, proci)
613 inplaceRenumberWithFlip
615 map().reverseFaceMap(),
618 constructFaceMap[proci]
637 forAll(pointToGlobalMaster, pointi)
639 if (pointToGlobalMaster[pointi] != -1)
645 Map<label> globalMasterToLocalMaster(2*nShared);
646 Map<label> pointToMaster(2*nShared);
648 forAll(pointToGlobalMaster, pointi)
650 label globali = pointToGlobalMaster[pointi];
658 if (iter == globalMasterToLocalMaster.end())
661 globalMasterToLocalMaster.insert(globali, pointi);
662 pointToMaster.insert(pointi, pointi);
666 pointToMaster.insert(pointi, iter());
671 if (
returnReduce(pointToMaster.size(), sumOp<label>()) == 0)
673 return autoPtr<polyTopoChangeMap>(
nullptr);
677 polyTopoChange meshMod(mesh_);
680 forAll(mesh_.points(), pointi)
684 if (iter != pointToMaster.end())
686 if (iter() != pointi)
688 meshMod.removePoint(pointi, iter());
695 const faceList& faces = mesh_.faces();
699 const face&
f = faces[facei];
701 bool hasMerged =
false;
709 if (iter != pointToMaster.end())
711 if (iter() != pointi)
728 pointToMaster.find(pointi);
730 if (iter != pointToMaster.end())
736 label patchID = mesh_.boundaryMesh().whichPatch(facei);
737 label nei = (patchID == -1 ? mesh_.faceNeighbour()[facei] : -1);
738 label zoneID = mesh_.faceZones().whichZone(facei);
739 bool zoneFlip =
false;
743 const faceZone& fZone = mesh_.faceZones()[zoneID];
744 zoneFlip = fZone.flipMap()[fZone.whichFace(facei)];
753 mesh_.faceOwner()[facei],
767 autoPtr<polyTopoChangeMap> map = meshMod.changeMesh(mesh_,
false,
true);
770 mesh_.mapFields(map);
773 forAll(constructPointMap, proci)
775 labelList& constructMap = constructPointMap[proci];
779 label oldPointi = constructMap[i];
794 <<
"Problem. oldPointi:" << oldPointi
804 void Foam::fvMeshDistribute::getCouplingData
818 label nBnd = mesh_.nFaces() - mesh_.nInternalFaces();
819 sourceFace.setSize(nBnd);
820 sourceProc.setSize(nBnd);
821 sourcePatch.setSize(nBnd);
822 sourceNbrPatch.setSize(nBnd);
823 sourceNewNbrProc.setSize(nBnd);
825 const polyBoundaryMesh&
patches = mesh_.boundaryMesh();
837 label offset = pp.start() - mesh_.nInternalFaces();
843 nbrFaces[bndI] = pp.start()+i;
847 SubList<label>(nbrNewNbrProc, pp.size(),
offset) =
848 UIndirectList<label>(distribution, pp.faceCells())();
861 label offset = pp.start() - mesh_.nInternalFaces();
863 if (isA<processorPolyPatch>(pp))
865 const processorPolyPatch& procPatch =
866 refCast<const processorPolyPatch>(pp);
870 if (procPatch.owner())
876 sourceFace[bndI] = pp.start()+i;
878 sourceNewNbrProc[bndI] = nbrNewNbrProc[bndI];
887 sourceFace[bndI] = nbrFaces[bndI];
888 sourceProc[bndI] = procPatch.neighbProcNo();
889 sourceNewNbrProc[bndI] = nbrNewNbrProc[bndI];
895 if (isA<processorCyclicPolyPatch>(pp))
898 refCast<const processorCyclicPolyPatch>(pp)
909 sourcePatch[bndI] =
patchi;
910 sourceNbrPatch[bndI] = nbrPatchi;
913 else if (isA<cyclicPolyPatch>(pp))
915 const cyclicPolyPatch& cpp = refCast<const cyclicPolyPatch>(pp);
922 sourceFace[bndI] = pp.start()+i;
924 sourcePatch[bndI] =
patchi;
925 sourceNbrPatch[bndI] = cpp.nbrPatchID();
926 sourceNewNbrProc[bndI] = nbrNewNbrProc[bndI];
934 sourceFace[bndI] = nbrFaces[bndI];
936 sourcePatch[bndI] =
patchi;
937 sourceNbrPatch[bndI] = cpp.nbrPatchID();
938 sourceNewNbrProc[bndI] = nbrNewNbrProc[bndI];
948 sourceFace[bndI] = -1;
949 sourceProc[bndI] = -1;
950 sourcePatch[bndI] =
patchi;
951 sourceNbrPatch[bndI] = -1;
952 sourceNewNbrProc[bndI] = -1;
959 sourcePointMaster.setSize(mesh_.nPoints());
960 sourcePointMaster = -1;
963 const globalIndex globalPoints(mesh_.nPoints());
965 const globalMeshData& gmd = mesh_.globalData();
967 const labelList& meshPoints = cpp.meshPoints();
968 const distributionMap& slavesMap = gmd.globalCoPointSlavesMap();
971 labelList elems(slavesMap.constructSize(), -1);
972 forAll(meshPoints, pointi)
980 label globalPointi = globalPoints.toGlobal(meshPoints[pointi]);
981 elems[pointi] = globalPointi;
984 label sloti = slots[i];
985 if (sloti >= meshPoints.size())
989 elems[slots[i]] = globalPointi;
996 slavesMap.reverseDistribute(elems.size(), elems,
false);
999 forAll(meshPoints, pointi)
1001 sourcePointMaster[meshPoints[pointi]] = elems[pointi];
1007 void Foam::fvMeshDistribute::subsetCouplingData
1017 const label oldInternalFaces,
1034 subFace.setSize(mesh.nFaces() - mesh.nInternalFaces());
1035 subProc.setSize(mesh.nFaces() - mesh.nInternalFaces());
1036 subPatch.setSize(mesh.nFaces() - mesh.nInternalFaces());
1037 subNbrPatch.setSize(mesh.nFaces() - mesh.nInternalFaces());
1038 subNewNbrProc.setSize(mesh.nFaces() - mesh.nInternalFaces());
1040 forAll(subFace, newBFacei)
1042 label newFacei = newBFacei + mesh.nInternalFaces();
1047 if (oldFacei < oldInternalFaces)
1049 subFace[newBFacei] = oldFacei;
1051 subPatch[newBFacei] = -1;
1053 label oldOwn = oldFaceOwner[oldFacei];
1054 label oldNei = oldFaceNeighbour[oldFacei];
1056 if (oldOwn == cellMap[mesh.faceOwner()[newFacei]])
1059 subNewNbrProc[newBFacei] = oldDistribution[oldNei];
1064 subNewNbrProc[newBFacei] = oldDistribution[oldOwn];
1070 label oldBFacei = oldFacei - oldInternalFaces;
1072 subFace[newBFacei] = sourceFace[oldBFacei];
1073 subProc[newBFacei] = sourceProc[oldBFacei];
1074 subPatch[newBFacei] = sourcePatch[oldBFacei];
1075 subNbrPatch[newBFacei] = sourceNbrPatch[oldBFacei];
1076 subNewNbrProc[newBFacei] = sourceNewNbrProc[oldBFacei];
1081 subPointMaster = UIndirectList<label>(sourcePointMaster, pointMap);
1085 void Foam::fvMeshDistribute::findCouples
1087 const primitiveMesh& mesh,
1093 const primitiveMesh& domainMesh,
1104 HashTable<label, labelPair, labelPair::Hash<>> map(domainFace.size());
1106 forAll(domainProc, bFacei)
1108 if (domainProc[bFacei] != -1 && domainPatch[bFacei] == -1)
1112 labelPair(domainFace[bFacei], domainProc[bFacei]),
1121 masterCoupledFaces.setSize(domainFace.size());
1122 slaveCoupledFaces.setSize(domainFace.size());
1125 forAll(sourceFace, bFacei)
1127 if (sourceProc[bFacei] != -1 && sourcePatch[bFacei] == -1)
1129 labelPair myData(sourceFace[bFacei], sourceProc[bFacei]);
1131 HashTable<label, labelPair, labelPair::Hash<>>::const_iterator
1132 iter = map.find(myData);
1134 if (iter != map.end())
1136 label nbrBFacei = iter();
1138 masterCoupledFaces[coupledI] = mesh.nInternalFaces() + bFacei;
1139 slaveCoupledFaces[coupledI] =
1140 domainMesh.nInternalFaces()
1148 masterCoupledFaces.setSize(coupledI);
1149 slaveCoupledFaces.setSize(coupledI);
1153 Pout<<
"findCouples : found " << coupledI
1154 <<
" faces that will be stitched" <<
nl <<
endl;
1161 const primitiveMesh& mesh,
1162 const mapAddedPolyMesh& map,
1164 const label nInternalFaces1,
1168 labelList newBoundaryData(mesh.nFaces() - mesh.nInternalFaces());
1170 forAll(boundaryData0, oldBFacei)
1172 label newFacei = map.oldFaceMap()[oldBFacei + map.nOldInternalFaces()];
1175 if (newFacei >= 0 && newFacei >= mesh.nInternalFaces())
1177 newBoundaryData[newFacei - mesh.nInternalFaces()] =
1178 boundaryData0[oldBFacei];
1182 forAll(boundaryData1, addedBFacei)
1184 label newFacei = map.addedFaceMap()[addedBFacei + nInternalFaces1];
1186 if (newFacei >= 0 && newFacei >= mesh.nInternalFaces())
1188 newBoundaryData[newFacei - mesh.nInternalFaces()] =
1189 boundaryData1[addedBFacei];
1193 return newBoundaryData;
1199 const primitiveMesh& mesh,
1200 const mapAddedPolyMesh& map,
1205 labelList newBoundaryData(mesh.nPoints());
1207 forAll(boundaryData0, oldPointi)
1214 newBoundaryData[
newPointi] = boundaryData0[oldPointi];
1218 forAll(boundaryData1, addedPointi)
1224 newBoundaryData[
newPointi] = boundaryData1[addedPointi];
1228 return newBoundaryData;
1235 const label oldInternalPatchi
1239 polyTopoChange meshMod(mesh_);
1243 removeCells cellRemover(mesh_,
false);
1246 labelList exposedFaces(cellRemover.getExposedFaces(cellsToRemove));
1249 cellRemover.setRefinement
1253 labelList(exposedFaces.size(), oldInternalPatchi),
1260 PtrList<Field<scalar>> sFlds;
1261 PtrList<Field<vector>> vFlds;
1262 PtrList<Field<sphericalTensor>> sptFlds;
1263 PtrList<Field<symmTensor>> sytFlds;
1264 PtrList<Field<tensor>> tFlds;
1265 initMapExposedFaces(sFlds);
1266 initMapExposedFaces(vFlds);
1267 initMapExposedFaces(sptFlds);
1268 initMapExposedFaces(sytFlds);
1269 initMapExposedFaces(tFlds);
1272 autoPtr<polyTopoChangeMap> map = meshMod.changeMesh(mesh_,
false,
false);
1275 mesh_.mapFields(map);
1280 mapExposedFaces(map(), sFlds);
1281 mapExposedFaces(map(), vFlds);
1282 mapExposedFaces(map(), sptFlds);
1283 mapExposedFaces(map(), sytFlds);
1284 mapExposedFaces(map(), tFlds);
1290 void Foam::fvMeshDistribute::addProcPatches
1295 List<Map<label>>& procPatchID
1311 lessProcPatches(nbrProc, referPatchID, referNbrPatchID)
1318 label bFacei = indices[i];
1319 label proci = nbrProc[bFacei];
1323 if (!procPatchID[proci].
found(referPatchID[bFacei]))
1328 if (referPatchID[bFacei] == -1)
1332 processorPolyPatch pp
1336 mesh_.boundaryMesh().size(),
1337 mesh_.boundaryMesh(),
1342 procPatchID[proci].insert
1344 referPatchID[bFacei],
1357 const coupledPolyPatch& pcPatch
1358 = refCast<const coupledPolyPatch>
1360 mesh_.boundaryMesh()[referPatchID[bFacei]]
1362 processorCyclicPolyPatch pp
1366 mesh_.boundaryMesh().size(),
1367 mesh_.boundaryMesh(),
1373 procPatchID[proci].insert
1375 referPatchID[bFacei],
1396 const List<Map<label>>& procPatchID
1405 label origPatchi = referPatchID[bFacei];
1406 patchIDs[bFacei] = origPatchi;
1408 else if (nbrProc[bFacei] != -1)
1410 label origPatchi = referPatchID[bFacei];
1411 patchIDs[bFacei] = procPatchID[nbrProc[bFacei]][origPatchi];
1415 patchIDs[bFacei] = -1;
1422 void Foam::fvMeshDistribute::sendMesh
1442 Pout<<
"Sending to domain " << domain <<
nl
1443 <<
" nPoints:" << mesh.nPoints() <<
nl
1444 <<
" nFaces:" << mesh.nFaces() <<
nl
1445 <<
" nCells:" << mesh.nCells() <<
nl
1446 <<
" nPatches:" << mesh.boundaryMesh().size() <<
nl
1452 CompactListList<label> zonePoints;
1456 labelList rowSizes(pointZoneNames.size(), 0);
1458 forAll(pointZoneNames, nameI)
1460 label myZoneID = pointZones.findZoneID(pointZoneNames[nameI]);
1464 rowSizes[nameI] = pointZones[myZoneID].size();
1467 zonePoints.setSize(rowSizes);
1469 forAll(pointZoneNames, nameI)
1471 label myZoneID = pointZones.findZoneID(pointZoneNames[nameI]);
1475 zonePoints[nameI].deepCopy(pointZones[myZoneID]);
1481 CompactListList<label> zoneFaces;
1482 CompactListList<bool> zoneFaceFlip;
1486 labelList rowSizes(faceZoneNames.size(), 0);
1488 forAll(faceZoneNames, nameI)
1490 label myZoneID = faceZones.findZoneID(faceZoneNames[nameI]);
1494 rowSizes[nameI] = faceZones[myZoneID].size();
1498 zoneFaces.setSize(rowSizes);
1499 zoneFaceFlip.setSize(rowSizes);
1501 forAll(faceZoneNames, nameI)
1503 label myZoneID = faceZones.findZoneID(faceZoneNames[nameI]);
1507 zoneFaces[nameI].deepCopy(faceZones[myZoneID]);
1508 zoneFaceFlip[nameI].deepCopy(faceZones[myZoneID].flipMap());
1514 CompactListList<label> zoneCells;
1518 labelList rowSizes(cellZoneNames.size(), 0);
1520 forAll(cellZoneNames, nameI)
1522 label myZoneID = cellZones.findZoneID(cellZoneNames[nameI]);
1526 rowSizes[nameI] = cellZones[myZoneID].size();
1530 zoneCells.setSize(rowSizes);
1532 forAll(cellZoneNames, nameI)
1534 label myZoneID = cellZones.findZoneID(cellZoneNames[nameI]);
1538 zoneCells[nameI].deepCopy(cellZones[myZoneID]);
1560 << CompactListList<label>(mesh.faces())
1562 << mesh.faceNeighbour()
1563 << mesh.boundaryMesh()
1579 << sourcePointMaster;
1584 Pout<<
"Started sending mesh to domain " << domain
1596 const Time& runTime,
1607 faceList domainFaces = CompactListList<label>(fromNbr).list<face>();
1610 PtrList<entry> patchEntries(fromNbr);
1616 CompactListList<label> zonePoints(fromNbr);
1617 CompactListList<label> zoneFaces(fromNbr);
1618 CompactListList<bool> zoneFaceFlip(fromNbr);
1619 CompactListList<label> zoneCells(fromNbr);
1624 >> domainSourcePatch
1625 >> domainSourceNbrPatch
1626 >> domainSourceNewNbrProc
1627 >> domainSourcePointMaster;
1630 autoPtr<fvMesh> domainMeshPtr
1643 move(domainAllOwner),
1644 move(domainAllNeighbour),
1648 fvMesh& domainMesh = domainMeshPtr();
1650 List<polyPatch*>
patches(patchEntries.size());
1656 patchEntries[
patchi].keyword(),
1659 domainMesh.boundaryMesh()
1663 domainMesh.addFvPatches(
patches,
false);
1670 List<pointZone*> pZonePtrs(pointZoneNames.size());
1673 pZonePtrs[i] =
new pointZone
1678 domainMesh.pointZones()
1682 List<faceZone*> fZonePtrs(faceZoneNames.size());
1685 fZonePtrs[i] =
new faceZone
1691 domainMesh.faceZones()
1695 List<cellZone*> cZonePtrs(cellZoneNames.size());
1698 cZonePtrs[i] =
new cellZone
1703 domainMesh.cellZones()
1706 domainMesh.addZones(pZonePtrs, fZonePtrs, cZonePtrs);
1708 return domainMeshPtr;
1737 <<
"At index " << celli <<
" distribution:" << newProc
1755 <<
"Size of distribution:"
1764 if (
patches.checkParallelSync(
true))
1767 <<
"This application requires all non-processor patches"
1768 <<
" to be present in the same order on all patches" <<
nl
1769 <<
"followed by the processor patches (which of course are unique)."
1771 <<
"Local patches:" << mesh_.boundaryMesh().names()
1776 const label nOldPoints(mesh_.nPoints());
1777 const label nOldFaces(mesh_.nFaces());
1778 const label nOldCells(mesh_.nCells());
1801 move(oldPatchStarts),
1802 move(oldPatchNMeshPoints),
1819 const wordList pointZoneNames(mergeWordList(mesh_.pointZones().names()));
1820 const wordList faceZoneNames(mergeWordList(mesh_.faceZones().names()));
1821 const wordList cellZoneNames(mergeWordList(mesh_.cellZones().names()));
1883 mesh_.resetMotion();
1889 nFields += checkEqualWordList(
"volScalarFields", volScalars);
1891 nFields += checkEqualWordList(
"volVectorFields", volVectors);
1896 nFields += checkEqualWordList(
"volSphericalTensorFields", volSphereTensors);
1898 nFields += checkEqualWordList(
"volSymmTensorFields", volSymmTensors);
1900 nFields += checkEqualWordList(
"volTensorField", volTensors);
1903 nFields += checkEqualWordList(
"surfaceScalarFields", surfScalars);
1905 nFields += checkEqualWordList(
"surfaceVectorFields", surfVectors);
1910 nFields += checkEqualWordList
1912 "surfaceSphericalTensorFields",
1919 nFields += checkEqualWordList(
"surfaceSymmTensorFields", surfSymmTensors);
1921 nFields += checkEqualWordList(
"surfaceTensorFields", surfTensors);
1924 nFields += checkEqualWordList(
"pointScalarFields", pointScalars);
1926 nFields += checkEqualWordList(
"pointVectorFields", pointVectors);
1931 nFields += checkEqualWordList
1933 "pointSphericalTensorFields",
1940 nFields += checkEqualWordList(
"pointSymmTensorFields", pointSymmTensors);
1942 nFields += checkEqualWordList(
"pointTensorFields", pointTensors);
1945 nFields += checkEqualWordList(
"volScalarField::Internal", dimScalars);
1948 nFields += checkEqualWordList(
"volVectorField::Internal", dimVectors);
1954 nFields += checkEqualWordList
1956 "volSphericalTensorField::Internal",
1964 nFields += checkEqualWordList
1966 "volSymmTensorField::Internal",
1971 nFields += checkEqualWordList(
"volTensorField::Internal", dimTensors);
1976 const label oldInternalPatchi =
1978 ? findInternalPatch()
1979 : findNonEmptyPatch();
1986 deleteProcPatches(oldInternalPatchi);
1989 repatchFaceMap = repatchMap().faceMap();
1996 repatchMap().reverseFaceMap(),
1997 mesh_.nFaces() - mesh_.nInternalFaces(),
1998 mesh_.nInternalFaces()
2000 - mesh_.nInternalFaces()
2015 Pout<<
nl <<
"MESH WITH PROC PATCHES DELETED:" <<
endl;
2016 printMeshInfo(mesh_);
2017 printFieldInfo<volScalarField>(mesh_);
2018 printFieldInfo<volVectorField>(mesh_);
2019 printFieldInfo<volSphericalTensorField>(mesh_);
2020 printFieldInfo<volSymmTensorField>(mesh_);
2021 printFieldInfo<volTensorField>(mesh_);
2022 printFieldInfo<surfaceScalarField>(mesh_);
2023 printFieldInfo<surfaceVectorField>(mesh_);
2024 printFieldInfo<surfaceSphericalTensorField>(mesh_);
2025 printFieldInfo<surfaceSymmTensorField>(mesh_);
2026 printFieldInfo<surfaceTensorField>(mesh_);
2027 printFieldInfo<pointScalarField>(mesh_);
2028 printFieldInfo<pointVectorField>(mesh_);
2029 printFieldInfo<pointSphericalTensorField>(mesh_);
2030 printFieldInfo<pointSymmTensorField>(mesh_);
2031 printFieldInfo<pointTensorField>(mesh_);
2083 <<
"SUBSETTING FOR DOMAIN " << recvProc
2084 <<
" cells to send:"
2105 subCellMap[recvProc] = subsetter.
cellMap();
2107 inplaceRenumberWithFlip
2112 subFaceMap[recvProc]
2114 subPointMap[recvProc] = subsetter.
pointMap();
2115 subPatchMap[recvProc] = subsetter.
patchMap();
2135 mesh_.faceNeighbour(),
2136 mesh_.nInternalFaces(),
2149 procSourceNewNbrProc,
2150 procSourcePointMaster
2168 procSourceNewNbrProc,
2169 procSourcePointMaster,
2175 sendFields<volScalarField>(recvProc, volScalars, subsetter, str);
2176 sendFields<volVectorField>(recvProc, volVectors, subsetter, str);
2177 sendFields<volSphericalTensorField>
2184 sendFields<volSymmTensorField>
2191 sendFields<volTensorField>(recvProc, volTensors, subsetter, str);
2194 sendFields<surfaceScalarField>
2201 sendFields<surfaceVectorField>
2208 sendFields<surfaceSphericalTensorField>
2215 sendFields<surfaceSymmTensorField>
2222 sendFields<surfaceTensorField>
2231 sendFields<pointScalarField>
2238 sendFields<pointVectorField>
2245 sendFields<pointSphericalTensorField>
2252 sendFields<pointSymmTensorField>
2259 sendFields<pointTensorField>
2268 sendFields<volScalarField::Internal>
2275 sendFields<volVectorField::Internal>
2282 sendFields<volSphericalTensorField::Internal>
2289 sendFields<volSymmTensorField::Internal>
2296 sendFields<volTensorField::Internal>
2319 const labelList oldFaceOwner(mesh_.faceOwner());
2320 const labelList oldFaceNeighbour(mesh_.faceNeighbour());
2321 const label oldInternalFaces = mesh_.nInternalFaces();
2349 label facei = iter.key();
2373 subMap().pointMap(),
2392 domainSourceNbrPatch,
2393 domainSourceNewNbrProc,
2394 domainSourcePointMaster
2397 sourceFace.
transfer(domainSourceFace);
2398 sourceProc.
transfer(domainSourceProc);
2399 sourcePatch.
transfer(domainSourcePatch);
2400 sourceNbrPatch.
transfer(domainSourceNbrPatch);
2401 sourceNewNbrProc.
transfer(domainSourceNewNbrProc);
2402 sourcePointMaster.
transfer(domainSourcePointMaster);
2410 printMeshInfo(mesh_);
2411 printFieldInfo<volScalarField>(mesh_);
2412 printFieldInfo<volVectorField>(mesh_);
2413 printFieldInfo<volSphericalTensorField>(mesh_);
2414 printFieldInfo<volSymmTensorField>(mesh_);
2415 printFieldInfo<volTensorField>(mesh_);
2416 printFieldInfo<surfaceScalarField>(mesh_);
2417 printFieldInfo<surfaceVectorField>(mesh_);
2418 printFieldInfo<surfaceSphericalTensorField>(mesh_);
2419 printFieldInfo<surfaceSymmTensorField>(mesh_);
2420 printFieldInfo<surfaceTensorField>(mesh_);
2421 printFieldInfo<pointScalarField>(mesh_);
2422 printFieldInfo<pointVectorField>(mesh_);
2423 printFieldInfo<pointSphericalTensorField>(mesh_);
2424 printFieldInfo<pointSymmTensorField>(mesh_);
2425 printFieldInfo<pointTensorField>(mesh_);
2437 forAll(nSendCells, sendProc)
2449 <<
"RECEIVING FROM DOMAIN " << sendProc
2450 <<
" cells to receive:"
2497 domainMeshPtr = receiveMesh
2504 const_cast<Time&
>(mesh_.time()),
2508 domainSourceNbrPatch,
2509 domainSourceNewNbrProc,
2510 domainSourcePointMaster,
2513 fvMesh& domainMesh = domainMeshPtr();
2523 receiveFields<volScalarField>
2531 receiveFields<volVectorField>
2539 receiveFields<volSphericalTensorField>
2547 receiveFields<volSymmTensorField>
2555 receiveFields<volTensorField>
2565 receiveFields<surfaceScalarField>
2573 receiveFields<surfaceVectorField>
2581 receiveFields<surfaceSphericalTensorField>
2589 receiveFields<surfaceSymmTensorField>
2597 receiveFields<surfaceTensorField>
2609 receiveFields<pointScalarField>
2617 receiveFields<pointVectorField>
2625 receiveFields<pointSphericalTensorField>
2633 receiveFields<pointSymmTensorField>
2641 receiveFields<pointTensorField>
2651 receiveFields<volScalarField::Internal>
2662 receiveFields<volVectorField::Internal>
2673 receiveFields<volSphericalTensorField::Internal>
2685 receiveFields<volSymmTensorField::Internal>
2696 receiveFields<volTensorField::Internal>
2708 const fvMesh& domainMesh = domainMeshPtr();
2714 constructPatchMap[sendProc] =
2721 Pout<<
nl <<
"RECEIVED MESH FROM:" << sendProc <<
endl;
2722 printMeshInfo(domainMesh);
2723 printFieldInfo<volScalarField>(domainMesh);
2724 printFieldInfo<volVectorField>(domainMesh);
2725 printFieldInfo<volSphericalTensorField>(domainMesh);
2726 printFieldInfo<volSymmTensorField>(domainMesh);
2727 printFieldInfo<volTensorField>(domainMesh);
2728 printFieldInfo<surfaceScalarField>(domainMesh);
2729 printFieldInfo<surfaceVectorField>(domainMesh);
2730 printFieldInfo<surfaceSphericalTensorField>(domainMesh);
2731 printFieldInfo<surfaceSymmTensorField>(domainMesh);
2732 printFieldInfo<surfaceTensorField>(domainMesh);
2733 printFieldInfo<pointScalarField>(domainMesh);
2734 printFieldInfo<pointVectorField>(domainMesh);
2735 printFieldInfo<pointSphericalTensorField>(domainMesh);
2736 printFieldInfo<pointSymmTensorField>(domainMesh);
2737 printFieldInfo<pointTensorField>(domainMesh);
2791 sourceFace = mapBoundaryData
2799 sourceProc = mapBoundaryData
2807 sourcePatch = mapBoundaryData
2815 sourceNbrPatch = mapBoundaryData
2821 domainSourceNbrPatch
2823 sourceNewNbrProc = mapBoundaryData
2829 domainSourceNewNbrProc
2832 sourcePointMaster = mapPointData
2837 domainSourcePointMaster
2843 const labelList& oldCellMap = map().oldCellMap();
2844 const labelList& oldFaceMap = map().oldFaceMap();
2845 const labelList& oldPointMap = map().oldPointMap();
2846 const labelList& oldPatchMap = map().oldPatchMap();
2849 forAll(constructPatchMap, proci)
2851 if (proci != sendProc && constructPatchMap[proci].size())
2855 inplaceRenumberWithFlip
2860 constructFaceMap[proci]
2873 flippedAddedFaces.
resize(nBnd/4);
2878 domainFacei < domainMesh.
nFaces();
2882 label newFacei = map().addedFaceMap()[domainFacei];
2883 label newCellI = mesh_.faceOwner()[newFacei];
2887 if (newCellI != map().addedCellMap()[domainCellI])
2889 flippedAddedFaces.
insert(domainFacei);
2900 label domainFacei = iter.key();
2901 label& val = constructFaceMap[sendProc][domainFacei];
2904 inplaceRenumberWithFlip
2906 map().addedFaceMap(),
2909 constructFaceMap[sendProc]
2916 Pout<<
nl <<
"MERGED MESH FROM:" << sendProc <<
endl;
2917 printMeshInfo(mesh_);
2918 printFieldInfo<volScalarField>(mesh_);
2919 printFieldInfo<volVectorField>(mesh_);
2920 printFieldInfo<volSphericalTensorField>(mesh_);
2921 printFieldInfo<volSymmTensorField>(mesh_);
2922 printFieldInfo<volTensorField>(mesh_);
2923 printFieldInfo<surfaceScalarField>(mesh_);
2924 printFieldInfo<surfaceVectorField>(mesh_);
2925 printFieldInfo<surfaceSphericalTensorField>(mesh_);
2926 printFieldInfo<surfaceSymmTensorField>(mesh_);
2927 printFieldInfo<surfaceTensorField>(mesh_);
2928 printFieldInfo<pointScalarField>(mesh_);
2929 printFieldInfo<pointVectorField>(mesh_);
2930 printFieldInfo<pointSphericalTensorField>(mesh_);
2931 printFieldInfo<pointSymmTensorField>(mesh_);
2932 printFieldInfo<pointTensorField>(mesh_);
2944 printMeshInfo(mesh_);
2945 printFieldInfo<volScalarField>(mesh_);
2946 printFieldInfo<volVectorField>(mesh_);
2947 printFieldInfo<volSphericalTensorField>(mesh_);
2948 printFieldInfo<volSymmTensorField>(mesh_);
2949 printFieldInfo<volTensorField>(mesh_);
2950 printFieldInfo<surfaceScalarField>(mesh_);
2951 printFieldInfo<surfaceVectorField>(mesh_);
2952 printFieldInfo<surfaceSphericalTensorField>(mesh_);
2953 printFieldInfo<surfaceSymmTensorField>(mesh_);
2954 printFieldInfo<surfaceTensorField>(mesh_);
2955 printFieldInfo<pointScalarField>(mesh_);
2956 printFieldInfo<pointVectorField>(mesh_);
2957 printFieldInfo<pointSphericalTensorField>(mesh_);
2958 printFieldInfo<pointSymmTensorField>(mesh_);
2959 printFieldInfo<pointTensorField>(mesh_);
2966 mergeSharedPoints(sourcePointMaster, constructPointMap);
2978 addProcPatches(sourceNewNbrProc, sourcePatch, sourceNbrPatch, procPatchID);
2997 repatch(newPatchID, constructFaceMap);
3000 correctCoupledPatchFields<volScalarField>();
3001 correctCoupledPatchFields<volVectorField>();
3002 correctCoupledPatchFields<volSphericalTensorField>();
3003 correctCoupledPatchFields<volSymmTensorField>();
3004 correctCoupledPatchFields<volTensorField>();
3006 mesh_.setInstance(mesh_.time().name());
3012 printMeshInfo(mesh_);
3013 printFieldInfo<volScalarField>(mesh_);
3014 printFieldInfo<volVectorField>(mesh_);
3015 printFieldInfo<volSphericalTensorField>(mesh_);
3016 printFieldInfo<volSymmTensorField>(mesh_);
3017 printFieldInfo<volTensorField>(mesh_);
3018 printFieldInfo<surfaceScalarField>(mesh_);
3019 printFieldInfo<surfaceVectorField>(mesh_);
3020 printFieldInfo<surfaceSphericalTensorField>(mesh_);
3021 printFieldInfo<surfaceSymmTensorField>(mesh_);
3022 printFieldInfo<surfaceTensorField>(mesh_);
3023 printFieldInfo<pointScalarField>(mesh_);
3024 printFieldInfo<pointVectorField>(mesh_);
3025 printFieldInfo<pointSphericalTensorField>(mesh_);
3026 printFieldInfo<pointSymmTensorField>(mesh_);
3027 printFieldInfo<pointTensorField>(mesh_);
3041 move(oldPatchStarts),
3042 move(oldPatchNMeshPoints),
3049 move(constructPointMap),
3050 move(constructFaceMap),
3051 move(constructCellMap),
3052 move(constructPatchMap),
Various functions to operate on Lists.
Combination-Reduction operation for a parallel run. The information from all nodes is collected on th...
#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.
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 meshFaceZones & faceZones() const
Return face zones.
virtual const labelList & faceOwner() const
Return face owner.
static word defaultRegion
Return the default region name.
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.
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.