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++)
159 const label oldNei = map.
cellMap()[faceNeighbour[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
352 const point& insidePoint = insidePoints[i];
354 const label celli = mesh_.cellTree().findInside(insidePoint);
362 const edgeMesh& featureMesh = features_[feati];
363 const label featureLevel = features_.levels()[feati][0];
377 forAll(pointEdges, pointi)
379 if (pointEdges[pointi].size() != 2)
383 Pout<<
"Adding particle from point:" << pointi
384 <<
" coord:" << featureMesh.
points()[pointi]
385 <<
" since number of emanating edges:" 386 << pointEdges[pointi].
size()
398 featureMesh.
points()[pointi],
407 if (pointEdges[pointi].size() > 0)
409 label e0 = pointEdges[pointi][0];
410 label regioni = edgeRegion[e0];
411 regionVisited[regioni] = 1u;
421 if (regionVisited.
set(edgeRegion[edgei], 1u))
427 Pout<<
"Adding particle from point:" << pointi
428 <<
" coord:" << featureMesh.
points()[pointi]
429 <<
" on circular region:" << edgeRegion[edgei]
441 featureMesh.
points()[pointi],
456 maxFeatureLevel =
labelList(mesh_.nCells(), -1);
463 featureEdgeVisited[feati].setSize(features_[feati].edges().size());
464 featureEdgeVisited[feati] = 0u;
479 scalar maxTrackLen = 2.0*mesh_.bounds().mag();
483 Pout<<
"Tracking " << startPointCloud.
size()
484 <<
" particles over distance " << maxTrackLen
485 <<
" to find the starting cell" <<
endl;
487 startPointCloud.
move(startPointCloud, td, maxTrackLen);
491 maxFeatureLevel = -1;
494 featureEdgeVisited[feati] = 0u;
505 if (debug&meshRefinement::FEATURESEEDS)
507 Pout<<
"Constructing cloud for cell marking" <<
endl;
514 const label feati = startTp.
i();
515 const label pointi = startTp.
j();
517 const edgeMesh& featureMesh = features_[feati];
523 const label edgei = pEdges[pEdgei];
525 if (featureEdgeVisited[feati].
set(edgei, 1u))
535 tp->
end() = featureMesh.
points()[otherPointi];
536 tp->
j() = otherPointi;
539 if (debug&meshRefinement::FEATURESEEDS)
541 Pout<<
"Adding particle for point:" << pointi
543 <<
" feature:" << feati
544 <<
" to track to:" << tp->
end()
553 startPointCloud.
clear();
559 if (debug&meshRefinement::FEATURESEEDS)
562 <<
" particles over distance " << maxTrackLen
563 <<
" to mark cells" <<
endl;
565 cloud.
move(cloud, td, maxTrackLen);
572 const label feati = tp.
i();
573 const label pointi = tp.
j();
575 const edgeMesh& featureMesh = features_[feati];
581 bool keepParticle =
false;
585 const label edgei = pEdges[i];
587 if (featureEdgeVisited[feati].
set(edgei, 1u))
596 tp.
end() = featureMesh.
points()[otherPointi];
597 tp.
j() = otherPointi;
613 if (debug&meshRefinement::FEATURESEEDS)
643 Foam::label Foam::meshRefinement::markFeatureRefinement
646 const label nAllowRefine,
654 markFeatureCellLevel(insidePoints, maxFeatureLevel);
659 const labelList& cellLevel = meshCutter_.cellLevel();
661 const label oldNRefine = nRefine;
663 forAll(maxFeatureLevel, celli)
665 if (maxFeatureLevel[celli] > cellLevel[celli])
691 Info<<
"Reached refinement limit." <<
endl;
699 Foam::label Foam::meshRefinement::markInternalDistanceToFeatureRefinement
701 const label nAllowRefine,
707 const labelList& cellLevel = meshCutter_.cellLevel();
708 const pointField& cellCentres = mesh_.cellCentres();
711 if (features_.maxDistance() <= 0.0)
716 label oldNRefine = nRefine;
725 if (refineCell[celli] == -1)
727 testCc[testi] = cellCentres[celli];
728 testLevels[testi] = cellLevel[celli];
735 features_.findHigherLevel(testCc, testLevels, maxLevel);
742 if (refineCell[celli] == -1)
744 if (maxLevel[testi] > testLevels[testi])
746 const bool reachedLimit = !markForRefine
758 Pout<<
"Stopped refining internal cells" 759 <<
" since reaching my cell limit of " 760 << mesh_.nCells()+7*nRefine <<
endl;
775 Info<<
"Reached refinement limit." <<
endl;
782 Foam::label Foam::meshRefinement::markInternalRefinement
784 const label nAllowRefine,
790 const labelList& cellLevel = meshCutter_.cellLevel();
791 const pointField& cellCentres = mesh_.cellCentres();
793 const label oldNRefine = nRefine;
802 if (refineCell[celli] == -1)
804 testCc[testi] = cellCentres[celli];
805 testLevels[testi] = cellLevel[celli];
812 shells_.findHigherLevel
816 meshCutter_.level0EdgeLength(),
825 if (refineCell[celli] == -1)
827 if (maxLevel[testi] > testLevels[testi])
829 bool reachedLimit = !markForRefine
841 Pout<<
"Stopped refining internal cells" 842 <<
" since reaching my cell limit of " 843 << mesh_.nCells()+7*nRefine <<
endl;
858 Info<<
"Reached refinement limit." <<
endl;
874 forAll(surfaceIndex_, facei)
876 if (surfaceIndex_[facei] != -1)
878 label own = mesh_.faceOwner()[facei];
880 if (mesh_.isInternalFace(facei))
882 const label nei = mesh_.faceNeighbour()[facei];
884 if (refineCell[own] == -1 || refineCell[nei] == -1)
886 testFaces[nTest++] = facei;
891 if (refineCell[own] == -1)
893 testFaces[nTest++] = facei;
898 testFaces.setSize(nTest);
904 Foam::label Foam::meshRefinement::markSurfaceRefinement
906 const label nAllowRefine,
914 const labelList& cellLevel = meshCutter_.cellLevel();
915 const pointField& cellCentres = mesh_.cellCentres();
917 const label oldNRefine = nRefine;
925 labelList testFaces(getRefineCandidateFaces(refineCell));
936 const label facei = testFaces[i];
938 const label own = mesh_.faceOwner()[facei];
940 if (mesh_.isInternalFace(facei))
942 label nei = mesh_.faceNeighbour()[facei];
944 start[i] = cellCentres[own];
945 end[i] = cellCentres[nei];
946 minLevel[i] =
min(cellLevel[own], cellLevel[nei]);
950 const label bFacei = facei - mesh_.nInternalFaces();
952 start[i] = cellCentres[own];
953 end[i] = neiCc[bFacei];
954 minLevel[i] =
min(cellLevel[own], neiLevel[bFacei]);
971 surfaces_.findHigherIntersection
987 const label facei = testFaces[i];
989 const label surfi = surfaceHit[i];
999 const label own = mesh_.faceOwner()[facei];
1001 if (surfaceMinLevel[i] > cellLevel[own])
1019 if (mesh_.isInternalFace(facei))
1021 const label nei = mesh_.faceNeighbour()[facei];
1023 if (surfaceMinLevel[i] > cellLevel[nei])
1050 Info<<
"Reached refinement limit." <<
endl;
1069 const vector& n1 = normals1[i];
1073 const vector& n2 = normals2[j];
1088 Foam::label Foam::meshRefinement::markSurfaceCurvatureRefinement
1090 const scalar curvature,
1091 const label nAllowRefine,
1099 const labelList& cellLevel = meshCutter_.cellLevel();
1100 const pointField& cellCentres = mesh_.cellCentres();
1102 const label oldNRefine = nRefine;
1116 labelList testFaces(getRefineCandidateFaces(refineCell));
1125 const label facei = testFaces[i];
1126 const label own = mesh_.faceOwner()[facei];
1128 if (mesh_.isInternalFace(facei))
1130 const label nei = mesh_.faceNeighbour()[facei];
1132 start[i] = cellCentres[own];
1133 end[i] = cellCentres[nei];
1134 minLevel[i] =
min(cellLevel[own], cellLevel[nei]);
1138 const label bFacei = facei - mesh_.nInternalFaces();
1140 start[i] = cellCentres[own];
1141 end[i] = neiCc[bFacei];
1143 if (!isMasterFace[facei])
1145 Swap(start[i], end[i]);
1148 minLevel[i] =
min(cellLevel[own], neiLevel[bFacei]);
1154 const vectorField smallVec(rootSmall*(end-start));
1172 surfaces_.findAllHigherIntersections
1179 surfaces_.maxLevel(),
1190 forAll(surfaceNormal, pointi)
1192 vectorList& pNormals = surfaceNormal[pointi];
1193 labelList& pLevel = surfaceLevel[pointi];
1209 const label facei = testFaces[i];
1210 const label own = mesh_.faceOwner()[facei];
1212 const vectorList& fNormals = surfaceNormal[i];
1213 const labelList& fLevels = surfaceLevel[i];
1217 if (fLevels[hiti] > cellLevel[own])
1219 cellSurfLevels[own].append(fLevels[hiti]);
1220 cellSurfNormals[own].append(fNormals[hiti]);
1223 if (mesh_.isInternalFace(facei))
1225 label nei = mesh_.faceNeighbour()[facei];
1226 if (fLevels[hiti] > cellLevel[nei])
1228 cellSurfLevels[nei].append(fLevels[hiti]);
1229 cellSurfNormals[nei].append(fNormals[hiti]);
1243 forAll(cellSurfNormals, celli)
1245 const vectorList& normals = cellSurfNormals[celli];
1249 nNormals += normals.
size();
1254 Info<<
"markSurfaceCurvatureRefinement :" 1255 <<
" cells:" << mesh_.globalData().nTotalCells()
1256 <<
" of which with normals:" << nSet
1257 <<
" ; total normals stored:" << nNormals
1263 bool reachedLimit =
false;
1272 !reachedLimit && celli < cellSurfNormals.size();
1276 const vectorList& normals = cellSurfNormals[celli];
1277 const labelList& levels = cellSurfLevels[celli];
1280 for (
label i = 0; !reachedLimit && i < normals.
size(); i++)
1282 for (
label j = i+1; !reachedLimit && j < normals.
size(); j++)
1284 if ((normals[i] & normals[j]) < curvature)
1286 const label maxLevel =
max(levels[i], levels[j]);
1288 if (cellLevel[celli] < maxLevel)
1303 Pout<<
"Stopped refining since reaching my cell" 1304 <<
" limit of " << mesh_.nCells()+7*nRefine
1307 reachedLimit =
true;
1327 !reachedLimit && facei < mesh_.nInternalFaces();
1331 const label own = mesh_.faceOwner()[facei];
1332 const label nei = mesh_.faceNeighbour()[facei];
1334 const vectorList& ownNormals = cellSurfNormals[own];
1335 const labelList& ownLevels = cellSurfLevels[own];
1336 const vectorList& neiNormals = cellSurfNormals[nei];
1337 const labelList& neiLevels = cellSurfLevels[nei];
1345 countMatches(ownNormals, neiNormals)
1346 == ownNormals.
size();
1349 countMatches(neiNormals, ownNormals)
1350 == neiNormals.
size();
1353 if (!ownisSubset && !neiisSubset)
1356 for (
label i = 0; !reachedLimit && i < ownNormals.
size(); i++)
1358 for (
label j = 0; !reachedLimit && j < neiNormals.
size(); j++)
1361 if ((ownNormals[i] & neiNormals[j]) < curvature)
1364 if (cellLevel[own] < ownLevels[i])
1379 Pout<<
"Stopped refining since reaching" 1380 <<
" my cell limit of " 1381 << mesh_.nCells()+7*nRefine <<
endl;
1383 reachedLimit =
true;
1387 if (cellLevel[nei] < neiLevels[j])
1402 Pout<<
"Stopped refining since reaching" 1403 <<
" my cell limit of " 1404 << mesh_.nCells()+7*nRefine <<
endl;
1406 reachedLimit =
true;
1424 label facei = mesh_.nInternalFaces();
1425 !reachedLimit && facei < mesh_.nFaces();
1429 label own = mesh_.faceOwner()[facei];
1430 label bFacei = facei - mesh_.nInternalFaces();
1432 const vectorList& ownNormals = cellSurfNormals[own];
1433 const labelList& ownLevels = cellSurfLevels[own];
1434 const vectorList& neiNormals = neiSurfaceNormals[bFacei];
1441 countMatches(ownNormals, neiNormals)
1442 == ownNormals.
size();
1445 countMatches(neiNormals, ownNormals)
1446 == neiNormals.
size();
1449 if (!ownisSubset && !neiisSubset)
1452 for (
label i = 0; !reachedLimit && i < ownNormals.
size(); i++)
1454 for (
label j = 0; !reachedLimit && j < neiNormals.
size(); j++)
1457 if ((ownNormals[i] & neiNormals[j]) < curvature)
1459 if (cellLevel[own] < ownLevels[i])
1474 Pout<<
"Stopped refining since reaching" 1475 <<
" my cell limit of " 1476 << mesh_.nCells()+7*nRefine
1479 reachedLimit =
true;
1496 Info<<
"Reached refinement limit." <<
endl;
1505 const scalar planarCos,
1515 const vector d = point1 - point0;
1516 const scalar magD =
mag(d);
1518 if (magD > mergeDistance())
1520 scalar cosAngle = (normal0 & normal1);
1523 if (cosAngle < (-1+planarCos))
1526 avg = 0.5*(normal0-normal1);
1528 else if (cosAngle > (1-planarCos))
1530 avg = 0.5*(normal0+normal1);
1538 if (
mag(avg&d) > mergeDistance())
1562 const scalar planarCos,
1572 vector d = point1 - point0;
1573 const scalar magD =
mag(d);
1575 if (magD > mergeDistance())
1577 scalar cosAngle = (normal0 & normal1);
1580 if (cosAngle < (-1+planarCos))
1583 avg = 0.5*(normal0-normal1);
1585 else if (cosAngle > (1-planarCos))
1587 avg = 0.5*(normal0+normal1);
1617 bool Foam::meshRefinement::checkProximity
1619 const scalar planarCos,
1620 const label nAllowRefine,
1622 const label surfaceLevel,
1623 const vector& surfaceLocation,
1624 const vector& surfaceNormal,
1628 label& cellMaxLevel,
1636 const labelList& cellLevel = meshCutter_.cellLevel();
1639 if (surfaceLevel > cellLevel[celli])
1641 if (cellMaxLevel == -1)
1644 cellMaxLevel = surfaceLevel;
1645 cellMaxLocation = surfaceLocation;
1646 cellMaxNormal = surfaceNormal;
1655 bool closeSurfaces = isNormalGap
1666 if (surfaceLevel > cellMaxLevel)
1668 cellMaxLevel = surfaceLevel;
1669 cellMaxLocation = surfaceLocation;
1670 cellMaxNormal = surfaceNormal;
1684 return markForRefine
1700 Foam::label Foam::meshRefinement::markProximityRefinement
1702 const scalar planarCos,
1703 const label nAllowRefine,
1711 const labelList& cellLevel = meshCutter_.cellLevel();
1712 const pointField& cellCentres = mesh_.cellCentres();
1714 const label oldNRefine = nRefine;
1725 labelList testFaces(getRefineCandidateFaces(refineCell));
1734 const label facei = testFaces[i];
1735 const label own = mesh_.faceOwner()[facei];
1737 if (mesh_.isInternalFace(facei))
1739 const label nei = mesh_.faceNeighbour()[facei];
1741 start[i] = cellCentres[own];
1742 end[i] = cellCentres[nei];
1743 minLevel[i] =
min(cellLevel[own], cellLevel[nei]);
1747 const label bFacei = facei - mesh_.nInternalFaces();
1749 start[i] = cellCentres[own];
1750 end[i] = neiCc[bFacei];
1751 minLevel[i] =
min(cellLevel[own], neiLevel[bFacei]);
1757 const vectorField smallVec(rootSmall*(end-start));
1766 labelList cellMaxLevel(mesh_.nCells(), -1);
1777 surfaces_.findAllHigherIntersections
1784 surfaces_.gapLevel(),
1814 label facei = testFaces[i];
1815 label own = mesh_.faceOwner()[facei];
1817 const labelList& fLevels = surfaceLevel[i];
1818 const vectorList& fPoints = surfaceLocation[i];
1819 const vectorList& fNormals = surfaceNormal[i];
1834 cellMaxLocation[own],
1842 if (mesh_.isInternalFace(facei))
1844 label nei = mesh_.faceNeighbour()[facei];
1859 cellMaxLocation[nei],
1873 labelList neiBndMaxLevel(mesh_.nFaces()-mesh_.nInternalFaces());
1874 pointField neiBndMaxLocation(mesh_.nFaces()-mesh_.nInternalFaces());
1875 vectorField neiBndMaxNormal(mesh_.nFaces()-mesh_.nInternalFaces());
1877 for (
label facei = mesh_.nInternalFaces(); facei < mesh_.nFaces(); facei++)
1879 const label bFacei = facei-mesh_.nInternalFaces();
1880 const label own = mesh_.faceOwner()[facei];
1882 neiBndMaxLevel[bFacei] = cellMaxLevel[own];
1883 neiBndMaxLocation[bFacei] = cellMaxLocation[own];
1884 neiBndMaxNormal[bFacei] = cellMaxNormal[own];
1893 for (
label facei = 0; facei < mesh_.nInternalFaces(); facei++)
1895 const label own = mesh_.faceOwner()[facei];
1896 const label nei = mesh_.faceNeighbour()[facei];
1898 if (cellMaxLevel[own] != -1 && cellMaxLevel[nei] != -1)
1906 cellMaxLocation[own],
1908 cellMaxLocation[nei],
1914 if (cellLevel[own] < cellMaxLevel[own])
1929 Pout<<
"Stopped refining since reaching my cell" 1930 <<
" limit of " << mesh_.nCells()+7*nRefine
1937 if (cellLevel[nei] < cellMaxLevel[nei])
1952 Pout<<
"Stopped refining since reaching my cell" 1953 <<
" limit of " << mesh_.nCells()+7*nRefine
1963 for (
label facei = mesh_.nInternalFaces(); facei < mesh_.nFaces(); facei++)
1965 const label own = mesh_.faceOwner()[facei];
1966 const label bFacei = facei - mesh_.nInternalFaces();
1968 if (cellLevel[own] < cellMaxLevel[own] && neiBndMaxLevel[bFacei] != -1)
1976 cellMaxLocation[own],
1978 neiBndMaxLocation[bFacei],
1979 neiBndMaxNormal[bFacei]
1996 Pout<<
"Stopped refining since reaching my cell" 1997 <<
" limit of " << mesh_.nCells()+7*nRefine
2012 Info<<
"Reached refinement limit." <<
endl;
2029 const scalar curvature,
2030 const scalar planarAngle,
2032 const bool featureRefinement,
2033 const bool featureDistanceRefinement,
2034 const bool internalRefinement,
2035 const bool surfaceRefinement,
2036 const bool curvatureRefinement,
2037 const bool gapRefinement,
2038 const label maxGlobalCells,
2039 const label maxLocalCells
2042 const label totNCells = mesh_.globalData().nTotalCells();
2046 if (totNCells >= maxGlobalCells)
2048 Info<<
"No cells marked for refinement since reached limit " 2049 << maxGlobalCells <<
'.' <<
endl;
2078 labelList refineCell(mesh_.nCells(), -1);
2083 labelList neiLevel(mesh_.nFaces()-mesh_.nInternalFaces());
2084 pointField neiCc(mesh_.nFaces()-mesh_.nInternalFaces());
2085 calcNeighbourData(neiLevel, neiCc);
2092 if (featureRefinement)
2094 const label nFeatures = markFeatureRefinement
2103 Info<<
"Marked for refinement due to explicit features " 2104 <<
": " << nFeatures <<
" cells." <<
endl;
2110 if (featureDistanceRefinement)
2112 const label nCellsFeat = markInternalDistanceToFeatureRefinement
2119 Info<<
"Marked for refinement due to distance to explicit features " 2120 ": " << nCellsFeat <<
" cells." <<
endl;
2126 if (internalRefinement)
2128 const label nShell = markInternalRefinement
2135 Info<<
"Marked for refinement due to refinement shells " 2136 <<
": " << nShell <<
" cells." <<
endl;
2142 if (surfaceRefinement)
2144 const label nSurf = markSurfaceRefinement
2153 Info<<
"Marked for refinement due to surface intersection " 2154 <<
": " << nSurf <<
" cells." <<
endl;
2163 && (curvature >= -1 && curvature <= 1)
2164 && (surfaces_.minLevel() != surfaces_.maxLevel())
2167 const label nCurv = markSurfaceCurvatureRefinement
2177 Info<<
"Marked for refinement due to curvature/regions " 2178 <<
": " << nCurv <<
" cells." <<
endl;
2187 && (planarCos >= -1 && planarCos <= 1)
2188 && (
max(surfaces_.gapLevel()) > -1)
2191 Info<<
"Specified gap level : " <<
max(surfaces_.gapLevel())
2192 <<
", planar angle " << planarAngle <<
endl;
2194 const label nGap = markProximityRefinement
2204 Info<<
"Marked for refinement due to close opposite surfaces " 2205 <<
": " << nGap <<
" cells." <<
endl;
2213 cellsToRefine.
setSize(nRefine);
2216 forAll(refineCell, celli)
2218 if (refineCell[celli] != -1)
2220 cellsToRefine[nRefine++] = celli;
2225 return cellsToRefine;
2238 meshCutter_.setRefinement(cellsToRefine, meshMod);
2244 mesh_.topoChange(map);
2247 if (map().hasMotionPoints())
2249 mesh_.movePoints(map().preMotionPoints());
2274 const scalar maxLoadUnbalance
2278 refine(cellsToRefine);
2282 Pout<<
"Writing refined but unbalanced " << msg
2290 Pout<<
"Dumped debug data in = " 2291 << mesh_.time().cpuTimeIncrement() <<
" s" <<
endl;
2297 Info<<
"Refined mesh in = " 2298 << mesh_.time().cpuTimeIncrement() <<
" s" <<
endl;
2299 printMeshInfo(debug,
"After refinement " + msg);
2309 const scalar nIdealCells =
2310 mesh_.globalData().nTotalCells()
2315 mag(1.0-mesh_.nCells()/nIdealCells),
2319 if (unbalance <= maxLoadUnbalance)
2321 Info<<
"Skipping balancing since max unbalance " << unbalance
2322 <<
" is less than allowable " << maxLoadUnbalance
2338 Info<<
"Balanced mesh in = " 2339 << mesh_.time().cpuTimeIncrement() <<
" s" <<
endl;
2341 printMeshInfo(debug,
"After balancing " + msg);
2344 if (debug&meshRefinement::MESH)
2346 Pout<<
"Writing balanced " << msg
2354 Pout<<
"Dumped debug data in = " 2355 << mesh_.time().cpuTimeIncrement() <<
" s" <<
endl;
2375 const scalar maxLoadUnbalance
2378 labelList cellsToRefine(initCellsToRefine);
2413 const scalar nNewCells =
2414 scalar(mesh_.nCells() + 7*cellsToRefine.
size());
2415 const scalar nIdealNewCells =
2419 mag(1.0-nNewCells/nIdealNewCells),
2423 if (unbalance <= maxLoadUnbalance)
2425 Info<<
"Skipping balancing since max unbalance " << unbalance
2426 <<
" is less than allowable " << maxLoadUnbalance
2434 cellWeights[cellsToRefine[i]] += 7;
2447 distMap().distributeCellIndices(cellsToRefine);
2449 Info<<
"Balanced mesh in = " 2450 << mesh_.time().cpuTimeIncrement() <<
" s" <<
endl;
2465 printMeshInfo(debug,
"After balancing " + msg);
2469 Pout<<
"Writing balanced " << msg
2477 Pout<<
"Dumped debug data in = " 2478 << mesh_.time().cpuTimeIncrement() <<
" s" <<
endl;
2489 refine(cellsToRefine);
2493 Pout<<
"Writing refined " << msg
2501 Pout<<
"Dumped debug data in = " 2502 << mesh_.time().cpuTimeIncrement() <<
" s" <<
endl;
2508 Info<<
"Refined mesh in = " 2509 << mesh_.time().cpuTimeIncrement() <<
" s" <<
endl;
2523 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.
autoPtr< polyTopoChangeMap > 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.
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
const word & name() const
Return name.
void sortedOrder(const UList< T > &, labelList &order)
Generate the (stable) sort order for the list.
unsigned int get(const label) const
Get value at index I.
void deleteParticle(ParticleType &)
Remove particle from cloud and delete.
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.
autoPtr< polyDistributionMap > balanceAndRefine(const string &msg, decompositionMethod &decomposer, fvMeshDistribute &distributor, const labelList &cellsToRefine, const scalar maxLoadUnbalance)
Balance before refining some cells.
scalar degToRad(const scalar deg)
Conversion from degrees to radians.
const labelList & cellMap() const
Old cell map.
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.
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.
autoPtr< polyTopoChangeMap > refine(const labelList &cellsToRefine)
Refine some cells.
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...
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
labelList getChangedFaces(const polyMesh &mesh, const labelHashSet &patchIDs)
Get initial set of changed faces.
A cloud is a collection of lagrangian particles.
const edgeList & edges() const
Return edges.
point & end()
Point to track to.
autoPtr< polyDistributionMap > refineAndBalance(const string &msg, decompositionMethod &decomposer, fvMeshDistribute &distributor, const labelList &cellsToRefine, const scalar maxLoadUnbalance)
Refine some cells and rebalance.
virtual const labelList & faceOwner() const
Return face owner.
void write(std::ostream &os, const bool binary, List< floatScalar > &fField)
Write floats ascii or binary.
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
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.
const polyMesh & mesh() const
Return polyMesh.
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.
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
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.
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?
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.
label nOldCells() const
Number of old cells.
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