89 return less(values_[a], values_[
b]);
126 const mapPolyMesh& map,
130 const polyMesh&
mesh = map.mesh();
135 label nMasterChanged = 0;
153 bitSet oldRefineCell(map.nOldCells(), oldCellsToRefine);
156 bitSet refinedInternalFace(nInternalFaces);
160 for (label faceI = 0; faceI < nInternalFaces; faceI++)
162 label oldOwn = map.cellMap()[faceOwner[faceI]];
163 label oldNei = map.cellMap()[faceNeighbour[faceI]];
167 oldOwn >= 0 && !oldRefineCell.test(oldOwn)
168 && oldNei >= 0 && !oldRefineCell.test(oldNei)
175 refinedInternalFace.set(faceI);
188 label faceI = pp.
start();
192 label oldOwn = map.cellMap()[faceOwner[faceI]];
194 if (oldOwn >= 0 && !oldRefineCell.test(oldOwn))
200 refinedBoundaryFace[faceI-nInternalFaces] =
true;
220 forAll(refinedInternalFace, faceI)
222 if (refinedInternalFace.test(faceI))
224 const cell& ownFaces =
cells[faceOwner[faceI]];
227 changedFace[ownFaces[ownI]] =
true;
229 const cell& neiFaces =
cells[faceNeighbour[faceI]];
232 changedFace[neiFaces[neiI]] =
true;
237 forAll(refinedBoundaryFace, i)
239 if (refinedBoundaryFace[i])
241 const cell& ownFaces =
cells[faceOwner[i+nInternalFaces]];
244 changedFace[ownFaces[ownI]] =
true;
265 forAll(changedFace, faceI)
267 if (changedFace[faceI] && isMasterFace.test(faceI))
277 Pout<<
"getChangedFaces : Detected "
278 <<
" local:" << changedFaces.size()
279 <<
" global:" <<
returnReduce(nMasterChanged, sumOp<label>())
283 faceSet changedFacesSet(
mesh,
"changedFaces", changedFaces);
284 Pout<<
"getChangedFaces : Writing " << changedFaces.size()
285 <<
" changed faces to faceSet " << changedFacesSet.
name()
287 changedFacesSet.
write();
297 bool Foam::meshRefinement::markForRefine
299 const label markValue,
300 const label nAllowRefine,
308 cellValue = markValue;
312 return nRefine <= nAllowRefine;
316 void Foam::meshRefinement::markFeatureCellLevel
338 Cloud<trackedParticle> startPointCloud
342 IDLList<trackedParticle>()
350 for (
const point& keepPoint : keepPoints)
352 const label celli = mesh_.cellTree().findInside(keepPoint);
360 const edgeMesh& featureMesh = features_[feati];
361 const label featureLevel = features_.levels()[feati][0];
366 label nRegions = featureMesh.regions(edgeRegion);
369 bitSet regionVisited(nRegions);
375 forAll(pointEdges, pointi)
377 if (pointEdges[pointi].size() != 2)
381 Pout<<
"Adding particle from point:" << pointi
382 <<
" coord:" << featureMesh.points()[pointi]
383 <<
" since number of emanating edges:"
384 << pointEdges[pointi].size()
389 startPointCloud.addParticle
396 featureMesh.points()[pointi],
405 if (pointEdges[pointi].size() > 0)
407 label e0 = pointEdges[pointi][0];
408 label regioni = edgeRegion[e0];
409 regionVisited.set(regioni);
417 forAll(featureMesh.edges(), edgei)
419 if (regionVisited.set(edgeRegion[edgei]))
421 const edge&
e = featureMesh.edges()[edgei];
422 label pointi =
e.start();
425 Pout<<
"Adding particle from point:" << pointi
426 <<
" coord:" << featureMesh.points()[pointi]
427 <<
" on circular region:" << edgeRegion[edgei]
432 startPointCloud.addParticle
439 featureMesh.points()[pointi],
454 maxFeatureLevel =
labelList(mesh_.nCells(), -1);
457 List<bitSet> featureEdgeVisited(features_.size());
461 featureEdgeVisited[featI].setSize(features_[featI].edges().size());
462 featureEdgeVisited[featI] =
false;
466 trackedParticle::trackingData td
477 scalar maxTrackLen = 2.0*mesh_.bounds().mag();
481 Pout<<
"Tracking " << startPointCloud.size()
482 <<
" particles over distance " << maxTrackLen
483 <<
" to find the starting cell" <<
endl;
485 startPointCloud.move(startPointCloud, td, maxTrackLen);
489 maxFeatureLevel = -1;
492 featureEdgeVisited[featI] =
false;
496 Cloud<trackedParticle> cloud
500 IDLList<trackedParticle>()
505 Pout<<
"Constructing cloud for cell marking" <<
endl;
508 for (
const trackedParticle& startTp : startPointCloud)
510 const label featI = startTp.i();
511 const label pointI = startTp.j();
513 const edgeMesh& featureMesh = features_[featI];
514 const labelList& pEdges = featureMesh.pointEdges()[pointI];
519 label edgeI = pEdges[pEdgeI];
521 if (featureEdgeVisited[featI].set(edgeI))
526 const edge&
e = featureMesh.edges()[edgeI];
527 label otherPointi =
e.otherVertex(pointI);
529 trackedParticle* tp(
new trackedParticle(startTp));
530 tp->start() = tp->position();
531 tp->end() = featureMesh.points()[otherPointi];
532 tp->j() = otherPointi;
537 Pout<<
"Adding particle for point:" << pointI
538 <<
" coord:" << tp->position()
539 <<
" feature:" << featI
540 <<
" to track to:" << tp->end()
544 cloud.addParticle(tp);
549 startPointCloud.clear();
557 Pout<<
"Tracking " << cloud.size()
558 <<
" particles over distance " << maxTrackLen
559 <<
" to mark cells" <<
endl;
561 cloud.move(cloud, td, maxTrackLen);
564 for (trackedParticle& tp : cloud)
566 const label featI = tp.i();
567 const label pointI = tp.j();
569 const edgeMesh& featureMesh = features_[featI];
570 const labelList& pEdges = featureMesh.pointEdges()[pointI];
575 bool keepParticle =
false;
579 label edgeI = pEdges[i];
581 if (featureEdgeVisited[featI].set(edgeI))
586 const edge&
e = featureMesh.edges()[edgeI];
587 label otherPointi =
e.otherVertex(pointI);
589 tp.start() = tp.position();
590 tp.end() = featureMesh.points()[otherPointi];
591 tp.j() = otherPointi;
602 cloud.deleteParticle(tp);
609 Pout<<
"Remaining particles " << cloud.size() <<
endl;
637 Foam::label Foam::meshRefinement::markFeatureRefinement
640 const label nAllowRefine,
648 markFeatureCellLevel(keepPoints, maxFeatureLevel);
653 const labelList& cellLevel = meshCutter_.cellLevel();
655 label oldNRefine = nRefine;
657 forAll(maxFeatureLevel, cellI)
659 if (maxFeatureLevel[cellI] > cellLevel[cellI])
685 Info<<
"Reached refinement limit." <<
endl;
688 return returnReduce(nRefine-oldNRefine, sumOp<label>());
693 Foam::label Foam::meshRefinement::markInternalDistanceToFeatureRefinement
695 const label nAllowRefine,
701 const labelList& cellLevel = meshCutter_.cellLevel();
702 const pointField& cellCentres = mesh_.cellCentres();
705 if (features_.maxDistance() <= 0.0)
710 label oldNRefine = nRefine;
714 labelList testLevels(cellLevel.size()-nRefine);
719 if (refineCell[cellI] == -1)
721 testCc[testI] = cellCentres[cellI];
722 testLevels[testI] = cellLevel[cellI];
729 features_.findHigherLevel(testCc, testLevels, maxLevel);
736 if (refineCell[cellI] == -1)
738 if (maxLevel[testI] > testLevels[testI])
740 bool reachedLimit = !markForRefine
752 Pout<<
"Stopped refining internal cells"
753 <<
" since reaching my cell limit of "
754 << mesh_.nCells()+7*nRefine <<
endl;
769 Info<<
"Reached refinement limit." <<
endl;
772 return returnReduce(nRefine-oldNRefine, sumOp<label>());
777 Foam::label Foam::meshRefinement::markInternalRefinement
779 const label nAllowRefine,
785 const labelList& cellLevel = meshCutter_.cellLevel();
786 const pointField& cellCentres = mesh_.cellCentres();
788 label oldNRefine = nRefine;
792 labelList testLevels(cellLevel.size()-nRefine);
797 if (refineCell[cellI] == -1)
799 testCc[testI] = cellCentres[cellI];
800 testLevels[testI] = cellLevel[cellI];
807 shells_.findHigherLevel(testCc, testLevels, maxLevel);
814 if (refineCell[cellI] == -1)
816 if (maxLevel[testI] > testLevels[testI])
818 bool reachedLimit = !markForRefine
830 Pout<<
"Stopped refining internal cells"
831 <<
" since reaching my cell limit of "
832 << mesh_.nCells()+7*nRefine <<
endl;
847 Info<<
"Reached refinement limit." <<
endl;
850 return returnReduce(nRefine-oldNRefine, sumOp<label>());
854 Foam::label Foam::meshRefinement::unmarkInternalRefinement
860 const labelList& cellLevel = meshCutter_.cellLevel();
861 const pointField& cellCentres = mesh_.cellCentres();
863 label oldNRefine = nRefine;
872 if (refineCell[cellI] >= 0)
874 testCc[testI] = cellCentres[cellI];
875 testLevels[testI] = cellLevel[cellI];
882 limitShells_.findLevel(testCc, testLevels, levelShell);
889 if (refineCell[cellI] >= 0)
891 if (levelShell[testI] != -1)
893 refineCell[cellI] = -1;
900 return returnReduce(oldNRefine-nRefine, sumOp<label>());
915 const labelList& surfIndex = surfaceIndex();
919 if (surfIndex[faceI] != -1)
921 label own = mesh_.faceOwner()[faceI];
923 if (mesh_.isInternalFace(faceI))
925 label nei = mesh_.faceNeighbour()[faceI];
927 if (refineCell[own] == -1 || refineCell[nei] == -1)
929 testFaces[nTest++] = faceI;
934 if (refineCell[own] == -1)
936 testFaces[nTest++] = faceI;
941 testFaces.setSize(nTest);
948 Foam::label Foam::meshRefinement::markSurfaceRefinement
950 const label nAllowRefine,
958 const labelList& cellLevel = meshCutter_.cellLevel();
960 label oldNRefine = nRefine;
968 labelList testFaces(getRefineCandidateFaces(refineCell));
993 surfaces_.findHigherIntersection
1010 label faceI = testFaces[i];
1012 label surfI = surfaceHit[i];
1022 label own = mesh_.faceOwner()[faceI];
1024 if (surfaceMinLevel[i] > cellLevel[own])
1042 if (mesh_.isInternalFace(faceI))
1044 label nei = mesh_.faceNeighbour()[faceI];
1045 if (surfaceMinLevel[i] > cellLevel[nei])
1072 Info<<
"Reached refinement limit." <<
endl;
1075 return returnReduce(nRefine-oldNRefine, sumOp<label>());
1080 Foam::label Foam::meshRefinement::countMatches
1082 const List<point>& normals1,
1083 const List<point>& normals2,
1091 const vector& n1 = normals1[i];
1095 const vector& n2 = normals2[j];
1110 Foam::label Foam::meshRefinement::markSurfaceCurvatureRefinement
1112 const scalar curvature,
1113 const label nAllowRefine,
1121 const labelList& cellLevel = meshCutter_.cellLevel();
1122 const pointField& cellCentres = mesh_.cellCentres();
1124 label oldNRefine = nRefine;
1138 labelList testFaces(getRefineCandidateFaces(refineCell));
1148 label faceI = testFaces[i];
1150 label own = mesh_.faceOwner()[faceI];
1152 if (mesh_.isInternalFace(faceI))
1154 label nei = mesh_.faceNeighbour()[faceI];
1156 start[i] = cellCentres[own];
1157 end[i] = cellCentres[nei];
1158 minLevel[i] =
min(cellLevel[own], cellLevel[nei]);
1162 label bFaceI = faceI - mesh_.nInternalFaces();
1164 start[i] = cellCentres[own];
1165 end[i] = neiCc[bFaceI];
1167 if (!isMasterFace[faceI])
1172 minLevel[i] =
min(cellLevel[own], neiLevel[bFaceI]);
1187 List<vectorList> cellSurfNormals(mesh_.nCells());
1191 List<vectorList> surfaceNormal;
1195 surfaces_.findAllIntersections
1202 labelList(surfaces_.maxLevel().size(), 0),
1203 surfaces_.maxLevel(),
1214 forAll(surfaceNormal, pointI)
1216 vectorList& pNormals = surfaceNormal[pointI];
1217 labelList& pLevel = surfaceLevel[pointI];
1219 sortedOrder(pNormals, visitOrder, normalLess(pNormals));
1221 pNormals = List<point>(pNormals, visitOrder);
1233 label faceI = testFaces[i];
1234 label own = mesh_.faceOwner()[faceI];
1236 const vectorList& fNormals = surfaceNormal[i];
1237 const labelList& fLevels = surfaceLevel[i];
1241 if (fLevels[hitI] > cellLevel[own])
1243 cellSurfLevels[own].append(fLevels[hitI]);
1244 cellSurfNormals[own].append(fNormals[hitI]);
1247 if (mesh_.isInternalFace(faceI))
1249 label nei = mesh_.faceNeighbour()[faceI];
1250 if (fLevels[hitI] > cellLevel[nei])
1252 cellSurfLevels[nei].append(fLevels[hitI]);
1253 cellSurfNormals[nei].append(fNormals[hitI]);
1267 forAll(cellSurfNormals, cellI)
1269 const vectorList& normals = cellSurfNormals[cellI];
1273 nNormals += normals.size();
1276 reduce(nSet, sumOp<label>());
1277 reduce(nNormals, sumOp<label>());
1278 Info<<
"markSurfaceCurvatureRefinement :"
1279 <<
" cells:" << mesh_.globalData().nTotalCells()
1280 <<
" of which with normals:" << nSet
1281 <<
" ; total normals stored:" << nNormals
1287 bool reachedLimit =
false;
1296 !reachedLimit && cellI < cellSurfNormals.size();
1300 const vectorList& normals = cellSurfNormals[cellI];
1301 const labelList& levels = cellSurfLevels[cellI];
1304 for (label i = 0; !reachedLimit && i < normals.size(); i++)
1306 for (label j = i+1; !reachedLimit && j < normals.size(); j++)
1308 if ((normals[i] & normals[j]) < curvature)
1310 label maxLevel =
max(levels[i], levels[j]);
1312 if (cellLevel[cellI] < maxLevel)
1327 Pout<<
"Stopped refining since reaching my cell"
1328 <<
" limit of " << mesh_.nCells()+7*nRefine
1331 reachedLimit =
true;
1351 !reachedLimit && faceI < mesh_.nInternalFaces();
1355 label own = mesh_.faceOwner()[faceI];
1356 label nei = mesh_.faceNeighbour()[faceI];
1358 const vectorList& ownNormals = cellSurfNormals[own];
1359 const labelList& ownLevels = cellSurfLevels[own];
1360 const vectorList& neiNormals = cellSurfNormals[nei];
1361 const labelList& neiLevels = cellSurfLevels[nei];
1369 countMatches(ownNormals, neiNormals)
1370 == ownNormals.size();
1373 countMatches(neiNormals, ownNormals)
1374 == neiNormals.size();
1377 if (!ownIsSubset && !neiIsSubset)
1380 for (label i = 0; !reachedLimit && i < ownNormals.size(); i++)
1382 for (label j = 0; !reachedLimit && j < neiNormals.size(); j++)
1385 if ((ownNormals[i] & neiNormals[j]) < curvature)
1388 if (cellLevel[own] < ownLevels[i])
1403 Pout<<
"Stopped refining since reaching"
1404 <<
" my cell limit of "
1405 << mesh_.nCells()+7*nRefine <<
endl;
1407 reachedLimit =
true;
1411 if (cellLevel[nei] < neiLevels[j])
1426 Pout<<
"Stopped refining since reaching"
1427 <<
" my cell limit of "
1428 << mesh_.nCells()+7*nRefine <<
endl;
1430 reachedLimit =
true;
1442 List<vectorList> neiSurfaceNormals;
1448 label faceI = mesh_.nInternalFaces();
1449 !reachedLimit && faceI < mesh_.nFaces();
1453 label own = mesh_.faceOwner()[faceI];
1454 label bFaceI = faceI - mesh_.nInternalFaces();
1456 const vectorList& ownNormals = cellSurfNormals[own];
1457 const labelList& ownLevels = cellSurfLevels[own];
1458 const vectorList& neiNormals = neiSurfaceNormals[bFaceI];
1465 countMatches(ownNormals, neiNormals)
1466 == ownNormals.size();
1469 countMatches(neiNormals, ownNormals)
1470 == neiNormals.size();
1473 if (!ownIsSubset && !neiIsSubset)
1476 for (label i = 0; !reachedLimit && i < ownNormals.size(); i++)
1478 for (label j = 0; !reachedLimit && j < neiNormals.size(); j++)
1481 if ((ownNormals[i] & neiNormals[j]) < curvature)
1483 if (cellLevel[own] < ownLevels[i])
1498 Pout<<
"Stopped refining since reaching"
1499 <<
" my cell limit of "
1500 << mesh_.nCells()+7*nRefine
1503 reachedLimit =
true;
1520 Info<<
"Reached refinement limit." <<
endl;
1523 return returnReduce(nRefine-oldNRefine, sumOp<label>());
1529 const scalar planarCos,
1539 vector d = point1-point0;
1540 scalar magD =
mag(d);
1542 if (magD > mergeDistance())
1544 scalar cosAngle = (normal0 & normal1);
1547 if (cosAngle < (-1+planarCos))
1550 avg = 0.5*(normal0-normal1);
1552 else if (cosAngle > (1-planarCos))
1554 avg = 0.5*(normal0+normal1);
1562 if (
mag(avg&d) > mergeDistance())
1576 const scalar planarCos,
1590 vector d = point1-point0;
1591 scalar magD =
mag(d);
1593 if (magD > mergeDistance())
1595 scalar cosAngle = (normal0 & normal1);
1598 if (cosAngle < (-1+planarCos))
1601 avgNormal = 0.5*(normal0-normal1);
1603 else if (cosAngle > (1-planarCos))
1605 avgNormal = 0.5*(normal0+normal1);
1610 avgNormal /=
mag(avgNormal);
1632 bool Foam::meshRefinement::checkProximity
1634 const scalar planarCos,
1635 const label nAllowRefine,
1637 const label surfaceLevel,
1639 const vector& surfaceNormal,
1643 label& cellMaxLevel,
1651 const labelList& cellLevel = meshCutter_.cellLevel();
1654 if (surfaceLevel > cellLevel[cellI])
1656 if (cellMaxLevel == -1)
1659 cellMaxLevel = surfaceLevel;
1661 cellMaxNormal = surfaceNormal;
1670 bool closeSurfaces = isNormalGap
1683 if (surfaceLevel > cellMaxLevel)
1685 cellMaxLevel = surfaceLevel;
1686 cellMaxLocation = surfaceLocation;
1687 cellMaxNormal = surfaceNormal;
1701 return markForRefine
1717 Foam::label Foam::meshRefinement::markProximityRefinement
1719 const scalar planarCos,
1724 const label nAllowRefine,
1732 const labelList& cellLevel = meshCutter_.cellLevel();
1734 label oldNRefine = nRefine;
1745 const labelList testFaces(getRefineCandidateFaces(refineCell));
1766 labelList cellMaxLevel(mesh_.nCells(), -1);
1772 List<vectorList> surfaceLocation;
1773 List<vectorList> surfaceNormal;
1777 surfaces_.findAllIntersections
1815 label faceI = testFaces[i];
1816 label own = mesh_.faceOwner()[faceI];
1818 const labelList& fLevels = surfaceLevel[i];
1819 const vectorList& fPoints = surfaceLocation[i];
1820 const vectorList& fNormals = surfaceNormal[i];
1835 cellMaxLocation[own],
1843 if (mesh_.isInternalFace(faceI))
1845 label nei = mesh_.faceNeighbour()[faceI];
1860 cellMaxLocation[nei],
1874 labelList neiBndMaxLevel(mesh_.nBoundaryFaces());
1875 pointField neiBndMaxLocation(mesh_.nBoundaryFaces());
1876 vectorField neiBndMaxNormal(mesh_.nBoundaryFaces());
1878 for (label faceI = mesh_.nInternalFaces(); faceI < mesh_.nFaces(); faceI++)
1880 label bFaceI = faceI-mesh_.nInternalFaces();
1881 label own = mesh_.faceOwner()[faceI];
1883 neiBndMaxLevel[bFaceI] = cellMaxLevel[own];
1884 neiBndMaxLocation[bFaceI] = cellMaxLocation[own];
1885 neiBndMaxNormal[bFaceI] = cellMaxNormal[own];
1894 for (label faceI = 0; faceI < mesh_.nInternalFaces(); faceI++)
1896 label own = mesh_.faceOwner()[faceI];
1897 label nei = mesh_.faceNeighbour()[faceI];
1899 if (cellMaxLevel[own] != -1 && cellMaxLevel[nei] != -1)
1908 cellMaxLocation[own],
1911 cellMaxLocation[nei],
1917 if (cellLevel[own] < cellMaxLevel[own])
1932 Pout<<
"Stopped refining since reaching my cell"
1933 <<
" limit of " << mesh_.nCells()+7*nRefine
1940 if (cellLevel[nei] < cellMaxLevel[nei])
1955 Pout<<
"Stopped refining since reaching my cell"
1956 <<
" limit of " << mesh_.nCells()+7*nRefine
1966 for (label faceI = mesh_.nInternalFaces(); faceI < mesh_.nFaces(); faceI++)
1968 label own = mesh_.faceOwner()[faceI];
1969 label bFaceI = faceI - mesh_.nInternalFaces();
1971 if (cellLevel[own] < cellMaxLevel[own] && neiBndMaxLevel[bFaceI] != -1)
1980 cellMaxLocation[own],
1983 neiBndMaxLocation[bFaceI],
1984 neiBndMaxNormal[bFaceI]
2001 Pout<<
"Stopped refining since reaching my cell"
2002 <<
" limit of " << mesh_.nCells()+7*nRefine
2017 Info<<
"Reached refinement limit." <<
endl;
2020 return returnReduce(nRefine-oldNRefine, sumOp<label>());
2034 const scalar curvature,
2035 const scalar planarAngle,
2037 const bool featureRefinement,
2038 const bool featureDistanceRefinement,
2039 const bool internalRefinement,
2040 const bool surfaceRefinement,
2041 const bool curvatureRefinement,
2042 const bool smallFeatureRefinement,
2043 const bool gapRefinement,
2044 const bool bigGapRefinement,
2045 const bool spreadGapSize,
2046 const label maxGlobalCells,
2047 const label maxLocalCells
2050 label totNCells = mesh_.globalData().nTotalCells();
2054 if (totNCells >= maxGlobalCells)
2056 Info<<
"No cells marked for refinement since reached limit "
2057 << maxGlobalCells <<
'.' <<
endl;
2091 labelList neiLevel(mesh_.nFaces()-mesh_.nInternalFaces());
2092 pointField neiCc(mesh_.nFaces()-mesh_.nInternalFaces());
2093 calcNeighbourData(neiLevel, neiCc);
2102 if (featureRefinement)
2104 label nFeatures = markFeatureRefinement
2113 Info<<
"Marked for refinement due to explicit features "
2114 <<
": " << nFeatures <<
" cells." <<
endl;
2120 if (featureDistanceRefinement)
2122 label nShell = markInternalDistanceToFeatureRefinement
2129 Info<<
"Marked for refinement due to distance to explicit features "
2130 ": " << nShell <<
" cells." <<
endl;
2136 if (internalRefinement)
2138 label nShell = markInternalRefinement
2145 Info<<
"Marked for refinement due to refinement shells "
2146 <<
": " << nShell <<
" cells." <<
endl;
2152 if (surfaceRefinement)
2154 label nSurf = markSurfaceRefinement
2163 Info<<
"Marked for refinement due to surface intersection "
2164 <<
": " << nSurf <<
" cells." <<
endl;
2172 &&
max(shells_.maxGapLevel()) > 0
2175 label nGapSurf = markSurfaceGapRefinement
2185 Info<<
"Marked for refinement due to surface intersection"
2187 <<
": " << nGapSurf <<
" cells." <<
endl;
2197 && (curvature >= -1 && curvature <= 1)
2198 && (surfaces_.minLevel() != surfaces_.maxLevel())
2201 label nCurv = markSurfaceCurvatureRefinement
2211 Info<<
"Marked for refinement due to curvature/regions "
2212 <<
": " << nCurv <<
" cells." <<
endl;
2221 smallFeatureRefinement
2222 && (planarCos >= -1 && planarCos <= 1)
2223 &&
max(shells_.maxGapLevel()) > 0
2226 label nGap = markSmallFeatureRefinement
2236 Info<<
"Marked for refinement due to close opposite surfaces "
2237 <<
": " << nGap <<
" cells." <<
endl;
2244 const labelList& surfaceGapLevel = surfaces_.gapLevel();
2249 && (planarCos >= -1 && planarCos <= 1)
2250 && (
max(surfaceGapLevel) > -1)
2253 Info<<
"Specified gap level : " <<
max(surfaceGapLevel)
2254 <<
", planar angle " << planarAngle <<
endl;
2256 label nGap = markProximityRefinement
2270 Info<<
"Marked for refinement due to close opposite surfaces "
2271 <<
": " << nGap <<
" cells." <<
endl;
2281 && (planarCos >= -1 && planarCos <= 1)
2282 &&
max(shells_.maxGapLevel()) > 0
2289 label nGap = markInternalGapRefinement
2300 Info<<
"Marked for refinement due to opposite surfaces"
2302 <<
": " << nGap <<
" cells." <<
endl;
2310 label nUnmarked = unmarkInternalRefinement(
refineCell, nRefine);
2313 Info<<
"Unmarked for refinement due to limit shells"
2314 <<
" : " << nUnmarked <<
" cells." <<
endl;
2323 cellsToRefine.
setSize(nRefine);
2330 cellsToRefine[nRefine++] = cellI;
2335 return cellsToRefine;
2348 meshCutter_.setRefinement(cellsToRefine, meshMod);
2355 mesh_.updateMesh(map);
2372 updateMesh(map, getChangedFaces(map, cellsToRefine));
2387 const scalar maxLoadUnbalance
2391 refine(cellsToRefine);
2395 Pout<<
"Writing refined but unbalanced " << msg
2403 Pout<<
"Dumped debug data in = "
2404 << mesh_.time().cpuTimeIncrement() <<
" s" <<
endl;
2410 Info<<
"Refined mesh in = "
2411 << mesh_.time().cpuTimeIncrement() <<
" s" <<
endl;
2412 printMeshInfo(
debug,
"After refinement " + msg);
2422 scalar nIdealCells =
2423 mesh_.globalData().nTotalCells()
2428 mag(1.0-mesh_.nCells()/nIdealCells),
2432 if (unbalance <= maxLoadUnbalance)
2434 Info<<
"Skipping balancing since max unbalance " << unbalance
2435 <<
" is less than allowable " << maxLoadUnbalance
2451 Info<<
"Balanced mesh in = "
2452 << mesh_.time().cpuTimeIncrement() <<
" s" <<
endl;
2454 printMeshInfo(
debug,
"After balancing " + msg);
2459 Pout<<
"Writing balanced " << msg
2467 Pout<<
"Dumped debug data in = "
2468 << mesh_.time().cpuTimeIncrement() <<
" s" <<
endl;
2488 const scalar maxLoadUnbalance
2491 labelList cellsToRefine(initCellsToRefine);
2526 scalar nNewCells = scalar(mesh_.nCells() + 7*cellsToRefine.size());
2527 scalar nIdealNewCells =
2532 mag(1.0-nNewCells/nIdealNewCells),
2536 if (unbalance <= maxLoadUnbalance)
2538 Info<<
"Skipping balancing since max unbalance " << unbalance
2539 <<
" is less than allowable " << maxLoadUnbalance
2547 cellWeights[cellsToRefine[i]] += 7;
2560 distMap().distributeCellIndices(cellsToRefine);
2562 Info<<
"Balanced mesh in = "
2563 << mesh_.time().cpuTimeIncrement() <<
" s" <<
endl;
2578 printMeshInfo(
debug,
"After balancing " + msg);
2582 Pout<<
"Writing balanced " << msg
2590 Pout<<
"Dumped debug data in = "
2591 << mesh_.time().cpuTimeIncrement() <<
" s" <<
endl;
2602 refine(cellsToRefine);
2606 Pout<<
"Writing refined " << msg
2614 Pout<<
"Dumped debug data in = "
2615 << mesh_.time().cpuTimeIncrement() <<
" s" <<
endl;
2621 Info<<
"Refined mesh in = "
2622 << mesh_.time().cpuTimeIncrement() <<
" s" <<
endl;
2636 printMeshInfo(
debug,
"After refinement " + msg);
2644 const label maxGlobalCells,
2645 const label maxLocalCells,
2650 const labelList& cellLevel = meshCutter_.cellLevel();
2651 const pointField& cellCentres = mesh_.cellCentres();
2653 label totNCells = mesh_.globalData().nTotalCells();
2657 if (totNCells >= maxGlobalCells)
2659 Info<<
"No cells marked for refinement since reached limit "
2660 << maxGlobalCells <<
'.' <<
endl;
2674 shells_.findDirectionalLevel
2684 forAll(insideShell, celli)
2686 if (insideShell[celli] >= 0)
2688 bool reachedLimit = !markForRefine
2700 Pout<<
"Stopped refining cells"
2701 <<
" since reaching my cell limit of "
2702 << mesh_.nCells()+nAllowRefine <<
endl;
2713 label nUnmarked = unmarkInternalRefinement(
refineCell, nRefine);
2716 Info<<
"Unmarked for refinement due to limit shells"
2717 <<
" : " << nUnmarked <<
" cells." <<
endl;
2726 cellsToRefine.
setSize(nRefine);
2733 cellsToRefine[nRefine++] = cellI;
2738 return cellsToRefine;
2755 refCells[i] =
refineCell(cellsToRefine[i], refDir);
2762 cellCuts cuts(mesh_, cellWalker, refCells);
2775 mesh_.updateMesh(*morphMap);
2778 if (morphMap().hasMotionPoints())
2780 mesh_.movePoints(morphMap().preMotionPoints());
2795 updateMesh(*morphMap, getChangedFaces(*morphMap, cellsToRefine));