59 polyTopoChange& meshMod
62 const face& f = mesh_.
faces()[facei];
64 bool zoneFlip =
false;
68 const faceZone& fZone = mesh_.
faceZones()[zoneID];
69 zoneFlip = fZone.flipMap()[fZone.whichFace(facei)];
96 <<
"No neighbour patch for internal face " << facei
101 bool reverseFlip =
false;
104 reverseFlip = !zoneFlip;
107 dupFacei = meshMod.setAction
128 void Foam::meshRefinement::getBafflePatches
137 autoPtr<OFstream> str;
139 if (debug&OBJINTERSECTIONS)
150 Pout<<
"getBafflePatches : Writing surface intersections to file " 162 ownPatch.setSize(mesh_.
nFaces());
164 nbrPatch.setSize(mesh_.
nFaces());
181 label facei = testFaces[i];
187 start[i] = cellCentres[own];
192 start[i] = cellCentres[own];
208 List<pointIndexHit> hit1;
211 List<pointIndexHit> hit2;
230 label facei = testFaces[i];
232 if (hit1[i].hit() && hit2[i].hit())
244 str()<<
"l " << vertI-3 <<
' ' << vertI-2 <<
nl;
245 str()<<
"l " << vertI-2 <<
' ' << vertI-1 <<
nl;
246 str()<<
"l " << vertI-1 <<
' ' << vertI <<
nl;
250 ownPatch[facei] = globalToMasterPatch
254 nbrPatch[facei] = globalToMasterPatch
259 if (ownPatch[facei] == -1 || nbrPatch[facei] == -1)
282 const bool allowBoundary,
287 Map<labelPair> bafflePatch(mesh_.
nFaces()/1000);
289 const PtrList<surfaceZonesInfo>& surfZones = surfaces_.
surfZones();
294 const word& faceZoneName = surfZones[surfI].faceZoneName();
296 if (faceZoneName.size())
299 label zoneI = fZones.findZoneID(faceZoneName);
301 const faceZone& fZone = fZones[zoneI];
307 globalToMasterPatch[globalRegionI],
308 globalToSlavePatch[globalRegionI]
311 Info<<
"For zone " << fZone.name() <<
" found patches " 318 label facei = fZone[i];
323 if (fZone.flipMap()[i])
328 if (!bafflePatch.insert(facei, patches))
333 <<
" in zone " << fZone.name()
334 <<
" is in multiple zones!" 359 <<
" ownPatch:" << ownPatch.
size()
360 <<
" nbrPatch:" << nbrPatch.
size()
361 <<
". Should be number of faces:" << mesh_.
nFaces()
372 forAll(syncedOwnPatch, facei)
376 (ownPatch[facei] == -1 && syncedOwnPatch[facei] != -1)
377 || (nbrPatch[facei] == -1 && syncedNeiPatch[facei] != -1)
381 <<
"Non synchronised at face:" << facei
384 <<
"ownPatch:" << ownPatch[facei]
385 <<
" syncedOwnPatch:" << syncedOwnPatch[facei]
386 <<
" nbrPatch:" << nbrPatch[facei]
387 <<
" syncedNeiPatch:" << syncedNeiPatch[facei]
400 if (ownPatch[facei] != -1)
424 if (map().hasMotionPoints())
440 faceSet baffledFacesSet(mesh_,
"baffledFacesSet", 2*nBaffles);
442 const labelList& reverseFaceMap = map().reverseFaceMap();
446 forAll(ownPatch, oldFacei)
448 label facei = reverseFaceMap[oldFacei];
450 if (ownPatch[oldFacei] != -1 && facei >= 0)
456 baffledFacesSet.
insert(ownFaces[i]);
463 label oldFacei = faceMap[facei];
465 if (oldFacei >= 0 && reverseFaceMap[oldFacei] != facei)
471 baffledFacesSet.
insert(ownFaces[i]);
475 baffledFacesSet.
sync(mesh_);
493 if (isA<processorPolyPatch>(pp))
503 <<
"face:" << facei <<
" on patch " << pp.
name()
504 <<
" is in zone " << fZones[zoneI].
name()
528 if (zonedSurfaces.
size())
531 Info<<
"Converting zoned faces into baffles ..." <<
endl;
553 ownPatch[iter.key()] = iter().
first();
554 nbrPatch[iter.key()] = iter().second();
568 const labelList& reverseFaceMap = map().reverseFaceMap();
572 label oldFacei = faceMap[facei];
580 if (iter != faceToPatch.
end())
582 label masterFacei = reverseFaceMap[oldFacei];
583 if (facei != masterFacei)
585 baffles[baffleI++] =
labelPair(masterFacei, facei);
590 if (baffleI != faceToPatch.
size())
593 <<
"Had " << faceToPatch.
size() <<
" patches to create " 594 <<
" but encountered " << baffleI
595 <<
" slave faces originating from patcheable faces." 602 Pout<<
"Writing zone-baffled mesh to time " <<
timeName()
612 Info<<
"Created " << nZoneFaces <<
" baffles in = " 622 const scalar planarAngle
649 const label baffleValue = 1000000;
672 nBafflesPerEdge[fEdges[fEdgeI]]++;
694 nBafflesPerEdge[fEdges0[fEdgeI]] += baffleValue;
699 label f1 = couples[i].second();
703 nBafflesPerEdge[fEdges1[fEdgeI]] += baffleValue;
739 label edgeI = fEdges[fEdgeI];
741 if (nBafflesPerEdge[edgeI] == 2*baffleValue+2*1)
743 filteredCouples[filterI++] = couple;
749 filteredCouples.
setSize(filterI);
754 Info<<
"freeStandingBaffles : detected " 756 <<
" free-standing baffles out of " 771 forAll(filteredCouples, i)
773 const labelPair& couple = filteredCouples[i];
824 forAll(filteredCouples, i)
826 const labelPair& couple = filteredCouples[i];
833 surface1[i] != surface2[i]
834 || hit1[i].index() != hit2[i].index()
846 if ((normal1[i]&normal2[i]) > planarAngleCos)
850 scalar magN =
mag(n);
853 filteredCouples[filterI++] = couple;
857 else if (hit1[i].hit() || hit2[i].hit())
863 filteredCouples.
setSize(filterI);
865 Info<<
"freeStandingBaffles : detected " 867 <<
" planar (within " << planarAngle
868 <<
" degrees) free-standing baffles out of " 873 return filteredCouples;
892 label face1 = couples[i].second();
896 label own0 = faceOwner[face0];
897 label own1 = faceOwner[face1];
899 if (face1 < 0 || own0 < own1)
903 bool zoneFlip =
false;
907 const faceZone& fZone = faceZones[zoneID];
911 label nei = (face1 < 0 ? -1 : own1);
934 bool zoneFlip =
false;
938 const faceZone& fZone = faceZones[zoneID];
970 if (map().hasMotionPoints())
991 label newFace0 = map().reverseFaceMap()[couples[i].
first()];
994 newExposedFaces[newI++] = newFace0;
997 label newFace1 = map().reverseFaceMap()[couples[i].second()];
1000 newExposedFaces[newI++] = newFace1;
1003 newExposedFaces.setSize(newI);
1011 void Foam::meshRefinement::findCellZoneGeometric
1029 closedNamedSurfaces,
1034 forAll(insideSurfaces, celli)
1036 if (cellToZone[celli] == -2)
1038 label surfI = insideSurfaces[celli];
1042 cellToZone[celli] = surfaceToCellZone[surfI];
1055 label nCandidates = 0;
1056 forAll(namedSurfaceIndex, facei)
1058 label surfI = namedSurfaceIndex[facei];
1076 forAll(namedSurfaceIndex, facei)
1078 label surfI = namedSurfaceIndex[facei];
1082 label own = faceOwner[facei];
1083 const point& ownCc = cellCentres[own];
1087 label nei = faceNeighbour[facei];
1088 const point& neiCc = cellCentres[nei];
1090 const vector d = 1
e-4*(neiCc - ownCc);
1091 candidatePoints[nCandidates++] = ownCc-d;
1092 candidatePoints[nCandidates++] = neiCc+d;
1100 const vector d = 1
e-4*(neiFc - ownCc);
1101 candidatePoints[nCandidates++] = ownCc-d;
1111 closedNamedSurfaces,
1120 forAll(namedSurfaceIndex, facei)
1122 label surfI = namedSurfaceIndex[facei];
1126 label own = faceOwner[facei];
1130 label ownSurfI = insideSurfaces[nCandidates++];
1133 cellToZone[own] = surfaceToCellZone[ownSurfI];
1136 label neiSurfI = insideSurfaces[nCandidates++];
1139 label nei = faceNeighbour[facei];
1141 cellToZone[nei] = surfaceToCellZone[neiSurfI];
1146 label ownSurfI = insideSurfaces[nCandidates++];
1149 cellToZone[own] = surfaceToCellZone[ownSurfI];
1165 if (namedSurfaceIndex[facei] == -1 && (ownZone != neiZone))
1171 max(ownZone, neiZone)
1207 if (namedSurfaceIndex[facei] == -1 && (ownZone != neiZone))
1213 max(ownZone, neiZone)
1225 void Foam::meshRefinement::findCellZoneInsideWalk
1238 forAll(namedSurfaceIndex, facei)
1240 if (namedSurfaceIndex[facei] == -1)
1242 blockedFace[facei] =
false;
1246 blockedFace[facei] =
true;
1253 blockedFace.clear();
1262 forAll(locationSurfaces, i)
1264 label surfI = locationSurfaces[i];
1266 const point& insidePoint = surfZones[surfI].zoneInsidePoint();
1268 Info<<
"For surface " << surfaces_.
names()[surfI]
1269 <<
" finding inside point " << insidePoint
1277 mergeDistance_*
vector(1,1,1),
1281 Info<<
"For surface " << surfaces_.
names()[surfI]
1282 <<
" found point " << insidePoint
1283 <<
" in global region " << keepRegionI
1284 <<
" out of " << cellRegion.
nRegions() <<
" regions." <<
endl;
1286 if (keepRegionI == -1)
1289 <<
"Point " << insidePoint
1290 <<
" is not inside the mesh." <<
nl 1291 <<
"Bounding box of the mesh:" << mesh_.
bounds()
1296 forAll(cellRegion, celli)
1298 if (cellRegion[celli] == keepRegionI)
1300 if (cellToZone[celli] == -2)
1302 cellToZone[celli] = surfaceToCellZone[surfI];
1304 else if (cellToZone[celli] != surfaceToCellZone[surfI])
1309 <<
" is inside surface " << surfaces_.
names()[surfI]
1310 <<
" but already marked as being in zone " 1311 << cellToZone[celli] << endl
1312 <<
"This can happen if your surfaces are not" 1313 <<
" (sufficiently) closed." 1322 bool Foam::meshRefinement::calcRegionToZone
1324 const label surfZoneI,
1325 const label ownRegion,
1326 const label neiRegion,
1331 bool changed =
false;
1334 if (ownRegion != neiRegion)
1341 if (regionToCellZone[ownRegion] == -2)
1343 if (regionToCellZone[neiRegion] == surfZoneI)
1347 regionToCellZone[ownRegion] = -1;
1350 else if (regionToCellZone[neiRegion] != -2)
1354 regionToCellZone[ownRegion] = surfZoneI;
1358 else if (regionToCellZone[neiRegion] == -2)
1360 if (regionToCellZone[ownRegion] == surfZoneI)
1364 regionToCellZone[neiRegion] = -1;
1367 else if (regionToCellZone[ownRegion] != -2)
1371 regionToCellZone[neiRegion] = surfZoneI;
1380 void Foam::meshRefinement::findCellZoneTopo
1382 const point& keepPoint,
1396 forAll(namedSurfaceIndex, facei)
1398 if (namedSurfaceIndex[facei] == -1)
1400 blockedFace[facei] =
false;
1404 blockedFace[facei] =
true;
1411 blockedFace.clear();
1422 forAll(cellToZone, celli)
1424 if (cellToZone[celli] != -2)
1426 regionToCellZone[cellRegion[celli]] = cellToZone[celli];
1436 mergeDistance_*
vector(1,1,1),
1440 Info<<
"Found point " << keepPoint
1441 <<
" in global region " << keepRegionI
1442 <<
" out of " << cellRegion.
nRegions() <<
" regions." <<
endl;
1444 if (keepRegionI == -1)
1447 <<
"Point " << keepPoint
1448 <<
" is not inside the mesh." <<
nl 1449 <<
"Bounding box of the mesh:" << mesh_.
bounds()
1454 if (regionToCellZone[keepRegionI] == -2)
1456 regionToCellZone[keepRegionI] = -1;
1475 bool changed =
false;
1481 label surfI = namedSurfaceIndex[facei];
1488 bool changedCell = calcRegionToZone
1490 surfaceToCellZone[surfI],
1496 changed = changed | changedCell;
1534 label surfI = namedSurfaceIndex[facei];
1539 bool changedCell = calcRegionToZone
1541 surfaceToCellZone[surfI],
1547 changed = changed | changedCell;
1560 forAll(regionToCellZone, regionI)
1562 label zoneI = regionToCellZone[regionI];
1567 <<
"For region " << regionI <<
" haven't set cell zone." 1574 forAll(regionToCellZone, regionI)
1576 Pout<<
"Region " << regionI
1577 <<
" becomes cellZone:" << regionToCellZone[regionI]
1583 forAll(cellToZone, celli)
1585 cellToZone[celli] = regionToCellZone[cellRegion[celli]];
1590 void Foam::meshRefinement::makeConsistentFaceIndex
1601 label ownZone = cellToZone[faceOwner[facei]];
1602 label neiZone = cellToZone[faceNeighbour[facei]];
1604 if (ownZone == neiZone && namedSurfaceIndex[facei] != -1)
1606 namedSurfaceIndex[facei] = -1;
1608 else if (ownZone != neiZone && namedSurfaceIndex[facei] == -1)
1611 <<
"Different cell zones on either side of face " << facei
1613 <<
" but face not marked with a surface." 1649 label ownZone = cellToZone[faceOwner[facei]];
1652 if (ownZone == neiZone && namedSurfaceIndex[facei] != -1)
1654 namedSurfaceIndex[facei] = -1;
1656 else if (ownZone != neiZone && namedSurfaceIndex[facei] == -1)
1659 <<
"Different cell zones on either side of face " 1661 <<
" but face not marked with a surface." 1672 namedSurfaceIndex[facei] = -1;
1679 void Foam::meshRefinement::handleSnapProblems
1682 const bool useTopologicalSnapDetection,
1683 const bool removeEdgeConnectedCells,
1692 <<
"Introducing baffles to block off problem cells" <<
nl 1693 <<
"----------------------------------------------" <<
nl 1697 if (useTopologicalSnapDetection)
1699 facePatch = markFacesOnProblemCells
1702 removeEdgeConnectedCells,
1709 facePatch = markFacesOnProblemCellsGeometric(snapParams, motionDict);
1711 Info<<
"Analyzed problem cells in = " 1716 faceSet problemFaces(mesh_,
"problemFaces", mesh_.
nFaces()/100);
1720 if (facePatch[facei] != -1)
1722 problemFaces.insert(facei);
1725 problemFaces.instance() =
timeName();
1726 Pout<<
"Dumping " << problemFaces.size()
1727 <<
" problem faces to " << problemFaces.objectPath() <<
endl;
1728 problemFaces.
write();
1731 Info<<
"Introducing baffles to delete problem cells." <<
nl <<
endl;
1746 Info<<
"Created baffles in = " 1753 Pout<<
"Writing extra baffled mesh to time " 1759 runTime.
path()/
"extraBaffles" 1761 Pout<<
"Dumped debug data in = " 1797 if (faceToZone[facei] != -1)
1800 label ownZone = cellToZone[faceOwner[facei]];
1801 label neiZone = cellToZone[faceNeighbour[facei]];
1802 if (ownZone == neiZone)
1804 faceLabels.
append(facei);
1815 if (faceToZone[facei] != -1)
1818 label ownZone = cellToZone[faceOwner[facei]];
1820 if (ownZone == neiZone)
1822 faceLabels.
append(facei);
1827 return faceLabels.shrink();
1831 void Foam::meshRefinement::calcPatchNumMasterFaces
1840 nMasterFacesPerEdge = 0;
1842 forAll(patch.addressing(), facei)
1844 const label meshFacei = patch.addressing()[facei];
1846 if (isMasterFace[meshFacei])
1851 nMasterFacesPerEdge[fEdges[fEdgeI]]++;
1860 nMasterFacesPerEdge,
1880 label nProtected = 0;
1882 forAll(nMasterFacesPerEdge, edgeI)
1884 if (nMasterFacesPerEdge[edgeI] > 2)
1886 allEdgeInfo[edgeI] = -2;
1905 >::propagationTol();
1913 label currentZoneI = 0;
1919 for (; facei < allFaceInfo.size(); facei++)
1921 if (!allFaceInfo[facei].valid(dummyTrackData))
1923 globalSeed = globalFaces.toGlobal(facei);
1935 label proci = globalFaces.whichProcID(globalSeed);
1936 label seedFacei = globalFaces.toLocal(proci, globalSeed);
1948 faceInfo = currentZoneI;
1954 label edgeI = fEdges[fEdgeI];
1972 changedEdges.
append(edgeI);
1973 changedInfo.
append(edgeInfo);
2005 faceToZone.
setSize(patch.size());
2006 forAll(allFaceInfo, facei)
2008 if (!allFaceInfo[facei].valid(dummyTrackData))
2011 <<
"Problem: unvisited face " << facei
2015 faceToZone[facei] = allFaceInfo[facei].region();
2018 return currentZoneI;
2022 void Foam::meshRefinement::consistentOrientation
2042 label nProtected = 0;
2044 forAll(patch.addressing(), facei)
2046 const label meshFacei = patch.addressing()[facei];
2052 && bm[patchi].coupled()
2053 && !isMasterFace[meshFacei]
2066 label nProtected = 0;
2068 forAll(nMasterFacesPerEdge, edgeI)
2070 if (nMasterFacesPerEdge[edgeI] > 2)
2077 Info<<
"Protected from visiting " 2079 <<
" non-manifold edges" <<
nl <<
endl;
2091 >::propagationTol();
2101 forAll(allFaceInfo, facei)
2105 globalSeed = globalFaces.toGlobal(facei);
2117 label proci = globalFaces.whichProcID(globalSeed);
2118 label seedFacei = globalFaces.toLocal(proci, globalSeed);
2132 if (zoneToOrientation[faceToZone[seedFacei]] < 0)
2141 label edgeI = fEdges[fEdgeI];
2159 changedEdges.
append(edgeI);
2160 changedInfo.
append(edgeInfo);
2199 forAll(patch.addressing(), i)
2201 const label meshFacei = patch.addressing()[i];
2205 allFaceInfo[i].flipStatus();
2210 forAll(patch.addressing(), i)
2212 const label meshFacei = patch.addressing()[i];
2218 && bm[patchi].coupled()
2219 && !isMasterFace[meshFacei]
2236 <<
"Incorrect status for face " << meshFacei
2247 meshFlipMap =
false;
2249 forAll(allFaceInfo, facei)
2251 label meshFacei = patch.addressing()[facei];
2255 meshFlipMap[meshFacei] =
false;
2259 meshFlipMap[meshFacei] =
true;
2264 <<
"Problem : unvisited face " << facei
2276 const bool doHandleSnapProblems,
2278 const bool useTopologicalSnapDetection,
2279 const bool removeEdgeConnectedCells,
2281 const bool mergeFreeStanding,
2282 const scalar planarAngle,
2287 const point& keepPoint
2296 Info<<
"Introducing baffles for " 2298 <<
" faces that are intersected by the surface." <<
nl <<
endl;
2303 calcNeighbourData(neiLevel, neiCc);
2308 globalToMasterPatch,
2324 Info<<
"Created baffles in = " 2337 runTime.
path()/
"baffles" 2339 Pout<<
"Dumped debug data in = " 2349 if (doHandleSnapProblems)
2354 useTopologicalSnapDetection,
2355 removeEdgeConnectedCells,
2359 globalToMasterPatch,
2369 <<
"Remove unreachable sections of mesh" <<
nl 2370 <<
"-----------------------------------" <<
nl 2385 Info<<
"Split mesh in = " 2400 Pout<<
"Dumped debug data in = " 2408 if (mergeFreeStanding)
2411 <<
"Merge free-standing baffles" <<
nl 2412 <<
"---------------------------" <<
nl 2429 Info<<
"Detected free-standing baffles : " << nCouples <<
endl;
2443 useTopologicalSnapDetection,
2444 removeEdgeConnectedCells,
2448 globalToMasterPatch,
2458 Info<<
"Merged free-standing baffles in = " 2466 const label nBufferLayers,
2469 const point& keepPoint
2478 calcNeighbourData(neiLevel, neiCc);
2483 globalToMasterPatch,
2496 if (ownPatch[facei] != -1 || nbrPatch[facei] != -1)
2498 blockedFace[facei] =
true;
2505 blockedFace.clear();
2512 mergeDistance_*
vector(1,1,1),
2516 Info<<
"Found point " << keepPoint
2517 <<
" in global region " << keepRegionI
2518 <<
" out of " << cellRegion.
nRegions() <<
" regions." <<
endl;
2520 if (keepRegionI == -1)
2523 <<
"Point " << keepPoint
2524 <<
" is not inside the mesh." <<
nl 2525 <<
"Bounding box of the mesh:" << mesh_.
bounds()
2540 label defaultPatch = 0;
2541 if (globalToMasterPatch.
size())
2543 defaultPatch = globalToMasterPatch[0];
2546 for (
label i = 0; i < nBufferLayers; i++)
2552 forAll(faceNeighbour, facei)
2556 label ownRegion = cellRegion[faceOwner[facei]];
2557 label neiRegion = cellRegion[faceNeighbour[facei]];
2559 if (ownRegion == keepRegionI && neiRegion != keepRegionI)
2566 pointBaffle[f[fp]] =
max(defaultPatch, ownPatch[facei]);
2569 else if (ownRegion != keepRegionI && neiRegion == keepRegionI)
2571 label newPatchi = nbrPatch[facei];
2572 if (newPatchi == -1)
2574 newPatchi =
max(defaultPatch, ownPatch[facei]);
2578 pointBaffle[f[fp]] = newPatchi;
2591 label ownRegion = cellRegion[faceOwner[facei]];
2593 if (ownRegion == keepRegionI)
2597 pointBaffle[f[fp]] =
max(defaultPatch, ownPatch[facei]);
2616 forAll(pointFaces, pointi)
2618 if (pointBaffle[pointi] != -1)
2624 label facei = pFaces[pFacei];
2626 if (ownPatch[facei] == -1)
2628 ownPatch[facei] = pointBaffle[pointi];
2642 if (ownPatch[facei] != -1)
2644 label own = faceOwner[facei];
2646 if (cellRegion[own] != keepRegionI)
2648 cellRegion[own] = keepRegionI;
2650 const cell& ownFaces = mesh_.
cells()[own];
2653 if (ownPatch[ownFaces[j]] == -1)
2655 newOwnPatch[ownFaces[j]] = ownPatch[facei];
2661 label nei = faceNeighbour[facei];
2663 if (cellRegion[nei] != keepRegionI)
2665 cellRegion[nei] = keepRegionI;
2667 const cell& neiFaces = mesh_.
cells()[nei];
2670 if (ownPatch[neiFaces[j]] == -1)
2672 newOwnPatch[neiFaces[j]] = ownPatch[facei];
2692 forAll(cellRegion, celli)
2694 if (cellRegion[celli] != keepRegionI)
2696 cellsToRemove.append(celli);
2699 cellsToRemove.shrink();
2701 label nCellsToKeep = mesh_.
nCells() - cellsToRemove.size();
2704 Info<<
"Keeping all cells in region " << keepRegionI
2705 <<
" containing point " << keepPoint <<
endl 2706 <<
"Selected for keeping : " << nCellsToKeep
2707 <<
" cells." <<
endl;
2715 labelList exposedPatches(exposedFaces.size());
2719 label facei = exposedFaces[i];
2721 if (ownPatch[facei] != -1)
2723 exposedPatches[i] = ownPatch[facei];
2728 <<
"For exposed face " << facei
2730 <<
" found no patch." << endl
2731 <<
" Taking patch " << defaultPatch
2732 <<
" instead." <<
endl;
2733 exposedPatches[i] = defaultPatch;
2737 return doRemoveCells
2761 Info<<
"dupNonManifoldPoints : Found : " << nNonManifPoints
2762 <<
" non-manifold points (out of " 2781 if (map().hasMotionPoints())
2813 const point& keepPoint,
2814 const bool allowFreeStandingZoneFaces
2823 label surfI = namedSurfaces[i];
2825 Info<<
"Surface : " << surfaces_.
names()[surfI] <<
nl 2826 <<
" faceZone : " << surfZones[surfI].faceZoneName() <<
nl 2827 <<
" cellZone : " << surfZones[surfI].cellZoneName() <<
endl;
2858 calcNeighbourData(neiLevel, neiCc);
2891 label facei = testFaces[i];
2895 start[i] = cellCentres[faceOwner[facei]];
2896 end[i] = cellCentres[faceNeighbour[facei]];
2900 start[i] = cellCentres[faceOwner[facei]];
2907 const vectorField smallVec(rootSmall*(end-start));
2947 label facei = testFaces[i];
2950 if (surface1[i] != -1)
2957 magSqr(hit2[i].hitPoint())
2958 <
magSqr(hit1[i].hitPoint())
2962 namedSurfaceIndex[facei] = surface2[i];
2963 posOrientation[facei] = ((area&normal2[i]) > 0);
2964 nSurfFaces[surface2[i]]++;
2968 namedSurfaceIndex[facei] = surface1[i];
2969 posOrientation[facei] = ((area&normal1[i]) > 0);
2970 nSurfFaces[surface1[i]]++;
2973 else if (surface2[i] != -1)
2975 namedSurfaceIndex[facei] = surface2[i];
2976 posOrientation[facei] = ((area&normal2[i]) > 0);
2977 nSurfFaces[surface2[i]]++;
2996 forAll(nSurfFaces, surfI)
2999 << surfaces_.
names()[surfI]
3000 <<
" nZoneFaces:" << nSurfFaces[surfI] <<
nl;
3031 if (closedNamedSurfaces.size())
3033 Info<<
"Found " << closedNamedSurfaces.size()
3034 <<
" closed, named surfaces. Assigning cells in/outside" 3035 <<
" these surfaces to the corresponding cellZone." 3038 findCellZoneGeometric
3041 closedNamedSurfaces,
3058 if (locationSurfaces.
size())
3060 Info<<
"Found " << locationSurfaces.
size()
3061 <<
" named surfaces with a provided inside point." 3062 <<
" Assigning cells inside these surfaces" 3063 <<
" to the corresponding cellZone." 3066 findCellZoneInsideWalk
3081 Info<<
"Walking from location-in-mesh " << keepPoint
3082 <<
" to assign cellZones " 3083 <<
"- crossing a faceZone face changes cellZone" <<
nl <<
endl;
3098 if (!allowFreeStandingZoneFaces)
3100 Info<<
"Only keeping zone faces in between different cellZones." 3103 makeConsistentFaceIndex(cellToZone, namedSurfaceIndex);
3113 forAll(namedSurfaceIndex, facei)
3115 label surfI = namedSurfaceIndex[facei];
3118 faceToZone[facei] = surfaceToFaceZone[surfI];
3140 neiCellZone[bFacei++] = -1;
3170 freeStandingBaffleFaces
3181 if (nFreeStanding > 0)
3183 Info<<
"Detected " << nFreeStanding <<
" free-standing zone faces" 3195 calcPatchNumMasterFaces(isMasterFace, patch, nMasterFacesPerEdge);
3200 const label nZones = markPatchZones
3203 nMasterFacesPerEdge,
3208 for (
label zoneI = 0; zoneI < nZones; zoneI++)
3210 nPosOrientation.
insert(zoneI, 0);
3216 consistentOrientation
3220 nMasterFacesPerEdge,
3221 faceToConnectedZone,
3229 forAll(patch.addressing(), facei)
3231 label meshFacei = patch.addressing()[facei];
3233 if (isMasterFace[meshFacei])
3238 bool(posOrientation[meshFacei])
3239 == meshFlipMap[meshFacei]
3245 nPosOrientation.
find(faceToConnectedZone[facei])() += n;
3252 Info<<
"Split " << nFreeStanding <<
" free-standing zone faces" 3253 <<
" into " << nZones <<
" disconnected regions with size" 3254 <<
" (negative denotes wrong orientation) :" 3257 for (
label zoneI = 0; zoneI < nZones; zoneI++)
3259 Info<<
" " << zoneI <<
"\t" << nPosOrientation[zoneI]
3267 consistentOrientation
3271 nMasterFacesPerEdge,
3272 faceToConnectedZone,
3286 label faceZoneI = faceToZone[facei];
3288 if (faceZoneI != -1)
3294 label ownZone = cellToZone[faceOwner[facei]];
3295 label neiZone = cellToZone[faceNeighbour[facei]];
3299 if (ownZone == neiZone)
3302 flip = meshFlipMap[facei];
3309 || (neiZone != -1 && ownZone > neiZone)
3317 mesh_.
faces()[facei],
3320 faceNeighbour[facei],
3341 label faceZoneI = faceToZone[facei];
3343 if (faceZoneI != -1)
3345 label ownZone = cellToZone[faceOwner[facei]];
3350 if (ownZone == neiZone)
3353 flip = meshFlipMap[facei];
3360 || (neiZone != -1 && ownZone > neiZone)
3368 mesh_.
faces()[facei],
3388 forAll(cellToZone, celli)
3390 label zoneI = cellToZone[celli];
3415 if (map().hasMotionPoints())
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
This class separates the mesh into distinct unconnected regions, each of which is then given a label ...
virtual const fileName & name() const
Return the name of the stream.
Class containing data for face removal.
void clearOut()
Clear all geometry and addressing.
void printMeshInfo(const bool, const string &) const
Print some mesh stats.
bool updateEdge(const polyMesh &mesh, const indirectPrimitivePatch &patch, const label edgeI, const label facei, const patchEdgeFaceRegion &faceInfo, const scalar tol, TrackingData &td)
Influence of face on edge.
ZoneMesh< faceZone, polyMesh > faceZoneMesh
A ZoneMesh with the type faceZone.
static void listCombineScatter(const List< commsStruct > &comms, List< T > &Value, const int tag, const label comm)
Scatter data. Reverse of combineGather.
#define forAll(list, i)
Loop across all elements in list.
fileName path() const
Return path.
void checkZoneFaces() const
Debug helper: check faceZones are not on processor patches.
virtual Ostream & write(const char)=0
Write character.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
const word & name() const
Return name.
const word & name() const
Return name.
const labelList & surfaces() const
An STL-conforming const_iterator.
bool updateEdge(const polyMesh &mesh, const indirectPrimitivePatch &patch, const label edgeI, const label facei, const patchFaceOrientation &faceInfo, const scalar tol, TrackingData &td)
Influence of face on edge.
const faceZoneMesh & faceZones() const
Return face zone mesh.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Class describing modification of a face.
A face is a list of labels corresponding to mesh vertices.
static iteratorEnd end()
iteratorEnd set to beyond the end of any HashTable
label countHits() const
Count number of intersections (local)
A list of keyword definitions, which are a keyword followed by any number of values (e...
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
const labelListList & faceEdges() const
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
const Field< PointType > & faceCentres() const
Return face centres for patch.
label nInternalFaces() const
virtual const labelList & faceNeighbour() const
Return face neighbour.
const labelIOList & tetBasePtIs() const
Return the tetBasePtIs.
const labelListList & pointEdges() const
static label findRegion(const polyMesh &, const labelList &cellRegion, const vector &perturbVec, const point &p)
Find region point is in. Uses optional perturbation to re-test.
Wave propagation of information along patch. Every iteration information goes through one layer of fa...
Unit conversion functions.
label nTotalPoints() const
Return total number of points in decomposed mesh. Not.
void size(const label)
Override size to be inconsistent with allocated storage.
const boolList & flipMap() const
Return face flip map.
static int myProcNo(const label communicator=0)
Number of this process (starting from masterNo() = 0)
Given list of cells to remove insert all the topology changes.
Ostream & endl(Ostream &os)
Add newline and flush stream.
autoPtr< mapPolyMesh > createZoneBaffles(const labelList &globalToMasterPatch, const labelList &globalToSlavePatch, List< labelPair > &)
Create baffles for faces straddling zoned surfaces. Return.
labelList intersectedFaces() const
Get faces with intersection.
static writeType writeLevel()
Get/set write level.
labelList identity(const label len)
Create identity map (map[i] == i) of given length.
Transport of orientation for use in PatchEdgeFaceWave.
static labelList addCellZonesToMesh(const PtrList< surfaceZonesInfo > &surfList, const labelList &namedSurfaces, polyMesh &mesh)
void baffleAndSplitMesh(const bool handleSnapProblems, const snapParameters &snapParams, const bool useTopologicalSnapDetection, const bool removeEdgeConnectedCells, const scalarField &perpendicularAngle, const bool mergeFreeStanding, const scalar freeStandingAngle, const dictionary &motionDict, Time &runTime, const labelList &globalToMasterPatch, const labelList &globalToSlavePatch, const point &keepPoint)
Split off unreachable areas of mesh.
const cellList & cells() const
label whichFace(const label globalCellID) const
Helper function to re-direct to zone::localID(...)
Vector< scalar > vector
A scalar version of the templated Vector.
autoPtr< mapPolyMesh > splitMesh(const label nBufferLayers, const labelList &globalToMasterPatch, const labelList &globalToSlavePatch, const point &keepPoint)
Split off (with optional buffer layers) unreachable areas.
const Field< PointType > & localPoints() const
Return pointField of points in patch.
const Time & time() const
Return the top-level database.
virtual Ostream & write(const char)
Write character.
PrimitivePatch< IndirectList< face >, const pointField & > indirectPrimitivePatch
Foam::indirectPrimitivePatch.
bool insert(const Key &key)
Insert a new entry.
T & first()
Return the first element of the list.
Class describing modification of a cell.
static void listCombineGather(const List< commsStruct > &comms, List< T > &Value, const CombineOp &cop, const int tag, const label comm)
const Map< label > & meshPointMap() const
Per point that is to be duplicated the local index.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
label size() const
Return number of elements in table.
scalar degToRad(const scalar deg)
Conversion from degrees to radians.
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
autoPtr< mapPolyMesh > splitMeshRegions(const labelList &globalToMasterPatch, const labelList &globalToSlavePatch, const point &keepPoint)
Split mesh. Keep part containing point.
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.
virtual const pointField & points() const
Return raw points.
static void mapCombineScatter(const List< commsStruct > &comms, Container &Values, const int tag, const label comm)
Scatter data. Reverse of combineGather.
autoPtr< mapPolyMesh > mergeBaffles(const List< labelPair > &)
Merge baffles. Gets pairs of faces.
bool insert(const Key &, const T &newElmt)
Insert a new hashedEntry.
iterator find(const label &)
Find and return an iterator set at the hashedEntry.
const searchableSurfaces & geometry() const
A list of faces which address into the list of points.
Calculates a unique integer (label so might not have enough room - 2G max) for processor + local inde...
vectorField pointField
pointField is a vectorField.
virtual void updateMesh(const mapPolyMesh &mpm)
Update mesh corresponding to the given map.
An ordered pair of two objects of type <T> with first() and second() elements.
virtual bool coupled() const
Return true if this patch is geometrically coupled (i.e. faces and.
dimensionedScalar cos(const dimensionedScalar &ds)
const cellZoneMesh & cellZones() const
Return cell zone mesh.
Simple container to keep together snap specific information.
double cpuTimeIncrement() const
Return CPU time (in seconds) since last call to cpuTimeIncrement()
void append(const T &)
Append an element at the end of the list.
Transport of region for use in PatchEdgeFaceWave.
virtual const labelList & faceOwner() const
Return face owner.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
void flip()
Reverse orientation.
Pair< label > labelPair
Label pair.
const globalMeshData & globalData() const
Return parallel info.
static const label labelMax
List< label > labelList
A List of labels.
const word & name() const
Return name.
static void mapCombineGather(const List< commsStruct > &comms, Container &Values, const CombineOp &cop, const int tag, const label comm)
virtual const faceList & faces() const
Return raw faces.
static labelList getInsidePointNamedSurfaces(const PtrList< surfaceZonesInfo > &surfList)
Get indices of surfaces with a cellZone that have 'insidePoint'.
const PtrList< surfaceZonesInfo > & surfZones() const
const vectorField & cellCentres() const
static labelList getUnnamedSurfaces(const PtrList< surfaceZonesInfo > &surfList)
Get indices of unnamed surfaces (surfaces without faceZoneName)
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
errorManip< error > abort(error &err)
word timeName() const
Replacement for Time::timeName() : return oldInstance (if.
Info<< "Finished reading KIVA file"<< endl;cellShapeList cellShapes(nPoints);labelList cellZoning(nPoints, -1);const cellModel &hex=*(cellModeller::lookup("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]=cellShape(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, &mergedCyclicPolyPatch::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]
bool isInternalFace(const label faceIndex) const
Return true if given face label is internal to the mesh.
dimensioned< scalar > magSqr(const dimensioned< Type > &)
autoPtr< mapPolyMesh > createBaffles(const labelList &ownPatch, const labelList &nbrPatch)
Create baffle for every internal face where ownPatch != -1.
label nEdges() const
Return number of edges in patch.
void reverse(UList< T > &, const label n)
OFstream which keeps track of vertices.
void checkData()
Debugging: check that all faces still obey start()>end()
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurrence of given element and return index,.
bool mkDir(const fileName &, mode_t=0777)
Make a directory and return an error if it could not be created.
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
void updateMesh(const mapPolyMesh &, const labelList &changedFaces)
Update for external change to mesh. changedFaces are in new mesh.
void setInstance(const fileName &)
Set the instance for mesh files.
const Type & second() const
Return second.
label whichZone(const label objectIndex) const
Given a global object index, return the zone it is in.
virtual tmp< scalarField > movePoints(const pointField &)
Move points, returns volumes swept by faces in motion.
label size() const
Return the number of elements in the UPtrList.
const edgeList & edges() const
Return mesh edges. Uses calcEdges.
const vectorField & faceCentres() const
void setSize(const label)
Reset size of List.
const boundBox & bounds() const
Return mesh bounding box.
autoPtr< mapPolyMesh > dupNonManifoldPoints()
Find boundary points that connect to more than one cell.
const wordList & names() const
Names of surfaces.
autoPtr< mapPolyMesh > zonify(const point &keepPoint, const bool allowFreeStandingZoneFaces)
Put faces/cells into zones according to surface specification.
#define WarningInFunction
Report a warning using Foam::Warning.
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
labelList meshEdges(const edgeList &allEdges, const labelListList &cellEdges, const labelList &faceCells) const
Return labels of patch edges in the global edge list using.
A cell is defined as a list of faces with extra functionality.
prefixOSstream Pout(cout, "Pout")
const List< FaceType > & localFaces() const
Return patch faces addressing into local point list.
const vectorField & faceAreas() const
Direct mesh changes based on v1.3 polyTopoChange syntax.
label start() const
Return start label of this patch in the polyMesh face list.
static labelList addFaceZonesToMesh(const PtrList< surfaceZonesInfo > &surfList, const labelList &namedSurfaces, polyMesh &mesh)
void setRefinement(const localPointRegion ®ionSide, polyTopoChange &)
Play commands into polyTopoChange to duplicate points. Gets.
label globalRegion(const label surfI, const label regionI) const
From surface and region on surface to global region.
label nRegions() const
Return total number of regions.
static labelList getClosedNamedSurfaces(const PtrList< surfaceZonesInfo > &surfList, const searchableSurfaces &allGeometry, const labelList &surfaces)
Get indices of surfaces with a cellZone that are closed and.
static labelList getNamedSurfaces(const PtrList< surfaceZonesInfo > &surfList)
Get indices of named surfaces (surfaces with faceZoneName)
const labelListList & pointFaces() const
const labelListList & faceEdges() const
Return face-edge addressing.
dimensioned< scalar > mag(const dimensioned< Type > &)
Field< vector > vectorField
Specialisation of Field<T> for vector.
void setSize(const label)
Dummy setSize function.
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
const doubleScalar e
Elementary charge.
labelList getExposedFaces(const labelList &cellsToRemove) const
Get labels of exposed faces.
A subset of mesh faces organised as a primitive patch.
List< Key > toc() const
Return the table of contents.
virtual void sync(const polyMesh &mesh)
Sync faceSet across coupled patches.
autoPtr< mapPolyMesh > changeMesh(polyMesh &mesh, const bool inflate, const bool syncParallel=true, const bool orderCells=false, const bool orderPoints=false)
Inplace changes mesh without change of patches.
bool write() const
Write mesh and all data.
A patch is a list of labels that address the faces in the global face list.
void findNearestIntersection(const labelList &surfacesToTest, const pointField &start, const pointField &end, labelList &surface1, List< pointIndexHit > &hit1, labelList ®ion1, labelList &surface2, List< pointIndexHit > &hit2, labelList ®ion2) const
Find intersection nearest to the endpoints. surface1,2 are.
const Type & first() const
Return first.
A List with indirect addressing.
label whichPatch(const label faceIndex) const
Return patch index for a given face label.
void transfer(List< T > &)
Transfer the contents of the argument List into this list.
A HashTable to objects of type <T> with a label key.
void findInside(const labelList &surfacesToTest, const pointField &pt, labelList &insideSurfaces) const
Detect if a point is 'inside' (closed) surfaces.
label setAction(const topoAction &action)
For compatibility with polyTopoChange: set topological action.