65Foam::label Foam::meshRefinement::createBaffle
70 polyTopoChange& meshMod
73 const face&
f = mesh_.
faces()[faceI];
75 bool zoneFlip =
false;
80 zoneFlip = fZone.flipMap()[fZone.whichFace(faceI)];
107 <<
"No neighbour patch for internal face " << faceI
112 bool reverseFlip =
false;
115 reverseFlip = !zoneFlip;
118 dupFaceI = meshMod.setAction
178void Foam::meshRefinement::getIntersections
188 autoPtr<OBJstream> str;
189 if (debug&OBJINTERSECTIONS)
196 mesh_.time().path()/
timeName()/
"intersections.obj"
200 Pout<<
"getIntersections : Writing surface intersections to file "
205 globalRegion1.setSize(mesh_.nFaces());
207 globalRegion2.setSize(mesh_.nFaces());
235 List<pointIndexHit> hit1;
238 List<pointIndexHit> hit2;
240 surfaces_.findNearestIntersection
258 label faceI = testFaces[i];
260 if (hit1[i].hit() && hit2[i].hit())
264 str().write(
linePointRef(start[i], hit1[i].rawPoint()));
273 globalRegion1[faceI] =
274 surfaces_.globalRegion(surface1[i], region1[i]);
275 globalRegion2[faceI] =
276 surfaces_.globalRegion(surface2[i], region2[i]);
278 if (globalRegion1[faceI] == -1 || globalRegion2[faceI] == -1)
288void Foam::meshRefinement::getBafflePatches
290 const label nErodeCellZones,
295 const bool exitIfLeakPath,
296 const refPtr<coordSetWriter>& leakPathFormatter,
321 bitSet posOrientation;
329 locationsOutsideMesh,
351 ownPatch.setSize(mesh_.nFaces());
353 neiPatch.setSize(mesh_.nFaces());
358 if (unnamedRegion1[faceI] != -1 || unnamedRegion2[faceI] != -1)
360 label ownMasterPatch = -1;
361 if (unnamedRegion1[faceI] != -1)
363 ownMasterPatch = globalToMasterPatch[unnamedRegion1[faceI]];
365 label neiMasterPatch = -1;
366 if (unnamedRegion2[faceI] != -1)
368 neiMasterPatch = globalToMasterPatch[unnamedRegion2[faceI]];
375 label ownZone = cellToZone[mesh_.faceOwner()[faceI]];
378 if (mesh_.isInternalFace(faceI))
380 neiZone = cellToZone[mesh_.faceNeighbour()[faceI]];
384 neiZone = neiCellZone[faceI-mesh_.nInternalFaces()];
392 (ownZone >= 0 && neiZone != -2)
393 || (neiZone >= 0 && ownZone != -2)
396 namedSurfaceRegion.size() == 0
397 || namedSurfaceRegion[faceI] == -1
408 ownPatch[faceI] = ownMasterPatch;
409 neiPatch[faceI] = neiMasterPatch;
429 const bool allowBoundary,
434 Map<labelPair> bafflePatch(mesh_.nFaces()/1000);
436 const PtrList<surfaceZonesInfo>& surfZones = surfaces_.surfZones();
441 const wordList& faceZoneNames = surfZones[surfI].faceZoneNames();
443 forAll(faceZoneNames, fzi)
446 const word& faceZoneName = faceZoneNames[fzi];
447 label zoneI = fZones.findZoneID(faceZoneName);
448 const faceZone& fZone = fZones[zoneI];
451 label globalRegionI = surfaces_.globalRegion(surfI, fzi);
454 globalToMasterPatch[globalRegionI],
455 globalToSlavePatch[globalRegionI]
458 Info<<
"For zone " << fZone.name() <<
" found patches "
459 << mesh_.boundaryMesh()[zPatches[0]].name() <<
" and "
460 << mesh_.boundaryMesh()[zPatches[1]].name()
465 label faceI = fZone[i];
467 if (allowBoundary || mesh_.isInternalFace(faceI))
470 if (fZone.flipMap()[i])
475 if (!bafflePatch.insert(faceI,
patches))
479 <<
" fc:" << mesh_.faceCentres()[faceI]
480 <<
" in zone " << fZone.name()
481 <<
" is in multiple zones!"
500 ownPatch.
size() != mesh_.nFaces()
501 || neiPatch.
size() != mesh_.nFaces()
506 <<
" ownPatch:" << ownPatch.
size()
507 <<
" neiPatch:" << neiPatch.
size()
508 <<
". Should be number of faces:" << mesh_.nFaces()
519 forAll(syncedOwnPatch, faceI)
523 (ownPatch[faceI] == -1 && syncedOwnPatch[faceI] != -1)
524 || (neiPatch[faceI] == -1 && syncedNeiPatch[faceI] != -1)
528 <<
"Non synchronised at face:" << faceI
529 <<
" on patch:" << mesh_.boundaryMesh().whichPatch(faceI)
530 <<
" fc:" << mesh_.faceCentres()[faceI] <<
endl
531 <<
"ownPatch:" << ownPatch[faceI]
532 <<
" syncedOwnPatch:" << syncedOwnPatch[faceI]
533 <<
" neiPatch:" << neiPatch[faceI]
534 <<
" syncedNeiPatch:" << syncedNeiPatch[faceI]
545 for (label faceI = 0; faceI < mesh_.nInternalFaces(); faceI++)
547 if (ownPatch[faceI] != -1)
567 label coupledPatchI = -1;
571 && !refCast<const coupledPolyPatch>(pp).separated()
574 coupledPatchI = patchI;
579 label faceI = pp.
start()+i;
581 if (ownPatch[faceI] != -1)
591 if (coupledPatchI != -1)
593 faceToCoupledPatch_.insert(faceI, coupledPatchI);
610 mapPtr = meshMod.
changeMesh(mesh_,
false,
true);
614 mesh_.updateMesh(map);
633 faceSet baffledFacesSet(mesh_,
"baffledFacesSet", 2*nBaffles);
639 forAll(ownPatch, oldFaceI)
641 label faceI = reverseFaceMap[oldFaceI];
643 if (ownPatch[oldFaceI] != -1 && faceI >= 0)
645 const cell& ownFaces = mesh_.cells()[mesh_.faceOwner()[faceI]];
647 baffledFacesSet.
insert(ownFaces);
653 label oldFaceI =
faceMap[faceI];
655 if (oldFaceI >= 0 && reverseFaceMap[oldFaceI] != faceI)
657 const cell& ownFaces = mesh_.cells()[mesh_.faceOwner()[faceI]];
659 baffledFacesSet.
insert(ownFaces);
662 baffledFacesSet.
sync(mesh_);
664 updateMesh(map, baffledFacesSet.
toc());
682 const faceZone& fZone = faceZones[zoneI];
686 bool hasInfo = getFaceZoneInfo(fZone.
name(), mpI, spI, fzType);
688 if (hasInfo && fzTypes.
found(fzType))
721 if (faceToZone[
p[0]] != -1 && (faceToZone[
p[0]] == faceToZone[
p[1]]))
743 ownPatch.
setSize(mesh_.nFaces());
745 neiPatch.
setSize(mesh_.nFaces());
754 const bitSet isInternalOrCoupled
762 const faceZone& fz = faceZones[zoneI];
763 const word& masterName = faceZoneToMasterPatch_[fz.
name()];
764 label masterPatchI = mesh_.boundaryMesh().findPatchID(masterName);
765 const word& slaveName = faceZoneToSlavePatch_[fz.
name()];
766 label slavePatchI = mesh_.boundaryMesh().findPatchID(slaveName);
768 if (masterPatchI == -1 || slavePatchI == -1)
771 <<
"Problem: masterPatchI:" << masterPatchI
778 if (isInternalOrCoupled[faceI])
782 ownPatch[faceI] = slavePatchI;
783 neiPatch[faceI] = masterPatchI;
787 ownPatch[faceI] = masterPatchI;
788 neiPatch[faceI] = slavePatchI;
813 Info<<
"Converting zoned faces into baffles ..." <<
endl;
822 label nLocalBaffles =
sum(nBaffles);
827 if (nTotalBaffles > 0)
832 <<
setf(ios_base::left)
833 <<
setw(30) <<
"FaceZone"
834 <<
setw(10) <<
"FaceType"
835 <<
setw(10) <<
"nBaffles"
837 <<
setw(30) <<
"--------"
838 <<
setw(10) <<
"--------"
839 <<
setw(10) <<
"--------"
845 const faceZone& fz = faceZones[zoneI];
849 bool hasInfo = getFaceZoneInfo(fz.
name(), mpI, spI, fzType);
857 <<
setw(10) << nBaffles[j]
864 map = createBaffles(ownPatch, neiPatch);
870 baffles.
setSize(nLocalBaffles);
871 originatingFaceZone.
setSize(nLocalBaffles);
875 const labelList& reverseFaceMap = map().reverseFaceMap();
879 label faceI = mesh_.nInternalFaces();
880 faceI < mesh_.nFaces();
884 label oldFaceI =
faceMap[faceI];
885 label masterFaceI = reverseFaceMap[oldFaceI];
886 if (masterFaceI != faceI && ownPatch[oldFaceI] != -1)
888 baffles[baffleI] =
labelPair(masterFaceI, faceI);
889 originatingFaceZone[baffleI] =
faceZoneID[oldFaceI];
894 if (baffleI != baffles.
size())
897 <<
"Had " << baffles.
size() <<
" baffles to create "
898 <<
" but encountered " << baffleI
899 <<
" slave faces originating from patcheable faces."
905 const_cast<Time&
>(mesh_.time())++;
906 Pout<<
"Writing zone-baffled mesh to time " <<
timeName()
912 mesh_.time().path()/
"baffles"
916 Info<<
"Created " << nTotalBaffles <<
" baffles in = "
917 << mesh_.time().cpuTimeIncrement() <<
" s\n" <<
nl <<
endl;
922 originatingFaceZone.
clear();
932 const scalar planarAngle
959 const label baffleValue = 1000000;
974 label faceI = pp.
start();
978 const labelList& fEdges = mesh_.faceEdges(faceI);
982 nBafflesPerEdge[fEdges[fEdgeI]]++;
990 DynamicList<label> fe0;
991 DynamicList<label> fe1;
1000 label f0 = couples[i].
first();
1001 const labelList& fEdges0 = mesh_.faceEdges(f0, fe0);
1004 nBafflesPerEdge[fEdges0[fEdgeI]] += baffleValue;
1009 label f1 = couples[i].second();
1010 const labelList& fEdges1 = mesh_.faceEdges(f1, fe1);
1013 nBafflesPerEdge[fEdges1[fEdgeI]] += baffleValue;
1032 List<labelPair> filteredCouples(couples.
size());
1045 const labelList& fEdges = mesh_.faceEdges(couple.first());
1049 label edgeI = fEdges[fEdgeI];
1051 if (nBafflesPerEdge[edgeI] == 2*baffleValue+2*1)
1053 filteredCouples[filterI++] = couple;
1059 filteredCouples.setSize(filterI);
1062 label nFiltered =
returnReduce(filteredCouples.size(), sumOp<label>());
1064 Info<<
"freeStandingBaffles : detected "
1066 <<
" free-standing baffles out of "
1079 const pointField& cellCentres = mesh_.cellCentres();
1081 forAll(filteredCouples, i)
1083 const labelPair& couple = filteredCouples[i];
1084 start[i] = cellCentres[mesh_.faceOwner()[couple.first()]];
1085 end[i] = cellCentres[mesh_.faceOwner()[couple.second()]];
1090 const vectorField smallVec(ROOTSMALL*(end-start));
1099 List<pointIndexHit> hit1;
1104 List<pointIndexHit> hit2;
1108 surfaces_.findNearestIntersection
1110 identity(surfaces_.surfaces().size()),
1134 forAll(filteredCouples, i)
1136 const labelPair& couple = filteredCouples[i];
1150 &&
mag(hit1[i].hitPoint()-hit2[i].hitPoint()) > mergeDistance_
1161 if ((normal1[i]&normal2[i]) > planarAngleCos)
1165 scalar magN =
mag(
n);
1168 filteredCouples[filterI++] = couple;
1172 else if (hit1[i].hit() || hit2[i].hit())
1178 filteredCouples.setSize(filterI);
1180 Info<<
"freeStandingBaffles : detected "
1182 <<
" planar (within " << planarAngle
1183 <<
" degrees) free-standing baffles out of "
1188 return filteredCouples;
1205 const faceList& faces = mesh_.faces();
1206 const labelList& faceOwner = mesh_.faceOwner();
1211 label face0 = couples[i].
first();
1212 label face1 = couples[i].second();
1217 label own0 = faceOwner[face0];
1218 label own1 = faceOwner[face1];
1220 if (face1 < 0 || own0 < own1)
1224 bool zoneFlip =
false;
1232 label nei = (face1 < 0 ? -1 : own1);
1255 bool zoneFlip =
false;
1284 const label faceI = iter.key();
1285 const label patchI = iter.val();
1287 if (!mesh_.isInternalFace(faceI))
1290 <<
"problem: face:" << faceI
1291 <<
" at:" << mesh_.faceCentres()[faceI]
1292 <<
"(wanted patch:" << patchI
1297 bool zoneFlip =
false;
1325 mesh_.moving(
false);
1328 mapPtr = meshMod.
changeMesh(mesh_,
false,
true);
1332 mesh_.updateMesh(map);
1359 newExposedFaces[newI++] = newFace0;
1362 const label newFace1 = map.
reverseFaceMap()[couples[i].second()];
1365 newExposedFaces[newI++] = newFace1;
1368 newExposedFaces.
setSize(newI);
1369 updateMesh(map, newExposedFaces);
1378 const bool doInternalZones,
1379 const bool doBaffleZones
1385 if (doInternalZones)
1409 mapPtr = mergeBaffles(zoneBaffles,
Map<label>(0));
1416void Foam::meshRefinement::findCellZoneGeometric
1426 const pointField& cellCentres = mesh_.cellCentres();
1427 const labelList& faceOwner = mesh_.faceOwner();
1428 const labelList& faceNeighbour = mesh_.faceNeighbour();
1432 surfaces_.findInside
1434 closedNamedSurfaces,
1439 forAll(insideSurfaces, cellI)
1441 label surfI = insideSurfaces[cellI];
1445 if (cellToZone[cellI] == -2)
1447 cellToZone[cellI] = surfaceToCellZone[surfI];
1449 else if (cellToZone[cellI] == -1)
1454 cellToZone[cellI] = surfaceToCellZone[surfI];
1467 label nCandidates = 0;
1468 forAll(namedSurfaceRegion, faceI)
1470 if (namedSurfaceRegion[faceI] != -1)
1472 if (mesh_.isInternalFace(faceI))
1486 forAll(namedSurfaceRegion, faceI)
1488 if (namedSurfaceRegion[faceI] != -1)
1490 label own = faceOwner[faceI];
1491 const point& ownCc = cellCentres[own];
1493 if (mesh_.isInternalFace(faceI))
1495 label nei = faceNeighbour[faceI];
1496 const point& neiCc = cellCentres[nei];
1498 const vector d = 1
e-4*(neiCc - ownCc);
1499 candidatePoints[nCandidates++] = ownCc-d;
1500 candidatePoints[nCandidates++] = neiCc+d;
1505 const point& neiFc = neiCc[faceI-mesh_.nInternalFaces()];
1508 const vector d = 1
e-4*(neiFc - ownCc);
1509 candidatePoints[nCandidates++] = ownCc-d;
1517 surfaces_.findInside
1519 closedNamedSurfaces,
1528 forAll(namedSurfaceRegion, faceI)
1530 if (namedSurfaceRegion[faceI] != -1)
1532 label own = faceOwner[faceI];
1534 if (mesh_.isInternalFace(faceI))
1536 label ownSurfI = insideSurfaces[nCandidates++];
1539 cellToZone[own] = surfaceToCellZone[ownSurfI];
1542 label neiSurfI = insideSurfaces[nCandidates++];
1545 label nei = faceNeighbour[faceI];
1547 cellToZone[nei] = surfaceToCellZone[neiSurfI];
1552 label ownSurfI = insideSurfaces[nCandidates++];
1555 cellToZone[own] = surfaceToCellZone[ownSurfI];
1566 for (label faceI = 0; faceI < mesh_.nInternalFaces(); faceI++)
1568 label ownZone = cellToZone[mesh_.faceOwner()[faceI]];
1569 label neiZone = cellToZone[mesh_.faceNeighbour()[faceI]];
1571 if (namedSurfaceRegion[faceI] == -1 && (ownZone != neiZone))
1581 else if (neiZone == -1)
1587 minZone =
min(ownZone, neiZone);
1592 label geomSurfI = surfaceToCellZone.
find(minZone);
1594 if (geomSurfI != -1)
1596 namedSurfaceRegion[faceI] =
1597 surfaces_.globalRegion(geomSurfI, 0);
1605 const polyBoundaryMesh&
patches = mesh_.boundaryMesh();
1609 const polyPatch& pp =
patches[patchI];
1615 label faceI = pp.start()+i;
1616 label ownZone = cellToZone[mesh_.faceOwner()[faceI]];
1617 label neiZone = neiCellZone[faceI-mesh_.nInternalFaces()];
1619 if (namedSurfaceRegion[faceI] == -1 && (ownZone != neiZone))
1627 else if (neiZone == -1)
1633 minZone =
min(ownZone, neiZone);
1638 label geomSurfI = surfaceToCellZone.
find(minZone);
1640 if (geomSurfI != -1)
1642 namedSurfaceRegion[faceI] =
1643 surfaces_.globalRegion(geomSurfI, 0);
1655void Foam::meshRefinement::findCellZoneInsideWalk
1665 boolList blockedFace(mesh_.nFaces());
1668 forAll(blockedFace, faceI)
1670 if (faceToZone[faceI] == -1)
1672 blockedFace[faceI] =
false;
1676 blockedFace[faceI] =
true;
1682 regionSplit cellRegion(mesh_, blockedFace);
1683 blockedFace.clear();
1686 (void)mesh_.tetBasePtIs();
1689 forAll(locationsInMesh, i)
1692 const point& insidePoint = locationsInMesh[i];
1693 label
zoneID = zonesInMesh[i];
1696 label keepRegionI = findRegion
1700 vector::uniform(mergeDistance_),
1704 Info<<
"For cellZone "
1710 <<
" found point " << insidePoint
1711 <<
" in global region " << keepRegionI
1712 <<
" out of " << cellRegion.nRegions() <<
" regions." <<
endl;
1714 if (keepRegionI == -1)
1717 <<
"Point " << insidePoint
1718 <<
" is not inside the mesh." <<
nl
1719 <<
"Bounding box of the mesh:" << mesh_.bounds()
1728 label nWarnings = 0;
1730 forAll(cellRegion, cellI)
1732 if (cellRegion[cellI] == keepRegionI)
1734 if (cellToZone[cellI] == -2)
1737 cellToZone[cellI] =
zoneID;
1739 else if (cellToZone[cellI] !=
zoneID)
1741 if (cellToZone[cellI] != -1 && nWarnings < 10)
1745 <<
" at " << mesh_.cellCentres()[cellI]
1746 <<
" is inside cellZone "
1752 <<
" from locationInMesh " << insidePoint
1753 <<
" but already marked as being in zone "
1754 << mesh_.cellZones()[cellToZone[cellI]].name()
1756 <<
"This can happen if your surfaces are not"
1757 <<
" (sufficiently) closed."
1763 cellToZone[cellI] =
zoneID;
1771void Foam::meshRefinement::findCellZoneInsideWalk
1783 forAll(zoneNamesInMesh, i)
1785 zoneIDs[i] = czs.findZoneID(zoneNamesInMesh[i]);
1787 findCellZoneInsideWalk
1797bool Foam::meshRefinement::calcRegionToZone
1799 const label backgroundZoneID,
1800 const label surfZoneI,
1801 const label ownRegion,
1802 const label neiRegion,
1807 bool changed =
false;
1810 if (ownRegion != neiRegion)
1817 if (regionToCellZone[ownRegion] == -2)
1819 if (surfZoneI == -1)
1824 if (regionToCellZone[neiRegion] != -2)
1826 regionToCellZone[ownRegion] = regionToCellZone[neiRegion];
1830 else if (regionToCellZone[neiRegion] == surfZoneI)
1835 if (backgroundZoneID != -2)
1837 regionToCellZone[ownRegion] = backgroundZoneID;
1841 else if (regionToCellZone[neiRegion] != -2)
1845 regionToCellZone[ownRegion] = surfZoneI;
1849 else if (regionToCellZone[neiRegion] == -2)
1851 if (surfZoneI == -1)
1856 regionToCellZone[neiRegion] = regionToCellZone[ownRegion];
1859 else if (regionToCellZone[ownRegion] == surfZoneI)
1863 if (backgroundZoneID != -2)
1865 regionToCellZone[neiRegion] = backgroundZoneID;
1869 else if (regionToCellZone[ownRegion] != -2)
1873 regionToCellZone[neiRegion] = surfZoneI;
1882void Foam::meshRefinement::findCellZoneTopo
1884 const label backgroundZoneID,
1913 boolList blockedFace(mesh_.nFaces());
1915 forAll(unnamedSurfaceRegion, faceI)
1919 unnamedSurfaceRegion[faceI] == -1
1920 && namedSurfaceRegion[faceI] == -1
1923 blockedFace[faceI] =
false;
1927 blockedFace[faceI] =
true;
1933 regionSplit cellRegion(mesh_, blockedFace);
1934 blockedFace.clear();
1940 labelList regionToCellZone(cellRegion.nRegions(), -2);
1945 forAll(cellToZone, cellI)
1947 label regionI = cellRegion[cellI];
1948 if (cellToZone[cellI] != -2 && regionToCellZone[regionI] == -2)
1950 regionToCellZone[regionI] = cellToZone[cellI];
1963 forAll(locationsInMesh, i)
1965 const point& keepPoint = locationsInMesh[i];
1966 label keepRegionI = findRegion
1970 vector::uniform(mergeDistance_),
1974 Info<<
"Found point " << keepPoint
1975 <<
" in global region " << keepRegionI
1976 <<
" out of " << cellRegion.nRegions() <<
" regions." <<
endl;
1978 if (keepRegionI == -1)
1981 <<
"Point " << keepPoint
1982 <<
" is not inside the mesh." <<
nl
1983 <<
"Bounding box of the mesh:" << mesh_.bounds()
1991 if (regionToCellZone[keepRegionI] == -2)
1993 regionToCellZone[keepRegionI] = -1;
2012 bool changed =
false;
2016 for (label faceI = 0; faceI < mesh_.nInternalFaces(); faceI++)
2018 label regionI = namedSurfaceRegion[faceI];
2021 if (unnamedSurfaceRegion[faceI] == -1 && regionI != -1)
2026 label surfI = surfaces_.whichSurface(regionI).first();
2028 bool changedCell = calcRegionToZone
2031 surfaceToCellZone[surfI],
2032 cellRegion[mesh_.faceOwner()[faceI]],
2033 cellRegion[mesh_.faceNeighbour()[faceI]],
2037 changed = changed | changedCell;
2043 const polyBoundaryMesh&
patches = mesh_.boundaryMesh();
2053 const polyPatch& pp =
patches[patchI];
2059 label faceI = pp.start()+i;
2061 label regionI = namedSurfaceRegion[faceI];
2064 if (unnamedSurfaceRegion[faceI] == -1 && regionI != -1)
2066 label surfI = surfaces_.whichSurface(regionI).first();
2068 bool changedCell = calcRegionToZone
2071 surfaceToCellZone[surfI],
2072 cellRegion[mesh_.faceOwner()[faceI]],
2073 neiCellRegion[faceI-mesh_.nInternalFaces()],
2077 changed = changed | changedCell;
2092 Pout<<
"meshRefinement::findCellZoneTopo :"
2093 <<
" nRegions:" << regionToCellZone.size()
2094 <<
" of which visited (-1 = background, >= 0 : cellZone) :"
2097 forAll(regionToCellZone, regionI)
2099 if (regionToCellZone[regionI] != -2)
2101 Pout<<
"Region " << regionI
2102 <<
" becomes cellZone:" << regionToCellZone[regionI]
2109 forAll(cellToZone, cellI)
2111 label regionI = cellRegion[cellI];
2112 if (cellToZone[cellI] == -2 && regionToCellZone[regionI] != -2)
2114 cellToZone[cellI] = regionToCellZone[regionI];
2120void Foam::meshRefinement::erodeCellZone
2122 const label nErodeCellZones,
2123 const label backgroundZoneID,
2140 for (label iter = 0; iter < nErodeCellZones; iter++)
2147 for (label facei = 0; facei < mesh_.nInternalFaces(); facei++)
2151 unnamedSurfaceRegion[facei] == -1
2152 && namedSurfaceRegion[facei] == -1
2155 label own = mesh_.faceOwner()[facei];
2156 label nei = mesh_.faceNeighbour()[facei];
2157 if (cellToZone[own] == -2 && cellToZone[nei] >= -1)
2159 erodedCellToZone[nei] = backgroundZoneID;
2162 else if (cellToZone[nei] == -2 && cellToZone[own] >= -1)
2164 erodedCellToZone[own] = backgroundZoneID;
2172 const polyBoundaryMesh&
patches = mesh_.boundaryMesh();
2182 const polyPatch& pp =
patches[patchi];
2188 label facei = pp.start()+i;
2191 unnamedSurfaceRegion[facei] == -1
2192 && namedSurfaceRegion[facei] == -1
2195 label own = mesh_.faceOwner()[facei];
2196 label bFacei = facei-mesh_.nInternalFaces();
2197 if (neiCellZone[bFacei] == -2 && cellToZone[own] >= -1)
2199 erodedCellToZone[own] = backgroundZoneID;
2207 cellToZone.transfer(erodedCellToZone);
2209 reduce(nChanged, sumOp<label>());
2212 Pout<<
"erodeCellZone : eroded " << nChanged
2213 <<
" cells (moved from cellZone to background zone "
2214 << backgroundZoneID <<
endl;
2225void Foam::meshRefinement::growCellZone
2227 const label nGrowCellZones,
2228 const label backgroundZoneID,
2235 if (nGrowCellZones != 1)
2238 <<
"Growing currently only supported for single layer."
2239 <<
" Exiting zone growing" <<
endl;
2256 const FixedList<label, 3> wallTag
2266 List<FixedList<label, 3>> surfaces(1);
2286 List<wallPoints> allCellInfo(mesh_.nCells());
2287 forAll(cellToZone, celli)
2289 if (cellToZone[celli] >= 0)
2291 const FixedList<label, 3> zoneTag
2298 origins[0] = mesh_.cellCentres()[celli];
2300 surfaces[0] = zoneTag;
2301 allCellInfo[celli] = wallPoints(origins, distSqrs, surfaces);
2306 DynamicList<wallPoints> faceDist(mesh_.nFaces()/128);
2307 DynamicList<label> changedFaces(mesh_.nFaces()/128);
2309 for (label facei = 0; facei < mesh_.nInternalFaces(); facei++)
2311 const label own = mesh_.faceOwner()[facei];
2312 const label nei = mesh_.faceNeighbour()[facei];
2313 if (cellToZone[own] >= 0 && cellToZone[nei] < 0)
2317 origins[0] = mesh_.faceCentres()[facei];
2319 surfaces[0] = FixedList<label, 3>
2325 faceDist.append(wallPoints(origins, distSqrs, surfaces));
2326 changedFaces.append(facei);
2328 else if (cellToZone[own] < 0 && cellToZone[nei] >= 0)
2332 origins[0] = mesh_.faceCentres()[facei];
2334 surfaces[0] = FixedList<label, 3>
2340 faceDist.append(wallPoints(origins, distSqrs, surfaces));
2341 changedFaces.append(facei);
2345 unnamedSurfaceRegion1[facei] != -1
2346 || unnamedSurfaceRegion2[facei] != -1
2351 origins[0] = mesh_.faceCentres()[facei];
2353 surfaces[0] = wallTag;
2354 faceDist.append(wallPoints(origins, distSqrs, surfaces));
2355 changedFaces.append(facei);
2363 const polyBoundaryMesh&
patches = mesh_.boundaryMesh();
2369 const polyPatch& pp =
patches[patchi];
2376 label facei = pp.start()+i;
2377 label own = mesh_.faceOwner()[facei];
2378 label bFacei = facei-mesh_.nInternalFaces();
2379 if (cellToZone[own] >= 0 && neiCellZone[bFacei] < 0)
2381 origins[0] = mesh_.faceCentres()[facei];
2383 surfaces[0] = FixedList<label, 3>
2389 faceDist.append(wallPoints(origins, distSqrs, surfaces));
2390 changedFaces.append(facei);
2392 else if (cellToZone[own] < 0 && neiCellZone[bFacei] >= 0)
2398 unnamedSurfaceRegion1[facei] != -1
2399 || unnamedSurfaceRegion2[facei] != -1
2403 origins[0] = mesh_.faceCentres()[facei];
2405 surfaces[0] = wallTag;
2406 faceDist.append(wallPoints(origins, distSqrs, surfaces));
2407 changedFaces.append(facei);
2416 label facei = pp.start()+i;
2417 label own = mesh_.faceOwner()[facei];
2418 if (cellToZone[own] < 0)
2420 origins[0] = mesh_.faceCentres()[facei];
2422 surfaces[0] = wallTag;
2423 faceDist.append(wallPoints(origins, distSqrs, surfaces));
2424 changedFaces.append(facei);
2431 List<wallPoints> allFaceInfo(mesh_.nFaces());
2434 const bitSet isBlockedFace(mesh_.nFaces());
2435 List<scalarList> regionToBlockSize(surfaces_.surfaces().size());
2437 forAll(surfaces_.surfaces(), surfi)
2439 const label geomi = surfaces_.surfaces()[surfi];
2440 const auto&
s = surfaces_.geometry()[geomi];
2441 const label nRegions =
s.regions().size();
2442 regionToBlockSize[surfi].setSize(nRegions,
Foam::sqr(GREAT));
2447 wallPoints::trackData td(isBlockedFace, regionToBlockSize);
2448 FaceCellWave<wallPoints, wallPoints::trackData> wallDistCalc
2458 wallDistCalc.iterate(nGrowCellZones);
2465 bitSet isChangedCell(mesh_.nCells());
2467 forAll(allCellInfo, celli)
2469 if (allCellInfo[celli].valid(wallDistCalc.data()))
2471 const List<FixedList<label, 3>>& surfaces =
2472 allCellInfo[celli].surface();
2474 if (surfaces.size())
2478 isChangedCell.set(celli);
2481 if (surfaces.size() > 1)
2487 for (label i = 0; i < surfaces.size(); i++)
2489 const label zonei = surfaces[i][0];
2490 const scalar d2 = allCellInfo[celli].distSqr()[i];
2491 if (zonei != cellToZone[celli] && d2 < minDistSqr)
2500 if (minZone != cellToZone[celli] && minZone != wallTag[0])
2502 cellToZone[celli] = minZone;
2503 isChangedCell.set(celli);
2511 if (backgroundZoneID != -2)
2513 forAll(cellToZone, celli)
2515 if (cellToZone[celli] == -2)
2517 cellToZone[celli] = backgroundZoneID;
2530 for (
const label celli : isChangedCell)
2532 const cell& cFaces = mesh_.cells()[celli];
2533 for (
const label facei : cFaces)
2535 const label own = mesh_.faceOwner()[facei];
2536 const label ownZone = cellToZone[own];
2539 if (mesh_.isInternalFace(facei))
2541 const label neiZone = cellToZone[mesh_.faceNeighbour()[facei]];
2542 nbrZone = (own != celli ? ownZone : neiZone);
2546 nbrZone = neiCellZone[facei-mesh_.nInternalFaces()];
2549 if (nbrZone == cellToZone[celli])
2553 unnamedSurfaceRegion1[facei] != -1
2554 || unnamedSurfaceRegion2[facei] != -1
2557 unnamedSurfaceRegion1[facei] = -1;
2558 unnamedSurfaceRegion2[facei] = -1;
2563 namedSurfaceRegion.size()
2564 && namedSurfaceRegion[facei] != -1
2567 namedSurfaceRegion[facei] = -1;
2574 reduce(nUnnamed, sumOp<label>());
2575 reduce(nNamed, sumOp<label>());
2581 unnamedSurfaceRegion1,
2587 unnamedSurfaceRegion2,
2590 if (namedSurfaceRegion.size())
2602 Pout<<
"growCellZone : grown cellZones by "
2604 <<
" cells (moved from background to nearest cellZone)"
2606 Pout<<
"growCellZone : unmarked " << nUnnamed
2607 <<
" unzoned intersections; " << nNamed <<
" zoned intersections; "
2613void Foam::meshRefinement::makeConsistentFaceIndex
2628 const labelList& faceOwner = mesh_.faceOwner();
2629 const labelList& faceNeighbour = mesh_.faceNeighbour();
2631 for (label faceI = 0; faceI < mesh_.nInternalFaces(); faceI++)
2633 label ownZone = cellToZone[faceOwner[faceI]];
2634 label neiZone = cellToZone[faceNeighbour[faceI]];
2635 label globalI = namedSurfaceRegion[faceI];
2641 && surfaceMap[surfaces_.whichSurface(globalI).first()] == -1
2644 namedSurfaceRegion[faceI] = -1;
2648 const polyBoundaryMesh&
patches = mesh_.boundaryMesh();
2657 const polyPatch& pp =
patches[patchI];
2663 label faceI = pp.start()+i;
2665 label ownZone = cellToZone[faceOwner[faceI]];
2666 label neiZone = neiCellZone[faceI-mesh_.nInternalFaces()];
2667 label globalI = namedSurfaceRegion[faceI];
2673 && surfaceMap[surfaces_.whichSurface(globalI).first()] == -1
2676 namedSurfaceRegion[faceI] = -1;
2685 label faceI = pp.start()+i;
2686 label globalI = namedSurfaceRegion[faceI];
2691 && surfaceMap[surfaces_.whichSurface(globalI).first()] == -1
2694 namedSurfaceRegion[faceI] = -1;
2702void Foam::meshRefinement::getIntersections
2709 bitSet& posOrientation
2712 namedSurfaceRegion.setSize(mesh_.nFaces());
2713 namedSurfaceRegion = -1;
2715 posOrientation.setSize(mesh_.nFaces());
2716 posOrientation =
false;
2747 List<pointIndexHit> hit1;
2751 List<pointIndexHit> hit2;
2754 surfaces_.findNearestIntersection
2773 label faceI = testFaces[i];
2774 const vector&
area = mesh_.faceAreas()[faceI];
2776 if (surface1[i] != -1)
2783 magSqr(hit2[i].hitPoint())
2784 <
magSqr(hit1[i].hitPoint())
2788 namedSurfaceRegion[faceI] = surfaces_.globalRegion
2793 posOrientation.
set(faceI, ((area&normal2[i]) > 0));
2794 nSurfFaces[surface2[i]]++;
2798 namedSurfaceRegion[faceI] = surfaces_.globalRegion
2803 posOrientation.set(faceI, ((area&normal1[i]) > 0));
2804 nSurfFaces[surface1[i]]++;
2807 else if (surface2[i] != -1)
2809 namedSurfaceRegion[faceI] = surfaces_.globalRegion
2814 posOrientation.set(faceI, ((area&normal2[i]) > 0));
2815 nSurfFaces[surface2[i]]++;
2834 forAll(nSurfFaces, surfI)
2837 << surfaces_.names()[surfI]
2838 <<
" nZoneFaces:" << nSurfFaces[surfI] <<
nl;
2845void Foam::meshRefinement::zonify
2847 const bool allowFreeStandingZoneFaces,
2848 const label nErodeCellZones,
2849 const label backgroundZoneID,
2853 const bool exitIfLeakPath,
2854 const refPtr<coordSetWriter>& leakPathFormatter,
2860 bitSet& posOrientation
2873 const PtrList<surfaceZonesInfo>& surfZones = surfaces_.surfZones();
2876 const List<pointField> allLocations
2882 locationsOutsideMesh
2887 labelList neiLevel(mesh_.nBoundaryFaces());
2889 calcNeighbourData(neiLevel, neiCc);
2897 if (namedSurfaces.size())
2909 cellToZone.setSize(mesh_.nCells());
2912 namedSurfaceRegion.clear();
2913 posOrientation.clear();
2933 autoPtr<mapDistribute> unnamedMapPtr;
2934 if (locationsOutsideMesh.size())
2939 [](
const label
x){
return x != -1;}
2942 const globalIndex globalUnnamedFaces(unnamedFaces.size());
2952 unnamedClosureFaces,
2958 Pout<<
"meshRefinement::zonify : found wall closure faces:"
2959 << unnamedClosureFaces.size()
2960 <<
" map:" << unnamedMapPtr.valid() <<
endl;
2965 if (unnamedMapPtr.valid())
2968 if (leakPathFormatter)
2970 boolList blockedFace(mesh_.nFaces(),
false);
2971 UIndirectList<bool>(blockedFace, unnamedFaces) =
true;
2972 const fileName fName
2978 locationsOutsideMesh,
2980 leakPathFormatter.constCast()
2983 Info<<
"Dumped leak path to " << fName <<
endl;
2993 err <<
"Locations in mesh " << locationsInMesh
2994 <<
" connect to one of the locations outside mesh "
2995 << locationsOutsideMesh <<
endl;
3005 UIndirectList<label>(unnamedRegion1, unnamedFaces)
3007 unnamedMapPtr->distribute(packedRegion1);
3010 UIndirectList<label>(unnamedRegion2, unnamedFaces)
3012 unnamedMapPtr->distribute(packedRegion2);
3013 forAll(unnamedClosureFaces, i)
3015 const label sloti = unnamedToClosure[i];
3019 const label facei = unnamedClosureFaces[i];
3020 const label region1 = unnamedRegion1[facei];
3021 const label slotRegion1 = packedRegion1[sloti];
3022 const label region2 = unnamedRegion2[facei];
3023 const label slotRegion2 = packedRegion2[sloti];
3025 if (slotRegion1 != region1 || slotRegion2 != region2)
3027 unnamedRegion1[facei] = slotRegion1;
3028 unnamedRegion2[facei] = slotRegion2;
3040 autoPtr<mapDistribute> namedMapPtr;
3041 if (namedSurfaces.size())
3170 bitSet isClosureFace(mesh_.nFaces());
3171 isClosureFace.set(unnamedClosureFaces);
3172 isClosureFace.set(namedClosureFaces);
3173 const labelList closureFaces(isClosureFace.sortedToc());
3177 UIndirectList<face>(mesh_.faces(), closureFaces),
3182 const labelList nEdgeFaces(countEdgeFaces(pp));
3185 bitSet isFrozenPoint(mesh_.nPoints());
3186 forAll(nEdgeFaces, edgei)
3188 if (nEdgeFaces[edgei] != 1)
3190 const edge&
e = pp.edges()[edgei];
3191 isFrozenPoint.
set(pp.meshPoints()[
e[0]]);
3192 isFrozenPoint.set(pp.meshPoints()[
e[1]]);
3200 const_cast<meshRefinement&
>(*this).addPointZone(
"frozenPoints");
3201 const bitSet oldSet(mesh_.nPoints(), pointZones[zonei]);
3202 isFrozenPoint.set(oldSet);
3208 orEqOp<unsigned int>(),
3213 pointZones.clearAddressing();
3214 pointZones[zonei] = isFrozenPoint.sortedToc();
3218 const pointZone& pz = pointZones[zonei];
3219 mkDir(mesh_.time().timePath());
3220 OBJstream str(mesh_.time().timePath()/pz.name()+
".obj");
3221 Pout<<
"Writing " << pz.size() <<
" frozen points to "
3223 for (
const label pointi : pz)
3225 str.
write(mesh_.points()[pointi]);
3229 if (debug &&
returnReduce(unnamedClosureFaces.size(), sumOp<label>()))
3231 mkDir(mesh_.time().timePath());
3232 OBJstream str(mesh_.time().timePath()/
"unnamedClosureFaces.obj");
3233 Pout<<
"Writing " << unnamedClosureFaces.size()
3234 <<
" unnamedClosureFaces to " << str.
name() <<
endl;
3235 for (
const label facei : unnamedClosureFaces)
3237 str.
write(mesh_.faces()[facei], mesh_.points(),
false);
3240 if (debug &&
returnReduce(namedClosureFaces.size(), sumOp<label>()))
3242 mkDir(mesh_.time().timePath());
3243 OBJstream str(mesh_.time().timePath()/
"namedClosureFaces.obj");
3244 Pout<<
"Writing " << namedClosureFaces.size()
3245 <<
" namedClosureFaces to " << str.
name() <<
endl;
3246 for (
const label facei : namedClosureFaces)
3248 str.
write(mesh_.faces()[facei], mesh_.points(),
false);
3258 if (locationsInMesh.size())
3260 Info<<
"Setting cellZones according to locationsInMesh:" <<
endl;
3262 labelList locationsZoneIDs(zonesInMesh.size(), -1);
3263 forAll(locationsInMesh, i)
3265 const word&
name = zonesInMesh[i];
3267 Info<<
"Location : " << locationsInMesh[i] <<
nl
3272 label
zoneID = mesh_.cellZones().findZoneID(
name);
3277 locationsZoneIDs[i] =
zoneID;
3284 findCellZoneInsideWalk
3301 if (locationSurfaces.size())
3303 Info<<
"Found " << locationSurfaces.size()
3304 <<
" named surfaces with a provided inside point."
3305 <<
" Assigning cells inside these surfaces"
3306 <<
" to the corresponding cellZone."
3311 labelList insidePointCellZoneIDs(locationSurfaces.size(), -1);
3312 forAll(locationSurfaces, i)
3314 label surfI = locationSurfaces[i];
3317 const word&
name = surfZones[surfI].cellZoneName();
3320 label
zoneID = mesh_.cellZones().findZoneID(
name);
3327 insidePointCellZoneIDs[i] =
zoneID;
3333 labelList allRegion1(mesh_.nFaces(), -1);
3334 forAll(namedSurfaceRegion, faceI)
3336 allRegion1[faceI] =
max
3338 unnamedRegion1[faceI],
3339 namedSurfaceRegion[faceI]
3343 findCellZoneInsideWalk
3346 insidePointCellZoneIDs,
3362 surfaces_.geometry(),
3363 surfaces_.surfaces()
3367 if (closedNamedSurfaces.
size())
3369 Info<<
"Found " << closedNamedSurfaces.
size()
3370 <<
" closed, named surfaces. Assigning cells in/outside"
3371 <<
" these surfaces to the corresponding cellZone."
3374 findCellZoneGeometric
3377 closedNamedSurfaces,
3388 if (namedSurfaces.size())
3390 if (nErodeCellZones == 0)
3392 Info<<
"Walking from known cellZones; crossing a faceZone "
3393 <<
"face changes cellZone" <<
nl <<
endl;
3406 else if (nErodeCellZones < 0)
3408 Info<<
"Growing cellZones by " << -nErodeCellZones
3409 <<
" layers" <<
nl <<
endl;
3423 Info<<
"Eroding cellZone cells to make these consistent with"
3424 <<
" faceZone faces" <<
nl <<
endl;
3440 if (!allowFreeStandingZoneFaces)
3442 Info<<
"Only keeping zone faces inbetween different cellZones."
3456 labelList surfaceMap(surfZones.size(), -1);
3457 forAll(standaloneNamedSurfaces, i)
3459 surfaceMap[standaloneNamedSurfaces[i]] = i;
3462 makeConsistentFaceIndex
3470 else if (nErodeCellZones < 0 &&
gMax(cellToZone) >= 0)
3475 Info<<
"Growing cellZones by " << -nErodeCellZones
3476 <<
" layers" <<
nl <<
endl;
3489 if (!allowFreeStandingZoneFaces && namedSurfaceRegion.size())
3491 Info<<
"Only keeping zone faces inbetween different cellZones."
3505 labelList surfaceMap(surfZones.size(), -1);
3506 forAll(standaloneNamedSurfaces, i)
3508 surfaceMap[standaloneNamedSurfaces[i]] = i;
3511 makeConsistentFaceIndex
3526 label nUnvisited = 0;
3527 label nBackgroundCells = 0;
3529 forAll(cellToZone, cellI)
3531 label zoneI = cellToZone[cellI];
3534 nZoneCells[zoneI]++;
3536 else if (zoneI == -1)
3540 else if (zoneI == -2)
3550 reduce(nUnvisited, sumOp<label>());
3551 reduce(nBackgroundCells, sumOp<label>());
3552 forAll(nZoneCells, zoneI)
3554 reduce(nZoneCells[zoneI], sumOp<label>());
3556 Info<<
"nUnvisited :" << nUnvisited <<
endl;
3557 Info<<
"nBackgroundCells:" << nBackgroundCells <<
endl;
3558 Info<<
"nZoneCells :" << nZoneCells <<
endl;
3562 const_cast<Time&
>(mesh_.time())++;
3563 Pout<<
"Writing cell zone allocation on mesh to time "
3568 writeType(writeLevel() | WRITEMESH),
3569 mesh_.time().path()/
"cell2Zone"
3584 zeroGradientFvPatchScalarField::typeName
3587 forAll(cellToZone, cellI)
3589 volCellToZone[cellI] = cellToZone[cellI];
3591 volCellToZone.write();
3695 const snapParameters& snapParams,
3696 const bool useTopologicalSnapDetection,
3697 const bool removeEdgeConnectedCells,
3699 const dictionary& motionDict,
3706 <<
"Introducing baffles to block off problem cells" <<
nl
3707 <<
"----------------------------------------------" <<
nl
3712 if (useTopologicalSnapDetection)
3714 markFacesOnProblemCells
3717 removeEdgeConnectedCells,
3719 globalToMasterPatch,
3727 markFacesOnProblemCellsGeometric
3731 globalToMasterPatch,
3738 Info<<
"Analyzed problem cells in = "
3743 faceSet problemFaces(mesh_,
"problemFaces", mesh_.nFaces()/100);
3747 if (facePatch[faceI] != -1)
3749 problemFaces.insert(faceI);
3752 problemFaces.instance() =
timeName();
3753 Pout<<
"Dumping " << problemFaces.size()
3754 <<
" problem faces to " << problemFaces.objectPath() <<
endl;
3755 problemFaces.
write();
3758 Info<<
"Introducing baffles to delete problem cells." <<
nl <<
endl;
3769 List<DynamicList<label>> zoneToFaces(fzs.size());
3770 List<DynamicList<bool>> zoneToFlip(fzs.size());
3775 zoneToFaces[zonei].append(fzs[zonei]);
3776 zoneToFlip[zonei].append(fzs[zonei].flipMap());
3782 if (facePatch[facei] != -1)
3784 label zonei = faceZone[facei];
3787 zoneToFaces[zonei].append(facei);
3788 zoneToFlip[zonei].append(
false);
3793 forAll(zoneToFaces, zonei)
3807 createBaffles(facePatch, facePatch);
3814 Info<<
"Created baffles in = "
3817 printMeshInfo(debug,
"After introducing baffles");
3821 const_cast<Time&
>(mesh_.time())++;
3822 Pout<<
"Writing extra baffled mesh to time "
3827 writeType(writeLevel() | WRITEMESH),
3830 Pout<<
"Dumped debug data in = "
3843 const polyBoundaryMesh&
patches = mesh_.boundaryMesh();
3844 const labelList& faceOwner = mesh_.faceOwner();
3845 const labelList& faceNeighbour = mesh_.faceNeighbour();
3862 DynamicList<label> faceLabels(mesh_.nFaces()/100);
3864 for (label faceI = 0; faceI < mesh_.nInternalFaces(); faceI++)
3866 if (faceToZone[faceI] != -1)
3869 label ownZone = cellToZone[faceOwner[faceI]];
3870 label neiZone = cellToZone[faceNeighbour[faceI]];
3871 if (ownZone == neiZone)
3873 faceLabels.append(faceI);
3879 const polyPatch& pp =
patches[patchI];
3883 label faceI = pp.start()+i;
3884 if (faceToZone[faceI] != -1)
3887 label ownZone = cellToZone[faceOwner[faceI]];
3888 label neiZone = neiCellZone[faceI-mesh_.nInternalFaces()];
3889 if (ownZone == neiZone)
3891 faceLabels.append(faceI);
3896 return faceLabels.shrink();
3900void Foam::meshRefinement::calcPatchNumMasterFaces
3902 const bitSet& isMasterFace,
3908 nMasterFacesPerEdge.setSize(
patch.nEdges());
3909 nMasterFacesPerEdge = 0;
3913 const label meshFaceI =
patch.addressing()[faceI];
3915 if (isMasterFace.test(meshFaceI))
3920 nMasterFacesPerEdge[fEdges[fEdgeI]]++;
3928 patch.meshEdges(mesh_.edges(), mesh_.pointEdges()),
3929 nMasterFacesPerEdge,
3936Foam::label Foam::meshRefinement::markPatchZones
3943 List<edgeTopoDistanceData<label>> allEdgeInfo(
patch.nEdges());
3944 List<edgeTopoDistanceData<label>> allFaceInfo(
patch.size());
3949 label nProtected = 0;
3951 forAll(nMasterFacesPerEdge, edgeI)
3953 if (nMasterFacesPerEdge[edgeI] > 2)
3955 allEdgeInfo[edgeI] = edgeTopoDistanceData<label>(0, -2);
3967 DynamicList<label> changedEdges;
3968 DynamicList<edgeTopoDistanceData<label>> changedInfo;
3970 const scalar tol = PatchEdgeFaceWave
3973 edgeTopoDistanceData<label>
3974 >::propagationTol();
3978 const globalIndex globalFaces(
patch.size());
3982 label currentZoneI = 0;
3988 for (; faceI < allFaceInfo.size(); faceI++)
3990 if (!allFaceInfo[faceI].valid(dummyTrackData))
3992 globalSeed = globalFaces.toGlobal(faceI);
3997 reduce(globalSeed, minOp<label>());
4004 if (globalFaces.isLocal(globalSeed))
4006 const label seedFaceI = globalFaces.toLocal(globalSeed);
4008 edgeTopoDistanceData<label>& faceInfo = allFaceInfo[seedFaceI];
4011 faceInfo = edgeTopoDistanceData<label>(0, currentZoneI);
4017 label edgeI = fEdges[fEdgeI];
4019 edgeTopoDistanceData<label>& edgeInfo = allEdgeInfo[edgeI];
4023 edgeInfo.updateEdge<
int>
4035 changedEdges.append(edgeI);
4036 changedInfo.append(edgeInfo);
4042 if (
returnReduce(changedEdges.size(), sumOp<label>()) == 0)
4052 edgeTopoDistanceData<label>
4068 faceToZone.setSize(
patch.size());
4069 forAll(allFaceInfo, faceI)
4071 if (!allFaceInfo[faceI].valid(dummyTrackData))
4074 <<
"Problem: unvisited face " << faceI
4075 <<
" at " <<
patch.faceCentres()[faceI]
4078 faceToZone[faceI] = allFaceInfo[faceI].data();
4081 return currentZoneI;
4085void Foam::meshRefinement::consistentOrientation
4087 const bitSet& isMasterFace,
4091 const Map<label>& zoneToOrientation,
4095 const polyBoundaryMesh& bm = mesh_.boundaryMesh();
4098 List<patchFaceOrientation> allEdgeInfo(
patch.nEdges());
4099 List<patchFaceOrientation> allFaceInfo(
patch.size());
4105 label nProtected = 0;
4109 const label meshFaceI =
patch.addressing()[faceI];
4110 const label patchI = bm.whichPatch(meshFaceI);
4116 && !isMasterFace.test(meshFaceI)
4129 label nProtected = 0;
4131 forAll(nMasterFacesPerEdge, edgeI)
4133 if (nMasterFacesPerEdge[edgeI] > 2)
4140 Info<<
"Protected from visiting "
4142 <<
" non-manifold edges" <<
nl <<
endl;
4147 DynamicList<label> changedEdges;
4148 DynamicList<patchFaceOrientation> changedInfo;
4150 const scalar tol = PatchEdgeFaceWave
4153 patchFaceOrientation
4154 >::propagationTol();
4158 globalIndex globalFaces(
patch.size());
4164 forAll(allFaceInfo, faceI)
4168 globalSeed = globalFaces.toGlobal(faceI);
4173 reduce(globalSeed, minOp<label>());
4180 if (globalFaces.isLocal(globalSeed))
4182 const label seedFaceI = globalFaces.toLocal(globalSeed);
4186 patchFaceOrientation& faceInfo = allFaceInfo[seedFaceI];
4191 if (zoneToOrientation[faceToZone[seedFaceI]] < 0)
4200 label edgeI = fEdges[fEdgeI];
4202 patchFaceOrientation& edgeInfo = allEdgeInfo[edgeI];
4206 edgeInfo.updateEdge<
int>
4218 changedEdges.append(edgeI);
4219 changedInfo.append(edgeInfo);
4225 if (
returnReduce(changedEdges.size(), sumOp<label>()) == 0)
4236 patchFaceOrientation
4254 mesh_.nBoundaryFaces(),
4260 const label meshFaceI =
patch.addressing()[i];
4261 if (!mesh_.isInternalFace(meshFaceI))
4263 neiStatus[meshFaceI-mesh_.nInternalFaces()] =
4264 allFaceInfo[i].flipStatus();
4271 const label meshFaceI =
patch.addressing()[i];
4272 const label patchI = bm.whichPatch(meshFaceI);
4278 && !isMasterFace.test(meshFaceI)
4282 label bFaceI = meshFaceI-mesh_.nInternalFaces();
4295 <<
"Incorrect status for face " << meshFaceI
4305 meshFlipMap.setSize(mesh_.nFaces());
4306 meshFlipMap =
false;
4308 forAll(allFaceInfo, faceI)
4310 label meshFaceI =
patch.addressing()[faceI];
4314 meshFlipMap.unset(meshFaceI);
4318 meshFlipMap.set(meshFaceI);
4323 <<
"Problem : unvisited face " << faceI
4324 <<
" centre:" << mesh_.faceCentres()[meshFaceI]
4331void Foam::meshRefinement::zonify
4334 const bitSet& isMasterFace,
4338 const bitSet& meshFlipMap,
4339 polyTopoChange& meshMod
4342 const labelList& faceOwner = mesh_.faceOwner();
4343 const labelList& faceNeighbour = mesh_.faceNeighbour();
4345 for (label faceI = 0; faceI < mesh_.nInternalFaces(); faceI++)
4347 label faceZoneI = faceToZone[faceI];
4349 if (faceZoneI != -1)
4355 label ownZone = cellToZone[faceOwner[faceI]];
4356 label neiZone = cellToZone[faceNeighbour[faceI]];
4360 if (ownZone == neiZone)
4363 flip = meshFlipMap.
test(faceI);
4370 || (neiZone != -1 && ownZone > neiZone)
4378 mesh_.faces()[faceI],
4381 faceNeighbour[faceI],
4393 const polyBoundaryMesh&
patches = mesh_.boundaryMesh();
4398 const polyPatch& pp =
patches[patchI];
4400 label faceI = pp.
start();
4404 label faceZoneI = faceToZone[faceI];
4406 if (faceZoneI != -1)
4408 label ownZone = cellToZone[faceOwner[faceI]];
4409 label neiZone = neiCellZone[faceI-mesh_.nInternalFaces()];
4413 if (ownZone == neiZone)
4416 flip = meshFlipMap.test(faceI);
4423 || (neiZone != -1 && ownZone > neiZone)
4431 mesh_.faces()[faceI],
4451 forAll(cellToZone, cellI)
4453 label zoneI = cellToZone[cellI];
4471void Foam::meshRefinement::allocateInterRegionFaceZone
4473 const label ownZone,
4474 const label neiZone,
4476 LabelPairMap<word>& zoneIDsToFaceZone
4481 if (ownZone != neiZone)
4488 || (neiZone != -1 && ownZone > neiZone)
4498 if (!zoneIDsToFaceZone.found(key))
4501 const word ownZoneName =
4504 ? cellZones[ownZone].name()
4507 const word neiZoneName =
4510 ? cellZones[neiZone].name()
4515 Pair<word> wordKey(ownZoneName, neiZoneName);
4521 word fzName = wordKey.first() +
"_to_" + wordKey.second();
4523 zoneIDsToFaceZone.insert(key, fzName);
4524 zonesToFaceZone.insert(wordKey, fzName);
4534 const bool doHandleSnapProblems,
4536 const bool useTopologicalSnapDetection,
4537 const bool removeEdgeConnectedCells,
4539 const label nErodeCellZones,
4548 const bool exitIfLeakPath,
4558 Info<<
"Introducing baffles for "
4560 <<
" faces that are intersected by the surface." <<
nl <<
endl;
4563 labelList neiLevel(mesh_.nBoundaryFaces());
4565 calcNeighbourData(neiLevel, neiCc);
4571 globalToMasterPatch,
4575 locationsOutsideMesh,
4586 createBaffles(ownPatch, neiPatch);
4594 Info<<
"Created baffles in = "
4597 printMeshInfo(debug,
"After introducing baffles");
4601 const_cast<Time&
>(mesh_.time())++;
4610 Pout<<
"Dumped debug data in = "
4620 if (doHandleSnapProblems)
4625 useTopologicalSnapDetection,
4626 removeEdgeConnectedCells,
4630 globalToMasterPatch,
4638 neiLevel.
setSize(mesh_.nBoundaryFaces());
4639 neiCc.
setSize(mesh_.nBoundaryFaces());
4640 calcNeighbourData(neiLevel, neiCc);
4646 globalToMasterPatch,
4650 locationsOutsideMesh,
4661 createBaffles(ownPatch, neiPatch);
4676 <<
"Remove unreachable sections of mesh" <<
nl
4677 <<
"-----------------------------------" <<
nl
4687 globalToMasterPatch,
4690 locationsOutsideMesh,
4700 Info<<
"Split mesh in = "
4703 printMeshInfo(debug,
"After subsetting");
4716 Pout<<
"Dumped debug data in = "
4725 const bool useTopologicalSnapDetection,
4726 const bool removeEdgeConnectedCells,
4728 const scalar planarAngle,
4741 <<
"Merge free-standing baffles" <<
nl
4742 <<
"---------------------------" <<
nl
4756 label nCouples = couples.
size();
4759 Info<<
"Detected free-standing baffles : " << nCouples <<
endl;
4773 useTopologicalSnapDetection,
4774 removeEdgeConnectedCells,
4778 globalToMasterPatch,
4786 <<
"Remove unreachable sections of mesh" <<
nl
4787 <<
"-----------------------------------" <<
nl
4797 globalToMasterPatch,
4800 locationsOutsideMesh,
4812 Info<<
"Merged free-standing baffles in = "
4819 const label nBufferLayers,
4820 const label nErodeCellZones,
4827 const bool exitIfLeakPath,
4836 labelList neiLevel(mesh_.nBoundaryFaces());
4838 calcNeighbourData(neiLevel, neiCc);
4845 globalToMasterPatch,
4849 locationsOutsideMesh,
4861 boolList blockedFace(mesh_.nFaces(),
false);
4865 if (ownPatch[faceI] != -1 || neiPatch[faceI] != -1)
4867 blockedFace[faceI] =
true;
4881 locationsOutsideMesh,
4893 globalToMasterPatch,
4903 const label nBufferLayers,
4918 const labelList& faceOwner = mesh_.faceOwner();
4919 const labelList& faceNeighbour = mesh_.faceNeighbour();
4923 for (label facei = 0; facei < mesh_.nInternalFaces(); facei++)
4925 if (ownPatch[facei] == -1 && neiPatch[facei] != -1)
4928 <<
" at:" << mesh_.faceCentres()[facei]
4929 <<
" ownPatch:" << ownPatch[facei]
4930 <<
" neiPatch:" << neiPatch[facei]
4936 const label ownRegion = cellRegion[faceOwner[facei]];
4937 const label neiRegion = cellRegion[faceNeighbour[facei]];
4938 if (ownRegion != neiRegion)
4940 if (ownPatch[facei] == -1)
4943 <<
" at:" << mesh_.faceCentres()[facei]
4944 <<
" ownPatch:" << ownPatch[facei]
4945 <<
" ownRegion:" << ownRegion
4946 <<
" neiPatch:" << neiPatch[facei]
4947 <<
" neiRegion:" << neiRegion
4959 DynamicList<label> startFaces;
4962 if (ownPatch[facei] != -1)
4964 startFaces.append(facei);
4970 autoPtr<mapDistribute> mapPtr;
4974 bitSet(mesh_.nFaces()),
4982 labelList startOwnPatch(ownPatch, startFaces);
4983 mapPtr().distribute(startOwnPatch);
4985 nearestOwnPatch.setSize(mesh_.nFaces());
4986 nearestOwnPatch = -1;
4987 forAll(faceToStart, facei)
4989 const label sloti = faceToStart[facei];
4992 nearestOwnPatch[facei] = startOwnPatch[sloti];
5006 bitSet isFrozenPoint(mesh_.nPoints());
5007 bitSet isFrozenFace(mesh_.nFaces());
5013 const label pointZonei = pzs.
findZoneID(
"frozenPoints");
5014 if (pointZonei != -1)
5016 const pointZone& pz = pzs[pointZonei];
5017 isFrozenPoint.set(pz);
5018 for (
const label pointi : pz)
5020 isFrozenFace.set(pointFaces[pointi]);
5025 const label faceZonei = fzs.
findZoneID(
"frozenFaces");
5026 if (faceZonei != -1)
5028 const faceZone& fz = fzs[faceZonei];
5029 isFrozenFace.set(fz);
5030 for (
const label facei : fz)
5032 isFrozenPoint.set(mesh_.faces()[facei]);
5038 label defaultPatch = 0;
5039 if (globalToMasterPatch.
size())
5041 defaultPatch = globalToMasterPatch[0];
5044 for (label i = 0; i < nBufferLayers; i++)
5048 labelList pointBaffle(mesh_.nPoints(), -1);
5050 forAll(faceNeighbour, facei)
5052 if (!isFrozenFace[facei])
5054 const face&
f = mesh_.faces()[facei];
5056 const label ownRegion = cellRegion[faceOwner[facei]];
5057 const label neiRegion = cellRegion[faceNeighbour[facei]];
5059 if (ownRegion == -1 && neiRegion != -1)
5066 if (!isFrozenPoint[
f[fp]])
5068 pointBaffle[
f[fp]] =
5069 max(defaultPatch, ownPatch[facei]);
5073 else if (ownRegion != -1 && neiRegion == -1)
5075 label newPatchi = neiPatch[facei];
5076 if (newPatchi == -1)
5078 newPatchi =
max(defaultPatch, ownPatch[facei]);
5082 if (!isFrozenPoint[
f[fp]])
5084 pointBaffle[
f[fp]] = newPatchi;
5095 label facei = mesh_.nInternalFaces();
5096 facei < mesh_.nFaces();
5100 if (!isFrozenFace[facei])
5102 const face&
f = mesh_.faces()[facei];
5104 const label ownRegion = cellRegion[faceOwner[facei]];
5105 const label neiRegion =
5106 neiCellRegion[facei-mesh_.nInternalFaces()];
5108 if (ownRegion == -1 && neiRegion != -1)
5112 if (!isFrozenPoint[
f[fp]])
5114 pointBaffle[
f[fp]] =
5115 max(defaultPatch, ownPatch[facei]);
5136 forAll(pointFaces, pointi)
5138 if (pointBaffle[pointi] != -1)
5144 const label facei =
pFaces[pFacei];
5146 if (!isFrozenFace[facei] && ownPatch[facei] == -1)
5148 ownPatch[facei] = pointBaffle[pointi];
5162 if (!isFrozenFace[facei] && ownPatch[facei] != -1)
5164 const label own = faceOwner[facei];
5166 if (cellRegion[own] == -1)
5170 const cell& ownFaces = mesh_.cells()[own];
5173 const label ownFacei = ownFaces[j];
5174 if (!isFrozenFace[ownFacei] && ownPatch[ownFacei] == -1)
5176 newOwnPatch[ownFacei] = ownPatch[facei];
5180 if (mesh_.isInternalFace(facei))
5182 const label nei = faceNeighbour[facei];
5184 if (cellRegion[nei] == -1)
5188 const cell& neiFaces = mesh_.cells()[nei];
5191 const label neiFacei = neiFaces[j];
5192 const bool isFrozen = isFrozenFace[neiFacei];
5193 if (!isFrozen && ownPatch[neiFacei] == -1)
5195 newOwnPatch[neiFacei] = ownPatch[facei];
5213 DynamicList<label> cellsToRemove(mesh_.nCells());
5214 forAll(cellRegion, celli)
5216 if (cellRegion[celli] == -1)
5218 cellsToRemove.append(celli);
5221 cellsToRemove.shrink();
5223 label nCellsToKeep = mesh_.nCells() - cellsToRemove.size();
5224 reduce(nCellsToKeep, sumOp<label>());
5226 Info<<
"Keeping all cells containing inside points" <<
endl
5227 <<
"Selected for keeping : " << nCellsToKeep <<
" cells." <<
endl;
5231 removeCells cellRemover(mesh_);
5234 const labelList exposedFaces(cellRemover.getExposedFaces(cellsToRemove));
5235 labelList exposedPatches(exposedFaces.size());
5237 label nUnpatched = 0;
5241 label facei = exposedFaces[i];
5243 if (ownPatch[facei] != -1)
5245 exposedPatches[i] = ownPatch[facei];
5249 const label fallbackPatch =
5251 nearestOwnPatch.size()
5252 ? nearestOwnPatch[facei]
5255 if (nUnpatched == 0)
5258 <<
"For exposed face " << facei
5259 <<
" fc:" << mesh_.faceCentres()[facei]
5260 <<
" found no patch." <<
endl
5261 <<
" Taking patch " << fallbackPatch
5262 <<
" instead. Suppressing future warnings" <<
endl;
5266 exposedPatches[i] = fallbackPatch;
5270 reduce(nUnpatched, sumOp<label>());
5273 Info<<
"Detected " << nUnpatched <<
" faces out of "
5275 <<
" for which the default patch " << defaultPatch
5276 <<
" will be used" <<
endl;
5279 return doRemoveCells
5291 const label nBufferLayers,
5292 const label nErodeCellZones,
5304 labelList neiLevel(mesh_.nBoundaryFaces());
5306 calcNeighbourData(neiLevel, neiCc);
5313 globalToMasterPatch,
5317 locationsOutsideMesh,
5332 limitShells_.findLevel
5334 mesh_.cellCentres(),
5338 forAll(levelShell, celli)
5340 if (levelShell[celli] != -1)
5343 cellRegion[celli] = -1;
5350 globalToMasterPatch,
5359 const_cast<Time&
>(mesh_.time())++;
5360 Pout<<
"Writing mesh after removing limitShells"
5391 Info<<
"dupNonManifoldPoints : Found : " << nNonManifPoints
5392 <<
" non-manifold points (out of "
5393 << mesh_.globalData().nTotalPoints()
5399 if (nNonManifPoints)
5409 mesh_.moving(
false);
5412 mapPtr = meshMod.
changeMesh(mesh_,
false,
true);
5416 mesh_.updateMesh(map);
5455 label nPointPairs = 0;
5456 forAll(pointToDuplicate, pointI)
5458 label otherPointI = pointToDuplicate[pointI];
5459 if (otherPointI != -1)
5470 forAll(pointToDuplicate, pointI)
5472 label otherPointI = pointToDuplicate[pointI];
5473 if (otherPointI != -1)
5476 pointToMaster.
insert(pointI, otherPointI);
5488 mesh_.moving(
false);
5491 mapPtr = meshMod.
changeMesh(mesh_,
false,
true);
5495 mesh_.updateMesh(map);
5542 internalOrBaffleFaceZones = getZones(fzTypes);
5552 forAll(boundaryFaceZones, j)
5554 const faceZone& fZone = mesh_.faceZones()[boundaryFaceZones[j]];
5557 const face&
f = mesh_.faces()[fZone[i]];
5560 pointStatus[
f[fp]] =
max(pointStatus[
f[fp]], 1u);
5564 forAll(internalOrBaffleFaceZones, j)
5566 const faceZone& fZone = mesh_.faceZones()[internalOrBaffleFaceZones[j]];
5569 const face&
f = mesh_.faces()[fZone[i]];
5572 pointStatus[
f[fp]] =
max(pointStatus[
f[fp]], 2u);
5587 forAll(pointStatus, pointI)
5589 if (pointStatus[pointI] == 1u)
5596 Info<<
"Duplicating " << globalNPoints <<
" points on"
5597 <<
" faceZones of type "
5607 forAll(pointStatus, pointI)
5609 if (pointStatus[pointI] == 1u)
5611 candidatePoints[
n++] = pointI;
5624 const bool allowFreeStandingZoneFaces,
5625 const label nErodeCellZones,
5629 const bool exitIfLeakPath,
5634 if (locationsInMesh.
size() != zonesInMesh.
size())
5644 labelList neiLevel(mesh_.nBoundaryFaces());
5646 calcNeighbourData(neiLevel, neiCc);
5655 if (namedSurfaces.
size())
5657 Info<<
"Setting cellZones according to named surfaces:" <<
endl;
5660 label surfI = namedSurfaces[i];
5662 Info<<
"Surface : " << surfaces_.names()[surfI] <<
nl
5663 <<
" faceZones : " << surfZones[surfI].faceZoneNames() <<
nl
5664 <<
" cellZone : " << surfZones[surfI].cellZoneName()
5705 allowFreeStandingZoneFaces,
5710 locationsOutsideMesh,
5727 labelList faceToZone(mesh_.nFaces(), -1);
5729 forAll(namedSurfaceRegion, faceI)
5732 label globalI = namedSurfaceRegion[faceI];
5735 const labelPair spr = surfaces_.whichSurface(globalI);
5736 faceToZone[faceI] = surfaceToFaceZones[spr.
first()][spr.
second()];
5750 for (label faceI = 0; faceI < mesh_.nInternalFaces(); faceI++)
5752 if (faceToZone[faceI] == -1)
5757 allocateInterRegionFaceZone
5759 cellToZone[mesh_.faceOwner()[faceI]],
5760 cellToZone[mesh_.faceNeighbour()[faceI]],
5770 forAll(neiCellZone, bFaceI)
5772 label faceI = bFaceI + mesh_.nInternalFaces();
5773 if (faceToZone[faceI] == -1)
5775 allocateInterRegionFaceZone
5777 cellToZone[mesh_.faceOwner()[faceI]],
5778 neiCellZone[bFaceI],
5796 Info<<
"Setting faceZones according to neighbouring cellZones:"
5810 const word& fzName = zonesToFaceZone[cz];
5813 << cz[0] <<
' ' << cz[1] <<
nl
5814 <<
" faceZone : " << fzName <<
endl;
5835 for (label faceI = 0; faceI < mesh_.nInternalFaces(); faceI++)
5837 if (faceToZone[faceI] == -1)
5843 label ownZone = cellToZone[mesh_.faceOwner()[faceI]];
5844 label neiZone = cellToZone[mesh_.faceNeighbour()[faceI]];
5845 if (ownZone != neiZone)
5850 || (neiZone != -1 && ownZone > neiZone)
5857 faceToZone[faceI] = fZoneLookup[key];
5861 forAll(neiCellZone, bFaceI)
5863 label faceI = bFaceI + mesh_.nInternalFaces();
5864 if (faceToZone[faceI] == -1)
5866 label ownZone = cellToZone[mesh_.faceOwner()[faceI]];
5867 label neiZone = neiCellZone[bFaceI];
5868 if (ownZone != neiZone)
5873 || (neiZone != -1 && ownZone > neiZone)
5880 faceToZone[faceI] = fZoneLookup[key];
5899 label bFaceI = pp.
start()-mesh_.nInternalFaces();
5902 neiCellZone[bFaceI++] = -1;
5923 bitSet meshFlipMap(mesh_.nFaces(),
false);
5931 freeStandingBaffleFaces
5942 if (nFreeStanding > 0)
5944 Info<<
"Detected " << nFreeStanding <<
" free-standing zone faces"
5949 OBJstream str(mesh_.time().path()/
"freeStanding.obj");
5950 Pout<<
"meshRefinement::zonify : dumping faceZone faces to "
5952 str.
write(patch.localFaces(), patch.localPoints(),
false);
5958 calcPatchNumMasterFaces(isMasterFace, patch, nMasterFacesPerEdge);
5963 const label
nZones = markPatchZones
5966 nMasterFacesPerEdge,
5971 for (label zoneI = 0; zoneI <
nZones; zoneI++)
5973 nPosOrientation.
insert(zoneI, 0);
5979 consistentOrientation
5983 nMasterFacesPerEdge,
5984 faceToConnectedZone,
5992 forAll(patch.addressing(), faceI)
5994 label meshFaceI = patch.addressing()[faceI];
5996 if (isMasterFace.
test(meshFaceI))
6001 posOrientation.
test(meshFaceI)
6002 == meshFlipMap.
test(meshFaceI)
6008 nPosOrientation.
find(faceToConnectedZone[faceI])() +=
n;
6014 Info<<
"Split " << nFreeStanding <<
" free-standing zone faces"
6015 <<
" into " <<
nZones <<
" disconnected regions with size"
6016 <<
" (negative denotes wrong orientation) :"
6019 for (label zoneI = 0; zoneI <
nZones; zoneI++)
6021 Info<<
" " << zoneI <<
"\t" << nPosOrientation[zoneI]
6029 consistentOrientation
6033 nMasterFacesPerEdge,
6034 faceToConnectedZone,
6061 mesh_.moving(
false);
6067 mesh_.updateMesh(map());
6070 if (map().hasMotionPoints())
6072 mesh_.movePoints(map().preMotionPoints());
6084 if (mesh_.cellZones().size() > 0)
6087 forAll(mesh_.cellZones(), zoneI)
6089 const cellZone& cz = mesh_.cellZones()[zoneI];
6096 if (mesh_.faceZones().size() > 0)
6099 forAll(mesh_.faceZones(), zoneI)
6101 const faceZone& fz = mesh_.faceZones()[zoneI];
Istream and Ostream manipulators taking arguments.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
void append(const T &val)
Copy append an element to the end of this list.
T & first() noexcept
The first element of the list, position [0].
bool insert(const Key &key)
Insert a new entry, not overwriting existing entries.
A HashTable similar to std::unordered_map.
List< Key > sortedToc() const
The table of contents (the keys) in sorted order.
List< Key > toc() const
The table of contents (the keys) in unsorted order.
bool insert(const Key &key, const T &obj)
Copy insert a new entry, not overwriting existing entries.
label size() const noexcept
The number of elements in table.
iterator find(const Key &key)
Find and return an iterator set at the hashed entry.
const word & name() const noexcept
Return the object name.
A List with indirect addressing.
std::enable_if< std::is_same< bool, TypeT >::value, bool >::type set(const label i, bool val=true)
A bitSet::set() method for a list of bool.
void transfer(List< T > &list)
void setSize(const label n)
Alias for resize()
void append(const T &val)
Append an element at the end of the list.
void clear()
Clear the list, i.e. set size to zero.
A HashTable to objects of type <T> with a label key.
OFstream that keeps track of vertices.
virtual Ostream & write(const char c)
Write character.
virtual const fileName & name() const
Read/write access to the name of the stream.
virtual const fileName & name() const
Get the name of the stream.
virtual bool write(const token &tok)=0
Write token to stream or otherwise handle it.
A dynamic list of packed unsigned integers, with the number of bits per item specified by the <Width>...
const T & second() const noexcept
Return second element, which is also the last element.
A list of faces which address into the list of points.
static void listCombineAllGather(const List< commsStruct > &comms, List< T > &values, const CombineOp &cop, const int tag, const label comm)
After completion all processors have the same data.
static void mapCombineAllGather(const List< commsStruct > &comms, Container &values, const CombineOp &cop, const int tag, const label comm)
After completion all processors have the same data.
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
fileName path() const
Return path.
T & first()
Return the first element of the list.
bool found(const T &val, label pos=0) const
True if the value if found in the list.
std::enable_if< std::is_same< bool, TypeT >::value, bool >::type test(const label i) const
label find(const T &val, label pos=0) const
Find index of the first occurrence of the value.
void size(const label n)
Older name for setAddressableSize.
label size() const noexcept
The number of elements in the list.
label findZoneID(const word &zoneName) const
Find zone index by name, return -1 if not found.
label whichZone(const label objectIndex) const
Given a global object index, return the zone it is in.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
bool test(const label pos) const
Test value at specified position, never auto-vivify entries.
A cell is defined as a list of faces with extra functionality.
double cpuTimeIncrement() const
Return CPU time (in seconds) since last call to cpuTimeIncrement()
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
void setRefinement(const localPointRegion ®ionSide, polyTopoChange &)
Play commands into polyTopoChange to duplicate points. Gets.
virtual void sync(const polyMesh &mesh)
Sync faceSet across coupled patches.
A subset of mesh faces organised as a primitive patch.
label whichFace(const label globalCellID) const
Helper function to re-direct to zone::localID(...)
const boolList & flipMap() const noexcept
Return face flip map.
A face is a list of labels corresponding to mesh vertices.
static autoPtr< mapDistribute > calcClosure(const polyMesh &mesh, const List< pointField > &zonePoints, const labelList &blockedFaces, const globalIndex &globalBlockedFaces, const bool erode, labelList &closureFaces, labelList &closureToBlocked)
Optional direct use to generate the set of faces and the method to.
Takes mesh with 'baffles' (= boundary faces sharing points). Determines for selected points on bounda...
static labelPairList findDuplicateFacePairs(const polyMesh &)
Helper routine to find all baffles (two boundary faces.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
const labelList & faceMap() const
Old face map.
const pointField & preMotionPoints() const
Pre-motion point positions.
const labelList & reverseFaceMap() const
Reverse face map.
bool hasMotionPoints() const
Has valid preMotionPoints?
labelList getZones(const List< surfaceZonesInfo::faceZoneType > &fzTypes) const
Get zones of given type.
autoPtr< mapPolyMesh > removeLimitShells(const label nBufferLayers, const label nErodeCellZones, const labelList &globalToMasterPatch, const labelList &globalToSlavePatch, const pointField &locationsInMesh, const wordList ®ionsInMesh, const pointField &locationsOutsideMesh)
Remove cells from limitRegions if level -1.
static List< labelPair > subsetBaffles(const polyMesh &mesh, const labelList &zoneIDs, const List< labelPair > &baffles)
Subset baffles according to zones.
writeType
Enumeration for what to write. Used as a bit-pattern.
autoPtr< mapPolyMesh > mergePoints(const labelList &pointToDuplicate)
Merge duplicate points.
autoPtr< mapPolyMesh > dupNonManifoldPoints()
Find boundary points that connect to more than one cell.
autoPtr< mapPolyMesh > dupNonManifoldBoundaryPoints()
Find boundary points that are on faceZones of type boundary.
void getZoneFaces(const labelList &zoneIDs, labelList &faceZoneID, labelList &ownPatch, labelList &neiPatch, labelList &nBaffles) const
Get per-face information (faceZone, master/slave patch)
autoPtr< mapPolyMesh > mergeBaffles(const List< labelPair > &, const Map< label > &faceToPatch)
Merge baffles. Gets pairs of faces and boundary faces to move.
void baffleAndSplitMesh(const bool handleSnapProblems, const snapParameters &snapParams, const bool useTopologicalSnapDetection, const bool removeEdgeConnectedCells, const scalarField &perpendicularAngle, const label nErodeCellZones, const dictionary &motionDict, Time &runTime, const labelList &globalToMasterPatch, const labelList &globalToSlavePatch, const pointField &locationsInMesh, const wordList ®ionsInMesh, const pointField &locationsOutsideMesh, const bool exitIfLeakPath, const refPtr< coordSetWriter > &leakPathFormatter)
Split off unreachable areas of mesh.
debugType
Enumeration for what to debug. Used as a bit-pattern.
autoPtr< mapPolyMesh > mergeZoneBaffles(const bool doInternalZones, const bool doBaffleZones)
Merge all baffles on faceZones.
autoPtr< mapPolyMesh > createBaffles(const labelList &ownPatch, const labelList &neiPatch)
Create baffle for every internal face where ownPatch != -1.
autoPtr< mapPolyMesh > createZoneBaffles(const labelList &zoneIDs, List< labelPair > &baffles, labelList &originatingFaceZone)
Create baffles for faces on faceZones. Return created baffles.
void mergeFreeStandingBaffles(const snapParameters &snapParams, const bool useTopologicalSnapDetection, const bool removeEdgeConnectedCells, const scalarField &perpendicularAngle, const scalar planarAngle, const dictionary &motionDict, Time &runTime, const labelList &globalToMasterPatch, const labelList &globalToSlavePatch, const pointField &locationsInMesh, const pointField &locationsOutsideMesh)
Merge free-standing baffles.
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO.
label whichPatch(const label faceIndex) const
Return patch index for a given face label.
label start() const noexcept
The start label of boundary faces in the polyMesh face list.
static void mergePoints(const polyMesh &, const Map< label > &pointToMaster, polyTopoChange &meshMod)
Helper: Merge points.
Mesh consisting of general polyhedral cells.
const faceZoneMesh & faceZones() const noexcept
Return face zone mesh.
virtual const faceList & faces() const
Return raw faces.
virtual const labelList & faceOwner() const
Return face owner.
virtual const labelList & faceNeighbour() const
Return face neighbour.
Class describing modification of a face.
A patch is a list of labels that address the faces in the global face list.
virtual bool coupled() const
Return true if this patch is geometrically coupled (i.e. faces and.
label start() const
Return start label of this patch in the polyMesh face list.
Class containing data for face removal.
Direct mesh changes based on v1.3 polyTopoChange syntax.
label setAction(const topoAction &action)
For compatibility with polyTopoChange: set topological action.
autoPtr< mapPolyMesh > changeMesh(polyMesh &mesh, const labelUList &patchMap, const bool inflate, const bool syncParallel=true, const bool orderCells=false, const bool orderPoints=false)
Inplace changes mesh without change of patches.
bool isInternalFace(const label faceIndex) const noexcept
Return true if given face label is internal to the mesh.
const vectorField & faceCentres() const
label nFaces() const noexcept
Number of mesh faces.
A class for managing references or pointers (no reference counting)
static List< pointField > zonePoints(const pointField &locationsInMesh, const wordList &zonesInMesh, const pointField &locationsOutsideMesh)
Helper: per zone (entry in zonesInMesh) the locations with.
bool handleSnapProblems() const
Determines the 'side' for every face and connected to a singly-connected (through edges) region of fa...
This class separates the mesh into distinct unconnected regions, each of which is then given a label ...
label nRegions() const
Return total number of regions.
Simple container to keep together snap specific information.
static labelList getInsidePointNamedSurfaces(const PtrList< surfaceZonesInfo > &surfList)
Get indices of surfaces with a cellZone that have 'insidePoint'.
static labelList getUnnamedSurfaces(const PtrList< surfaceZonesInfo > &surfList)
Get indices of unnamed surfaces (surfaces without faceZoneName)
static labelList getStandaloneNamedSurfaces(const PtrList< surfaceZonesInfo > &surfList)
Get indices of named surfaces without a cellZone.
faceZoneType
What to do with faceZone faces.
static label addFaceZone(const word &name, const labelList &addressing, const boolList &flipMap, polyMesh &mesh)
static const Enum< faceZoneType > faceZoneTypeNames
static labelList getNamedSurfaces(const PtrList< surfaceZonesInfo > &surfList)
Get indices of named surfaces (surfaces with faceZoneName)
static labelList addCellZonesToMesh(const PtrList< surfaceZonesInfo > &surfList, const labelList &namedSurfaces, polyMesh &mesh)
static labelListList addFaceZonesToMesh(const PtrList< surfaceZonesInfo > &surfList, const labelList &namedSurfaces, polyMesh &mesh)
static labelList getClosedNamedSurfaces(const PtrList< surfaceZonesInfo > &surfList, const searchableSurfaces &allGeometry, const labelList &surfaces)
Get indices of surfaces with a cellZone that are closed and.
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
A class for handling words, derived from Foam::string.
const word & name() const noexcept
The zone name.
const polyBoundaryMesh & patches
bool coupled(solutionDict.getOrDefault("coupledEnergyField", false))
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
const labelIOList & zoneIDs
const labelIOList & zoneID
#define WarningInFunction
Report a warning using Foam::Warning.
labelList findIndices(const ListType &input, const UnaryPredicate &pred, label start=0)
Linear search to find all occurences of given element.
const wordList area
Standard area field types (scalar, vector, tensor, etc)
const std::string patch
OpenFOAM patch number as a std::string.
auto key(const Type &t) -> typename std::enable_if< std::is_enum< Type >::value, typename std::underlying_type< Type >::type >::type
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
Pair< label > labelPair
A pair of labels.
List< word > wordList
A List of words.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Smanip< ios_base::fmtflags > setf(const ios_base::fmtflags flags)
const dimensionSet dimless
Dimensionless.
labelList identity(const label len, label start=0)
Return an identity map of the given length with (map[i] == i)
List< label > labelList
A List of labels.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
bool mkDir(const fileName &pathName, mode_t mode=0777)
Make a directory and return an error if it could not be created.
ZoneMesh< cellZone, polyMesh > cellZoneMesh
A ZoneMesh with the type cellZone.
line< point, const point & > linePointRef
A line using referred points.
GeometricField< scalar, fvPatchField, volMesh > volScalarField
void reverse(UList< T > &list, const label n)
Reverse the first n elements of the list.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
ZoneMesh< pointZone, polyMesh > pointZoneMesh
A ZoneMesh with the type pointZone.
messageStream Info
Information stream (stdout output on master, null elsewhere)
vectorField pointField
pointField is a vectorField.
vector point
Point is a vector.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
HashTable< word, wordPair, Foam::Hash< wordPair > > wordPairHashTable
HashTable of wordPair.
Omanip< int > setw(const int i)
ZoneMesh< faceZone, polyMesh > faceZoneMesh
A ZoneMesh with the type faceZone.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Ostream & indent(Ostream &os)
Indent stream.
constexpr scalar degToRad() noexcept
Multiplication factor for degrees to radians conversion.
PrimitivePatch< UIndirectList< face >, const pointField & > uindirectPrimitivePatch
A PrimitivePatch with UIndirectList for the faces, const reference for the point field.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
List< labelList > labelListList
A List of labelList.
void reduce(const List< UPstream::commsStruct > &comms, T &value, const BinaryOp &bop, const int tag, const label comm)
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
errorManip< error > abort(error &err)
Field< vector > vectorField
Specialisation of Field<T> for vector.
List< bool > boolList
A List of bools.
static constexpr const zero Zero
Global zero (0)
label checkData(const fvMesh &mesh, const instantList &timeDirs, wordList &objectNames)
Check if fields are good to use (available at all times)
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
T returnReduce(const T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Reduce (copy) and return value.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
PrimitivePatch< IndirectList< face >, const pointField & > indirectPrimitivePatch
A PrimitivePatch with an IndirectList for the faces, const reference for the point field.
errorManipArg< error, int > exit(error &err, const int errNo=1)
DynamicID< faceZoneMesh > faceZoneID
Foam::faceZoneID.
Type gMax(const FieldField< Field, Type > &f)
UIndirectList< label > labelUIndList
UIndirectList of labels.
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
dimensionedScalar cos(const dimensionedScalar &ds)
constexpr char nl
The newline '\n' character (0x0a)
constexpr auto end(C &c) -> decltype(c.end())
Return iterator to the end of the container c.
Info<< "Finished reading KIVA file"<< endl;cellShapeList cellShapes(nPoints);labelList cellZoning(nPoints, -1);const cellModel &hex=cellModel::ref(cellModel::HEX);labelList hexLabels(8);label activeCells=0;labelList pointMap(nPoints);forAll(pointMap, i){ pointMap[i]=i;}for(label i=0;i< nPoints;i++){ if(f[i] > 0.0) { hexLabels[0]=i;hexLabels[1]=i1tab[i];hexLabels[2]=i3tab[i1tab[i]];hexLabels[3]=i3tab[i];hexLabels[4]=i8tab[i];hexLabels[5]=i1tab[i8tab[i]];hexLabels[6]=i3tab[i1tab[i8tab[i]]];hexLabels[7]=i3tab[i8tab[i]];cellShapes[activeCells].reset(hex, hexLabels);edgeList edges=cellShapes[activeCells].edges();forAll(edges, ei) { if(edges[ei].mag(points)< SMALL) { label start=pointMap[edges[ei].start()];while(start !=pointMap[start]) { start=pointMap[start];} label end=pointMap[edges[ei].end()];while(end !=pointMap[end]) { end=pointMap[end];} label minLabel=min(start, end);pointMap[start]=pointMap[end]=minLabel;} } cellZoning[activeCells]=idreg[i];activeCells++;}}cellShapes.setSize(activeCells);cellZoning.setSize(activeCells);forAll(cellShapes, celli){ cellShape &cs=cellShapes[celli];forAll(cs, i) { cs[i]=pointMap[cs[i]];} cs.collapse();}label bcIDs[11]={-1, 0, 2, 4, -1, 5, -1, 6, 7, 8, 9};const label nBCs=12;const word *kivaPatchTypes[nBCs]={ &wallPolyPatch::typeName, &wallPolyPatch::typeName, &wallPolyPatch::typeName, &wallPolyPatch::typeName, &symmetryPolyPatch::typeName, &wedgePolyPatch::typeName, &polyPatch::typeName, &polyPatch::typeName, &polyPatch::typeName, &polyPatch::typeName, &symmetryPolyPatch::typeName, &oldCyclicPolyPatch::typeName};enum patchTypeNames{ PISTON, VALVE, LINER, CYLINDERHEAD, AXIS, WEDGE, INFLOW, OUTFLOW, PRESIN, PRESOUT, SYMMETRYPLANE, CYCLIC};const char *kivaPatchNames[nBCs]={ "piston", "valve", "liner", "cylinderHead", "axis", "wedge", "inflow", "outflow", "presin", "presout", "symmetryPlane", "cyclic"};List< SLList< face > > pFaces[nBCs]
#define forAll(list, i)
Loop across all elements in list.
#define forAllConstIters(container, iter)
Iterate across all elements of the container object with const access.
Unit conversion functions.