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
139 ownPatch.setSize(mesh_.
nFaces());
141 nbrPatch.setSize(mesh_.
nFaces());
158 const label facei = testFaces[i];
163 start[i] = cellCentres[own];
168 start[i] = cellCentres[own];
184 List<pointIndexHit> hit1;
187 List<pointIndexHit> hit2;
206 const label facei = testFaces[i];
208 if (hit1[i].hit() && hit2[i].hit())
211 ownPatch[facei] = globalToMasterPatch
215 nbrPatch[facei] = globalToMasterPatch
220 if (ownPatch[facei] == -1 || nbrPatch[facei] == -1)
243 const bool allowBoundary,
248 Map<labelPair> bafflePatch(mesh_.
nFaces()/1000);
250 const PtrList<surfaceZonesInfo>& surfZones = surfaces_.
surfZones();
255 const word& faceZoneName = surfZones[surfi].faceZoneName();
257 if (faceZoneName.size())
260 const label zonei = fZones.findZoneID(faceZoneName);
261 const faceZone& fZone = fZones[zonei];
267 globalToMasterPatch[globalRegioni],
268 globalToSlavePatch[globalRegioni]
271 Info<<
"For zone " << fZone.name() <<
" found patches " 278 const label facei = fZone[i];
283 if (fZone.flipMap()[i])
288 if (!bafflePatch.insert(facei, patches))
293 <<
" in zone " << fZone.name()
294 <<
" is in multiple zones!" 320 <<
" ownPatch:" << ownPatch.
size()
321 <<
" nbrPatch:" << nbrPatch.
size()
322 <<
". Should be number of faces:" << mesh_.
nFaces()
333 forAll(syncedOwnPatch, facei)
337 (ownPatch[facei] == -1 && syncedOwnPatch[facei] != -1)
338 || (nbrPatch[facei] == -1 && syncedNeiPatch[facei] != -1)
342 <<
"Non synchronised at face:" << facei
345 <<
"ownPatch:" << ownPatch[facei]
346 <<
" syncedOwnPatch:" << syncedOwnPatch[facei]
347 <<
" nbrPatch:" << nbrPatch[facei]
348 <<
" syncedNeiPatch:" << syncedNeiPatch[facei]
361 if (ownPatch[facei] != -1)
385 if (map().hasMotionPoints())
401 faceSet baffledFacesSet(mesh_,
"baffledFacesSet", 2*nBaffles);
403 const labelList& reverseFaceMap = map().reverseFaceMap();
407 forAll(ownPatch, oldFacei)
409 const label facei = reverseFaceMap[oldFacei];
411 if (ownPatch[oldFacei] != -1 && facei >= 0)
417 baffledFacesSet.
insert(ownFaces[i]);
424 const label oldFacei = faceMap[facei];
426 if (oldFacei >= 0 && reverseFaceMap[oldFacei] != facei)
432 baffledFacesSet.
insert(ownFaces[i]);
436 baffledFacesSet.
sync(mesh_);
454 if (isA<processorPolyPatch>(pp))
464 <<
"face:" << facei <<
" on patch " << pp.
name()
465 <<
" is in zone " << fZones[zonei].
name()
489 if (zonedSurfaces.
size())
492 Info<<
"Converting zoned faces into baffles ..." <<
endl;
506 const label nZoneFaces =
516 ownPatch[iter.key()] = iter().
first();
517 nbrPatch[iter.key()] = iter().second();
531 const labelList& reverseFaceMap = map().reverseFaceMap();
535 const label oldFacei = faceMap[facei];
543 if (iter != faceToPatch.
end())
545 const label masterFacei = reverseFaceMap[oldFacei];
546 if (facei != masterFacei)
548 baffles[baffleI++] =
labelPair(masterFacei, facei);
553 if (baffleI != faceToPatch.
size())
556 <<
"Had " << faceToPatch.
size() <<
" patches to create " 557 <<
" but encountered " << baffleI
558 <<
" slave faces originating from patcheable faces." 565 Pout<<
"Writing zone-baffled mesh to time " <<
timeName()
575 Info<<
"Created " << nZoneFaces <<
" baffles in = " 585 const scalar planarAngle
612 const label baffleValue = 1000000;
635 nBafflesPerEdge[fEdges[fEdgei]]++;
657 nBafflesPerEdge[fEdges0[fEdgei]] += baffleValue;
662 const label f1 = couples[i].second();
666 nBafflesPerEdge[fEdges1[fEdgei]] += baffleValue;
702 const label edgei = fEdges[fEdgei];
704 if (nBafflesPerEdge[edgei] == 2*baffleValue+2*1)
706 filteredCouples[filterI++] = couple;
712 filteredCouples.
setSize(filterI);
715 const label nFiltered =
718 Info<<
"freeStandingBaffles : detected " 720 <<
" free-standing baffles out of " 735 forAll(filteredCouples, i)
737 const labelPair& couple = filteredCouples[i];
782 forAll(filteredCouples, i)
784 const labelPair& couple = filteredCouples[i];
791 surface1[i] != surface2[i]
792 || hit1[i].index() != hit2[i].index()
796 if ((normal1[i ]& normal2[i]) > planarAngleCos)
799 const vector n = end[i] - start[i];
800 const scalar magN =
mag(n);
803 filteredCouples[filterI++] = couple;
807 else if (hit1[i].hit() || hit2[i].hit())
813 filteredCouples.
setSize(filterI);
815 Info<<
"freeStandingBaffles : detected " 817 <<
" planar (within " << planarAngle
818 <<
" degrees) free-standing baffles out of " 823 return filteredCouples;
842 const label face1 = couples[i].second();
846 const label own0 = faceOwner[face0];
847 const label own1 = faceOwner[face1];
849 if (face1 < 0 || own0 < own1)
853 bool zoneFlip =
false;
857 const faceZone& fZone = faceZones[zoneID];
861 const label nei = (face1 < 0 ? -1 : own1);
884 bool zoneFlip =
false;
888 const faceZone& fZone = faceZones[zoneID];
920 if (map().hasMotionPoints())
941 const label newFace0 = map().reverseFaceMap()[couples[i].
first()];
944 newExposedFaces[newI++] = newFace0;
947 const label newFace1 = map().reverseFaceMap()[couples[i].second()];
950 newExposedFaces[newI++] = newFace1;
953 newExposedFaces.setSize(newI);
961 void Foam::meshRefinement::findCellZoneGeometric
984 forAll(insideSurfaces, celli)
986 if (cellToZone[celli] == -2)
988 label surfi = insideSurfaces[celli];
992 cellToZone[celli] = surfaceToCellZone[surfi];
1005 label nCandidates = 0;
1006 forAll(namedSurfaceIndex, facei)
1008 const label surfi = namedSurfaceIndex[facei];
1026 forAll(namedSurfaceIndex, facei)
1028 const label surfi = namedSurfaceIndex[facei];
1032 const label own = faceOwner[facei];
1033 const point& ownCc = cellCentres[own];
1037 const label nei = faceNeighbour[facei];
1038 const point& neiCc = cellCentres[nei];
1041 const vector d = 1
e-4*(neiCc - ownCc);
1042 candidatePoints[nCandidates++] = ownCc-d;
1043 candidatePoints[nCandidates++] = neiCc+d;
1050 const vector d = 1
e-4*(neiFc - ownCc);
1051 candidatePoints[nCandidates++] = ownCc-d;
1061 closedNamedSurfaces,
1070 forAll(namedSurfaceIndex, facei)
1072 const label surfi = namedSurfaceIndex[facei];
1076 const label own = faceOwner[facei];
1080 const label ownSurfI = insideSurfaces[nCandidates++];
1083 cellToZone[own] = surfaceToCellZone[ownSurfI];
1086 const label neiSurfI = insideSurfaces[nCandidates++];
1089 label nei = faceNeighbour[facei];
1091 cellToZone[nei] = surfaceToCellZone[neiSurfI];
1096 const label ownSurfI = insideSurfaces[nCandidates++];
1099 cellToZone[own] = surfaceToCellZone[ownSurfI];
1115 if (namedSurfaceIndex[facei] == -1 && (ownZone != neiZone))
1121 max(ownZone, neiZone)
1157 if (namedSurfaceIndex[facei] == -1 && (ownZone != neiZone))
1163 max(ownZone, neiZone)
1175 void Foam::meshRefinement::findCellZoneInsideWalk
1188 forAll(namedSurfaceIndex, facei)
1190 if (namedSurfaceIndex[facei] == -1)
1192 blockedFace[facei] =
false;
1196 blockedFace[facei] =
true;
1203 blockedFace.clear();
1212 forAll(locationSurfaces, i)
1214 const label surfi = locationSurfaces[i];
1216 const point& insidePoint = surfZones[surfi].zoneInsidePoint();
1218 Info<<
"For surface " << surfaces_.
names()[surfi]
1219 <<
" finding inside point " << insidePoint
1231 Info<<
"For surface " << surfaces_.
names()[surfi]
1232 <<
" found point " << insidePoint
1233 <<
" in global region " << regioninMeshi
1234 <<
" out of " << cellRegion.
nRegions() <<
" regions." <<
endl;
1236 if (regioninMeshi == -1)
1239 <<
"Point " << insidePoint
1240 <<
" is not inside the mesh." <<
nl 1241 <<
"Bounding box of the mesh:" << mesh_.
bounds()
1246 forAll(cellRegion, celli)
1248 if (cellRegion[celli] == regioninMeshi)
1250 if (cellToZone[celli] == -2)
1252 cellToZone[celli] = surfaceToCellZone[surfi];
1254 else if (cellToZone[celli] != surfaceToCellZone[surfi])
1259 <<
" is inside surface " << surfaces_.
names()[surfi]
1260 <<
" but already marked as being in zone " 1261 << cellToZone[celli] << endl
1262 <<
"This can happen if your surfaces are not" 1263 <<
" (sufficiently) closed." 1272 bool Foam::meshRefinement::calcRegionToZone
1274 const label surfZoneI,
1275 const label ownRegion,
1276 const label neiRegion,
1281 bool changed =
false;
1284 if (ownRegion != neiRegion)
1291 if (regionToCellZone[ownRegion] == -2)
1293 if (regionToCellZone[neiRegion] == surfZoneI)
1297 regionToCellZone[ownRegion] = -1;
1300 else if (regionToCellZone[neiRegion] != -2)
1304 regionToCellZone[ownRegion] = surfZoneI;
1308 else if (regionToCellZone[neiRegion] == -2)
1310 if (regionToCellZone[ownRegion] == surfZoneI)
1314 regionToCellZone[neiRegion] = -1;
1317 else if (regionToCellZone[ownRegion] != -2)
1321 regionToCellZone[neiRegion] = surfZoneI;
1330 void Foam::meshRefinement::findCellZoneTopo
1346 forAll(namedSurfaceIndex, facei)
1348 if (namedSurfaceIndex[facei] == -1)
1350 blockedFace[facei] =
false;
1354 blockedFace[facei] =
true;
1361 blockedFace.clear();
1372 forAll(cellToZone, celli)
1374 if (cellToZone[celli] != -2)
1376 regionToCellZone[cellRegion[celli]] = cellToZone[celli];
1392 Info<<
"Found point " << insidePoints[i]
1393 <<
" in global region " << regioninMeshi
1394 <<
" out of " << cellRegion.
nRegions() <<
" regions." <<
endl;
1396 if (regioninMeshi == -1)
1399 <<
"Point " << insidePoints[i]
1400 <<
" is not inside the mesh." <<
nl 1401 <<
"Bounding box of the mesh:" << mesh_.
bounds()
1406 if (regionToCellZone[regioninMeshi] == -2)
1408 regionToCellZone[regioninMeshi] = -1;
1428 bool changed =
false;
1434 const label surfi = namedSurfaceIndex[facei];
1441 const bool changedCell = calcRegionToZone
1443 surfaceToCellZone[surfi],
1449 changed = changed | changedCell;
1486 const label surfi = namedSurfaceIndex[facei];
1491 const bool changedCell = calcRegionToZone
1493 surfaceToCellZone[surfi],
1499 changed = changed | changedCell;
1512 forAll(regionToCellZone, regioni)
1514 const label zonei = regionToCellZone[regioni];
1519 <<
"For region " << regioni <<
" haven't set cell zone." 1526 forAll(regionToCellZone, regioni)
1528 Pout<<
"Region " << regioni
1529 <<
" becomes cellZone:" << regionToCellZone[regioni]
1535 forAll(cellToZone, celli)
1537 cellToZone[celli] = regionToCellZone[cellRegion[celli]];
1542 void Foam::meshRefinement::makeConsistentFaceIndex
1553 const label ownZone = cellToZone[faceOwner[facei]];
1554 const label neiZone = cellToZone[faceNeighbour[facei]];
1556 if (ownZone == neiZone && namedSurfaceIndex[facei] != -1)
1558 namedSurfaceIndex[facei] = -1;
1560 else if (ownZone != neiZone && namedSurfaceIndex[facei] == -1)
1563 <<
"Different cell zones on either side of face " << facei
1565 <<
" but face not marked with a surface." 1601 const label ownZone = cellToZone[faceOwner[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 " 1613 <<
" but face not marked with a surface." 1624 namedSurfaceIndex[facei] = -1;
1631 void Foam::meshRefinement::handleSnapProblems
1634 const bool useTopologicalSnapDetection,
1635 const bool removeEdgeConnectedCells,
1644 <<
"Introducing baffles to block off problem cells" <<
nl 1645 <<
"----------------------------------------------" <<
nl 1649 if (useTopologicalSnapDetection)
1651 facePatch = markFacesOnProblemCells
1654 removeEdgeConnectedCells,
1661 facePatch = markFacesOnProblemCellsGeometric(snapParams, motionDict);
1663 Info<<
"Analyzed problem cells in = " 1668 faceSet problemFaces(mesh_,
"problemFaces", mesh_.
nFaces()/100);
1672 if (facePatch[facei] != -1)
1674 problemFaces.insert(facei);
1677 problemFaces.instance() =
timeName();
1678 Pout<<
"Dumping " << problemFaces.size()
1679 <<
" problem faces to " << problemFaces.objectPath() <<
endl;
1680 problemFaces.
write();
1683 Info<<
"Introducing baffles to delete problem cells." <<
nl <<
endl;
1698 Info<<
"Created baffles in = " 1705 Pout<<
"Writing extra baffled mesh to time " 1711 runTime.
path()/
"extraBaffles" 1713 Pout<<
"Dumped debug data in = " 1749 if (faceToZone[facei] != -1)
1752 const label ownZone = cellToZone[faceOwner[facei]];
1753 const label neiZone = cellToZone[faceNeighbour[facei]];
1754 if (ownZone == neiZone)
1756 faceLabels.
append(facei);
1767 if (faceToZone[facei] != -1)
1770 const label ownZone = cellToZone[faceOwner[facei]];
1771 const label neiZone =
1774 if (ownZone == neiZone)
1776 faceLabels.
append(facei);
1781 return faceLabels.shrink();
1785 void Foam::meshRefinement::calcPatchNumMasterFaces
1794 nMasterFacesPerEdge = 0;
1796 forAll(patch.addressing(), facei)
1798 const label meshFacei = patch.addressing()[facei];
1800 if (isMasterFace[meshFacei])
1805 nMasterFacesPerEdge[fEdges[fEdgei]]++;
1814 nMasterFacesPerEdge,
1834 label nProtected = 0;
1836 forAll(nMasterFacesPerEdge, edgei)
1838 if (nMasterFacesPerEdge[edgei] > 2)
1840 allEdgeInfo[edgei] = -2;
1856 >::propagationTol();
1864 label currentZoneI = 0;
1870 for (; facei < allFaceInfo.size(); facei++)
1872 if (!allFaceInfo[facei].valid(dummyTrackData))
1874 globalSeed = globalFaces.toGlobal(facei);
1886 const label proci = globalFaces.whichProcID(globalSeed);
1887 const label seedFacei = globalFaces.toLocal(proci, globalSeed);
1898 faceInfo = currentZoneI;
1904 const label edgei = fEdges[fEdgei];
1922 changedEdges.
append(edgei);
1923 changedInfo.
append(edgeinfo);
1955 faceToZone.
setSize(patch.size());
1956 forAll(allFaceInfo, facei)
1958 if (!allFaceInfo[facei].valid(dummyTrackData))
1961 <<
"Problem: unvisited face " << facei
1965 faceToZone[facei] = allFaceInfo[facei].region();
1968 return currentZoneI;
1972 void Foam::meshRefinement::consistentOrientation
1992 label nProtected = 0;
1994 forAll(patch.addressing(), facei)
1996 const label meshFacei = patch.addressing()[facei];
2002 && bm[patchi].coupled()
2003 && !isMasterFace[meshFacei]
2013 label nProtected = 0;
2015 forAll(nMasterFacesPerEdge, edgei)
2017 if (nMasterFacesPerEdge[edgei] > 2)
2024 Info<<
"Protected from visiting " 2026 <<
" non-manifold edges" <<
nl <<
endl;
2038 >::propagationTol();
2048 forAll(allFaceInfo, facei)
2052 globalSeed = globalFaces.toGlobal(facei);
2064 const label proci = globalFaces.whichProcID(globalSeed);
2065 const label seedFacei = globalFaces.toLocal(proci, globalSeed);
2079 if (zoneToOrientation[faceToZone[seedFacei]] < 0)
2088 const label edgei = fEdges[fEdgei];
2106 changedEdges.
append(edgei);
2107 changedInfo.
append(edgeinfo);
2146 forAll(patch.addressing(), i)
2148 const label meshFacei = patch.addressing()[i];
2152 allFaceInfo[i].flipStatus();
2157 forAll(patch.addressing(), i)
2159 const label meshFacei = patch.addressing()[i];
2165 && bm[patchi].coupled()
2166 && !isMasterFace[meshFacei]
2183 <<
"Incorrect status for face " << meshFacei
2194 meshFlipMap =
false;
2196 forAll(allFaceInfo, facei)
2198 label meshFacei = patch.addressing()[facei];
2202 meshFlipMap[meshFacei] =
false;
2206 meshFlipMap[meshFacei] =
true;
2211 <<
"Problem : unvisited face " << facei
2223 const bool doHandleSnapProblems,
2225 const bool useTopologicalSnapDetection,
2226 const bool removeEdgeConnectedCells,
2228 const bool mergeFreeStanding,
2229 const scalar planarAngle,
2243 Info<<
"Introducing baffles for " 2245 <<
" faces that are intersected by the surface." <<
nl <<
endl;
2250 calcNeighbourData(neiLevel, neiCc);
2255 globalToMasterPatch,
2271 Info<<
"Created baffles in = " 2284 runTime.
path()/
"baffles" 2286 Pout<<
"Dumped debug data in = " 2296 if (doHandleSnapProblems)
2301 useTopologicalSnapDetection,
2302 removeEdgeConnectedCells,
2306 globalToMasterPatch,
2316 <<
"Remove unreachable sections of mesh" <<
nl 2317 <<
"-----------------------------------" <<
nl 2325 splitMeshRegions(globalToMasterPatch, globalToSlavePatch, selectionPoints);
2332 Info<<
"Split mesh in = " 2347 Pout<<
"Dumped debug data in = " 2355 if (mergeFreeStanding)
2358 <<
"Merge free-standing baffles" <<
nl 2359 <<
"---------------------------" <<
nl 2376 Info<<
"Detected free-standing baffles : " << nCouples <<
endl;
2390 useTopologicalSnapDetection,
2391 removeEdgeConnectedCells,
2395 globalToMasterPatch,
2405 Info<<
"Merged free-standing baffles in = " 2413 const label nBufferLayers,
2425 calcNeighbourData(neiLevel, neiCc);
2431 globalToMasterPatch,
2444 if (ownPatch[facei] != -1 || nbrPatch[facei] != -1)
2446 blockedFace[facei] =
true;
2453 blockedFace.clear();
2475 label defaultPatch = 0;
2476 if (globalToMasterPatch.
size())
2478 defaultPatch = globalToMasterPatch[0];
2481 for (
label i = 0; i < nBufferLayers; i++)
2487 forAll(faceNeighbour, facei)
2490 const label ownRegion = cellRegion[faceOwner[facei]];
2491 const label neiRegion = cellRegion[faceNeighbour[facei]];
2493 if (ownRegion == -1 && neiRegion != -1)
2500 pointBaffle[f[fp]] =
max(defaultPatch, ownPatch[facei]);
2503 else if (ownRegion != -1 && neiRegion == -1)
2505 label newPatchi = nbrPatch[facei];
2506 if (newPatchi == -1)
2508 newPatchi =
max(defaultPatch, ownPatch[facei]);
2512 pointBaffle[f[fp]] = newPatchi;
2525 const label ownRegion = cellRegion[faceOwner[facei]];
2527 if (ownRegion == -1)
2531 pointBaffle[f[fp]] =
max(defaultPatch, ownPatch[facei]);
2550 forAll(pointFaces, pointi)
2552 if (pointBaffle[pointi] != -1)
2558 const label facei = pFaces[pFacei];
2560 if (ownPatch[facei] == -1)
2562 ownPatch[facei] = pointBaffle[pointi];
2576 if (ownPatch[facei] != -1)
2578 const label own = faceOwner[facei];
2580 if (cellRegion[own] == -1)
2584 const cell& ownFaces = mesh_.
cells()[own];
2587 if (ownPatch[ownFaces[j]] == -1)
2589 newOwnPatch[ownFaces[j]] = ownPatch[facei];
2595 const label nei = faceNeighbour[facei];
2597 if (cellRegion[nei] == -1)
2601 const cell& neiFaces = mesh_.
cells()[nei];
2604 if (ownPatch[neiFaces[j]] == -1)
2606 newOwnPatch[neiFaces[j]] = ownPatch[facei];
2626 forAll(cellRegion, celli)
2628 if (cellRegion[celli] == -1)
2630 cellsToRemove.append(celli);
2633 cellsToRemove.shrink();
2635 label nCellsInMesh = mesh_.
nCells() - cellsToRemove.size();
2638 Info<<
"Selecting all cells in regions containing any of the points in " 2640 <<
"Selected: " << nCellsInMesh <<
" cells." <<
endl;
2648 labelList exposedPatches(exposedFaces.size());
2652 const label facei = exposedFaces[i];
2654 if (ownPatch[facei] != -1)
2656 exposedPatches[i] = ownPatch[facei];
2661 <<
"For exposed face " << facei
2663 <<
" found no patch." << endl
2664 <<
" Taking patch " << defaultPatch
2665 <<
" instead." <<
endl;
2666 exposedPatches[i] = defaultPatch;
2670 return doRemoveCells
2695 Info<<
"dupNonManifoldPoints : Found : " << nNonManifPoints
2696 <<
" non-manifold points (out of " 2715 if (map().hasMotionPoints())
2749 const bool allowFreeStandingZoneFaces
2761 label surfi = namedSurfaces[i];
2763 Info<<
"Surface : " << surfaces_.
names()[surfi] <<
nl 2764 <<
" faceZone : " << surfZones[surfi].faceZoneName() <<
nl 2765 <<
" cellZone : " << surfZones[surfi].cellZoneName() <<
endl;
2796 calcNeighbourData(neiLevel, neiCc);
2829 label facei = testFaces[i];
2833 start[i] = cellCentres[faceOwner[facei]];
2834 end[i] = cellCentres[faceNeighbour[facei]];
2838 start[i] = cellCentres[faceOwner[facei]];
2845 const vectorField smallVec(rootSmall*(end-start));
2885 label facei = testFaces[i];
2888 if (surface1[i] != -1)
2895 magSqr(hit2[i].hitPoint())
2896 <
magSqr(hit1[i].hitPoint())
2900 namedSurfaceIndex[facei] = surface2[i];
2901 posOrientation[facei] = ((area&normal2[i]) > 0);
2902 nSurfFaces[surface2[i]]++;
2906 namedSurfaceIndex[facei] = surface1[i];
2907 posOrientation[facei] = ((area&normal1[i]) > 0);
2908 nSurfFaces[surface1[i]]++;
2911 else if (surface2[i] != -1)
2913 namedSurfaceIndex[facei] = surface2[i];
2914 posOrientation[facei] = ((area&normal2[i]) > 0);
2915 nSurfFaces[surface2[i]]++;
2934 forAll(nSurfFaces, surfi)
2937 << surfaces_.
names()[surfi]
2938 <<
" nZoneFaces:" << nSurfFaces[surfi] <<
nl;
2969 if (closedNamedSurfaces.size())
2971 Info<<
"Found " << closedNamedSurfaces.size()
2972 <<
" closed, named surfaces. Assigning cells in/outside" 2973 <<
" these surfaces to the corresponding cellZone." 2976 findCellZoneGeometric
2979 closedNamedSurfaces,
2996 if (locationSurfaces.
size())
2998 Info<<
"Found " << locationSurfaces.
size()
2999 <<
" named surfaces with a provided inside point." 3000 <<
" Assigning cells inside these surfaces" 3001 <<
" to the corresponding cellZone." 3004 findCellZoneInsideWalk
3019 Info<<
"Walking from locations-in-mesh " << insidePoints
3020 <<
" to assign cellZones " 3021 <<
"- crossing a faceZone face changes cellZone" <<
nl <<
endl;
3036 if (!allowFreeStandingZoneFaces)
3038 Info<<
"Only selecting zone faces in between different cellZones." 3041 makeConsistentFaceIndex(cellToZone, namedSurfaceIndex);
3051 forAll(namedSurfaceIndex, facei)
3053 const label surfi = namedSurfaceIndex[facei];
3056 faceToZone[facei] = surfaceToFaceZone[surfi];
3078 neiCellZone[bFacei++] = -1;
3108 freeStandingBaffleFaces
3119 if (nFreeStanding > 0)
3121 Info<<
"Detected " << nFreeStanding <<
" free-standing zone faces" 3133 calcPatchNumMasterFaces(isMasterFace, patch, nMasterFacesPerEdge);
3138 const label nZones = markPatchZones
3141 nMasterFacesPerEdge,
3146 for (
label zonei = 0; zonei < nZones; zonei++)
3148 nPosOrientation.
insert(zonei, 0);
3154 consistentOrientation
3158 nMasterFacesPerEdge,
3159 faceToConnectedZone,
3167 forAll(patch.addressing(), facei)
3169 label meshFacei = patch.addressing()[facei];
3171 if (isMasterFace[meshFacei])
3176 bool(posOrientation[meshFacei])
3177 == meshFlipMap[meshFacei]
3183 nPosOrientation.
find(faceToConnectedZone[facei])() += n;
3190 Info<<
"Split " << nFreeStanding <<
" free-standing zone faces" 3191 <<
" into " << nZones <<
" disconnected regions with size" 3192 <<
" (negative denotes wrong orientation) :" 3195 for (
label zonei = 0; zonei < nZones; zonei++)
3197 Info<<
" " << zonei <<
"\t" << nPosOrientation[zonei]
3205 consistentOrientation
3209 nMasterFacesPerEdge,
3210 faceToConnectedZone,
3224 label faceZoneI = faceToZone[facei];
3226 if (faceZoneI != -1)
3232 const label ownZone = cellToZone[faceOwner[facei]];
3233 const label neiZone = cellToZone[faceNeighbour[facei]];
3237 if (ownZone == neiZone)
3240 flip = meshFlipMap[facei];
3247 || (neiZone != -1 && ownZone > neiZone)
3255 mesh_.
faces()[facei],
3258 faceNeighbour[facei],
3279 const label faceZoneI = faceToZone[facei];
3281 if (faceZoneI != -1)
3283 const label ownZone = cellToZone[faceOwner[facei]];
3288 if (ownZone == neiZone)
3291 flip = meshFlipMap[facei];
3298 || (neiZone != -1 && ownZone > neiZone)
3306 mesh_.
faces()[facei],
3326 forAll(cellToZone, celli)
3328 const label zonei = cellToZone[celli];
3353 if (map().hasMotionPoints())
const fvPatchList & patches
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
This class separates the mesh into distinct unconnected regions, each of which is then given a label ...
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.
autoPtr< polyTopoChangeMap > 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.
void checkZoneFaces() const
Debug helper: check faceZones are not on processor patches.
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
virtual Ostream & write(const char)=0
Write character.
FvWallInfoData< WallInfo, label > 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.
autoPtr< polyTopoChangeMap > createBaffles(const labelList &ownPatch, const labelList &nbrPatch)
Create baffle for every internal face where ownPatch != -1.
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...
const labelListList & faceEdges() const
autoPtr< polyTopoChangeMap > zonify(const List< point > &insidePoints, const bool allowFreeStandingZoneFaces)
Put faces/cells into zones according to surface specification.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
const Field< PointType > & faceCentres() const
Return face centres for patch.
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object of type.
label nInternalFaces() const
virtual const labelList & faceNeighbour() const
Return face neighbour.
const labelIOList & tetBasePtIs() const
Return the tetBasePtIs.
const labelListList & pointEdges() const
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 topoChange(const polyTopoChangeMap &, const labelList &changedFaces)
Update for external change to mesh. changedFaces are in new mesh.
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< polyTopoChangeMap > dupNonManifoldPoints()
Find boundary points that connect to more than one cell.
labelList intersectedFaces() const
Get faces with intersection.
static writeType writeLevel()
Get/set write level.
Holds information (coordinate and normal) regarding nearest wall point.
autoPtr< polyTopoChangeMap > createZoneBaffles(const labelList &globalToMasterPatch, const labelList &globalToSlavePatch, List< labelPair > &)
Create baffles for faces straddling zoned surfaces. Return.
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)
const cellList & cells() const
label whichFace(const label globalCellID) const
Helper function to re-direct to zone::localID(...)
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.
virtual void topoChange(const polyTopoChangeMap &map)
Update mesh corresponding to the given map.
autoPtr< polyTopoChangeMap > splitMesh(const label nBufferLayers, const labelList &globalToMasterPatch, const labelList &globalToSlavePatch, const refinementParameters::cellSelectionPoints &selectionPoints)
Split off (with optional buffer layers) unreachable areas.
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)
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.
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.
const List< point > & inside() const
Return the points inside the surface regions to selected cells.
Calculates a unique integer (label so might not have enough room - 2G max) for processor + local inde...
vectorField pointField
pointField is a vectorField.
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)
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects...
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)
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 > &)
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 globalRegion(const label surfi, const label regioni) const
From surface and region on surface to global region.
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 refinementParameters::cellSelectionPoints &selectionPoints)
Split off unreachable areas of mesh.
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurrence of given element and return index,.
MeshZones< faceZone, polyMesh > meshFaceZones
A MeshZones with the type faceZone.
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
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.
const wordList & names() const
Names of surfaces.
autoPtr< polyTopoChangeMap > splitMeshRegions(const labelList &globalToMasterPatch, const labelList &globalToSlavePatch, const refinementParameters::cellSelectionPoints &selectionPoints)
Split mesh according to selectionPoints.
#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 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 const Vector< scalar > one
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 > &)
static void findRegions(const polyMesh &, labelList &cellRegion, const vector &perturbVec, const refinementParameters::cellSelectionPoints &selectionPoints)
Find regions points are in and update cellRegion.
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.
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.
autoPtr< polyTopoChangeMap > mergeBaffles(const List< labelPair > &)
Merge baffles. Gets pairs of faces.
fileName path() const
Return path.
static label findRegion(const polyMesh &, const labelList &cellRegion, const vector &perturbVec, const point &location)
Find region point is in. Uses optional perturbation to re-test.
const Type & first() const
Return first.
label whichPatch(const label faceIndex) const
Return patch index for a given face label.
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.
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.
Class to hold the points to select cells inside and outside.
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.