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);
2446 for (label facei = mesh_.nInternalFaces(); facei < mesh_.nFaces(); facei++)
2451 label own = faceOwner[facei];
2464 seedFaces.append(facei);
2465 seedFacesInfo.append(faceData);
2483 Pout<<
"hexRef8::consistentSlowRefinement : Seeded " 2484 << seedFaces.size() <<
" faces between cells with different" 2485 <<
" refinement level." <<
endl;
2489 levelCalc.
setFaceInfo(seedFaces.shrink(), seedFacesInfo.shrink());
2491 seedFacesInfo.clear();
2494 levelCalc.
iterate(mesh_.globalData().nTotalFaces()+1);
2502 if (maxPointDiff == -1)
2512 forAll(maxPointCount, pointi)
2514 label& pLevel = maxPointCount[pointi];
2516 const labelList& pCells = mesh_.pointCells(pointi);
2541 label pointi = pointsToCheck[i];
2546 const labelList& pCells = mesh_.pointCells(pointi);
2550 label celli = pCells[pCelli];
2558 maxPointCount[pointi]
2559 >
cellInfo.count() + maxFaceDiff*maxPointDiff
2567 const cell& cFaces = mesh_.cells()[celli];
2571 label facei = cFaces[cFacei];
2586 changedFacesInfo.insert(facei, faceData);
2593 label nChanged = changedFacesInfo.size();
2603 seedFaces.setCapacity(changedFacesInfo.size());
2604 seedFacesInfo.setCapacity(changedFacesInfo.size());
2608 seedFaces.append(iter.key());
2609 seedFacesInfo.append(iter.val());
2616 for (label facei = 0; facei < mesh_.nInternalFaces(); facei++)
2618 label own = mesh_.faceOwner()[facei];
2623 label nei = mesh_.faceNeighbour()[facei];
2628 if (
mag(ownLevel-neiLevel) > 1)
2634 <<
" current level:" << cellLevel_[own]
2636 <<
" level after refinement:" << ownLevel
2638 <<
"neighbour cell:" << nei
2639 <<
" current level:" << cellLevel_[nei]
2641 <<
" level after refinement:" << neiLevel
2643 <<
"which does not satisfy 2:1 constraints anymore." <<
nl 2644 <<
"face:" << facei <<
" faceRefData:" <<
allFaceInfo[facei]
2653 labelList neiLevel(mesh_.nBoundaryFaces());
2654 labelList neiCount(mesh_.nBoundaryFaces());
2655 labelList neiRefCount(mesh_.nBoundaryFaces());
2659 label own = mesh_.faceOwner()[i+mesh_.nInternalFaces()];
2660 neiLevel[i] = cellLevel_[own];
2662 neiRefCount[i] =
allCellInfo[own].refinementCount();
2673 label facei = i+mesh_.nInternalFaces();
2675 label own = mesh_.faceOwner()[facei];
2682 + ((neiCount[i] >= neiRefCount[i]) ? 1 : 0);
2684 if (
mag(ownLevel - nbrLevel) > 1)
2687 label patchi = mesh_.boundaryMesh().whichPatch(facei);
2690 <<
"Celllevel does not satisfy 2:1 constraint." 2691 <<
" On coupled face " 2694 <<
" on patch " << patchi <<
" " 2695 << mesh_.boundaryMesh()[patchi].name() <<
nl 2696 <<
"owner cell " << own
2697 <<
" current level:" << cellLevel_[own]
2699 <<
" current refCount:" 2701 <<
" level after refinement:" << ownLevel
2703 <<
"(coupled) neighbour cell" 2704 <<
" has current level:" << neiLevel[i]
2705 <<
" current count:" << neiCount[i]
2706 <<
" current refCount:" << neiRefCount[i]
2707 <<
" level after refinement:" << nbrLevel
2733 newCellsToRefine[nRefined++] = celli;
2739 Pout<<
"hexRef8::consistentSlowRefinement : From " 2740 << cellsToRefine.
size() <<
" to " << newCellsToRefine.
size()
2741 <<
" cells to refine." <<
endl;
2744 return newCellsToRefine;
2750 const label maxFaceDiff,
2755 const labelList& faceOwner = mesh_.faceOwner();
2756 const labelList& faceNeighbour = mesh_.faceNeighbour();
2758 if (maxFaceDiff <= 0)
2761 <<
"Illegal maxFaceDiff " << maxFaceDiff <<
nl 2765 const scalar level0Size = 2*maxFaceDiff*level0EdgeLength();
2774 List<refinementDistanceData>
allCellInfo(mesh_.nCells());
2777 List<refinementDistanceData>
allFaceInfo(mesh_.nFaces());
2780 int dummyTrackData = 0;
2786 label celli = cellsToRefine[i];
2791 mesh_.cellCentres()[celli],
2803 mesh_.cellCentres()[celli],
2849 DynamicList<label> seedFaces(mesh_.nFaces()/100);
2851 DynamicList<refinementDistanceData> seedFacesInfo(mesh_.nFaces()/100);
2854 const polyBoundaryMesh&
patches = mesh_.boundaryMesh();
2861 bitSet isBoundary(mesh_.nFaces());
2867 const auto& faceCells =
pp.faceCells();
2870 const label own = faceCells[i];
2871 nbrCc[
pp.offset()+i] = cc[own];
2873 const label ownLevel =
2879 nbrLevel[
pp.offset()+i] = ownLevel;
2884 isBoundary.set(
pp.range());
2892 for (
const label facei : facesToCheck)
2898 <<
"Argument facesToCheck seems to have duplicate entries!" 2900 <<
"face:" << facei <<
" occurs at positions " 2905 const label own = faceOwner[facei];
2906 const label ownLevel =
2912 const point& ownCc = cc[own];
2914 if (isBoundary(facei))
2918 const point& fc = mesh_.faceCentres()[facei];
2920 refinementDistanceData neiData
2941 if (mesh_.isInternalFace(facei))
2943 const label nei = faceNeighbour[facei];
2954 neiLevel = nbrLevel[facei-mesh_.nInternalFaces()];
2955 neiCc = nbrCc[facei-mesh_.nInternalFaces()];
2958 if (ownLevel == neiLevel)
2966 refinementDistanceData(level0Size, neiCc, neiLevel+1),
2975 refinementDistanceData(level0Size, ownCc, ownLevel+1),
2988 refinementDistanceData(level0Size, neiCc, neiLevel),
2997 refinementDistanceData(level0Size, ownCc, ownLevel),
3003 seedFaces.append(facei);
3018 if (!
allFaceInfo[facei].valid(dummyTrackData) && !isBoundary(facei))
3020 const label own = faceOwner[facei];
3021 const label ownLevel =
3027 const point& ownCc = cc[own];
3031 if (mesh_.isInternalFace(facei))
3033 const label nei = faceNeighbour[facei];
3044 neiLevel = nbrLevel[facei-mesh_.nInternalFaces()];
3045 neiCc = nbrCc[facei-mesh_.nInternalFaces()];
3048 if (ownLevel > neiLevel)
3057 refinementDistanceData(level0Size, ownCc, ownLevel),
3063 else if (neiLevel > ownLevel)
3065 seedFaces.append(facei);
3071 refinementDistanceData(level0Size, neiCc, neiLevel),
3081 seedFacesInfo.shrink();
3084 FaceCellWave<refinementDistanceData, int> levelCalc
3091 mesh_.globalData().nTotalCells()+1,
3172 label celli = cellsToRefine[i];
3174 allCellInfo[celli].originLevel() =
sizeof(label)*8-2;
3181 bitSet refineCell(mesh_.nCells());
3184 label wanted =
allCellInfo[celli].wantedLevel(cc[celli]);
3186 if (wanted > cellLevel_[celli]+1)
3188 refineCell.set(celli);
3191 faceConsistentRefinement(
true, cellLevel_, refineCell);
3195 label nChanged = faceConsistentRefinement(
true, cellLevel_, refineCell);
3197 reduce(nChanged, sumOp<label>());
3201 Pout<<
"hexRef8::consistentSlowRefinement2 : Changed " << nChanged
3202 <<
" refinement levels due to 2:1 conflicts." 3213 labelList newCellsToRefine(refineCell.toc());
3217 Pout<<
"hexRef8::consistentSlowRefinement2 : From " 3218 << cellsToRefine.
size() <<
" to " << newCellsToRefine.size()
3219 <<
" cells to refine." <<
endl;
3224 cellSet cellsIn(mesh_,
"cellsToRefineIn", cellsToRefine);
3225 Pout<<
"hexRef8::consistentSlowRefinement2 : writing " 3226 << cellsIn.size() <<
" to cellSet " 3227 << cellsIn.objectPath() <<
endl;
3231 cellSet cellsOut(mesh_,
"cellsToRefineOut", newCellsToRefine);
3232 Pout<<
"hexRef8::consistentSlowRefinement2 : writing " 3233 << cellsOut.size() <<
" to cellSet " 3234 << cellsOut.objectPath() <<
endl;
3239 bitSet refineCell(mesh_.nCells(), newCellsToRefine);
3241 const bitSet savedRefineCell(refineCell);
3242 label nChanged = faceConsistentRefinement(
true, cellLevel_, refineCell);
3247 mesh_,
"cellsToRefineOut2", newCellsToRefine.size()
3249 forAll(refineCell, celli)
3251 if (refineCell.test(celli))
3253 cellsOut2.insert(celli);
3256 Pout<<
"hexRef8::consistentSlowRefinement2 : writing " 3257 << cellsOut2.size() <<
" to cellSet " 3258 << cellsOut2.objectPath() <<
endl;
3264 forAll(refineCell, celli)
3266 if (refineCell.test(celli) && !savedRefineCell.test(celli))
3270 <<
"Cell:" << celli <<
" cc:" 3271 << mesh_.cellCentres()[celli]
3272 <<
" was not marked for refinement but does not obey" 3273 <<
" 2:1 constraints." 3280 return newCellsToRefine;
3293 Pout<<
"hexRef8::setRefinement :" 3294 <<
" Checking initial mesh just to make sure" <<
endl;
3303 savedPointLevel_.clear();
3304 savedCellLevel_.clear();
3309 forAll(cellLevel_, celli)
3311 newCellLevel.append(cellLevel_[celli]);
3314 forAll(pointLevel_, pointi)
3316 newPointLevel.append(pointLevel_[pointi]);
3322 Pout<<
"hexRef8::setRefinement :" 3323 <<
" Allocating " << cellLabels.
size() <<
" cell midpoints." 3331 labelList cellMidPoint(mesh_.nCells(), -1);
3335 label celli = cellLabels[i];
3337 label anchorPointi = mesh_.faces()[mesh_.cells()[celli][0]][0];
3343 mesh_.cellCentres()[celli],
3350 newPointLevel(cellMidPoint[celli]) = cellLevel_[celli]+1;
3356 cellSet splitCells(mesh_,
"splitCells", cellLabels.
size());
3358 forAll(cellMidPoint, celli)
3360 if (cellMidPoint[celli] >= 0)
3362 splitCells.insert(celli);
3366 Pout<<
"hexRef8::setRefinement : Dumping " << splitCells.size()
3367 <<
" cells to split to cellSet " << splitCells.objectPath()
3380 Pout<<
"hexRef8::setRefinement :" 3381 <<
" Allocating edge midpoints." 3390 labelList edgeMidPoint(mesh_.nEdges(), -1);
3393 forAll(cellMidPoint, celli)
3395 if (cellMidPoint[celli] >= 0)
3397 const labelList& cEdges = mesh_.cellEdges(celli);
3401 label edgeI = cEdges[i];
3403 const edge&
e = mesh_.edges()[edgeI];
3407 pointLevel_[
e[0]] <= cellLevel_[celli]
3408 && pointLevel_[
e[1]] <= cellLevel_[celli]
3411 edgeMidPoint[edgeI] = 12345;
3438 forAll(edgeMidPoint, edgeI)
3440 if (edgeMidPoint[edgeI] >= 0)
3443 edgeMids[edgeI] = mesh_.edges()[edgeI].centre(mesh_.points());
3451 point(-GREAT, -GREAT, -GREAT)
3456 forAll(edgeMidPoint, edgeI)
3458 if (edgeMidPoint[edgeI] >= 0)
3463 const edge&
e = mesh_.edges()[edgeI];
3476 newPointLevel(edgeMidPoint[edgeI]) =
3489 OFstream str(mesh_.time().path()/
"edgeMidPoint.obj");
3491 forAll(edgeMidPoint, edgeI)
3493 if (edgeMidPoint[edgeI] >= 0)
3495 const edge&
e = mesh_.edges()[edgeI];
3501 Pout<<
"hexRef8::setRefinement :" 3502 <<
" Dumping edge centres to split to file " << str.
name() <<
endl;
3512 Pout<<
"hexRef8::setRefinement :" 3513 <<
" Allocating face midpoints." 3519 labelList faceAnchorLevel(mesh_.nFaces());
3521 for (label facei = 0; facei < mesh_.nFaces(); facei++)
3523 faceAnchorLevel[facei] = faceLevel(facei);
3528 labelList faceMidPoint(mesh_.nFaces(), -1);
3533 for (label facei = 0; facei < mesh_.nInternalFaces(); facei++)
3535 if (faceAnchorLevel[facei] >= 0)
3537 label own = mesh_.faceOwner()[facei];
3538 label ownLevel = cellLevel_[own];
3539 label newOwnLevel = ownLevel + (cellMidPoint[own] >= 0 ? 1 : 0);
3541 label nei = mesh_.faceNeighbour()[facei];
3542 label neiLevel = cellLevel_[nei];
3543 label newNeiLevel = neiLevel + (cellMidPoint[nei] >= 0 ? 1 : 0);
3547 newOwnLevel > faceAnchorLevel[facei]
3548 || newNeiLevel > faceAnchorLevel[facei]
3551 faceMidPoint[facei] = 12345;
3564 labelList newNeiLevel(mesh_.nBoundaryFaces());
3568 label own = mesh_.faceOwner()[i+mesh_.nInternalFaces()];
3569 label ownLevel = cellLevel_[own];
3570 label newOwnLevel = ownLevel + (cellMidPoint[own] >= 0 ? 1 : 0);
3572 newNeiLevel[i] = newOwnLevel;
3582 label facei = i+mesh_.nInternalFaces();
3584 if (faceAnchorLevel[facei] >= 0)
3586 label own = mesh_.faceOwner()[facei];
3587 label ownLevel = cellLevel_[own];
3588 label newOwnLevel = ownLevel + (cellMidPoint[own] >= 0 ? 1 : 0);
3592 newOwnLevel > faceAnchorLevel[facei]
3593 || newNeiLevel[i] > faceAnchorLevel[facei]
3596 faceMidPoint[facei] = 12345;
3621 mesh_.nBoundaryFaces(),
3622 point(-GREAT, -GREAT, -GREAT)
3627 label facei = i+mesh_.nInternalFaces();
3629 if (faceMidPoint[facei] >= 0)
3631 bFaceMids[i] = mesh_.faceCentres()[facei];
3641 forAll(faceMidPoint, facei)
3643 if (faceMidPoint[facei] >= 0)
3648 const face&
f = mesh_.faces()[facei];
3655 facei < mesh_.nInternalFaces()
3656 ? mesh_.faceCentres()[facei]
3657 : bFaceMids[facei-mesh_.nInternalFaces()]
3667 newPointLevel(faceMidPoint[facei]) = faceAnchorLevel[facei]+1;
3674 faceSet splitFaces(mesh_,
"splitFaces", cellLabels.
size());
3676 forAll(faceMidPoint, facei)
3678 if (faceMidPoint[facei] >= 0)
3680 splitFaces.insert(facei);
3684 Pout<<
"hexRef8::setRefinement : Dumping " << splitFaces.size()
3685 <<
" faces to split to faceSet " << splitFaces.objectPath() <<
endl;
3706 Pout<<
"hexRef8::setRefinement :" 3707 <<
" Finding cell anchorPoints (8 per cell)" 3720 forAll(cellMidPoint, celli)
3722 if (cellMidPoint[celli] >= 0)
3724 cellAnchorPoints[celli].setSize(8);
3728 forAll(pointLevel_, pointi)
3730 const labelList& pCells = mesh_.pointCells(pointi);
3734 label celli = pCells[pCelli];
3738 cellMidPoint[celli] >= 0
3739 && pointLevel_[pointi] <= cellLevel_[celli]
3742 if (nAnchorPoints[celli] == 8)
3747 <<
" of level " << cellLevel_[celli]
3748 <<
" uses more than 8 points of equal or" 3749 <<
" lower level" <<
nl 3750 <<
"Points so far:" << cellAnchorPoints[celli]
3754 cellAnchorPoints[celli][nAnchorPoints[celli]++] = pointi;
3759 forAll(cellMidPoint, celli)
3761 if (cellMidPoint[celli] >= 0)
3763 if (nAnchorPoints[celli] != 8)
3767 const labelList& cPoints = mesh_.cellPoints(celli);
3771 <<
" of level " << cellLevel_[celli]
3772 <<
" does not seem to have 8 points of equal or" 3773 <<
" lower level" <<
endl 3774 <<
"cellPoints:" << cPoints <<
endl 3789 Pout<<
"hexRef8::setRefinement :" 3790 <<
" Adding cells (1 per anchorPoint)" 3797 forAll(cellAnchorPoints, celli)
3799 const labelList& cAnchors = cellAnchorPoints[celli];
3801 if (cAnchors.
size() == 8)
3803 labelList& cAdded = cellAddedCells[celli];
3810 newCellLevel[celli] = cellLevel_[celli]+1;
3813 for (label i = 1; i < 8; i++)
3823 mesh_.cellZones().whichZone(celli)
3827 newCellLevel(cAdded[i]) = cellLevel_[celli]+1;
3842 Pout<<
"hexRef8::setRefinement :" 3843 <<
" Marking faces to be handled" 3848 bitSet affectedFace(mesh_.nFaces());
3851 forAll(cellMidPoint, celli)
3853 if (cellMidPoint[celli] >= 0)
3855 const cell& cFaces = mesh_.cells()[celli];
3857 affectedFace.
set(cFaces);
3861 forAll(faceMidPoint, facei)
3863 if (faceMidPoint[facei] >= 0)
3865 affectedFace.set(facei);
3869 forAll(edgeMidPoint, edgeI)
3871 if (edgeMidPoint[edgeI] >= 0)
3873 const labelList& eFaces = mesh_.edgeFaces(edgeI);
3875 affectedFace.
set(eFaces);
3886 Pout<<
"hexRef8::setRefinement : Splitting faces" <<
endl;
3889 forAll(faceMidPoint, facei)
3891 if (faceMidPoint[facei] >= 0 && affectedFace.test(facei))
3897 const face&
f = mesh_.faces()[facei];
3901 bool modifiedFace =
false;
3903 label anchorLevel = faceAnchorLevel[facei];
3909 label pointi =
f[fp];
3911 if (pointLevel_[pointi] <= anchorLevel)
3917 faceVerts.
append(pointi);
3933 faceVerts.
append(faceMidPoint[facei]);
3966 if (mesh_.isInternalFace(facei))
3968 label oldOwn = mesh_.faceOwner()[facei];
3969 label oldNei = mesh_.faceNeighbour()[facei];
3971 checkInternalOrientation
3976 mesh_.cellCentres()[oldOwn],
3977 mesh_.cellCentres()[oldNei],
3983 label oldOwn = mesh_.faceOwner()[facei];
3985 checkBoundaryOrientation
3990 mesh_.cellCentres()[oldOwn],
3991 mesh_.faceCentres()[facei],
4000 modifiedFace =
true;
4002 modFace(meshMod, facei, newFace, own, nei);
4006 addFace(meshMod, facei, newFace, own, nei);
4012 affectedFace.unset(facei);
4022 Pout<<
"hexRef8::setRefinement :" 4023 <<
" Adding edge splits to unsplit faces" 4030 forAll(edgeMidPoint, edgeI)
4032 if (edgeMidPoint[edgeI] >= 0)
4036 const labelList& eFaces = mesh_.edgeFaces(edgeI, eFacesStorage);
4040 label facei = eFaces[i];
4042 if (faceMidPoint[facei] < 0 && affectedFace.test(facei))
4046 const face&
f = mesh_.faces()[facei];
4047 const labelList& fEdges = mesh_.faceEdges
4057 newFaceVerts.append(
f[fp]);
4059 label edgeI = fEdges[fp];
4061 if (edgeMidPoint[edgeI] >= 0)
4063 newFaceVerts.
append(edgeMidPoint[edgeI]);
4072 label anchorFp = findMinLevel(
f);
4089 if (mesh_.isInternalFace(facei))
4091 label oldOwn = mesh_.faceOwner()[facei];
4092 label oldNei = mesh_.faceNeighbour()[facei];
4094 checkInternalOrientation
4099 mesh_.cellCentres()[oldOwn],
4100 mesh_.cellCentres()[oldNei],
4106 label oldOwn = mesh_.faceOwner()[facei];
4108 checkBoundaryOrientation
4113 mesh_.cellCentres()[oldOwn],
4114 mesh_.faceCentres()[facei],
4120 modFace(meshMod, facei, newFace, own, nei);
4123 affectedFace.unset(facei);
4135 Pout<<
"hexRef8::setRefinement :" 4136 <<
" Changing owner/neighbour for otherwise unaffected faces" 4140 forAll(affectedFace, facei)
4142 if (affectedFace.test(facei))
4144 const face&
f = mesh_.faces()[facei];
4148 label anchorFp = findMinLevel(
f);
4162 modFace(meshMod, facei,
f, own, nei);
4165 affectedFace.unset(facei);
4180 Pout<<
"hexRef8::setRefinement :" 4181 <<
" Create new internal faces for split cells" 4185 forAll(cellMidPoint, celli)
4187 if (cellMidPoint[celli] >= 0)
4212 forAll(cellMidPoint, celli)
4214 if (cellMidPoint[celli] >= 0)
4216 minPointi =
min(minPointi, cellMidPoint[celli]);
4217 maxPointi =
max(maxPointi, cellMidPoint[celli]);
4220 forAll(faceMidPoint, facei)
4222 if (faceMidPoint[facei] >= 0)
4224 minPointi =
min(minPointi, faceMidPoint[facei]);
4225 maxPointi =
max(maxPointi, faceMidPoint[facei]);
4228 forAll(edgeMidPoint, edgeI)
4230 if (edgeMidPoint[edgeI] >= 0)
4232 minPointi =
min(minPointi, edgeMidPoint[edgeI]);
4233 maxPointi =
max(maxPointi, edgeMidPoint[edgeI]);
4237 if (minPointi !=
labelMax && minPointi != mesh_.nPoints())
4240 <<
"Added point labels not consecutive to existing mesh points." 4242 <<
"mesh_.nPoints():" << mesh_.nPoints()
4243 <<
" minPointi:" << minPointi
4244 <<
" maxPointi:" << maxPointi
4249 pointLevel_.transfer(newPointLevel);
4250 cellLevel_.transfer(newCellLevel);
4253 setInstance(mesh_.facesInstance());
4260 if (history_.active())
4264 Pout<<
"hexRef8::setRefinement :" 4265 <<
" Updating refinement history to " << cellLevel_.size()
4266 <<
" cells" <<
endl;
4270 history_.resize(cellLevel_.size());
4272 forAll(cellAddedCells, celli)
4274 const labelList& addedCells = cellAddedCells[celli];
4276 if (addedCells.
size())
4279 history_.storeSplit(celli, addedCells);
4290 label celli = cellLabels[i];
4292 refinedCells[i].
transfer(cellAddedCells[celli]);
4295 return refinedCells;
4306 savedPointLevel_.clear();
4307 savedPointLevel_.reserve(pointsToStore.
size());
4310 label pointi = pointsToStore[i];
4311 savedPointLevel_.insert(pointi, pointLevel_[pointi]);
4314 savedCellLevel_.
clear();
4315 savedCellLevel_.reserve(cellsToStore.
size());
4318 label celli = cellsToStore[i];
4319 savedCellLevel_.insert(celli, cellLevel_[celli]);
4331 updateMesh(map, dummyMap, dummyMap, dummyMap);
4349 Pout<<
"hexRef8::updateMesh :" 4350 <<
" Updating various lists" 4359 Pout<<
"hexRef8::updateMesh :" 4362 <<
" nCells:" << mesh_.nCells()
4364 <<
" cellLevel_:" << cellLevel_.size()
4367 <<
" nPoints:" << mesh_.nPoints()
4369 <<
" pointLevel_:" << pointLevel_.size()
4373 if (reverseCellMap.
size() == cellLevel_.size())
4379 reorder(reverseCellMap, mesh_.nCells(), -1, cellLevel_);
4387 forAll(cellMap, newCelli)
4389 label oldCelli = cellMap[newCelli];
4393 newCellLevel[newCelli] = -1;
4397 newCellLevel[newCelli] = cellLevel_[oldCelli];
4407 const label newCelli = iter.key();
4408 const label storedCelli = iter.val();
4410 const auto fnd = savedCellLevel_.cfind(storedCelli);
4415 <<
"Problem : trying to restore old value for new cell " 4416 << newCelli <<
" but cannot find old cell " << storedCelli
4417 <<
" in map of stored values " << savedCellLevel_
4420 cellLevel_[newCelli] = fnd.val();
4441 if (reversePointMap.
size() == pointLevel_.size())
4444 reorder(reversePointMap, mesh_.nPoints(), -1, pointLevel_);
4455 const label oldPointi = pointMap[
newPointi];
4457 if (oldPointi == -1)
4470 newPointLevel[
newPointi] = pointLevel_[oldPointi];
4473 pointLevel_.
transfer(newPointLevel);
4481 const label storedPointi = iter.val();
4483 auto fnd = savedPointLevel_.find(storedPointi);
4488 <<
"Problem : trying to restore old value for new point " 4489 <<
newPointi <<
" but cannot find old point " 4491 <<
" in map of stored values " << savedPointLevel_
4511 if (history_.active())
4513 history_.updateMesh(map);
4517 setInstance(mesh_.facesInstance());
4520 faceRemover_.updateMesh(map);
4523 cellShapesPtr_.clear();
4538 Pout<<
"hexRef8::subset :" 4539 <<
" Updating various lists" 4543 if (history_.active())
4546 <<
"Subsetting will not work in combination with unrefinement." 4548 <<
"Proceed at your own risk." <<
endl;
4556 forAll(cellMap, newCelli)
4558 newCellLevel[newCelli] = cellLevel_[cellMap[newCelli]];
4561 cellLevel_.transfer(newCellLevel);
4563 if (cellLevel_.found(-1))
4567 <<
"cellLevel_ contains illegal value -1 after mapping:" 4582 pointLevel_.transfer(newPointLevel);
4584 if (pointLevel_.found(-1))
4588 <<
"pointLevel_ contains illegal value -1 after mapping:" 4595 if (history_.active())
4597 history_.subset(pointMap,
faceMap, cellMap);
4601 setInstance(mesh_.facesInstance());
4607 cellShapesPtr_.clear();
4616 Pout<<
"hexRef8::distribute :" 4617 <<
" Updating various lists" 4627 if (history_.active())
4629 history_.distribute(map);
4633 faceRemover_.distribute(map);
4636 cellShapesPtr_.clear();
4642 const scalar smallDim = 1
e-6 * mesh_.bounds().mag();
4646 Pout<<
"hexRef8::checkMesh : Using matching tolerance smallDim:" 4647 << smallDim <<
endl;
4660 nei[i] = mesh_.faceOwner()[i+mesh_.nInternalFaces()];
4678 label facei =
pp.start();
4682 label own = mesh_.faceOwner()[facei];
4683 label bFacei = facei-mesh_.nInternalFaces();
4689 <<
"Faces do not seem to be correct across coupled" 4690 <<
" boundaries" <<
endl 4691 <<
"Coupled face " << facei
4692 <<
" between owner " << own
4693 <<
" on patch " <<
pp.name()
4694 <<
" and coupled neighbour " << nei[bFacei]
4695 <<
" has two faces connected to it:" 4714 neiFaceAreas[i] =
mag(mesh_.faceAreas()[i+mesh_.nInternalFaces()]);
4722 label facei = i+mesh_.nInternalFaces();
4724 const scalar magArea =
mag(mesh_.faceAreas()[facei]);
4726 if (
mag(magArea - neiFaceAreas[i]) > smallDim)
4728 const face&
f = mesh_.faces()[facei];
4729 label patchi = mesh_.boundaryMesh().whichPatch(facei);
4731 dumpCell(mesh_.faceOwner()[facei]);
4734 <<
"Faces do not seem to be correct across coupled" 4735 <<
" boundaries" <<
endl 4736 <<
"Coupled face " << facei
4737 <<
" on patch " << patchi
4738 <<
" " << mesh_.boundaryMesh()[patchi].
name()
4740 <<
" has face area:" << magArea
4741 <<
" (coupled) neighbour face area differs:" 4743 <<
" to within tolerance " << smallDim
4753 labelList nVerts(mesh_.nBoundaryFaces());
4757 nVerts[i] = mesh_.faces()[i+mesh_.nInternalFaces()].size();
4765 label facei = i+mesh_.nInternalFaces();
4767 const face&
f = mesh_.faces()[facei];
4769 if (
f.
size() != nVerts[i])
4771 dumpCell(mesh_.faceOwner()[facei]);
4773 label patchi = mesh_.boundaryMesh().whichPatch(facei);
4776 <<
"Faces do not seem to be correct across coupled" 4777 <<
" boundaries" <<
endl 4778 <<
"Coupled face " << facei
4779 <<
" on patch " << patchi
4780 <<
" " << mesh_.boundaryMesh()[patchi].
name()
4782 <<
" has size:" <<
f.
size()
4783 <<
" (coupled) neighbour face has size:" 4795 pointField anchorPoints(mesh_.nBoundaryFaces());
4799 label facei = i+mesh_.nInternalFaces();
4800 const point& fc = mesh_.faceCentres()[facei];
4801 const face&
f = mesh_.faces()[facei];
4802 const vector anchorVec(mesh_.points()[
f[0]] - fc);
4804 anchorPoints[i] = anchorVec;
4814 label facei = i+mesh_.nInternalFaces();
4815 const point& fc = mesh_.faceCentres()[facei];
4816 const face&
f = mesh_.faces()[facei];
4817 const vector anchorVec(mesh_.points()[
f[0]] - fc);
4819 if (
mag(anchorVec - anchorPoints[i]) > smallDim)
4821 dumpCell(mesh_.faceOwner()[facei]);
4823 label patchi = mesh_.boundaryMesh().whichPatch(facei);
4826 <<
"Faces do not seem to be correct across coupled" 4827 <<
" boundaries" <<
endl 4828 <<
"Coupled face " << facei
4829 <<
" on patch " << patchi
4830 <<
" " << mesh_.boundaryMesh()[patchi].
name()
4832 <<
" has anchor vector:" << anchorVec
4833 <<
" (coupled) neighbour face anchor vector differs:" 4835 <<
" to within tolerance " << smallDim
4843 Pout<<
"hexRef8::checkMesh : Returning" <<
endl;
4850 const label maxPointDiff,
4856 Pout<<
"hexRef8::checkRefinementLevels :" 4857 <<
" Checking 2:1 refinement level" <<
endl;
4862 cellLevel_.size() != mesh_.nCells()
4863 || pointLevel_.size() != mesh_.nPoints()
4867 <<
"cellLevel size should be number of cells" 4868 <<
" and pointLevel size should be number of points."<<
nl 4869 <<
"cellLevel:" << cellLevel_.size()
4870 <<
" mesh.nCells():" << mesh_.nCells() <<
nl 4871 <<
"pointLevel:" << pointLevel_.size()
4872 <<
" mesh.nPoints():" << mesh_.nPoints()
4882 for (label facei = 0; facei < mesh_.nInternalFaces(); facei++)
4884 label own = mesh_.faceOwner()[facei];
4885 label nei = mesh_.faceNeighbour()[facei];
4887 if (
mag(cellLevel_[own] - cellLevel_[nei]) > 1)
4893 <<
"Celllevel does not satisfy 2:1 constraint." <<
nl 4894 <<
"On face " << facei <<
" owner cell " << own
4895 <<
" has refinement " << cellLevel_[own]
4896 <<
" neighbour cell " << nei <<
" has refinement " 4903 labelList neiLevel(mesh_.nBoundaryFaces());
4907 label own = mesh_.faceOwner()[i+mesh_.nInternalFaces()];
4909 neiLevel[i] = cellLevel_[own];
4917 label facei = i+mesh_.nInternalFaces();
4919 label own = mesh_.faceOwner()[facei];
4921 if (
mag(cellLevel_[own] - neiLevel[i]) > 1)
4925 label patchi = mesh_.boundaryMesh().whichPatch(facei);
4928 <<
"Celllevel does not satisfy 2:1 constraint." 4929 <<
" On coupled face " << facei
4930 <<
" on patch " << patchi <<
" " 4931 << mesh_.boundaryMesh()[patchi].name()
4932 <<
" owner cell " << own <<
" has refinement " 4934 <<
" (coupled) neighbour cell has refinement " 4957 forAll(syncPointLevel, pointi)
4959 if (pointLevel_[pointi] != syncPointLevel[pointi])
4962 <<
"PointLevel is not consistent across coupled patches." 4964 <<
"point:" << pointi <<
" coord:" << mesh_.points()[pointi]
4965 <<
" has level " << pointLevel_[pointi]
4966 <<
" whereas the coupled point has level " 4967 << syncPointLevel[pointi]
4975 if (maxPointDiff != -1)
4980 forAll(maxPointLevel, pointi)
4982 const labelList& pCells = mesh_.pointCells(pointi);
4984 label& pLevel = maxPointLevel[pointi];
4988 pLevel =
max(pLevel, cellLevel_[pCells[i]]);
5004 label pointi = pointsToCheck[i];
5006 const labelList& pCells = mesh_.pointCells(pointi);
5010 label celli = pCells[i];
5014 mag(cellLevel_[celli]-maxPointLevel[pointi])
5021 <<
"Too big a difference between" 5022 <<
" point-connected cells." <<
nl 5024 <<
" cellLevel:" << cellLevel_[celli]
5025 <<
" uses point:" << pointi
5026 <<
" coord:" << mesh_.points()[pointi]
5027 <<
" which is also used by a cell with level:" 5028 << maxPointLevel[pointi]
5103 if (!cellShapesPtr_)
5107 Pout<<
"hexRef8::cellShapes() : calculating splitHex cellShapes." 5108 <<
" cellLevel:" << cellLevel_.size()
5109 <<
" pointLevel:" << pointLevel_.size()
5116 label nSplitHex = 0;
5117 label nUnrecognised = 0;
5119 forAll(cellLevel_, celli)
5121 if (meshShapes[celli].model().index() == 0)
5123 label level = cellLevel_[celli];
5127 bool haveQuads = matchHexShape
5137 cellShapesPtr_()[celli] = degenerateMatcher::match(faces);
5148 Pout<<
"hexRef8::cellShapes() :" 5149 <<
" nCells:" << mesh_.nCells() <<
" of which" <<
nl 5150 <<
" primitive:" << (mesh_.nCells()-nSplitHex-nUnrecognised)
5152 <<
" split-hex:" << nSplitHex <<
nl 5153 <<
" poly :" << nUnrecognised <<
nl 5157 return *cellShapesPtr_;
5165 checkRefinementLevels(-1,
labelList(0));
5170 Pout<<
"hexRef8::getSplitPoints :" 5171 <<
" Calculating unrefineable points" <<
endl;
5175 if (!history_.active())
5178 <<
"Only call if constructed with history capability" 5186 labelList splitMaster(mesh_.nPoints(), -1);
5192 for (label pointi = 0; pointi < mesh_.nPoints(); pointi++)
5194 const labelList& pCells = mesh_.pointCells(pointi);
5196 if (pCells.
size() != 8)
5198 splitMaster[pointi] = -2;
5203 const labelList& visibleCells = history_.visibleCells();
5205 forAll(visibleCells, celli)
5207 const labelList& cPoints = mesh_.cellPoints(celli);
5209 if (visibleCells[celli] != -1 && history_.parentIndex(celli) >= 0)
5211 label parentIndex = history_.parentIndex(celli);
5216 label pointi = cPoints[i];
5218 label masterCelli = splitMaster[pointi];
5220 if (masterCelli == -1)
5227 splitMaster[pointi] = parentIndex;
5228 splitMasterLevel[pointi] = cellLevel_[celli] - 1;
5230 else if (masterCelli == -2)
5236 (masterCelli != parentIndex)
5237 || (splitMasterLevel[pointi] != cellLevel_[celli] - 1)
5242 splitMaster[pointi] = -2;
5251 label pointi = cPoints[i];
5253 splitMaster[pointi] = -2;
5261 label facei = mesh_.nInternalFaces();
5262 facei < mesh_.nFaces();
5266 const face&
f = mesh_.faces()[facei];
5270 splitMaster[
f[fp]] = -2;
5277 label nSplitPoints = 0;
5279 forAll(splitMaster, pointi)
5281 if (splitMaster[pointi] >= 0)
5290 forAll(splitMaster, pointi)
5292 if (splitMaster[pointi] >= 0)
5294 splitPoints[nSplitPoints++] = pointi;
5372 Pout<<
"hexRef8::consistentUnrefinement :" 5373 <<
" Determining 2:1 consistent unrefinement" <<
endl;
5379 <<
"maxSet not implemented yet." 5389 bitSet unrefinePoint(mesh_.nPoints(), pointsToUnrefine);
5396 bitSet unrefineCell(mesh_.nCells());
5398 forAll(unrefinePoint, pointi)
5400 if (unrefinePoint.test(pointi))
5402 const labelList& pCells = mesh_.pointCells(pointi);
5404 unrefineCell.
set(pCells);
5416 for (label facei = 0; facei < mesh_.nInternalFaces(); facei++)
5418 label own = mesh_.faceOwner()[facei];
5419 label nei = mesh_.faceNeighbour()[facei];
5421 label ownLevel = cellLevel_[own] - unrefineCell.get(own);
5422 label neiLevel = cellLevel_[nei] - unrefineCell.get(nei);
5424 if (ownLevel < (neiLevel-1))
5431 unrefineCell.set(nei);
5442 if (!unrefineCell.test(own))
5448 unrefineCell.unset(own);
5452 else if (neiLevel < (ownLevel-1))
5456 unrefineCell.set(own);
5460 if (!unrefineCell.test(nei))
5466 unrefineCell.unset(nei);
5474 labelList neiLevel(mesh_.nBoundaryFaces());
5478 label own = mesh_.faceOwner()[i+mesh_.nInternalFaces()];
5480 neiLevel[i] = cellLevel_[own] - unrefineCell.get(own);
5488 label facei = i+mesh_.nInternalFaces();
5489 label own = mesh_.faceOwner()[facei];
5490 label ownLevel = cellLevel_[own] - unrefineCell.get(own);
5492 if (ownLevel < (neiLevel[i]-1))
5496 if (!unrefineCell.test(own))
5502 unrefineCell.unset(own);
5506 else if (neiLevel[i] < (ownLevel-1))
5510 if (unrefineCell.test(own))
5516 unrefineCell.set(own);
5526 Pout<<
"hexRef8::consistentUnrefinement :" 5527 <<
" Changed " << nChanged
5528 <<
" refinement levels due to 2:1 conflicts." 5542 forAll(unrefinePoint, pointi)
5544 if (unrefinePoint.test(pointi))
5546 const labelList& pCells = mesh_.pointCells(pointi);
5550 if (!unrefineCell.test(pCells[j]))
5552 unrefinePoint.unset(pointi);
5564 forAll(unrefinePoint, pointi)
5566 if (unrefinePoint.test(pointi))
5575 forAll(unrefinePoint, pointi)
5577 if (unrefinePoint.test(pointi))
5579 newPointsToUnrefine[nSet++] = pointi;
5583 return newPointsToUnrefine;
5593 if (!history_.active())
5596 <<
"Only call if constructed with history capability" 5602 Pout<<
"hexRef8::setUnrefinement :" 5603 <<
" Checking initial mesh just to make sure" <<
endl;
5607 forAll(cellLevel_, celli)
5609 if (cellLevel_[celli] < 0)
5612 <<
"Illegal cell level " << cellLevel_[celli]
5613 <<
" for cell " << celli
5620 pointSet pSet(mesh_,
"splitPoints", splitPointLabels);
5623 cellSet cSet(mesh_,
"splitPointCells", splitPointLabels.
size());
5625 forAll(splitPointLabels, i)
5627 const labelList& pCells = mesh_.pointCells(splitPointLabels[i]);
5629 cSet.insert(pCells);
5633 Pout<<
"hexRef8::setRefinement : Dumping " << pSet.
size()
5635 << cSet.size() <<
" cells for unrefinement to" <<
nl 5637 <<
" cellSet " << cSet.objectPath()
5649 forAll(splitPointLabels, i)
5653 splitFaces.insert(
pFaces);
5658 faceRemover_.compatibleRemoves
5666 if (facesToRemove.
size() != splitFaces.size())
5670 const_cast<polyMesh&
>(mesh_).setInstance
5672 mesh_.time().timeName()
5675 pointSet pSet(mesh_,
"splitPoints", splitPointLabels);
5677 faceSet fSet(mesh_,
"splitFaces", splitFaces);
5679 faceSet removeSet(mesh_,
"facesToRemove", facesToRemove);
5684 <<
"Ininitial set of split points to unrefine does not" 5685 <<
" seem to be consistent or not mid points of refined cells" 5686 <<
" splitPoints:" << splitPointLabels.
size()
5687 <<
" splitFaces:" << splitFaces.size()
5688 <<
" facesToRemove:" << facesToRemove.
size()
5697 forAll(splitPointLabels, i)
5699 label pointi = splitPointLabels[i];
5703 const labelList& pCells = mesh_.pointCells(pointi);
5706 if (pCells.
size() != 8)
5709 <<
"splitPoint " << pointi
5710 <<
" should have 8 cells using it. It has " << pCells
5719 label masterCelli =
min(pCells);
5723 label celli = pCells[j];
5725 label region = cellRegion[celli];
5730 <<
"Ininitial set of split points to unrefine does not" 5731 <<
" seem to be consistent or not mid points" 5732 <<
" of refined cells" <<
nl 5733 <<
"cell:" << celli <<
" on splitPoint " << pointi
5734 <<
" has no region to be merged into" 5738 if (masterCelli != cellRegionMaster[region])
5741 <<
"cell:" << celli <<
" on splitPoint:" << pointi
5742 <<
" in region " << region
5743 <<
" has master:" << cellRegionMaster[region]
5744 <<
" which is not the lowest numbered cell" 5745 <<
" among the pointCells:" << pCells
5754 faceRemover_.setRefinement
5765 forAll(splitPointLabels, i)
5767 label pointi = splitPointLabels[i];
5769 const labelList& pCells = mesh_.pointCells(pointi);
5771 label masterCelli =
min(pCells);
5775 cellLevel_[pCells[j]]--;
5778 history_.combineCells(masterCelli, pCells);
5782 setInstance(mesh_.facesInstance());
5792 cellLevel_.write(writeOnProc)
5793 && pointLevel_.write(writeOnProc)
5794 && level0Edge_.write(writeOnProc);
5796 if (history_.active())
5798 writeOk = writeOk && history_.write(writeOnProc);
5822 if (
exists(setsDir/
"cellLevel"))
5824 rm(setsDir/
"cellLevel");
5826 if (
exists(setsDir/
"pointLevel"))
5828 rm(setsDir/
"pointLevel");
5830 if (
exists(setsDir/
"level0Edge"))
5832 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)