65 polyTopoChange& meshMod
68 const face&
f = mesh_.
faces()[faceI];
70 bool zoneFlip =
false;
75 zoneFlip = fZone.flipMap()[fZone.whichFace(faceI)];
102 <<
"No neighbour patch for internal face " << faceI
107 bool reverseFlip =
false;
110 reverseFlip = !zoneFlip;
113 dupFaceI = meshMod.setAction
173 void Foam::meshRefinement::getIntersections
183 autoPtr<OBJstream> str;
184 if (
debug&OBJINTERSECTIONS)
191 mesh_.time().path()/
timeName()/
"intersections.obj"
195 Pout<<
"getIntersections : Writing surface intersections to file "
200 globalRegion1.setSize(mesh_.nFaces());
202 globalRegion2.setSize(mesh_.nFaces());
230 List<pointIndexHit> hit1;
233 List<pointIndexHit> hit2;
235 surfaces_.findNearestIntersection
253 label faceI = testFaces[i];
255 if (hit1[i].hit() && hit2[i].hit())
268 globalRegion1[faceI] =
269 surfaces_.globalRegion(surface1[i], region1[i]);
270 globalRegion2[faceI] =
271 surfaces_.globalRegion(surface2[i], region2[i]);
273 if (globalRegion1[faceI] == -1 || globalRegion2[faceI] == -1)
283 void Foam::meshRefinement::getBafflePatches
285 const label nErodeCellZones,
312 bitSet posOrientation;
339 ownPatch.setSize(mesh_.nFaces());
341 neiPatch.setSize(mesh_.nFaces());
346 if (unnamedRegion1[faceI] != -1 || unnamedRegion2[faceI] != -1)
348 label ownMasterPatch = -1;
349 if (unnamedRegion1[faceI] != -1)
351 ownMasterPatch = globalToMasterPatch[unnamedRegion1[faceI]];
353 label neiMasterPatch = -1;
354 if (unnamedRegion2[faceI] != -1)
356 neiMasterPatch = globalToMasterPatch[unnamedRegion2[faceI]];
363 label ownZone = cellToZone[mesh_.faceOwner()[faceI]];
366 if (mesh_.isInternalFace(faceI))
368 neiZone = cellToZone[mesh_.faceNeighbour()[faceI]];
372 neiZone = neiCellZone[faceI-mesh_.nInternalFaces()];
380 (ownZone >= 0 && neiZone != -2)
381 || (neiZone >= 0 && ownZone != -2)
384 namedSurfaceIndex.size() == 0
385 || namedSurfaceIndex[faceI] == -1
396 ownPatch[faceI] = ownMasterPatch;
397 neiPatch[faceI] = neiMasterPatch;
417 const bool allowBoundary,
422 Map<labelPair> bafflePatch(mesh_.nFaces()/1000);
424 const PtrList<surfaceZonesInfo>& surfZones = surfaces_.surfZones();
429 const word& faceZoneName = surfZones[surfI].faceZoneName();
431 if (faceZoneName.size())
434 label zoneI = fZones.findZoneID(faceZoneName);
436 const faceZone& fZone = fZones[zoneI];
439 label globalRegionI = surfaces_.globalRegion(surfI, 0);
442 globalToMasterPatch[globalRegionI],
443 globalToSlavePatch[globalRegionI]
446 Info<<
"For zone " << fZone.name() <<
" found patches "
447 << mesh_.boundaryMesh()[zPatches[0]].name() <<
" and "
448 << mesh_.boundaryMesh()[zPatches[1]].name()
453 label faceI = fZone[i];
455 if (allowBoundary || mesh_.isInternalFace(faceI))
458 if (fZone.flipMap()[i])
463 if (!bafflePatch.insert(faceI,
patches))
467 <<
" fc:" << mesh_.faceCentres()[faceI]
468 <<
" in zone " << fZone.name()
469 <<
" is in multiple zones!"
488 ownPatch.size() != mesh_.nFaces()
489 || neiPatch.size() != mesh_.nFaces()
494 <<
" ownPatch:" << ownPatch.size()
495 <<
" neiPatch:" << neiPatch.size()
496 <<
". Should be number of faces:" << mesh_.nFaces()
507 forAll(syncedOwnPatch, faceI)
511 (ownPatch[faceI] == -1 && syncedOwnPatch[faceI] != -1)
512 || (neiPatch[faceI] == -1 && syncedNeiPatch[faceI] != -1)
516 <<
"Non synchronised at face:" << faceI
517 <<
" on patch:" << mesh_.boundaryMesh().whichPatch(faceI)
518 <<
" fc:" << mesh_.faceCentres()[faceI] <<
endl
519 <<
"ownPatch:" << ownPatch[faceI]
520 <<
" syncedOwnPatch:" << syncedOwnPatch[faceI]
521 <<
" neiPatch:" << neiPatch[faceI]
522 <<
" syncedNeiPatch:" << syncedNeiPatch[faceI]
533 for (
label faceI = 0; faceI < mesh_.nInternalFaces(); faceI++)
535 if (ownPatch[faceI] != -1)
555 label coupledPatchI = -1;
559 && !refCast<const coupledPolyPatch>(pp).separated()
562 coupledPatchI = patchI;
569 if (ownPatch[faceI] != -1)
579 if (coupledPatchI != -1)
581 faceToCoupledPatch_.insert(faceI, coupledPatchI);
594 mapPtr = meshMod.
changeMesh(mesh_,
false,
true);
598 mesh_.updateMesh(map);
617 faceSet baffledFacesSet(mesh_,
"baffledFacesSet", 2*nBaffles);
623 forAll(ownPatch, oldFaceI)
625 label faceI = reverseFaceMap[oldFaceI];
627 if (ownPatch[oldFaceI] != -1 && faceI >= 0)
629 const cell& ownFaces = mesh_.cells()[mesh_.faceOwner()[faceI]];
631 baffledFacesSet.
insert(ownFaces);
639 if (oldFaceI >= 0 && reverseFaceMap[oldFaceI] != faceI)
641 const cell& ownFaces = mesh_.cells()[mesh_.faceOwner()[faceI]];
643 baffledFacesSet.
insert(ownFaces);
646 baffledFacesSet.
sync(mesh_);
648 updateMesh(map, baffledFacesSet.
toc());
666 const faceZone& fZone = faceZones[zoneI];
670 bool hasInfo = getFaceZoneInfo(fZone.
name(), mpI, spI, fzType);
672 if (hasInfo && fzTypes.found(fzType))
705 if (faceToZone[
p[0]] != -1 && (faceToZone[
p[0]] == faceToZone[
p[1]]))
729 Info<<
"Converting zoned faces into baffles ..." <<
endl;
742 const faceZone& fz = faceZones[zoneI];
744 const word& masterName = faceZoneToMasterPatch_[fz.
name()];
745 label masterPatchI = mesh_.boundaryMesh().findPatchID(masterName);
746 const word& slaveName = faceZoneToSlavePatch_[fz.
name()];
747 label slavePatchI = mesh_.boundaryMesh().findPatchID(slaveName);
749 if (masterPatchI == -1 || slavePatchI == -1)
752 <<
"Problem: masterPatchI:" << masterPatchI
759 if (mesh_.isInternalFace(faceI))
763 ownPatch[faceI] = slavePatchI;
764 neiPatch[faceI] = masterPatchI;
768 ownPatch[faceI] = masterPatchI;
769 neiPatch[faceI] = slavePatchI;
778 label nLocalBaffles =
sum(nBaffles);
783 if (nTotalBaffles > 0)
789 <<
setf(ios_base::left)
790 <<
setw(30) <<
"FaceZone"
791 <<
setw(10) <<
"FaceType"
792 <<
setw(10) <<
"nBaffles"
794 <<
setw(30) <<
"--------"
795 <<
setw(10) <<
"--------"
796 <<
setw(10) <<
"--------"
802 const faceZone& fz = faceZones[zoneI];
806 bool hasInfo = getFaceZoneInfo(fz.
name(), mpI, spI, fzType);
814 <<
setw(10) << nBaffles[j]
821 map = createBaffles(ownPatch, neiPatch);
827 baffles.
setSize(nLocalBaffles);
828 originatingFaceZone.
setSize(nLocalBaffles);
832 const labelList& reverseFaceMap = map().reverseFaceMap();
836 label faceI = mesh_.nInternalFaces();
837 faceI < mesh_.nFaces();
842 label masterFaceI = reverseFaceMap[oldFaceI];
843 if (masterFaceI != faceI && ownPatch[oldFaceI] != -1)
845 baffles[baffleI] =
labelPair(masterFaceI, faceI);
846 originatingFaceZone[baffleI] =
faceZoneID[oldFaceI];
851 if (baffleI != baffles.size())
854 <<
"Had " << baffles.size() <<
" baffles to create "
855 <<
" but encountered " << baffleI
856 <<
" slave faces originating from patcheable faces."
862 const_cast<Time&
>(mesh_.time())++;
863 Pout<<
"Writing zone-baffled mesh to time " <<
timeName()
869 mesh_.time().path()/
"baffles"
873 Info<<
"Created " << nTotalBaffles <<
" baffles in = "
874 << mesh_.time().cpuTimeIncrement() <<
" s\n" <<
nl <<
endl;
879 originatingFaceZone.
clear();
889 const scalar planarAngle
916 const label baffleValue = 1000000;
935 const labelList& fEdges = mesh_.faceEdges(faceI);
939 nBafflesPerEdge[fEdges[fEdgeI]]++;
947 DynamicList<label> fe0;
948 DynamicList<label> fe1;
957 label f0 = couples[i].first();
958 const labelList& fEdges0 = mesh_.faceEdges(f0, fe0);
961 nBafflesPerEdge[fEdges0[fEdgeI]] += baffleValue;
966 label f1 = couples[i].second();
967 const labelList& fEdges1 = mesh_.faceEdges(f1, fe1);
970 nBafflesPerEdge[fEdges1[fEdgeI]] += baffleValue;
989 List<labelPair> filteredCouples(couples.size());
1002 const labelList& fEdges = mesh_.faceEdges(couple.first());
1006 label edgeI = fEdges[fEdgeI];
1008 if (nBafflesPerEdge[edgeI] == 2*baffleValue+2*1)
1010 filteredCouples[filterI++] = couple;
1016 filteredCouples.setSize(filterI);
1021 Info<<
"freeStandingBaffles : detected "
1023 <<
" free-standing baffles out of "
1036 const pointField& cellCentres = mesh_.cellCentres();
1038 forAll(filteredCouples, i)
1040 const labelPair& couple = filteredCouples[i];
1041 start[i] = cellCentres[mesh_.faceOwner()[couple.first()]];
1042 end[i] = cellCentres[mesh_.faceOwner()[couple.second()]];
1056 List<pointIndexHit> hit1;
1061 List<pointIndexHit> hit2;
1065 surfaces_.findNearestIntersection
1067 identity(surfaces_.surfaces().size()),
1091 forAll(filteredCouples, i)
1093 const labelPair& couple = filteredCouples[i];
1107 &&
mag(hit1[i].hitPoint()-hit2[i].hitPoint()) > mergeDistance_
1118 if ((normal1[i]&normal2[i]) > planarAngleCos)
1122 scalar magN =
mag(
n);
1125 filteredCouples[filterI++] = couple;
1129 else if (hit1[i].hit() || hit2[i].hit())
1135 filteredCouples.setSize(filterI);
1137 Info<<
"freeStandingBaffles : detected "
1139 <<
" planar (within " << planarAngle
1140 <<
" degrees) free-standing baffles out of "
1145 return filteredCouples;
1162 const faceList& faces = mesh_.faces();
1163 const labelList& faceOwner = mesh_.faceOwner();
1168 label face0 = couples[i].first();
1169 label face1 = couples[i].second();
1174 label own0 = faceOwner[face0];
1175 label own1 = faceOwner[face1];
1177 if (face1 < 0 || own0 < own1)
1181 bool zoneFlip =
false;
1189 label nei = (face1 < 0 ? -1 : own1);
1212 bool zoneFlip =
false;
1241 const label faceI = iter.key();
1242 const label patchI = iter.val();
1244 if (!mesh_.isInternalFace(faceI))
1247 <<
"problem: face:" << faceI
1248 <<
" at:" << mesh_.faceCentres()[faceI]
1249 <<
"(wanted patch:" << patchI
1254 bool zoneFlip =
false;
1281 mapPtr = meshMod.
changeMesh(mesh_,
false,
true);
1285 mesh_.updateMesh(map);
1304 labelList newExposedFaces(2*couples.size());
1312 newExposedFaces[newI++] = newFace0;
1318 newExposedFaces[newI++] = newFace1;
1321 newExposedFaces.
setSize(newI);
1322 updateMesh(map, newExposedFaces);
1331 const bool doInternalZones,
1332 const bool doBaffleZones
1338 if (doInternalZones)
1362 mapPtr = mergeBaffles(zoneBaffles,
Map<label>(0));
1369 void Foam::meshRefinement::findCellZoneGeometric
1379 const pointField& cellCentres = mesh_.cellCentres();
1380 const labelList& faceOwner = mesh_.faceOwner();
1381 const labelList& faceNeighbour = mesh_.faceNeighbour();
1385 surfaces_.findInside
1387 closedNamedSurfaces,
1392 forAll(insideSurfaces, cellI)
1394 label surfI = insideSurfaces[cellI];
1398 if (cellToZone[cellI] == -2)
1400 cellToZone[cellI] = surfaceToCellZone[surfI];
1402 else if (cellToZone[cellI] == -1)
1407 cellToZone[cellI] = surfaceToCellZone[surfI];
1420 label nCandidates = 0;
1421 forAll(namedSurfaceIndex, faceI)
1423 label surfI = namedSurfaceIndex[faceI];
1427 if (mesh_.isInternalFace(faceI))
1441 forAll(namedSurfaceIndex, faceI)
1443 label surfI = namedSurfaceIndex[faceI];
1447 label own = faceOwner[faceI];
1448 const point& ownCc = cellCentres[own];
1450 if (mesh_.isInternalFace(faceI))
1452 label nei = faceNeighbour[faceI];
1453 const point& neiCc = cellCentres[nei];
1455 const vector d = 1
e-4*(neiCc - ownCc);
1456 candidatePoints[nCandidates++] = ownCc-d;
1457 candidatePoints[nCandidates++] = neiCc+d;
1462 const point& neiFc = neiCc[faceI-mesh_.nInternalFaces()];
1465 const vector d = 1
e-4*(neiFc - ownCc);
1466 candidatePoints[nCandidates++] = ownCc-d;
1474 surfaces_.findInside
1476 closedNamedSurfaces,
1485 forAll(namedSurfaceIndex, faceI)
1487 label surfI = namedSurfaceIndex[faceI];
1491 label own = faceOwner[faceI];
1493 if (mesh_.isInternalFace(faceI))
1495 label ownSurfI = insideSurfaces[nCandidates++];
1498 cellToZone[own] = surfaceToCellZone[ownSurfI];
1501 label neiSurfI = insideSurfaces[nCandidates++];
1504 label nei = faceNeighbour[faceI];
1506 cellToZone[nei] = surfaceToCellZone[neiSurfI];
1511 label ownSurfI = insideSurfaces[nCandidates++];
1514 cellToZone[own] = surfaceToCellZone[ownSurfI];
1525 for (
label faceI = 0; faceI < mesh_.nInternalFaces(); faceI++)
1527 label ownZone = cellToZone[mesh_.faceOwner()[faceI]];
1528 label neiZone = cellToZone[mesh_.faceNeighbour()[faceI]];
1530 if (namedSurfaceIndex[faceI] == -1 && (ownZone != neiZone))
1540 else if (neiZone == -1)
1546 minZone =
min(ownZone, neiZone);
1550 label geomSurfI = surfaceToCellZone.find(minZone);
1552 if (geomSurfI != -1)
1554 namedSurfaceIndex[faceI] = geomSurfI;
1562 const polyBoundaryMesh&
patches = mesh_.boundaryMesh();
1566 const polyPatch& pp =
patches[patchI];
1572 label faceI = pp.start()+i;
1573 label ownZone = cellToZone[mesh_.faceOwner()[faceI]];
1574 label neiZone = neiCellZone[faceI-mesh_.nInternalFaces()];
1576 if (namedSurfaceIndex[faceI] == -1 && (ownZone != neiZone))
1584 else if (neiZone == -1)
1590 minZone =
min(ownZone, neiZone);
1594 label geomSurfI = surfaceToCellZone.find(minZone);
1596 if (geomSurfI != -1)
1598 namedSurfaceIndex[faceI] = geomSurfI;
1610 void Foam::meshRefinement::findCellZoneInsideWalk
1620 boolList blockedFace(mesh_.nFaces());
1623 forAll(blockedFace, faceI)
1625 if (faceToZone[faceI] == -1)
1627 blockedFace[faceI] =
false;
1631 blockedFace[faceI] =
true;
1637 regionSplit cellRegion(mesh_, blockedFace);
1638 blockedFace.clear();
1641 (void)mesh_.tetBasePtIs();
1644 forAll(locationsInMesh, i)
1647 const point& insidePoint = locationsInMesh[i];
1651 label keepRegionI = findRegion
1659 Info<<
"For cellZone "
1665 <<
" found point " << insidePoint
1666 <<
" in global region " << keepRegionI
1667 <<
" out of " << cellRegion.nRegions() <<
" regions." <<
endl;
1669 if (keepRegionI == -1)
1672 <<
"Point " << insidePoint
1673 <<
" is not inside the mesh." <<
nl
1674 <<
"Bounding box of the mesh:" << mesh_.bounds()
1683 label nWarnings = 0;
1685 forAll(cellRegion, cellI)
1687 if (cellRegion[cellI] == keepRegionI)
1689 if (cellToZone[cellI] == -2)
1692 cellToZone[cellI] =
zoneID;
1694 else if (cellToZone[cellI] !=
zoneID)
1696 if (cellToZone[cellI] != -1 && nWarnings < 10)
1700 <<
" at " << mesh_.cellCentres()[cellI]
1701 <<
" is inside cellZone "
1707 <<
" from locationInMesh " << insidePoint
1708 <<
" but already marked as being in zone "
1709 << mesh_.cellZones()[cellToZone[cellI]].name()
1711 <<
"This can happen if your surfaces are not"
1712 <<
" (sufficiently) closed."
1718 cellToZone[cellI] =
zoneID;
1726 void Foam::meshRefinement::findCellZoneInsideWalk
1738 forAll(zoneNamesInMesh, i)
1740 zoneIDs[i] = czs.findZoneID(zoneNamesInMesh[i]);
1742 findCellZoneInsideWalk
1752 bool Foam::meshRefinement::calcRegionToZone
1754 const label backgroundZoneID,
1755 const label surfZoneI,
1756 const label ownRegion,
1757 const label neiRegion,
1762 bool changed =
false;
1765 if (ownRegion != neiRegion)
1772 if (regionToCellZone[ownRegion] == -2)
1774 if (surfZoneI == -1)
1779 if (regionToCellZone[neiRegion] != -2)
1781 regionToCellZone[ownRegion] = regionToCellZone[neiRegion];
1785 else if (regionToCellZone[neiRegion] == surfZoneI)
1790 if (backgroundZoneID != -2)
1792 regionToCellZone[ownRegion] = backgroundZoneID;
1796 else if (regionToCellZone[neiRegion] != -2)
1800 regionToCellZone[ownRegion] = surfZoneI;
1804 else if (regionToCellZone[neiRegion] == -2)
1806 if (surfZoneI == -1)
1811 regionToCellZone[neiRegion] = regionToCellZone[ownRegion];
1814 else if (regionToCellZone[ownRegion] == surfZoneI)
1818 if (backgroundZoneID != -2)
1820 regionToCellZone[neiRegion] = backgroundZoneID;
1824 else if (regionToCellZone[ownRegion] != -2)
1828 regionToCellZone[neiRegion] = surfZoneI;
1837 void Foam::meshRefinement::findCellZoneTopo
1839 const label backgroundZoneID,
1868 boolList blockedFace(mesh_.nFaces());
1870 forAll(unnamedSurfaceRegion, faceI)
1872 if (unnamedSurfaceRegion[faceI] == -1 && namedSurfaceIndex[faceI] == -1)
1874 blockedFace[faceI] =
false;
1878 blockedFace[faceI] =
true;
1884 regionSplit cellRegion(mesh_, blockedFace);
1885 blockedFace.clear();
1891 labelList regionToCellZone(cellRegion.nRegions(), -2);
1896 forAll(cellToZone, cellI)
1898 label regionI = cellRegion[cellI];
1899 if (cellToZone[cellI] != -2 && regionToCellZone[regionI] == -2)
1901 regionToCellZone[regionI] = cellToZone[cellI];
1915 forAll(locationsInMesh, i)
1917 const point& keepPoint = locationsInMesh[i];
1918 label keepRegionI = findRegion
1926 Info<<
"Found point " << keepPoint
1927 <<
" in global region " << keepRegionI
1928 <<
" out of " << cellRegion.nRegions() <<
" regions." <<
endl;
1930 if (keepRegionI == -1)
1933 <<
"Point " << keepPoint
1934 <<
" is not inside the mesh." <<
nl
1935 <<
"Bounding box of the mesh:" << mesh_.bounds()
1943 if (regionToCellZone[keepRegionI] == -2)
1945 regionToCellZone[keepRegionI] = -1;
1965 bool changed =
false;
1969 for (
label faceI = 0; faceI < mesh_.nInternalFaces(); faceI++)
1971 label surfI = namedSurfaceIndex[faceI];
1974 if (unnamedSurfaceRegion[faceI] == -1 && surfI != -1)
1978 bool changedCell = calcRegionToZone
1981 surfaceToCellZone[surfI],
1982 cellRegion[mesh_.faceOwner()[faceI]],
1983 cellRegion[mesh_.faceNeighbour()[faceI]],
1987 changed = changed | changedCell;
1993 const polyBoundaryMesh&
patches = mesh_.boundaryMesh();
2003 const polyPatch& pp =
patches[patchI];
2009 label faceI = pp.start()+i;
2011 label surfI = namedSurfaceIndex[faceI];
2014 if (unnamedSurfaceRegion[faceI] == -1 && surfI != -1)
2016 bool changedCell = calcRegionToZone
2019 surfaceToCellZone[surfI],
2020 cellRegion[mesh_.faceOwner()[faceI]],
2021 neiCellRegion[faceI-mesh_.nInternalFaces()],
2025 changed = changed | changedCell;
2040 Pout<<
"meshRefinement::findCellZoneTopo :"
2041 <<
" nRegions:" << regionToCellZone.size()
2042 <<
" of which visited (-1 = background, >= 0 : cellZone) :"
2045 forAll(regionToCellZone, regionI)
2047 if (regionToCellZone[regionI] != -2)
2049 Pout<<
"Region " << regionI
2050 <<
" becomes cellZone:" << regionToCellZone[regionI]
2057 forAll(cellToZone, cellI)
2059 label regionI = cellRegion[cellI];
2060 if (cellToZone[cellI] == -2 && regionToCellZone[regionI] != -2)
2062 cellToZone[cellI] = regionToCellZone[regionI];
2068 void Foam::meshRefinement::erodeCellZone
2070 const label nErodeCellZones,
2071 const label backgroundZoneID,
2088 for (
label iter = 0; iter < nErodeCellZones; iter++)
2095 for (
label facei = 0; facei < mesh_.nInternalFaces(); facei++)
2099 unnamedSurfaceRegion[facei] == -1
2100 && namedSurfaceIndex[facei] == -1
2103 label own = mesh_.faceOwner()[facei];
2104 label nei = mesh_.faceNeighbour()[facei];
2105 if (cellToZone[own] == -2 && cellToZone[nei] >= -1)
2107 erodedCellToZone[nei] = backgroundZoneID;
2110 else if (cellToZone[nei] == -2 && cellToZone[own] >= -1)
2112 erodedCellToZone[own] = backgroundZoneID;
2120 const polyBoundaryMesh&
patches = mesh_.boundaryMesh();
2130 const polyPatch& pp =
patches[patchi];
2136 label facei = pp.start()+i;
2139 unnamedSurfaceRegion[facei] == -1
2140 && namedSurfaceIndex[facei] == -1
2143 label own = mesh_.faceOwner()[facei];
2144 label bFacei = facei-mesh_.nInternalFaces();
2145 if (neiCellZone[bFacei] == -2 && cellToZone[own] >= -1)
2147 erodedCellToZone[own] = backgroundZoneID;
2155 cellToZone.transfer(erodedCellToZone);
2157 reduce(nChanged, sumOp<label>());
2160 Pout<<
"erodeCellZone : eroded " << nChanged
2161 <<
" cells (moved from cellZone to background zone "
2162 << backgroundZoneID <<
endl;
2173 void Foam::meshRefinement::makeConsistentFaceIndex
2188 const labelList& faceOwner = mesh_.faceOwner();
2189 const labelList& faceNeighbour = mesh_.faceNeighbour();
2191 for (
label faceI = 0; faceI < mesh_.nInternalFaces(); faceI++)
2193 label ownZone = cellToZone[faceOwner[faceI]];
2194 label neiZone = cellToZone[faceNeighbour[faceI]];
2199 && namedSurfaceIndex[faceI] != -1
2200 && surfaceMap[namedSurfaceIndex[faceI]] == -1
2203 namedSurfaceIndex[faceI] = -1;
2207 const polyBoundaryMesh&
patches = mesh_.boundaryMesh();
2216 const polyPatch& pp =
patches[patchI];
2222 label faceI = pp.start()+i;
2224 label ownZone = cellToZone[faceOwner[faceI]];
2225 label neiZone = neiCellZone[faceI-mesh_.nInternalFaces()];
2230 && namedSurfaceIndex[faceI] != -1
2231 && surfaceMap[namedSurfaceIndex[faceI]] == -1
2234 namedSurfaceIndex[faceI] = -1;
2243 label faceI = pp.start()+i;
2247 namedSurfaceIndex[faceI] != -1
2248 && surfaceMap[namedSurfaceIndex[faceI]] == -1
2251 namedSurfaceIndex[faceI] = -1;
2259 void Foam::meshRefinement::getIntersections
2266 bitSet& posOrientation
2269 namedSurfaceIndex.setSize(mesh_.nFaces());
2270 namedSurfaceIndex = -1;
2272 posOrientation.setSize(mesh_.nFaces());
2273 posOrientation =
false;
2303 List<pointIndexHit> hit1;
2306 List<pointIndexHit> hit2;
2311 surfaces_.findNearestIntersection
2331 label faceI = testFaces[i];
2332 const vector&
area = mesh_.faceAreas()[faceI];
2334 if (surface1[i] != -1)
2341 magSqr(hit2[i].hitPoint())
2342 <
magSqr(hit1[i].hitPoint())
2346 namedSurfaceIndex[faceI] = surface2[i];
2347 posOrientation.
set(faceI, ((
area&normal2[i]) > 0));
2348 nSurfFaces[surface2[i]]++;
2352 namedSurfaceIndex[faceI] = surface1[i];
2353 posOrientation.set(faceI, ((
area&normal1[i]) > 0));
2354 nSurfFaces[surface1[i]]++;
2357 else if (surface2[i] != -1)
2359 namedSurfaceIndex[faceI] = surface2[i];
2360 posOrientation.set(faceI, ((
area&normal2[i]) > 0));
2361 nSurfFaces[surface2[i]]++;
2380 forAll(nSurfFaces, surfI)
2383 << surfaces_.names()[surfI]
2384 <<
" nZoneFaces:" << nSurfFaces[surfI] <<
nl;
2391 void Foam::meshRefinement::zonify
2393 const bool allowFreeStandingZoneFaces,
2394 const label nErodeCellZones,
2395 const label backgroundZoneID,
2403 bitSet& posOrientation
2416 const PtrList<surfaceZonesInfo>& surfZones = surfaces_.surfZones();
2419 labelList neiLevel(mesh_.nBoundaryFaces());
2421 calcNeighbourData(neiLevel, neiCc);
2429 if (namedSurfaces.size())
2441 cellToZone.setSize(mesh_.nCells());
2444 namedSurfaceIndex.clear();
2445 posOrientation.clear();
2462 if (namedSurfaces.size())
2478 if (locationsInMesh.size())
2480 Info<<
"Setting cellZones according to locationsInMesh:" <<
endl;
2482 labelList locationsZoneIDs(zonesInMesh.size(), -1);
2483 forAll(locationsInMesh, i)
2485 const word&
name = zonesInMesh[i];
2487 Info<<
"Location : " << locationsInMesh[i] <<
nl
2497 locationsZoneIDs[i] =
zoneID;
2504 findCellZoneInsideWalk
2521 if (locationSurfaces.size())
2523 Info<<
"Found " << locationSurfaces.size()
2524 <<
" named surfaces with a provided inside point."
2525 <<
" Assigning cells inside these surfaces"
2526 <<
" to the corresponding cellZone."
2531 labelList insidePointCellZoneIDs(locationSurfaces.size(), -1);
2532 forAll(locationSurfaces, i)
2534 label surfI = locationSurfaces[i];
2537 const word&
name = surfZones[surfI].cellZoneName();
2547 insidePointCellZoneIDs[i] =
zoneID;
2553 labelList allRegion1(mesh_.nFaces(), -1);
2554 forAll(namedSurfaceIndex, faceI)
2556 allRegion1[faceI] =
max
2558 unnamedRegion1[faceI],
2559 namedSurfaceIndex[faceI]
2563 findCellZoneInsideWalk
2566 insidePointCellZoneIDs,
2582 surfaces_.geometry(),
2583 surfaces_.surfaces()
2587 if (closedNamedSurfaces.size())
2589 Info<<
"Found " << closedNamedSurfaces.size()
2590 <<
" closed, named surfaces. Assigning cells in/outside"
2591 <<
" these surfaces to the corresponding cellZone."
2594 findCellZoneGeometric
2597 closedNamedSurfaces,
2608 if (namedSurfaces.size())
2610 if (nErodeCellZones <= 0)
2612 Info<<
"Walking from known cellZones; crossing a faceZone "
2613 <<
"face changes cellZone" <<
nl <<
endl;
2628 Info<<
"Eroding cellZone cells to make these consistent with"
2629 <<
" faceZone faces" <<
nl <<
endl;
2645 if (!allowFreeStandingZoneFaces)
2647 Info<<
"Only keeping zone faces inbetween different cellZones."
2661 labelList surfaceMap(surfZones.size(), -1);
2662 forAll(standaloneNamedSurfaces, i)
2664 surfaceMap[standaloneNamedSurfaces[i]] = i;
2667 makeConsistentFaceIndex
2682 label nUnvisited = 0;
2683 label nBackgroundCells = 0;
2685 forAll(cellToZone, cellI)
2687 label zoneI = cellToZone[cellI];
2690 nZoneCells[zoneI]++;
2692 else if (zoneI == -1)
2696 else if (zoneI == -2)
2706 reduce(nUnvisited, sumOp<label>());
2707 reduce(nBackgroundCells, sumOp<label>());
2708 forAll(nZoneCells, zoneI)
2710 reduce(nZoneCells[zoneI], sumOp<label>());
2712 Info<<
"nUnvisited :" << nUnvisited <<
endl;
2713 Info<<
"nBackgroundCells:" << nBackgroundCells <<
endl;
2714 Info<<
"nZoneCells :" << nZoneCells <<
endl;
2718 const_cast<Time&
>(mesh_.time())++;
2719 Pout<<
"Writing cell zone allocation on mesh to time "
2724 writeType(writeLevel() | WRITEMESH),
2725 mesh_.time().path()/
"cell2Zone"
2740 zeroGradientFvPatchScalarField::typeName
2743 forAll(cellToZone, cellI)
2745 volCellToZone[cellI] = cellToZone[cellI];
2747 volCellToZone.write();
2752 void Foam::meshRefinement::handleSnapProblems
2754 const snapParameters& snapParams,
2755 const bool useTopologicalSnapDetection,
2756 const bool removeEdgeConnectedCells,
2758 const dictionary& motionDict,
2765 <<
"Introducing baffles to block off problem cells" <<
nl
2766 <<
"----------------------------------------------" <<
nl
2770 if (useTopologicalSnapDetection)
2772 facePatch = markFacesOnProblemCells
2775 removeEdgeConnectedCells,
2782 facePatch = markFacesOnProblemCellsGeometric
2786 globalToMasterPatch,
2790 Info<<
"Analyzed problem cells in = "
2795 faceSet problemFaces(mesh_,
"problemFaces", mesh_.nFaces()/100);
2799 if (facePatch[faceI] != -1)
2801 problemFaces.insert(faceI);
2804 problemFaces.instance() =
timeName();
2805 Pout<<
"Dumping " << problemFaces.size()
2806 <<
" problem faces to " << problemFaces.objectPath() <<
endl;
2807 problemFaces.
write();
2810 Info<<
"Introducing baffles to delete problem cells." <<
nl <<
endl;
2818 createBaffles(facePatch, facePatch);
2825 Info<<
"Created baffles in = "
2828 printMeshInfo(
debug,
"After introducing baffles");
2832 Pout<<
"Writing extra baffled mesh to time "
2837 writeType(writeLevel() | WRITEMESH),
2840 Pout<<
"Dumped debug data in = "
2853 const polyBoundaryMesh&
patches = mesh_.boundaryMesh();
2854 const labelList& faceOwner = mesh_.faceOwner();
2855 const labelList& faceNeighbour = mesh_.faceNeighbour();
2872 DynamicList<label> faceLabels(mesh_.nFaces()/100);
2874 for (
label faceI = 0; faceI < mesh_.nInternalFaces(); faceI++)
2876 if (faceToZone[faceI] != -1)
2879 label ownZone = cellToZone[faceOwner[faceI]];
2880 label neiZone = cellToZone[faceNeighbour[faceI]];
2881 if (ownZone == neiZone)
2883 faceLabels.append(faceI);
2889 const polyPatch& pp =
patches[patchI];
2893 label faceI = pp.start()+i;
2894 if (faceToZone[faceI] != -1)
2897 label ownZone = cellToZone[faceOwner[faceI]];
2898 label neiZone = neiCellZone[faceI-mesh_.nInternalFaces()];
2899 if (ownZone == neiZone)
2901 faceLabels.append(faceI);
2906 return faceLabels.shrink();
2910 void Foam::meshRefinement::calcPatchNumMasterFaces
2912 const bitSet& isMasterFace,
2918 nMasterFacesPerEdge.setSize(
patch.nEdges());
2919 nMasterFacesPerEdge = 0;
2923 const label meshFaceI =
patch.addressing()[faceI];
2925 if (isMasterFace.test(meshFaceI))
2930 nMasterFacesPerEdge[fEdges[fEdgeI]]++;
2938 patch.meshEdges(mesh_.edges(), mesh_.pointEdges()),
2939 nMasterFacesPerEdge,
2953 List<patchEdgeFaceRegion> allEdgeInfo(
patch.nEdges());
2954 List<patchEdgeFaceRegion> allFaceInfo(
patch.size());
2959 label nProtected = 0;
2961 forAll(nMasterFacesPerEdge, edgeI)
2963 if (nMasterFacesPerEdge[edgeI] > 2)
2965 allEdgeInfo[edgeI] = -2;
2977 DynamicList<label> changedEdges;
2978 DynamicList<patchEdgeFaceRegion> changedInfo;
2980 const scalar tol = PatchEdgeFaceWave
2984 >::propagationTol();
2988 const globalIndex globalFaces(
patch.size());
2992 label currentZoneI = 0;
2998 for (; faceI < allFaceInfo.size(); faceI++)
3000 if (!allFaceInfo[faceI].valid(dummyTrackData))
3002 globalSeed = globalFaces.toGlobal(faceI);
3007 reduce(globalSeed, minOp<label>());
3014 label procI = globalFaces.whichProcID(globalSeed);
3015 label seedFaceI = globalFaces.toLocal(procI, globalSeed);
3023 patchEdgeFaceRegion& faceInfo = allFaceInfo[seedFaceI];
3027 faceInfo = currentZoneI;
3033 label edgeI = fEdges[fEdgeI];
3035 patchEdgeFaceRegion& edgeInfo = allEdgeInfo[edgeI];
3039 edgeInfo.updateEdge<
int>
3051 changedEdges.append(edgeI);
3052 changedInfo.append(edgeInfo);
3058 if (
returnReduce(changedEdges.size(), sumOp<label>()) == 0)
3084 faceToZone.setSize(
patch.size());
3085 forAll(allFaceInfo, faceI)
3087 if (!allFaceInfo[faceI].valid(dummyTrackData))
3090 <<
"Problem: unvisited face " << faceI
3091 <<
" at " <<
patch.faceCentres()[faceI]
3094 faceToZone[faceI] = allFaceInfo[faceI].region();
3097 return currentZoneI;
3101 void Foam::meshRefinement::consistentOrientation
3103 const bitSet& isMasterFace,
3107 const Map<label>& zoneToOrientation,
3111 const polyBoundaryMesh& bm = mesh_.boundaryMesh();
3114 List<patchFaceOrientation> allEdgeInfo(
patch.nEdges());
3115 List<patchFaceOrientation> allFaceInfo(
patch.size());
3121 label nProtected = 0;
3125 const label meshFaceI =
patch.addressing()[faceI];
3126 const label patchI = bm.whichPatch(meshFaceI);
3131 && bm[patchI].coupled()
3132 && !isMasterFace.test(meshFaceI)
3145 label nProtected = 0;
3147 forAll(nMasterFacesPerEdge, edgeI)
3149 if (nMasterFacesPerEdge[edgeI] > 2)
3156 Info<<
"Protected from visiting "
3158 <<
" non-manifold edges" <<
nl <<
endl;
3163 DynamicList<label> changedEdges;
3164 DynamicList<patchFaceOrientation> changedInfo;
3166 const scalar tol = PatchEdgeFaceWave
3169 patchFaceOrientation
3170 >::propagationTol();
3174 globalIndex globalFaces(
patch.size());
3180 forAll(allFaceInfo, faceI)
3184 globalSeed = globalFaces.toGlobal(faceI);
3189 reduce(globalSeed, minOp<label>());
3196 label procI = globalFaces.whichProcID(globalSeed);
3197 label seedFaceI = globalFaces.toLocal(procI, globalSeed);
3206 patchFaceOrientation& faceInfo = allFaceInfo[seedFaceI];
3211 if (zoneToOrientation[faceToZone[seedFaceI]] < 0)
3220 label edgeI = fEdges[fEdgeI];
3222 patchFaceOrientation& edgeInfo = allEdgeInfo[edgeI];
3226 edgeInfo.updateEdge<
int>
3238 changedEdges.append(edgeI);
3239 changedInfo.append(edgeInfo);
3245 if (
returnReduce(changedEdges.size(), sumOp<label>()) == 0)
3256 patchFaceOrientation
3274 mesh_.nBoundaryFaces(),
3280 const label meshFaceI =
patch.addressing()[i];
3281 if (!mesh_.isInternalFace(meshFaceI))
3283 neiStatus[meshFaceI-mesh_.nInternalFaces()] =
3284 allFaceInfo[i].flipStatus();
3291 const label meshFaceI =
patch.addressing()[i];
3292 const label patchI = bm.whichPatch(meshFaceI);
3297 && bm[patchI].coupled()
3298 && !isMasterFace.test(meshFaceI)
3302 label bFaceI = meshFaceI-mesh_.nInternalFaces();
3315 <<
"Incorrect status for face " << meshFaceI
3325 meshFlipMap.setSize(mesh_.nFaces());
3326 meshFlipMap =
false;
3328 forAll(allFaceInfo, faceI)
3334 meshFlipMap.unset(meshFaceI);
3338 meshFlipMap.set(meshFaceI);
3343 <<
"Problem : unvisited face " << faceI
3344 <<
" centre:" << mesh_.faceCentres()[meshFaceI]
3351 void Foam::meshRefinement::zonify
3354 const bitSet& isMasterFace,
3358 const bitSet& meshFlipMap,
3359 polyTopoChange& meshMod
3362 const labelList& faceOwner = mesh_.faceOwner();
3363 const labelList& faceNeighbour = mesh_.faceNeighbour();
3365 for (
label faceI = 0; faceI < mesh_.nInternalFaces(); faceI++)
3367 label faceZoneI = faceToZone[faceI];
3369 if (faceZoneI != -1)
3375 label ownZone = cellToZone[faceOwner[faceI]];
3376 label neiZone = cellToZone[faceNeighbour[faceI]];
3380 if (ownZone == neiZone)
3383 flip = meshFlipMap.test(faceI);
3390 || (neiZone != -1 && ownZone > neiZone)
3398 mesh_.faces()[faceI],
3401 faceNeighbour[faceI],
3413 const polyBoundaryMesh&
patches = mesh_.boundaryMesh();
3418 const polyPatch& pp =
patches[patchI];
3420 label faceI = pp.start();
3424 label faceZoneI = faceToZone[faceI];
3426 if (faceZoneI != -1)
3428 label ownZone = cellToZone[faceOwner[faceI]];
3429 label neiZone = neiCellZone[faceI-mesh_.nInternalFaces()];
3433 if (ownZone == neiZone)
3436 flip = meshFlipMap.test(faceI);
3443 || (neiZone != -1 && ownZone > neiZone)
3451 mesh_.faces()[faceI],
3471 forAll(cellToZone, cellI)
3473 label zoneI = cellToZone[cellI];
3491 void Foam::meshRefinement::allocateInterRegionFaceZone
3493 const label ownZone,
3494 const label neiZone,
3496 LabelPairMap<word>& zoneIDsToFaceZone
3501 if (ownZone != neiZone)
3508 || (neiZone != -1 && ownZone > neiZone)
3518 if (!zoneIDsToFaceZone.found(key))
3521 const word ownZoneName =
3524 ? cellZones[ownZone].name()
3527 const word neiZoneName =
3530 ? cellZones[neiZone].name()
3535 Pair<word> wordKey(ownZoneName, neiZoneName);
3541 word fzName = wordKey.first() +
"_to_" + wordKey.second();
3543 zoneIDsToFaceZone.insert(key, fzName);
3544 zonesToFaceZone.insert(wordKey, fzName);
3554 const bool doHandleSnapProblems,
3556 const bool useTopologicalSnapDetection,
3557 const bool removeEdgeConnectedCells,
3559 const label nErodeCellZones,
3577 Info<<
"Introducing baffles for "
3579 <<
" faces that are intersected by the surface." <<
nl <<
endl;
3582 labelList neiLevel(mesh_.nBoundaryFaces());
3584 calcNeighbourData(neiLevel, neiCc);
3590 globalToMasterPatch,
3602 createBaffles(ownPatch, neiPatch);
3610 Info<<
"Created baffles in = "
3613 printMeshInfo(
debug,
"After introducing baffles");
3625 Pout<<
"Dumped debug data in = "
3635 if (doHandleSnapProblems)
3640 useTopologicalSnapDetection,
3641 removeEdgeConnectedCells,
3645 globalToMasterPatch,
3653 neiLevel.setSize(mesh_.nBoundaryFaces());
3654 neiCc.setSize(mesh_.nBoundaryFaces());
3655 calcNeighbourData(neiLevel, neiCc);
3661 globalToMasterPatch,
3673 createBaffles(ownPatch, neiPatch);
3688 <<
"Remove unreachable sections of mesh" <<
nl
3689 <<
"-----------------------------------" <<
nl
3699 globalToMasterPatch,
3702 locationsOutsideMesh,
3711 Info<<
"Split mesh in = "
3714 printMeshInfo(
debug,
"After subsetting");
3727 Pout<<
"Dumped debug data in = "
3736 const bool useTopologicalSnapDetection,
3737 const bool removeEdgeConnectedCells,
3739 const scalar planarAngle,
3753 <<
"Merge free-standing baffles" <<
nl
3754 <<
"---------------------------" <<
nl
3768 label nCouples = couples.size();
3771 Info<<
"Detected free-standing baffles : " << nCouples <<
endl;
3785 useTopologicalSnapDetection,
3786 removeEdgeConnectedCells,
3790 globalToMasterPatch,
3798 <<
"Remove unreachable sections of mesh" <<
nl
3799 <<
"-----------------------------------" <<
nl
3809 globalToMasterPatch,
3812 locationsOutsideMesh,
3823 Info<<
"Merged free-standing baffles in = "
3830 const label nBufferLayers,
3831 const label nErodeCellZones,
3845 labelList neiLevel(mesh_.nBoundaryFaces());
3847 calcNeighbourData(neiLevel, neiCc);
3854 globalToMasterPatch,
3867 boolList blockedFace(mesh_.nFaces(),
false);
3871 if (ownPatch[faceI] != -1 || neiPatch[faceI] != -1)
3873 blockedFace[faceI] =
true;
3887 locationsOutsideMesh,
3897 globalToMasterPatch,
3907 const label nBufferLayers,
3922 const labelList& faceOwner = mesh_.faceOwner();
3923 const labelList& faceNeighbour = mesh_.faceNeighbour();
3926 label defaultPatch = 0;
3927 if (globalToMasterPatch.size())
3929 defaultPatch = globalToMasterPatch[0];
3932 for (
label i = 0; i < nBufferLayers; i++)
3936 labelList pointBaffle(mesh_.nPoints(), -1);
3938 forAll(faceNeighbour, faceI)
3940 const face&
f = mesh_.faces()[faceI];
3942 label ownRegion = cellRegion[faceOwner[faceI]];
3943 label neiRegion = cellRegion[faceNeighbour[faceI]];
3945 if (ownRegion == -1 && neiRegion != -1)
3952 pointBaffle[
f[fp]] =
max(defaultPatch, ownPatch[faceI]);
3955 else if (ownRegion != -1 && neiRegion == -1)
3957 label newPatchI = neiPatch[faceI];
3958 if (newPatchI == -1)
3960 newPatchI =
max(defaultPatch, ownPatch[faceI]);
3964 pointBaffle[
f[fp]] = newPatchI;
3970 label faceI = mesh_.nInternalFaces();
3971 faceI < mesh_.nFaces();
3975 const face&
f = mesh_.faces()[faceI];
3977 label ownRegion = cellRegion[faceOwner[faceI]];
3979 if (ownRegion == -1)
3983 pointBaffle[
f[fp]] =
max(defaultPatch, ownPatch[faceI]);
4002 forAll(pointFaces, pointI)
4004 if (pointBaffle[pointI] != -1)
4012 if (ownPatch[faceI] == -1)
4014 ownPatch[faceI] = pointBaffle[pointI];
4028 if (ownPatch[faceI] != -1)
4030 label own = faceOwner[faceI];
4032 if (cellRegion[own] == -1)
4036 const cell& ownFaces = mesh_.cells()[own];
4039 if (ownPatch[ownFaces[j]] == -1)
4041 newOwnPatch[ownFaces[j]] = ownPatch[faceI];
4045 if (mesh_.isInternalFace(faceI))
4047 label nei = faceNeighbour[faceI];
4049 if (cellRegion[nei] == -1)
4053 const cell& neiFaces = mesh_.cells()[nei];
4056 if (ownPatch[neiFaces[j]] == -1)
4058 newOwnPatch[neiFaces[j]] = ownPatch[faceI];
4077 DynamicList<label> cellsToRemove(mesh_.nCells());
4078 forAll(cellRegion, cellI)
4080 if (cellRegion[cellI] == -1)
4082 cellsToRemove.append(cellI);
4085 cellsToRemove.shrink();
4087 label nCellsToKeep = mesh_.nCells() - cellsToRemove.size();
4088 reduce(nCellsToKeep, sumOp<label>());
4090 Info<<
"Keeping all cells containing inside points" <<
endl
4091 <<
"Selected for keeping : " << nCellsToKeep <<
" cells." <<
endl;
4095 removeCells cellRemover(mesh_);
4098 labelList exposedFaces(cellRemover.getExposedFaces(cellsToRemove));
4099 labelList exposedPatches(exposedFaces.size());
4103 label faceI = exposedFaces[i];
4105 if (ownPatch[faceI] != -1)
4107 exposedPatches[i] = ownPatch[faceI];
4112 <<
"For exposed face " << faceI
4113 <<
" fc:" << mesh_.faceCentres()[faceI]
4114 <<
" found no patch." <<
endl
4115 <<
" Taking patch " << defaultPatch
4116 <<
" instead." <<
endl;
4117 exposedPatches[i] = defaultPatch;
4121 return doRemoveCells
4133 const label nBufferLayers,
4134 const label nErodeCellZones,
4145 labelList neiLevel(mesh_.nBoundaryFaces());
4147 calcNeighbourData(neiLevel, neiCc);
4154 globalToMasterPatch,
4170 limitShells_.findLevel
4172 mesh_.cellCentres(),
4176 forAll(levelShell, celli)
4178 if (levelShell[celli] != -1)
4181 cellRegion[celli] = -1;
4188 globalToMasterPatch,
4197 const_cast<Time&
>(mesh_.time())++;
4198 Pout<<
"Writing mesh after removing limitShells"
4229 Info<<
"dupNonManifoldPoints : Found : " << nNonManifPoints
4230 <<
" non-manifold points (out of "
4231 << mesh_.globalData().nTotalPoints()
4237 if (nNonManifPoints)
4246 mapPtr = meshMod.
changeMesh(mesh_,
false,
true);
4250 mesh_.updateMesh(map);
4289 label nPointPairs = 0;
4290 forAll(pointToDuplicate, pointI)
4292 label otherPointI = pointToDuplicate[pointI];
4293 if (otherPointI != -1)
4304 forAll(pointToDuplicate, pointI)
4306 label otherPointI = pointToDuplicate[pointI];
4307 if (otherPointI != -1)
4310 pointToMaster.insert(pointI, otherPointI);
4321 mapPtr = meshMod.
changeMesh(mesh_,
false,
true);
4325 mesh_.updateMesh(map);
4372 internalOrBaffleFaceZones = getZones(fzTypes);
4382 forAll(boundaryFaceZones, j)
4384 const faceZone& fZone = mesh_.faceZones()[boundaryFaceZones[j]];
4387 const face&
f = mesh_.faces()[fZone[i]];
4390 pointStatus[
f[fp]] =
max(pointStatus[
f[fp]], 1u);
4394 forAll(internalOrBaffleFaceZones, j)
4396 const faceZone& fZone = mesh_.faceZones()[internalOrBaffleFaceZones[j]];
4399 const face&
f = mesh_.faces()[fZone[i]];
4402 pointStatus[
f[fp]] =
max(pointStatus[
f[fp]], 2u);
4417 forAll(pointStatus, pointI)
4419 if (pointStatus[pointI] == 1u)
4426 Info<<
"Duplicating " << globalNPoints <<
" points on"
4427 <<
" faceZones of type "
4437 forAll(pointStatus, pointI)
4439 if (pointStatus[pointI] == 1u)
4441 candidatePoints[
n++] = pointI;
4454 const bool allowFreeStandingZoneFaces,
4455 const label nErodeCellZones,
4461 if (locationsInMesh.size() != zonesInMesh.size())
4471 labelList neiLevel(mesh_.nBoundaryFaces());
4473 calcNeighbourData(neiLevel, neiCc);
4482 if (namedSurfaces.size())
4484 Info<<
"Setting cellZones according to named surfaces:" <<
endl;
4487 label surfI = namedSurfaces[i];
4489 Info<<
"Surface : " << surfaces_.names()[surfI] <<
nl
4490 <<
" faceZone : " << surfZones[surfI].faceZoneName() <<
nl
4491 <<
" cellZone : " << surfZones[surfI].cellZoneName() <<
endl;
4531 allowFreeStandingZoneFaces,
4550 labelList faceToZone(mesh_.nFaces(), -1);
4552 forAll(namedSurfaceIndex, faceI)
4554 label surfI = namedSurfaceIndex[faceI];
4557 faceToZone[faceI] = surfaceToFaceZone[surfI];
4571 for (
label faceI = 0; faceI < mesh_.nInternalFaces(); faceI++)
4573 if (faceToZone[faceI] == -1)
4578 allocateInterRegionFaceZone
4580 cellToZone[mesh_.faceOwner()[faceI]],
4581 cellToZone[mesh_.faceNeighbour()[faceI]],
4591 forAll(neiCellZone, bFaceI)
4593 label faceI = bFaceI + mesh_.nInternalFaces();
4594 if (faceToZone[faceI] == -1)
4596 allocateInterRegionFaceZone
4598 cellToZone[mesh_.faceOwner()[faceI]],
4599 neiCellZone[bFaceI],
4618 Info<<
"Setting faceZones according to neighbouring cellZones:"
4624 zonesToFaceZone.
size()
4635 const word& fzName = zonesToFaceZone[cz];
4638 << cz[0] <<
' ' << cz[1] <<
nl
4639 <<
" faceZone : " << fzName <<
endl;
4649 label cz0 = cellZones.findZoneID(cz[0]);
4650 label cz1 = cellZones.findZoneID(cz[1]);
4660 for (
label faceI = 0; faceI < mesh_.nInternalFaces(); faceI++)
4662 if (faceToZone[faceI] == -1)
4668 label ownZone = cellToZone[mesh_.faceOwner()[faceI]];
4669 label neiZone = cellToZone[mesh_.faceNeighbour()[faceI]];
4670 if (ownZone != neiZone)
4675 || (neiZone != -1 && ownZone > neiZone)
4682 faceToZone[faceI] = fZoneLookup[key];
4686 forAll(neiCellZone, bFaceI)
4688 label faceI = bFaceI + mesh_.nInternalFaces();
4689 if (faceToZone[faceI] == -1)
4691 label ownZone = cellToZone[mesh_.faceOwner()[faceI]];
4692 label neiZone = neiCellZone[bFaceI];
4693 if (ownZone != neiZone)
4698 || (neiZone != -1 && ownZone > neiZone)
4705 faceToZone[faceI] = fZoneLookup[key];
4724 label bFaceI = pp.
start()-mesh_.nInternalFaces();
4727 neiCellZone[bFaceI++] = -1;
4748 bitSet meshFlipMap(mesh_.nFaces(),
false);
4756 freeStandingBaffleFaces
4767 if (nFreeStanding > 0)
4769 Info<<
"Detected " << nFreeStanding <<
" free-standing zone faces"
4774 OBJstream str(mesh_.time().path()/
"freeStanding.obj");
4781 calcPatchNumMasterFaces(isMasterFace,
patch, nMasterFacesPerEdge);
4789 nMasterFacesPerEdge,
4796 nPosOrientation.insert(zoneI, 0);
4802 consistentOrientation
4806 nMasterFacesPerEdge,
4807 faceToConnectedZone,
4819 if (isMasterFace.
test(meshFaceI))
4824 posOrientation.
test(meshFaceI)
4825 == meshFlipMap.test(meshFaceI)
4831 nPosOrientation.find(faceToConnectedZone[faceI])() +=
n;
4838 Info<<
"Split " << nFreeStanding <<
" free-standing zone faces"
4839 <<
" into " <<
nZones <<
" disconnected regions with size"
4840 <<
" (negative denotes wrong orientation) :"
4845 Info<<
" " << zoneI <<
"\t" << nPosOrientation[zoneI]
4853 consistentOrientation
4857 nMasterFacesPerEdge,
4858 faceToConnectedZone,
4887 mesh_.updateMesh(map());
4890 if (map().hasMotionPoints())
4892 mesh_.movePoints(map().preMotionPoints());
4904 if (mesh_.cellZones().size() > 0)
4907 forAll(mesh_.cellZones(), zoneI)
4909 const cellZone& cz = mesh_.cellZones()[zoneI];
4916 if (mesh_.faceZones().size() > 0)
4919 forAll(mesh_.faceZones(), zoneI)
4921 const faceZone& fz = mesh_.faceZones()[zoneI];