80 return less(values_[a], values_[
b]);
117 const polyTopoChangeMap& map,
121 const polyMesh&
mesh = map.mesh();
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
337 lagrangian::Cloud<trackedParticle> startPointCloud
341 IDLList<trackedParticle>()
347 label nLocateBoundaryHits = 0;
355 const label celli = searchEngine.findCell(insidePoint);
363 const edgeMesh& featureMesh = features_[feati];
364 const label featureLevel = features_.levels()[feati][0];
369 const label nRegions = featureMesh.regions(edgeRegion);
372 PackedBoolList regionVisited(nRegions);
378 forAll(pointEdges, pointi)
380 if (pointEdges[pointi].size() != 2)
384 Pout<<
"Adding particle from point:" << pointi
385 <<
" coord:" << featureMesh.points()[pointi]
386 <<
" since number of emanating edges:"
387 << pointEdges[pointi].size()
392 startPointCloud.addParticle
400 featureMesh.points()[pointi],
409 if (pointEdges[pointi].size() > 0)
411 label e0 = pointEdges[pointi][0];
412 label regioni = edgeRegion[e0];
413 regionVisited[regioni] = 1u;
421 forAll(featureMesh.edges(), edgei)
423 if (regionVisited.set(edgeRegion[edgei], 1u))
425 const edge&
e = featureMesh.edges()[edgei];
426 const label pointi =
e.start();
429 Pout<<
"Adding particle from point:" << pointi
430 <<
" coord:" << featureMesh.points()[pointi]
431 <<
" on circular region:" << edgeRegion[edgei]
436 startPointCloud.addParticle
444 featureMesh.points()[pointi],
459 maxFeatureLevel =
labelList(mesh_.nCells(), -1);
466 featureEdgeVisited[feati].setSize(features_[feati].edges().size());
467 featureEdgeVisited[feati] = 0u;
471 trackedParticle::trackingData td
474 2.0*mesh_.bounds().mag(),
485 Pout<<
"Tracking " << startPointCloud.size()
486 <<
" particles over distance " << td.maxTrackLen_
487 <<
" to find the starting cell" <<
endl;
489 startPointCloud.move(startPointCloud, td);
493 maxFeatureLevel = -1;
496 featureEdgeVisited[feati] = 0u;
500 lagrangian::Cloud<trackedParticle> cloud
504 IDLList<trackedParticle>()
509 Pout<<
"Constructing cloud for cell marking" <<
endl;
512 forAllIter(lagrangian::Cloud<trackedParticle>, startPointCloud, iter)
514 const trackedParticle& startTp = iter();
516 const label feati = startTp.i();
517 const label pointi = startTp.j();
519 const edgeMesh& featureMesh = features_[feati];
520 const labelList& pEdges = featureMesh.pointEdges()[pointi];
525 const label edgei = pEdges[pEdgei];
527 if (featureEdgeVisited[feati].set(edgei, 1u))
532 const edge&
e = featureMesh.edges()[edgei];
533 label otherPointi =
e.otherVertex(pointi);
535 trackedParticle* tp(
new trackedParticle(startTp));
536 tp->start() = tp->position(mesh_);
537 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(lagrangian::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];
601 tp.j() = otherPointi;
612 cloud.deleteParticle(tp);
619 Pout<<
"Remaining particles " << cloud.size() <<
endl;
647 Foam::label Foam::meshRefinement::markFeatureRefinement
650 const label nAllowRefine,
663 const labelList& cellLevel = meshCutter_.cellLevel();
665 const label oldNRefine = nRefine;
667 forAll(maxFeatureLevel, celli)
669 if (maxFeatureLevel[celli] > cellLevel[celli])
695 Info<<
"Reached refinement limit." <<
endl;
698 return returnReduce(nRefine-oldNRefine, sumOp<label>());
703 Foam::label Foam::meshRefinement::markInternalDistanceToFeatureRefinement
705 const label nAllowRefine,
711 const labelList& cellLevel = meshCutter_.cellLevel();
712 const pointField& cellCentres = mesh_.cellCentres();
715 if (features_.maxDistance() <= 0.0)
720 label oldNRefine = nRefine;
724 labelList testLevels(cellLevel.size()-nRefine);
729 if (refineCell[celli] == -1)
731 testCc[testi] = cellCentres[celli];
732 testLevels[testi] = cellLevel[celli];
739 features_.findHigherLevel(testCc, testLevels, maxLevel);
746 if (refineCell[celli] == -1)
748 if (maxLevel[testi] > testLevels[testi])
750 const bool reachedLimit = !markForRefine
762 Pout<<
"Stopped refining internal cells"
763 <<
" since reaching my cell limit of "
764 << mesh_.nCells()+7*nRefine <<
endl;
779 Info<<
"Reached refinement limit." <<
endl;
782 return returnReduce(nRefine-oldNRefine, sumOp<label>());
786 Foam::label Foam::meshRefinement::markInternalRefinement
788 const label nAllowRefine,
794 const labelList& cellLevel = meshCutter_.cellLevel();
795 const pointField& cellCentres = mesh_.cellCentres();
797 const label oldNRefine = nRefine;
801 labelList testLevels(cellLevel.size()-nRefine);
806 if (refineCell[celli] == -1)
808 testCc[testi] = cellCentres[celli];
809 testLevels[testi] = cellLevel[celli];
816 shells_.findHigherLevel
820 meshCutter_.level0EdgeLength(),
829 if (refineCell[celli] == -1)
831 if (maxLevel[testi] > testLevels[testi])
833 bool reachedLimit = !markForRefine
845 Pout<<
"Stopped refining internal cells"
846 <<
" since reaching my cell limit of "
847 << mesh_.nCells()+7*nRefine <<
endl;
862 Info<<
"Reached refinement limit." <<
endl;
865 return returnReduce(nRefine-oldNRefine, sumOp<label>());
878 forAll(surfaceIndex_, facei)
880 if (surfaceIndex_[facei] != -1)
882 label own = mesh_.faceOwner()[facei];
884 if (mesh_.isInternalFace(facei))
886 const label nei = mesh_.faceNeighbour()[facei];
888 if (refineCell[own] == -1 || refineCell[nei] == -1)
890 testFaces[nTest++] = facei;
895 if (refineCell[own] == -1)
897 testFaces[nTest++] = facei;
902 testFaces.setSize(nTest);
908 Foam::label Foam::meshRefinement::markSurfaceRefinement
910 const label nAllowRefine,
918 const labelList& cellLevel = meshCutter_.cellLevel();
919 const pointField& cellCentres = mesh_.cellCentres();
921 const label oldNRefine = nRefine;
929 labelList testFaces(getRefineCandidateFaces(refineCell));
940 const label facei = testFaces[i];
942 const label own = mesh_.faceOwner()[facei];
944 if (mesh_.isInternalFace(facei))
946 label nei = mesh_.faceNeighbour()[facei];
948 start[i] = cellCentres[own];
949 end[i] = cellCentres[nei];
950 minLevel[i] =
min(cellLevel[own], cellLevel[nei]);
954 const label bFacei = facei - mesh_.nInternalFaces();
956 start[i] = cellCentres[own];
957 end[i] = neiCc[bFacei];
958 minLevel[i] =
min(cellLevel[own], neiLevel[bFacei]);
975 surfaces_.findHigherIntersection
991 const label facei = testFaces[i];
993 const label surfi = surfaceHit[i];
1003 const label own = mesh_.faceOwner()[facei];
1005 if (surfaceMinLevel[i] > cellLevel[own])
1023 if (mesh_.isInternalFace(facei))
1025 const label nei = mesh_.faceNeighbour()[facei];
1027 if (surfaceMinLevel[i] > cellLevel[nei])
1054 Info<<
"Reached refinement limit." <<
endl;
1057 return returnReduce(nRefine-oldNRefine, sumOp<label>());
1073 const vector& n1 = normals1[i];
1077 const vector& n2 = normals2[j];
1092 Foam::label Foam::meshRefinement::markSurfaceCurvatureRefinement
1094 const scalar curvature,
1095 const label nAllowRefine,
1103 const labelList& cellLevel = meshCutter_.cellLevel();
1104 const pointField& cellCentres = mesh_.cellCentres();
1106 const label oldNRefine = nRefine;
1120 labelList testFaces(getRefineCandidateFaces(refineCell));
1129 const label facei = testFaces[i];
1130 const label own = mesh_.faceOwner()[facei];
1132 if (mesh_.isInternalFace(facei))
1134 const label nei = mesh_.faceNeighbour()[facei];
1136 start[i] = cellCentres[own];
1137 end[i] = cellCentres[nei];
1138 minLevel[i] =
min(cellLevel[own], cellLevel[nei]);
1142 const label bFacei = facei - mesh_.nInternalFaces();
1144 start[i] = cellCentres[own];
1145 end[i] = neiCc[bFacei];
1147 if (!isMasterFace[facei])
1149 Swap(start[i], end[i]);
1152 minLevel[i] =
min(cellLevel[own], neiLevel[bFacei]);
1158 const vectorField smallVec(rootSmall*(end-start));
1176 surfaces_.findAllHigherIntersections
1183 surfaces_.maxLevel(),
1194 forAll(surfaceNormal, pointi)
1196 vectorList& pNormals = surfaceNormal[pointi];
1197 labelList& pLevel = surfaceLevel[pointi];
1199 sortedOrder(pNormals, visitOrder, normalLess(pNormals));
1202 pLevel = UIndirectList<label>(pLevel, visitOrder);
1213 const label facei = testFaces[i];
1214 const label own = mesh_.faceOwner()[facei];
1216 const vectorList& fNormals = surfaceNormal[i];
1217 const labelList& fLevels = surfaceLevel[i];
1221 if (fLevels[hiti] > cellLevel[own])
1223 cellSurfLevels[own].append(fLevels[hiti]);
1224 cellSurfNormals[own].append(fNormals[hiti]);
1227 if (mesh_.isInternalFace(facei))
1229 label nei = mesh_.faceNeighbour()[facei];
1230 if (fLevels[hiti] > cellLevel[nei])
1232 cellSurfLevels[nei].append(fLevels[hiti]);
1233 cellSurfNormals[nei].append(fNormals[hiti]);
1247 forAll(cellSurfNormals, celli)
1249 const vectorList& normals = cellSurfNormals[celli];
1253 nNormals += normals.size();
1256 reduce(nSet, sumOp<label>());
1257 reduce(nNormals, sumOp<label>());
1258 Info<<
"markSurfaceCurvatureRefinement :"
1259 <<
" cells:" << mesh_.globalData().nTotalCells()
1260 <<
" of which with normals:" << nSet
1261 <<
" ; total normals stored:" << nNormals
1267 bool reachedLimit =
false;
1276 !reachedLimit && celli < cellSurfNormals.size();
1280 const vectorList& normals = cellSurfNormals[celli];
1281 const labelList& levels = cellSurfLevels[celli];
1284 for (
label i = 0; !reachedLimit && i < normals.size(); i++)
1286 for (
label j = i+1; !reachedLimit && j < normals.size(); j++)
1288 if ((normals[i] & normals[j]) < curvature)
1290 const label maxLevel =
max(levels[i], levels[j]);
1292 if (cellLevel[celli] < maxLevel)
1307 Pout<<
"Stopped refining since reaching my cell"
1308 <<
" limit of " << mesh_.nCells()+7*nRefine
1311 reachedLimit =
true;
1331 !reachedLimit && facei < mesh_.nInternalFaces();
1335 const label own = mesh_.faceOwner()[facei];
1336 const label nei = mesh_.faceNeighbour()[facei];
1338 const vectorList& ownNormals = cellSurfNormals[own];
1339 const labelList& ownLevels = cellSurfLevels[own];
1340 const vectorList& neiNormals = cellSurfNormals[nei];
1341 const labelList& neiLevels = cellSurfLevels[nei];
1349 countMatches(ownNormals, neiNormals)
1350 == ownNormals.
size();
1353 countMatches(neiNormals, ownNormals)
1354 == neiNormals.size();
1357 if (!ownisSubset && !neiisSubset)
1360 for (
label i = 0; !reachedLimit && i < ownNormals.size(); i++)
1362 for (
label j = 0; !reachedLimit && j < neiNormals.size(); j++)
1365 if ((ownNormals[i] & neiNormals[j]) < curvature)
1368 if (cellLevel[own] < ownLevels[i])
1383 Pout<<
"Stopped refining since reaching"
1384 <<
" my cell limit of "
1385 << mesh_.nCells()+7*nRefine <<
endl;
1387 reachedLimit =
true;
1391 if (cellLevel[nei] < neiLevels[j])
1406 Pout<<
"Stopped refining since reaching"
1407 <<
" my cell limit of "
1408 << mesh_.nCells()+7*nRefine <<
endl;
1410 reachedLimit =
true;
1428 label facei = mesh_.nInternalFaces();
1429 !reachedLimit && facei < mesh_.nFaces();
1433 label own = mesh_.faceOwner()[facei];
1434 label bFacei = facei - mesh_.nInternalFaces();
1436 const vectorList& ownNormals = cellSurfNormals[own];
1437 const labelList& ownLevels = cellSurfLevels[own];
1438 const vectorList& neiNormals = neiSurfaceNormals[bFacei];
1445 countMatches(ownNormals, neiNormals)
1446 == ownNormals.size();
1449 countMatches(neiNormals, ownNormals)
1450 == neiNormals.size();
1453 if (!ownisSubset && !neiisSubset)
1456 for (
label i = 0; !reachedLimit && i < ownNormals.size(); i++)
1458 for (
label j = 0; !reachedLimit && j < neiNormals.size(); j++)
1461 if ((ownNormals[i] & neiNormals[j]) < curvature)
1463 if (cellLevel[own] < ownLevels[i])
1478 Pout<<
"Stopped refining since reaching"
1479 <<
" my cell limit of "
1480 << mesh_.nCells()+7*nRefine
1483 reachedLimit =
true;
1500 Info<<
"Reached refinement limit." <<
endl;
1503 return returnReduce(nRefine-oldNRefine, sumOp<label>());
1509 const scalar planarCos,
1519 const vector d = point1 - point0;
1520 const scalar magD =
mag(d);
1522 if (magD > mergeDistance())
1524 scalar cosAngle = (normal0 & normal1);
1527 if (cosAngle < (-1+planarCos))
1530 avg = 0.5*(normal0-normal1);
1532 else if (cosAngle > (1-planarCos))
1534 avg = 0.5*(normal0+normal1);
1542 if (
mag(avg&d) > mergeDistance())
1566 const scalar planarCos,
1576 vector d = point1 - point0;
1577 const scalar magD =
mag(d);
1579 if (magD > mergeDistance())
1581 scalar cosAngle = (normal0 & normal1);
1584 if (cosAngle < (-1+planarCos))
1587 avg = 0.5*(normal0-normal1);
1589 else if (cosAngle > (1-planarCos))
1591 avg = 0.5*(normal0+normal1);
1621 bool Foam::meshRefinement::checkProximity
1623 const scalar planarCos,
1624 const label nAllowRefine,
1626 const label surfaceLevel,
1628 const vector& surfaceNormal,
1632 label& cellMaxLevel,
1640 const labelList& cellLevel = meshCutter_.cellLevel();
1643 if (surfaceLevel > cellLevel[celli])
1645 if (cellMaxLevel == -1)
1648 cellMaxLevel = surfaceLevel;
1650 cellMaxNormal = surfaceNormal;
1659 bool closeSurfaces = isNormalGap
1670 if (surfaceLevel > cellMaxLevel)
1672 cellMaxLevel = surfaceLevel;
1673 cellMaxLocation = surfaceLocation;
1674 cellMaxNormal = surfaceNormal;
1688 return markForRefine
1704 Foam::label Foam::meshRefinement::markProximityRefinement
1706 const scalar planarCos,
1707 const label nAllowRefine,
1715 const labelList& cellLevel = meshCutter_.cellLevel();
1716 const pointField& cellCentres = mesh_.cellCentres();
1718 const label oldNRefine = nRefine;
1729 labelList testFaces(getRefineCandidateFaces(refineCell));
1738 const label facei = testFaces[i];
1739 const label own = mesh_.faceOwner()[facei];
1741 if (mesh_.isInternalFace(facei))
1743 const label nei = mesh_.faceNeighbour()[facei];
1745 start[i] = cellCentres[own];
1746 end[i] = cellCentres[nei];
1747 minLevel[i] =
min(cellLevel[own], cellLevel[nei]);
1751 const label bFacei = facei - mesh_.nInternalFaces();
1753 start[i] = cellCentres[own];
1754 end[i] = neiCc[bFacei];
1755 minLevel[i] =
min(cellLevel[own], neiLevel[bFacei]);
1761 const vectorField smallVec(rootSmall*(end-start));
1770 labelList cellMaxLevel(mesh_.nCells(), -1);
1781 surfaces_.findAllHigherIntersections
1788 surfaces_.gapLevel(),
1818 label facei = testFaces[i];
1819 label own = mesh_.faceOwner()[facei];
1821 const labelList& fLevels = surfaceLevel[i];
1822 const vectorList& fPoints = surfaceLocation[i];
1823 const vectorList& fNormals = surfaceNormal[i];
1838 cellMaxLocation[own],
1846 if (mesh_.isInternalFace(facei))
1848 label nei = mesh_.faceNeighbour()[facei];
1863 cellMaxLocation[nei],
1877 labelList neiBndMaxLevel(mesh_.nFaces()-mesh_.nInternalFaces());
1878 pointField neiBndMaxLocation(mesh_.nFaces()-mesh_.nInternalFaces());
1879 vectorField neiBndMaxNormal(mesh_.nFaces()-mesh_.nInternalFaces());
1881 for (
label facei = mesh_.nInternalFaces(); facei < mesh_.nFaces(); facei++)
1883 const label bFacei = facei-mesh_.nInternalFaces();
1884 const label own = mesh_.faceOwner()[facei];
1886 neiBndMaxLevel[bFacei] = cellMaxLevel[own];
1887 neiBndMaxLocation[bFacei] = cellMaxLocation[own];
1888 neiBndMaxNormal[bFacei] = cellMaxNormal[own];
1897 for (
label facei = 0; facei < mesh_.nInternalFaces(); facei++)
1899 const label own = mesh_.faceOwner()[facei];
1900 const label nei = mesh_.faceNeighbour()[facei];
1902 if (cellMaxLevel[own] != -1 && cellMaxLevel[nei] != -1)
1910 cellMaxLocation[own],
1912 cellMaxLocation[nei],
1918 if (cellLevel[own] < cellMaxLevel[own])
1933 Pout<<
"Stopped refining since reaching my cell"
1934 <<
" limit of " << mesh_.nCells()+7*nRefine
1941 if (cellLevel[nei] < cellMaxLevel[nei])
1956 Pout<<
"Stopped refining since reaching my cell"
1957 <<
" limit of " << mesh_.nCells()+7*nRefine
1967 for (
label facei = mesh_.nInternalFaces(); facei < mesh_.nFaces(); facei++)
1969 const label own = mesh_.faceOwner()[facei];
1970 const label bFacei = facei - mesh_.nInternalFaces();
1972 if (cellLevel[own] < cellMaxLevel[own] && neiBndMaxLevel[bFacei] != -1)
1980 cellMaxLocation[own],
1982 neiBndMaxLocation[bFacei],
1983 neiBndMaxNormal[bFacei]
2000 Pout<<
"Stopped refining since reaching my cell"
2001 <<
" limit of " << mesh_.nCells()+7*nRefine
2016 Info<<
"Reached refinement limit." <<
endl;
2019 return returnReduce(nRefine-oldNRefine, sumOp<label>());
2033 const scalar curvature,
2034 const scalar planarAngle,
2036 const bool featureRefinement,
2037 const bool featureDistanceRefinement,
2038 const bool internalRefinement,
2039 const bool surfaceRefinement,
2040 const bool curvatureRefinement,
2041 const bool gapRefinement,
2042 const label maxGlobalCells,
2043 const label maxLocalCells
2046 const label totNCells = mesh_.globalData().nTotalCells();
2050 if (totNCells >= maxGlobalCells)
2052 Info<<
"No cells marked for refinement since reached limit "
2053 << maxGlobalCells <<
'.' <<
endl;
2087 labelList neiLevel(mesh_.nFaces()-mesh_.nInternalFaces());
2088 pointField neiCc(mesh_.nFaces()-mesh_.nInternalFaces());
2089 calcNeighbourData(neiLevel, neiCc);
2096 if (featureRefinement)
2098 const label nFeatures = markFeatureRefinement
2107 Info<<
"Marked for refinement due to explicit features "
2108 <<
": " << nFeatures <<
" cells." <<
endl;
2114 if (featureDistanceRefinement)
2116 const label nCellsFeat = markInternalDistanceToFeatureRefinement
2123 Info<<
"Marked for refinement due to distance to explicit features "
2124 ": " << nCellsFeat <<
" cells." <<
endl;
2130 if (internalRefinement)
2132 const label nShell = markInternalRefinement
2139 Info<<
"Marked for refinement due to refinement shells "
2140 <<
": " << nShell <<
" cells." <<
endl;
2146 if (surfaceRefinement)
2148 const label nSurf = markSurfaceRefinement
2157 Info<<
"Marked for refinement due to surface intersection "
2158 <<
": " << nSurf <<
" cells." <<
endl;
2167 && (curvature >= -1 && curvature <= 1)
2168 && (surfaces_.minLevel() != surfaces_.maxLevel())
2171 const label nCurv = markSurfaceCurvatureRefinement
2181 Info<<
"Marked for refinement due to curvature/regions "
2182 <<
": " << nCurv <<
" cells." <<
endl;
2186 const scalar planarCos =
Foam::cos(planarAngle);
2191 && (planarCos >= -1 && planarCos <= 1)
2192 && (
max(surfaces_.gapLevel()) > -1)
2195 Info<<
"Specified gap level : " <<
max(surfaces_.gapLevel())
2198 const label nGap = markProximityRefinement
2208 Info<<
"Marked for refinement due to close opposite surfaces "
2209 <<
": " << nGap <<
" cells." <<
endl;
2217 cellsToRefine.
setSize(nRefine);
2224 cellsToRefine[nRefine++] = celli;
2229 return cellsToRefine;
2242 meshCutter_.setRefinement(cellsToRefine, meshMod);
2249 mesh_.topoChange(map);
2252 mesh_.setInstance(
name());
2268 const scalar maxLoadUnbalance
2272 refine(cellsToRefine);
2276 Pout<<
"Writing refined but unbalanced " << msg
2277 <<
" mesh to time " <<
name() <<
endl;
2282 mesh_.time().path()/
name()
2284 Pout<<
"Dumped debug data in = "
2285 << mesh_.time().cpuTimeIncrement() <<
" s" <<
endl;
2291 Info<<
"Refined mesh in = "
2292 << mesh_.time().cpuTimeIncrement() <<
" s" <<
endl;
2293 printMeshInfo(debug,
"After refinement " + msg);
2303 const scalar nIdealCells =
2304 mesh_.globalData().nTotalCells()
2309 mag(1.0-mesh_.nCells()/nIdealCells),
2313 if (unbalance <= maxLoadUnbalance)
2315 Info<<
"Skipping balancing since max unbalance " << unbalance
2316 <<
" is less than allowable " << maxLoadUnbalance
2332 Info<<
"Balanced mesh in = "
2333 << mesh_.time().cpuTimeIncrement() <<
" s" <<
endl;
2335 printMeshInfo(debug,
"After balancing " + msg);
2340 Pout<<
"Writing balanced " << msg
2341 <<
" mesh to time " <<
name() <<
endl;
2346 mesh_.time().path()/
name()
2348 Pout<<
"Dumped debug data in = "
2349 << mesh_.time().cpuTimeIncrement() <<
" s" <<
endl;
2369 const scalar maxLoadUnbalance
2372 labelList cellsToRefine(initCellsToRefine);
2407 const scalar nNewCells =
2408 scalar(mesh_.nCells() + 7*cellsToRefine.
size());
2409 const scalar nIdealNewCells =
2413 mag(1.0-nNewCells/nIdealNewCells),
2417 if (unbalance <= maxLoadUnbalance)
2419 Info<<
"Skipping balancing since max unbalance " << unbalance
2420 <<
" is less than allowable " << maxLoadUnbalance
2428 cellWeights[cellsToRefine[i]] += 7;
2441 distMap().distributeCellIndices(cellsToRefine);
2443 Info<<
"Balanced mesh in = "
2444 << mesh_.time().cpuTimeIncrement() <<
" s" <<
endl;
2459 printMeshInfo(debug,
"After balancing " + msg);
2463 Pout<<
"Writing balanced " << msg
2464 <<
" mesh to time " <<
name() <<
endl;
2469 mesh_.time().path()/
name()
2471 Pout<<
"Dumped debug data in = "
2472 << mesh_.time().cpuTimeIncrement() <<
" s" <<
endl;
2483 refine(cellsToRefine);
2487 Pout<<
"Writing refined " << msg
2488 <<
" mesh to time " <<
name() <<
endl;
2493 mesh_.time().path()/
name()
2495 Pout<<
"Dumped debug data in = "
2496 << mesh_.time().cpuTimeIncrement() <<
" s" <<
endl;
2502 Info<<
"Refined mesh in = "
2503 << mesh_.time().cpuTimeIncrement() <<
" s" <<
endl;
2517 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 token &)
Write token.
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 fvBoundaryMesh & boundary() const
Return reference to boundary mesh.
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.
static const meshSearch & New(const polyMesh &mesh, const pointInCellShapes=pointInCellShapes::tets)
Lookup or construct from mesh and cell decomposition option.
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.
Motion of the mesh specified as a list of pointMeshMovers.
virtual const labelList & faceOwner() const
Return face owner.
const globalMeshData & globalData() const
Return parallel info.
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.
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
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.
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.
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< Type > min(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
Field< vector > vectorField
Specialisation of Field<T> for vector.
static bool less(const vector &x, const vector &y)
To compare normals.
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
prefixOSstream Pout(cout, "Pout")
tmp< DimensionedField< scalar, GeoMesh, Field > > mag(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
static const label labelMax
void sortedOrder(const UList< T > &, labelList &order)
Generate the (stable) sort order for the list.
tmp< DimensionedField< scalar, GeoMesh, Field > > magSqr(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
dimensionedScalar cos(const dimensionedScalar &ds)
dimensioned< Type > max(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)