67 x = (
x ==
y) ?
x : value;
75void Foam::hexRef8::reorder
96 newElems[newI] = elems[i];
100 elems.transfer(newElems);
104void Foam::hexRef8::getFaceInfo
114 if (!mesh_.isInternalFace(facei))
116 patchID = mesh_.boundaryMesh().whichPatch(facei);
119 zoneID = mesh_.faceZones().whichZone(facei);
125 const faceZone& fZone = mesh_.faceZones()[zoneID];
127 zoneFlip = fZone.
flipMap()[fZone.whichFace(facei)];
133Foam::label Foam::hexRef8::addFace
142 label
patchID, zoneID, zoneFlip;
144 getFaceInfo(facei,
patchID, zoneID, zoneFlip);
148 if ((nei == -1) || (own < nei))
151 newFacei = meshMod.setAction
171 newFacei = meshMod.setAction
175 newFace.reverseFace(),
198Foam::label Foam::hexRef8::addInternalFace
201 const label meshFacei,
202 const label meshPointi,
208 if (mesh_.isInternalFace(meshFacei))
210 return meshMod.setAction
238 return meshMod.setAction
294void Foam::hexRef8::modFace
303 label
patchID, zoneID, zoneFlip;
305 getFaceInfo(facei,
patchID, zoneID, zoneFlip);
309 (own != mesh_.faceOwner()[facei])
311 mesh_.isInternalFace(facei)
312 && (nei != mesh_.faceNeighbour()[facei])
314 || (newFace != mesh_.faces()[facei])
317 if ((nei == -1) || (own < nei))
341 newFace.reverseFace(),
358Foam::scalar Foam::hexRef8::getLevel0EdgeLength()
const
360 if (cellLevel_.size() != mesh_.nCells())
363 <<
"Number of cells in mesh:" << mesh_.nCells()
364 <<
" does not equal size of cellLevel:" << cellLevel_.size()
366 <<
"This might be because of a restart with inconsistent cellLevel."
373 const scalar GREAT2 =
sqr(GREAT);
375 label nLevels =
gMax(cellLevel_)+1;
390 const label cLevel = cellLevel_[celli];
392 const labelList& cEdges = mesh_.cellEdges(celli);
396 label edgeI = cEdges[i];
398 if (edgeLevel[edgeI] == -1)
400 edgeLevel[edgeI] = cLevel;
402 else if (edgeLevel[edgeI] ==
labelMax)
406 else if (edgeLevel[edgeI] != cLevel)
428 const label eLevel = edgeLevel[edgeI];
430 if (eLevel >= 0 && eLevel <
labelMax)
432 const edge&
e = mesh_.edges()[edgeI];
434 scalar edgeLenSqr =
e.magSqr(mesh_.points());
436 typEdgeLenSqr[eLevel] =
min(typEdgeLenSqr[eLevel], edgeLenSqr);
447 Pout<<
"hexRef8::getLevel0EdgeLength() :"
448 <<
" After phase1: Edgelengths (squared) per refinementlevel:"
449 << typEdgeLenSqr <<
endl;
463 const label cLevel = cellLevel_[celli];
465 const labelList& cEdges = mesh_.cellEdges(celli);
469 const edge&
e = mesh_.edges()[cEdges[i]];
471 scalar edgeLenSqr =
e.magSqr(mesh_.points());
473 maxEdgeLenSqr[cLevel] =
max(maxEdgeLenSqr[cLevel], edgeLenSqr);
481 Pout<<
"hexRef8::getLevel0EdgeLength() :"
482 <<
" Poor Edgelengths (squared) per refinementlevel:"
483 << maxEdgeLenSqr <<
endl;
490 forAll(typEdgeLenSqr, levelI)
492 if (typEdgeLenSqr[levelI] == GREAT2 && maxEdgeLenSqr[levelI] >= 0)
494 typEdgeLenSqr[levelI] = maxEdgeLenSqr[levelI];
500 Pout<<
"hexRef8::getLevel0EdgeLength() :"
501 <<
" Final Edgelengths (squared) per refinementlevel:"
502 << typEdgeLenSqr <<
endl;
506 scalar level0Size = -1;
508 forAll(typEdgeLenSqr, levelI)
510 scalar lenSqr = typEdgeLenSqr[levelI];
518 Pout<<
"hexRef8::getLevel0EdgeLength() :"
519 <<
" For level:" << levelI
521 <<
" with equivalent level0 len:" << level0Size
528 if (level0Size == -1)
540Foam::label Foam::hexRef8::getAnchorCell
549 if (cellAnchorPoints[celli].size())
551 label index = cellAnchorPoints[celli].find(pointi);
555 return cellAddedCells[celli][index];
562 const face&
f = mesh_.faces()[facei];
566 label index = cellAnchorPoints[celli].
find(
f[fp]);
570 return cellAddedCells[celli][index];
576 Perr<<
"cell:" << celli <<
" anchorPoints:" << cellAnchorPoints[celli]
580 <<
"Could not find point " << pointi
581 <<
" in the anchorPoints for cell " << celli <<
endl
582 <<
"Does your original mesh obey the 2:1 constraint and"
583 <<
" did you use consistentRefinement to make your cells to refine"
584 <<
" obey this constraint as well?"
597void Foam::hexRef8::getFaceNeighbours
613 mesh_.faceOwner()[facei],
618 if (mesh_.isInternalFace(facei))
624 mesh_.faceNeighbour()[facei],
637Foam::label Foam::hexRef8::findMinLevel(
const labelList&
f)
const
644 label level = pointLevel_[
f[fp]];
646 if (level < minLevel)
658Foam::label Foam::hexRef8::findMaxLevel(
const labelList&
f)
const
665 label level = pointLevel_[
f[fp]];
667 if (level > maxLevel)
678Foam::label Foam::hexRef8::countAnchors
681 const label anchorLevel
688 if (pointLevel_[
f[fp]] <= anchorLevel)
697void Foam::hexRef8::dumpCell(
const label celli)
const
700 Pout<<
"hexRef8 : Dumping cell as obj to " << str.name() <<
endl;
702 const cell& cFaces = mesh_.cells()[celli];
709 const face&
f = mesh_.faces()[cFaces[i]];
713 if (pointToObjVert.insert(
f[fp], objVertI))
723 const face&
f = mesh_.faces()[cFaces[i]];
727 label pointi =
f[fp];
730 str <<
"l " << pointToObjVert[pointi]+1
731 <<
' ' << pointToObjVert[nexPointi]+1 <<
nl;
738Foam::label Foam::hexRef8::findLevel
743 const bool searchForward,
744 const label wantedLevel
751 label pointi =
f[fp];
753 if (pointLevel_[pointi] < wantedLevel)
755 dumpCell(mesh_.faceOwner()[facei]);
756 if (mesh_.isInternalFace(facei))
758 dumpCell(mesh_.faceNeighbour()[facei]);
764 <<
" startFp:" << startFp
765 <<
" wantedLevel:" << wantedLevel
768 else if (pointLevel_[pointi] == wantedLevel)
783 dumpCell(mesh_.faceOwner()[facei]);
784 if (mesh_.isInternalFace(facei))
786 dumpCell(mesh_.faceNeighbour()[facei]);
792 <<
" startFp:" << startFp
793 <<
" wantedLevel:" << wantedLevel
803 const face&
f = mesh_.faces()[facei];
807 return pointLevel_[
f[findMaxLevel(
f)]];
811 label ownLevel = cellLevel_[mesh_.faceOwner()[facei]];
813 if (countAnchors(
f, ownLevel) == 4)
817 else if (countAnchors(
f, ownLevel+1) == 4)
829void Foam::hexRef8::checkInternalOrientation
840 pointField compactPoints(meshMod.points(), newFace);
842 const vector areaNorm(compactFace.areaNormal(compactPoints));
844 const vector dir(neiPt - ownPt);
846 if ((dir & areaNorm) < 0)
849 <<
"cell:" << celli <<
" old face:" << facei
850 <<
" newFace:" << newFace <<
endl
851 <<
" coords:" << compactPoints
852 <<
" ownPt:" << ownPt
853 <<
" neiPt:" << neiPt
857 const vector fcToOwn(compactFace.centre(compactPoints) - ownPt);
859 const scalar
s = (fcToOwn & areaNorm) / (dir & areaNorm);
864 <<
"cell:" << celli <<
" old face:" << facei
865 <<
" newFace:" << newFace <<
endl
866 <<
" coords:" << compactPoints
867 <<
" ownPt:" << ownPt
868 <<
" neiPt:" << neiPt
875void Foam::hexRef8::checkBoundaryOrientation
881 const point& boundaryPt,
886 pointField compactPoints(meshMod.points(), newFace);
888 const vector areaNorm(compactFace.areaNormal(compactPoints));
890 const vector dir(boundaryPt - ownPt);
892 if ((dir & areaNorm) < 0)
895 <<
"cell:" << celli <<
" old face:" << facei
896 <<
" newFace:" << newFace
897 <<
" coords:" << compactPoints
898 <<
" ownPt:" << ownPt
899 <<
" boundaryPt:" << boundaryPt
903 const vector fcToOwn(compactFace.centre(compactPoints) - ownPt);
905 const scalar
s = (fcToOwn & dir) /
magSqr(dir);
910 <<
"cell:" << celli <<
" old face:" << facei
911 <<
" newFace:" << newFace
912 <<
" coords:" << compactPoints
913 <<
" ownPt:" << ownPt
914 <<
" boundaryPt:" << boundaryPt
924void Foam::hexRef8::insertEdgeSplit
932 if (
p0 < mesh_.nPoints() && p1 < mesh_.nPoints())
936 if (edgeI != -1 && edgeMidPoint[edgeI] != -1)
938 verts.append(edgeMidPoint[edgeI]);
952Foam::label Foam::hexRef8::storeMidPointInfo
960 const bool faceOrder,
961 const label edgeMidPointi,
962 const label anchorPointi,
963 const label faceMidPointi,
972 bool changed =
false;
973 bool haveTwoAnchors =
false;
975 auto edgeMidFnd = midPointToAnchors.find(edgeMidPointi);
977 if (!edgeMidFnd.good())
979 midPointToAnchors.insert(edgeMidPointi,
edge(anchorPointi, -1));
983 edge&
e = edgeMidFnd.val();
985 if (anchorPointi !=
e[0])
994 if (
e[0] != -1 &&
e[1] != -1)
996 haveTwoAnchors =
true;
1000 bool haveTwoFaceMids =
false;
1002 auto faceMidFnd = midPointToFaceMids.find(edgeMidPointi);
1004 if (!faceMidFnd.good())
1006 midPointToFaceMids.insert(edgeMidPointi,
edge(faceMidPointi, -1));
1010 edge&
e = faceMidFnd.val();
1012 if (faceMidPointi !=
e[0])
1016 e[1] = faceMidPointi;
1021 if (
e[0] != -1 &&
e[1] != -1)
1023 haveTwoFaceMids =
true;
1030 if (changed && haveTwoAnchors && haveTwoFaceMids)
1032 const edge& anchors = midPointToAnchors[edgeMidPointi];
1033 const edge& faceMids = midPointToFaceMids[edgeMidPointi];
1035 label otherFaceMidPointi = faceMids.
otherVertex(faceMidPointi);
1043 if (faceOrder == (mesh_.faceOwner()[facei] == celli))
1045 newFaceVerts.append(faceMidPointi);
1056 newFaceVerts.append(edgeMidPointi);
1066 newFaceVerts.append(otherFaceMidPointi);
1067 newFaceVerts.append(cellMidPoint[celli]);
1071 newFaceVerts.append(otherFaceMidPointi);
1081 newFaceVerts.append(edgeMidPointi);
1091 newFaceVerts.append(faceMidPointi);
1092 newFaceVerts.append(cellMidPoint[celli]);
1098 label anchorCell0 = getAnchorCell
1106 label anchorCell1 = getAnchorCell
1112 anchors.otherVertex(anchorPointi)
1119 if (anchorCell0 < anchorCell1)
1124 ownPt = mesh_.points()[anchorPointi];
1125 neiPt = mesh_.points()[anchors.otherVertex(anchorPointi)];
1134 ownPt = mesh_.points()[anchors.otherVertex(anchorPointi)];
1135 neiPt = mesh_.points()[anchorPointi];
1142 if (anchorCell0 < anchorCell1)
1144 ownPt = mesh_.points()[anchorPointi];
1145 neiPt = mesh_.points()[anchors.otherVertex(anchorPointi)];
1149 ownPt = mesh_.points()[anchors.otherVertex(anchorPointi)];
1150 neiPt = mesh_.points()[anchorPointi];
1153 checkInternalOrientation
1164 return addInternalFace
1182void Foam::hexRef8::createInternalFaces
1198 const cell& cFaces = mesh_.cells()[celli];
1199 const label cLevel = cellLevel_[celli];
1204 midPointToAnchors.
reserve(12);
1205 midPointToFaceMids.reserve(12);
1212 label nFacesAdded = 0;
1214 for (
const label facei : cFaces)
1216 const face&
f = mesh_.faces()[facei];
1217 const labelList& fEdges = mesh_.faceEdges(facei, storage);
1222 label faceMidPointi = -1;
1224 label nAnchors = countAnchors(
f, cLevel);
1232 label anchorFp = -1;
1236 if (pointLevel_[
f[fp]] <= cLevel)
1244 label edgeMid = findLevel
1252 label faceMid = findLevel
1261 faceMidPointi =
f[faceMid];
1263 else if (nAnchors == 4)
1268 faceMidPointi = faceMidPoint[facei];
1272 dumpCell(mesh_.faceOwner()[facei]);
1273 if (mesh_.isInternalFace(facei))
1275 dumpCell(mesh_.faceNeighbour()[facei]);
1279 <<
"nAnchors:" << nAnchors
1280 <<
" facei:" << facei
1292 label point0 =
f[fp0];
1294 if (pointLevel_[point0] <= cLevel)
1303 label edgeMidPointi = -1;
1307 if (pointLevel_[
f[fp1]] <= cLevel)
1310 label edgeI = fEdges[fp0];
1312 edgeMidPointi = edgeMidPoint[edgeI];
1314 if (edgeMidPointi == -1)
1318 const labelList& cPoints = mesh_.cellPoints(celli);
1321 <<
"cell:" << celli <<
" cLevel:" << cLevel
1322 <<
" cell points:" << cPoints
1325 <<
" face:" << facei
1329 <<
" faceAnchorLevel:" << faceAnchorLevel[facei]
1330 <<
" faceMidPoint:" << faceMidPoint[facei]
1331 <<
" faceMidPointi:" << faceMidPointi
1339 label edgeMid = findLevel(facei,
f, fp1,
true, cLevel+1);
1341 edgeMidPointi =
f[edgeMid];
1344 label newFacei = storeMidPointInfo
1367 if (nFacesAdded == 12)
1380 if (pointLevel_[
f[fpMin1]] <= cLevel)
1383 label edgeI = fEdges[fpMin1];
1385 edgeMidPointi = edgeMidPoint[edgeI];
1387 if (edgeMidPointi == -1)
1391 const labelList& cPoints = mesh_.cellPoints(celli);
1394 <<
"cell:" << celli <<
" cLevel:" << cLevel
1395 <<
" cell points:" << cPoints
1398 <<
" face:" << facei
1402 <<
" faceAnchorLevel:" << faceAnchorLevel[facei]
1403 <<
" faceMidPoint:" << faceMidPoint[facei]
1404 <<
" faceMidPointi:" << faceMidPointi
1412 label edgeMid = findLevel
1421 edgeMidPointi =
f[edgeMid];
1424 newFacei = storeMidPointInfo
1447 if (nFacesAdded == 12)
1455 if (nFacesAdded == 12)
1463void Foam::hexRef8::walkFaceToMid
1468 const label startFp,
1472 const face&
f = mesh_.faces()[facei];
1473 const labelList& fEdges = mesh_.faceEdges(facei);
1482 if (edgeMidPoint[fEdges[fp]] >= 0)
1484 faceVerts.append(edgeMidPoint[fEdges[fp]]);
1489 if (pointLevel_[
f[fp]] <= cLevel)
1495 else if (pointLevel_[
f[fp]] == cLevel+1)
1498 faceVerts.append(
f[fp]);
1502 else if (pointLevel_[
f[fp]] == cLevel+2)
1505 faceVerts.append(
f[fp]);
1512void Foam::hexRef8::walkFaceFromMid
1517 const label startFp,
1521 const face&
f = mesh_.faces()[facei];
1522 const labelList& fEdges = mesh_.faceEdges(facei);
1528 if (pointLevel_[
f[fp]] <= cLevel)
1533 else if (pointLevel_[
f[fp]] == cLevel+1)
1536 faceVerts.append(
f[fp]);
1539 else if (pointLevel_[
f[fp]] == cLevel+2)
1549 if (edgeMidPoint[fEdges[fp]] >= 0)
1551 faceVerts.append(edgeMidPoint[fEdges[fp]]);
1560 faceVerts.append(
f[fp]);
1567Foam::label Foam::hexRef8::faceConsistentRefinement
1577 for (label facei = 0; facei < mesh_.nInternalFaces(); facei++)
1579 label own = mesh_.faceOwner()[facei];
1580 label ownLevel = cellLevel[own] +
refineCell.get(own);
1582 label nei = mesh_.faceNeighbour()[facei];
1583 label neiLevel = cellLevel[nei] +
refineCell.get(nei);
1585 if (ownLevel > (neiLevel+1))
1597 else if (neiLevel > (ownLevel+1))
1614 labelList neiLevel(mesh_.nBoundaryFaces());
1618 label own = mesh_.faceOwner()[i+mesh_.nInternalFaces()];
1620 neiLevel[i] = cellLevel[own] +
refineCell.get(own);
1629 label own = mesh_.faceOwner()[i+mesh_.nInternalFaces()];
1630 label ownLevel = cellLevel[own] +
refineCell.get(own);
1632 if (ownLevel > (neiLevel[i]+1))
1640 else if (neiLevel[i] > (ownLevel+1))
1655void Foam::hexRef8::checkWantedRefinementLevels
1663 for (label facei = 0; facei < mesh_.nInternalFaces(); facei++)
1665 label own = mesh_.faceOwner()[facei];
1666 label ownLevel = cellLevel[own] +
refineCell.get(own);
1668 label nei = mesh_.faceNeighbour()[facei];
1669 label neiLevel = cellLevel[nei] +
refineCell.get(nei);
1671 if (
mag(ownLevel-neiLevel) > 1)
1677 <<
" current level:" << cellLevel[own]
1678 <<
" level after refinement:" << ownLevel
1680 <<
"neighbour cell:" << nei
1681 <<
" current level:" << cellLevel[nei]
1682 <<
" level after refinement:" << neiLevel
1684 <<
"which does not satisfy 2:1 constraints anymore."
1691 labelList neiLevel(mesh_.nBoundaryFaces());
1695 label own = mesh_.faceOwner()[i+mesh_.nInternalFaces()];
1697 neiLevel[i] = cellLevel[own] +
refineCell.get(own);
1706 label facei = i + mesh_.nInternalFaces();
1708 label own = mesh_.faceOwner()[facei];
1709 label ownLevel = cellLevel[own] +
refineCell.get(own);
1711 if (
mag(ownLevel - neiLevel[i]) > 1)
1713 label patchi = mesh_.boundaryMesh().whichPatch(facei);
1717 <<
"Celllevel does not satisfy 2:1 constraint."
1718 <<
" On coupled face "
1720 <<
" on patch " << patchi <<
" "
1721 << mesh_.boundaryMesh()[patchi].name()
1722 <<
" owner cell " << own
1723 <<
" current level:" << cellLevel[own]
1724 <<
" level after refinement:" << ownLevel
1726 <<
" (coupled) neighbour cell will get refinement "
1739 Pout<<
"hexRef8::setInstance(const fileName& inst) : "
1740 <<
"Resetting file instance to " << inst <<
endl;
1743 cellLevel_.instance() = inst;
1744 pointLevel_.instance() = inst;
1745 level0Edge_.instance() = inst;
1746 history_.instance() = inst;
1750void Foam::hexRef8::collectLevelPoints
1759 if (pointLevel_[
f[fp]] <= level)
1767void Foam::hexRef8::collectLevelPoints
1777 label pointi = meshPoints[
f[fp]];
1778 if (pointLevel_[pointi] <= level)
1787bool Foam::hexRef8::matchHexShape
1790 const label cellLevel,
1794 const cell& cFaces = mesh_.cells()[celli];
1805 label facei = cFaces[i];
1806 const face&
f = mesh_.faces()[facei];
1809 collectLevelPoints(
f, cellLevel, verts);
1810 if (verts.size() == 4)
1812 if (mesh_.faceOwner()[facei] != celli)
1816 quads.emplace_back(verts);
1821 if (quads.size() < 6)
1827 label facei = cFaces[i];
1828 const face&
f = mesh_.faces()[facei];
1836 collectLevelPoints(
f, cellLevel, verts);
1837 if (verts.size() == 1)
1841 for (
const label pointi :
f)
1843 if (pointLevel_[pointi] == cellLevel+1)
1845 pointFaces(pointi).push_uniq(facei);
1862 label facei =
pFaces[pFacei];
1863 const face&
f = mesh_.faces()[facei];
1864 if (mesh_.faceOwner()[facei] == celli)
1866 fourFaces[pFacei] =
f;
1870 fourFaces[pFacei] =
f.reverseFace();
1881 if (edgeLoops.size() == 1)
1887 bigFace.meshPoints(),
1888 bigFace.edgeLoops()[0],
1893 if (verts.size() == 4)
1895 quads.emplace_back(verts);
1902 return (quads.size() == 6);
1909Foam::hexRef8::hexRef8(
const polyMesh&
mesh,
const bool readHistory)
1917 mesh_.facesInstance(),
1930 mesh_.facesInstance(),
1943 mesh_.facesInstance(),
1956 "refinementHistory",
1957 mesh_.facesInstance(),
1964 (readHistory ? mesh_.nCells() : 0)
1966 faceRemover_(mesh_, GREAT),
1967 savedPointLevel_(0),
1979 if (history_.active() && history_.visibleCells().size() != mesh_.nCells())
1981 FatalErrorInFunction
1982 <<
"History enabled but number of visible cells "
1983 << history_.visibleCells().size() <<
" in "
1984 << history_.objectPath()
1985 <<
" is not equal to the number of cells in the mesh "
1987 << abort(FatalError);
1992 cellLevel_.size() != mesh_.nCells()
1993 || pointLevel_.size() != mesh_.nPoints()
1996 FatalErrorInFunction
1997 <<
"Restarted from inconsistent cellLevel or pointLevel files."
1999 <<
"cellLevel file " << cellLevel_.objectPath() << endl
2000 <<
"pointLevel file " << pointLevel_.objectPath() << endl
2001 <<
"Number of cells in mesh:" << mesh_.nCells()
2002 <<
" does not equal size of cellLevel:" << cellLevel_.size() << endl
2003 <<
"Number of points in mesh:" << mesh_.nPoints()
2004 <<
" does not equal size of pointLevel:" << pointLevel_.size()
2005 << abort(FatalError);
2022Foam::hexRef8::hexRef8
2024 const polyMesh&
mesh,
2027 const refinementHistory& history,
2028 const scalar level0Edge
2037 mesh_.facesInstance(),
2038 polyMesh::meshSubDir,
2050 mesh_.facesInstance(),
2051 polyMesh::meshSubDir,
2063 mesh_.facesInstance(),
2064 polyMesh::meshSubDir,
2074 (level0Edge >= 0 ? level0Edge : getLevel0EdgeLength())
2081 "refinementHistory",
2082 mesh_.facesInstance(),
2083 polyMesh::meshSubDir,
2090 faceRemover_(mesh_, GREAT),
2091 savedPointLevel_(0),
2096 FatalErrorInFunction
2097 <<
"History enabled but number of visible cells in it "
2098 << history_.visibleCells().size()
2099 <<
" is not equal to the number of cells in the mesh "
2100 << mesh_.nCells() << abort(FatalError);
2109 FatalErrorInFunction
2110 <<
"Incorrect cellLevel or pointLevel size." << endl
2111 <<
"Number of cells in mesh:" << mesh_.nCells()
2112 <<
" does not equal size of cellLevel:" << cellLevel_.size() << endl
2113 <<
"Number of points in mesh:" << mesh_.nPoints()
2114 <<
" does not equal size of pointLevel:" << pointLevel_.size()
2115 << abort(FatalError);
2131Foam::hexRef8::hexRef8
2133 const polyMesh&
mesh,
2136 const scalar level0Edge
2145 mesh_.facesInstance(),
2146 polyMesh::meshSubDir,
2158 mesh_.facesInstance(),
2159 polyMesh::meshSubDir,
2171 mesh_.facesInstance(),
2172 polyMesh::meshSubDir,
2182 (level0Edge >= 0 ? level0Edge : getLevel0EdgeLength())
2189 "refinementHistory",
2190 mesh_.facesInstance(),
2191 polyMesh::meshSubDir,
2196 List<refinementHistory::splitCell8>(0),
2200 faceRemover_(mesh_, GREAT),
2201 savedPointLevel_(0),
2210 FatalErrorInFunction
2211 <<
"Incorrect cellLevel or pointLevel size." << endl
2212 <<
"Number of cells in mesh:" << mesh_.nCells()
2213 <<
" does not equal size of cellLevel:" << cellLevel_.size() << endl
2214 <<
"Number of points in mesh:" << mesh_.nPoints()
2215 <<
" does not equal size of pointLevel:" << pointLevel_.size()
2216 << abort(FatalError);
2249 label nChanged = faceConsistentRefinement
2260 Pout<<
"hexRef8::consistentRefinement : Changed " << nChanged
2261 <<
" refinement levels due to 2:1 conflicts."
2276 checkWantedRefinementLevels(cellLevel, newCellsToRefine);
2279 return newCellsToRefine;
2291 const label maxFaceDiff,
2294 const label maxPointDiff,
2298 const labelList& faceOwner = mesh_.faceOwner();
2299 const labelList& faceNeighbour = mesh_.faceNeighbour();
2302 if (maxFaceDiff <= 0)
2305 <<
"Illegal maxFaceDiff " << maxFaceDiff <<
nl
2330 maxFaceDiff*(cellLevel_[celli]+1),
2331 maxFaceDiff*cellLevel_[celli]
2338 label celli = cellsToRefine[i];
2350 int dummyTrackData = 0;
2358 label facei = facesToCheck[i];
2364 <<
"Argument facesToCheck seems to have duplicate entries!"
2366 <<
"face:" << facei <<
" occurs at positions "
2374 label maxDataCount = ownData.
count();
2376 if (mesh_.isInternalFace(facei))
2383 if (maxDataCount < neiData.
count())
2385 maxDataCount = neiData.
count();
2389 label faceCount = maxDataCount + maxFaceDiff;
2390 label faceRefineCount = faceCount + maxFaceDiff;
2394 seedFacesInfo.
emplace_back(faceRefineCount, faceCount);
2401 forAll(faceNeighbour, facei)
2406 label own = faceOwner[facei];
2407 label nei = faceNeighbour[facei];
2448 for (label facei = mesh_.nInternalFaces(); facei < mesh_.nFaces(); facei++)
2453 const label own = faceOwner[facei];
2454 const auto& nbrInfo = nbrCellInfo[facei-mesh_.nInternalFaces()];
2470 else if (
allCellInfo[own].count() < nbrInfo.count())
2501 Pout<<
"hexRef8::consistentSlowRefinement : Seeded "
2502 << seedFaces.
size() <<
" faces between cells with different"
2503 <<
" refinement level." <<
endl;
2509 seedFacesInfo.
clear();
2512 levelCalc.
iterate(mesh_.globalData().nTotalFaces()+1);
2520 if (maxPointDiff == -1)
2530 forAll(maxPointCount, pointi)
2532 label& pLevel = maxPointCount[pointi];
2534 const labelList& pCells = mesh_.pointCells(pointi);
2559 label pointi = pointsToCheck[i];
2564 const labelList& pCells = mesh_.pointCells(pointi);
2568 label celli = pCells[pCelli];
2576 maxPointCount[pointi]
2577 >
cellInfo.count() + maxFaceDiff*maxPointDiff
2585 const cell& cFaces = mesh_.cells()[celli];
2589 label facei = cFaces[cFacei];
2604 changedFacesInfo.
insert(facei, faceData);
2611 label nChanged = changedFacesInfo.
size();
2626 seedFaces.
append(iter.key());
2627 seedFacesInfo.
append(iter.val());
2634 for (label facei = 0; facei < mesh_.nInternalFaces(); facei++)
2636 label own = mesh_.faceOwner()[facei];
2641 label nei = mesh_.faceNeighbour()[facei];
2646 if (
mag(ownLevel-neiLevel) > 1)
2652 <<
" current level:" << cellLevel_[own]
2654 <<
" level after refinement:" << ownLevel
2656 <<
"neighbour cell:" << nei
2657 <<
" current level:" << cellLevel_[nei]
2659 <<
" level after refinement:" << neiLevel
2661 <<
"which does not satisfy 2:1 constraints anymore." <<
nl
2662 <<
"face:" << facei <<
" faceRefData:" <<
allFaceInfo[facei]
2671 labelList neiLevel(mesh_.nBoundaryFaces());
2672 labelList neiCount(mesh_.nBoundaryFaces());
2673 labelList neiRefCount(mesh_.nBoundaryFaces());
2677 label own = mesh_.faceOwner()[i+mesh_.nInternalFaces()];
2678 neiLevel[i] = cellLevel_[own];
2680 neiRefCount[i] =
allCellInfo[own].refinementCount();
2691 label facei = i+mesh_.nInternalFaces();
2693 label own = mesh_.faceOwner()[facei];
2700 + ((neiCount[i] >= neiRefCount[i]) ? 1 : 0);
2702 if (
mag(ownLevel - nbrLevel) > 1)
2705 label patchi = mesh_.boundaryMesh().whichPatch(facei);
2708 <<
"Celllevel does not satisfy 2:1 constraint."
2709 <<
" On coupled face "
2712 <<
" on patch " << patchi <<
" "
2713 << mesh_.boundaryMesh()[patchi].name() <<
nl
2714 <<
"owner cell " << own
2715 <<
" current level:" << cellLevel_[own]
2717 <<
" current refCount:"
2719 <<
" level after refinement:" << ownLevel
2721 <<
"(coupled) neighbour cell"
2722 <<
" has current level:" << neiLevel[i]
2723 <<
" current count:" << neiCount[i]
2724 <<
" current refCount:" << neiRefCount[i]
2725 <<
" level after refinement:" << nbrLevel
2751 newCellsToRefine[nRefined++] = celli;
2757 Pout<<
"hexRef8::consistentSlowRefinement : From "
2758 << cellsToRefine.
size() <<
" to " << newCellsToRefine.
size()
2759 <<
" cells to refine." <<
endl;
2762 return newCellsToRefine;
2768 const label maxFaceDiff,
2773 const labelList& faceOwner = mesh_.faceOwner();
2774 const labelList& faceNeighbour = mesh_.faceNeighbour();
2776 if (maxFaceDiff <= 0)
2779 <<
"Illegal maxFaceDiff " << maxFaceDiff <<
nl
2783 const scalar level0Size = 2*maxFaceDiff*level0EdgeLength();
2792 List<refinementDistanceData>
allCellInfo(mesh_.nCells());
2795 List<refinementDistanceData>
allFaceInfo(mesh_.nFaces());
2798 int dummyTrackData = 0;
2804 label celli = cellsToRefine[i];
2809 mesh_.cellCentres()[celli],
2821 mesh_.cellCentres()[celli],
2879 bitSet isBoundary(mesh_.nFaces());
2889 nbrCc[
pp.offset()+i] = cc[own];
2891 const label ownLevel =
2897 nbrLevel[
pp.offset()+i] = ownLevel;
2902 isBoundary.set(
pp.range());
2910 for (
const label facei : facesToCheck)
2916 <<
"Argument facesToCheck seems to have duplicate entries!"
2918 <<
"face:" << facei <<
" occurs at positions "
2923 const label own = faceOwner[facei];
2924 const label ownLevel =
2930 const point& ownCc = cc[own];
2932 if (isBoundary(facei))
2936 const point& fc = mesh_.faceCentres()[facei];
2959 if (mesh_.isInternalFace(facei))
2961 const label nei = faceNeighbour[facei];
2972 neiLevel = nbrLevel[facei-mesh_.nInternalFaces()];
2973 neiCc = nbrCc[facei-mesh_.nInternalFaces()];
2976 if (ownLevel == neiLevel)
3021 seedFaces.append(facei);
3036 if (!
allFaceInfo[facei].valid(dummyTrackData) && !isBoundary(facei))
3038 const label own = faceOwner[facei];
3039 const label ownLevel =
3045 const point& ownCc = cc[own];
3049 if (mesh_.isInternalFace(facei))
3051 const label nei = faceNeighbour[facei];
3062 neiLevel = nbrLevel[facei-mesh_.nInternalFaces()];
3063 neiCc = nbrCc[facei-mesh_.nInternalFaces()];
3066 if (ownLevel > neiLevel)
3069 seedFaces.append(facei);
3081 else if (neiLevel > ownLevel)
3083 seedFaces.append(facei);
3099 seedFacesInfo.shrink();
3109 mesh_.globalData().nTotalCells()+1,
3190 label celli = cellsToRefine[i];
3192 allCellInfo[celli].originLevel() =
sizeof(label)*8-2;
3202 label wanted =
allCellInfo[celli].wantedLevel(cc[celli]);
3204 if (wanted > cellLevel_[celli]+1)
3209 faceConsistentRefinement(
true, cellLevel_,
refineCell);
3213 label nChanged = faceConsistentRefinement(
true, cellLevel_,
refineCell);
3219 Pout<<
"hexRef8::consistentSlowRefinement2 : Changed " << nChanged
3220 <<
" refinement levels due to 2:1 conflicts."
3235 Pout<<
"hexRef8::consistentSlowRefinement2 : From "
3236 << cellsToRefine.
size() <<
" to " << newCellsToRefine.size()
3237 <<
" cells to refine." <<
endl;
3242 cellSet cellsIn(mesh_,
"cellsToRefineIn", cellsToRefine);
3243 Pout<<
"hexRef8::consistentSlowRefinement2 : writing "
3244 << cellsIn.size() <<
" to cellSet "
3245 << cellsIn.objectPath() <<
endl;
3249 cellSet cellsOut(mesh_,
"cellsToRefineOut", newCellsToRefine);
3250 Pout<<
"hexRef8::consistentSlowRefinement2 : writing "
3251 << cellsOut.size() <<
" to cellSet "
3252 << cellsOut.objectPath() <<
endl;
3260 label nChanged = faceConsistentRefinement(
true, cellLevel_,
refineCell);
3265 mesh_,
"cellsToRefineOut2", newCellsToRefine.size()
3271 cellsOut2.insert(celli);
3274 Pout<<
"hexRef8::consistentSlowRefinement2 : writing "
3275 << cellsOut2.size() <<
" to cellSet "
3276 << cellsOut2.objectPath() <<
endl;
3284 if (
refineCell.test(celli) && !savedRefineCell.test(celli))
3288 <<
"Cell:" << celli <<
" cc:"
3289 << mesh_.cellCentres()[celli]
3290 <<
" was not marked for refinement but does not obey"
3291 <<
" 2:1 constraints."
3298 return newCellsToRefine;
3311 Pout<<
"hexRef8::setRefinement :"
3312 <<
" Checking initial mesh just to make sure" <<
endl;
3321 savedPointLevel_.
clear();
3322 savedCellLevel_.clear();
3327 forAll(cellLevel_, celli)
3329 newCellLevel.
append(cellLevel_[celli]);
3332 forAll(pointLevel_, pointi)
3334 newPointLevel.
append(pointLevel_[pointi]);
3340 Pout<<
"hexRef8::setRefinement :"
3341 <<
" Allocating " << cellLabels.
size() <<
" cell midpoints."
3349 labelList cellMidPoint(mesh_.nCells(), -1);
3353 label celli = cellLabels[i];
3355 label anchorPointi = mesh_.faces()[mesh_.cells()[celli][0]][0];
3361 mesh_.cellCentres()[celli],
3368 newPointLevel(cellMidPoint[celli]) = cellLevel_[celli]+1;
3374 cellSet splitCells(mesh_,
"splitCells", cellLabels.
size());
3376 forAll(cellMidPoint, celli)
3378 if (cellMidPoint[celli] >= 0)
3380 splitCells.
insert(celli);
3384 Pout<<
"hexRef8::setRefinement : Dumping " << splitCells.
size()
3385 <<
" cells to split to cellSet " << splitCells.
objectPath()
3398 Pout<<
"hexRef8::setRefinement :"
3399 <<
" Allocating edge midpoints."
3408 labelList edgeMidPoint(mesh_.nEdges(), -1);
3411 forAll(cellMidPoint, celli)
3413 if (cellMidPoint[celli] >= 0)
3415 const labelList& cEdges = mesh_.cellEdges(celli);
3419 label edgeI = cEdges[i];
3421 const edge&
e = mesh_.edges()[edgeI];
3425 pointLevel_[
e[0]] <= cellLevel_[celli]
3426 && pointLevel_[
e[1]] <= cellLevel_[celli]
3429 edgeMidPoint[edgeI] = 12345;
3456 forAll(edgeMidPoint, edgeI)
3458 if (edgeMidPoint[edgeI] >= 0)
3461 edgeMids[edgeI] = mesh_.edges()[edgeI].centre(mesh_.points());
3469 point(-GREAT, -GREAT, -GREAT)
3474 forAll(edgeMidPoint, edgeI)
3476 if (edgeMidPoint[edgeI] >= 0)
3481 const edge&
e = mesh_.edges()[edgeI];
3494 newPointLevel(edgeMidPoint[edgeI]) =
3507 OFstream str(mesh_.time().path()/
"edgeMidPoint.obj");
3509 forAll(edgeMidPoint, edgeI)
3511 if (edgeMidPoint[edgeI] >= 0)
3513 const edge&
e = mesh_.edges()[edgeI];
3519 Pout<<
"hexRef8::setRefinement :"
3520 <<
" Dumping edge centres to split to file " << str.
name() <<
endl;
3530 Pout<<
"hexRef8::setRefinement :"
3531 <<
" Allocating face midpoints."
3537 labelList faceAnchorLevel(mesh_.nFaces());
3539 for (label facei = 0; facei < mesh_.nFaces(); facei++)
3541 faceAnchorLevel[facei] =
faceLevel(facei);
3546 labelList faceMidPoint(mesh_.nFaces(), -1);
3551 for (label facei = 0; facei < mesh_.nInternalFaces(); facei++)
3553 if (faceAnchorLevel[facei] >= 0)
3555 label own = mesh_.faceOwner()[facei];
3556 label ownLevel = cellLevel_[own];
3557 label newOwnLevel = ownLevel + (cellMidPoint[own] >= 0 ? 1 : 0);
3559 label nei = mesh_.faceNeighbour()[facei];
3560 label neiLevel = cellLevel_[nei];
3561 label newNeiLevel = neiLevel + (cellMidPoint[nei] >= 0 ? 1 : 0);
3565 newOwnLevel > faceAnchorLevel[facei]
3566 || newNeiLevel > faceAnchorLevel[facei]
3569 faceMidPoint[facei] = 12345;
3582 labelList newNeiLevel(mesh_.nBoundaryFaces());
3586 label own = mesh_.faceOwner()[i+mesh_.nInternalFaces()];
3587 label ownLevel = cellLevel_[own];
3588 label newOwnLevel = ownLevel + (cellMidPoint[own] >= 0 ? 1 : 0);
3590 newNeiLevel[i] = newOwnLevel;
3600 label facei = i+mesh_.nInternalFaces();
3602 if (faceAnchorLevel[facei] >= 0)
3604 label own = mesh_.faceOwner()[facei];
3605 label ownLevel = cellLevel_[own];
3606 label newOwnLevel = ownLevel + (cellMidPoint[own] >= 0 ? 1 : 0);
3610 newOwnLevel > faceAnchorLevel[facei]
3611 || newNeiLevel[i] > faceAnchorLevel[facei]
3614 faceMidPoint[facei] = 12345;
3639 mesh_.nBoundaryFaces(),
3640 point(-GREAT, -GREAT, -GREAT)
3645 label facei = i+mesh_.nInternalFaces();
3647 if (faceMidPoint[facei] >= 0)
3649 bFaceMids[i] = mesh_.faceCentres()[facei];
3659 forAll(faceMidPoint, facei)
3661 if (faceMidPoint[facei] >= 0)
3666 const face&
f = mesh_.faces()[facei];
3673 facei < mesh_.nInternalFaces()
3674 ? mesh_.faceCentres()[facei]
3675 : bFaceMids[facei-mesh_.nInternalFaces()]
3685 newPointLevel(faceMidPoint[facei]) = faceAnchorLevel[facei]+1;
3692 faceSet splitFaces(mesh_,
"splitFaces", cellLabels.
size());
3694 forAll(faceMidPoint, facei)
3696 if (faceMidPoint[facei] >= 0)
3698 splitFaces.
insert(facei);
3702 Pout<<
"hexRef8::setRefinement : Dumping " << splitFaces.
size()
3703 <<
" faces to split to faceSet " << splitFaces.
objectPath() <<
endl;
3724 Pout<<
"hexRef8::setRefinement :"
3725 <<
" Finding cell anchorPoints (8 per cell)"
3738 forAll(cellMidPoint, celli)
3740 if (cellMidPoint[celli] >= 0)
3742 cellAnchorPoints[celli].
setSize(8);
3746 forAll(pointLevel_, pointi)
3748 const labelList& pCells = mesh_.pointCells(pointi);
3752 label celli = pCells[pCelli];
3756 cellMidPoint[celli] >= 0
3757 && pointLevel_[pointi] <= cellLevel_[celli]
3760 if (nAnchorPoints[celli] == 8)
3765 <<
" of level " << cellLevel_[celli]
3766 <<
" uses more than 8 points of equal or"
3767 <<
" lower level" <<
nl
3768 <<
"Points so far:" << cellAnchorPoints[celli]
3772 cellAnchorPoints[celli][nAnchorPoints[celli]++] = pointi;
3777 forAll(cellMidPoint, celli)
3779 if (cellMidPoint[celli] >= 0)
3781 if (nAnchorPoints[celli] != 8)
3785 const labelList& cPoints = mesh_.cellPoints(celli);
3789 <<
" of level " << cellLevel_[celli]
3790 <<
" does not seem to have 8 points of equal or"
3791 <<
" lower level" <<
endl
3792 <<
"cellPoints:" << cPoints <<
endl
3807 Pout<<
"hexRef8::setRefinement :"
3808 <<
" Adding cells (1 per anchorPoint)"
3815 forAll(cellAnchorPoints, celli)
3817 const labelList& cAnchors = cellAnchorPoints[celli];
3819 if (cAnchors.
size() == 8)
3821 labelList& cAdded = cellAddedCells[celli];
3828 newCellLevel[celli] = cellLevel_[celli]+1;
3831 for (label i = 1; i < 8; i++)
3841 mesh_.cellZones().whichZone(celli)
3845 newCellLevel(cAdded[i]) = cellLevel_[celli]+1;
3860 Pout<<
"hexRef8::setRefinement :"
3861 <<
" Marking faces to be handled"
3866 bitSet affectedFace(mesh_.nFaces());
3869 forAll(cellMidPoint, celli)
3871 if (cellMidPoint[celli] >= 0)
3873 const cell& cFaces = mesh_.cells()[celli];
3875 affectedFace.
set(cFaces);
3879 forAll(faceMidPoint, facei)
3881 if (faceMidPoint[facei] >= 0)
3883 affectedFace.
set(facei);
3887 forAll(edgeMidPoint, edgeI)
3889 if (edgeMidPoint[edgeI] >= 0)
3891 const labelList& eFaces = mesh_.edgeFaces(edgeI);
3893 affectedFace.
set(eFaces);
3904 Pout<<
"hexRef8::setRefinement : Splitting faces" <<
endl;
3907 forAll(faceMidPoint, facei)
3909 if (faceMidPoint[facei] >= 0 && affectedFace.
test(facei))
3915 const face&
f = mesh_.faces()[facei];
3919 bool modifiedFace =
false;
3921 label anchorLevel = faceAnchorLevel[facei];
3927 label pointi =
f[fp];
3929 if (pointLevel_[pointi] <= anchorLevel)
3935 faceVerts.
append(pointi);
3951 faceVerts.
append(faceMidPoint[facei]);
3984 if (mesh_.isInternalFace(facei))
3986 label oldOwn = mesh_.faceOwner()[facei];
3987 label oldNei = mesh_.faceNeighbour()[facei];
3989 checkInternalOrientation
3994 mesh_.cellCentres()[oldOwn],
3995 mesh_.cellCentres()[oldNei],
4001 label oldOwn = mesh_.faceOwner()[facei];
4003 checkBoundaryOrientation
4008 mesh_.cellCentres()[oldOwn],
4009 mesh_.faceCentres()[facei],
4018 modifiedFace =
true;
4020 modFace(meshMod, facei, newFace, own, nei);
4024 addFace(meshMod, facei, newFace, own, nei);
4030 affectedFace.
unset(facei);
4040 Pout<<
"hexRef8::setRefinement :"
4041 <<
" Adding edge splits to unsplit faces"
4048 forAll(edgeMidPoint, edgeI)
4050 if (edgeMidPoint[edgeI] >= 0)
4054 const labelList& eFaces = mesh_.edgeFaces(edgeI, eFacesStorage);
4058 label facei = eFaces[i];
4060 if (faceMidPoint[facei] < 0 && affectedFace.
test(facei))
4064 const face&
f = mesh_.faces()[facei];
4065 const labelList& fEdges = mesh_.faceEdges
4077 label edgeI = fEdges[fp];
4079 if (edgeMidPoint[edgeI] >= 0)
4081 newFaceVerts.
append(edgeMidPoint[edgeI]);
4090 label anchorFp = findMinLevel(
f);
4107 if (mesh_.isInternalFace(facei))
4109 label oldOwn = mesh_.faceOwner()[facei];
4110 label oldNei = mesh_.faceNeighbour()[facei];
4112 checkInternalOrientation
4117 mesh_.cellCentres()[oldOwn],
4118 mesh_.cellCentres()[oldNei],
4124 label oldOwn = mesh_.faceOwner()[facei];
4126 checkBoundaryOrientation
4131 mesh_.cellCentres()[oldOwn],
4132 mesh_.faceCentres()[facei],
4138 modFace(meshMod, facei, newFace, own, nei);
4141 affectedFace.
unset(facei);
4153 Pout<<
"hexRef8::setRefinement :"
4154 <<
" Changing owner/neighbour for otherwise unaffected faces"
4158 forAll(affectedFace, facei)
4160 if (affectedFace.
test(facei))
4162 const face&
f = mesh_.faces()[facei];
4166 label anchorFp = findMinLevel(
f);
4180 modFace(meshMod, facei,
f, own, nei);
4183 affectedFace.
unset(facei);
4198 Pout<<
"hexRef8::setRefinement :"
4199 <<
" Create new internal faces for split cells"
4203 forAll(cellMidPoint, celli)
4205 if (cellMidPoint[celli] >= 0)
4230 forAll(cellMidPoint, celli)
4232 if (cellMidPoint[celli] >= 0)
4234 minPointi =
min(minPointi, cellMidPoint[celli]);
4235 maxPointi =
max(maxPointi, cellMidPoint[celli]);
4238 forAll(faceMidPoint, facei)
4240 if (faceMidPoint[facei] >= 0)
4242 minPointi =
min(minPointi, faceMidPoint[facei]);
4243 maxPointi =
max(maxPointi, faceMidPoint[facei]);
4246 forAll(edgeMidPoint, edgeI)
4248 if (edgeMidPoint[edgeI] >= 0)
4250 minPointi =
min(minPointi, edgeMidPoint[edgeI]);
4251 maxPointi =
max(maxPointi, edgeMidPoint[edgeI]);
4255 if (minPointi !=
labelMax && minPointi != mesh_.nPoints())
4258 <<
"Added point labels not consecutive to existing mesh points."
4260 <<
"mesh_.nPoints():" << mesh_.nPoints()
4261 <<
" minPointi:" << minPointi
4262 <<
" maxPointi:" << maxPointi
4267 pointLevel_.
transfer(newPointLevel);
4268 cellLevel_.transfer(newCellLevel);
4278 if (history_.active())
4282 Pout<<
"hexRef8::setRefinement :"
4283 <<
" Updating refinement history to " << cellLevel_.size()
4284 <<
" cells" <<
endl;
4288 history_.resize(cellLevel_.size());
4290 forAll(cellAddedCells, celli)
4292 const labelList& addedCells = cellAddedCells[celli];
4294 if (addedCells.
size())
4297 history_.storeSplit(celli, addedCells);
4308 label celli = cellLabels[i];
4310 refinedCells[i].
transfer(cellAddedCells[celli]);
4313 return refinedCells;
4324 savedPointLevel_.
clear();
4325 savedPointLevel_.reserve(pointsToStore.
size());
4328 label pointi = pointsToStore[i];
4329 savedPointLevel_.insert(pointi, pointLevel_[pointi]);
4332 savedCellLevel_.
clear();
4333 savedCellLevel_.reserve(cellsToStore.
size());
4336 label celli = cellsToStore[i];
4337 savedCellLevel_.insert(celli, cellLevel_[celli]);
4349 updateMesh(map, dummyMap, dummyMap, dummyMap);
4367 Pout<<
"hexRef8::updateMesh :"
4368 <<
" Updating various lists"
4377 Pout<<
"hexRef8::updateMesh :"
4380 <<
" nCells:" << mesh_.nCells()
4382 <<
" cellLevel_:" << cellLevel_.size()
4385 <<
" nPoints:" << mesh_.nPoints()
4387 <<
" pointLevel_:" << pointLevel_.size()
4391 if (reverseCellMap.
size() == cellLevel_.size())
4397 reorder(reverseCellMap, mesh_.nCells(), -1, cellLevel_);
4405 forAll(cellMap, newCelli)
4407 label oldCelli = cellMap[newCelli];
4411 newCellLevel[newCelli] = -1;
4415 newCellLevel[newCelli] = cellLevel_[oldCelli];
4425 const label newCelli = iter.key();
4426 const label storedCelli = iter.val();
4428 const auto fnd = savedCellLevel_.cfind(storedCelli);
4433 <<
"Problem : trying to restore old value for new cell "
4434 << newCelli <<
" but cannot find old cell " << storedCelli
4435 <<
" in map of stored values " << savedCellLevel_
4438 cellLevel_[newCelli] = fnd.val();
4459 if (reversePointMap.
size() == pointLevel_.size())
4462 reorder(reversePointMap, mesh_.nPoints(), -1, pointLevel_);
4473 const label oldPointi = pointMap[
newPointi];
4475 if (oldPointi == -1)
4488 newPointLevel[
newPointi] = pointLevel_[oldPointi];
4491 pointLevel_.
transfer(newPointLevel);
4499 const label storedPointi = iter.val();
4501 auto fnd = savedPointLevel_.find(storedPointi);
4506 <<
"Problem : trying to restore old value for new point "
4507 <<
newPointi <<
" but cannot find old point "
4509 <<
" in map of stored values " << savedPointLevel_
4529 if (history_.active())
4531 history_.updateMesh(map);
4538 faceRemover_.updateMesh(map);
4541 cellShapesPtr_.clear();
4556 Pout<<
"hexRef8::subset :"
4557 <<
" Updating various lists"
4561 if (history_.active())
4564 <<
"Subsetting will not work in combination with unrefinement."
4566 <<
"Proceed at your own risk." <<
endl;
4574 forAll(cellMap, newCelli)
4576 newCellLevel[newCelli] = cellLevel_[cellMap[newCelli]];
4579 cellLevel_.transfer(newCellLevel);
4581 if (cellLevel_.found(-1))
4585 <<
"cellLevel_ contains illegal value -1 after mapping:"
4600 pointLevel_.transfer(newPointLevel);
4602 if (pointLevel_.found(-1))
4606 <<
"pointLevel_ contains illegal value -1 after mapping:"
4613 if (history_.active())
4615 history_.subset(pointMap,
faceMap, cellMap);
4625 cellShapesPtr_.clear();
4634 Pout<<
"hexRef8::distribute :"
4635 <<
" Updating various lists"
4645 if (history_.active())
4647 history_.distribute(map);
4651 faceRemover_.distribute(map);
4654 cellShapesPtr_.clear();
4660 const scalar smallDim = 1
e-6 * mesh_.bounds().mag();
4664 Pout<<
"hexRef8::checkMesh : Using matching tolerance smallDim:"
4665 << smallDim <<
endl;
4678 nei[i] = mesh_.faceOwner()[i+mesh_.nInternalFaces()];
4696 label facei =
pp.start();
4700 label own = mesh_.faceOwner()[facei];
4701 label bFacei = facei-mesh_.nInternalFaces();
4707 <<
"Faces do not seem to be correct across coupled"
4708 <<
" boundaries" <<
endl
4709 <<
"Coupled face " << facei
4710 <<
" between owner " << own
4711 <<
" on patch " <<
pp.name()
4712 <<
" and coupled neighbour " << nei[bFacei]
4713 <<
" has two faces connected to it:"
4732 neiFaceAreas[i] =
mag(mesh_.faceAreas()[i+mesh_.nInternalFaces()]);
4740 label facei = i+mesh_.nInternalFaces();
4742 const scalar magArea =
mag(mesh_.faceAreas()[facei]);
4744 if (
mag(magArea - neiFaceAreas[i]) > smallDim)
4746 const face&
f = mesh_.faces()[facei];
4747 label patchi = mesh_.boundaryMesh().whichPatch(facei);
4749 dumpCell(mesh_.faceOwner()[facei]);
4752 <<
"Faces do not seem to be correct across coupled"
4753 <<
" boundaries" <<
endl
4754 <<
"Coupled face " << facei
4755 <<
" on patch " << patchi
4756 <<
" " << mesh_.boundaryMesh()[patchi].name()
4758 <<
" has face area:" << magArea
4759 <<
" (coupled) neighbour face area differs:"
4761 <<
" to within tolerance " << smallDim
4771 labelList nVerts(mesh_.nBoundaryFaces());
4775 nVerts[i] = mesh_.faces()[i+mesh_.nInternalFaces()].
size();
4783 label facei = i+mesh_.nInternalFaces();
4785 const face&
f = mesh_.faces()[facei];
4787 if (
f.size() != nVerts[i])
4789 dumpCell(mesh_.faceOwner()[facei]);
4791 label patchi = mesh_.boundaryMesh().whichPatch(facei);
4794 <<
"Faces do not seem to be correct across coupled"
4795 <<
" boundaries" <<
endl
4796 <<
"Coupled face " << facei
4797 <<
" on patch " << patchi
4798 <<
" " << mesh_.boundaryMesh()[patchi].name()
4800 <<
" has size:" <<
f.size()
4801 <<
" (coupled) neighbour face has size:"
4813 pointField anchorPoints(mesh_.nBoundaryFaces());
4817 label facei = i+mesh_.nInternalFaces();
4818 const point& fc = mesh_.faceCentres()[facei];
4819 const face&
f = mesh_.faces()[facei];
4820 const vector anchorVec(mesh_.points()[
f[0]] - fc);
4822 anchorPoints[i] = anchorVec;
4832 label facei = i+mesh_.nInternalFaces();
4833 const point& fc = mesh_.faceCentres()[facei];
4834 const face&
f = mesh_.faces()[facei];
4835 const vector anchorVec(mesh_.points()[
f[0]] - fc);
4837 if (
mag(anchorVec - anchorPoints[i]) > smallDim)
4839 dumpCell(mesh_.faceOwner()[facei]);
4841 label patchi = mesh_.boundaryMesh().whichPatch(facei);
4844 <<
"Faces do not seem to be correct across coupled"
4845 <<
" boundaries" <<
endl
4846 <<
"Coupled face " << facei
4847 <<
" on patch " << patchi
4848 <<
" " << mesh_.boundaryMesh()[patchi].name()
4850 <<
" has anchor vector:" << anchorVec
4851 <<
" (coupled) neighbour face anchor vector differs:"
4853 <<
" to within tolerance " << smallDim
4861 Pout<<
"hexRef8::checkMesh : Returning" <<
endl;
4868 const label maxPointDiff,
4874 Pout<<
"hexRef8::checkRefinementLevels :"
4875 <<
" Checking 2:1 refinement level" <<
endl;
4880 cellLevel_.size() != mesh_.nCells()
4881 || pointLevel_.size() != mesh_.nPoints()
4885 <<
"cellLevel size should be number of cells"
4886 <<
" and pointLevel size should be number of points."<<
nl
4887 <<
"cellLevel:" << cellLevel_.size()
4888 <<
" mesh.nCells():" << mesh_.nCells() <<
nl
4889 <<
"pointLevel:" << pointLevel_.size()
4890 <<
" mesh.nPoints():" << mesh_.nPoints()
4900 for (label facei = 0; facei < mesh_.nInternalFaces(); facei++)
4902 label own = mesh_.faceOwner()[facei];
4903 label nei = mesh_.faceNeighbour()[facei];
4905 if (
mag(cellLevel_[own] - cellLevel_[nei]) > 1)
4911 <<
"Celllevel does not satisfy 2:1 constraint." <<
nl
4912 <<
"On face " << facei <<
" owner cell " << own
4913 <<
" has refinement " << cellLevel_[own]
4914 <<
" neighbour cell " << nei <<
" has refinement "
4921 labelList neiLevel(mesh_.nBoundaryFaces());
4925 label own = mesh_.faceOwner()[i+mesh_.nInternalFaces()];
4927 neiLevel[i] = cellLevel_[own];
4935 label facei = i+mesh_.nInternalFaces();
4937 label own = mesh_.faceOwner()[facei];
4939 if (
mag(cellLevel_[own] - neiLevel[i]) > 1)
4943 label patchi = mesh_.boundaryMesh().whichPatch(facei);
4946 <<
"Celllevel does not satisfy 2:1 constraint."
4947 <<
" On coupled face " << facei
4948 <<
" on patch " << patchi <<
" "
4949 << mesh_.boundaryMesh()[patchi].name()
4950 <<
" owner cell " << own <<
" has refinement "
4952 <<
" (coupled) neighbour cell has refinement "
4975 forAll(syncPointLevel, pointi)
4977 if (pointLevel_[pointi] != syncPointLevel[pointi])
4980 <<
"PointLevel is not consistent across coupled patches."
4982 <<
"point:" << pointi <<
" coord:" << mesh_.points()[pointi]
4983 <<
" has level " << pointLevel_[pointi]
4984 <<
" whereas the coupled point has level "
4985 << syncPointLevel[pointi]
4993 if (maxPointDiff != -1)
4998 forAll(maxPointLevel, pointi)
5000 const labelList& pCells = mesh_.pointCells(pointi);
5002 label& pLevel = maxPointLevel[pointi];
5006 pLevel =
max(pLevel, cellLevel_[pCells[i]]);
5022 label pointi = pointsToCheck[i];
5024 const labelList& pCells = mesh_.pointCells(pointi);
5028 label celli = pCells[i];
5032 mag(cellLevel_[celli]-maxPointLevel[pointi])
5039 <<
"Too big a difference between"
5040 <<
" point-connected cells." <<
nl
5042 <<
" cellLevel:" << cellLevel_[celli]
5043 <<
" uses point:" << pointi
5044 <<
" coord:" << mesh_.points()[pointi]
5045 <<
" which is also used by a cell with level:"
5046 << maxPointLevel[pointi]
5121 if (!cellShapesPtr_)
5125 Pout<<
"hexRef8::cellShapes() : calculating splitHex cellShapes."
5126 <<
" cellLevel:" << cellLevel_.size()
5127 <<
" pointLevel:" << pointLevel_.size()
5134 label nSplitHex = 0;
5135 label nUnrecognised = 0;
5137 forAll(cellLevel_, celli)
5139 if (meshShapes[celli].model().index() == 0)
5141 label level = cellLevel_[celli];
5145 bool haveQuads = matchHexShape
5155 cellShapesPtr_()[celli] = degenerateMatcher::match(faces);
5166 Pout<<
"hexRef8::cellShapes() :"
5167 <<
" nCells:" << mesh_.nCells() <<
" of which" <<
nl
5168 <<
" primitive:" << (mesh_.nCells()-nSplitHex-nUnrecognised)
5170 <<
" split-hex:" << nSplitHex <<
nl
5171 <<
" poly :" << nUnrecognised <<
nl
5175 return *cellShapesPtr_;
5188 Pout<<
"hexRef8::getSplitPoints :"
5189 <<
" Calculating unrefineable points" <<
endl;
5193 if (!history_.active())
5196 <<
"Only call if constructed with history capability"
5204 labelList splitMaster(mesh_.nPoints(), -1);
5210 for (label pointi = 0; pointi < mesh_.nPoints(); pointi++)
5212 const labelList& pCells = mesh_.pointCells(pointi);
5214 if (pCells.
size() != 8)
5216 splitMaster[pointi] = -2;
5221 const labelList& visibleCells = history_.visibleCells();
5223 forAll(visibleCells, celli)
5225 const labelList& cPoints = mesh_.cellPoints(celli);
5227 if (visibleCells[celli] != -1 && history_.parentIndex(celli) >= 0)
5229 label parentIndex = history_.parentIndex(celli);
5234 label pointi = cPoints[i];
5236 label masterCelli = splitMaster[pointi];
5238 if (masterCelli == -1)
5245 splitMaster[pointi] = parentIndex;
5246 splitMasterLevel[pointi] = cellLevel_[celli] - 1;
5248 else if (masterCelli == -2)
5254 (masterCelli != parentIndex)
5255 || (splitMasterLevel[pointi] != cellLevel_[celli] - 1)
5260 splitMaster[pointi] = -2;
5269 label pointi = cPoints[i];
5271 splitMaster[pointi] = -2;
5279 label facei = mesh_.nInternalFaces();
5280 facei < mesh_.nFaces();
5284 const face&
f = mesh_.faces()[facei];
5288 splitMaster[
f[fp]] = -2;
5295 label nSplitPoints = 0;
5297 forAll(splitMaster, pointi)
5299 if (splitMaster[pointi] >= 0)
5308 forAll(splitMaster, pointi)
5310 if (splitMaster[pointi] >= 0)
5312 splitPoints[nSplitPoints++] = pointi;
5390 Pout<<
"hexRef8::consistentUnrefinement :"
5391 <<
" Determining 2:1 consistent unrefinement" <<
endl;
5397 <<
"maxSet not implemented yet."
5407 bitSet unrefinePoint(mesh_.nPoints(), pointsToUnrefine);
5414 bitSet unrefineCell(mesh_.nCells());
5416 forAll(unrefinePoint, pointi)
5418 if (unrefinePoint.
test(pointi))
5420 const labelList& pCells = mesh_.pointCells(pointi);
5422 unrefineCell.
set(pCells);
5434 for (label facei = 0; facei < mesh_.nInternalFaces(); facei++)
5436 label own = mesh_.faceOwner()[facei];
5437 label nei = mesh_.faceNeighbour()[facei];
5439 label ownLevel = cellLevel_[own] - unrefineCell.
get(own);
5440 label neiLevel = cellLevel_[nei] - unrefineCell.
get(nei);
5442 if (ownLevel < (neiLevel-1))
5449 unrefineCell.
set(nei);
5460 if (!unrefineCell.
test(own))
5466 unrefineCell.
unset(own);
5470 else if (neiLevel < (ownLevel-1))
5474 unrefineCell.
set(own);
5478 if (!unrefineCell.
test(nei))
5484 unrefineCell.
unset(nei);
5492 labelList neiLevel(mesh_.nBoundaryFaces());
5496 label own = mesh_.faceOwner()[i+mesh_.nInternalFaces()];
5498 neiLevel[i] = cellLevel_[own] - unrefineCell.
get(own);
5506 label facei = i+mesh_.nInternalFaces();
5507 label own = mesh_.faceOwner()[facei];
5508 label ownLevel = cellLevel_[own] - unrefineCell.
get(own);
5510 if (ownLevel < (neiLevel[i]-1))
5514 if (!unrefineCell.
test(own))
5520 unrefineCell.
unset(own);
5524 else if (neiLevel[i] < (ownLevel-1))
5528 if (unrefineCell.
test(own))
5534 unrefineCell.
set(own);
5544 Pout<<
"hexRef8::consistentUnrefinement :"
5545 <<
" Changed " << nChanged
5546 <<
" refinement levels due to 2:1 conflicts."
5560 forAll(unrefinePoint, pointi)
5562 if (unrefinePoint.
test(pointi))
5564 const labelList& pCells = mesh_.pointCells(pointi);
5568 if (!unrefineCell.
test(pCells[j]))
5570 unrefinePoint.
unset(pointi);
5582 forAll(unrefinePoint, pointi)
5584 if (unrefinePoint.
test(pointi))
5593 forAll(unrefinePoint, pointi)
5595 if (unrefinePoint.
test(pointi))
5597 newPointsToUnrefine[nSet++] = pointi;
5601 return newPointsToUnrefine;
5611 if (!history_.active())
5614 <<
"Only call if constructed with history capability"
5620 Pout<<
"hexRef8::setUnrefinement :"
5621 <<
" Checking initial mesh just to make sure" <<
endl;
5625 forAll(cellLevel_, celli)
5627 if (cellLevel_[celli] < 0)
5630 <<
"Illegal cell level " << cellLevel_[celli]
5631 <<
" for cell " << celli
5638 pointSet pSet(mesh_,
"splitPoints", splitPointLabels);
5641 cellSet cSet(mesh_,
"splitPointCells", splitPointLabels.
size());
5643 forAll(splitPointLabels, i)
5645 const labelList& pCells = mesh_.pointCells(splitPointLabels[i]);
5651 Pout<<
"hexRef8::setRefinement : Dumping " << pSet.
size()
5653 << cSet.
size() <<
" cells for unrefinement to" <<
nl
5667 forAll(splitPointLabels, i)
5676 faceRemover_.compatibleRemoves
5684 if (facesToRemove.
size() != splitFaces.
size())
5690 mesh_.time().timeName()
5693 pointSet pSet(mesh_,
"splitPoints", splitPointLabels);
5695 faceSet fSet(mesh_,
"splitFaces", splitFaces);
5697 faceSet removeSet(mesh_,
"facesToRemove", facesToRemove);
5702 <<
"Ininitial set of split points to unrefine does not"
5703 <<
" seem to be consistent or not mid points of refined cells"
5704 <<
" splitPoints:" << splitPointLabels.
size()
5705 <<
" splitFaces:" << splitFaces.
size()
5706 <<
" facesToRemove:" << facesToRemove.
size()
5715 forAll(splitPointLabels, i)
5717 label pointi = splitPointLabels[i];
5721 const labelList& pCells = mesh_.pointCells(pointi);
5724 if (pCells.
size() != 8)
5727 <<
"splitPoint " << pointi
5728 <<
" should have 8 cells using it. It has " << pCells
5737 label masterCelli =
min(pCells);
5741 label celli = pCells[j];
5743 label region = cellRegion[celli];
5748 <<
"Ininitial set of split points to unrefine does not"
5749 <<
" seem to be consistent or not mid points"
5750 <<
" of refined cells" <<
nl
5751 <<
"cell:" << celli <<
" on splitPoint " << pointi
5752 <<
" has no region to be merged into"
5756 if (masterCelli != cellRegionMaster[region])
5759 <<
"cell:" << celli <<
" on splitPoint:" << pointi
5760 <<
" in region " << region
5761 <<
" has master:" << cellRegionMaster[region]
5762 <<
" which is not the lowest numbered cell"
5763 <<
" among the pointCells:" << pCells
5772 faceRemover_.setRefinement
5783 forAll(splitPointLabels, i)
5785 label pointi = splitPointLabels[i];
5787 const labelList& pCells = mesh_.pointCells(pointi);
5789 label masterCelli =
min(pCells);
5793 cellLevel_[pCells[j]]--;
5796 history_.combineCells(masterCelli, pCells);
5810 cellLevel_.write(writeOnProc)
5811 && pointLevel_.write(writeOnProc)
5812 && level0Edge_.write(writeOnProc);
5814 if (history_.active())
5816 writeOk = writeOk && history_.write(writeOnProc);
5832 mesh.facesInstance(),
5838 if (topoSet::debug)
DebugVar(setsDir);
5840 if (
exists(setsDir/
"cellLevel"))
5842 rm(setsDir/
"cellLevel");
5844 if (
exists(setsDir/
"pointLevel"))
5846 rm(setsDir/
"pointLevel");
5848 if (
exists(setsDir/
"level0Edge"))
5850 rm(setsDir/
"level0Edge");
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
void clear() noexcept
Clear the addressed list, i.e. set the size to zero.
void transfer(List< T > &list)
Transfer contents of the argument List into this.
T & emplace_back(Args &&... args)
Construct an element at the end of the list, return reference to the new list element.
void append(const T &val)
Copy append an element to the end of this list.
void push_back(const T &val)
Copy append an element to the end of this list.
DynamicList< T, SizeMin > & shrink()
Calls shrink_to_fit() and returns a reference to the DynamicList.
void setCapacity(const label len)
Alter the size of the underlying storage.
static scalar propagationTol() noexcept
Access to propagation tolerance.
Wave propagation of information through grid. Every iteration information goes through one layer of c...
virtual label iterate(const label maxIter)
Iterate until no changes or maxIter reached.
void setFaceInfo(const label facei, const Type &faceInfo)
Set single initial changed face.
bool insert(const Key &key)
Insert a new entry, not overwriting existing entries.
List< Key > toc() const
The table of contents (the keys) in unsorted order.
void reserve(label numEntries)
Reserve space for at least the specified number of elements (not the number of buckets) and regenerat...
bool insert(const Key &key, const T &obj)
Copy insert a new entry, not overwriting existing entries.
label size() const noexcept
The number of elements in table.
@ READ_IF_PRESENT
Reading is optional [identical to LAZY_READ].
Defines the attributes of an object for which implicit objectRegistry management is supported,...
fileName objectPath() const
The complete path + object name.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void transfer(List< T > &list)
Transfer the contents of the argument List into this list and annul the argument list.
void append(const T &val)
Append an element at the end of the list.
void setSize(label n)
Alias for resize().
void clear()
Clear the list, i.e. set size to zero.
A HashTable to objects of type <T> with a label key.
Output to file stream as an OSstream, normally using std::ofstream for the actual output.
virtual const fileName & name() const override
Read/write access to the name of the stream.
unsigned int get(const label i) const
Get value at index i or 0 for out-of-range.
static void listReduce(UList< T > &values, BinaryOp bop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Reduce list elements (list must be equal size on all ranks), applying bop to each list element.
A non-owning sub-view of a List (allocated or unallocated storage).
A List with indirect addressing. Like IndirectList but does not store addressing.
label rcIndex(const label i) const noexcept
The reverse circular index. The previous index in the list which returns to the last at the beginning...
void size(const label n)
Older name for setAddressableSize.
label find(const T &val) const
Find index of the first occurrence of the value.
label fcIndex(const label i) const noexcept
The forward circular index. The next index in the list which returns to the first at the end of the l...
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
void set(const bitSet &bitset)
Set specified bits from another bitset.
bool test(const label pos) const
Test for True value at specified position, never auto-vivify entries.
labelList toc() const
The indices of the on bits as a sorted labelList.
bitSet & unset(const bitSet &other)
Unset (subtract) the bits specified in the other bitset, which is a set difference corresponds to the...
Holds information regarding type of cell. Used in inside/outside determination in cellClassification.
A collection of cell labels.
A topoSetFaceSource to select all the faces from given cellSet(s).
A cell is defined as a list of faces with extra functionality.
An edge is a list of two vertex labels. This can correspond to a directed graph edge or an edge on a ...
label otherVertex(const label vertex) const
Given one vertex label, return the other one.
Smooth ATC in cells next to a set of patches supplied by type.
A subset of mesh faces organised as a primitive patch.
const boolList & flipMap() const noexcept
Return face flip map.
A face is a list of labels corresponding to mesh vertices.
A class for handling file names.
Refinement of (split) hexes using polyTopoChange.
void checkRefinementLevels(const label maxPointDiff, const labelList &pointsToCheck) const
Debug: Check 2:1 consistency across faces.
labelList consistentSlowRefinement(const label maxFaceDiff, const labelList &cellsToRefine, const labelList &facesToCheck, const label maxPointDiff, const labelList &pointsToCheck) const
Like consistentRefinement but slower:
static void removeFiles(const polyMesh &)
Helper: remove all relevant files from mesh instance.
const labelIOList & cellLevel() const
const polyMesh & mesh() const
void checkMesh() const
Debug: Check coupled mesh for correctness.
scalar level0EdgeLength() const
Typical edge length between unrefined points.
labelListList setRefinement(const labelList &cells, polyTopoChange &)
Insert refinement. All selected cells will be split into 8.
labelList consistentRefinement(const labelUList &cellLevel, const labelList &cellsToRefine, const bool maxSet) const
Given valid mesh and current cell level and proposed.
void distribute(const mapDistributePolyMesh &)
Update local numbering for mesh redistribution.
const cellShapeList & cellShapes() const
Utility: get hexes as cell shapes.
void setUnrefinement(const labelList &splitPointLabels, polyTopoChange &)
Remove some refinement. Needs to be supplied output of.
bool write(const bool writeOnProc=true) const
Force writing refinement+history to polyMesh directory.
labelList consistentUnrefinement(const labelList &pointsToUnrefine, const bool maxSet) const
Given proposed.
labelList getSplitPoints() const
Return the points at the centre of top-level split cells.
label faceLevel(const label facei) const
Gets level such that the face has four points <= level.
const labelIOList & pointLevel() const
void storeData(const labelList &pointsToStore, const labelList &facesToStore, const labelList &cellsToStore)
Signal points/face/cells for which to store data.
const refinementHistory & history() const
void updateMesh(const mapPolyMesh &)
Update local numbering for changed mesh.
labelList consistentSlowRefinement2(const label maxFaceDiff, const labelList &cellsToRefine, const labelList &facesToCheck) const
Like consistentSlowRefinement but uses different meshWave.
void subset(const labelList &pointMap, const labelList &faceMap, const labelList &cellMap)
Update local numbering for subsetted mesh.
void setInstance(const fileName &inst)
Class containing mesh-to-mesh mapping information after a mesh distribution where we send parts of me...
void distributeCellData(List< T > &values) const
Distribute list of cell data.
void distributePointData(List< T > &values) const
Distribute list of point data.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
const labelList & reverseCellMap() const noexcept
Reverse cell map.
label nOldCells() const noexcept
Number of old cells.
const labelList & cellMap() const noexcept
Old cell map.
const labelList & reversePointMap() const noexcept
Reverse point map.
const labelList & pointMap() const noexcept
Old point map.
label nOldPoints() const noexcept
Number of old points.
Class containing data for cell addition.
A face addition data class. A face can be inflated either from a point or from another face and can e...
Class containing data for point addition.
A polyBoundaryMesh is a polyPatch list with registered IO, a reference to the associated polyMesh,...
Mesh consisting of general polyhedral cells.
static word meshSubDir
Return the mesh sub-directory name (usually "polyMesh").
Class describing modification of a face.
A patch is a list of labels that address the faces in the global face list.
Direct mesh changes based on v1.3 polyTopoChange syntax.
label setAction(const topoAction &action)
For compatibility with polyTopoChange: set topological action.
const DynamicList< point > & points() const
Points. Shrunk after constructing mesh (or calling of compact()).
label nPoints() const noexcept
Number of mesh points.
label nCells() const noexcept
Number of mesh cells.
Container with cells to refine. Refinement given as single direction.
Transfers refinement levels such that slow transition between levels is maintained....
bool updateFace(const polyMesh &, const label thisFacei, const label neighbourCelli, const refinementData &neighbourInfo, const scalar tol, TrackingData &td)
Influence of neighbouring cell.
Transfers refinement levels such that slow transition between levels is maintained....
All refinement history. Used in unrefinement.
static void removeFiles(const polyMesh &)
Helper: remove all sets files from mesh instance.
const labelList & visibleCells() const
Per cell in the current mesh (i.e. visible) either -1 (unrefined) or an index into splitCells.
bool active() const
Is there unrefinement history?
virtual bool write(const bool writeOnProc=true) const
Write using setting from DB.
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
const volScalarField & p0
const polyBoundaryMesh & patches
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
A HashTable to objects of type <T> with a labelPair key. The hashing is based on labelPair (FixedList...
List< wallPoints > allFaceInfo(mesh_.nFaces())
List< wallPoints > allCellInfo(mesh_.nCells())
#define WarningInFunction
Report a warning using Foam::Warning.
#define DebugVar(var)
Report a variable name and value.
Namespace for handling debugging switches.
bool rm(const fileName &file)
Remove a file (or its gz equivalent), returning true if successful.
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
Pair< label > labelPair
A pair of labels.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
List< labelList > labelListList
List of labelList.
bool exists(const fileName &name, const bool checkGzip=true, const bool followLink=true)
Does the name exist (as DIRECTORY or FILE) in the file system?
List< label > labelList
A List of labels.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
HashSet< label, Hash< label > > labelHashSet
A HashSet of labels, uses label hasher.
prefixOSstream Perr
OSstream wrapped stderr (std::cerr) with parallel prefix.
UIndirectList< label > labelUIndList
UIndirectList of labels.
void reverse(UList< T > &list, const label n)
Reverse the first n elements of the list.
PrimitivePatch< SubList< face >, const pointField & > primitivePatch
A PrimitivePatch with a SubList addressing for the faces, const reference for the point field.
List< face > faceList
List of faces.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
HashTable< label, labelPair, Foam::Hash< labelPair > > labelPairLookup
This is a Map of a labelPair to a label. Used for e.g. for face1, face2 to shared edge....
Ostream & endl(Ostream &os)
Add newline and flush stream.
dimensionedScalar sqrt(const dimensionedScalar &ds)
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
void reduce(T &value, BinaryOp bop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Reduce inplace (cf. MPI Allreduce).
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
labelList identity(const label len, label start=0)
Return an identity map of the given length with (map[i] == i), works like std::iota() but returning a...
errorManip< error > abort(error &err)
vector point
Point is a vector.
static constexpr const zero Zero
Global zero (0).
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
vectorField pointField
pointField is a vectorField.
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
labelList findIndices(const ListType &input, typename ListType::const_reference val, label start=0)
Linear search to find all occurrences of given element.
errorManipArg< error, int > exit(error &err, const int errNo=1)
UList< label > labelUList
A UList of labels.
Type gMax(const FieldField< Field, Type > &f)
ListType reorder(const labelUList &oldToNew, const ListType &input, const bool prune=false)
Reorder the elements of a list.
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
List< cellShape > cellShapeList
List of cellShape.
constexpr char nl
The newline '\n' character (0x0a).
Info<< "Finished reading KIVA file"<< endl;cellShapeList cellShapes(nPoints);labelList cellZoning(nPoints, -1);const cellModel &hex=cellModel::ref(cellModel::HEX);labelList hexLabels(8);label activeCells=0;labelList pointMap(nPoints);forAll(pointMap, i){ pointMap[i]=i;}for(label i=0;i< nPoints;i++){ if(f[i] > 0.0) { hexLabels[0]=i;hexLabels[1]=i1tab[i];hexLabels[2]=i3tab[i1tab[i]];hexLabels[3]=i3tab[i];hexLabels[4]=i8tab[i];hexLabels[5]=i1tab[i8tab[i]];hexLabels[6]=i3tab[i1tab[i8tab[i]]];hexLabels[7]=i3tab[i8tab[i]];cellShapes[activeCells].reset(hex, hexLabels);edgeList edges=cellShapes[activeCells].edges();forAll(edges, ei) { if(edges[ei].mag(points)< SMALL) { label start=pointMap[edges[ei].start()];while(start !=pointMap[start]) { start=pointMap[start];} label end=pointMap[edges[ei].end()];while(end !=pointMap[end]) { end=pointMap[end];} pointMap[start]=pointMap[end]=Foam::min(start, end);} } cellZoning[activeCells]=idreg[i];activeCells++;}}cellShapes.setSize(activeCells);cellZoning.setSize(activeCells);forAll(cellShapes, celli){ cellShape &cs=cellShapes[celli];forAll(cs, i) { cs[i]=pointMap[cs[i]];} cs.collapse();}label bcIDs[11]={-1, 0, 2, 4, -1, 5, -1, 6, 7, 8, 9};constexpr label nBCs=12;const word *kivaPatchTypes[nBCs]={ &wallPolyPatch::typeName, &wallPolyPatch::typeName, &wallPolyPatch::typeName, &wallPolyPatch::typeName, &symmetryPolyPatch::typeName, &wedgePolyPatch::typeName, &polyPatch::typeName, &polyPatch::typeName, &polyPatch::typeName, &polyPatch::typeName, &symmetryPolyPatch::typeName, &oldCyclicPolyPatch::typeName};enum patchTypeNames{ PISTON, VALVE, LINER, CYLINDERHEAD, AXIS, WEDGE, INFLOW, OUTFLOW, PRESIN, PRESOUT, SYMMETRYPLANE, CYCLIC};const char *kivaPatchNames[nBCs]={ "piston", "valve", "liner", "cylinderHead", "axis", "wedge", "inflow", "outflow", "presin", "presout", "symmetryPlane", "cyclic"};List< DynamicList< face > > pFaces[nBCs]
#define forAll(list, i)
Loop across all elements in list.
#define forAllConstIters(container, iter)
Iterate across all elements of the container object with const access.
Reduction class. If x and y are not equal assign value.
void operator()(label &x, const label y) const