67 x = (
x ==
y) ?
x : value;
75 void Foam::hexRef8::reorder
96 newElems[newI] = elems[i];
100 elems.transfer(newElems);
104 void 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)];
133 Foam::label Foam::hexRef8::addFace
135 polyTopoChange& meshMod,
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(),
198 Foam::label Foam::hexRef8::addInternalFace
200 polyTopoChange& meshMod,
201 const label meshFacei,
202 const label meshPointi,
208 if (mesh_.isInternalFace(meshFacei))
210 return meshMod.setAction
238 return meshMod.setAction
294 void Foam::hexRef8::modFace
296 polyTopoChange& meshMod,
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(),
358 Foam::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)
420 ifEqEqOp<labelMax>(),
428 const label eLevel = edgeLevel[edgeI];
430 if (eLevel >= 0 && eLevel <
labelMax)
432 const edge&
e = mesh_.edges()[edgeI];
434 scalar edgeLenSqr =
magSqr(
e.vec(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 =
magSqr(
e.vec(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)
540 Foam::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?" 597 void Foam::hexRef8::getFaceNeighbours
613 mesh_.faceOwner()[facei],
618 if (mesh_.isInternalFace(facei))
624 mesh_.faceNeighbour()[facei],
637 Foam::label Foam::hexRef8::findMinLevel(
const labelList&
f)
const 644 label level = pointLevel_[
f[fp]];
646 if (level < minLevel)
658 Foam::label Foam::hexRef8::findMaxLevel(
const labelList&
f)
const 665 label level = pointLevel_[
f[fp]];
667 if (level > maxLevel)
678 Foam::label Foam::hexRef8::countAnchors
681 const label anchorLevel
688 if (pointLevel_[
f[fp]] <= anchorLevel)
697 void Foam::hexRef8::dumpCell(
const label celli)
const 699 OFstream str(mesh_.time().path()/
"cell_" +
Foam::name(celli) +
".obj");
700 Pout<<
"hexRef8 : Dumping cell as obj to " << str.
name() <<
endl;
702 const cell& cFaces = mesh_.cells()[celli];
704 Map<label> pointToObjVert;
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;
738 Foam::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)
829 void Foam::hexRef8::checkInternalOrientation
831 polyTopoChange& meshMod,
839 face compactFace(
identity(newFace.size()));
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);
861 if (s < 0.1 || s > 0.9)
864 <<
"cell:" << celli <<
" old face:" << facei
865 <<
" newFace:" << newFace <<
endl 866 <<
" coords:" << compactPoints
867 <<
" ownPt:" << ownPt
868 <<
" neiPt:" << neiPt
875 void Foam::hexRef8::checkBoundaryOrientation
877 polyTopoChange& meshMod,
881 const point& boundaryPt,
885 face compactFace(
identity(newFace.size()));
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);
907 if (s < 0.7 || s > 1.3)
910 <<
"cell:" << celli <<
" old face:" << facei
911 <<
" newFace:" << newFace
912 <<
" coords:" << compactPoints
913 <<
" ownPt:" << ownPt
914 <<
" boundaryPt:" << boundaryPt
924 void Foam::hexRef8::insertEdgeSplit
929 DynamicList<label>& verts
932 if (
p0 < mesh_.nPoints() && p1 < mesh_.nPoints())
936 if (edgeI != -1 && edgeMidPoint[edgeI] != -1)
938 verts.append(edgeMidPoint[edgeI]);
952 Foam::label Foam::hexRef8::storeMidPointInfo
960 const bool faceOrder,
961 const label edgeMidPointi,
962 const label anchorPointi,
963 const label faceMidPointi,
965 Map<edge>& midPointToAnchors,
966 Map<edge>& midPointToFaceMids,
967 polyTopoChange& meshMod
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);
1042 DynamicList<label> newFaceVerts(4);
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]);
1096 newFace.transfer(newFaceVerts);
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
1182 void Foam::hexRef8::createInternalFaces
1192 polyTopoChange& meshMod
1198 const cell& cFaces = mesh_.cells()[celli];
1199 const label cLevel = cellLevel_[celli];
1202 Map<edge> midPointToAnchors(24);
1204 Map<edge> midPointToFaceMids(24);
1207 DynamicList<label> storage;
1211 label nFacesAdded = 0;
1215 label facei = cFaces[i];
1217 const face&
f = mesh_.faces()[facei];
1218 const labelList& fEdges = mesh_.faceEdges(facei, storage);
1223 label faceMidPointi = -1;
1225 label nAnchors = countAnchors(
f, cLevel);
1233 label anchorFp = -1;
1237 if (pointLevel_[
f[fp]] <= cLevel)
1245 label edgeMid = findLevel
1253 label faceMid = findLevel
1262 faceMidPointi =
f[faceMid];
1264 else if (nAnchors == 4)
1269 faceMidPointi = faceMidPoint[facei];
1273 dumpCell(mesh_.faceOwner()[facei]);
1274 if (mesh_.isInternalFace(facei))
1276 dumpCell(mesh_.faceNeighbour()[facei]);
1280 <<
"nAnchors:" << nAnchors
1281 <<
" facei:" << facei
1293 label point0 =
f[fp0];
1295 if (pointLevel_[point0] <= cLevel)
1304 label edgeMidPointi = -1;
1308 if (pointLevel_[
f[fp1]] <= cLevel)
1311 label edgeI = fEdges[fp0];
1313 edgeMidPointi = edgeMidPoint[edgeI];
1315 if (edgeMidPointi == -1)
1319 const labelList& cPoints = mesh_.cellPoints(celli);
1322 <<
"cell:" << celli <<
" cLevel:" << cLevel
1323 <<
" cell points:" << cPoints
1326 <<
" face:" << facei
1330 <<
" faceAnchorLevel:" << faceAnchorLevel[facei]
1331 <<
" faceMidPoint:" << faceMidPoint[facei]
1332 <<
" faceMidPointi:" << faceMidPointi
1340 label edgeMid = findLevel(facei,
f, fp1,
true, cLevel+1);
1342 edgeMidPointi =
f[edgeMid];
1345 label newFacei = storeMidPointInfo
1368 if (nFacesAdded == 12)
1381 if (pointLevel_[
f[fpMin1]] <= cLevel)
1384 label edgeI = fEdges[fpMin1];
1386 edgeMidPointi = edgeMidPoint[edgeI];
1388 if (edgeMidPointi == -1)
1392 const labelList& cPoints = mesh_.cellPoints(celli);
1395 <<
"cell:" << celli <<
" cLevel:" << cLevel
1396 <<
" cell points:" << cPoints
1399 <<
" face:" << facei
1403 <<
" faceAnchorLevel:" << faceAnchorLevel[facei]
1404 <<
" faceMidPoint:" << faceMidPoint[facei]
1405 <<
" faceMidPointi:" << faceMidPointi
1413 label edgeMid = findLevel
1422 edgeMidPointi =
f[edgeMid];
1425 newFacei = storeMidPointInfo
1448 if (nFacesAdded == 12)
1456 if (nFacesAdded == 12)
1464 void Foam::hexRef8::walkFaceToMid
1469 const label startFp,
1470 DynamicList<label>& faceVerts
1473 const face&
f = mesh_.faces()[facei];
1474 const labelList& fEdges = mesh_.faceEdges(facei);
1483 if (edgeMidPoint[fEdges[fp]] >= 0)
1485 faceVerts.
append(edgeMidPoint[fEdges[fp]]);
1490 if (pointLevel_[
f[fp]] <= cLevel)
1496 else if (pointLevel_[
f[fp]] == cLevel+1)
1499 faceVerts.append(
f[fp]);
1503 else if (pointLevel_[
f[fp]] == cLevel+2)
1506 faceVerts.append(
f[fp]);
1513 void Foam::hexRef8::walkFaceFromMid
1518 const label startFp,
1519 DynamicList<label>& faceVerts
1522 const face&
f = mesh_.faces()[facei];
1523 const labelList& fEdges = mesh_.faceEdges(facei);
1529 if (pointLevel_[
f[fp]] <= cLevel)
1534 else if (pointLevel_[
f[fp]] == cLevel+1)
1537 faceVerts.append(
f[fp]);
1540 else if (pointLevel_[
f[fp]] == cLevel+2)
1550 if (edgeMidPoint[fEdges[fp]] >= 0)
1552 faceVerts.append(edgeMidPoint[fEdges[fp]]);
1561 faceVerts.append(
f[fp]);
1568 Foam::label Foam::hexRef8::faceConsistentRefinement
1578 for (label facei = 0; facei < mesh_.nInternalFaces(); facei++)
1580 label own = mesh_.faceOwner()[facei];
1581 label ownLevel = cellLevel[own] + refineCell.get(own);
1583 label nei = mesh_.faceNeighbour()[facei];
1584 label neiLevel = cellLevel[nei] + refineCell.get(nei);
1586 if (ownLevel > (neiLevel+1))
1590 refineCell.set(nei);
1594 refineCell.unset(own);
1598 else if (neiLevel > (ownLevel+1))
1602 refineCell.set(own);
1606 refineCell.unset(nei);
1615 labelList neiLevel(mesh_.nBoundaryFaces());
1619 label own = mesh_.faceOwner()[i+mesh_.nInternalFaces()];
1621 neiLevel[i] = cellLevel[own] + refineCell.get(own);
1630 label own = mesh_.faceOwner()[i+mesh_.nInternalFaces()];
1631 label ownLevel = cellLevel[own] + refineCell.get(own);
1633 if (ownLevel > (neiLevel[i]+1))
1637 refineCell.unset(own);
1641 else if (neiLevel[i] > (ownLevel+1))
1645 refineCell.set(own);
1656 void Foam::hexRef8::checkWantedRefinementLevels
1662 bitSet refineCell(mesh_.nCells(), cellsToRefine);
1664 for (label facei = 0; facei < mesh_.nInternalFaces(); facei++)
1666 label own = mesh_.faceOwner()[facei];
1667 label ownLevel = cellLevel[own] + refineCell.get(own);
1669 label nei = mesh_.faceNeighbour()[facei];
1670 label neiLevel = cellLevel[nei] + refineCell.get(nei);
1672 if (
mag(ownLevel-neiLevel) > 1)
1678 <<
" current level:" << cellLevel[own]
1679 <<
" level after refinement:" << ownLevel
1681 <<
"neighbour cell:" << nei
1682 <<
" current level:" << cellLevel[nei]
1683 <<
" level after refinement:" << neiLevel
1685 <<
"which does not satisfy 2:1 constraints anymore." 1692 labelList neiLevel(mesh_.nBoundaryFaces());
1696 label own = mesh_.faceOwner()[i+mesh_.nInternalFaces()];
1698 neiLevel[i] = cellLevel[own] + refineCell.get(own);
1707 label facei = i + mesh_.nInternalFaces();
1709 label own = mesh_.faceOwner()[facei];
1710 label ownLevel = cellLevel[own] + refineCell.get(own);
1712 if (
mag(ownLevel - neiLevel[i]) > 1)
1714 label patchi = mesh_.boundaryMesh().whichPatch(facei);
1718 <<
"Celllevel does not satisfy 2:1 constraint." 1719 <<
" On coupled face " 1721 <<
" on patch " << patchi <<
" " 1722 << mesh_.boundaryMesh()[patchi].name()
1723 <<
" owner cell " << own
1724 <<
" current level:" << cellLevel[own]
1725 <<
" level after refinement:" << ownLevel
1727 <<
" (coupled) neighbour cell will get refinement " 1740 Pout<<
"hexRef8::setInstance(const fileName& inst) : " 1741 <<
"Resetting file instance to " << inst <<
endl;
1744 cellLevel_.instance() = inst;
1745 pointLevel_.instance() = inst;
1746 level0Edge_.instance() = inst;
1747 history_.instance() = inst;
1751 void Foam::hexRef8::collectLevelPoints
1755 DynamicList<label>&
points 1760 if (pointLevel_[
f[fp]] <= level)
1768 void Foam::hexRef8::collectLevelPoints
1773 DynamicList<label>&
points 1778 label pointi = meshPoints[
f[fp]];
1779 if (pointLevel_[pointi] <= level)
1788 bool Foam::hexRef8::matchHexShape
1791 const label cellLevel,
1792 DynamicList<face>& quads
1795 const cell& cFaces = mesh_.cells()[celli];
1798 DynamicList<label> verts(4);
1806 label facei = cFaces[i];
1807 const face&
f = mesh_.faces()[facei];
1810 collectLevelPoints(
f, cellLevel, verts);
1811 if (verts.size() == 4)
1813 if (mesh_.faceOwner()[facei] != celli)
1817 quads.emplace_back(verts);
1822 if (quads.size() < 6)
1824 Map<labelList> pointFaces(2*cFaces.size());
1828 label facei = cFaces[i];
1829 const face&
f = mesh_.faces()[facei];
1837 collectLevelPoints(
f, cellLevel, verts);
1838 if (verts.size() == 1)
1842 for (
const label pointi :
f)
1844 if (pointLevel_[pointi] == cellLevel+1)
1846 pointFaces(pointi).push_uniq(facei);
1863 label facei =
pFaces[pFacei];
1864 const face&
f = mesh_.faces()[facei];
1865 if (mesh_.faceOwner()[facei] == celli)
1867 fourFaces[pFacei] =
f;
1871 fourFaces[pFacei] =
f.reverseFace();
1877 SubList<face>(fourFaces),
1882 if (edgeLoops.size() == 1)
1888 bigFace.meshPoints(),
1889 bigFace.edgeLoops()[0],
1894 if (verts.size() == 4)
1896 quads.emplace_back(verts);
1903 return (quads.size() == 6);
1910 Foam::hexRef8::hexRef8(
const polyMesh&
mesh,
const bool readHistory)
1918 mesh_.facesInstance(),
1931 mesh_.facesInstance(),
1944 mesh_.facesInstance(),
1957 "refinementHistory",
1958 mesh_.facesInstance(),
1965 (readHistory ? mesh_.nCells() : 0)
1967 faceRemover_(mesh_, GREAT),
1968 savedPointLevel_(0),
1983 <<
"History enabled but number of visible cells " 1986 <<
" is not equal to the number of cells in the mesh " 1993 cellLevel_.
size() != mesh_.nCells()
1994 || pointLevel_.
size() != mesh_.nPoints()
1998 <<
"Restarted from inconsistent cellLevel or pointLevel files." 2002 <<
"Number of cells in mesh:" << mesh_.nCells()
2003 <<
" does not equal size of cellLevel:" << cellLevel_.
size() <<
endl 2004 <<
"Number of points in mesh:" << mesh_.nPoints()
2005 <<
" does not equal size of pointLevel:" << pointLevel_.
size()
2023 Foam::hexRef8::hexRef8
2025 const polyMesh&
mesh,
2028 const refinementHistory& history,
2029 const scalar level0Edge
2038 mesh_.facesInstance(),
2039 polyMesh::meshSubDir,
2051 mesh_.facesInstance(),
2052 polyMesh::meshSubDir,
2064 mesh_.facesInstance(),
2065 polyMesh::meshSubDir,
2075 (level0Edge >= 0 ? level0Edge : getLevel0EdgeLength())
2082 "refinementHistory",
2083 mesh_.facesInstance(),
2084 polyMesh::meshSubDir,
2091 faceRemover_(mesh_, GREAT),
2092 savedPointLevel_(0),
2098 <<
"History enabled but number of visible cells in it " 2100 <<
" is not equal to the number of cells in the mesh " 2106 cellLevel_.
size() != mesh_.nCells()
2107 || pointLevel_.
size() != mesh_.nPoints()
2111 <<
"Incorrect cellLevel or pointLevel size." <<
endl 2112 <<
"Number of cells in mesh:" << mesh_.nCells()
2113 <<
" does not equal size of cellLevel:" << cellLevel_.
size() <<
endl 2114 <<
"Number of points in mesh:" << mesh_.nPoints()
2115 <<
" does not equal size of pointLevel:" << pointLevel_.
size()
2132 Foam::hexRef8::hexRef8
2134 const polyMesh&
mesh,
2137 const scalar level0Edge
2146 mesh_.facesInstance(),
2147 polyMesh::meshSubDir,
2159 mesh_.facesInstance(),
2160 polyMesh::meshSubDir,
2172 mesh_.facesInstance(),
2173 polyMesh::meshSubDir,
2183 (level0Edge >= 0 ? level0Edge : getLevel0EdgeLength())
2190 "refinementHistory",
2191 mesh_.facesInstance(),
2192 polyMesh::meshSubDir,
2197 List<refinementHistory::splitCell8>(0),
2201 faceRemover_(mesh_, GREAT),
2202 savedPointLevel_(0),
2207 cellLevel_.
size() != mesh_.nCells()
2208 || pointLevel_.
size() != mesh_.nPoints()
2212 <<
"Incorrect cellLevel or pointLevel size." <<
endl 2213 <<
"Number of cells in mesh:" << mesh_.nCells()
2214 <<
" does not equal size of cellLevel:" << cellLevel_.
size() <<
endl 2215 <<
"Number of points in mesh:" << mesh_.nPoints()
2216 <<
" does not equal size of pointLevel:" << pointLevel_.
size()
2250 label nChanged = faceConsistentRefinement
2261 Pout<<
"hexRef8::consistentRefinement : Changed " << nChanged
2262 <<
" refinement levels due to 2:1 conflicts." 2277 checkWantedRefinementLevels(cellLevel, newCellsToRefine);
2280 return newCellsToRefine;
2292 const label maxFaceDiff,
2295 const label maxPointDiff,
2299 const labelList& faceOwner = mesh_.faceOwner();
2300 const labelList& faceNeighbour = mesh_.faceNeighbour();
2303 if (maxFaceDiff <= 0)
2306 <<
"Illegal maxFaceDiff " << maxFaceDiff <<
nl 2331 maxFaceDiff*(cellLevel_[celli]+1),
2332 maxFaceDiff*cellLevel_[celli]
2339 label celli = cellsToRefine[i];
2351 int dummyTrackData = 0;
2359 label facei = facesToCheck[i];
2365 <<
"Argument facesToCheck seems to have duplicate entries!" 2367 <<
"face:" << facei <<
" occurs at positions " 2375 label maxDataCount = ownData.
count();
2377 if (mesh_.isInternalFace(facei))
2384 if (maxDataCount < neiData.
count())
2386 maxDataCount = neiData.
count();
2390 label faceCount = maxDataCount + maxFaceDiff;
2391 label faceRefineCount = faceCount + maxFaceDiff;
2393 seedFaces.push_back(facei);
2395 seedFacesInfo.emplace_back(faceRefineCount, faceCount);
2402 forAll(faceNeighbour, facei)
2407 label own = faceOwner[facei];
2408 label nei = faceNeighbour[facei];
2423 seedFaces.append(facei);
2437 seedFaces.append(facei);
2449 for (label facei = mesh_.nInternalFaces(); facei < mesh_.nFaces(); facei++)
2454 const label own = faceOwner[facei];
2455 const auto& nbrInfo = nbrCellInfo[facei-mesh_.nInternalFaces()];
2468 seedFaces.append(facei);
2482 seedFaces.append(facei);
2502 Pout<<
"hexRef8::consistentSlowRefinement : Seeded " 2503 << seedFaces.size() <<
" faces between cells with different" 2504 <<
" refinement level." <<
endl;
2508 levelCalc.
setFaceInfo(seedFaces.shrink(), seedFacesInfo.shrink());
2510 seedFacesInfo.clear();
2513 levelCalc.
iterate(mesh_.globalData().nTotalFaces()+1);
2521 if (maxPointDiff == -1)
2531 forAll(maxPointCount, pointi)
2533 label& pLevel = maxPointCount[pointi];
2535 const labelList& pCells = mesh_.pointCells(pointi);
2560 label pointi = pointsToCheck[i];
2565 const labelList& pCells = mesh_.pointCells(pointi);
2569 label celli = pCells[pCelli];
2577 maxPointCount[pointi]
2578 >
cellInfo.count() + maxFaceDiff*maxPointDiff
2586 const cell& cFaces = mesh_.cells()[celli];
2590 label facei = cFaces[cFacei];
2605 changedFacesInfo.insert(facei, faceData);
2612 label nChanged = changedFacesInfo.size();
2622 seedFaces.setCapacity(changedFacesInfo.size());
2623 seedFacesInfo.setCapacity(changedFacesInfo.size());
2627 seedFaces.append(iter.key());
2628 seedFacesInfo.append(iter.val());
2635 for (label facei = 0; facei < mesh_.nInternalFaces(); facei++)
2637 label own = mesh_.faceOwner()[facei];
2642 label nei = mesh_.faceNeighbour()[facei];
2647 if (
mag(ownLevel-neiLevel) > 1)
2653 <<
" current level:" << cellLevel_[own]
2655 <<
" level after refinement:" << ownLevel
2657 <<
"neighbour cell:" << nei
2658 <<
" current level:" << cellLevel_[nei]
2660 <<
" level after refinement:" << neiLevel
2662 <<
"which does not satisfy 2:1 constraints anymore." <<
nl 2663 <<
"face:" << facei <<
" faceRefData:" <<
allFaceInfo[facei]
2672 labelList neiLevel(mesh_.nBoundaryFaces());
2673 labelList neiCount(mesh_.nBoundaryFaces());
2674 labelList neiRefCount(mesh_.nBoundaryFaces());
2678 label own = mesh_.faceOwner()[i+mesh_.nInternalFaces()];
2679 neiLevel[i] = cellLevel_[own];
2681 neiRefCount[i] =
allCellInfo[own].refinementCount();
2692 label facei = i+mesh_.nInternalFaces();
2694 label own = mesh_.faceOwner()[facei];
2701 + ((neiCount[i] >= neiRefCount[i]) ? 1 : 0);
2703 if (
mag(ownLevel - nbrLevel) > 1)
2706 label patchi = mesh_.boundaryMesh().whichPatch(facei);
2709 <<
"Celllevel does not satisfy 2:1 constraint." 2710 <<
" On coupled face " 2713 <<
" on patch " << patchi <<
" " 2714 << mesh_.boundaryMesh()[patchi].name() <<
nl 2715 <<
"owner cell " << own
2716 <<
" current level:" << cellLevel_[own]
2718 <<
" current refCount:" 2720 <<
" level after refinement:" << ownLevel
2722 <<
"(coupled) neighbour cell" 2723 <<
" has current level:" << neiLevel[i]
2724 <<
" current count:" << neiCount[i]
2725 <<
" current refCount:" << neiRefCount[i]
2726 <<
" level after refinement:" << nbrLevel
2752 newCellsToRefine[nRefined++] = celli;
2758 Pout<<
"hexRef8::consistentSlowRefinement : From " 2759 << cellsToRefine.
size() <<
" to " << newCellsToRefine.
size()
2760 <<
" cells to refine." <<
endl;
2763 return newCellsToRefine;
2769 const label maxFaceDiff,
2774 const labelList& faceOwner = mesh_.faceOwner();
2775 const labelList& faceNeighbour = mesh_.faceNeighbour();
2777 if (maxFaceDiff <= 0)
2780 <<
"Illegal maxFaceDiff " << maxFaceDiff <<
nl 2784 const scalar level0Size = 2*maxFaceDiff*level0EdgeLength();
2793 List<refinementDistanceData>
allCellInfo(mesh_.nCells());
2796 List<refinementDistanceData>
allFaceInfo(mesh_.nFaces());
2799 int dummyTrackData = 0;
2805 label celli = cellsToRefine[i];
2810 mesh_.cellCentres()[celli],
2822 mesh_.cellCentres()[celli],
2868 DynamicList<label> seedFaces(mesh_.nFaces()/100);
2870 DynamicList<refinementDistanceData> seedFacesInfo(mesh_.nFaces()/100);
2873 const polyBoundaryMesh&
patches = mesh_.boundaryMesh();
2880 bitSet isBoundary(mesh_.nFaces());
2886 const auto& faceCells =
pp.faceCells();
2889 const label own = faceCells[i];
2890 nbrCc[
pp.offset()+i] = cc[own];
2892 const label ownLevel =
2898 nbrLevel[
pp.offset()+i] = ownLevel;
2903 isBoundary.set(
pp.range());
2911 for (
const label facei : facesToCheck)
2917 <<
"Argument facesToCheck seems to have duplicate entries!" 2919 <<
"face:" << facei <<
" occurs at positions " 2924 const label own = faceOwner[facei];
2925 const label ownLevel =
2931 const point& ownCc = cc[own];
2933 if (isBoundary(facei))
2937 const point& fc = mesh_.faceCentres()[facei];
2939 refinementDistanceData neiData
2960 if (mesh_.isInternalFace(facei))
2962 const label nei = faceNeighbour[facei];
2973 neiLevel = nbrLevel[facei-mesh_.nInternalFaces()];
2974 neiCc = nbrCc[facei-mesh_.nInternalFaces()];
2977 if (ownLevel == neiLevel)
2985 refinementDistanceData(level0Size, neiCc, neiLevel+1),
2994 refinementDistanceData(level0Size, ownCc, ownLevel+1),
3007 refinementDistanceData(level0Size, neiCc, neiLevel),
3016 refinementDistanceData(level0Size, ownCc, ownLevel),
3022 seedFaces.append(facei);
3037 if (!
allFaceInfo[facei].valid(dummyTrackData) && !isBoundary(facei))
3039 const label own = faceOwner[facei];
3040 const label ownLevel =
3046 const point& ownCc = cc[own];
3050 if (mesh_.isInternalFace(facei))
3052 const label nei = faceNeighbour[facei];
3063 neiLevel = nbrLevel[facei-mesh_.nInternalFaces()];
3064 neiCc = nbrCc[facei-mesh_.nInternalFaces()];
3067 if (ownLevel > neiLevel)
3076 refinementDistanceData(level0Size, ownCc, ownLevel),
3082 else if (neiLevel > ownLevel)
3084 seedFaces.append(facei);
3090 refinementDistanceData(level0Size, neiCc, neiLevel),
3100 seedFacesInfo.shrink();
3103 FaceCellWave<refinementDistanceData, int> levelCalc
3110 mesh_.globalData().nTotalCells()+1,
3191 label celli = cellsToRefine[i];
3193 allCellInfo[celli].originLevel() =
sizeof(label)*8-2;
3200 bitSet refineCell(mesh_.nCells());
3203 label wanted =
allCellInfo[celli].wantedLevel(cc[celli]);
3205 if (wanted > cellLevel_[celli]+1)
3207 refineCell.set(celli);
3210 faceConsistentRefinement(
true, cellLevel_, refineCell);
3214 label nChanged = faceConsistentRefinement(
true, cellLevel_, refineCell);
3216 reduce(nChanged, sumOp<label>());
3220 Pout<<
"hexRef8::consistentSlowRefinement2 : Changed " << nChanged
3221 <<
" refinement levels due to 2:1 conflicts." 3232 labelList newCellsToRefine(refineCell.toc());
3236 Pout<<
"hexRef8::consistentSlowRefinement2 : From " 3237 << cellsToRefine.
size() <<
" to " << newCellsToRefine.size()
3238 <<
" cells to refine." <<
endl;
3243 cellSet cellsIn(mesh_,
"cellsToRefineIn", cellsToRefine);
3244 Pout<<
"hexRef8::consistentSlowRefinement2 : writing " 3245 << cellsIn.size() <<
" to cellSet " 3246 << cellsIn.objectPath() <<
endl;
3250 cellSet cellsOut(mesh_,
"cellsToRefineOut", newCellsToRefine);
3251 Pout<<
"hexRef8::consistentSlowRefinement2 : writing " 3252 << cellsOut.size() <<
" to cellSet " 3253 << cellsOut.objectPath() <<
endl;
3258 bitSet refineCell(mesh_.nCells(), newCellsToRefine);
3260 const bitSet savedRefineCell(refineCell);
3261 label nChanged = faceConsistentRefinement(
true, cellLevel_, refineCell);
3266 mesh_,
"cellsToRefineOut2", newCellsToRefine.size()
3268 forAll(refineCell, celli)
3270 if (refineCell.test(celli))
3272 cellsOut2.insert(celli);
3275 Pout<<
"hexRef8::consistentSlowRefinement2 : writing " 3276 << cellsOut2.size() <<
" to cellSet " 3277 << cellsOut2.objectPath() <<
endl;
3283 forAll(refineCell, celli)
3285 if (refineCell.test(celli) && !savedRefineCell.test(celli))
3289 <<
"Cell:" << celli <<
" cc:" 3290 << mesh_.cellCentres()[celli]
3291 <<
" was not marked for refinement but does not obey" 3292 <<
" 2:1 constraints." 3299 return newCellsToRefine;
3312 Pout<<
"hexRef8::setRefinement :" 3313 <<
" Checking initial mesh just to make sure" <<
endl;
3322 savedPointLevel_.clear();
3323 savedCellLevel_.clear();
3328 forAll(cellLevel_, celli)
3330 newCellLevel.append(cellLevel_[celli]);
3333 forAll(pointLevel_, pointi)
3335 newPointLevel.append(pointLevel_[pointi]);
3341 Pout<<
"hexRef8::setRefinement :" 3342 <<
" Allocating " << cellLabels.
size() <<
" cell midpoints." 3350 labelList cellMidPoint(mesh_.nCells(), -1);
3354 label celli = cellLabels[i];
3356 label anchorPointi = mesh_.faces()[mesh_.cells()[celli][0]][0];
3362 mesh_.cellCentres()[celli],
3369 newPointLevel(cellMidPoint[celli]) = cellLevel_[celli]+1;
3375 cellSet splitCells(mesh_,
"splitCells", cellLabels.
size());
3377 forAll(cellMidPoint, celli)
3379 if (cellMidPoint[celli] >= 0)
3381 splitCells.insert(celli);
3385 Pout<<
"hexRef8::setRefinement : Dumping " << splitCells.size()
3386 <<
" cells to split to cellSet " << splitCells.objectPath()
3399 Pout<<
"hexRef8::setRefinement :" 3400 <<
" Allocating edge midpoints." 3409 labelList edgeMidPoint(mesh_.nEdges(), -1);
3412 forAll(cellMidPoint, celli)
3414 if (cellMidPoint[celli] >= 0)
3416 const labelList& cEdges = mesh_.cellEdges(celli);
3420 label edgeI = cEdges[i];
3422 const edge&
e = mesh_.edges()[edgeI];
3426 pointLevel_[
e[0]] <= cellLevel_[celli]
3427 && pointLevel_[
e[1]] <= cellLevel_[celli]
3430 edgeMidPoint[edgeI] = 12345;
3457 forAll(edgeMidPoint, edgeI)
3459 if (edgeMidPoint[edgeI] >= 0)
3462 edgeMids[edgeI] = mesh_.edges()[edgeI].centre(mesh_.points());
3470 point(-GREAT, -GREAT, -GREAT)
3475 forAll(edgeMidPoint, edgeI)
3477 if (edgeMidPoint[edgeI] >= 0)
3482 const edge&
e = mesh_.edges()[edgeI];
3495 newPointLevel(edgeMidPoint[edgeI]) =
3508 OFstream str(mesh_.time().path()/
"edgeMidPoint.obj");
3510 forAll(edgeMidPoint, edgeI)
3512 if (edgeMidPoint[edgeI] >= 0)
3514 const edge&
e = mesh_.edges()[edgeI];
3520 Pout<<
"hexRef8::setRefinement :" 3521 <<
" Dumping edge centres to split to file " << str.
name() <<
endl;
3531 Pout<<
"hexRef8::setRefinement :" 3532 <<
" Allocating face midpoints." 3538 labelList faceAnchorLevel(mesh_.nFaces());
3540 for (label facei = 0; facei < mesh_.nFaces(); facei++)
3542 faceAnchorLevel[facei] = faceLevel(facei);
3547 labelList faceMidPoint(mesh_.nFaces(), -1);
3552 for (label facei = 0; facei < mesh_.nInternalFaces(); facei++)
3554 if (faceAnchorLevel[facei] >= 0)
3556 label own = mesh_.faceOwner()[facei];
3557 label ownLevel = cellLevel_[own];
3558 label newOwnLevel = ownLevel + (cellMidPoint[own] >= 0 ? 1 : 0);
3560 label nei = mesh_.faceNeighbour()[facei];
3561 label neiLevel = cellLevel_[nei];
3562 label newNeiLevel = neiLevel + (cellMidPoint[nei] >= 0 ? 1 : 0);
3566 newOwnLevel > faceAnchorLevel[facei]
3567 || newNeiLevel > faceAnchorLevel[facei]
3570 faceMidPoint[facei] = 12345;
3583 labelList newNeiLevel(mesh_.nBoundaryFaces());
3587 label own = mesh_.faceOwner()[i+mesh_.nInternalFaces()];
3588 label ownLevel = cellLevel_[own];
3589 label newOwnLevel = ownLevel + (cellMidPoint[own] >= 0 ? 1 : 0);
3591 newNeiLevel[i] = newOwnLevel;
3601 label facei = i+mesh_.nInternalFaces();
3603 if (faceAnchorLevel[facei] >= 0)
3605 label own = mesh_.faceOwner()[facei];
3606 label ownLevel = cellLevel_[own];
3607 label newOwnLevel = ownLevel + (cellMidPoint[own] >= 0 ? 1 : 0);
3611 newOwnLevel > faceAnchorLevel[facei]
3612 || newNeiLevel[i] > faceAnchorLevel[facei]
3615 faceMidPoint[facei] = 12345;
3640 mesh_.nBoundaryFaces(),
3641 point(-GREAT, -GREAT, -GREAT)
3646 label facei = i+mesh_.nInternalFaces();
3648 if (faceMidPoint[facei] >= 0)
3650 bFaceMids[i] = mesh_.faceCentres()[facei];
3660 forAll(faceMidPoint, facei)
3662 if (faceMidPoint[facei] >= 0)
3667 const face&
f = mesh_.faces()[facei];
3674 facei < mesh_.nInternalFaces()
3675 ? mesh_.faceCentres()[facei]
3676 : bFaceMids[facei-mesh_.nInternalFaces()]
3686 newPointLevel(faceMidPoint[facei]) = faceAnchorLevel[facei]+1;
3693 faceSet splitFaces(mesh_,
"splitFaces", cellLabels.
size());
3695 forAll(faceMidPoint, facei)
3697 if (faceMidPoint[facei] >= 0)
3699 splitFaces.insert(facei);
3703 Pout<<
"hexRef8::setRefinement : Dumping " << splitFaces.size()
3704 <<
" faces to split to faceSet " << splitFaces.objectPath() <<
endl;
3725 Pout<<
"hexRef8::setRefinement :" 3726 <<
" Finding cell anchorPoints (8 per cell)" 3739 forAll(cellMidPoint, celli)
3741 if (cellMidPoint[celli] >= 0)
3743 cellAnchorPoints[celli].setSize(8);
3747 forAll(pointLevel_, pointi)
3749 const labelList& pCells = mesh_.pointCells(pointi);
3753 label celli = pCells[pCelli];
3757 cellMidPoint[celli] >= 0
3758 && pointLevel_[pointi] <= cellLevel_[celli]
3761 if (nAnchorPoints[celli] == 8)
3766 <<
" of level " << cellLevel_[celli]
3767 <<
" uses more than 8 points of equal or" 3768 <<
" lower level" <<
nl 3769 <<
"Points so far:" << cellAnchorPoints[celli]
3773 cellAnchorPoints[celli][nAnchorPoints[celli]++] = pointi;
3778 forAll(cellMidPoint, celli)
3780 if (cellMidPoint[celli] >= 0)
3782 if (nAnchorPoints[celli] != 8)
3786 const labelList& cPoints = mesh_.cellPoints(celli);
3790 <<
" of level " << cellLevel_[celli]
3791 <<
" does not seem to have 8 points of equal or" 3792 <<
" lower level" <<
endl 3793 <<
"cellPoints:" << cPoints <<
endl 3808 Pout<<
"hexRef8::setRefinement :" 3809 <<
" Adding cells (1 per anchorPoint)" 3816 forAll(cellAnchorPoints, celli)
3818 const labelList& cAnchors = cellAnchorPoints[celli];
3820 if (cAnchors.
size() == 8)
3822 labelList& cAdded = cellAddedCells[celli];
3829 newCellLevel[celli] = cellLevel_[celli]+1;
3832 for (label i = 1; i < 8; i++)
3842 mesh_.cellZones().whichZone(celli)
3846 newCellLevel(cAdded[i]) = cellLevel_[celli]+1;
3861 Pout<<
"hexRef8::setRefinement :" 3862 <<
" Marking faces to be handled" 3867 bitSet affectedFace(mesh_.nFaces());
3870 forAll(cellMidPoint, celli)
3872 if (cellMidPoint[celli] >= 0)
3874 const cell& cFaces = mesh_.cells()[celli];
3876 affectedFace.
set(cFaces);
3880 forAll(faceMidPoint, facei)
3882 if (faceMidPoint[facei] >= 0)
3884 affectedFace.set(facei);
3888 forAll(edgeMidPoint, edgeI)
3890 if (edgeMidPoint[edgeI] >= 0)
3892 const labelList& eFaces = mesh_.edgeFaces(edgeI);
3894 affectedFace.
set(eFaces);
3905 Pout<<
"hexRef8::setRefinement : Splitting faces" <<
endl;
3908 forAll(faceMidPoint, facei)
3910 if (faceMidPoint[facei] >= 0 && affectedFace.test(facei))
3916 const face&
f = mesh_.faces()[facei];
3920 bool modifiedFace =
false;
3922 label anchorLevel = faceAnchorLevel[facei];
3928 label pointi =
f[fp];
3930 if (pointLevel_[pointi] <= anchorLevel)
3936 faceVerts.
append(pointi);
3952 faceVerts.
append(faceMidPoint[facei]);
3985 if (mesh_.isInternalFace(facei))
3987 label oldOwn = mesh_.faceOwner()[facei];
3988 label oldNei = mesh_.faceNeighbour()[facei];
3990 checkInternalOrientation
3995 mesh_.cellCentres()[oldOwn],
3996 mesh_.cellCentres()[oldNei],
4002 label oldOwn = mesh_.faceOwner()[facei];
4004 checkBoundaryOrientation
4009 mesh_.cellCentres()[oldOwn],
4010 mesh_.faceCentres()[facei],
4019 modifiedFace =
true;
4021 modFace(meshMod, facei, newFace, own, nei);
4025 addFace(meshMod, facei, newFace, own, nei);
4031 affectedFace.unset(facei);
4041 Pout<<
"hexRef8::setRefinement :" 4042 <<
" Adding edge splits to unsplit faces" 4049 forAll(edgeMidPoint, edgeI)
4051 if (edgeMidPoint[edgeI] >= 0)
4055 const labelList& eFaces = mesh_.edgeFaces(edgeI, eFacesStorage);
4059 label facei = eFaces[i];
4061 if (faceMidPoint[facei] < 0 && affectedFace.test(facei))
4065 const face&
f = mesh_.faces()[facei];
4066 const labelList& fEdges = mesh_.faceEdges
4076 newFaceVerts.append(
f[fp]);
4078 label edgeI = fEdges[fp];
4080 if (edgeMidPoint[edgeI] >= 0)
4082 newFaceVerts.
append(edgeMidPoint[edgeI]);
4091 label anchorFp = findMinLevel(
f);
4108 if (mesh_.isInternalFace(facei))
4110 label oldOwn = mesh_.faceOwner()[facei];
4111 label oldNei = mesh_.faceNeighbour()[facei];
4113 checkInternalOrientation
4118 mesh_.cellCentres()[oldOwn],
4119 mesh_.cellCentres()[oldNei],
4125 label oldOwn = mesh_.faceOwner()[facei];
4127 checkBoundaryOrientation
4132 mesh_.cellCentres()[oldOwn],
4133 mesh_.faceCentres()[facei],
4139 modFace(meshMod, facei, newFace, own, nei);
4142 affectedFace.unset(facei);
4154 Pout<<
"hexRef8::setRefinement :" 4155 <<
" Changing owner/neighbour for otherwise unaffected faces" 4159 forAll(affectedFace, facei)
4161 if (affectedFace.test(facei))
4163 const face&
f = mesh_.faces()[facei];
4167 label anchorFp = findMinLevel(
f);
4181 modFace(meshMod, facei,
f, own, nei);
4184 affectedFace.unset(facei);
4199 Pout<<
"hexRef8::setRefinement :" 4200 <<
" Create new internal faces for split cells" 4204 forAll(cellMidPoint, celli)
4206 if (cellMidPoint[celli] >= 0)
4231 forAll(cellMidPoint, celli)
4233 if (cellMidPoint[celli] >= 0)
4235 minPointi =
min(minPointi, cellMidPoint[celli]);
4236 maxPointi =
max(maxPointi, cellMidPoint[celli]);
4239 forAll(faceMidPoint, facei)
4241 if (faceMidPoint[facei] >= 0)
4243 minPointi =
min(minPointi, faceMidPoint[facei]);
4244 maxPointi =
max(maxPointi, faceMidPoint[facei]);
4247 forAll(edgeMidPoint, edgeI)
4249 if (edgeMidPoint[edgeI] >= 0)
4251 minPointi =
min(minPointi, edgeMidPoint[edgeI]);
4252 maxPointi =
max(maxPointi, edgeMidPoint[edgeI]);
4256 if (minPointi !=
labelMax && minPointi != mesh_.nPoints())
4259 <<
"Added point labels not consecutive to existing mesh points." 4261 <<
"mesh_.nPoints():" << mesh_.nPoints()
4262 <<
" minPointi:" << minPointi
4263 <<
" maxPointi:" << maxPointi
4268 pointLevel_.transfer(newPointLevel);
4269 cellLevel_.transfer(newCellLevel);
4272 setInstance(mesh_.facesInstance());
4279 if (history_.active())
4283 Pout<<
"hexRef8::setRefinement :" 4284 <<
" Updating refinement history to " << cellLevel_.size()
4285 <<
" cells" <<
endl;
4289 history_.resize(cellLevel_.size());
4291 forAll(cellAddedCells, celli)
4293 const labelList& addedCells = cellAddedCells[celli];
4295 if (addedCells.
size())
4298 history_.storeSplit(celli, addedCells);
4309 label celli = cellLabels[i];
4311 refinedCells[i].
transfer(cellAddedCells[celli]);
4314 return refinedCells;
4325 savedPointLevel_.clear();
4326 savedPointLevel_.reserve(pointsToStore.
size());
4329 label pointi = pointsToStore[i];
4330 savedPointLevel_.insert(pointi, pointLevel_[pointi]);
4333 savedCellLevel_.
clear();
4334 savedCellLevel_.reserve(cellsToStore.
size());
4337 label celli = cellsToStore[i];
4338 savedCellLevel_.insert(celli, cellLevel_[celli]);
4350 updateMesh(map, dummyMap, dummyMap, dummyMap);
4368 Pout<<
"hexRef8::updateMesh :" 4369 <<
" Updating various lists" 4378 Pout<<
"hexRef8::updateMesh :" 4381 <<
" nCells:" << mesh_.nCells()
4383 <<
" cellLevel_:" << cellLevel_.size()
4386 <<
" nPoints:" << mesh_.nPoints()
4388 <<
" pointLevel_:" << pointLevel_.size()
4392 if (reverseCellMap.
size() == cellLevel_.size())
4398 reorder(reverseCellMap, mesh_.nCells(), -1, cellLevel_);
4406 forAll(cellMap, newCelli)
4408 label oldCelli = cellMap[newCelli];
4412 newCellLevel[newCelli] = -1;
4416 newCellLevel[newCelli] = cellLevel_[oldCelli];
4426 const label newCelli = iter.key();
4427 const label storedCelli = iter.val();
4429 const auto fnd = savedCellLevel_.cfind(storedCelli);
4434 <<
"Problem : trying to restore old value for new cell " 4435 << newCelli <<
" but cannot find old cell " << storedCelli
4436 <<
" in map of stored values " << savedCellLevel_
4439 cellLevel_[newCelli] = fnd.val();
4460 if (reversePointMap.
size() == pointLevel_.size())
4463 reorder(reversePointMap, mesh_.nPoints(), -1, pointLevel_);
4474 const label oldPointi = pointMap[
newPointi];
4476 if (oldPointi == -1)
4489 newPointLevel[
newPointi] = pointLevel_[oldPointi];
4492 pointLevel_.
transfer(newPointLevel);
4500 const label storedPointi = iter.val();
4502 auto fnd = savedPointLevel_.find(storedPointi);
4507 <<
"Problem : trying to restore old value for new point " 4508 <<
newPointi <<
" but cannot find old point " 4510 <<
" in map of stored values " << savedPointLevel_
4530 if (history_.active())
4532 history_.updateMesh(map);
4536 setInstance(mesh_.facesInstance());
4539 faceRemover_.updateMesh(map);
4542 cellShapesPtr_.clear();
4557 Pout<<
"hexRef8::subset :" 4558 <<
" Updating various lists" 4562 if (history_.active())
4565 <<
"Subsetting will not work in combination with unrefinement." 4567 <<
"Proceed at your own risk." <<
endl;
4575 forAll(cellMap, newCelli)
4577 newCellLevel[newCelli] = cellLevel_[cellMap[newCelli]];
4580 cellLevel_.transfer(newCellLevel);
4582 if (cellLevel_.found(-1))
4586 <<
"cellLevel_ contains illegal value -1 after mapping:" 4601 pointLevel_.transfer(newPointLevel);
4603 if (pointLevel_.found(-1))
4607 <<
"pointLevel_ contains illegal value -1 after mapping:" 4614 if (history_.active())
4616 history_.subset(pointMap,
faceMap, cellMap);
4620 setInstance(mesh_.facesInstance());
4626 cellShapesPtr_.clear();
4635 Pout<<
"hexRef8::distribute :" 4636 <<
" Updating various lists" 4646 if (history_.active())
4648 history_.distribute(map);
4652 faceRemover_.distribute(map);
4655 cellShapesPtr_.clear();
4661 const scalar smallDim = 1
e-6 * mesh_.bounds().mag();
4665 Pout<<
"hexRef8::checkMesh : Using matching tolerance smallDim:" 4666 << smallDim <<
endl;
4679 nei[i] = mesh_.faceOwner()[i+mesh_.nInternalFaces()];
4697 label facei =
pp.start();
4701 label own = mesh_.faceOwner()[facei];
4702 label bFacei = facei-mesh_.nInternalFaces();
4708 <<
"Faces do not seem to be correct across coupled" 4709 <<
" boundaries" <<
endl 4710 <<
"Coupled face " << facei
4711 <<
" between owner " << own
4712 <<
" on patch " <<
pp.name()
4713 <<
" and coupled neighbour " << nei[bFacei]
4714 <<
" has two faces connected to it:" 4733 neiFaceAreas[i] =
mag(mesh_.faceAreas()[i+mesh_.nInternalFaces()]);
4741 label facei = i+mesh_.nInternalFaces();
4743 const scalar magArea =
mag(mesh_.faceAreas()[facei]);
4745 if (
mag(magArea - neiFaceAreas[i]) > smallDim)
4747 const face&
f = mesh_.faces()[facei];
4748 label patchi = mesh_.boundaryMesh().whichPatch(facei);
4750 dumpCell(mesh_.faceOwner()[facei]);
4753 <<
"Faces do not seem to be correct across coupled" 4754 <<
" boundaries" <<
endl 4755 <<
"Coupled face " << facei
4756 <<
" on patch " << patchi
4757 <<
" " << mesh_.boundaryMesh()[patchi].
name()
4759 <<
" has face area:" << magArea
4760 <<
" (coupled) neighbour face area differs:" 4762 <<
" to within tolerance " << smallDim
4772 labelList nVerts(mesh_.nBoundaryFaces());
4776 nVerts[i] = mesh_.faces()[i+mesh_.nInternalFaces()].size();
4784 label facei = i+mesh_.nInternalFaces();
4786 const face&
f = mesh_.faces()[facei];
4788 if (
f.
size() != nVerts[i])
4790 dumpCell(mesh_.faceOwner()[facei]);
4792 label patchi = mesh_.boundaryMesh().whichPatch(facei);
4795 <<
"Faces do not seem to be correct across coupled" 4796 <<
" boundaries" <<
endl 4797 <<
"Coupled face " << facei
4798 <<
" on patch " << patchi
4799 <<
" " << mesh_.boundaryMesh()[patchi].
name()
4801 <<
" has size:" <<
f.
size()
4802 <<
" (coupled) neighbour face has size:" 4814 pointField anchorPoints(mesh_.nBoundaryFaces());
4818 label facei = i+mesh_.nInternalFaces();
4819 const point& fc = mesh_.faceCentres()[facei];
4820 const face&
f = mesh_.faces()[facei];
4821 const vector anchorVec(mesh_.points()[
f[0]] - fc);
4823 anchorPoints[i] = anchorVec;
4833 label facei = i+mesh_.nInternalFaces();
4834 const point& fc = mesh_.faceCentres()[facei];
4835 const face&
f = mesh_.faces()[facei];
4836 const vector anchorVec(mesh_.points()[
f[0]] - fc);
4838 if (
mag(anchorVec - anchorPoints[i]) > smallDim)
4840 dumpCell(mesh_.faceOwner()[facei]);
4842 label patchi = mesh_.boundaryMesh().whichPatch(facei);
4845 <<
"Faces do not seem to be correct across coupled" 4846 <<
" boundaries" <<
endl 4847 <<
"Coupled face " << facei
4848 <<
" on patch " << patchi
4849 <<
" " << mesh_.boundaryMesh()[patchi].
name()
4851 <<
" has anchor vector:" << anchorVec
4852 <<
" (coupled) neighbour face anchor vector differs:" 4854 <<
" to within tolerance " << smallDim
4862 Pout<<
"hexRef8::checkMesh : Returning" <<
endl;
4869 const label maxPointDiff,
4875 Pout<<
"hexRef8::checkRefinementLevels :" 4876 <<
" Checking 2:1 refinement level" <<
endl;
4881 cellLevel_.size() != mesh_.nCells()
4882 || pointLevel_.size() != mesh_.nPoints()
4886 <<
"cellLevel size should be number of cells" 4887 <<
" and pointLevel size should be number of points."<<
nl 4888 <<
"cellLevel:" << cellLevel_.size()
4889 <<
" mesh.nCells():" << mesh_.nCells() <<
nl 4890 <<
"pointLevel:" << pointLevel_.size()
4891 <<
" mesh.nPoints():" << mesh_.nPoints()
4901 for (label facei = 0; facei < mesh_.nInternalFaces(); facei++)
4903 label own = mesh_.faceOwner()[facei];
4904 label nei = mesh_.faceNeighbour()[facei];
4906 if (
mag(cellLevel_[own] - cellLevel_[nei]) > 1)
4912 <<
"Celllevel does not satisfy 2:1 constraint." <<
nl 4913 <<
"On face " << facei <<
" owner cell " << own
4914 <<
" has refinement " << cellLevel_[own]
4915 <<
" neighbour cell " << nei <<
" has refinement " 4922 labelList neiLevel(mesh_.nBoundaryFaces());
4926 label own = mesh_.faceOwner()[i+mesh_.nInternalFaces()];
4928 neiLevel[i] = cellLevel_[own];
4936 label facei = i+mesh_.nInternalFaces();
4938 label own = mesh_.faceOwner()[facei];
4940 if (
mag(cellLevel_[own] - neiLevel[i]) > 1)
4944 label patchi = mesh_.boundaryMesh().whichPatch(facei);
4947 <<
"Celllevel does not satisfy 2:1 constraint." 4948 <<
" On coupled face " << facei
4949 <<
" on patch " << patchi <<
" " 4950 << mesh_.boundaryMesh()[patchi].name()
4951 <<
" owner cell " << own <<
" has refinement " 4953 <<
" (coupled) neighbour cell has refinement " 4976 forAll(syncPointLevel, pointi)
4978 if (pointLevel_[pointi] != syncPointLevel[pointi])
4981 <<
"PointLevel is not consistent across coupled patches." 4983 <<
"point:" << pointi <<
" coord:" << mesh_.points()[pointi]
4984 <<
" has level " << pointLevel_[pointi]
4985 <<
" whereas the coupled point has level " 4986 << syncPointLevel[pointi]
4994 if (maxPointDiff != -1)
4999 forAll(maxPointLevel, pointi)
5001 const labelList& pCells = mesh_.pointCells(pointi);
5003 label& pLevel = maxPointLevel[pointi];
5007 pLevel =
max(pLevel, cellLevel_[pCells[i]]);
5023 label pointi = pointsToCheck[i];
5025 const labelList& pCells = mesh_.pointCells(pointi);
5029 label celli = pCells[i];
5033 mag(cellLevel_[celli]-maxPointLevel[pointi])
5040 <<
"Too big a difference between" 5041 <<
" point-connected cells." <<
nl 5043 <<
" cellLevel:" << cellLevel_[celli]
5044 <<
" uses point:" << pointi
5045 <<
" coord:" << mesh_.points()[pointi]
5046 <<
" which is also used by a cell with level:" 5047 << maxPointLevel[pointi]
5122 if (!cellShapesPtr_)
5126 Pout<<
"hexRef8::cellShapes() : calculating splitHex cellShapes." 5127 <<
" cellLevel:" << cellLevel_.size()
5128 <<
" pointLevel:" << pointLevel_.size()
5135 label nSplitHex = 0;
5136 label nUnrecognised = 0;
5138 forAll(cellLevel_, celli)
5140 if (meshShapes[celli].model().index() == 0)
5142 label level = cellLevel_[celli];
5146 bool haveQuads = matchHexShape
5156 cellShapesPtr_()[celli] = degenerateMatcher::match(faces);
5167 Pout<<
"hexRef8::cellShapes() :" 5168 <<
" nCells:" << mesh_.nCells() <<
" of which" <<
nl 5169 <<
" primitive:" << (mesh_.nCells()-nSplitHex-nUnrecognised)
5171 <<
" split-hex:" << nSplitHex <<
nl 5172 <<
" poly :" << nUnrecognised <<
nl 5176 return *cellShapesPtr_;
5184 checkRefinementLevels(-1,
labelList(0));
5189 Pout<<
"hexRef8::getSplitPoints :" 5190 <<
" Calculating unrefineable points" <<
endl;
5194 if (!history_.active())
5197 <<
"Only call if constructed with history capability" 5205 labelList splitMaster(mesh_.nPoints(), -1);
5211 for (label pointi = 0; pointi < mesh_.nPoints(); pointi++)
5213 const labelList& pCells = mesh_.pointCells(pointi);
5215 if (pCells.
size() != 8)
5217 splitMaster[pointi] = -2;
5222 const labelList& visibleCells = history_.visibleCells();
5224 forAll(visibleCells, celli)
5226 const labelList& cPoints = mesh_.cellPoints(celli);
5228 if (visibleCells[celli] != -1 && history_.parentIndex(celli) >= 0)
5230 label parentIndex = history_.parentIndex(celli);
5235 label pointi = cPoints[i];
5237 label masterCelli = splitMaster[pointi];
5239 if (masterCelli == -1)
5246 splitMaster[pointi] = parentIndex;
5247 splitMasterLevel[pointi] = cellLevel_[celli] - 1;
5249 else if (masterCelli == -2)
5255 (masterCelli != parentIndex)
5256 || (splitMasterLevel[pointi] != cellLevel_[celli] - 1)
5261 splitMaster[pointi] = -2;
5270 label pointi = cPoints[i];
5272 splitMaster[pointi] = -2;
5280 label facei = mesh_.nInternalFaces();
5281 facei < mesh_.nFaces();
5285 const face&
f = mesh_.faces()[facei];
5289 splitMaster[
f[fp]] = -2;
5296 label nSplitPoints = 0;
5298 forAll(splitMaster, pointi)
5300 if (splitMaster[pointi] >= 0)
5309 forAll(splitMaster, pointi)
5311 if (splitMaster[pointi] >= 0)
5313 splitPoints[nSplitPoints++] = pointi;
5391 Pout<<
"hexRef8::consistentUnrefinement :" 5392 <<
" Determining 2:1 consistent unrefinement" <<
endl;
5398 <<
"maxSet not implemented yet." 5408 bitSet unrefinePoint(mesh_.nPoints(), pointsToUnrefine);
5415 bitSet unrefineCell(mesh_.nCells());
5417 forAll(unrefinePoint, pointi)
5419 if (unrefinePoint.test(pointi))
5421 const labelList& pCells = mesh_.pointCells(pointi);
5423 unrefineCell.
set(pCells);
5435 for (label facei = 0; facei < mesh_.nInternalFaces(); facei++)
5437 label own = mesh_.faceOwner()[facei];
5438 label nei = mesh_.faceNeighbour()[facei];
5440 label ownLevel = cellLevel_[own] - unrefineCell.get(own);
5441 label neiLevel = cellLevel_[nei] - unrefineCell.get(nei);
5443 if (ownLevel < (neiLevel-1))
5450 unrefineCell.set(nei);
5461 if (!unrefineCell.test(own))
5467 unrefineCell.unset(own);
5471 else if (neiLevel < (ownLevel-1))
5475 unrefineCell.set(own);
5479 if (!unrefineCell.test(nei))
5485 unrefineCell.unset(nei);
5493 labelList neiLevel(mesh_.nBoundaryFaces());
5497 label own = mesh_.faceOwner()[i+mesh_.nInternalFaces()];
5499 neiLevel[i] = cellLevel_[own] - unrefineCell.get(own);
5507 label facei = i+mesh_.nInternalFaces();
5508 label own = mesh_.faceOwner()[facei];
5509 label ownLevel = cellLevel_[own] - unrefineCell.get(own);
5511 if (ownLevel < (neiLevel[i]-1))
5515 if (!unrefineCell.test(own))
5521 unrefineCell.unset(own);
5525 else if (neiLevel[i] < (ownLevel-1))
5529 if (unrefineCell.test(own))
5535 unrefineCell.set(own);
5545 Pout<<
"hexRef8::consistentUnrefinement :" 5546 <<
" Changed " << nChanged
5547 <<
" refinement levels due to 2:1 conflicts." 5561 forAll(unrefinePoint, pointi)
5563 if (unrefinePoint.test(pointi))
5565 const labelList& pCells = mesh_.pointCells(pointi);
5569 if (!unrefineCell.test(pCells[j]))
5571 unrefinePoint.unset(pointi);
5583 forAll(unrefinePoint, pointi)
5585 if (unrefinePoint.test(pointi))
5594 forAll(unrefinePoint, pointi)
5596 if (unrefinePoint.test(pointi))
5598 newPointsToUnrefine[nSet++] = pointi;
5602 return newPointsToUnrefine;
5612 if (!history_.active())
5615 <<
"Only call if constructed with history capability" 5621 Pout<<
"hexRef8::setUnrefinement :" 5622 <<
" Checking initial mesh just to make sure" <<
endl;
5626 forAll(cellLevel_, celli)
5628 if (cellLevel_[celli] < 0)
5631 <<
"Illegal cell level " << cellLevel_[celli]
5632 <<
" for cell " << celli
5639 pointSet pSet(mesh_,
"splitPoints", splitPointLabels);
5642 cellSet cSet(mesh_,
"splitPointCells", splitPointLabels.
size());
5644 forAll(splitPointLabels, i)
5646 const labelList& pCells = mesh_.pointCells(splitPointLabels[i]);
5648 cSet.insert(pCells);
5652 Pout<<
"hexRef8::setRefinement : Dumping " << pSet.
size()
5654 << cSet.size() <<
" cells for unrefinement to" <<
nl 5656 <<
" cellSet " << cSet.objectPath()
5668 forAll(splitPointLabels, i)
5672 splitFaces.insert(
pFaces);
5677 faceRemover_.compatibleRemoves
5685 if (facesToRemove.
size() != splitFaces.size())
5689 const_cast<polyMesh&
>(mesh_).setInstance
5691 mesh_.time().timeName()
5694 pointSet pSet(mesh_,
"splitPoints", splitPointLabels);
5696 faceSet fSet(mesh_,
"splitFaces", splitFaces);
5698 faceSet removeSet(mesh_,
"facesToRemove", facesToRemove);
5703 <<
"Ininitial set of split points to unrefine does not" 5704 <<
" seem to be consistent or not mid points of refined cells" 5705 <<
" splitPoints:" << splitPointLabels.
size()
5706 <<
" splitFaces:" << splitFaces.size()
5707 <<
" facesToRemove:" << facesToRemove.
size()
5716 forAll(splitPointLabels, i)
5718 label pointi = splitPointLabels[i];
5722 const labelList& pCells = mesh_.pointCells(pointi);
5725 if (pCells.
size() != 8)
5728 <<
"splitPoint " << pointi
5729 <<
" should have 8 cells using it. It has " << pCells
5738 label masterCelli =
min(pCells);
5742 label celli = pCells[j];
5744 label region = cellRegion[celli];
5749 <<
"Ininitial set of split points to unrefine does not" 5750 <<
" seem to be consistent or not mid points" 5751 <<
" of refined cells" <<
nl 5752 <<
"cell:" << celli <<
" on splitPoint " << pointi
5753 <<
" has no region to be merged into" 5757 if (masterCelli != cellRegionMaster[region])
5760 <<
"cell:" << celli <<
" on splitPoint:" << pointi
5761 <<
" in region " << region
5762 <<
" has master:" << cellRegionMaster[region]
5763 <<
" which is not the lowest numbered cell" 5764 <<
" among the pointCells:" << pCells
5773 faceRemover_.setRefinement
5784 forAll(splitPointLabels, i)
5786 label pointi = splitPointLabels[i];
5788 const labelList& pCells = mesh_.pointCells(pointi);
5790 label masterCelli =
min(pCells);
5794 cellLevel_[pCells[j]]--;
5797 history_.combineCells(masterCelli, pCells);
5801 setInstance(mesh_.facesInstance());
5811 cellLevel_.write(writeOnProc)
5812 && pointLevel_.write(writeOnProc)
5813 && level0Edge_.write(writeOnProc);
5815 if (history_.active())
5817 writeOk = writeOk && history_.write(writeOnProc);
5841 if (
exists(setsDir/
"cellLevel"))
5843 rm(setsDir/
"cellLevel");
5845 if (
exists(setsDir/
"pointLevel"))
5847 rm(setsDir/
"pointLevel");
5849 if (
exists(setsDir/
"level0Edge"))
5851 rm(setsDir/
"level0Edge");
void distribute(const mapDistributePolyMesh &)
Update local numbering for mesh redistribution.
prefixOSstream Perr
OSstream wrapped stderr (std::cerr) with parallel prefix.
void size(const label n)
Older name for setAddressableSize.
A class for handling file names.
readOption readOpt() const noexcept
Get the read option.
virtual const fileName & name() const
The name of the stream.
List< wallPoints > allCellInfo(mesh_.nCells())
virtual label iterate(const label maxIter)
Iterate until no changes or maxIter reached.
errorManipArg< error, int > exit(error &err, const int errNo=1)
const fileName & facesInstance() const
Return the current instance directory for faces.
A face is a list of labels corresponding to mesh vertices.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
void transfer(List< T > &list)
Transfer the contents of the argument List into this list and annul the argument list.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
void setUnrefinement(const labelList &splitPointLabels, polyTopoChange &)
Remove some refinement. Needs to be supplied output of.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
void append(const T &val)
Append an element at the end of the list.
bool active() const
Is there unrefinement history?
static void removeFiles(const polyMesh &)
Helper: remove all relevant files from mesh instance.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
std::enable_if< std::is_same< bool, TypeT >::value, bool >::type set(const label i, bool val=true)
A bitSet::set() method for a list of bool.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
bool updateFace(const polyMesh &, const label thisFacei, const label neighbourCelli, const refinementData &neighbourInfo, const scalar tol, TrackingData &td)
Influence of neighbouring cell.
Output to file stream as an OSstream, normally using std::ofstream for the actual output...
constexpr char nl
The newline '\n' character (0x0a)
UIndirectList< label > labelUIndList
UIndirectList of labels.
static word meshSubDir
Return the mesh sub-directory name (usually "polyMesh")
dimensionedScalar sqrt(const dimensionedScalar &ds)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Wave propagation of information through grid. Every iteration information goes through one layer of c...
List< cellShape > cellShapeList
List of cellShape.
void checkMesh() const
Debug: Check coupled mesh for correctness.
void storeData(const labelList &pointsToStore, const labelList &facesToStore, const labelList &cellsToStore)
Signal points/face/cells for which to store data.
Class containing mesh-to-mesh mapping information after a mesh distribution where we send parts of me...
labelList consistentSlowRefinement2(const label maxFaceDiff, const labelList &cellsToRefine, const labelList &facesToCheck) const
Like consistentSlowRefinement but uses different meshWave.
labelList findIndices(const ListType &input, typename ListType::const_reference val, label start=0)
Linear search to find all occurrences of given element.
Class containing data for point addition.
labelListList setRefinement(const labelList &cells, polyTopoChange &)
Insert refinement. All selected cells will be split into 8.
Holds information regarding type of cell. Used in inside/outside determination in cellClassification...
virtual const fileName & name() const override
Get the name of the output serial stream. (eg, the name of the Fstream file name) ...
List< labelList > labelListList
List of labelList.
labelList consistentUnrefinement(const labelList &pointsToUnrefine, const bool maxSet) const
Given proposed.
fileName objectPath() const
The complete path + object name.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
static scalar propagationTol() noexcept
Access to propagation tolerance.
UList< label > labelUList
A UList of labels.
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
void subset(const labelList &pointMap, const labelList &faceMap, const labelList &cellMap)
Update local numbering for subsetted mesh.
fileName path() const
The complete path for the object (with instance, local,...).
#define forAll(list, i)
Loop across all elements in list.
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...
void setInstance(const fileName &inst)
A topoSetFaceSource to select all the faces from given cellSet(s).
List< face > faceList
List of faces.
label size() const noexcept
The number of elements in table.
Class containing data for cell addition.
unsigned int count(const UList< bool > &bools, const bool val=true)
Count number of 'true' entries.
vectorField pointField
pointField is a vectorField.
const dimensionedScalar e
Elementary charge.
void setSize(const label n)
Alias for resize()
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
const labelList & cellMap() const noexcept
Old cell map.
An edge is a list of two vertex labels. This can correspond to a directed graph edge or an edge on a ...
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...
void clear()
Clear the list, i.e. set size to zero.
Refinement of (split) hexes using polyTopoChange.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
const labelList & pointMap() const noexcept
Old point map.
const labelList & reverseCellMap() const noexcept
Reverse cell map.
labelList consistentSlowRefinement(const label maxFaceDiff, const labelList &cellsToRefine, const labelList &facesToCheck, const label maxPointDiff, const labelList &pointsToCheck) const
Like consistentRefinement but slower:
Reading is optional [identical to LAZY_READ].
virtual bool write(const bool writeOnProc=true) const
Write using setting from DB.
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?
virtual bool write(const token &tok)=0
Write token to stream or otherwise handle it.
void distributeCellData(List< T > &values) const
Distribute list of cell data.
void reverse(UList< T > &list, const label n)
Reverse the first n elements of the list.
const labelList & reversePointMap() const noexcept
Reverse point map.
void append(const T &val)
Copy append an element to the end of this list.
Container with cells to refine. Refinement given as single direction.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
errorManip< error > abort(error &err)
A HashTable to objects of type <T> with a labelPair key. The hashing is based on labelPair (FixedList...
bool typeHeaderOk(const bool checkType=true, const bool search=true, const bool verbose=true)
Read header (respects is_globalIOobject trait) and check its info.
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO...
void updateMesh(const mapPolyMesh &)
Update local numbering for changed mesh.
virtual bool read()
Read object. If global number of visible cells > 0 becomes active.
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
int debug
Static debugging option.
Pair< label > labelPair
A pair of labels.
Type gMax(const FieldField< Field, Type > &f)
defineTypeNameAndDebug(combustionModel, 0)
label nOldCells() const noexcept
Number of old cells.
Reduction class. If x and y are not equal assign value.
PrimitivePatch< SubList< face >, const pointField & > primitivePatch
A PrimitivePatch with a SubList addressing for the faces, const reference for the point field...
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];} label minLabel=min(start, end);pointMap[start]=pointMap[end]=minLabel;} } 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};const 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< SLList< face > > pFaces[nBCs]
label nOldPoints() const noexcept
Number of old points.
const labelList & visibleCells() const
Per cell in the current mesh (i.e. visible) either -1 (unrefined) or an index into splitCells...
Transfers refinement levels such that slow transition between levels is maintained. Used in FaceCellWave.
labelList consistentRefinement(const labelUList &cellLevel, const labelList &cellsToRefine, const bool maxSet) const
Given valid mesh and current cell level and proposed.
void distributePointData(List< T > &values) const
Distribute list of point data.
static void removeFiles(const polyMesh &)
Helper: remove all sets files from mesh instance.
vector point
Point is a vector.
label faceLevel(const label facei) const
Gets level such that the face has four points <= level.
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
#define WarningInFunction
Report a warning using Foam::Warning.
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
void operator()(label &x, const label y) const
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
A cell is defined as a list of faces with extra functionality.
A collection of cell labels.
A List with indirect addressing. Like IndirectList but does not store addressing. ...
Direct mesh changes based on v1.3 polyTopoChange syntax.
const polyBoundaryMesh & patches
labelList getSplitPoints() const
Return the points at the centre of top-level split cells.
#define DebugVar(var)
Report a variable name and value.
Mesh consisting of general polyhedral cells.
void checkRefinementLevels(const label maxPointDiff, const labelList &pointsToCheck) const
Debug: Check 2:1 consistency across faces.
List< label > labelList
A List of labels.
All refinement history. Used in unrefinement.
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, IOobject::NO_REGISTER)
A patch is a list of labels that address the faces in the global face list.
bool write(const bool writeOnProc=true) const
Force writing refinement+history to polyMesh directory.
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...
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))
ListType reorder(const labelUList &oldToNew, const ListType &input, const bool prune=false)
Reorder the elements of a list.
Defines the attributes of an object for which implicit objectRegistry management is supported...
List< wallPoints > allFaceInfo(mesh_.nFaces())
const cellShapeList & cellShapes() const
Utility: get hexes as cell shapes.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
void setFaceInfo(const label facei, const Type &faceInfo)
Set single initial changed face.
void reduce(T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Reduce inplace (cf. MPI Allreduce) using linear/tree communication schedule.
const volScalarField & p0
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
forAllConstIters(mixture.phases(), phase)
A HashTable to objects of type <T> with a label key.
static void listCombineReduce(List< T > &values, const CombineOp &cop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Combines List elements. After completion all processors have the same data.
bool rm(const fileName &file)
Remove a file (or its gz equivalent), returning true if successful.
label setAction(const topoAction &action)
For compatibility with polyTopoChange: set topological action.
static constexpr const zero Zero
Global zero (0)