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];
353 const label celli = mesh_.cellTree().findInside(keepPoint);
361 const edgeMesh& featureMesh = features_[featI];
362 const label featureLevel = features_.levels()[featI][0];
376 forAll(pointEdges, pointi)
378 if (pointEdges[pointi].size() != 2)
382 Pout<<
"Adding particle from point:" << pointi
383 <<
" coord:" << featureMesh.
points()[pointi]
384 <<
" since number of emanating edges:" 385 << pointEdges[pointi].
size()
397 featureMesh.
points()[pointi],
406 if (pointEdges[pointi].size() > 0)
408 label e0 = pointEdges[pointi][0];
409 label regionI = edgeRegion[e0];
410 regionVisited[regionI] = 1u;
420 if (regionVisited.
set(edgeRegion[edgeI], 1u))
426 Pout<<
"Adding particle from point:" << pointi
427 <<
" coord:" << featureMesh.
points()[pointi]
428 <<
" on circular region:" << edgeRegion[edgeI]
440 featureMesh.
points()[pointi],
455 maxFeatureLevel =
labelList(mesh_.nCells(), -1);
462 featureEdgeVisited[featI].setSize(features_[featI].edges().size());
463 featureEdgeVisited[featI] = 0u;
478 scalar maxTrackLen = 2.0*mesh_.bounds().mag();
482 Pout<<
"Tracking " << startPointCloud.
size()
483 <<
" particles over distance " << maxTrackLen
484 <<
" to find the starting cell" <<
endl;
486 startPointCloud.
move(startPointCloud, td, maxTrackLen);
490 maxFeatureLevel = -1;
493 featureEdgeVisited[featI] = 0u;
504 if (debug&meshRefinement::FEATURESEEDS)
506 Pout<<
"Constructing cloud for cell marking" <<
endl;
513 label featI = startTp.
i();
514 label pointi = startTp.
j();
516 const edgeMesh& featureMesh = features_[featI];
522 label edgeI = pEdges[pEdgeI];
524 if (featureEdgeVisited[featI].
set(edgeI, 1u))
534 tp->
end() = featureMesh.
points()[otherPointi];
535 tp->
j() = otherPointi;
538 if (debug&meshRefinement::FEATURESEEDS)
540 Pout<<
"Adding particle for point:" << pointi
542 <<
" feature:" << featI
543 <<
" to track to:" << tp->
end()
552 startPointCloud.
clear();
558 if (debug&meshRefinement::FEATURESEEDS)
561 <<
" particles over distance " << maxTrackLen
562 <<
" to mark cells" <<
endl;
564 cloud.
move(cloud, td, maxTrackLen);
574 const edgeMesh& featureMesh = features_[featI];
580 bool keepParticle =
false;
584 label edgeI = pEdges[i];
586 if (featureEdgeVisited[featI].
set(edgeI, 1u))
595 tp.
end() = featureMesh.
points()[otherPointi];
596 tp.
j() = otherPointi;
612 if (debug&meshRefinement::FEATURESEEDS)
642 Foam::label Foam::meshRefinement::markFeatureRefinement
645 const label nAllowRefine,
653 markFeatureCellLevel(keepPoints, maxFeatureLevel);
658 const labelList& cellLevel = meshCutter_.cellLevel();
660 label oldNRefine = nRefine;
662 forAll(maxFeatureLevel, celli)
664 if (maxFeatureLevel[celli] > cellLevel[celli])
690 Info<<
"Reached refinement limit." <<
endl;
698 Foam::label Foam::meshRefinement::markInternalDistanceToFeatureRefinement
700 const label nAllowRefine,
706 const labelList& cellLevel = meshCutter_.cellLevel();
707 const pointField& cellCentres = mesh_.cellCentres();
710 if (features_.maxDistance() <= 0.0)
715 label oldNRefine = nRefine;
724 if (refineCell[celli] == -1)
726 testCc[testI] = cellCentres[celli];
727 testLevels[testI] = cellLevel[celli];
734 features_.findHigherLevel(testCc, testLevels, maxLevel);
741 if (refineCell[celli] == -1)
743 if (maxLevel[testI] > testLevels[testI])
745 bool reachedLimit = !markForRefine
757 Pout<<
"Stopped refining internal cells" 758 <<
" since reaching my cell limit of " 759 << mesh_.nCells()+7*nRefine <<
endl;
774 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 label oldNRefine = nRefine;
802 if (refineCell[celli] == -1)
804 testCc[testI] = cellCentres[celli];
805 testLevels[testI] = cellLevel[celli];
812 shells_.findHigherLevel(testCc, testLevels, maxLevel);
819 if (refineCell[celli] == -1)
821 if (maxLevel[testI] > testLevels[testI])
823 bool reachedLimit = !markForRefine
835 Pout<<
"Stopped refining internal cells" 836 <<
" since reaching my cell limit of " 837 << mesh_.nCells()+7*nRefine <<
endl;
852 Info<<
"Reached refinement limit." <<
endl;
870 forAll(surfaceIndex_, facei)
872 if (surfaceIndex_[facei] != -1)
874 label own = mesh_.faceOwner()[facei];
876 if (mesh_.isInternalFace(facei))
878 label nei = mesh_.faceNeighbour()[facei];
880 if (refineCell[own] == -1 || refineCell[nei] == -1)
882 testFaces[nTest++] = facei;
887 if (refineCell[own] == -1)
889 testFaces[nTest++] = facei;
894 testFaces.setSize(nTest);
901 Foam::label Foam::meshRefinement::markSurfaceRefinement
903 const label nAllowRefine,
911 const labelList& cellLevel = meshCutter_.cellLevel();
912 const pointField& cellCentres = mesh_.cellCentres();
914 label oldNRefine = nRefine;
922 labelList testFaces(getRefineCandidateFaces(refineCell));
933 label facei = testFaces[i];
935 label own = mesh_.faceOwner()[facei];
937 if (mesh_.isInternalFace(facei))
939 label nei = mesh_.faceNeighbour()[facei];
941 start[i] = cellCentres[own];
942 end[i] = cellCentres[nei];
943 minLevel[i] =
min(cellLevel[own], cellLevel[nei]);
947 label bFacei = facei - mesh_.nInternalFaces();
949 start[i] = cellCentres[own];
950 end[i] = neiCc[bFacei];
951 minLevel[i] =
min(cellLevel[own], neiLevel[bFacei]);
968 surfaces_.findHigherIntersection
984 label facei = testFaces[i];
986 label surfI = surfaceHit[i];
996 label own = mesh_.faceOwner()[facei];
998 if (surfaceMinLevel[i] > cellLevel[own])
1016 if (mesh_.isInternalFace(facei))
1018 label nei = mesh_.faceNeighbour()[facei];
1019 if (surfaceMinLevel[i] > cellLevel[nei])
1046 Info<<
"Reached refinement limit." <<
endl;
1065 const vector& n1 = normals1[i];
1069 const vector& n2 = normals2[j];
1084 Foam::label Foam::meshRefinement::markSurfaceCurvatureRefinement
1086 const scalar curvature,
1087 const label nAllowRefine,
1095 const labelList& cellLevel = meshCutter_.cellLevel();
1096 const pointField& cellCentres = mesh_.cellCentres();
1098 label oldNRefine = nRefine;
1112 labelList testFaces(getRefineCandidateFaces(refineCell));
1121 label facei = testFaces[i];
1123 label own = mesh_.faceOwner()[facei];
1125 if (mesh_.isInternalFace(facei))
1127 label nei = mesh_.faceNeighbour()[facei];
1129 start[i] = cellCentres[own];
1130 end[i] = cellCentres[nei];
1131 minLevel[i] =
min(cellLevel[own], cellLevel[nei]);
1135 label bFacei = facei - mesh_.nInternalFaces();
1137 start[i] = cellCentres[own];
1138 end[i] = neiCc[bFacei];
1140 if (!isMasterFace[facei])
1142 Swap(start[i], end[i]);
1145 minLevel[i] =
min(cellLevel[own], neiLevel[bFacei]);
1151 const vectorField smallVec(rootSmall*(end-start));
1168 surfaces_.findAllHigherIntersections
1175 surfaces_.maxLevel(),
1186 forAll(surfaceNormal, pointi)
1188 vectorList& pNormals = surfaceNormal[pointi];
1189 labelList& pLevel = surfaceLevel[pointi];
1205 label facei = testFaces[i];
1206 label own = mesh_.faceOwner()[facei];
1208 const vectorList& fNormals = surfaceNormal[i];
1209 const labelList& fLevels = surfaceLevel[i];
1213 if (fLevels[hitI] > cellLevel[own])
1215 cellSurfLevels[own].append(fLevels[hitI]);
1216 cellSurfNormals[own].append(fNormals[hitI]);
1219 if (mesh_.isInternalFace(facei))
1221 label nei = mesh_.faceNeighbour()[facei];
1222 if (fLevels[hitI] > cellLevel[nei])
1224 cellSurfLevels[nei].append(fLevels[hitI]);
1225 cellSurfNormals[nei].append(fNormals[hitI]);
1239 forAll(cellSurfNormals, celli)
1241 const vectorList& normals = cellSurfNormals[celli];
1245 nNormals += normals.
size();
1250 Info<<
"markSurfaceCurvatureRefinement :" 1251 <<
" cells:" << mesh_.globalData().nTotalCells()
1252 <<
" of which with normals:" << nSet
1253 <<
" ; total normals stored:" << nNormals
1259 bool reachedLimit =
false;
1268 !reachedLimit && celli < cellSurfNormals.size();
1272 const vectorList& normals = cellSurfNormals[celli];
1273 const labelList& levels = cellSurfLevels[celli];
1276 for (
label i = 0; !reachedLimit && i < normals.
size(); i++)
1278 for (
label j = i+1; !reachedLimit && j < normals.
size(); j++)
1280 if ((normals[i] & normals[j]) < curvature)
1282 label maxLevel =
max(levels[i], levels[j]);
1284 if (cellLevel[celli] < maxLevel)
1299 Pout<<
"Stopped refining since reaching my cell" 1300 <<
" limit of " << mesh_.nCells()+7*nRefine
1303 reachedLimit =
true;
1323 !reachedLimit && facei < mesh_.nInternalFaces();
1327 label own = mesh_.faceOwner()[facei];
1328 label nei = mesh_.faceNeighbour()[facei];
1330 const vectorList& ownNormals = cellSurfNormals[own];
1331 const labelList& ownLevels = cellSurfLevels[own];
1332 const vectorList& neiNormals = cellSurfNormals[nei];
1333 const labelList& neiLevels = cellSurfLevels[nei];
1341 countMatches(ownNormals, neiNormals)
1342 == ownNormals.
size();
1345 countMatches(neiNormals, ownNormals)
1346 == neiNormals.
size();
1349 if (!ownIsSubset && !neiIsSubset)
1352 for (
label i = 0; !reachedLimit && i < ownNormals.
size(); i++)
1354 for (
label j = 0; !reachedLimit && j < neiNormals.
size(); j++)
1357 if ((ownNormals[i] & neiNormals[j]) < curvature)
1360 if (cellLevel[own] < ownLevels[i])
1375 Pout<<
"Stopped refining since reaching" 1376 <<
" my cell limit of " 1377 << mesh_.nCells()+7*nRefine <<
endl;
1379 reachedLimit =
true;
1383 if (cellLevel[nei] < neiLevels[j])
1398 Pout<<
"Stopped refining since reaching" 1399 <<
" my cell limit of " 1400 << mesh_.nCells()+7*nRefine <<
endl;
1402 reachedLimit =
true;
1420 label facei = mesh_.nInternalFaces();
1421 !reachedLimit && facei < mesh_.nFaces();
1425 label own = mesh_.faceOwner()[facei];
1426 label bFacei = facei - mesh_.nInternalFaces();
1428 const vectorList& ownNormals = cellSurfNormals[own];
1429 const labelList& ownLevels = cellSurfLevels[own];
1430 const vectorList& neiNormals = neiSurfaceNormals[bFacei];
1437 countMatches(ownNormals, neiNormals)
1438 == ownNormals.
size();
1441 countMatches(neiNormals, ownNormals)
1442 == neiNormals.
size();
1445 if (!ownIsSubset && !neiIsSubset)
1448 for (
label i = 0; !reachedLimit && i < ownNormals.
size(); i++)
1450 for (
label j = 0; !reachedLimit && j < neiNormals.
size(); j++)
1453 if ((ownNormals[i] & neiNormals[j]) < curvature)
1455 if (cellLevel[own] < ownLevels[i])
1470 Pout<<
"Stopped refining since reaching" 1471 <<
" my cell limit of " 1472 << mesh_.nCells()+7*nRefine
1475 reachedLimit =
true;
1492 Info<<
"Reached refinement limit." <<
endl;
1501 const scalar planarCos,
1511 vector d = point1-point0;
1512 scalar magD =
mag(d);
1514 if (magD > mergeDistance())
1516 scalar cosAngle = (normal0 & normal1);
1519 if (cosAngle < (-1+planarCos))
1522 avg = 0.5*(normal0-normal1);
1524 else if (cosAngle > (1-planarCos))
1526 avg = 0.5*(normal0+normal1);
1534 if (
mag(avg&d) > mergeDistance())
1558 const scalar planarCos,
1568 vector d = point1-point0;
1569 scalar magD =
mag(d);
1571 if (magD > mergeDistance())
1573 scalar cosAngle = (normal0 & normal1);
1576 if (cosAngle < (-1+planarCos))
1579 avg = 0.5*(normal0-normal1);
1581 else if (cosAngle > (1-planarCos))
1583 avg = 0.5*(normal0+normal1);
1613 bool Foam::meshRefinement::checkProximity
1615 const scalar planarCos,
1616 const label nAllowRefine,
1618 const label surfaceLevel,
1619 const vector& surfaceLocation,
1620 const vector& surfaceNormal,
1624 label& cellMaxLevel,
1632 const labelList& cellLevel = meshCutter_.cellLevel();
1635 if (surfaceLevel > cellLevel[celli])
1637 if (cellMaxLevel == -1)
1640 cellMaxLevel = surfaceLevel;
1641 cellMaxLocation = surfaceLocation;
1642 cellMaxNormal = surfaceNormal;
1651 bool closeSurfaces = isNormalGap
1662 if (surfaceLevel > cellMaxLevel)
1664 cellMaxLevel = surfaceLevel;
1665 cellMaxLocation = surfaceLocation;
1666 cellMaxNormal = surfaceNormal;
1680 return markForRefine
1696 Foam::label Foam::meshRefinement::markProximityRefinement
1698 const scalar planarCos,
1699 const label nAllowRefine,
1707 const labelList& cellLevel = meshCutter_.cellLevel();
1708 const pointField& cellCentres = mesh_.cellCentres();
1710 label oldNRefine = nRefine;
1721 labelList testFaces(getRefineCandidateFaces(refineCell));
1730 label facei = testFaces[i];
1732 label own = mesh_.faceOwner()[facei];
1734 if (mesh_.isInternalFace(facei))
1736 label nei = mesh_.faceNeighbour()[facei];
1738 start[i] = cellCentres[own];
1739 end[i] = cellCentres[nei];
1740 minLevel[i] =
min(cellLevel[own], cellLevel[nei]);
1744 label bFacei = facei - mesh_.nInternalFaces();
1746 start[i] = cellCentres[own];
1747 end[i] = neiCc[bFacei];
1748 minLevel[i] =
min(cellLevel[own], neiLevel[bFacei]);
1754 const vectorField smallVec(rootSmall*(end-start));
1763 labelList cellMaxLevel(mesh_.nCells(), -1);
1774 surfaces_.findAllHigherIntersections
1781 surfaces_.gapLevel(),
1811 label facei = testFaces[i];
1812 label own = mesh_.faceOwner()[facei];
1814 const labelList& fLevels = surfaceLevel[i];
1815 const vectorList& fPoints = surfaceLocation[i];
1816 const vectorList& fNormals = surfaceNormal[i];
1831 cellMaxLocation[own],
1839 if (mesh_.isInternalFace(facei))
1841 label nei = mesh_.faceNeighbour()[facei];
1856 cellMaxLocation[nei],
1870 labelList neiBndMaxLevel(mesh_.nFaces()-mesh_.nInternalFaces());
1871 pointField neiBndMaxLocation(mesh_.nFaces()-mesh_.nInternalFaces());
1872 vectorField neiBndMaxNormal(mesh_.nFaces()-mesh_.nInternalFaces());
1874 for (
label facei = mesh_.nInternalFaces(); facei < mesh_.nFaces(); facei++)
1876 label bFacei = facei-mesh_.nInternalFaces();
1877 label own = mesh_.faceOwner()[facei];
1879 neiBndMaxLevel[bFacei] = cellMaxLevel[own];
1880 neiBndMaxLocation[bFacei] = cellMaxLocation[own];
1881 neiBndMaxNormal[bFacei] = cellMaxNormal[own];
1890 for (
label facei = 0; facei < mesh_.nInternalFaces(); facei++)
1892 label own = mesh_.faceOwner()[facei];
1893 label nei = mesh_.faceNeighbour()[facei];
1895 if (cellMaxLevel[own] != -1 && cellMaxLevel[nei] != -1)
1903 cellMaxLocation[own],
1905 cellMaxLocation[nei],
1911 if (cellLevel[own] < cellMaxLevel[own])
1926 Pout<<
"Stopped refining since reaching my cell" 1927 <<
" limit of " << mesh_.nCells()+7*nRefine
1934 if (cellLevel[nei] < cellMaxLevel[nei])
1949 Pout<<
"Stopped refining since reaching my cell" 1950 <<
" limit of " << mesh_.nCells()+7*nRefine
1960 for (
label facei = mesh_.nInternalFaces(); facei < mesh_.nFaces(); facei++)
1962 label own = mesh_.faceOwner()[facei];
1963 label bFacei = facei - mesh_.nInternalFaces();
1965 if (cellLevel[own] < cellMaxLevel[own] && neiBndMaxLevel[bFacei] != -1)
1973 cellMaxLocation[own],
1975 neiBndMaxLocation[bFacei],
1976 neiBndMaxNormal[bFacei]
1993 Pout<<
"Stopped refining since reaching my cell" 1994 <<
" limit of " << mesh_.nCells()+7*nRefine
2009 Info<<
"Reached refinement limit." <<
endl;
2026 const scalar curvature,
2027 const scalar planarAngle,
2029 const bool featureRefinement,
2030 const bool featureDistanceRefinement,
2031 const bool internalRefinement,
2032 const bool surfaceRefinement,
2033 const bool curvatureRefinement,
2034 const bool gapRefinement,
2035 const label maxGlobalCells,
2036 const label maxLocalCells
2039 label totNCells = mesh_.globalData().nTotalCells();
2043 if (totNCells >= maxGlobalCells)
2045 Info<<
"No cells marked for refinement since reached limit " 2046 << maxGlobalCells <<
'.' <<
endl;
2075 labelList refineCell(mesh_.nCells(), -1);
2080 labelList neiLevel(mesh_.nFaces()-mesh_.nInternalFaces());
2081 pointField neiCc(mesh_.nFaces()-mesh_.nInternalFaces());
2082 calcNeighbourData(neiLevel, neiCc);
2089 if (featureRefinement)
2091 label nFeatures = markFeatureRefinement
2100 Info<<
"Marked for refinement due to explicit features " 2101 <<
": " << nFeatures <<
" cells." <<
endl;
2107 if (featureDistanceRefinement)
2109 label nShell = markInternalDistanceToFeatureRefinement
2116 Info<<
"Marked for refinement due to distance to explicit features " 2117 ": " << nShell <<
" cells." <<
endl;
2123 if (internalRefinement)
2125 label nShell = markInternalRefinement
2132 Info<<
"Marked for refinement due to refinement shells " 2133 <<
": " << nShell <<
" cells." <<
endl;
2139 if (surfaceRefinement)
2141 label nSurf = markSurfaceRefinement
2150 Info<<
"Marked for refinement due to surface intersection " 2151 <<
": " << nSurf <<
" cells." <<
endl;
2160 && (curvature >= -1 && curvature <= 1)
2161 && (surfaces_.minLevel() != surfaces_.maxLevel())
2164 label nCurv = markSurfaceCurvatureRefinement
2174 Info<<
"Marked for refinement due to curvature/regions " 2175 <<
": " << nCurv <<
" cells." <<
endl;
2184 && (planarCos >= -1 && planarCos <= 1)
2185 && (
max(surfaces_.gapLevel()) > -1)
2188 Info<<
"Specified gap level : " <<
max(surfaces_.gapLevel())
2189 <<
", planar angle " << planarAngle <<
endl;
2191 label nGap = markProximityRefinement
2201 Info<<
"Marked for refinement due to close opposite surfaces " 2202 <<
": " << nGap <<
" cells." <<
endl;
2210 cellsToRefine.
setSize(nRefine);
2213 forAll(refineCell, celli)
2215 if (refineCell[celli] != -1)
2217 cellsToRefine[nRefine++] = celli;
2222 return cellsToRefine;
2235 meshCutter_.setRefinement(cellsToRefine, meshMod);
2241 mesh_.updateMesh(map);
2244 if (map().hasMotionPoints())
2246 mesh_.movePoints(map().preMotionPoints());
2258 updateMesh(map, getChangedFaces(map, cellsToRefine));
2273 const scalar maxLoadUnbalance
2277 refine(cellsToRefine);
2281 Pout<<
"Writing refined but unbalanced " << msg
2289 Pout<<
"Dumped debug data in = " 2290 << mesh_.time().cpuTimeIncrement() <<
" s" <<
endl;
2296 Info<<
"Refined mesh in = " 2297 << mesh_.time().cpuTimeIncrement() <<
" s" <<
endl;
2298 printMeshInfo(debug,
"After refinement " + msg);
2308 scalar nIdealCells =
2309 mesh_.globalData().nTotalCells()
2314 mag(1.0-mesh_.nCells()/nIdealCells),
2318 if (unbalance <= maxLoadUnbalance)
2320 Info<<
"Skipping balancing since max unbalance " << unbalance
2321 <<
" is less than allowable " << maxLoadUnbalance
2337 Info<<
"Balanced mesh in = " 2338 << mesh_.time().cpuTimeIncrement() <<
" s" <<
endl;
2340 printMeshInfo(debug,
"After balancing " + msg);
2343 if (debug&meshRefinement::MESH)
2345 Pout<<
"Writing balanced " << msg
2353 Pout<<
"Dumped debug data in = " 2354 << mesh_.time().cpuTimeIncrement() <<
" s" <<
endl;
2374 const scalar maxLoadUnbalance
2377 labelList cellsToRefine(initCellsToRefine);
2412 scalar nNewCells = scalar(mesh_.nCells() + 7*cellsToRefine.
size());
2413 scalar nIdealNewCells =
2418 mag(1.0-nNewCells/nIdealNewCells),
2422 if (unbalance <= maxLoadUnbalance)
2424 Info<<
"Skipping balancing since max unbalance " << unbalance
2425 <<
" is less than allowable " << maxLoadUnbalance
2433 cellWeights[cellsToRefine[i]] += 7;
2446 distMap().distributeCellIndices(cellsToRefine);
2448 Info<<
"Balanced mesh in = " 2449 << mesh_.time().cpuTimeIncrement() <<
" s" <<
endl;
2464 printMeshInfo(debug,
"After balancing " + msg);
2468 Pout<<
"Writing balanced " << msg
2476 Pout<<
"Dumped debug data in = " 2477 << mesh_.time().cpuTimeIncrement() <<
" s" <<
endl;
2488 refine(cellsToRefine);
2492 Pout<<
"Writing refined " << msg
2500 Pout<<
"Dumped debug data in = " 2501 << mesh_.time().cpuTimeIncrement() <<
" s" <<
endl;
2507 Info<<
"Refined mesh in = " 2508 << mesh_.time().cpuTimeIncrement() <<
" s" <<
endl;
2522 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.
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.
const dimensionedScalar b
Wien displacement law constant: default SI units: [m K].
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.
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