80 return less(values_[a], values_[b]);
126 label nMasterChanged = 0;
146 forAll(oldCellsToRefine, i)
148 oldRefineCell.set(oldCellsToRefine[i], 1u);
156 for (
label facei = 0; facei < nInternalFaces; facei++)
164 && oldRefineCell.get(oldOwn) == 0u
166 && oldRefineCell.get(oldNei) == 0u
173 refinedInternalFace.
set(facei, 1u);
180 boolList refinedBoundaryFace(mesh.
nFaces()-nInternalFaces,
false);
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()
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
350 const point& keepPoint = keepPoints[i];
352 const label celli = mesh_.cellTree().findInside(keepPoint);
360 const edgeMesh& featureMesh = features_[featI];
361 const label featureLevel = features_.levels()[featI][0];
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()
396 featureMesh.
points()[pointi],
405 if (pointEdges[pointi].size() > 0)
407 label e0 = pointEdges[pointi][0];
408 label regionI = edgeRegion[e0];
409 regionVisited[regionI] = 1u;
419 if (regionVisited.
set(edgeRegion[edgeI], 1u))
425 Pout<<
"Adding particle from point:" << pointi
426 <<
" coord:" << featureMesh.
points()[pointi]
427 <<
" on circular region:" << edgeRegion[edgeI]
439 featureMesh.
points()[pointi],
454 maxFeatureLevel =
labelList(mesh_.nCells(), -1);
461 featureEdgeVisited[featI].setSize(features_[featI].edges().size());
462 featureEdgeVisited[featI] = 0u;
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] = 0u;
503 if (debug&meshRefinement::FEATURESEEDS)
505 Pout<<
"Constructing cloud for cell marking" <<
endl;
512 label featI = startTp.
i();
513 label pointi = startTp.
j();
515 const edgeMesh& featureMesh = features_[featI];
521 label edgeI = pEdges[pEdgeI];
523 if (featureEdgeVisited[featI].
set(edgeI, 1u))
533 tp->
end() = featureMesh.
points()[otherPointi];
534 tp->
j() = otherPointi;
537 if (debug&meshRefinement::FEATURESEEDS)
539 Pout<<
"Adding particle for point:" << pointi
541 <<
" feature:" << featI
542 <<
" to track to:" << tp->
end()
551 startPointCloud.
clear();
557 if (debug&meshRefinement::FEATURESEEDS)
560 <<
" particles over distance " << maxTrackLen
561 <<
" to mark cells" <<
endl;
563 cloud.
move(cloud, td, maxTrackLen);
573 const edgeMesh& featureMesh = features_[featI];
579 bool keepParticle =
false;
583 label edgeI = pEdges[i];
585 if (featureEdgeVisited[featI].
set(edgeI, 1u))
594 tp.
end() = featureMesh.
points()[otherPointi];
595 tp.
j() = otherPointi;
611 if (debug&meshRefinement::FEATURESEEDS)
641 Foam::label Foam::meshRefinement::markFeatureRefinement
644 const label nAllowRefine,
652 markFeatureCellLevel(keepPoints, maxFeatureLevel);
657 const labelList& cellLevel = meshCutter_.cellLevel();
659 label oldNRefine = nRefine;
661 forAll(maxFeatureLevel, celli)
663 if (maxFeatureLevel[celli] > cellLevel[celli])
689 Info<<
"Reached refinement limit." <<
endl;
697 Foam::label Foam::meshRefinement::markInternalDistanceToFeatureRefinement
699 const label nAllowRefine,
705 const labelList& cellLevel = meshCutter_.cellLevel();
706 const pointField& cellCentres = mesh_.cellCentres();
709 if (features_.maxDistance() <= 0.0)
714 label oldNRefine = nRefine;
723 if (refineCell[celli] == -1)
725 testCc[testI] = cellCentres[celli];
726 testLevels[testI] = cellLevel[celli];
733 features_.findHigherLevel(testCc, testLevels, maxLevel);
740 if (refineCell[celli] == -1)
742 if (maxLevel[testI] > testLevels[testI])
744 bool reachedLimit = !markForRefine
756 Pout<<
"Stopped refining internal cells" 757 <<
" since reaching my cell limit of " 758 << mesh_.nCells()+7*nRefine <<
endl;
773 Info<<
"Reached refinement limit." <<
endl;
781 Foam::label Foam::meshRefinement::markInternalRefinement
783 const label nAllowRefine,
789 const labelList& cellLevel = meshCutter_.cellLevel();
790 const pointField& cellCentres = mesh_.cellCentres();
792 label oldNRefine = nRefine;
801 if (refineCell[celli] == -1)
803 testCc[testI] = cellCentres[celli];
804 testLevels[testI] = cellLevel[celli];
811 shells_.findHigherLevel
824 if (refineCell[celli] == -1)
826 if (maxLevel[testI] > testLevels[testI])
828 bool reachedLimit = !markForRefine
840 Pout<<
"Stopped refining internal cells" 841 <<
" since reaching my cell limit of " 842 << mesh_.nCells()+7*nRefine <<
endl;
857 Info<<
"Reached refinement limit." <<
endl;
875 forAll(surfaceIndex_, facei)
877 if (surfaceIndex_[facei] != -1)
879 label own = mesh_.faceOwner()[facei];
881 if (mesh_.isInternalFace(facei))
883 label nei = mesh_.faceNeighbour()[facei];
885 if (refineCell[own] == -1 || refineCell[nei] == -1)
887 testFaces[nTest++] = facei;
892 if (refineCell[own] == -1)
894 testFaces[nTest++] = facei;
899 testFaces.setSize(nTest);
906 Foam::label Foam::meshRefinement::markSurfaceRefinement
908 const label nAllowRefine,
916 const labelList& cellLevel = meshCutter_.cellLevel();
917 const pointField& cellCentres = mesh_.cellCentres();
919 label oldNRefine = nRefine;
927 labelList testFaces(getRefineCandidateFaces(refineCell));
938 label facei = testFaces[i];
940 label own = mesh_.faceOwner()[facei];
942 if (mesh_.isInternalFace(facei))
944 label nei = mesh_.faceNeighbour()[facei];
946 start[i] = cellCentres[own];
947 end[i] = cellCentres[nei];
948 minLevel[i] =
min(cellLevel[own], cellLevel[nei]);
952 label bFacei = facei - mesh_.nInternalFaces();
954 start[i] = cellCentres[own];
955 end[i] = neiCc[bFacei];
956 minLevel[i] =
min(cellLevel[own], neiLevel[bFacei]);
973 surfaces_.findHigherIntersection
989 label facei = testFaces[i];
991 label surfI = surfaceHit[i];
1001 label own = mesh_.faceOwner()[facei];
1003 if (surfaceMinLevel[i] > cellLevel[own])
1021 if (mesh_.isInternalFace(facei))
1023 label nei = mesh_.faceNeighbour()[facei];
1024 if (surfaceMinLevel[i] > cellLevel[nei])
1051 Info<<
"Reached refinement limit." <<
endl;
1070 const vector& n1 = normals1[i];
1074 const vector& n2 = normals2[j];
1089 Foam::label Foam::meshRefinement::markSurfaceCurvatureRefinement
1091 const scalar curvature,
1092 const label nAllowRefine,
1100 const labelList& cellLevel = meshCutter_.cellLevel();
1101 const pointField& cellCentres = mesh_.cellCentres();
1103 label oldNRefine = nRefine;
1117 labelList testFaces(getRefineCandidateFaces(refineCell));
1126 label facei = testFaces[i];
1128 label own = mesh_.faceOwner()[facei];
1130 if (mesh_.isInternalFace(facei))
1132 label nei = mesh_.faceNeighbour()[facei];
1134 start[i] = cellCentres[own];
1135 end[i] = cellCentres[nei];
1136 minLevel[i] =
min(cellLevel[own], cellLevel[nei]);
1140 label bFacei = facei - mesh_.nInternalFaces();
1142 start[i] = cellCentres[own];
1143 end[i] = neiCc[bFacei];
1145 if (!isMasterFace[facei])
1147 Swap(start[i], end[i]);
1150 minLevel[i] =
min(cellLevel[own], neiLevel[bFacei]);
1156 const vectorField smallVec(rootSmall*(end-start));
1173 surfaces_.findAllHigherIntersections
1180 surfaces_.maxLevel(),
1191 forAll(surfaceNormal, pointi)
1193 vectorList& pNormals = surfaceNormal[pointi];
1194 labelList& pLevel = surfaceLevel[pointi];
1210 label facei = testFaces[i];
1211 label own = mesh_.faceOwner()[facei];
1213 const vectorList& fNormals = surfaceNormal[i];
1214 const labelList& fLevels = surfaceLevel[i];
1218 if (fLevels[hitI] > cellLevel[own])
1220 cellSurfLevels[own].append(fLevels[hitI]);
1221 cellSurfNormals[own].append(fNormals[hitI]);
1224 if (mesh_.isInternalFace(facei))
1226 label nei = mesh_.faceNeighbour()[facei];
1227 if (fLevels[hitI] > cellLevel[nei])
1229 cellSurfLevels[nei].append(fLevels[hitI]);
1230 cellSurfNormals[nei].append(fNormals[hitI]);
1244 forAll(cellSurfNormals, celli)
1246 const vectorList& normals = cellSurfNormals[celli];
1250 nNormals += normals.
size();
1255 Info<<
"markSurfaceCurvatureRefinement :" 1256 <<
" cells:" << mesh_.globalData().nTotalCells()
1257 <<
" of which with normals:" << nSet
1258 <<
" ; total normals stored:" << nNormals
1264 bool reachedLimit =
false;
1273 !reachedLimit && celli < cellSurfNormals.size();
1277 const vectorList& normals = cellSurfNormals[celli];
1278 const labelList& levels = cellSurfLevels[celli];
1281 for (
label i = 0; !reachedLimit && i < normals.
size(); i++)
1283 for (
label j = i+1; !reachedLimit && j < normals.
size(); j++)
1285 if ((normals[i] & normals[j]) < curvature)
1287 label maxLevel =
max(levels[i], levels[j]);
1289 if (cellLevel[celli] < maxLevel)
1304 Pout<<
"Stopped refining since reaching my cell" 1305 <<
" limit of " << mesh_.nCells()+7*nRefine
1308 reachedLimit =
true;
1328 !reachedLimit && facei < mesh_.nInternalFaces();
1332 label own = mesh_.faceOwner()[facei];
1333 label nei = mesh_.faceNeighbour()[facei];
1335 const vectorList& ownNormals = cellSurfNormals[own];
1336 const labelList& ownLevels = cellSurfLevels[own];
1337 const vectorList& neiNormals = cellSurfNormals[nei];
1338 const labelList& neiLevels = cellSurfLevels[nei];
1346 countMatches(ownNormals, neiNormals)
1347 == ownNormals.
size();
1350 countMatches(neiNormals, ownNormals)
1351 == neiNormals.
size();
1354 if (!ownIsSubset && !neiIsSubset)
1357 for (
label i = 0; !reachedLimit && i < ownNormals.
size(); i++)
1359 for (
label j = 0; !reachedLimit && j < neiNormals.
size(); j++)
1362 if ((ownNormals[i] & neiNormals[j]) < curvature)
1365 if (cellLevel[own] < ownLevels[i])
1380 Pout<<
"Stopped refining since reaching" 1381 <<
" my cell limit of " 1382 << mesh_.nCells()+7*nRefine <<
endl;
1384 reachedLimit =
true;
1388 if (cellLevel[nei] < neiLevels[j])
1403 Pout<<
"Stopped refining since reaching" 1404 <<
" my cell limit of " 1405 << mesh_.nCells()+7*nRefine <<
endl;
1407 reachedLimit =
true;
1425 label facei = mesh_.nInternalFaces();
1426 !reachedLimit && facei < mesh_.nFaces();
1430 label own = mesh_.faceOwner()[facei];
1431 label bFacei = facei - mesh_.nInternalFaces();
1433 const vectorList& ownNormals = cellSurfNormals[own];
1434 const labelList& ownLevels = cellSurfLevels[own];
1435 const vectorList& neiNormals = neiSurfaceNormals[bFacei];
1442 countMatches(ownNormals, neiNormals)
1443 == ownNormals.
size();
1446 countMatches(neiNormals, ownNormals)
1447 == neiNormals.
size();
1450 if (!ownIsSubset && !neiIsSubset)
1453 for (
label i = 0; !reachedLimit && i < ownNormals.
size(); i++)
1455 for (
label j = 0; !reachedLimit && j < neiNormals.
size(); j++)
1458 if ((ownNormals[i] & neiNormals[j]) < curvature)
1460 if (cellLevel[own] < ownLevels[i])
1475 Pout<<
"Stopped refining since reaching" 1476 <<
" my cell limit of " 1477 << mesh_.nCells()+7*nRefine
1480 reachedLimit =
true;
1497 Info<<
"Reached refinement limit." <<
endl;
1506 const scalar planarCos,
1516 vector d = point1-point0;
1517 scalar magD =
mag(d);
1519 if (magD > mergeDistance())
1521 scalar cosAngle = (normal0 & normal1);
1524 if (cosAngle < (-1+planarCos))
1527 avg = 0.5*(normal0-normal1);
1529 else if (cosAngle > (1-planarCos))
1531 avg = 0.5*(normal0+normal1);
1539 if (
mag(avg&d) > mergeDistance())
1563 const scalar planarCos,
1573 vector d = point1-point0;
1574 scalar magD =
mag(d);
1576 if (magD > mergeDistance())
1578 scalar cosAngle = (normal0 & normal1);
1581 if (cosAngle < (-1+planarCos))
1584 avg = 0.5*(normal0-normal1);
1586 else if (cosAngle > (1-planarCos))
1588 avg = 0.5*(normal0+normal1);
1618 bool Foam::meshRefinement::checkProximity
1620 const scalar planarCos,
1621 const label nAllowRefine,
1623 const label surfaceLevel,
1624 const vector& surfaceLocation,
1625 const vector& surfaceNormal,
1629 label& cellMaxLevel,
1637 const labelList& cellLevel = meshCutter_.cellLevel();
1640 if (surfaceLevel > cellLevel[celli])
1642 if (cellMaxLevel == -1)
1645 cellMaxLevel = surfaceLevel;
1646 cellMaxLocation = surfaceLocation;
1647 cellMaxNormal = surfaceNormal;
1656 bool closeSurfaces = isNormalGap
1667 if (surfaceLevel > cellMaxLevel)
1669 cellMaxLevel = surfaceLevel;
1670 cellMaxLocation = surfaceLocation;
1671 cellMaxNormal = surfaceNormal;
1685 return markForRefine
1701 Foam::label Foam::meshRefinement::markProximityRefinement
1703 const scalar planarCos,
1704 const label nAllowRefine,
1712 const labelList& cellLevel = meshCutter_.cellLevel();
1713 const pointField& cellCentres = mesh_.cellCentres();
1715 label oldNRefine = nRefine;
1726 labelList testFaces(getRefineCandidateFaces(refineCell));
1735 label facei = testFaces[i];
1737 label own = mesh_.faceOwner()[facei];
1739 if (mesh_.isInternalFace(facei))
1741 label nei = mesh_.faceNeighbour()[facei];
1743 start[i] = cellCentres[own];
1744 end[i] = cellCentres[nei];
1745 minLevel[i] =
min(cellLevel[own], cellLevel[nei]);
1749 label bFacei = facei - mesh_.nInternalFaces();
1751 start[i] = cellCentres[own];
1752 end[i] = neiCc[bFacei];
1753 minLevel[i] =
min(cellLevel[own], neiLevel[bFacei]);
1759 const vectorField smallVec(rootSmall*(end-start));
1768 labelList cellMaxLevel(mesh_.nCells(), -1);
1779 surfaces_.findAllHigherIntersections
1786 surfaces_.gapLevel(),
1816 label facei = testFaces[i];
1817 label own = mesh_.faceOwner()[facei];
1819 const labelList& fLevels = surfaceLevel[i];
1820 const vectorList& fPoints = surfaceLocation[i];
1821 const vectorList& fNormals = surfaceNormal[i];
1836 cellMaxLocation[own],
1844 if (mesh_.isInternalFace(facei))
1846 label nei = mesh_.faceNeighbour()[facei];
1861 cellMaxLocation[nei],
1875 labelList neiBndMaxLevel(mesh_.nFaces()-mesh_.nInternalFaces());
1876 pointField neiBndMaxLocation(mesh_.nFaces()-mesh_.nInternalFaces());
1877 vectorField neiBndMaxNormal(mesh_.nFaces()-mesh_.nInternalFaces());
1879 for (
label facei = mesh_.nInternalFaces(); facei < mesh_.nFaces(); facei++)
1881 label bFacei = facei-mesh_.nInternalFaces();
1882 label own = mesh_.faceOwner()[facei];
1884 neiBndMaxLevel[bFacei] = cellMaxLevel[own];
1885 neiBndMaxLocation[bFacei] = cellMaxLocation[own];
1886 neiBndMaxNormal[bFacei] = cellMaxNormal[own];
1895 for (
label facei = 0; facei < mesh_.nInternalFaces(); facei++)
1897 label own = mesh_.faceOwner()[facei];
1898 label nei = mesh_.faceNeighbour()[facei];
1900 if (cellMaxLevel[own] != -1 && cellMaxLevel[nei] != -1)
1908 cellMaxLocation[own],
1910 cellMaxLocation[nei],
1916 if (cellLevel[own] < cellMaxLevel[own])
1931 Pout<<
"Stopped refining since reaching my cell" 1932 <<
" limit of " << mesh_.nCells()+7*nRefine
1939 if (cellLevel[nei] < cellMaxLevel[nei])
1954 Pout<<
"Stopped refining since reaching my cell" 1955 <<
" limit of " << mesh_.nCells()+7*nRefine
1965 for (
label facei = mesh_.nInternalFaces(); facei < mesh_.nFaces(); facei++)
1967 label own = mesh_.faceOwner()[facei];
1968 label bFacei = facei - mesh_.nInternalFaces();
1970 if (cellLevel[own] < cellMaxLevel[own] && neiBndMaxLevel[bFacei] != -1)
1978 cellMaxLocation[own],
1980 neiBndMaxLocation[bFacei],
1981 neiBndMaxNormal[bFacei]
1998 Pout<<
"Stopped refining since reaching my cell" 1999 <<
" limit of " << mesh_.nCells()+7*nRefine
2014 Info<<
"Reached refinement limit." <<
endl;
2031 const scalar curvature,
2032 const scalar planarAngle,
2034 const bool featureRefinement,
2035 const bool featureDistanceRefinement,
2036 const bool internalRefinement,
2037 const bool surfaceRefinement,
2038 const bool curvatureRefinement,
2039 const bool gapRefinement,
2040 const label maxGlobalCells,
2041 const label maxLocalCells
2044 label totNCells = mesh_.globalData().nTotalCells();
2048 if (totNCells >= maxGlobalCells)
2050 Info<<
"No cells marked for refinement since reached limit " 2051 << maxGlobalCells <<
'.' <<
endl;
2080 labelList refineCell(mesh_.nCells(), -1);
2085 labelList neiLevel(mesh_.nFaces()-mesh_.nInternalFaces());
2086 pointField neiCc(mesh_.nFaces()-mesh_.nInternalFaces());
2087 calcNeighbourData(neiLevel, neiCc);
2094 if (featureRefinement)
2096 label nFeatures = markFeatureRefinement
2105 Info<<
"Marked for refinement due to explicit features " 2106 <<
": " << nFeatures <<
" cells." <<
endl;
2112 if (featureDistanceRefinement)
2114 label nShell = markInternalDistanceToFeatureRefinement
2121 Info<<
"Marked for refinement due to distance to explicit features " 2122 ": " << nShell <<
" cells." <<
endl;
2128 if (internalRefinement)
2130 label nShell = markInternalRefinement
2137 Info<<
"Marked for refinement due to refinement shells " 2138 <<
": " << nShell <<
" cells." <<
endl;
2144 if (surfaceRefinement)
2146 label nSurf = markSurfaceRefinement
2155 Info<<
"Marked for refinement due to surface intersection " 2156 <<
": " << nSurf <<
" cells." <<
endl;
2165 && (curvature >= -1 && curvature <= 1)
2166 && (surfaces_.minLevel() != surfaces_.maxLevel())
2169 label nCurv = markSurfaceCurvatureRefinement
2179 Info<<
"Marked for refinement due to curvature/regions " 2180 <<
": " << nCurv <<
" cells." <<
endl;
2189 && (planarCos >= -1 && planarCos <= 1)
2190 && (
max(surfaces_.gapLevel()) > -1)
2193 Info<<
"Specified gap level : " <<
max(surfaces_.gapLevel())
2194 <<
", planar angle " << planarAngle <<
endl;
2196 label nGap = markProximityRefinement
2206 Info<<
"Marked for refinement due to close opposite surfaces " 2207 <<
": " << nGap <<
" cells." <<
endl;
2215 cellsToRefine.
setSize(nRefine);
2218 forAll(refineCell, celli)
2220 if (refineCell[celli] != -1)
2222 cellsToRefine[nRefine++] = celli;
2227 return cellsToRefine;
2240 meshCutter_.setRefinement(cellsToRefine, meshMod);
2246 mesh_.updateMesh(map);
2249 if (map().hasMotionPoints())
2251 mesh_.movePoints(map().preMotionPoints());
2263 updateMesh(map, getChangedFaces(map, cellsToRefine));
2278 const scalar maxLoadUnbalance
2282 refine(cellsToRefine);
2286 Pout<<
"Writing refined but unbalanced " << msg
2294 Pout<<
"Dumped debug data in = " 2295 << mesh_.time().cpuTimeIncrement() <<
" s" <<
endl;
2301 Info<<
"Refined mesh in = " 2302 << mesh_.time().cpuTimeIncrement() <<
" s" <<
endl;
2303 printMeshInfo(debug,
"After refinement " + msg);
2313 scalar nIdealCells =
2314 mesh_.globalData().nTotalCells()
2319 mag(1.0-mesh_.nCells()/nIdealCells),
2323 if (unbalance <= maxLoadUnbalance)
2325 Info<<
"Skipping balancing since max unbalance " << unbalance
2326 <<
" is less than allowable " << maxLoadUnbalance
2342 Info<<
"Balanced mesh in = " 2343 << mesh_.time().cpuTimeIncrement() <<
" s" <<
endl;
2345 printMeshInfo(debug,
"After balancing " + msg);
2348 if (debug&meshRefinement::MESH)
2350 Pout<<
"Writing balanced " << msg
2358 Pout<<
"Dumped debug data in = " 2359 << mesh_.time().cpuTimeIncrement() <<
" s" <<
endl;
2379 const scalar maxLoadUnbalance
2382 labelList cellsToRefine(initCellsToRefine);
2417 scalar nNewCells = scalar(mesh_.nCells() + 7*cellsToRefine.
size());
2418 scalar nIdealNewCells =
2423 mag(1.0-nNewCells/nIdealNewCells),
2427 if (unbalance <= maxLoadUnbalance)
2429 Info<<
"Skipping balancing since max unbalance " << unbalance
2430 <<
" is less than allowable " << maxLoadUnbalance
2438 cellWeights[cellsToRefine[i]] += 7;
2451 distMap().distributeCellIndices(cellsToRefine);
2453 Info<<
"Balanced mesh in = " 2454 << mesh_.time().cpuTimeIncrement() <<
" s" <<
endl;
2469 printMeshInfo(debug,
"After balancing " + msg);
2473 Pout<<
"Writing balanced " << msg
2481 Pout<<
"Dumped debug data in = " 2482 << mesh_.time().cpuTimeIncrement() <<
" s" <<
endl;
2493 refine(cellsToRefine);
2497 Pout<<
"Writing refined " << msg
2505 Pout<<
"Dumped debug data in = " 2506 << mesh_.time().cpuTimeIncrement() <<
" s" <<
endl;
2512 Info<<
"Refined mesh in = " 2513 << mesh_.time().cpuTimeIncrement() <<
" s" <<
endl;
2527 printMeshInfo(debug,
"After refinement " + msg);
Template class for intrusive linked lists.
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
#define forAll(list, i)
Loop across all elements in list.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
const word & name() const
Return name.
void sortedOrder(const UList< T > &, labelList &order)
Generate the (stable) sort order for the list.
labelList refineCandidates(const pointField &keepPoints, 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.
label nOldCells() const
Number of old cells.
const labelList & cellMap() const
Old cell map.
unsigned int get(const label) const
Get value at index I.
void deleteParticle(ParticleType &)
Remove particle from cloud and delete.
autoPtr< mapDistributePolyMesh > balanceAndRefine(const string &msg, decompositionMethod &decomposer, fvMeshDistribute &distributor, const labelList &cellsToRefine, const scalar maxLoadUnbalance)
Balance before refining some cells.
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
label nInternalFaces() const
virtual const labelList & faceNeighbour() const
Return face neighbour.
#define forAllIter(Container, container, iter)
Iterate across all elements in the container object of type.
void size(const label)
Override size to be inconsistent with allocated storage.
const dimensionedScalar b
Wien displacement law constant: default SI units: [m K].
Ostream & endl(Ostream &os)
Add newline and flush stream.
vectorList cmptType
Component type.
Traits class for primitives.
const cellList & cells() const
label size() const
Return the number of particles in the cloud.
label otherVertex(const label a) const
Given one vertex, return the other.
labelList findIndices(const ListType &, typename ListType::const_reference, const label start=0)
Find all occurrences of given element. Linear search.
static bool less(const vector &x, const vector &y)
To compare normals.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
scalar degToRad(const scalar deg)
Conversion from degrees to radians.
labelList cmptType
Component type.
Particle class that marks cells it passes through. Used to mark cells visited by feature edges...
Sends/receives parts of mesh+fvfields to neighbouring processors. Used in load balancing.
static const direction nComponents
Number of components in this vector space.
const labelListList & pointEdges() const
Return edges.
void addParticle(ParticleType *pPtr)
Transfer particle to cloud.
label nTotalFaces() const
Return total number of faces in decomposed mesh. Not.
dimensionedScalar cos(const dimensionedScalar &ds)
void set(const PackedList< 1 > &)
Set specified bits.
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
autoPtr< mapDistributePolyMesh > refineAndBalance(const string &msg, decompositionMethod &decomposer, fvMeshDistribute &distributor, const labelList &cellsToRefine, const scalar maxLoadUnbalance)
Refine some cells and rebalance.
void clear()
Clear the list, i.e. set size to zero.
A cloud is a collection of lagrangian particles.
const edgeList & edges() const
Return edges.
point & end()
Point to track to.
virtual const labelList & faceOwner() const
Return face owner.
void write(std::ostream &os, const bool binary, List< floatScalar > &fField)
Write floats ascii or binary.
const globalMeshData & globalData() const
Return parallel info.
static const label labelMax
List< label > labelList
A List of labels.
point & start()
Point to track from.
Abstract base class for decomposition.
label k() const
Transported label.
Base cloud calls templated on particle type.
dimensioned< scalar > magSqr(const dimensioned< Type > &)
const pointField & points() const
Return points.
Points connected by edges.
Class used to pass tracking data to the trackToFace function.
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
autoPtr< mapPolyMesh > refine(const labelList &cellsToRefine)
Refine some cells.
void setSize(const label)
Reset size of List.
void move(TrackCloudType &cloud, typename ParticleType::trackingData &td, const scalar trackTime)
Move the particles.
static label nProcs(const label communicator=0)
Number of processes in parallel run.
A cell is defined as a list of faces with extra functionality.
prefixOSstream Pout(cout, "Pout")
A List with indirect addressing.
Direct mesh changes based on v1.3 polyTopoChange syntax.
label i() const
Transported label.
const polyMesh & mesh() const
Return polyMesh.
label start() const
Return start label of this patch in the polyMesh face list.
normalLess(const vectorList &values)
dimensioned< scalar > mag(const dimensioned< Type > &)
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.
Mesh consisting of general polyhedral cells.
bool isGap(const scalar, const vector &, const vector &, const vector &, const vector &) const
Is local topology a small gap?
autoPtr< mapPolyMesh > changeMesh(polyMesh &mesh, const bool inflate, const bool syncParallel=true, const bool orderCells=false, const bool orderPoints=false)
Inplace changes mesh without change of patches.
virtual bool write(const bool write=true) const
Write using setting from DB.
label regions(labelList &edgeRegion) const
Find connected regions. Set region number per edge.
label j() const
Transported label.
A patch is a list of labels that address the faces in the global face list.
bool isNormalGap(const scalar, const vector &, const vector &, const vector &, const vector &) const
Is local topology a small gap normal to the test vector.
vector position() const
Return current particle position.
static const Vector< scalar > zero
label start() const
Return start vertex label.
bool operator()(const label a, const label b) const