81 return less(values_[a], values_[b]);
127 label nMasterChanged = 0;
147 forAll(oldCellsToRefine, i)
149 oldRefineCell.set(oldCellsToRefine[i], 1u);
157 for (
label facei = 0; facei < nInternalFaces; facei++)
165 && oldRefineCell.get(oldOwn) == 0u
167 && oldRefineCell.get(oldNei) == 0u
174 refinedInternalFace.
set(facei, 1u);
181 boolList refinedBoundaryFace(mesh.
nFaces()-nInternalFaces,
false);
193 if (oldOwn >= 0 && oldRefineCell.get(oldOwn) == 0u)
199 refinedBoundaryFace[facei-nInternalFaces] =
true;
219 forAll(refinedInternalFace, facei)
221 if (refinedInternalFace.
get(facei) == 1u)
223 const cell& ownFaces = cells[faceOwner[facei]];
226 changedFace[ownFaces[ownI]] =
true;
228 const cell& neiFaces = cells[faceNeighbour[facei]];
231 changedFace[neiFaces[neiI]] =
true;
236 forAll(refinedBoundaryFace, i)
238 if (refinedBoundaryFace[i])
240 const cell& ownFaces = cells[faceOwner[i+nInternalFaces]];
243 changedFace[ownFaces[ownI]] =
true;
264 forAll(changedFace, facei)
266 if (changedFace[facei] && isMasterFace[facei])
276 Pout<<
"getChangedFaces : Detected " 277 <<
" local:" << changedFaces.
size()
282 faceSet changedFacesSet(mesh,
"changedFaces", changedFaces);
283 Pout<<
"getChangedFaces : Writing " << changedFaces.
size()
284 <<
" changed faces to faceSet " << changedFacesSet.
name()
286 changedFacesSet.
write();
296 bool Foam::meshRefinement::markForRefine
298 const label markValue,
299 const label nAllowRefine,
307 cellValue = markValue;
311 return nRefine <= nAllowRefine;
315 void Foam::meshRefinement::markFeatureCellLevel
351 const point& keepPoint = keepPoints[i];
360 (void)mesh_.cellTree();
363 mesh_.findCellFacePt(keepPoint, celli, tetFacei, tetPtI);
372 const edgeMesh& featureMesh = features_[featI];
373 const label featureLevel = features_.levels()[featI][0];
387 forAll(pointEdges, pointi)
389 if (pointEdges[pointi].size() != 2)
393 Pout<<
"Adding particle from point:" << pointi
394 <<
" coord:" << featureMesh.
points()[pointi]
395 <<
" since number of emanating edges:" 396 << pointEdges[pointi].
size()
410 featureMesh.
points()[pointi],
419 if (pointEdges[pointi].size() > 0)
421 label e0 = pointEdges[pointi][0];
422 label regionI = edgeRegion[e0];
423 regionVisited[regionI] = 1u;
433 if (regionVisited.
set(edgeRegion[edgeI], 1u))
439 Pout<<
"Adding particle from point:" << pointi
440 <<
" coord:" << featureMesh.
points()[pointi]
441 <<
" on circular region:" << edgeRegion[edgeI]
455 featureMesh.
points()[pointi],
470 maxFeatureLevel =
labelList(mesh_.nCells(), -1);
477 featureEdgeVisited[featI].setSize(features_[featI].edges().size());
478 featureEdgeVisited[featI] = 0u;
493 scalar maxTrackLen = 2.0*mesh_.bounds().mag();
497 Pout<<
"Tracking " << startPointCloud.
size()
498 <<
" particles over distance " << maxTrackLen
499 <<
" to find the starting cell" <<
endl;
501 startPointCloud.
move(td, maxTrackLen);
505 maxFeatureLevel = -1;
508 featureEdgeVisited[featI] = 0u;
519 if (debug&meshRefinement::FEATURESEEDS)
521 Pout<<
"Constructing cloud for cell marking" <<
endl;
528 label featI = startTp.
i();
529 label pointi = startTp.
j();
531 const edgeMesh& featureMesh = features_[featI];
537 label edgeI = pEdges[pEdgeI];
539 if (featureEdgeVisited[featI].
set(edgeI, 1u))
548 tp->
end() = featureMesh.
points()[otherPointi];
549 tp->
j() = otherPointi;
552 if (debug&meshRefinement::FEATURESEEDS)
554 Pout<<
"Adding particle for point:" << pointi
556 <<
" feature:" << featI
557 <<
" to track to:" << tp->
end()
566 startPointCloud.
clear();
572 if (debug&meshRefinement::FEATURESEEDS)
575 <<
" particles over distance " << maxTrackLen
576 <<
" to mark cells" <<
endl;
578 cloud.
move(td, maxTrackLen);
588 const edgeMesh& featureMesh = features_[featI];
594 bool keepParticle =
false;
598 label edgeI = pEdges[i];
600 if (featureEdgeVisited[featI].
set(edgeI, 1u))
608 tp.
end() = featureMesh.
points()[otherPointi];
609 tp.
j() = otherPointi;
625 if (debug&meshRefinement::FEATURESEEDS)
655 Foam::label Foam::meshRefinement::markFeatureRefinement
658 const label nAllowRefine,
666 markFeatureCellLevel(keepPoints, maxFeatureLevel);
671 const labelList& cellLevel = meshCutter_.cellLevel();
673 label oldNRefine = nRefine;
675 forAll(maxFeatureLevel, celli)
677 if (maxFeatureLevel[celli] > cellLevel[celli])
703 Info<<
"Reached refinement limit." <<
endl;
711 Foam::label Foam::meshRefinement::markInternalDistanceToFeatureRefinement
713 const label nAllowRefine,
719 const labelList& cellLevel = meshCutter_.cellLevel();
720 const pointField& cellCentres = mesh_.cellCentres();
723 if (features_.maxDistance() <= 0.0)
728 label oldNRefine = nRefine;
737 if (refineCell[celli] == -1)
739 testCc[testI] = cellCentres[celli];
740 testLevels[testI] = cellLevel[celli];
747 features_.findHigherLevel(testCc, testLevels, maxLevel);
754 if (refineCell[celli] == -1)
756 if (maxLevel[testI] > testLevels[testI])
758 bool reachedLimit = !markForRefine
770 Pout<<
"Stopped refining internal cells" 771 <<
" since reaching my cell limit of " 772 << mesh_.nCells()+7*nRefine <<
endl;
787 Info<<
"Reached refinement limit." <<
endl;
795 Foam::label Foam::meshRefinement::markInternalRefinement
797 const label nAllowRefine,
803 const labelList& cellLevel = meshCutter_.cellLevel();
804 const pointField& cellCentres = mesh_.cellCentres();
806 label oldNRefine = nRefine;
815 if (refineCell[celli] == -1)
817 testCc[testI] = cellCentres[celli];
818 testLevels[testI] = cellLevel[celli];
825 shells_.findHigherLevel(testCc, testLevels, maxLevel);
832 if (refineCell[celli] == -1)
834 if (maxLevel[testI] > testLevels[testI])
836 bool reachedLimit = !markForRefine
848 Pout<<
"Stopped refining internal cells" 849 <<
" since reaching my cell limit of " 850 << mesh_.nCells()+7*nRefine <<
endl;
865 Info<<
"Reached refinement limit." <<
endl;
883 forAll(surfaceIndex_, facei)
885 if (surfaceIndex_[facei] != -1)
887 label own = mesh_.faceOwner()[facei];
889 if (mesh_.isInternalFace(facei))
891 label nei = mesh_.faceNeighbour()[facei];
893 if (refineCell[own] == -1 || refineCell[nei] == -1)
895 testFaces[nTest++] = facei;
900 if (refineCell[own] == -1)
902 testFaces[nTest++] = facei;
907 testFaces.setSize(nTest);
914 Foam::label Foam::meshRefinement::markSurfaceRefinement
916 const label nAllowRefine,
924 const labelList& cellLevel = meshCutter_.cellLevel();
925 const pointField& cellCentres = mesh_.cellCentres();
927 label oldNRefine = nRefine;
935 labelList testFaces(getRefineCandidateFaces(refineCell));
946 label facei = testFaces[i];
948 label own = mesh_.faceOwner()[facei];
950 if (mesh_.isInternalFace(facei))
952 label nei = mesh_.faceNeighbour()[facei];
954 start[i] = cellCentres[own];
955 end[i] = cellCentres[nei];
956 minLevel[i] =
min(cellLevel[own], cellLevel[nei]);
960 label bFacei = facei - mesh_.nInternalFaces();
962 start[i] = cellCentres[own];
963 end[i] = neiCc[bFacei];
964 minLevel[i] =
min(cellLevel[own], neiLevel[bFacei]);
981 surfaces_.findHigherIntersection
997 label facei = testFaces[i];
999 label surfI = surfaceHit[i];
1009 label own = mesh_.faceOwner()[facei];
1011 if (surfaceMinLevel[i] > cellLevel[own])
1029 if (mesh_.isInternalFace(facei))
1031 label nei = mesh_.faceNeighbour()[facei];
1032 if (surfaceMinLevel[i] > cellLevel[nei])
1059 Info<<
"Reached refinement limit." <<
endl;
1078 const vector& n1 = normals1[i];
1082 const vector& n2 = normals2[j];
1097 Foam::label Foam::meshRefinement::markSurfaceCurvatureRefinement
1099 const scalar curvature,
1100 const label nAllowRefine,
1108 const labelList& cellLevel = meshCutter_.cellLevel();
1109 const pointField& cellCentres = mesh_.cellCentres();
1111 label oldNRefine = nRefine;
1125 labelList testFaces(getRefineCandidateFaces(refineCell));
1134 label facei = testFaces[i];
1136 label own = mesh_.faceOwner()[facei];
1138 if (mesh_.isInternalFace(facei))
1140 label nei = mesh_.faceNeighbour()[facei];
1142 start[i] = cellCentres[own];
1143 end[i] = cellCentres[nei];
1144 minLevel[i] =
min(cellLevel[own], cellLevel[nei]);
1148 label bFacei = facei - mesh_.nInternalFaces();
1150 start[i] = cellCentres[own];
1151 end[i] = neiCc[bFacei];
1153 if (!isMasterFace[facei])
1155 Swap(start[i], end[i]);
1158 minLevel[i] =
min(cellLevel[own], neiLevel[bFacei]);
1164 const vectorField smallVec(ROOTSMALL*(end-start));
1181 surfaces_.findAllHigherIntersections
1188 surfaces_.maxLevel(),
1199 forAll(surfaceNormal, pointi)
1201 vectorList& pNormals = surfaceNormal[pointi];
1202 labelList& pLevel = surfaceLevel[pointi];
1218 label facei = testFaces[i];
1219 label own = mesh_.faceOwner()[facei];
1221 const vectorList& fNormals = surfaceNormal[i];
1222 const labelList& fLevels = surfaceLevel[i];
1226 if (fLevels[hitI] > cellLevel[own])
1228 cellSurfLevels[own].append(fLevels[hitI]);
1229 cellSurfNormals[own].append(fNormals[hitI]);
1232 if (mesh_.isInternalFace(facei))
1234 label nei = mesh_.faceNeighbour()[facei];
1235 if (fLevels[hitI] > cellLevel[nei])
1237 cellSurfLevels[nei].append(fLevels[hitI]);
1238 cellSurfNormals[nei].append(fNormals[hitI]);
1252 forAll(cellSurfNormals, celli)
1254 const vectorList& normals = cellSurfNormals[celli];
1258 nNormals += normals.
size();
1263 Info<<
"markSurfaceCurvatureRefinement :" 1264 <<
" cells:" << mesh_.globalData().nTotalCells()
1265 <<
" of which with normals:" << nSet
1266 <<
" ; total normals stored:" << nNormals
1272 bool reachedLimit =
false;
1281 !reachedLimit && celli < cellSurfNormals.size();
1285 const vectorList& normals = cellSurfNormals[celli];
1286 const labelList& levels = cellSurfLevels[celli];
1289 for (
label i = 0; !reachedLimit && i < normals.
size(); i++)
1291 for (
label j = i+1; !reachedLimit && j < normals.
size(); j++)
1293 if ((normals[i] & normals[j]) < curvature)
1295 label maxLevel =
max(levels[i], levels[j]);
1297 if (cellLevel[celli] < maxLevel)
1312 Pout<<
"Stopped refining since reaching my cell" 1313 <<
" limit of " << mesh_.nCells()+7*nRefine
1316 reachedLimit =
true;
1336 !reachedLimit && facei < mesh_.nInternalFaces();
1340 label own = mesh_.faceOwner()[facei];
1341 label nei = mesh_.faceNeighbour()[facei];
1343 const vectorList& ownNormals = cellSurfNormals[own];
1344 const labelList& ownLevels = cellSurfLevels[own];
1345 const vectorList& neiNormals = cellSurfNormals[nei];
1346 const labelList& neiLevels = cellSurfLevels[nei];
1354 countMatches(ownNormals, neiNormals)
1355 == ownNormals.
size();
1358 countMatches(neiNormals, ownNormals)
1359 == neiNormals.
size();
1362 if (!ownIsSubset && !neiIsSubset)
1365 for (
label i = 0; !reachedLimit && i < ownNormals.
size(); i++)
1367 for (
label j = 0; !reachedLimit && j < neiNormals.
size(); j++)
1370 if ((ownNormals[i] & neiNormals[j]) < curvature)
1373 if (cellLevel[own] < ownLevels[i])
1388 Pout<<
"Stopped refining since reaching" 1389 <<
" my cell limit of " 1390 << mesh_.nCells()+7*nRefine <<
endl;
1392 reachedLimit =
true;
1396 if (cellLevel[nei] < neiLevels[j])
1411 Pout<<
"Stopped refining since reaching" 1412 <<
" my cell limit of " 1413 << mesh_.nCells()+7*nRefine <<
endl;
1415 reachedLimit =
true;
1433 label facei = mesh_.nInternalFaces();
1434 !reachedLimit && facei < mesh_.nFaces();
1438 label own = mesh_.faceOwner()[facei];
1439 label bFacei = facei - mesh_.nInternalFaces();
1441 const vectorList& ownNormals = cellSurfNormals[own];
1442 const labelList& ownLevels = cellSurfLevels[own];
1443 const vectorList& neiNormals = neiSurfaceNormals[bFacei];
1450 countMatches(ownNormals, neiNormals)
1451 == ownNormals.
size();
1454 countMatches(neiNormals, ownNormals)
1455 == neiNormals.
size();
1458 if (!ownIsSubset && !neiIsSubset)
1461 for (
label i = 0; !reachedLimit && i < ownNormals.
size(); i++)
1463 for (
label j = 0; !reachedLimit && j < neiNormals.
size(); j++)
1466 if ((ownNormals[i] & neiNormals[j]) < curvature)
1468 if (cellLevel[own] < ownLevels[i])
1483 Pout<<
"Stopped refining since reaching" 1484 <<
" my cell limit of " 1485 << mesh_.nCells()+7*nRefine
1488 reachedLimit =
true;
1505 Info<<
"Reached refinement limit." <<
endl;
1514 const scalar planarCos,
1524 vector d = point1-point0;
1525 scalar magD =
mag(d);
1527 if (magD > mergeDistance())
1529 scalar cosAngle = (normal0 & normal1);
1532 if (cosAngle < (-1+planarCos))
1535 avg = 0.5*(normal0-normal1);
1537 else if (cosAngle > (1-planarCos))
1539 avg = 0.5*(normal0+normal1);
1547 if (
mag(avg&d) > mergeDistance())
1571 const scalar planarCos,
1581 vector d = point1-point0;
1582 scalar magD =
mag(d);
1584 if (magD > mergeDistance())
1586 scalar cosAngle = (normal0 & normal1);
1589 if (cosAngle < (-1+planarCos))
1592 avg = 0.5*(normal0-normal1);
1594 else if (cosAngle > (1-planarCos))
1596 avg = 0.5*(normal0+normal1);
1626 bool Foam::meshRefinement::checkProximity
1628 const scalar planarCos,
1629 const label nAllowRefine,
1631 const label surfaceLevel,
1632 const vector& surfaceLocation,
1633 const vector& surfaceNormal,
1637 label& cellMaxLevel,
1645 const labelList& cellLevel = meshCutter_.cellLevel();
1648 if (surfaceLevel > cellLevel[celli])
1650 if (cellMaxLevel == -1)
1653 cellMaxLevel = surfaceLevel;
1654 cellMaxLocation = surfaceLocation;
1655 cellMaxNormal = surfaceNormal;
1664 bool closeSurfaces = isNormalGap
1675 if (surfaceLevel > cellMaxLevel)
1677 cellMaxLevel = surfaceLevel;
1678 cellMaxLocation = surfaceLocation;
1679 cellMaxNormal = surfaceNormal;
1693 return markForRefine
1709 Foam::label Foam::meshRefinement::markProximityRefinement
1711 const scalar planarCos,
1712 const label nAllowRefine,
1720 const labelList& cellLevel = meshCutter_.cellLevel();
1721 const pointField& cellCentres = mesh_.cellCentres();
1723 label oldNRefine = nRefine;
1734 labelList testFaces(getRefineCandidateFaces(refineCell));
1743 label facei = testFaces[i];
1745 label own = mesh_.faceOwner()[facei];
1747 if (mesh_.isInternalFace(facei))
1749 label nei = mesh_.faceNeighbour()[facei];
1751 start[i] = cellCentres[own];
1752 end[i] = cellCentres[nei];
1753 minLevel[i] =
min(cellLevel[own], cellLevel[nei]);
1757 label bFacei = facei - mesh_.nInternalFaces();
1759 start[i] = cellCentres[own];
1760 end[i] = neiCc[bFacei];
1761 minLevel[i] =
min(cellLevel[own], neiLevel[bFacei]);
1767 const vectorField smallVec(ROOTSMALL*(end-start));
1776 labelList cellMaxLevel(mesh_.nCells(), -1);
1787 surfaces_.findAllHigherIntersections
1794 surfaces_.gapLevel(),
1824 label facei = testFaces[i];
1825 label own = mesh_.faceOwner()[facei];
1827 const labelList& fLevels = surfaceLevel[i];
1828 const vectorList& fPoints = surfaceLocation[i];
1829 const vectorList& fNormals = surfaceNormal[i];
1844 cellMaxLocation[own],
1852 if (mesh_.isInternalFace(facei))
1854 label nei = mesh_.faceNeighbour()[facei];
1869 cellMaxLocation[nei],
1883 labelList neiBndMaxLevel(mesh_.nFaces()-mesh_.nInternalFaces());
1884 pointField neiBndMaxLocation(mesh_.nFaces()-mesh_.nInternalFaces());
1885 vectorField neiBndMaxNormal(mesh_.nFaces()-mesh_.nInternalFaces());
1887 for (
label facei = mesh_.nInternalFaces(); facei < mesh_.nFaces(); facei++)
1889 label bFacei = facei-mesh_.nInternalFaces();
1890 label own = mesh_.faceOwner()[facei];
1892 neiBndMaxLevel[bFacei] = cellMaxLevel[own];
1893 neiBndMaxLocation[bFacei] = cellMaxLocation[own];
1894 neiBndMaxNormal[bFacei] = cellMaxNormal[own];
1903 for (
label facei = 0; facei < mesh_.nInternalFaces(); facei++)
1905 label own = mesh_.faceOwner()[facei];
1906 label nei = mesh_.faceNeighbour()[facei];
1908 if (cellMaxLevel[own] != -1 && cellMaxLevel[nei] != -1)
1916 cellMaxLocation[own],
1918 cellMaxLocation[nei],
1924 if (cellLevel[own] < cellMaxLevel[own])
1939 Pout<<
"Stopped refining since reaching my cell" 1940 <<
" limit of " << mesh_.nCells()+7*nRefine
1947 if (cellLevel[nei] < cellMaxLevel[nei])
1962 Pout<<
"Stopped refining since reaching my cell" 1963 <<
" limit of " << mesh_.nCells()+7*nRefine
1973 for (
label facei = mesh_.nInternalFaces(); facei < mesh_.nFaces(); facei++)
1975 label own = mesh_.faceOwner()[facei];
1976 label bFacei = facei - mesh_.nInternalFaces();
1978 if (cellLevel[own] < cellMaxLevel[own] && neiBndMaxLevel[bFacei] != -1)
1986 cellMaxLocation[own],
1988 neiBndMaxLocation[bFacei],
1989 neiBndMaxNormal[bFacei]
2006 Pout<<
"Stopped refining since reaching my cell" 2007 <<
" limit of " << mesh_.nCells()+7*nRefine
2022 Info<<
"Reached refinement limit." <<
endl;
2039 const scalar curvature,
2040 const scalar planarAngle,
2042 const bool featureRefinement,
2043 const bool featureDistanceRefinement,
2044 const bool internalRefinement,
2045 const bool surfaceRefinement,
2046 const bool curvatureRefinement,
2047 const bool gapRefinement,
2048 const label maxGlobalCells,
2049 const label maxLocalCells
2052 label totNCells = mesh_.globalData().nTotalCells();
2056 if (totNCells >= maxGlobalCells)
2058 Info<<
"No cells marked for refinement since reached limit " 2059 << maxGlobalCells <<
'.' <<
endl;
2088 labelList refineCell(mesh_.nCells(), -1);
2093 labelList neiLevel(mesh_.nFaces()-mesh_.nInternalFaces());
2094 pointField neiCc(mesh_.nFaces()-mesh_.nInternalFaces());
2095 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;
2173 && (curvature >= -1 && curvature <= 1)
2174 && (surfaces_.minLevel() != surfaces_.maxLevel())
2177 label nCurv = markSurfaceCurvatureRefinement
2187 Info<<
"Marked for refinement due to curvature/regions " 2188 <<
": " << nCurv <<
" cells." <<
endl;
2197 && (planarCos >= -1 && planarCos <= 1)
2198 && (
max(surfaces_.gapLevel()) > -1)
2201 Info<<
"Specified gap level : " <<
max(surfaces_.gapLevel())
2202 <<
", planar angle " << planarAngle <<
endl;
2204 label nGap = markProximityRefinement
2214 Info<<
"Marked for refinement due to close opposite surfaces " 2215 <<
": " << nGap <<
" cells." <<
endl;
2223 cellsToRefine.
setSize(nRefine);
2226 forAll(refineCell, celli)
2228 if (refineCell[celli] != -1)
2230 cellsToRefine[nRefine++] = celli;
2235 return cellsToRefine;
2248 meshCutter_.setRefinement(cellsToRefine, meshMod);
2254 mesh_.updateMesh(map);
2257 if (map().hasMotionPoints())
2259 mesh_.movePoints(map().preMotionPoints());
2271 updateMesh(map, getChangedFaces(map, cellsToRefine));
2286 const scalar maxLoadUnbalance
2290 refine(cellsToRefine);
2294 Pout<<
"Writing refined but unbalanced " << msg
2302 Pout<<
"Dumped debug data in = " 2303 << mesh_.time().cpuTimeIncrement() <<
" s" <<
endl;
2309 Info<<
"Refined mesh in = " 2310 << mesh_.time().cpuTimeIncrement() <<
" s" <<
endl;
2311 printMeshInfo(debug,
"After refinement " + msg);
2321 scalar nIdealCells =
2322 mesh_.globalData().nTotalCells()
2327 mag(1.0-mesh_.nCells()/nIdealCells),
2331 if (unbalance <= maxLoadUnbalance)
2333 Info<<
"Skipping balancing since max unbalance " << unbalance
2334 <<
" is less than allowable " << maxLoadUnbalance
2350 Info<<
"Balanced mesh in = " 2351 << mesh_.time().cpuTimeIncrement() <<
" s" <<
endl;
2353 printMeshInfo(debug,
"After balancing " + msg);
2356 if (debug&meshRefinement::MESH)
2358 Pout<<
"Writing balanced " << msg
2366 Pout<<
"Dumped debug data in = " 2367 << mesh_.time().cpuTimeIncrement() <<
" s" <<
endl;
2387 const scalar maxLoadUnbalance
2390 labelList cellsToRefine(initCellsToRefine);
2425 scalar nNewCells = scalar(mesh_.nCells() + 7*cellsToRefine.
size());
2426 scalar nIdealNewCells =
2431 mag(1.0-nNewCells/nIdealNewCells),
2435 if (unbalance <= maxLoadUnbalance)
2437 Info<<
"Skipping balancing since max unbalance " << unbalance
2438 <<
" is less than allowable " << maxLoadUnbalance
2446 cellWeights[cellsToRefine[i]] += 7;
2459 distMap().distributeCellIndices(cellsToRefine);
2461 Info<<
"Balanced mesh in = " 2462 << mesh_.time().cpuTimeIncrement() <<
" s" <<
endl;
2477 printMeshInfo(debug,
"After balancing " + msg);
2481 Pout<<
"Writing balanced " << msg
2489 Pout<<
"Dumped debug data in = " 2490 << mesh_.time().cpuTimeIncrement() <<
" s" <<
endl;
2501 refine(cellsToRefine);
2505 Pout<<
"Writing refined " << msg
2513 Pout<<
"Dumped debug data in = " 2514 << mesh_.time().cpuTimeIncrement() <<
" s" <<
endl;
2520 Info<<
"Refined mesh in = " 2521 << mesh_.time().cpuTimeIncrement() <<
" s" <<
endl;
2535 printMeshInfo(debug,
"After refinement " + msg);
#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.
void sortedOrder(const UList< T > &, labelList &order)
Generate the (stable) sort order for the list.
void deleteParticle(ParticleType &)
Remove particle from cloud and delete.
const double e
Elementary charge.
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 > &)
#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.
label i() const
Transported label.
Ostream & endl(Ostream &os)
Add newline and flush stream.
vectorList cmptType
Component type.
Traits class for primitives.
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 occurences of given element. Linear search.
const cellList & cells() const
static bool less(const vector &x, const vector &y)
To compare normals.
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
scalar degToRad(const scalar deg)
Conversion from degrees to radians.
const pointField & points() const
Return points.
const vector & position() const
Return current particle position.
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.
void addParticle(ParticleType *pPtr)
Transfer particle to cloud.
dimensionedScalar cos(const dimensionedScalar &ds)
void set(const PackedList< 1 > &)
Set specified bits.
label start() const
Return start label of this patch in the polyMesh face list.
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.
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
void clear()
Clear the list, i.e. set size to zero.
bool operator()(const label a, const label b) const
A cloud is a collection of lagrangian particles.
label nTotalFaces() const
Return total number of faces in decomposed mesh. Not.
point & end()
Point to track to.
static const label labelMax
List< label > labelList
A List of labels.
Abstract base class for decomposition.
bool isGap(const scalar, const vector &, const vector &, const vector &, const vector &) const
Is local topology a small gap?
void move(TrackData &td, const scalar trackTime)
Move the particles.
const globalMeshData & globalData() const
Return parallel info.
dimensioned< scalar > magSqr(const dimensioned< Type > &)
prefixOSstream Pout(cout,"Pout")
label start() const
Return start vertex label.
bool isNormalGap(const scalar, const vector &, const vector &, const vector &, const vector &) const
Is local topology a small gap normal to the test vector.
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)
label nOldCells() const
Number of old cells.
autoPtr< mapPolyMesh > refine(const labelList &cellsToRefine)
Refine some cells.
label regions(labelList &edgeRegion) const
Find connected regions. Set region number per edge.
void setSize(const label)
Reset size of List.
static label nProcs(const label communicator=0)
Number of processes in parallel run.
virtual const labelList & faceNeighbour() const
Return face neighbour.
const labelList & cellMap() const
Old cell map.
label j() const
Transported label.
A cell is defined as a list of faces with extra functionality.
A List with indirect addressing.
Direct mesh changes based on v1.3 polyTopoChange syntax.
const edgeList & edges() const
Return edges.
normalLess(const vectorList &values)
virtual bool write() const
Write using setting from DB.
dimensioned< scalar > mag(const dimensioned< Type > &)
label k() const
Transported label.
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...
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.
Mesh consisting of general polyhedral cells.
static const Vector< scalar > zero
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 const labelList & faceOwner() const
Return face owner.
A patch is a list of labels that address the faces in the global face list.
label nInternalFaces() const
const word & name() const
Return name.
const polyMesh & mesh() const
Return polyMesh.
unsigned int get(const label) const
Get value at index I.
const labelListList & pointEdges() const
Return edges.