53 polyTopoChange& meshMod
56 const face& f = mesh_.
faces()[facei];
58 bool zoneFlip =
false;
62 const faceZone& fZone = mesh_.
faceZones()[zoneID];
63 zoneFlip = fZone.flipMap()[fZone.whichFace(facei)];
90 <<
"No neighbour patch for internal face " << facei
95 bool reverseFlip =
false;
98 reverseFlip = !zoneFlip;
101 dupFacei = meshMod.setAction
122 void Foam::meshRefinement::getBafflePatches
131 autoPtr<OFstream> str;
133 if (debug&OBJINTERSECTIONS)
144 Pout<<
"getBafflePatches : Writing surface intersections to file " 156 ownPatch.setSize(mesh_.
nFaces());
158 nbrPatch.setSize(mesh_.
nFaces());
175 label facei = testFaces[i];
181 start[i] = cellCentres[own];
186 start[i] = cellCentres[own];
202 List<pointIndexHit> hit1;
205 List<pointIndexHit> hit2;
224 label facei = testFaces[i];
226 if (hit1[i].hit() && hit2[i].hit())
238 str()<<
"l " << vertI-3 <<
' ' << vertI-2 <<
nl;
239 str()<<
"l " << vertI-2 <<
' ' << vertI-1 <<
nl;
240 str()<<
"l " << vertI-1 <<
' ' << vertI <<
nl;
244 ownPatch[facei] = globalToMasterPatch
248 nbrPatch[facei] = globalToMasterPatch
253 if (ownPatch[facei] == -1 || nbrPatch[facei] == -1)
276 const bool allowBoundary,
281 Map<labelPair> bafflePatch(mesh_.
nFaces()/1000);
283 const PtrList<surfaceZonesInfo>& surfZones = surfaces_.
surfZones();
288 const word& faceZoneName = surfZones[surfI].faceZoneName();
290 if (faceZoneName.size())
293 label zoneI = fZones.findZoneID(faceZoneName);
295 const faceZone& fZone = fZones[zoneI];
301 globalToMasterPatch[globalRegionI],
302 globalToSlavePatch[globalRegionI]
305 Info<<
"For zone " << fZone.name() <<
" found patches " 312 label facei = fZone[i];
317 if (fZone.flipMap()[i])
322 if (!bafflePatch.insert(facei, patches))
327 <<
" in zone " << fZone.name()
328 <<
" is in multiple zones!" 353 <<
" ownPatch:" << ownPatch.
size()
354 <<
" nbrPatch:" << nbrPatch.
size()
355 <<
". Should be number of faces:" << mesh_.
nFaces()
366 forAll(syncedOwnPatch, facei)
370 (ownPatch[facei] == -1 && syncedOwnPatch[facei] != -1)
371 || (nbrPatch[facei] == -1 && syncedNeiPatch[facei] != -1)
375 <<
"Non synchronised at face:" << facei
378 <<
"ownPatch:" << ownPatch[facei]
379 <<
" syncedOwnPatch:" << syncedOwnPatch[facei]
380 <<
" nbrPatch:" << nbrPatch[facei]
381 <<
" syncedNeiPatch:" << syncedNeiPatch[facei]
394 if (ownPatch[facei] != -1)
418 if (map().hasMotionPoints())
434 faceSet baffledFacesSet(mesh_,
"baffledFacesSet", 2*nBaffles);
436 const labelList& reverseFaceMap = map().reverseFaceMap();
440 forAll(ownPatch, oldFacei)
442 label facei = reverseFaceMap[oldFacei];
444 if (ownPatch[oldFacei] != -1 && facei >= 0)
450 baffledFacesSet.
insert(ownFaces[i]);
457 label oldFacei = faceMap[facei];
459 if (oldFacei >= 0 && reverseFaceMap[oldFacei] != facei)
465 baffledFacesSet.
insert(ownFaces[i]);
469 baffledFacesSet.
sync(mesh_);
487 if (isA<processorPolyPatch>(pp))
497 <<
"face:" << facei <<
" on patch " << pp.
name()
498 <<
" is in zone " << fZones[zoneI].
name()
522 if (zonedSurfaces.
size())
525 Info<<
"Converting zoned faces into baffles ..." <<
endl;
547 ownPatch[iter.key()] = iter().
first();
548 nbrPatch[iter.key()] = iter().second();
562 const labelList& reverseFaceMap = map().reverseFaceMap();
566 label oldFacei = faceMap[facei];
574 if (iter != faceToPatch.
end())
576 label masterFacei = reverseFaceMap[oldFacei];
577 if (facei != masterFacei)
579 baffles[baffleI++] =
labelPair(masterFacei, facei);
584 if (baffleI != faceToPatch.
size())
587 <<
"Had " << faceToPatch.
size() <<
" patches to create " 588 <<
" but encountered " << baffleI
589 <<
" slave faces originating from patcheable faces." 596 Pout<<
"Writing zone-baffled mesh to time " <<
timeName()
606 Info<<
"Created " << nZoneFaces <<
" baffles in = " 616 const scalar planarAngle
643 const label baffleValue = 1000000;
666 nBafflesPerEdge[fEdges[fEdgeI]]++;
688 nBafflesPerEdge[fEdges0[fEdgeI]] += baffleValue;
693 label f1 = couples[i].second();
697 nBafflesPerEdge[fEdges1[fEdgeI]] += baffleValue;
733 label edgeI = fEdges[fEdgeI];
735 if (nBafflesPerEdge[edgeI] == 2*baffleValue+2*1)
737 filteredCouples[filterI++] = couple;
743 filteredCouples.
setSize(filterI);
748 Info<<
"freeStandingBaffles : detected " 750 <<
" free-standing baffles out of " 765 forAll(filteredCouples, i)
767 const labelPair& couple = filteredCouples[i];
818 forAll(filteredCouples, i)
820 const labelPair& couple = filteredCouples[i];
827 surface1[i] != surface2[i]
828 || hit1[i].index() != hit2[i].index()
840 if ((normal1[i]&normal2[i]) > planarAngleCos)
844 scalar magN =
mag(n);
847 filteredCouples[filterI++] = couple;
851 else if (hit1[i].hit() || hit2[i].hit())
857 filteredCouples.
setSize(filterI);
859 Info<<
"freeStandingBaffles : detected " 861 <<
" planar (within " << planarAngle
862 <<
" degrees) free-standing baffles out of " 867 return filteredCouples;
886 label face1 = couples[i].second();
890 label own0 = faceOwner[face0];
891 label own1 = faceOwner[face1];
893 if (face1 < 0 || own0 < own1)
897 bool zoneFlip =
false;
901 const faceZone& fZone = faceZones[zoneID];
905 label nei = (face1 < 0 ? -1 : own1);
928 bool zoneFlip =
false;
932 const faceZone& fZone = faceZones[zoneID];
964 if (map().hasMotionPoints())
985 label newFace0 = map().reverseFaceMap()[couples[i].
first()];
988 newExposedFaces[newI++] = newFace0;
991 label newFace1 = map().reverseFaceMap()[couples[i].second()];
994 newExposedFaces[newI++] = newFace1;
997 newExposedFaces.setSize(newI);
1005 void Foam::meshRefinement::findCellZoneGeometric
1023 closedNamedSurfaces,
1028 forAll(insideSurfaces, celli)
1030 if (cellToZone[celli] == -2)
1032 label surfI = insideSurfaces[celli];
1036 cellToZone[celli] = surfaceToCellZone[surfI];
1049 label nCandidates = 0;
1050 forAll(namedSurfaceIndex, facei)
1052 label surfI = namedSurfaceIndex[facei];
1070 forAll(namedSurfaceIndex, facei)
1072 label surfI = namedSurfaceIndex[facei];
1076 label own = faceOwner[facei];
1077 const point& ownCc = cellCentres[own];
1081 label nei = faceNeighbour[facei];
1082 const point& neiCc = cellCentres[nei];
1084 const vector d = 1
e-4*(neiCc - ownCc);
1085 candidatePoints[nCandidates++] = ownCc-d;
1086 candidatePoints[nCandidates++] = neiCc+d;
1094 const vector d = 1
e-4*(neiFc - ownCc);
1095 candidatePoints[nCandidates++] = ownCc-d;
1105 closedNamedSurfaces,
1114 forAll(namedSurfaceIndex, facei)
1116 label surfI = namedSurfaceIndex[facei];
1120 label own = faceOwner[facei];
1124 label ownSurfI = insideSurfaces[nCandidates++];
1127 cellToZone[own] = surfaceToCellZone[ownSurfI];
1130 label neiSurfI = insideSurfaces[nCandidates++];
1133 label nei = faceNeighbour[facei];
1135 cellToZone[nei] = surfaceToCellZone[neiSurfI];
1140 label ownSurfI = insideSurfaces[nCandidates++];
1143 cellToZone[own] = surfaceToCellZone[ownSurfI];
1159 if (namedSurfaceIndex[facei] == -1 && (ownZone != neiZone))
1165 max(ownZone, neiZone)
1201 if (namedSurfaceIndex[facei] == -1 && (ownZone != neiZone))
1207 max(ownZone, neiZone)
1219 void Foam::meshRefinement::findCellZoneInsideWalk
1232 forAll(namedSurfaceIndex, facei)
1234 if (namedSurfaceIndex[facei] == -1)
1236 blockedFace[facei] =
false;
1240 blockedFace[facei] =
true;
1247 blockedFace.clear();
1256 forAll(locationSurfaces, i)
1258 label surfI = locationSurfaces[i];
1260 const point& insidePoint = surfZones[surfI].zoneInsidePoint();
1262 Info<<
"For surface " << surfaces_.
names()[surfI]
1263 <<
" finding inside point " << insidePoint
1271 mergeDistance_*
vector(1,1,1),
1275 Info<<
"For surface " << surfaces_.
names()[surfI]
1276 <<
" found point " << insidePoint
1277 <<
" in global region " << keepRegionI
1278 <<
" out of " << cellRegion.
nRegions() <<
" regions." <<
endl;
1280 if (keepRegionI == -1)
1283 <<
"Point " << insidePoint
1284 <<
" is not inside the mesh." <<
nl 1285 <<
"Bounding box of the mesh:" << mesh_.
bounds()
1290 forAll(cellRegion, celli)
1292 if (cellRegion[celli] == keepRegionI)
1294 if (cellToZone[celli] == -2)
1296 cellToZone[celli] = surfaceToCellZone[surfI];
1298 else if (cellToZone[celli] != surfaceToCellZone[surfI])
1303 <<
" is inside surface " << surfaces_.
names()[surfI]
1304 <<
" but already marked as being in zone " 1305 << cellToZone[celli] << endl
1306 <<
"This can happen if your surfaces are not" 1307 <<
" (sufficiently) closed." 1316 bool Foam::meshRefinement::calcRegionToZone
1318 const label surfZoneI,
1319 const label ownRegion,
1320 const label neiRegion,
1325 bool changed =
false;
1328 if (ownRegion != neiRegion)
1335 if (regionToCellZone[ownRegion] == -2)
1337 if (regionToCellZone[neiRegion] == surfZoneI)
1341 regionToCellZone[ownRegion] = -1;
1344 else if (regionToCellZone[neiRegion] != -2)
1348 regionToCellZone[ownRegion] = surfZoneI;
1352 else if (regionToCellZone[neiRegion] == -2)
1354 if (regionToCellZone[ownRegion] == surfZoneI)
1358 regionToCellZone[neiRegion] = -1;
1361 else if (regionToCellZone[ownRegion] != -2)
1365 regionToCellZone[neiRegion] = surfZoneI;
1374 void Foam::meshRefinement::findCellZoneTopo
1376 const point& keepPoint,
1390 forAll(namedSurfaceIndex, facei)
1392 if (namedSurfaceIndex[facei] == -1)
1394 blockedFace[facei] =
false;
1398 blockedFace[facei] =
true;
1405 blockedFace.clear();
1416 forAll(cellToZone, celli)
1418 if (cellToZone[celli] != -2)
1420 regionToCellZone[cellRegion[celli]] = cellToZone[celli];
1430 mergeDistance_*
vector(1,1,1),
1434 Info<<
"Found point " << keepPoint
1435 <<
" in global region " << keepRegionI
1436 <<
" out of " << cellRegion.
nRegions() <<
" regions." <<
endl;
1438 if (keepRegionI == -1)
1441 <<
"Point " << keepPoint
1442 <<
" is not inside the mesh." <<
nl 1443 <<
"Bounding box of the mesh:" << mesh_.
bounds()
1448 if (regionToCellZone[keepRegionI] == -2)
1450 regionToCellZone[keepRegionI] = -1;
1469 bool changed =
false;
1475 label surfI = namedSurfaceIndex[facei];
1482 bool changedCell = calcRegionToZone
1484 surfaceToCellZone[surfI],
1490 changed = changed | changedCell;
1528 label surfI = namedSurfaceIndex[facei];
1533 bool changedCell = calcRegionToZone
1535 surfaceToCellZone[surfI],
1541 changed = changed | changedCell;
1554 forAll(regionToCellZone, regionI)
1556 label zoneI = regionToCellZone[regionI];
1561 <<
"For region " << regionI <<
" haven't set cell zone." 1568 forAll(regionToCellZone, regionI)
1570 Pout<<
"Region " << regionI
1571 <<
" becomes cellZone:" << regionToCellZone[regionI]
1577 forAll(cellToZone, celli)
1579 cellToZone[celli] = regionToCellZone[cellRegion[celli]];
1584 void Foam::meshRefinement::makeConsistentFaceIndex
1595 label ownZone = cellToZone[faceOwner[facei]];
1596 label neiZone = cellToZone[faceNeighbour[facei]];
1598 if (ownZone == neiZone && namedSurfaceIndex[facei] != -1)
1600 namedSurfaceIndex[facei] = -1;
1602 else if (ownZone != neiZone && namedSurfaceIndex[facei] == -1)
1605 <<
"Different cell zones on either side of face " << facei
1607 <<
" but face not marked with a surface." 1643 label ownZone = cellToZone[faceOwner[facei]];
1646 if (ownZone == neiZone && namedSurfaceIndex[facei] != -1)
1648 namedSurfaceIndex[facei] = -1;
1650 else if (ownZone != neiZone && namedSurfaceIndex[facei] == -1)
1653 <<
"Different cell zones on either side of face " 1655 <<
" but face not marked with a surface." 1666 namedSurfaceIndex[facei] = -1;
1673 void Foam::meshRefinement::handleSnapProblems
1676 const bool useTopologicalSnapDetection,
1677 const bool removeEdgeConnectedCells,
1686 <<
"Introducing baffles to block off problem cells" <<
nl 1687 <<
"----------------------------------------------" <<
nl 1691 if (useTopologicalSnapDetection)
1693 facePatch = markFacesOnProblemCells
1696 removeEdgeConnectedCells,
1703 facePatch = markFacesOnProblemCellsGeometric(snapParams, motionDict);
1705 Info<<
"Analyzed problem cells in = " 1710 faceSet problemFaces(mesh_,
"problemFaces", mesh_.
nFaces()/100);
1714 if (facePatch[facei] != -1)
1716 problemFaces.insert(facei);
1719 problemFaces.instance() =
timeName();
1720 Pout<<
"Dumping " << problemFaces.size()
1721 <<
" problem faces to " << problemFaces.objectPath() <<
endl;
1722 problemFaces.
write();
1725 Info<<
"Introducing baffles to delete problem cells." <<
nl <<
endl;
1740 Info<<
"Created baffles in = " 1747 Pout<<
"Writing extra baffled mesh to time " 1753 runTime.
path()/
"extraBaffles" 1755 Pout<<
"Dumped debug data in = " 1791 if (faceToZone[facei] != -1)
1794 label ownZone = cellToZone[faceOwner[facei]];
1795 label neiZone = cellToZone[faceNeighbour[facei]];
1796 if (ownZone == neiZone)
1798 faceLabels.
append(facei);
1809 if (faceToZone[facei] != -1)
1812 label ownZone = cellToZone[faceOwner[facei]];
1814 if (ownZone == neiZone)
1816 faceLabels.
append(facei);
1821 return faceLabels.shrink();
1825 void Foam::meshRefinement::calcPatchNumMasterFaces
1834 nMasterFacesPerEdge = 0;
1836 forAll(patch.addressing(), facei)
1838 const label meshFacei = patch.addressing()[facei];
1840 if (isMasterFace[meshFacei])
1845 nMasterFacesPerEdge[fEdges[fEdgeI]]++;
1854 nMasterFacesPerEdge,
1874 label nProtected = 0;
1876 forAll(nMasterFacesPerEdge, edgeI)
1878 if (nMasterFacesPerEdge[edgeI] > 2)
1880 allEdgeInfo[edgeI] = -2;
1899 >::propagationTol();
1907 label currentZoneI = 0;
1913 for (; facei < allFaceInfo.size(); facei++)
1915 if (!allFaceInfo[facei].valid(dummyTrackData))
1917 globalSeed = globalFaces.toGlobal(facei);
1929 label proci = globalFaces.whichProcID(globalSeed);
1930 label seedFacei = globalFaces.toLocal(proci, globalSeed);
1942 faceInfo = currentZoneI;
1948 label edgeI = fEdges[fEdgeI];
1966 changedEdges.
append(edgeI);
1967 changedInfo.
append(edgeInfo);
1999 faceToZone.
setSize(patch.size());
2000 forAll(allFaceInfo, facei)
2002 if (!allFaceInfo[facei].valid(dummyTrackData))
2005 <<
"Problem: unvisited face " << facei
2009 faceToZone[facei] = allFaceInfo[facei].region();
2012 return currentZoneI;
2016 void Foam::meshRefinement::consistentOrientation
2036 label nProtected = 0;
2038 forAll(patch.addressing(), facei)
2040 const label meshFacei = patch.addressing()[facei];
2046 && bm[patchi].coupled()
2047 && !isMasterFace[meshFacei]
2060 label nProtected = 0;
2062 forAll(nMasterFacesPerEdge, edgeI)
2064 if (nMasterFacesPerEdge[edgeI] > 2)
2071 Info<<
"Protected from visiting " 2073 <<
" non-manifold edges" <<
nl <<
endl;
2085 >::propagationTol();
2095 forAll(allFaceInfo, facei)
2099 globalSeed = globalFaces.toGlobal(facei);
2111 label proci = globalFaces.whichProcID(globalSeed);
2112 label seedFacei = globalFaces.toLocal(proci, globalSeed);
2126 if (zoneToOrientation[faceToZone[seedFacei]] < 0)
2135 label edgeI = fEdges[fEdgeI];
2153 changedEdges.
append(edgeI);
2154 changedInfo.
append(edgeInfo);
2193 forAll(patch.addressing(), i)
2195 const label meshFacei = patch.addressing()[i];
2199 allFaceInfo[i].flipStatus();
2204 forAll(patch.addressing(), i)
2206 const label meshFacei = patch.addressing()[i];
2212 && bm[patchi].coupled()
2213 && !isMasterFace[meshFacei]
2230 <<
"Incorrect status for face " << meshFacei
2241 meshFlipMap =
false;
2243 forAll(allFaceInfo, facei)
2245 label meshFacei = patch.addressing()[facei];
2249 meshFlipMap[meshFacei] =
false;
2253 meshFlipMap[meshFacei] =
true;
2258 <<
"Problem : unvisited face " << facei
2270 const bool doHandleSnapProblems,
2272 const bool useTopologicalSnapDetection,
2273 const bool removeEdgeConnectedCells,
2275 const bool mergeFreeStanding,
2276 const scalar planarAngle,
2281 const point& keepPoint
2290 Info<<
"Introducing baffles for " 2292 <<
" faces that are intersected by the surface." <<
nl <<
endl;
2297 calcNeighbourData(neiLevel, neiCc);
2302 globalToMasterPatch,
2318 Info<<
"Created baffles in = " 2331 runTime.
path()/
"baffles" 2333 Pout<<
"Dumped debug data in = " 2343 if (doHandleSnapProblems)
2348 useTopologicalSnapDetection,
2349 removeEdgeConnectedCells,
2353 globalToMasterPatch,
2363 <<
"Remove unreachable sections of mesh" <<
nl 2364 <<
"-----------------------------------" <<
nl 2379 Info<<
"Split mesh in = " 2394 Pout<<
"Dumped debug data in = " 2402 if (mergeFreeStanding)
2405 <<
"Merge free-standing baffles" <<
nl 2406 <<
"---------------------------" <<
nl 2423 Info<<
"Detected free-standing baffles : " << nCouples <<
endl;
2437 useTopologicalSnapDetection,
2438 removeEdgeConnectedCells,
2442 globalToMasterPatch,
2452 Info<<
"Merged free-standing baffles in = " 2460 const label nBufferLayers,
2463 const point& keepPoint
2472 calcNeighbourData(neiLevel, neiCc);
2477 globalToMasterPatch,
2490 if (ownPatch[facei] != -1 || nbrPatch[facei] != -1)
2492 blockedFace[facei] =
true;
2499 blockedFace.clear();
2506 mergeDistance_*
vector(1,1,1),
2510 Info<<
"Found point " << keepPoint
2511 <<
" in global region " << keepRegionI
2512 <<
" out of " << cellRegion.
nRegions() <<
" regions." <<
endl;
2514 if (keepRegionI == -1)
2517 <<
"Point " << keepPoint
2518 <<
" is not inside the mesh." <<
nl 2519 <<
"Bounding box of the mesh:" << mesh_.
bounds()
2534 label defaultPatch = 0;
2535 if (globalToMasterPatch.
size())
2537 defaultPatch = globalToMasterPatch[0];
2540 for (
label i = 0; i < nBufferLayers; i++)
2546 forAll(faceNeighbour, facei)
2550 label ownRegion = cellRegion[faceOwner[facei]];
2551 label neiRegion = cellRegion[faceNeighbour[facei]];
2553 if (ownRegion == keepRegionI && neiRegion != keepRegionI)
2560 pointBaffle[f[fp]] =
max(defaultPatch, ownPatch[facei]);
2563 else if (ownRegion != keepRegionI && neiRegion == keepRegionI)
2565 label newPatchi = nbrPatch[facei];
2566 if (newPatchi == -1)
2568 newPatchi =
max(defaultPatch, ownPatch[facei]);
2572 pointBaffle[f[fp]] = newPatchi;
2585 label ownRegion = cellRegion[faceOwner[facei]];
2587 if (ownRegion == keepRegionI)
2591 pointBaffle[f[fp]] =
max(defaultPatch, ownPatch[facei]);
2610 forAll(pointFaces, pointi)
2612 if (pointBaffle[pointi] != -1)
2618 label facei = pFaces[pFacei];
2620 if (ownPatch[facei] == -1)
2622 ownPatch[facei] = pointBaffle[pointi];
2636 if (ownPatch[facei] != -1)
2638 label own = faceOwner[facei];
2640 if (cellRegion[own] != keepRegionI)
2642 cellRegion[own] = keepRegionI;
2644 const cell& ownFaces = mesh_.
cells()[own];
2647 if (ownPatch[ownFaces[j]] == -1)
2649 newOwnPatch[ownFaces[j]] = ownPatch[facei];
2655 label nei = faceNeighbour[facei];
2657 if (cellRegion[nei] != keepRegionI)
2659 cellRegion[nei] = keepRegionI;
2661 const cell& neiFaces = mesh_.
cells()[nei];
2664 if (ownPatch[neiFaces[j]] == -1)
2666 newOwnPatch[neiFaces[j]] = ownPatch[facei];
2686 forAll(cellRegion, celli)
2688 if (cellRegion[celli] != keepRegionI)
2690 cellsToRemove.append(celli);
2693 cellsToRemove.shrink();
2695 label nCellsToKeep = mesh_.
nCells() - cellsToRemove.size();
2698 Info<<
"Keeping all cells in region " << keepRegionI
2699 <<
" containing point " << keepPoint <<
endl 2700 <<
"Selected for keeping : " << nCellsToKeep
2701 <<
" cells." <<
endl;
2709 labelList exposedPatches(exposedFaces.size());
2713 label facei = exposedFaces[i];
2715 if (ownPatch[facei] != -1)
2717 exposedPatches[i] = ownPatch[facei];
2722 <<
"For exposed face " << facei
2724 <<
" found no patch." << endl
2725 <<
" Taking patch " << defaultPatch
2726 <<
" instead." <<
endl;
2727 exposedPatches[i] = defaultPatch;
2731 return doRemoveCells
2755 Info<<
"dupNonManifoldPoints : Found : " << nNonManifPoints
2756 <<
" non-manifold points (out of " 2775 if (map().hasMotionPoints())
2807 const point& keepPoint,
2808 const bool allowFreeStandingZoneFaces
2817 label surfI = namedSurfaces[i];
2819 Info<<
"Surface : " << surfaces_.
names()[surfI] <<
nl 2820 <<
" faceZone : " << surfZones[surfI].faceZoneName() <<
nl 2821 <<
" cellZone : " << surfZones[surfI].cellZoneName() <<
endl;
2852 calcNeighbourData(neiLevel, neiCc);
2885 label facei = testFaces[i];
2889 start[i] = cellCentres[faceOwner[facei]];
2890 end[i] = cellCentres[faceNeighbour[facei]];
2894 start[i] = cellCentres[faceOwner[facei]];
2901 const vectorField smallVec(rootSmall*(end-start));
2941 label facei = testFaces[i];
2944 if (surface1[i] != -1)
2951 magSqr(hit2[i].hitPoint())
2952 <
magSqr(hit1[i].hitPoint())
2956 namedSurfaceIndex[facei] = surface2[i];
2957 posOrientation[facei] = ((area&normal2[i]) > 0);
2958 nSurfFaces[surface2[i]]++;
2962 namedSurfaceIndex[facei] = surface1[i];
2963 posOrientation[facei] = ((area&normal1[i]) > 0);
2964 nSurfFaces[surface1[i]]++;
2967 else if (surface2[i] != -1)
2969 namedSurfaceIndex[facei] = surface2[i];
2970 posOrientation[facei] = ((area&normal2[i]) > 0);
2971 nSurfFaces[surface2[i]]++;
2990 forAll(nSurfFaces, surfI)
2993 << surfaces_.
names()[surfI]
2994 <<
" nZoneFaces:" << nSurfFaces[surfI] <<
nl;
3025 if (closedNamedSurfaces.size())
3027 Info<<
"Found " << closedNamedSurfaces.size()
3028 <<
" closed, named surfaces. Assigning cells in/outside" 3029 <<
" these surfaces to the corresponding cellZone." 3032 findCellZoneGeometric
3035 closedNamedSurfaces,
3052 if (locationSurfaces.
size())
3054 Info<<
"Found " << locationSurfaces.
size()
3055 <<
" named surfaces with a provided inside point." 3056 <<
" Assigning cells inside these surfaces" 3057 <<
" to the corresponding cellZone." 3060 findCellZoneInsideWalk
3075 Info<<
"Walking from location-in-mesh " << keepPoint
3076 <<
" to assign cellZones " 3077 <<
"- crossing a faceZone face changes cellZone" <<
nl <<
endl;
3092 if (!allowFreeStandingZoneFaces)
3094 Info<<
"Only keeping zone faces in between different cellZones." 3097 makeConsistentFaceIndex(cellToZone, namedSurfaceIndex);
3107 forAll(namedSurfaceIndex, facei)
3109 label surfI = namedSurfaceIndex[facei];
3112 faceToZone[facei] = surfaceToFaceZone[surfI];
3134 neiCellZone[bFacei++] = -1;
3164 freeStandingBaffleFaces
3175 if (nFreeStanding > 0)
3177 Info<<
"Detected " << nFreeStanding <<
" free-standing zone faces" 3189 calcPatchNumMasterFaces(isMasterFace, patch, nMasterFacesPerEdge);
3194 const label nZones = markPatchZones
3197 nMasterFacesPerEdge,
3202 for (
label zoneI = 0; zoneI < nZones; zoneI++)
3204 nPosOrientation.
insert(zoneI, 0);
3210 consistentOrientation
3214 nMasterFacesPerEdge,
3215 faceToConnectedZone,
3223 forAll(patch.addressing(), facei)
3225 label meshFacei = patch.addressing()[facei];
3227 if (isMasterFace[meshFacei])
3232 bool(posOrientation[meshFacei])
3233 == meshFlipMap[meshFacei]
3239 nPosOrientation.
find(faceToConnectedZone[facei])() += n;
3246 Info<<
"Split " << nFreeStanding <<
" free-standing zone faces" 3247 <<
" into " << nZones <<
" disconnected regions with size" 3248 <<
" (negative denotes wrong orientation) :" 3251 for (
label zoneI = 0; zoneI < nZones; zoneI++)
3253 Info<<
" " << zoneI <<
"\t" << nPosOrientation[zoneI]
3261 consistentOrientation
3265 nMasterFacesPerEdge,
3266 faceToConnectedZone,
3280 label faceZoneI = faceToZone[facei];
3282 if (faceZoneI != -1)
3288 label ownZone = cellToZone[faceOwner[facei]];
3289 label neiZone = cellToZone[faceNeighbour[facei]];
3293 if (ownZone == neiZone)
3296 flip = meshFlipMap[facei];
3303 || (neiZone != -1 && ownZone > neiZone)
3311 mesh_.
faces()[facei],
3314 faceNeighbour[facei],
3335 label faceZoneI = faceToZone[facei];
3337 if (faceZoneI != -1)
3339 label ownZone = cellToZone[faceOwner[facei]];
3344 if (ownZone == neiZone)
3347 flip = meshFlipMap[facei];
3354 || (neiZone != -1 && ownZone > neiZone)
3362 mesh_.
faces()[facei],
3382 forAll(cellToZone, celli)
3384 label zoneI = cellToZone[celli];
3409 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.
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.
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.
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
const meshCellZones & cellZones() const
Return cell zones.
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
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
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)
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.
MeshZones< faceZone, polyMesh > meshFaceZones
A MeshZones with the type faceZone.
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.
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.
label whichZone(const label objectIndex) const
Given a global object index, return the zone it is in.
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 meshFaceZones & faceZones() const
Return face zones.
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.
fileName path() const
Return path.
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.