80 return less(values_[a], values_[
b]);
117 const polyTopoChangeMap& map,
126 label nMasterChanged = 0;
144 PackedBoolList oldRefineCell(map.nOldCells());
146 forAll(oldCellsToRefine, i)
148 oldRefineCell.set(oldCellsToRefine[i], 1u);
152 PackedBoolList refinedInternalFace(nInternalFaces);
156 for (
label facei = 0; facei < nInternalFaces; facei++)
158 const label oldOwn = map.cellMap()[faceOwner[facei]];
159 const label oldNei = map.cellMap()[faceNeighbour[facei]];
164 && oldRefineCell.get(oldOwn) == 0u
166 && oldRefineCell.get(oldNei) == 0u
173 refinedInternalFace.set(facei, 1u);
186 label facei = pp.start();
190 label oldOwn = map.cellMap()[faceOwner[facei]];
192 if (oldOwn >= 0 && oldRefineCell.get(oldOwn) == 0u)
198 refinedBoundaryFace[facei - nInternalFaces] =
true;
218 forAll(refinedInternalFace, facei)
220 if (refinedInternalFace.get(facei) == 1u)
222 const cell& ownFaces =
cells[faceOwner[facei]];
225 changedFace[ownFaces[owni]] =
true;
227 const cell& neiFaces =
cells[faceNeighbour[facei]];
230 changedFace[neiFaces[neii]] =
true;
235 forAll(refinedBoundaryFace, i)
237 if (refinedBoundaryFace[i])
239 const cell& ownFaces =
cells[faceOwner[i+nInternalFaces]];
242 changedFace[ownFaces[owni]] =
true;
263 forAll(changedFace, facei)
265 if (changedFace[facei] && isMasterFace[facei])
275 Pout<<
"getChangedFaces : Detected "
276 <<
" local:" << changedFaces.size()
277 <<
" global:" <<
returnReduce(nMasterChanged, sumOp<label>())
281 faceSet changedFacesSet(
mesh,
"changedFaces", changedFaces);
282 Pout<<
"getChangedFaces : Writing " << changedFaces.size()
283 <<
" changed faces to faceSet " << changedFacesSet.
name()
285 changedFacesSet.
write();
295 bool Foam::meshRefinement::markForRefine
297 const label markValue,
298 const label nAllowRefine,
306 cellValue = markValue;
310 return nRefine <= nAllowRefine;
314 void Foam::meshRefinement::markFeatureCellLevel
338 Cloud<trackedParticle> startPointCloud
342 IDLList<trackedParticle>()
350 label nLocateBoundaryHits = 0;
356 const label celli = mesh_.cellTree().findInside(insidePoint);
364 const edgeMesh& featureMesh = features_[feati];
365 const label featureLevel = features_.levels()[feati][0];
370 const label nRegions = featureMesh.regions(edgeRegion);
373 PackedBoolList regionVisited(nRegions);
379 forAll(pointEdges, pointi)
381 if (pointEdges[pointi].size() != 2)
385 Pout<<
"Adding particle from point:" << pointi
386 <<
" coord:" << featureMesh.points()[pointi]
387 <<
" since number of emanating edges:"
388 << pointEdges[pointi].size()
393 startPointCloud.addParticle
401 featureMesh.points()[pointi],
410 if (pointEdges[pointi].size() > 0)
412 label e0 = pointEdges[pointi][0];
413 label regioni = edgeRegion[e0];
414 regionVisited[regioni] = 1u;
422 forAll(featureMesh.edges(), edgei)
424 if (regionVisited.set(edgeRegion[edgei], 1u))
426 const edge&
e = featureMesh.edges()[edgei];
427 const label pointi =
e.start();
430 Pout<<
"Adding particle from point:" << pointi
431 <<
" coord:" << featureMesh.points()[pointi]
432 <<
" on circular region:" << edgeRegion[edgei]
437 startPointCloud.addParticle
445 featureMesh.points()[pointi],
460 maxFeatureLevel =
labelList(mesh_.nCells(), -1);
463 List<PackedBoolList> featureEdgeVisited(features_.size());
467 featureEdgeVisited[feati].setSize(features_[feati].edges().size());
468 featureEdgeVisited[feati] = 0u;
472 trackedParticle::trackingData td
475 2.0*mesh_.bounds().mag(),
486 Pout<<
"Tracking " << startPointCloud.size()
487 <<
" particles over distance " << td.maxTrackLen_
488 <<
" to find the starting cell" <<
endl;
490 startPointCloud.move(startPointCloud, td);
494 maxFeatureLevel = -1;
497 featureEdgeVisited[feati] = 0u;
501 Cloud<trackedParticle> cloud
505 IDLList<trackedParticle>()
510 Pout<<
"Constructing cloud for cell marking" <<
endl;
513 forAllIter(Cloud<trackedParticle>, startPointCloud, iter)
515 const trackedParticle& startTp = iter();
517 const label feati = startTp.i();
518 const label pointi = startTp.j();
520 const edgeMesh& featureMesh = features_[feati];
521 const labelList& pEdges = featureMesh.pointEdges()[pointi];
526 const label edgei = pEdges[pEdgei];
528 if (featureEdgeVisited[feati].set(edgei, 1u))
533 const edge&
e = featureMesh.edges()[edgei];
534 label otherPointi =
e.otherVertex(pointi);
536 trackedParticle* tp(
new trackedParticle(startTp));
537 tp->start() = tp->position(mesh_);
538 tp->end() = featureMesh.points()[otherPointi];
539 tp->j() = otherPointi;
544 Pout<<
"Adding particle for point:" << pointi
545 <<
" coord:" << tp->position(mesh_)
546 <<
" feature:" << feati
547 <<
" to track to:" << tp->end()
551 cloud.addParticle(tp);
556 startPointCloud.clear();
564 Pout<<
"Tracking " << cloud.size()
565 <<
" particles over distance " << td.maxTrackLen_
566 <<
" to mark cells" <<
endl;
568 cloud.move(cloud, td);
571 forAllIter(Cloud<trackedParticle>, cloud, iter)
573 trackedParticle& tp = iter();
575 const label feati = tp.i();
576 const label pointi = tp.j();
578 const edgeMesh& featureMesh = features_[feati];
579 const labelList& pEdges = featureMesh.pointEdges()[pointi];
584 bool keepParticle =
false;
588 const label edgei = pEdges[i];
590 if (featureEdgeVisited[feati].set(edgei, 1u))
595 const edge&
e = featureMesh.edges()[edgei];
596 const label otherPointi =
e.otherVertex(pointi);
598 tp.start() = tp.position(mesh_);
599 tp.end() = featureMesh.points()[otherPointi];
600 tp.j() = otherPointi;
611 cloud.deleteParticle(tp);
618 Pout<<
"Remaining particles " << cloud.size() <<
endl;
646 Foam::label Foam::meshRefinement::markFeatureRefinement
649 const label nAllowRefine,
662 const labelList& cellLevel = meshCutter_.cellLevel();
664 const label oldNRefine = nRefine;
666 forAll(maxFeatureLevel, celli)
668 if (maxFeatureLevel[celli] > cellLevel[celli])
694 Info<<
"Reached refinement limit." <<
endl;
697 return returnReduce(nRefine-oldNRefine, sumOp<label>());
702 Foam::label Foam::meshRefinement::markInternalDistanceToFeatureRefinement
704 const label nAllowRefine,
710 const labelList& cellLevel = meshCutter_.cellLevel();
711 const pointField& cellCentres = mesh_.cellCentres();
714 if (features_.maxDistance() <= 0.0)
719 label oldNRefine = nRefine;
723 labelList testLevels(cellLevel.size()-nRefine);
728 if (refineCell[celli] == -1)
730 testCc[testi] = cellCentres[celli];
731 testLevels[testi] = cellLevel[celli];
738 features_.findHigherLevel(testCc, testLevels, maxLevel);
745 if (refineCell[celli] == -1)
747 if (maxLevel[testi] > testLevels[testi])
749 const bool reachedLimit = !markForRefine
761 Pout<<
"Stopped refining internal cells"
762 <<
" since reaching my cell limit of "
763 << mesh_.nCells()+7*nRefine <<
endl;
778 Info<<
"Reached refinement limit." <<
endl;
781 return returnReduce(nRefine-oldNRefine, sumOp<label>());
785 Foam::label Foam::meshRefinement::markInternalRefinement
787 const label nAllowRefine,
793 const labelList& cellLevel = meshCutter_.cellLevel();
794 const pointField& cellCentres = mesh_.cellCentres();
796 const label oldNRefine = nRefine;
800 labelList testLevels(cellLevel.size()-nRefine);
805 if (refineCell[celli] == -1)
807 testCc[testi] = cellCentres[celli];
808 testLevels[testi] = cellLevel[celli];
815 shells_.findHigherLevel
819 meshCutter_.level0EdgeLength(),
828 if (refineCell[celli] == -1)
830 if (maxLevel[testi] > testLevels[testi])
832 bool reachedLimit = !markForRefine
844 Pout<<
"Stopped refining internal cells"
845 <<
" since reaching my cell limit of "
846 << mesh_.nCells()+7*nRefine <<
endl;
861 Info<<
"Reached refinement limit." <<
endl;
864 return returnReduce(nRefine-oldNRefine, sumOp<label>());
877 forAll(surfaceIndex_, facei)
879 if (surfaceIndex_[facei] != -1)
881 label own = mesh_.faceOwner()[facei];
883 if (mesh_.isInternalFace(facei))
885 const label nei = mesh_.faceNeighbour()[facei];
887 if (refineCell[own] == -1 || refineCell[nei] == -1)
889 testFaces[nTest++] = facei;
894 if (refineCell[own] == -1)
896 testFaces[nTest++] = facei;
901 testFaces.setSize(nTest);
907 Foam::label Foam::meshRefinement::markSurfaceRefinement
909 const label nAllowRefine,
917 const labelList& cellLevel = meshCutter_.cellLevel();
918 const pointField& cellCentres = mesh_.cellCentres();
920 const label oldNRefine = nRefine;
928 labelList testFaces(getRefineCandidateFaces(refineCell));
939 const label facei = testFaces[i];
941 const label own = mesh_.faceOwner()[facei];
943 if (mesh_.isInternalFace(facei))
945 label nei = mesh_.faceNeighbour()[facei];
947 start[i] = cellCentres[own];
948 end[i] = cellCentres[nei];
949 minLevel[i] =
min(cellLevel[own], cellLevel[nei]);
953 const label bFacei = facei - mesh_.nInternalFaces();
955 start[i] = cellCentres[own];
956 end[i] = neiCc[bFacei];
957 minLevel[i] =
min(cellLevel[own], neiLevel[bFacei]);
974 surfaces_.findHigherIntersection
990 const label facei = testFaces[i];
992 const label surfi = surfaceHit[i];
1002 const label own = mesh_.faceOwner()[facei];
1004 if (surfaceMinLevel[i] > cellLevel[own])
1022 if (mesh_.isInternalFace(facei))
1024 const label nei = mesh_.faceNeighbour()[facei];
1026 if (surfaceMinLevel[i] > cellLevel[nei])
1053 Info<<
"Reached refinement limit." <<
endl;
1056 return returnReduce(nRefine-oldNRefine, sumOp<label>());
1063 const List<point>& normals1,
1064 const List<point>& normals2,
1072 const vector& n1 = normals1[i];
1076 const vector& n2 = normals2[j];
1091 Foam::label Foam::meshRefinement::markSurfaceCurvatureRefinement
1093 const scalar curvature,
1094 const label nAllowRefine,
1102 const labelList& cellLevel = meshCutter_.cellLevel();
1103 const pointField& cellCentres = mesh_.cellCentres();
1105 const label oldNRefine = nRefine;
1119 labelList testFaces(getRefineCandidateFaces(refineCell));
1128 const label facei = testFaces[i];
1129 const label own = mesh_.faceOwner()[facei];
1131 if (mesh_.isInternalFace(facei))
1133 const label nei = mesh_.faceNeighbour()[facei];
1135 start[i] = cellCentres[own];
1136 end[i] = cellCentres[nei];
1137 minLevel[i] =
min(cellLevel[own], cellLevel[nei]);
1141 const label bFacei = facei - mesh_.nInternalFaces();
1143 start[i] = cellCentres[own];
1144 end[i] = neiCc[bFacei];
1146 if (!isMasterFace[facei])
1148 Swap(start[i], end[i]);
1151 minLevel[i] =
min(cellLevel[own], neiLevel[bFacei]);
1157 const vectorField smallVec(rootSmall*(end-start));
1166 List<vectorList> cellSurfNormals(mesh_.nCells());
1170 List<vectorList> surfaceNormal;
1175 surfaces_.findAllHigherIntersections
1182 surfaces_.maxLevel(),
1193 forAll(surfaceNormal, pointi)
1195 vectorList& pNormals = surfaceNormal[pointi];
1196 labelList& pLevel = surfaceLevel[pointi];
1198 sortedOrder(pNormals, visitOrder, normalLess(pNormals));
1200 pNormals = List<point>(pNormals, visitOrder);
1201 pLevel = UIndirectList<label>(pLevel, visitOrder);
1212 const label facei = testFaces[i];
1213 const label own = mesh_.faceOwner()[facei];
1215 const vectorList& fNormals = surfaceNormal[i];
1216 const labelList& fLevels = surfaceLevel[i];
1220 if (fLevels[hiti] > cellLevel[own])
1222 cellSurfLevels[own].append(fLevels[hiti]);
1223 cellSurfNormals[own].append(fNormals[hiti]);
1226 if (mesh_.isInternalFace(facei))
1228 label nei = mesh_.faceNeighbour()[facei];
1229 if (fLevels[hiti] > cellLevel[nei])
1231 cellSurfLevels[nei].append(fLevels[hiti]);
1232 cellSurfNormals[nei].append(fNormals[hiti]);
1246 forAll(cellSurfNormals, celli)
1248 const vectorList& normals = cellSurfNormals[celli];
1252 nNormals += normals.size();
1255 reduce(nSet, sumOp<label>());
1256 reduce(nNormals, sumOp<label>());
1257 Info<<
"markSurfaceCurvatureRefinement :"
1258 <<
" cells:" << mesh_.globalData().nTotalCells()
1259 <<
" of which with normals:" << nSet
1260 <<
" ; total normals stored:" << nNormals
1266 bool reachedLimit =
false;
1275 !reachedLimit && celli < cellSurfNormals.size();
1279 const vectorList& normals = cellSurfNormals[celli];
1280 const labelList& levels = cellSurfLevels[celli];
1283 for (
label i = 0; !reachedLimit && i < normals.size(); i++)
1285 for (
label j = i+1; !reachedLimit && j < normals.size(); j++)
1287 if ((normals[i] & normals[j]) < curvature)
1289 const label maxLevel =
max(levels[i], levels[j]);
1291 if (cellLevel[celli] < maxLevel)
1306 Pout<<
"Stopped refining since reaching my cell"
1307 <<
" limit of " << mesh_.nCells()+7*nRefine
1310 reachedLimit =
true;
1330 !reachedLimit && facei < mesh_.nInternalFaces();
1334 const label own = mesh_.faceOwner()[facei];
1335 const label nei = mesh_.faceNeighbour()[facei];
1337 const vectorList& ownNormals = cellSurfNormals[own];
1338 const labelList& ownLevels = cellSurfLevels[own];
1339 const vectorList& neiNormals = cellSurfNormals[nei];
1340 const labelList& neiLevels = cellSurfLevels[nei];
1348 countMatches(ownNormals, neiNormals)
1349 == ownNormals.
size();
1352 countMatches(neiNormals, ownNormals)
1353 == neiNormals.size();
1356 if (!ownisSubset && !neiisSubset)
1359 for (
label i = 0; !reachedLimit && i < ownNormals.size(); i++)
1361 for (
label j = 0; !reachedLimit && j < neiNormals.size(); j++)
1364 if ((ownNormals[i] & neiNormals[j]) < curvature)
1367 if (cellLevel[own] < ownLevels[i])
1382 Pout<<
"Stopped refining since reaching"
1383 <<
" my cell limit of "
1384 << mesh_.nCells()+7*nRefine <<
endl;
1386 reachedLimit =
true;
1390 if (cellLevel[nei] < neiLevels[j])
1405 Pout<<
"Stopped refining since reaching"
1406 <<
" my cell limit of "
1407 << mesh_.nCells()+7*nRefine <<
endl;
1409 reachedLimit =
true;
1421 List<vectorList> neiSurfaceNormals;
1427 label facei = mesh_.nInternalFaces();
1428 !reachedLimit && facei < mesh_.nFaces();
1432 label own = mesh_.faceOwner()[facei];
1433 label bFacei = facei - mesh_.nInternalFaces();
1435 const vectorList& ownNormals = cellSurfNormals[own];
1436 const labelList& ownLevels = cellSurfLevels[own];
1437 const vectorList& neiNormals = neiSurfaceNormals[bFacei];
1444 countMatches(ownNormals, neiNormals)
1445 == ownNormals.size();
1448 countMatches(neiNormals, ownNormals)
1449 == neiNormals.size();
1452 if (!ownisSubset && !neiisSubset)
1455 for (
label i = 0; !reachedLimit && i < ownNormals.size(); i++)
1457 for (
label j = 0; !reachedLimit && j < neiNormals.size(); j++)
1460 if ((ownNormals[i] & neiNormals[j]) < curvature)
1462 if (cellLevel[own] < ownLevels[i])
1477 Pout<<
"Stopped refining since reaching"
1478 <<
" my cell limit of "
1479 << mesh_.nCells()+7*nRefine
1482 reachedLimit =
true;
1499 Info<<
"Reached refinement limit." <<
endl;
1502 return returnReduce(nRefine-oldNRefine, sumOp<label>());
1508 const scalar planarCos,
1518 const vector d = point1 - point0;
1519 const scalar magD =
mag(d);
1521 if (magD > mergeDistance())
1523 scalar cosAngle = (normal0 & normal1);
1526 if (cosAngle < (-1+planarCos))
1529 avg = 0.5*(normal0-normal1);
1531 else if (cosAngle > (1-planarCos))
1533 avg = 0.5*(normal0+normal1);
1541 if (
mag(avg&d) > mergeDistance())
1565 const scalar planarCos,
1575 vector d = point1 - point0;
1576 const scalar magD =
mag(d);
1578 if (magD > mergeDistance())
1580 scalar cosAngle = (normal0 & normal1);
1583 if (cosAngle < (-1+planarCos))
1586 avg = 0.5*(normal0-normal1);
1588 else if (cosAngle > (1-planarCos))
1590 avg = 0.5*(normal0+normal1);
1620 bool Foam::meshRefinement::checkProximity
1622 const scalar planarCos,
1623 const label nAllowRefine,
1625 const label surfaceLevel,
1627 const vector& surfaceNormal,
1631 label& cellMaxLevel,
1639 const labelList& cellLevel = meshCutter_.cellLevel();
1642 if (surfaceLevel > cellLevel[celli])
1644 if (cellMaxLevel == -1)
1647 cellMaxLevel = surfaceLevel;
1649 cellMaxNormal = surfaceNormal;
1658 bool closeSurfaces = isNormalGap
1669 if (surfaceLevel > cellMaxLevel)
1671 cellMaxLevel = surfaceLevel;
1672 cellMaxLocation = surfaceLocation;
1673 cellMaxNormal = surfaceNormal;
1687 return markForRefine
1703 Foam::label Foam::meshRefinement::markProximityRefinement
1705 const scalar planarCos,
1706 const label nAllowRefine,
1714 const labelList& cellLevel = meshCutter_.cellLevel();
1715 const pointField& cellCentres = mesh_.cellCentres();
1717 const label oldNRefine = nRefine;
1728 labelList testFaces(getRefineCandidateFaces(refineCell));
1737 const label facei = testFaces[i];
1738 const label own = mesh_.faceOwner()[facei];
1740 if (mesh_.isInternalFace(facei))
1742 const label nei = mesh_.faceNeighbour()[facei];
1744 start[i] = cellCentres[own];
1745 end[i] = cellCentres[nei];
1746 minLevel[i] =
min(cellLevel[own], cellLevel[nei]);
1750 const label bFacei = facei - mesh_.nInternalFaces();
1752 start[i] = cellCentres[own];
1753 end[i] = neiCc[bFacei];
1754 minLevel[i] =
min(cellLevel[own], neiLevel[bFacei]);
1760 const vectorField smallVec(rootSmall*(end-start));
1769 labelList cellMaxLevel(mesh_.nCells(), -1);
1775 List<vectorList> surfaceLocation;
1776 List<vectorList> surfaceNormal;
1780 surfaces_.findAllHigherIntersections
1787 surfaces_.gapLevel(),
1817 label facei = testFaces[i];
1818 label own = mesh_.faceOwner()[facei];
1820 const labelList& fLevels = surfaceLevel[i];
1821 const vectorList& fPoints = surfaceLocation[i];
1822 const vectorList& fNormals = surfaceNormal[i];
1837 cellMaxLocation[own],
1845 if (mesh_.isInternalFace(facei))
1847 label nei = mesh_.faceNeighbour()[facei];
1862 cellMaxLocation[nei],
1876 labelList neiBndMaxLevel(mesh_.nFaces()-mesh_.nInternalFaces());
1877 pointField neiBndMaxLocation(mesh_.nFaces()-mesh_.nInternalFaces());
1878 vectorField neiBndMaxNormal(mesh_.nFaces()-mesh_.nInternalFaces());
1880 for (
label facei = mesh_.nInternalFaces(); facei < mesh_.nFaces(); facei++)
1882 const label bFacei = facei-mesh_.nInternalFaces();
1883 const label own = mesh_.faceOwner()[facei];
1885 neiBndMaxLevel[bFacei] = cellMaxLevel[own];
1886 neiBndMaxLocation[bFacei] = cellMaxLocation[own];
1887 neiBndMaxNormal[bFacei] = cellMaxNormal[own];
1896 for (
label facei = 0; facei < mesh_.nInternalFaces(); facei++)
1898 const label own = mesh_.faceOwner()[facei];
1899 const label nei = mesh_.faceNeighbour()[facei];
1901 if (cellMaxLevel[own] != -1 && cellMaxLevel[nei] != -1)
1909 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 const label own = mesh_.faceOwner()[facei];
1969 const label bFacei = facei - mesh_.nInternalFaces();
1971 if (cellLevel[own] < cellMaxLevel[own] && neiBndMaxLevel[bFacei] != -1)
1979 cellMaxLocation[own],
1981 neiBndMaxLocation[bFacei],
1982 neiBndMaxNormal[bFacei]
1999 Pout<<
"Stopped refining since reaching my cell"
2000 <<
" limit of " << mesh_.nCells()+7*nRefine
2015 Info<<
"Reached refinement limit." <<
endl;
2018 return returnReduce(nRefine-oldNRefine, sumOp<label>());
2032 const scalar curvature,
2033 const scalar planarAngle,
2035 const bool featureRefinement,
2036 const bool featureDistanceRefinement,
2037 const bool internalRefinement,
2038 const bool surfaceRefinement,
2039 const bool curvatureRefinement,
2040 const bool gapRefinement,
2041 const label maxGlobalCells,
2042 const label maxLocalCells
2045 const label totNCells = mesh_.globalData().nTotalCells();
2049 if (totNCells >= maxGlobalCells)
2051 Info<<
"No cells marked for refinement since reached limit "
2052 << maxGlobalCells <<
'.' <<
endl;
2086 labelList neiLevel(mesh_.nFaces()-mesh_.nInternalFaces());
2087 pointField neiCc(mesh_.nFaces()-mesh_.nInternalFaces());
2088 calcNeighbourData(neiLevel, neiCc);
2095 if (featureRefinement)
2097 const label nFeatures = markFeatureRefinement
2106 Info<<
"Marked for refinement due to explicit features "
2107 <<
": " << nFeatures <<
" cells." <<
endl;
2113 if (featureDistanceRefinement)
2115 const label nCellsFeat = markInternalDistanceToFeatureRefinement
2122 Info<<
"Marked for refinement due to distance to explicit features "
2123 ": " << nCellsFeat <<
" cells." <<
endl;
2129 if (internalRefinement)
2131 const label nShell = markInternalRefinement
2138 Info<<
"Marked for refinement due to refinement shells "
2139 <<
": " << nShell <<
" cells." <<
endl;
2145 if (surfaceRefinement)
2147 const label nSurf = markSurfaceRefinement
2156 Info<<
"Marked for refinement due to surface intersection "
2157 <<
": " << nSurf <<
" cells." <<
endl;
2166 && (curvature >= -1 && curvature <= 1)
2167 && (surfaces_.minLevel() != surfaces_.maxLevel())
2170 const label nCurv = markSurfaceCurvatureRefinement
2180 Info<<
"Marked for refinement due to curvature/regions "
2181 <<
": " << nCurv <<
" cells." <<
endl;
2185 const scalar planarCos =
Foam::cos(planarAngle);
2190 && (planarCos >= -1 && planarCos <= 1)
2191 && (
max(surfaces_.gapLevel()) > -1)
2194 Info<<
"Specified gap level : " <<
max(surfaces_.gapLevel())
2197 const label nGap = markProximityRefinement
2207 Info<<
"Marked for refinement due to close opposite surfaces "
2208 <<
": " << nGap <<
" cells." <<
endl;
2216 cellsToRefine.
setSize(nRefine);
2223 cellsToRefine[nRefine++] = celli;
2228 return cellsToRefine;
2241 meshCutter_.setRefinement(cellsToRefine, meshMod);
2248 mesh_.topoChange(map);
2251 mesh_.setInstance(
name());
2267 const scalar maxLoadUnbalance
2271 refine(cellsToRefine);
2275 Pout<<
"Writing refined but unbalanced " << msg
2276 <<
" mesh to time " <<
name() <<
endl;
2281 mesh_.time().path()/
name()
2283 Pout<<
"Dumped debug data in = "
2284 << mesh_.time().cpuTimeIncrement() <<
" s" <<
endl;
2290 Info<<
"Refined mesh in = "
2291 << mesh_.time().cpuTimeIncrement() <<
" s" <<
endl;
2292 printMeshInfo(debug,
"After refinement " + msg);
2302 const scalar nIdealCells =
2303 mesh_.globalData().nTotalCells()
2308 mag(1.0-mesh_.nCells()/nIdealCells),
2312 if (unbalance <= maxLoadUnbalance)
2314 Info<<
"Skipping balancing since max unbalance " << unbalance
2315 <<
" is less than allowable " << maxLoadUnbalance
2331 Info<<
"Balanced mesh in = "
2332 << mesh_.time().cpuTimeIncrement() <<
" s" <<
endl;
2334 printMeshInfo(debug,
"After balancing " + msg);
2339 Pout<<
"Writing balanced " << msg
2340 <<
" mesh to time " <<
name() <<
endl;
2345 mesh_.time().path()/
name()
2347 Pout<<
"Dumped debug data in = "
2348 << mesh_.time().cpuTimeIncrement() <<
" s" <<
endl;
2368 const scalar maxLoadUnbalance
2371 labelList cellsToRefine(initCellsToRefine);
2406 const scalar nNewCells =
2407 scalar(mesh_.nCells() + 7*cellsToRefine.
size());
2408 const scalar nIdealNewCells =
2412 mag(1.0-nNewCells/nIdealNewCells),
2416 if (unbalance <= maxLoadUnbalance)
2418 Info<<
"Skipping balancing since max unbalance " << unbalance
2419 <<
" is less than allowable " << maxLoadUnbalance
2427 cellWeights[cellsToRefine[i]] += 7;
2440 distMap().distributeCellIndices(cellsToRefine);
2442 Info<<
"Balanced mesh in = "
2443 << mesh_.time().cpuTimeIncrement() <<
" s" <<
endl;
2458 printMeshInfo(debug,
"After balancing " + msg);
2462 Pout<<
"Writing balanced " << msg
2463 <<
" mesh to time " <<
name() <<
endl;
2468 mesh_.time().path()/
name()
2470 Pout<<
"Dumped debug data in = "
2471 << mesh_.time().cpuTimeIncrement() <<
" s" <<
endl;
2482 refine(cellsToRefine);
2486 Pout<<
"Writing refined " << msg
2487 <<
" mesh to time " <<
name() <<
endl;
2492 mesh_.time().path()/
name()
2494 Pout<<
"Dumped debug data in = "
2495 << mesh_.time().cpuTimeIncrement() <<
" s" <<
endl;
2501 Info<<
"Refined mesh in = "
2502 << mesh_.time().cpuTimeIncrement() <<
" s" <<
endl;
2516 printMeshInfo(debug,
"After refinement " + msg);
#define forAll(list, i)
Loop across all elements in list.
#define forAllIter(Container, container, iter)
Iterate across all elements in the container object of type.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void size(const label)
Override size to be inconsistent with allocated storage.
void clear()
Clear the list, i.e. set size to zero.
void setSize(const label)
Reset size of List.
virtual const fileName & name() const
Return the name of the stream.
virtual Ostream & write(const char)=0
Write character.
static label nProcs(const label communicator=0)
Number of processes in parallel run.
static const direction nComponents
Number of components in this vector space.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Abstract base class for decomposition.
Sends/receives parts of mesh+fvfields to neighbouring processors. Used in load balancing.
const polyMesh & mesh() const
Return reference to polyMesh.
label nTotalFaces() const
Return total number of faces in decomposed mesh. Not.
autoPtr< polyDistributionMap > refineAndBalance(const string &msg, decompositionMethod &decomposer, fvMeshDistribute &distributor, const labelList &cellsToRefine, const scalar maxLoadUnbalance)
Refine some cells and rebalance.
labelList refineCandidates(const List< point > &insidePoints, const scalar curvature, const scalar planarAngle, const bool featureRefinement, const bool featureDistanceRefinement, const bool internalRefinement, const bool surfaceRefinement, const bool curvatureRefinement, const bool gapRefinement, const label maxGlobalCells, const label maxLocalCells) const
Calculate list of cells to refine.
const fvMesh & mesh() const
Reference to mesh.
autoPtr< polyTopoChangeMap > refine(const labelList &cellsToRefine)
Refine some cells.
bool isGap(const scalar, const vector &, const vector &, const vector &, const vector &) const
Is local topology a small gap?
autoPtr< polyDistributionMap > balanceAndRefine(const string &msg, decompositionMethod &decomposer, fvMeshDistribute &distributor, const labelList &cellsToRefine, const scalar maxLoadUnbalance)
Balance before refining some cells.
bool isNormalGap(const scalar, const vector &, const vector &, const vector &, const vector &) const
Is local topology a small gap normal to the test vector.
normalLess(const vectorList &values)
bool operator()(const label a, const label b) const
labelList cmptType
Component type.
vectorList cmptType
Component type.
Traits class for primitives.
virtual const labelList & faceOwner() const
Return face owner.
const globalMeshData & globalData() const
Return parallel info.
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
virtual const labelList & faceNeighbour() const
Return face neighbour.
Direct mesh changes based on v1.3 polyTopoChange syntax.
autoPtr< polyTopoChangeMap > changeMesh(polyMesh &mesh, const bool syncParallel=true, const bool orderCells=false, const bool orderPoints=false)
Inplace changes mesh without change of patches.
label nInternalFaces() const
const cellList & cells() const
Container with cells to refine. Refinement given as single direction.
Contains information about location on a triSurface.
labelList getChangedFaces(const polyMesh &mesh, const labelHashSet &patchIDs)
Get initial set of changed faces.
void write(std::ostream &os, const bool binary, List< floatScalar > &fField)
Write floats ascii or binary.
scalar radToDeg(const scalar rad)
Convert radians to degrees.
scalar degToRad(const scalar deg)
Convert degrees to radians.
List< label > labelList
A List of labels.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
List< cell > cellList
list of cells
Ostream & endl(Ostream &os)
Add newline and flush stream.
word name(const bool)
Return a word representation of a bool.
labelList findIndices(const ListType &, typename ListType::const_reference, const label start=0)
Find all occurrences of given element. Linear search.
vectorField pointField
pointField is a vectorField.
List< bool > boolList
Bool container classes.
vector point
Point is a vector.
List< vector > vectorList
A List of vectors.
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
Vector< scalar > vector
A scalar version of the templated Vector.
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
List< labelList > labelListList
A List of labelList.
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
dimensioned< scalar > mag(const dimensioned< Type > &)
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
Field< vector > vectorField
Specialisation of Field<T> for vector.
static bool less(const vector &x, const vector &y)
To compare normals.
prefixOSstream Pout(cout, "Pout")
static const label labelMax
void sortedOrder(const UList< T > &, labelList &order)
Generate the (stable) sort order for the list.
dimensioned< scalar > magSqr(const dimensioned< Type > &)
dimensionedScalar cos(const dimensionedScalar &ds)