60 x = (x ==
y) ? x : value;
68 void Foam::hexRef8::reorder
89 newElems[newI] = elems[i];
97 void Foam::hexRef8::getFaceInfo
107 if (!mesh_.isInternalFace(facei))
109 patchID = mesh_.boundaryMesh().whichPatch(facei);
112 zoneID = mesh_.faceZones().whichZone(facei);
118 const faceZone& fZone = mesh_.faceZones()[zoneID];
135 label patchID, zoneID, zoneFlip;
137 getFaceInfo(facei, patchID, zoneID, zoneFlip);
141 if ((nei == -1) || (own < nei))
194 const label meshFacei,
195 const label meshPointi,
201 if (mesh_.isInternalFace(meshFacei))
287 void Foam::hexRef8::modFace
296 label patchID, zoneID, zoneFlip;
298 getFaceInfo(facei, patchID, zoneID, zoneFlip);
302 (own != mesh_.faceOwner()[facei])
304 mesh_.isInternalFace(facei)
305 && (nei != mesh_.faceNeighbour()[facei])
307 || (newFace != mesh_.faces()[facei])
310 if ((nei == -1) || (own < nei))
351 Foam::scalar Foam::hexRef8::getLevel0EdgeLength()
const 353 if (cellLevel_.size() != mesh_.nCells())
356 <<
"Number of cells in mesh:" << mesh_.nCells()
357 <<
" does not equal size of cellLevel:" << cellLevel_.size()
359 <<
"This might be because of a restart with inconsistent cellLevel." 366 const scalar great2 =
sqr(great);
383 const label cLevel = cellLevel_[celli];
385 const labelList& cEdges = mesh_.cellEdges(celli);
389 label edgeI = cEdges[i];
391 if (edgeLevel[edgeI] == -1)
393 edgeLevel[edgeI] = cLevel;
395 else if (edgeLevel[edgeI] ==
labelMax)
399 else if (edgeLevel[edgeI] != cLevel)
421 const label eLevel = edgeLevel[edgeI];
423 if (eLevel >= 0 && eLevel <
labelMax)
425 const edge&
e = mesh_.edges()[edgeI];
427 scalar edgeLenSqr =
magSqr(e.
vec(mesh_.points()));
429 typEdgeLenSqr[eLevel] =
min(typEdgeLenSqr[eLevel], edgeLenSqr);
441 Pout<<
"hexRef8::getLevel0EdgeLength() :" 442 <<
" After phase1: Edgelengths (squared) per refinementlevel:" 443 << typEdgeLenSqr <<
endl;
457 const label cLevel = cellLevel_[celli];
459 const labelList& cEdges = mesh_.cellEdges(celli);
463 const edge&
e = mesh_.edges()[cEdges[i]];
465 scalar edgeLenSqr =
magSqr(e.
vec(mesh_.points()));
467 maxEdgeLenSqr[cLevel] =
max(maxEdgeLenSqr[cLevel], edgeLenSqr);
476 Pout<<
"hexRef8::getLevel0EdgeLength() :" 477 <<
" Crappy Edgelengths (squared) per refinementlevel:" 478 << maxEdgeLenSqr <<
endl;
485 forAll(typEdgeLenSqr, levelI)
487 if (typEdgeLenSqr[levelI] == great2 && maxEdgeLenSqr[levelI] >= 0)
489 typEdgeLenSqr[levelI] = maxEdgeLenSqr[levelI];
495 Pout<<
"hexRef8::getLevel0EdgeLength() :" 496 <<
" Final Edgelengths (squared) per refinementlevel:" 497 << typEdgeLenSqr <<
endl;
501 scalar level0Size = -1;
503 forAll(typEdgeLenSqr, levelI)
505 scalar lenSqr = typEdgeLenSqr[levelI];
513 Pout<<
"hexRef8::getLevel0EdgeLength() :" 514 <<
" For level:" << levelI
516 <<
" with equivalent level0 len:" << level0Size
523 if (level0Size == -1)
544 if (cellAnchorPoints[celli].size())
550 return cellAddedCells[celli][index];
557 const face& f = mesh_.faces()[facei];
565 return cellAddedCells[celli][index];
571 Perr<<
"cell:" << celli <<
" anchorPoints:" << cellAnchorPoints[celli]
575 <<
"Could not find point " << pointi
576 <<
" in the anchorPoints for cell " << celli << endl
577 <<
"Does your original mesh obey the 2:1 constraint and" 578 <<
" did you use consistentRefinement to make your cells to refine" 579 <<
" obey this constraint as well?" 592 void Foam::hexRef8::getFaceNeighbours
608 mesh_.faceOwner()[facei],
613 if (mesh_.isInternalFace(facei))
619 mesh_.faceNeighbour()[facei],
639 label level = pointLevel_[f[fp]];
641 if (level < minLevel)
660 label level = pointLevel_[f[fp]];
662 if (level > maxLevel)
676 const label anchorLevel
683 if (pointLevel_[f[fp]] <= anchorLevel)
692 void Foam::hexRef8::dumpCell(
const label celli)
const 695 Pout<<
"hexRef8 : Dumping cell as obj to " << str.
name() <<
endl;
697 const cell& cFaces = mesh_.cells()[celli];
704 const face& f = mesh_.faces()[cFaces[i]];
708 if (pointToObjVert.
insert(f[fp], objVertI))
718 const face& f = mesh_.faces()[cFaces[i]];
722 label pointi = f[fp];
725 str <<
"l " << pointToObjVert[pointi]+1
726 <<
' ' << pointToObjVert[nexPointi]+1 <<
nl;
738 const bool searchForward,
739 const label wantedLevel
746 label pointi = f[fp];
748 if (pointLevel_[pointi] < wantedLevel)
750 dumpCell(mesh_.faceOwner()[facei]);
751 if (mesh_.isInternalFace(facei))
753 dumpCell(mesh_.faceNeighbour()[facei]);
759 <<
" startFp:" << startFp
760 <<
" wantedLevel:" << wantedLevel
763 else if (pointLevel_[pointi] == wantedLevel)
778 dumpCell(mesh_.faceOwner()[facei]);
779 if (mesh_.isInternalFace(facei))
781 dumpCell(mesh_.faceNeighbour()[facei]);
787 <<
" startFp:" << startFp
788 <<
" wantedLevel:" << wantedLevel
798 const face& f = mesh_.faces()[facei];
802 return pointLevel_[f[findMaxLevel(f)]];
806 label ownLevel = cellLevel_[mesh_.faceOwner()[facei]];
808 if (countAnchors(f, ownLevel) == 4)
812 else if (countAnchors(f, ownLevel+1) == 4)
824 void Foam::hexRef8::checkInternalOrientation
837 const vector a(compactFace.
area(compactPoints));
839 const vector dir(neiPt - ownPt);
844 <<
"cell:" << celli <<
" old face:" << facei
845 <<
" newFace:" << newFace <<
endl 846 <<
" coords:" << compactPoints
847 <<
" ownPt:" << ownPt
848 <<
" neiPt:" << neiPt
852 const vector fcToOwn(compactFace.
centre(compactPoints) - ownPt);
854 const scalar
s = (fcToOwn & a) / (dir & a);
856 if (s < 0.1 || s > 0.9)
859 <<
"cell:" << celli <<
" old face:" << facei
860 <<
" newFace:" << newFace <<
endl 861 <<
" coords:" << compactPoints
862 <<
" ownPt:" << ownPt
863 <<
" neiPt:" << neiPt
870 void Foam::hexRef8::checkBoundaryOrientation
876 const point& boundaryPt,
883 const vector a(compactFace.
area(compactPoints));
885 const vector dir(boundaryPt - ownPt);
890 <<
"cell:" << celli <<
" old face:" << facei
891 <<
" newFace:" << newFace
892 <<
" coords:" << compactPoints
893 <<
" ownPt:" << ownPt
894 <<
" boundaryPt:" << boundaryPt
898 const vector fcToOwn(compactFace.
centre(compactPoints) - ownPt);
900 const scalar
s = (fcToOwn&dir) /
magSqr(dir);
902 if (s < 0.7 || s > 1.3)
905 <<
"cell:" << celli <<
" old face:" << facei
906 <<
" newFace:" << newFace
907 <<
" coords:" << compactPoints
908 <<
" ownPt:" << ownPt
909 <<
" boundaryPt:" << boundaryPt
918 void Foam::hexRef8::insertEdgeSplit
926 if (p0 < mesh_.nPoints() && p1 < mesh_.nPoints())
930 if (edgeI != -1 && edgeMidPoint[edgeI] != -1)
932 verts.
append(edgeMidPoint[edgeI]);
954 const bool faceOrder,
955 const label edgeMidPointi,
956 const label anchorPointi,
957 const label faceMidPointi,
966 bool changed =
false;
967 bool haveTwoAnchors =
false;
971 if (edgeMidFnd == midPointToAnchors.
end())
973 midPointToAnchors.
insert(edgeMidPointi,
edge(anchorPointi, -1));
977 edge&
e = edgeMidFnd();
979 if (anchorPointi != e[0])
988 if (e[0] != -1 && e[1] != -1)
990 haveTwoAnchors =
true;
994 bool haveTwoFaceMids =
false;
998 if (faceMidFnd == midPointToFaceMids.
end())
1000 midPointToFaceMids.
insert(edgeMidPointi,
edge(faceMidPointi, -1));
1004 edge&
e = faceMidFnd();
1006 if (faceMidPointi != e[0])
1010 e[1] = faceMidPointi;
1015 if (e[0] != -1 && e[1] != -1)
1017 haveTwoFaceMids =
true;
1024 if (changed && haveTwoAnchors && haveTwoFaceMids)
1026 const edge& anchors = midPointToAnchors[edgeMidPointi];
1027 const edge& faceMids = midPointToFaceMids[edgeMidPointi];
1037 if (faceOrder == (mesh_.faceOwner()[facei] == celli))
1039 newFaceVerts.
append(faceMidPointi);
1050 newFaceVerts.
append(edgeMidPointi);
1060 newFaceVerts.
append(otherFaceMidPointi);
1061 newFaceVerts.
append(cellMidPoint[celli]);
1065 newFaceVerts.
append(otherFaceMidPointi);
1075 newFaceVerts.
append(edgeMidPointi);
1085 newFaceVerts.
append(faceMidPointi);
1086 newFaceVerts.
append(cellMidPoint[celli]);
1092 label anchorCell0 = getAnchorCell
1100 label anchorCell1 = getAnchorCell
1113 if (anchorCell0 < anchorCell1)
1118 ownPt = mesh_.points()[anchorPointi];
1119 neiPt = mesh_.points()[anchors.
otherVertex(anchorPointi)];
1128 ownPt = mesh_.points()[anchors.
otherVertex(anchorPointi)];
1129 neiPt = mesh_.points()[anchorPointi];
1136 if (anchorCell0 < anchorCell1)
1138 ownPt = mesh_.points()[anchorPointi];
1139 neiPt = mesh_.points()[anchors.
otherVertex(anchorPointi)];
1143 ownPt = mesh_.points()[anchors.
otherVertex(anchorPointi)];
1144 neiPt = mesh_.points()[anchorPointi];
1147 checkInternalOrientation
1158 return addInternalFace
1176 void Foam::hexRef8::createInternalFaces
1192 const cell& cFaces = mesh_.cells()[celli];
1193 const label cLevel = cellLevel_[celli];
1205 label nFacesAdded = 0;
1209 label facei = cFaces[i];
1211 const face& f = mesh_.faces()[facei];
1212 const labelList& fEdges = mesh_.faceEdges(facei, storage);
1217 label faceMidPointi = -1;
1219 label nAnchors = countAnchors(f, cLevel);
1227 label anchorFp = -1;
1231 if (pointLevel_[f[fp]] <= cLevel)
1239 label edgeMid = findLevel
1247 label faceMid = findLevel
1256 faceMidPointi = f[faceMid];
1258 else if (nAnchors == 4)
1263 faceMidPointi = faceMidPoint[facei];
1267 dumpCell(mesh_.faceOwner()[facei]);
1268 if (mesh_.isInternalFace(facei))
1270 dumpCell(mesh_.faceNeighbour()[facei]);
1274 <<
"nAnchors:" << nAnchors
1275 <<
" facei:" << facei
1287 label point0 = f[fp0];
1289 if (pointLevel_[point0] <= cLevel)
1298 label edgeMidPointi = -1;
1302 if (pointLevel_[f[fp1]] <= cLevel)
1305 label edgeI = fEdges[fp0];
1307 edgeMidPointi = edgeMidPoint[edgeI];
1309 if (edgeMidPointi == -1)
1313 const labelList& cPoints = mesh_.cellPoints(celli);
1316 <<
"cell:" << celli <<
" cLevel:" << cLevel
1317 <<
" cell points:" << cPoints
1320 <<
" face:" << facei
1324 <<
" faceAnchorLevel:" << faceAnchorLevel[facei]
1325 <<
" faceMidPoint:" << faceMidPoint[facei]
1326 <<
" faceMidPointi:" << faceMidPointi
1334 label edgeMid = findLevel(facei, f, fp1,
true, cLevel+1);
1336 edgeMidPointi = f[edgeMid];
1339 label newFacei = storeMidPointInfo
1362 if (nFacesAdded == 12)
1375 if (pointLevel_[f[fpMin1]] <= cLevel)
1378 label edgeI = fEdges[fpMin1];
1380 edgeMidPointi = edgeMidPoint[edgeI];
1382 if (edgeMidPointi == -1)
1386 const labelList& cPoints = mesh_.cellPoints(celli);
1389 <<
"cell:" << celli <<
" cLevel:" << cLevel
1390 <<
" cell points:" << cPoints
1393 <<
" face:" << facei
1397 <<
" faceAnchorLevel:" << faceAnchorLevel[facei]
1398 <<
" faceMidPoint:" << faceMidPoint[facei]
1399 <<
" faceMidPointi:" << faceMidPointi
1407 label edgeMid = findLevel
1416 edgeMidPointi = f[edgeMid];
1419 newFacei = storeMidPointInfo
1442 if (nFacesAdded == 12)
1450 if (nFacesAdded == 12)
1458 void Foam::hexRef8::walkFaceToMid
1463 const label startFp,
1467 const face& f = mesh_.faces()[facei];
1468 const labelList& fEdges = mesh_.faceEdges(facei);
1477 if (edgeMidPoint[fEdges[fp]] >= 0)
1479 faceVerts.
append(edgeMidPoint[fEdges[fp]]);
1484 if (pointLevel_[f[fp]] <= cLevel)
1490 else if (pointLevel_[f[fp]] == cLevel+1)
1497 else if (pointLevel_[f[fp]] == cLevel+2)
1507 void Foam::hexRef8::walkFaceFromMid
1512 const label startFp,
1516 const face& f = mesh_.faces()[facei];
1517 const labelList& fEdges = mesh_.faceEdges(facei);
1523 if (pointLevel_[f[fp]] <= cLevel)
1528 else if (pointLevel_[f[fp]] == cLevel+1)
1534 else if (pointLevel_[f[fp]] == cLevel+2)
1544 if (edgeMidPoint[fEdges[fp]] >= 0)
1546 faceVerts.
append(edgeMidPoint[fEdges[fp]]);
1562 Foam::label Foam::hexRef8::faceConsistentRefinement
1571 for (
label facei = 0; facei < mesh_.nInternalFaces(); facei++)
1573 label own = mesh_.faceOwner()[facei];
1574 label ownLevel = cellLevel_[own] + refineCell.
get(own);
1576 label nei = mesh_.faceNeighbour()[facei];
1577 label neiLevel = cellLevel_[nei] + refineCell.
get(nei);
1579 if (ownLevel > (neiLevel+1))
1583 refineCell.
set(nei);
1587 refineCell.
unset(own);
1591 else if (neiLevel > (ownLevel+1))
1595 refineCell.
set(own);
1599 refineCell.
unset(nei);
1608 labelList neiLevel(mesh_.nFaces()-mesh_.nInternalFaces());
1612 label own = mesh_.faceOwner()[i+mesh_.nInternalFaces()];
1614 neiLevel[i] = cellLevel_[own] + refineCell.
get(own);
1623 label own = mesh_.faceOwner()[i+mesh_.nInternalFaces()];
1624 label ownLevel = cellLevel_[own] + refineCell.
get(own);
1626 if (ownLevel > (neiLevel[i]+1))
1630 refineCell.
unset(own);
1634 else if (neiLevel[i] > (ownLevel+1))
1638 refineCell.
set(own);
1649 void Foam::hexRef8::checkWantedRefinementLevels
1657 refineCell.
set(cellsToRefine[i]);
1660 for (
label facei = 0; facei < mesh_.nInternalFaces(); facei++)
1662 label own = mesh_.faceOwner()[facei];
1663 label ownLevel = cellLevel_[own] + refineCell.
get(own);
1665 label nei = mesh_.faceNeighbour()[facei];
1666 label neiLevel = cellLevel_[nei] + refineCell.
get(nei);
1668 if (
mag(ownLevel-neiLevel) > 1)
1674 <<
" current level:" << cellLevel_[own]
1675 <<
" level after refinement:" << ownLevel
1677 <<
"neighbour cell:" << nei
1678 <<
" current level:" << cellLevel_[nei]
1679 <<
" level after refinement:" << neiLevel
1681 <<
"which does not satisfy 2:1 constraints anymore." 1688 labelList neiLevel(mesh_.nFaces()-mesh_.nInternalFaces());
1692 label own = mesh_.faceOwner()[i+mesh_.nInternalFaces()];
1694 neiLevel[i] = cellLevel_[own] + refineCell.
get(own);
1703 label facei = i + mesh_.nInternalFaces();
1705 label own = mesh_.faceOwner()[facei];
1706 label ownLevel = cellLevel_[own] + refineCell.
get(own);
1708 if (
mag(ownLevel - neiLevel[i]) > 1)
1710 label patchi = mesh_.boundaryMesh().whichPatch(facei);
1714 <<
"Celllevel does not satisfy 2:1 constraint." 1715 <<
" On coupled face " 1717 <<
" on patch " << patchi <<
" " 1718 << mesh_.boundaryMesh()[
patchi].name()
1719 <<
" owner cell " << own
1720 <<
" current level:" << cellLevel_[own]
1721 <<
" level after refinement:" << ownLevel
1723 <<
" (coupled) neighbour cell will get refinement " 1736 Pout<<
"hexRef8::setInstance(const fileName& inst) : " 1737 <<
"Resetting file instance to " << inst <<
endl;
1740 cellLevel_.instance() = inst;
1741 pointLevel_.instance() = inst;
1742 level0Edge_.instance() = inst;
1743 history_.instance() = inst;
1747 void Foam::hexRef8::collectLevelPoints
1756 if (pointLevel_[f[fp]] <= level)
1764 void Foam::hexRef8::collectLevelPoints
1774 label pointi = meshPoints[f[fp]];
1775 if (pointLevel_[pointi] <= level)
1784 bool Foam::hexRef8::matchHexShape
1787 const label cellLevel,
1791 const cell& cFaces = mesh_.cells()[celli];
1802 label facei = cFaces[i];
1803 const face& f = mesh_.faces()[facei];
1806 collectLevelPoints(f, cellLevel, verts);
1807 if (verts.
size() == 4)
1809 if (mesh_.faceOwner()[facei] != celli)
1820 if (quads.
size() < 6)
1826 label facei = cFaces[i];
1827 const face& f = mesh_.faces()[facei];
1835 collectLevelPoints(f, cellLevel, verts);
1836 if (verts.
size() == 1)
1842 label pointi = f[fp];
1843 if (pointLevel_[pointi] == cellLevel+1)
1846 pointFaces.find(pointi);
1847 if (iter != pointFaces.end())
1873 if (pFaces.
size() == 4)
1879 label facei = pFaces[pFacei];
1880 const face& f = mesh_.faces()[facei];
1881 if (mesh_.faceOwner()[facei] == celli)
1883 fourFaces[pFacei] =
f;
1898 if (edgeLoops.size() == 1)
1904 bigFace.meshPoints(),
1905 bigFace.edgeLoops()[0],
1910 if (verts.
size() == 4)
1921 return (quads.
size() == 6);
1936 mesh_.facesInstance(),
1949 mesh_.facesInstance(),
1962 mesh_.facesInstance(),
1974 "refinementHistory",
1975 mesh_.facesInstance(),
1982 (readHistory ? mesh_.nCells() : 0)
1984 faceRemover_(mesh_, great),
1985 savedPointLevel_(0),
2006 <<
"History enabled but number of visible cells " 2009 <<
" is not equal to the number of cells in the mesh " 2016 cellLevel_.
size() != mesh_.nCells()
2017 || pointLevel_.
size() != mesh_.nPoints()
2021 <<
"Restarted from inconsistent cellLevel or pointLevel files." 2025 <<
"Number of cells in mesh:" << mesh_.nCells()
2026 <<
" does not equal size of cellLevel:" << cellLevel_.
size() <<
endl 2027 <<
"Number of points in mesh:" << mesh_.nPoints()
2028 <<
" does not equal size of pointLevel:" << pointLevel_.
size()
2053 const scalar level0Edge
2062 mesh_.facesInstance(),
2075 mesh_.facesInstance(),
2088 mesh_.facesInstance(),
2097 (level0Edge >= 0 ? level0Edge : getLevel0EdgeLength())
2104 "refinementHistory",
2105 mesh_.facesInstance(),
2113 faceRemover_(mesh_, great),
2114 savedPointLevel_(0),
2120 <<
"History enabled but number of visible cells in it " 2122 <<
" is not equal to the number of cells in the mesh " 2128 cellLevel_.
size() != mesh_.nCells()
2129 || pointLevel_.
size() != mesh_.nPoints()
2133 <<
"Incorrect cellLevel or pointLevel size." <<
endl 2134 <<
"Number of cells in mesh:" << mesh_.nCells()
2135 <<
" does not equal size of cellLevel:" << cellLevel_.
size() <<
endl 2136 <<
"Number of points in mesh:" << mesh_.nPoints()
2137 <<
" does not equal size of pointLevel:" << pointLevel_.
size()
2160 const scalar level0Edge
2169 mesh_.facesInstance(),
2182 mesh_.facesInstance(),
2195 mesh_.facesInstance(),
2204 (level0Edge >= 0 ? level0Edge : getLevel0EdgeLength())
2211 "refinementHistory",
2212 mesh_.facesInstance(),
2222 faceRemover_(mesh_, great),
2223 savedPointLevel_(0),
2228 cellLevel_.
size() != mesh_.nCells()
2229 || pointLevel_.
size() != mesh_.nPoints()
2233 <<
"Incorrect cellLevel or pointLevel size." <<
endl 2234 <<
"Number of cells in mesh:" << mesh_.nCells()
2235 <<
" does not equal size of cellLevel:" << cellLevel_.
size() <<
endl 2236 <<
"Number of points in mesh:" << mesh_.nPoints()
2237 <<
" does not equal size of pointLevel:" << pointLevel_.
size()
2270 refineCell.
set(cellsToRefine[i]);
2275 label nChanged = faceConsistentRefinement(maxSet, refineCell);
2281 Pout<<
"hexRef8::consistentRefinement : Changed " << nChanged
2282 <<
" refinement levels due to 2:1 conflicts." 2296 forAll(refineCell, celli)
2298 if (refineCell.
get(celli))
2307 forAll(refineCell, celli)
2309 if (refineCell.
get(celli))
2311 newCellsToRefine[nRefined++] = celli;
2317 checkWantedRefinementLevels(newCellsToRefine);
2320 return newCellsToRefine;
2332 const label maxFaceDiff,
2335 const label maxPointDiff,
2339 const labelList& faceOwner = mesh_.faceOwner();
2340 const labelList& faceNeighbour = mesh_.faceNeighbour();
2343 if (maxFaceDiff <= 0)
2346 <<
"Illegal maxFaceDiff " << maxFaceDiff <<
nl 2365 forAll(allCellInfo, celli)
2371 maxFaceDiff*(cellLevel_[celli]+1),
2372 maxFaceDiff*cellLevel_[celli]
2379 label celli = cellsToRefine[i];
2381 allCellInfo[celli].count() = allCellInfo[celli].refinementCount();
2391 int dummyTrackData = 0;
2399 label facei = facesToCheck[i];
2401 if (allFaceInfo[facei].valid(dummyTrackData))
2405 <<
"Argument facesToCheck seems to have duplicate entries!" 2407 <<
"face:" << facei <<
" occurs at positions " 2415 if (mesh_.isInternalFace(facei))
2420 const refinementData& neiData = allCellInfo[faceNeighbour[facei]];
2423 label faceRefineCount;
2426 faceCount = neiData.
count() + maxFaceDiff;
2427 faceRefineCount = faceCount + maxFaceDiff;
2431 faceCount = ownData.
count() + maxFaceDiff;
2432 faceRefineCount = faceCount + maxFaceDiff;
2435 seedFaces.append(facei);
2436 seedFacesInfo.append
2444 allFaceInfo[facei] = seedFacesInfo.last();
2448 label faceCount = ownData.
count() + maxFaceDiff;
2449 label faceRefineCount = faceCount + maxFaceDiff;
2451 seedFaces.append(facei);
2452 seedFacesInfo.append
2460 allFaceInfo[facei] = seedFacesInfo.last();
2468 forAll(faceNeighbour, facei)
2471 if (!allFaceInfo[facei].valid(dummyTrackData))
2473 label own = faceOwner[facei];
2474 label nei = faceNeighbour[facei];
2478 if (allCellInfo[own].
count() > allCellInfo[nei].
count())
2480 allFaceInfo[facei].updateFace
2490 seedFacesInfo.append(allFaceInfo[facei]);
2492 else if (allCellInfo[own].
count() < allCellInfo[nei].
count())
2494 allFaceInfo[facei].updateFace
2503 seedFaces.append(facei);
2504 seedFacesInfo.append(allFaceInfo[facei]);
2512 for (
label facei = mesh_.nInternalFaces(); facei < mesh_.nFaces(); facei++)
2515 if (!allFaceInfo[facei].valid(dummyTrackData))
2517 label own = faceOwner[facei];
2530 seedFaces.append(facei);
2531 seedFacesInfo.append(faceData);
2549 Pout<<
"hexRef8::consistentSlowRefinement : Seeded " 2550 << seedFaces.size() <<
" faces between cells with different" 2551 <<
" refinement level." <<
endl;
2555 levelCalc.
setFaceInfo(seedFaces.shrink(), seedFacesInfo.shrink());
2557 seedFacesInfo.clear();
2560 levelCalc.
iterate(mesh_.globalData().nTotalFaces()+1);
2568 if (maxPointDiff == -1)
2576 labelList maxPointCount(mesh_.nPoints(), 0);
2578 forAll(maxPointCount, pointi)
2580 label& pLevel = maxPointCount[pointi];
2582 const labelList& pCells = mesh_.pointCells(pointi);
2586 pLevel =
max(pLevel, allCellInfo[pCells[i]].
count());
2607 label pointi = pointsToCheck[i];
2612 const labelList& pCells = mesh_.pointCells(pointi);
2616 label celli = pCells[pCelli];
2624 maxPointCount[pointi]
2625 > cellInfo.
count() + maxFaceDiff*maxPointDiff
2633 const cell& cFaces = mesh_.cells()[celli];
2637 label facei = cFaces[cFacei];
2650 if (faceData.
count() > allFaceInfo[facei].count())
2652 changedFacesInfo.insert(facei, faceData);
2659 label nChanged = changedFacesInfo.size();
2669 seedFaces.setCapacity(changedFacesInfo.size());
2670 seedFacesInfo.setCapacity(changedFacesInfo.size());
2674 seedFaces.append(iter.key());
2675 seedFacesInfo.append(iter());
2682 for (
label facei = 0; facei < mesh_.nInternalFaces(); facei++)
2684 label own = mesh_.faceOwner()[facei];
2687 + (allCellInfo[own].isRefined() ? 1 : 0);
2689 label nei = mesh_.faceNeighbour()[facei];
2692 + (allCellInfo[nei].isRefined() ? 1 : 0);
2694 if (
mag(ownLevel-neiLevel) > 1)
2700 <<
" current level:" << cellLevel_[own]
2701 <<
" current refData:" << allCellInfo[own]
2702 <<
" level after refinement:" << ownLevel
2704 <<
"neighbour cell:" << nei
2705 <<
" current level:" << cellLevel_[nei]
2706 <<
" current refData:" << allCellInfo[nei]
2707 <<
" level after refinement:" << neiLevel
2709 <<
"which does not satisfy 2:1 constraints anymore." <<
nl 2710 <<
"face:" << facei <<
" faceRefData:" << allFaceInfo[facei]
2719 labelList neiLevel(mesh_.nFaces()-mesh_.nInternalFaces());
2720 labelList neiCount(mesh_.nFaces()-mesh_.nInternalFaces());
2721 labelList neiRefCount(mesh_.nFaces()-mesh_.nInternalFaces());
2725 label own = mesh_.faceOwner()[i+mesh_.nInternalFaces()];
2726 neiLevel[i] = cellLevel_[own];
2727 neiCount[i] = allCellInfo[own].count();
2728 neiRefCount[i] = allCellInfo[own].refinementCount();
2739 label facei = i+mesh_.nInternalFaces();
2741 label own = mesh_.faceOwner()[facei];
2744 + (allCellInfo[own].isRefined() ? 1 : 0);
2748 + ((neiCount[i] >= neiRefCount[i]) ? 1 : 0);
2750 if (
mag(ownLevel - nbrLevel) > 1)
2753 label patchi = mesh_.boundaryMesh().whichPatch(facei);
2756 <<
"Celllevel does not satisfy 2:1 constraint." 2757 <<
" On coupled face " 2759 <<
" refData:" << allFaceInfo[facei]
2760 <<
" on patch " << patchi <<
" " 2761 << mesh_.boundaryMesh()[
patchi].name() <<
nl 2762 <<
"owner cell " << own
2763 <<
" current level:" << cellLevel_[own]
2764 <<
" current count:" << allCellInfo[own].count()
2765 <<
" current refCount:" 2766 << allCellInfo[own].refinementCount()
2767 <<
" level after refinement:" << ownLevel
2769 <<
"(coupled) neighbour cell" 2770 <<
" has current level:" << neiLevel[i]
2771 <<
" current count:" << neiCount[i]
2772 <<
" current refCount:" << neiRefCount[i]
2773 <<
" level after refinement:" << nbrLevel
2783 forAll(allCellInfo, celli)
2785 if (allCellInfo[celli].isRefined())
2795 forAll(allCellInfo, celli)
2797 if (allCellInfo[celli].isRefined())
2799 newCellsToRefine[nRefined++] = celli;
2805 Pout<<
"hexRef8::consistentSlowRefinement : From " 2806 << cellsToRefine.
size() <<
" to " << newCellsToRefine.
size()
2807 <<
" cells to refine." <<
endl;
2810 return newCellsToRefine;
2816 const label maxFaceDiff,
2821 const labelList& faceOwner = mesh_.faceOwner();
2822 const labelList& faceNeighbour = mesh_.faceNeighbour();
2824 if (maxFaceDiff <= 0)
2827 <<
"Illegal maxFaceDiff " << maxFaceDiff <<
nl 2846 int dummyTrackData = 0;
2852 label celli = cellsToRefine[i];
2857 mesh_.cellCentres()[celli],
2862 forAll(allCellInfo, celli)
2864 if (!allCellInfo[celli].valid(dummyTrackData))
2869 mesh_.cellCentres()[celli],
2885 label facei = facesToCheck[i];
2887 if (allFaceInfo[facei].valid(dummyTrackData))
2891 <<
"Argument facesToCheck seems to have duplicate entries!" 2893 <<
"face:" << facei <<
" occurs at positions " 2898 label own = faceOwner[facei];
2902 allCellInfo[own].valid(dummyTrackData)
2903 ? allCellInfo[own].originLevel()
2907 if (!mesh_.isInternalFace(facei))
2911 const point& fc = mesh_.faceCentres()[facei];
2920 allFaceInfo[facei].updateFace
2932 label nei = faceNeighbour[facei];
2936 allCellInfo[nei].valid(dummyTrackData)
2937 ? allCellInfo[nei].originLevel()
2941 if (ownLevel == neiLevel)
2944 allFaceInfo[facei].updateFace
2953 allFaceInfo[facei].updateFace
2966 allFaceInfo[facei].updateFace
2975 allFaceInfo[facei].updateFace
2987 seedFacesInfo.append(allFaceInfo[facei]);
2994 forAll(faceNeighbour, facei)
2997 if (!allFaceInfo[facei].valid(dummyTrackData))
2999 label own = faceOwner[facei];
3003 allCellInfo[own].valid(dummyTrackData)
3004 ? allCellInfo[own].originLevel()
3008 label nei = faceNeighbour[facei];
3012 allCellInfo[nei].valid(dummyTrackData)
3013 ? allCellInfo[nei].originLevel()
3017 if (ownLevel > neiLevel)
3021 allFaceInfo[facei].updateFace
3030 seedFacesInfo.append(allFaceInfo[facei]);
3032 else if (neiLevel > ownLevel)
3034 seedFaces.append(facei);
3035 allFaceInfo[facei].updateFace
3044 seedFacesInfo.append(allFaceInfo[facei]);
3050 seedFacesInfo.shrink();
3060 mesh_.globalData().nTotalCells()+1,
3101 label celli = cellsToRefine[i];
3103 allCellInfo[celli].originLevel() =
sizeof(
label)*8-2;
3104 allCellInfo[celli].origin() = cc[celli];
3111 forAll(allCellInfo, celli)
3113 label wanted = allCellInfo[celli].wantedLevel(cc[celli]);
3115 if (wanted > cellLevel_[celli]+1)
3117 refineCell.
set(celli);
3120 faceConsistentRefinement(
true, refineCell);
3124 label nChanged = faceConsistentRefinement(
true, refineCell);
3130 Pout<<
"hexRef8::consistentSlowRefinement2 : Changed " << nChanged
3131 <<
" refinement levels due to 2:1 conflicts." 3144 forAll(refineCell, celli)
3147 if (refineCell[celli])
3156 forAll(refineCell, celli)
3159 if (refineCell[celli])
3161 newCellsToRefine[nRefined++] = celli;
3167 Pout<<
"hexRef8::consistentSlowRefinement2 : From " 3168 << cellsToRefine.
size() <<
" to " << newCellsToRefine.
size()
3169 <<
" cells to refine." <<
endl;
3174 cellSet cellsIn(mesh_,
"cellsToRefineIn", cellsToRefine);
3175 Pout<<
"hexRef8::consistentSlowRefinement2 : writing " 3176 << cellsIn.
size() <<
" to cellSet " 3181 cellSet cellsOut(mesh_,
"cellsToRefineOut", newCellsToRefine);
3182 Pout<<
"hexRef8::consistentSlowRefinement2 : writing " 3183 << cellsOut.
size() <<
" to cellSet " 3190 forAll(newCellsToRefine, i)
3192 refineCell.
set(newCellsToRefine[i]);
3196 label nChanged = faceConsistentRefinement(
true, refineCell);
3201 mesh_,
"cellsToRefineOut2", newCellsToRefine.
size()
3203 forAll(refineCell, celli)
3205 if (refineCell.
get(celli))
3207 cellsOut2.insert(celli);
3210 Pout<<
"hexRef8::consistentSlowRefinement2 : writing " 3211 << cellsOut2.size() <<
" to cellSet " 3212 << cellsOut2.objectPath() <<
endl;
3218 forAll(refineCell, celli)
3220 if (refineCell.
get(celli) && !savedRefineCell.
get(celli))
3224 <<
"Cell:" << celli <<
" cc:" 3225 << mesh_.cellCentres()[celli]
3226 <<
" was not marked for refinement but does not obey" 3227 <<
" 2:1 constraints." 3234 return newCellsToRefine;
3247 Pout<<
"hexRef8::setRefinement :" 3248 <<
" Checking initial mesh just to make sure" <<
endl;
3257 savedPointLevel_.
clear();
3258 savedCellLevel_.
clear();
3263 forAll(cellLevel_, celli)
3265 newCellLevel.append(cellLevel_[celli]);
3268 forAll(pointLevel_, pointi)
3270 newPointLevel.append(pointLevel_[pointi]);
3276 Pout<<
"hexRef8::setRefinement :" 3277 <<
" Allocating " << cellLabels.
size() <<
" cell midpoints." 3285 labelList cellMidPoint(mesh_.nCells(), -1);
3289 label celli = cellLabels[i];
3291 label anchorPointi = mesh_.faces()[mesh_.cells()[celli][0]][0];
3297 mesh_.cellCentres()[celli],
3304 newPointLevel(cellMidPoint[celli]) = cellLevel_[celli]+1;
3310 cellSet splitCells(mesh_,
"splitCells", cellLabels.
size());
3312 forAll(cellMidPoint, celli)
3314 if (cellMidPoint[celli] >= 0)
3316 splitCells.insert(celli);
3320 Pout<<
"hexRef8::setRefinement : Dumping " << splitCells.size()
3321 <<
" cells to split to cellSet " << splitCells.objectPath()
3334 Pout<<
"hexRef8::setRefinement :" 3335 <<
" Allocating edge midpoints." 3344 labelList edgeMidPoint(mesh_.nEdges(), -1);
3347 forAll(cellMidPoint, celli)
3349 if (cellMidPoint[celli] >= 0)
3351 const labelList& cEdges = mesh_.cellEdges(celli);
3355 label edgeI = cEdges[i];
3357 const edge&
e = mesh_.edges()[edgeI];
3361 pointLevel_[e[0]] <= cellLevel_[celli]
3362 && pointLevel_[e[1]] <= cellLevel_[celli]
3365 edgeMidPoint[edgeI] = 12345;
3392 forAll(edgeMidPoint, edgeI)
3394 if (edgeMidPoint[edgeI] >= 0)
3397 edgeMids[edgeI] = mesh_.edges()[edgeI].centre(mesh_.points());
3405 point(-great, -great, -great)
3410 forAll(edgeMidPoint, edgeI)
3412 if (edgeMidPoint[edgeI] >= 0)
3417 const edge&
e = mesh_.edges()[edgeI];
3430 newPointLevel(edgeMidPoint[edgeI]) =
3443 OFstream str(mesh_.time().path()/
"edgeMidPoint.obj");
3445 forAll(edgeMidPoint, edgeI)
3447 if (edgeMidPoint[edgeI] >= 0)
3449 const edge&
e = mesh_.edges()[edgeI];
3455 Pout<<
"hexRef8::setRefinement :" 3456 <<
" Dumping edge centres to split to file " << str.
name() <<
endl;
3466 Pout<<
"hexRef8::setRefinement :" 3467 <<
" Allocating face midpoints." 3473 labelList faceAnchorLevel(mesh_.nFaces());
3475 for (
label facei = 0; facei < mesh_.nFaces(); facei++)
3477 faceAnchorLevel[facei] =
faceLevel(facei);
3482 labelList faceMidPoint(mesh_.nFaces(), -1);
3487 for (
label facei = 0; facei < mesh_.nInternalFaces(); facei++)
3489 if (faceAnchorLevel[facei] >= 0)
3491 label own = mesh_.faceOwner()[facei];
3492 label ownLevel = cellLevel_[own];
3493 label newOwnLevel = ownLevel + (cellMidPoint[own] >= 0 ? 1 : 0);
3495 label nei = mesh_.faceNeighbour()[facei];
3496 label neiLevel = cellLevel_[nei];
3497 label newNeiLevel = neiLevel + (cellMidPoint[nei] >= 0 ? 1 : 0);
3501 newOwnLevel > faceAnchorLevel[facei]
3502 || newNeiLevel > faceAnchorLevel[facei]
3505 faceMidPoint[facei] = 12345;
3518 labelList newNeiLevel(mesh_.nFaces()-mesh_.nInternalFaces());
3522 label own = mesh_.faceOwner()[i+mesh_.nInternalFaces()];
3523 label ownLevel = cellLevel_[own];
3524 label newOwnLevel = ownLevel + (cellMidPoint[own] >= 0 ? 1 : 0);
3526 newNeiLevel[i] = newOwnLevel;
3536 label facei = i+mesh_.nInternalFaces();
3538 if (faceAnchorLevel[facei] >= 0)
3540 label own = mesh_.faceOwner()[facei];
3541 label ownLevel = cellLevel_[own];
3542 label newOwnLevel = ownLevel + (cellMidPoint[own] >= 0 ? 1 : 0);
3546 newOwnLevel > faceAnchorLevel[facei]
3547 || newNeiLevel[i] > faceAnchorLevel[facei]
3550 faceMidPoint[facei] = 12345;
3575 mesh_.nFaces()-mesh_.nInternalFaces(),
3576 point(-great, -great, -great)
3581 label facei = i+mesh_.nInternalFaces();
3583 if (faceMidPoint[facei] >= 0)
3585 bFaceMids[i] = mesh_.faceCentres()[facei];
3595 forAll(faceMidPoint, facei)
3597 if (faceMidPoint[facei] >= 0)
3602 const face& f = mesh_.faces()[facei];
3609 facei < mesh_.nInternalFaces()
3610 ? mesh_.faceCentres()[facei]
3611 : bFaceMids[facei-mesh_.nInternalFaces()]
3621 newPointLevel(faceMidPoint[facei]) = faceAnchorLevel[facei]+1;
3628 faceSet splitFaces(mesh_,
"splitFaces", cellLabels.
size());
3630 forAll(faceMidPoint, facei)
3632 if (faceMidPoint[facei] >= 0)
3634 splitFaces.insert(facei);
3638 Pout<<
"hexRef8::setRefinement : Dumping " << splitFaces.size()
3639 <<
" faces to split to faceSet " << splitFaces.objectPath() <<
endl;
3660 Pout<<
"hexRef8::setRefinement :" 3661 <<
" Finding cell anchorPoints (8 per cell)" 3672 labelList nAnchorPoints(mesh_.nCells(), 0);
3674 forAll(cellMidPoint, celli)
3676 if (cellMidPoint[celli] >= 0)
3678 cellAnchorPoints[celli].
setSize(8);
3682 forAll(pointLevel_, pointi)
3684 const labelList& pCells = mesh_.pointCells(pointi);
3688 label celli = pCells[pCelli];
3692 cellMidPoint[celli] >= 0
3693 && pointLevel_[pointi] <= cellLevel_[celli]
3696 if (nAnchorPoints[celli] == 8)
3701 <<
" of level " << cellLevel_[celli]
3702 <<
" uses more than 8 points of equal or" 3703 <<
" lower level" <<
nl 3704 <<
"Points so far:" << cellAnchorPoints[celli]
3708 cellAnchorPoints[celli][nAnchorPoints[celli]++] = pointi;
3713 forAll(cellMidPoint, celli)
3715 if (cellMidPoint[celli] >= 0)
3717 if (nAnchorPoints[celli] != 8)
3721 const labelList& cPoints = mesh_.cellPoints(celli);
3725 <<
" of level " << cellLevel_[celli]
3726 <<
" does not seem to have 8 points of equal or" 3727 <<
" lower level" <<
endl 3728 <<
"cellPoints:" << cPoints <<
endl 3743 Pout<<
"hexRef8::setRefinement :" 3744 <<
" Adding cells (1 per anchorPoint)" 3751 forAll(cellAnchorPoints, celli)
3753 const labelList& cAnchors = cellAnchorPoints[celli];
3755 if (cAnchors.
size() == 8)
3757 labelList& cAdded = cellAddedCells[celli];
3764 newCellLevel[celli] = cellLevel_[celli]+1;
3767 for (
label i = 1; i < 8; i++)
3777 mesh_.cellZones().whichZone(celli)
3781 newCellLevel(cAdded[i]) = cellLevel_[celli]+1;
3796 Pout<<
"hexRef8::setRefinement :" 3797 <<
" Marking faces to be handled" 3805 forAll(cellMidPoint, celli)
3807 if (cellMidPoint[celli] >= 0)
3809 const cell& cFaces = mesh_.cells()[celli];
3813 affectedFace.set(cFaces[i]);
3818 forAll(faceMidPoint, facei)
3820 if (faceMidPoint[facei] >= 0)
3822 affectedFace.set(facei);
3826 forAll(edgeMidPoint, edgeI)
3828 if (edgeMidPoint[edgeI] >= 0)
3830 const labelList& eFaces = mesh_.edgeFaces(edgeI);
3834 affectedFace.set(eFaces[i]);
3846 Pout<<
"hexRef8::setRefinement : Splitting faces" <<
endl;
3849 forAll(faceMidPoint, facei)
3851 if (faceMidPoint[facei] >= 0 && affectedFace.get(facei))
3857 const face& f = mesh_.faces()[facei];
3861 bool modifiedFace =
false;
3863 label anchorLevel = faceAnchorLevel[facei];
3869 label pointi = f[fp];
3871 if (pointLevel_[pointi] <= anchorLevel)
3877 faceVerts.
append(pointi);
3893 faceVerts.
append(faceMidPoint[facei]);
3926 if (mesh_.isInternalFace(facei))
3928 label oldOwn = mesh_.faceOwner()[facei];
3929 label oldNei = mesh_.faceNeighbour()[facei];
3931 checkInternalOrientation
3936 mesh_.cellCentres()[oldOwn],
3937 mesh_.cellCentres()[oldNei],
3943 label oldOwn = mesh_.faceOwner()[facei];
3945 checkBoundaryOrientation
3950 mesh_.cellCentres()[oldOwn],
3951 mesh_.faceCentres()[facei],
3960 modifiedFace =
true;
3962 modFace(meshMod, facei, newFace, own, nei);
3966 addFace(meshMod, facei, newFace, own, nei);
3972 affectedFace.unset(facei);
3982 Pout<<
"hexRef8::setRefinement :" 3983 <<
" Adding edge splits to unsplit faces" 3990 forAll(edgeMidPoint, edgeI)
3992 if (edgeMidPoint[edgeI] >= 0)
3996 const labelList& eFaces = mesh_.edgeFaces(edgeI, eFacesStorage);
4000 label facei = eFaces[i];
4002 if (faceMidPoint[facei] < 0 && affectedFace.get(facei))
4006 const face& f = mesh_.faces()[facei];
4007 const labelList& fEdges = mesh_.faceEdges
4017 newFaceVerts.append(f[fp]);
4019 label edgeI = fEdges[fp];
4021 if (edgeMidPoint[edgeI] >= 0)
4023 newFaceVerts.
append(edgeMidPoint[edgeI]);
4032 label anchorFp = findMinLevel(f);
4049 if (mesh_.isInternalFace(facei))
4051 label oldOwn = mesh_.faceOwner()[facei];
4052 label oldNei = mesh_.faceNeighbour()[facei];
4054 checkInternalOrientation
4059 mesh_.cellCentres()[oldOwn],
4060 mesh_.cellCentres()[oldNei],
4066 label oldOwn = mesh_.faceOwner()[facei];
4068 checkBoundaryOrientation
4073 mesh_.cellCentres()[oldOwn],
4074 mesh_.faceCentres()[facei],
4080 modFace(meshMod, facei, newFace, own, nei);
4083 affectedFace.unset(facei);
4095 Pout<<
"hexRef8::setRefinement :" 4096 <<
" Changing owner/neighbour for otherwise unaffected faces" 4100 forAll(affectedFace, facei)
4102 if (affectedFace.get(facei))
4104 const face& f = mesh_.faces()[facei];
4108 label anchorFp = findMinLevel(f);
4122 modFace(meshMod, facei, f, own, nei);
4125 affectedFace.unset(facei);
4140 Pout<<
"hexRef8::setRefinement :" 4141 <<
" Create new internal faces for split cells" 4145 forAll(cellMidPoint, celli)
4147 if (cellMidPoint[celli] >= 0)
4172 forAll(cellMidPoint, celli)
4174 if (cellMidPoint[celli] >= 0)
4176 minPointi =
min(minPointi, cellMidPoint[celli]);
4177 maxPointi =
max(maxPointi, cellMidPoint[celli]);
4180 forAll(faceMidPoint, facei)
4182 if (faceMidPoint[facei] >= 0)
4184 minPointi =
min(minPointi, faceMidPoint[facei]);
4185 maxPointi =
max(maxPointi, faceMidPoint[facei]);
4188 forAll(edgeMidPoint, edgeI)
4190 if (edgeMidPoint[edgeI] >= 0)
4192 minPointi =
min(minPointi, edgeMidPoint[edgeI]);
4193 maxPointi =
max(maxPointi, edgeMidPoint[edgeI]);
4197 if (minPointi !=
labelMax && minPointi != mesh_.nPoints())
4200 <<
"Added point labels not consecutive to existing mesh points." 4202 <<
"mesh_.nPoints():" << mesh_.nPoints()
4203 <<
" minPointi:" << minPointi
4204 <<
" maxPointi:" << maxPointi
4209 pointLevel_.
transfer(newPointLevel);
4224 Pout<<
"hexRef8::setRefinement :" 4225 <<
" Updating refinement history to " << cellLevel_.
size()
4226 <<
" cells" <<
endl;
4232 forAll(cellAddedCells, celli)
4234 const labelList& addedCells = cellAddedCells[celli];
4236 if (addedCells.
size())
4250 label celli = cellLabels[i];
4252 refinedCells[i].
transfer(cellAddedCells[celli]);
4255 return refinedCells;
4266 savedPointLevel_.
resize(2*pointsToStore.
size());
4269 label pointi = pointsToStore[i];
4270 savedPointLevel_.
insert(pointi, pointLevel_[pointi]);
4273 savedCellLevel_.
resize(2*cellsToStore.
size());
4276 label celli = cellsToStore[i];
4277 savedCellLevel_.
insert(celli, cellLevel_[celli]);
4289 updateMesh(map, dummyMap, dummyMap, dummyMap);
4307 Pout<<
"hexRef8::updateMesh :" 4308 <<
" Updating various lists" 4317 Pout<<
"hexRef8::updateMesh :" 4320 <<
" nCells:" << mesh_.nCells()
4322 <<
" cellLevel_:" << cellLevel_.
size()
4325 <<
" nPoints:" << mesh_.nPoints()
4327 <<
" pointLevel_:" << pointLevel_.
size()
4331 if (reverseCellMap.
size() == cellLevel_.
size())
4337 reorder(reverseCellMap, mesh_.nCells(), -1, cellLevel_);
4345 forAll(cellMap, newCelli)
4347 label oldCelli = cellMap[newCelli];
4351 newCellLevel[newCelli] = -1;
4355 newCellLevel[newCelli] = cellLevel_[oldCelli];
4365 label newCelli = iter.key();
4366 label storedCelli = iter();
4370 if (fnd == savedCellLevel_.
end())
4373 <<
"Problem : trying to restore old value for new cell " 4374 << newCelli <<
" but cannot find old cell " << storedCelli
4375 <<
" in map of stored values " << savedCellLevel_
4378 cellLevel_[newCelli] = fnd();
4399 if (reversePointMap.
size() == pointLevel_.
size())
4402 reorder(reversePointMap, mesh_.nPoints(), -1, pointLevel_);
4415 if (oldPointi == -1)
4428 newPointLevel[
newPointi] = pointLevel_[oldPointi];
4431 pointLevel_.
transfer(newPointLevel);
4439 label storedPointi = iter();
4443 if (fnd == savedPointLevel_.
end())
4446 <<
"Problem : trying to restore old value for new point " 4447 << newPointi <<
" but cannot find old point " 4449 <<
" in map of stored values " << savedPointLevel_
4481 cellShapesPtr_.clear();
4496 Pout<<
"hexRef8::subset :" 4497 <<
" Updating various lists" 4504 <<
"Subsetting will not work in combination with unrefinement." 4506 <<
"Proceed at your own risk." <<
endl;
4514 forAll(cellMap, newCelli)
4516 newCellLevel[newCelli] = cellLevel_[cellMap[newCelli]];
4525 <<
"cellLevel_ contains illegal value -1 after mapping:" 4540 pointLevel_.
transfer(newPointLevel);
4546 <<
"pointLevel_ contains illegal value -1 after mapping:" 4555 history_.
subset(pointMap, faceMap, cellMap);
4565 cellShapesPtr_.clear();
4574 Pout<<
"hexRef8::distribute :" 4575 <<
" Updating various lists" 4594 cellShapesPtr_.clear();
4600 const scalar smallDim = 1
e-6 * mesh_.bounds().mag();
4604 Pout<<
"hexRef8::checkMesh : Using matching tolerance smallDim:" 4605 << smallDim <<
endl;
4615 labelList nei(mesh_.nFaces()-mesh_.nInternalFaces());
4618 nei[i] = mesh_.faceOwner()[i+mesh_.nInternalFaces()];
4641 label own = mesh_.faceOwner()[facei];
4642 label bFacei = facei-mesh_.nInternalFaces();
4648 <<
"Faces do not seem to be correct across coupled" 4649 <<
" boundaries" <<
endl 4650 <<
"Coupled face " << facei
4651 <<
" between owner " << own
4652 <<
" on patch " << pp.
name()
4653 <<
" and coupled neighbour " << nei[bFacei]
4654 <<
" has two faces connected to it:" 4670 scalarField neiFaceAreas(mesh_.nFaces()-mesh_.nInternalFaces());
4673 neiFaceAreas[i] = mesh_.magFaceAreas()[i+mesh_.nInternalFaces()];
4681 label facei = i+mesh_.nInternalFaces();
4683 const scalar magArea = mesh_.magFaceAreas()[facei];
4685 if (
mag(magArea - neiFaceAreas[i]) > smallDim)
4687 const face& f = mesh_.faces()[facei];
4688 label patchi = mesh_.boundaryMesh().whichPatch(facei);
4690 dumpCell(mesh_.faceOwner()[facei]);
4693 <<
"Faces do not seem to be correct across coupled" 4694 <<
" boundaries" <<
endl 4695 <<
"Coupled face " << facei
4696 <<
" on patch " << patchi
4697 <<
" " << mesh_.boundaryMesh()[
patchi].
name()
4699 <<
" has face area:" << magArea
4700 <<
" (coupled) neighbour face area differs:" 4702 <<
" to within tolerance " << smallDim
4712 labelList nVerts(mesh_.nFaces()-mesh_.nInternalFaces());
4716 nVerts[i] = mesh_.faces()[i+mesh_.nInternalFaces()].size();
4724 label facei = i+mesh_.nInternalFaces();
4726 const face& f = mesh_.faces()[facei];
4728 if (f.
size() != nVerts[i])
4730 dumpCell(mesh_.faceOwner()[facei]);
4732 label patchi = mesh_.boundaryMesh().whichPatch(facei);
4735 <<
"Faces do not seem to be correct across coupled" 4736 <<
" boundaries" <<
endl 4737 <<
"Coupled face " << facei
4738 <<
" on patch " << patchi
4739 <<
" " << mesh_.boundaryMesh()[
patchi].
name()
4741 <<
" has size:" << f.
size()
4742 <<
" (coupled) neighbour face has size:" 4754 pointField anchorPoints(mesh_.nFaces()-mesh_.nInternalFaces());
4758 label facei = i+mesh_.nInternalFaces();
4759 const point& fc = mesh_.faceCentres()[facei];
4760 const face& f = mesh_.faces()[facei];
4761 const vector anchorVec(mesh_.points()[f[0]] - fc);
4763 anchorPoints[i] = anchorVec;
4773 label facei = i+mesh_.nInternalFaces();
4774 const point& fc = mesh_.faceCentres()[facei];
4775 const face& f = mesh_.faces()[facei];
4776 const vector anchorVec(mesh_.points()[f[0]] - fc);
4778 if (
mag(anchorVec - anchorPoints[i]) > smallDim)
4780 dumpCell(mesh_.faceOwner()[facei]);
4782 label patchi = mesh_.boundaryMesh().whichPatch(facei);
4785 <<
"Faces do not seem to be correct across coupled" 4786 <<
" boundaries" <<
endl 4787 <<
"Coupled face " << facei
4788 <<
" on patch " << patchi
4789 <<
" " << mesh_.boundaryMesh()[
patchi].
name()
4791 <<
" has anchor vector:" << anchorVec
4792 <<
" (coupled) neighbour face anchor vector differs:" 4794 <<
" to within tolerance " << smallDim
4802 Pout<<
"hexRef8::checkMesh : Returning" <<
endl;
4809 const label maxPointDiff,
4815 Pout<<
"hexRef8::checkRefinementLevels :" 4816 <<
" Checking 2:1 refinement level" <<
endl;
4821 cellLevel_.
size() != mesh_.nCells()
4822 || pointLevel_.
size() != mesh_.nPoints()
4826 <<
"cellLevel size should be number of cells" 4827 <<
" and pointLevel size should be number of points."<<
nl 4828 <<
"cellLevel:" << cellLevel_.
size()
4829 <<
" mesh.nCells():" << mesh_.nCells() <<
nl 4830 <<
"pointLevel:" << pointLevel_.
size()
4831 <<
" mesh.nPoints():" << mesh_.nPoints()
4841 for (
label facei = 0; facei < mesh_.nInternalFaces(); facei++)
4843 label own = mesh_.faceOwner()[facei];
4844 label nei = mesh_.faceNeighbour()[facei];
4846 if (
mag(cellLevel_[own] - cellLevel_[nei]) > 1)
4852 <<
"Celllevel does not satisfy 2:1 constraint." <<
nl 4853 <<
"On face " << facei <<
" owner cell " << own
4854 <<
" has refinement " << cellLevel_[own]
4855 <<
" neighbour cell " << nei <<
" has refinement " 4862 labelList neiLevel(mesh_.nFaces()-mesh_.nInternalFaces());
4866 label own = mesh_.faceOwner()[i+mesh_.nInternalFaces()];
4868 neiLevel[i] = cellLevel_[own];
4876 label facei = i+mesh_.nInternalFaces();
4878 label own = mesh_.faceOwner()[facei];
4880 if (
mag(cellLevel_[own] - neiLevel[i]) > 1)
4884 label patchi = mesh_.boundaryMesh().whichPatch(facei);
4887 <<
"Celllevel does not satisfy 2:1 constraint." 4888 <<
" On coupled face " << facei
4889 <<
" on patch " << patchi <<
" " 4890 << mesh_.boundaryMesh()[
patchi].name()
4891 <<
" owner cell " << own <<
" has refinement " 4893 <<
" (coupled) neighbour cell has refinement " 4916 forAll(syncPointLevel, pointi)
4918 if (pointLevel_[pointi] != syncPointLevel[pointi])
4921 <<
"PointLevel is not consistent across coupled patches." 4923 <<
"point:" << pointi <<
" coord:" << mesh_.points()[pointi]
4924 <<
" has level " << pointLevel_[pointi]
4925 <<
" whereas the coupled point has level " 4926 << syncPointLevel[pointi]
4934 if (maxPointDiff != -1)
4937 labelList maxPointLevel(mesh_.nPoints(), 0);
4939 forAll(maxPointLevel, pointi)
4941 const labelList& pCells = mesh_.pointCells(pointi);
4943 label& pLevel = maxPointLevel[pointi];
4947 pLevel =
max(pLevel, cellLevel_[pCells[i]]);
4963 label pointi = pointsToCheck[i];
4965 const labelList& pCells = mesh_.pointCells(pointi);
4969 label celli = pCells[i];
4973 mag(cellLevel_[celli]-maxPointLevel[pointi])
4980 <<
"Too big a difference between" 4981 <<
" point-connected cells." <<
nl 4983 <<
" cellLevel:" << cellLevel_[celli]
4984 <<
" uses point:" << pointi
4985 <<
" coord:" << mesh_.points()[pointi]
4986 <<
" which is also used by a cell with level:" 4987 << maxPointLevel[pointi]
5062 if (cellShapesPtr_.empty())
5066 Pout<<
"hexRef8::cellShapes() : calculating splitHex cellShapes." 5067 <<
" cellLevel:" << cellLevel_.
size()
5068 <<
" pointLevel:" << pointLevel_.
size()
5075 label nSplitHex = 0;
5076 label nUnrecognised = 0;
5078 forAll(cellLevel_, celli)
5080 if (meshShapes[celli].model().index() == 0)
5082 label level = cellLevel_[celli];
5086 bool haveQuads = matchHexShape
5096 cellShapesPtr_()[celli] = degenerateMatcher::match(faces);
5107 Pout<<
"hexRef8::cellShapes() :" 5108 <<
" nCells:" << mesh_.nCells() <<
" of which" <<
nl 5109 <<
" primitive:" << (mesh_.nCells()-nSplitHex-nUnrecognised)
5111 <<
" split-hex:" << nSplitHex <<
nl 5112 <<
" poly :" << nUnrecognised <<
nl 5116 return cellShapesPtr_();
5129 Pout<<
"hexRef8::getSplitPoints :" 5130 <<
" Calculating unrefineable points" <<
endl;
5137 <<
"Only call if constructed with history capability" 5145 labelList splitMaster(mesh_.nPoints(), -1);
5146 labelList splitMasterLevel(mesh_.nPoints(), 0);
5151 for (
label pointi = 0; pointi < mesh_.nPoints(); pointi++)
5153 const labelList& pCells = mesh_.pointCells(pointi);
5155 if (pCells.
size() != 8)
5157 splitMaster[pointi] = -2;
5164 forAll(visibleCells, celli)
5166 const labelList& cPoints = mesh_.cellPoints(celli);
5168 if (visibleCells[celli] != -1 && history_.
parentIndex(celli) >= 0)
5175 label pointi = cPoints[i];
5177 label masterCelli = splitMaster[pointi];
5179 if (masterCelli == -1)
5186 splitMaster[pointi] = parentIndex;
5187 splitMasterLevel[pointi] = cellLevel_[celli] - 1;
5189 else if (masterCelli == -2)
5195 (masterCelli != parentIndex)
5196 || (splitMasterLevel[pointi] != cellLevel_[celli] - 1)
5201 splitMaster[pointi] = -2;
5210 label pointi = cPoints[i];
5212 splitMaster[pointi] = -2;
5220 label facei = mesh_.nInternalFaces();
5221 facei < mesh_.nFaces();
5225 const face& f = mesh_.faces()[facei];
5229 splitMaster[f[fp]] = -2;
5236 label nSplitPoints = 0;
5238 forAll(splitMaster, pointi)
5240 if (splitMaster[pointi] >= 0)
5249 forAll(splitMaster, pointi)
5251 if (splitMaster[pointi] >= 0)
5253 splitPoints[nSplitPoints++] = pointi;
5331 Pout<<
"hexRef8::consistentUnrefinement :" 5332 <<
" Determining 2:1 consistent unrefinement" <<
endl;
5338 <<
"maxSet not implemented yet." 5350 forAll(pointsToUnrefine, i)
5352 label pointi = pointsToUnrefine[i];
5354 unrefinePoint.set(pointi);
5365 forAll(unrefinePoint, pointi)
5367 if (unrefinePoint.get(pointi))
5369 const labelList& pCells = mesh_.pointCells(pointi);
5373 unrefineCell.set(pCells[j]);
5386 for (
label facei = 0; facei < mesh_.nInternalFaces(); facei++)
5388 label own = mesh_.faceOwner()[facei];
5389 label ownLevel = cellLevel_[own] - unrefineCell.get(own);
5391 label nei = mesh_.faceNeighbour()[facei];
5392 label neiLevel = cellLevel_[nei] - unrefineCell.get(nei);
5394 if (ownLevel < (neiLevel-1))
5401 unrefineCell.set(nei);
5412 if (unrefineCell.get(own) == 0)
5418 unrefineCell.unset(own);
5422 else if (neiLevel < (ownLevel-1))
5426 unrefineCell.set(own);
5430 if (unrefineCell.get(nei) == 0)
5436 unrefineCell.unset(nei);
5444 labelList neiLevel(mesh_.nFaces()-mesh_.nInternalFaces());
5448 label own = mesh_.faceOwner()[i+mesh_.nInternalFaces()];
5450 neiLevel[i] = cellLevel_[own] - unrefineCell.get(own);
5458 label facei = i+mesh_.nInternalFaces();
5459 label own = mesh_.faceOwner()[facei];
5460 label ownLevel = cellLevel_[own] - unrefineCell.get(own);
5462 if (ownLevel < (neiLevel[i]-1))
5466 if (unrefineCell.get(own) == 0)
5472 unrefineCell.unset(own);
5476 else if (neiLevel[i] < (ownLevel-1))
5480 if (unrefineCell.get(own) == 1)
5486 unrefineCell.set(own);
5496 Pout<<
"hexRef8::consistentUnrefinement :" 5497 <<
" Changed " << nChanged
5498 <<
" refinement levels due to 2:1 conflicts." 5512 forAll(unrefinePoint, pointi)
5514 if (unrefinePoint.get(pointi))
5516 const labelList& pCells = mesh_.pointCells(pointi);
5520 if (!unrefineCell.get(pCells[j]))
5522 unrefinePoint.unset(pointi);
5534 forAll(unrefinePoint, pointi)
5536 if (unrefinePoint.get(pointi))
5545 forAll(unrefinePoint, pointi)
5547 if (unrefinePoint.get(pointi))
5549 newPointsToUnrefine[nSet++] = pointi;
5553 return newPointsToUnrefine;
5566 <<
"Only call if constructed with history capability" 5572 Pout<<
"hexRef8::setUnrefinement :" 5573 <<
" Checking initial mesh just to make sure" <<
endl;
5577 forAll(cellLevel_, celli)
5579 if (cellLevel_[celli] < 0)
5582 <<
"Illegal cell level " << cellLevel_[celli]
5583 <<
" for cell " << celli
5590 pointSet pSet(mesh_,
"splitPoints", splitPointLabels);
5593 cellSet cSet(mesh_,
"splitPointCells", splitPointLabels.
size());
5595 forAll(splitPointLabels, i)
5597 const labelList& pCells = mesh_.pointCells(splitPointLabels[i]);
5601 cSet.insert(pCells[j]);
5606 Pout<<
"hexRef8::setRefinement : Dumping " << pSet.
size()
5608 << cSet.size() <<
" cells for unrefinement to" <<
nl 5610 <<
" cellSet " << cSet.objectPath()
5622 forAll(splitPointLabels, i)
5628 splitFaces.insert(pFaces[j]);
5642 if (facesToRemove.
size() != splitFaces.size())
5645 <<
"Initial set of split points to unrefine does not" 5646 <<
" seem to be consistent or not mid points of refined cells" 5655 forAll(splitPointLabels, i)
5657 label pointi = splitPointLabels[i];
5661 const labelList& pCells = mesh_.pointCells(pointi);
5664 if (pCells.
size() != 8)
5667 <<
"splitPoint " << pointi
5668 <<
" should have 8 cells using it. It has " << pCells
5681 label celli = pCells[j];
5683 label region = cellRegion[celli];
5688 <<
"Initial set of split points to unrefine does not" 5689 <<
" seem to be consistent or not mid points" 5690 <<
" of refined cells" <<
nl 5691 <<
"cell:" << celli <<
" on splitPoint " << pointi
5692 <<
" has no region to be merged into" 5696 if (masterCelli != cellRegionMaster[region])
5699 <<
"cell:" << celli <<
" on splitPoint:" << pointi
5700 <<
" in region " << region
5701 <<
" has master:" << cellRegionMaster[region]
5702 <<
" which is not the lowest numbered cell" 5703 <<
" among the pointCells:" << pCells
5723 forAll(splitPointLabels, i)
5725 label pointi = splitPointLabels[i];
5727 const labelList& pCells = mesh_.pointCells(pointi);
5733 cellLevel_[pCells[j]]--;
5749 cellLevel_.
write(write)
5750 && pointLevel_.
write(write)
5751 && level0Edge_.
write(write);
5755 writeOk = writeOk && history_.
write(write);
fileCheckTypes
Enumeration defining the file checking options.
void distribute(const mapDistributePolyMesh &)
Update local numbering for mesh redistribution.
virtual const fileName & name() const
Return the name of the stream.
static void listCombineScatter(const List< commsStruct > &comms, List< T > &Value, const int tag, const label comm)
Scatter data. Reverse of combineGather.
#define forAll(list, i)
Loop across all elements in list.
const labelList & reversePointMap() const
Reverse point map.
virtual Ostream & write(const char)=0
Write character.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
const word & name() const
Return name.
A class for handling file names.
label nOldCells() const
Number of old cells.
const labelList & cellMap() const
Old cell map.
virtual label iterate(const label maxIter)
Iterate until no changes or maxIter reached. Returns actual.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Class describing modification of a face.
unsigned int get(const label) const
Get value at index I.
static iteratorEnd end()
iteratorEnd set to beyond the end of any HashTable
A face is a list of labels corresponding to mesh vertices.
void distributePointData(List< T > &lst) const
Distribute list of point data.
void setFaceInfo(const labelList &changedFaces, const List< Type > &changedFacesInfo)
Set initial changed faces.
void operator()(label &x, const label y) const
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
void setUnrefinement(const labelList &splitPointLabels, polyTopoChange &)
Remove some refinement. Needs to be supplied output of.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
label rcIndex(const label i) const
Return the reverse circular index, i.e. the previous index.
bool active() const
Is there unrefinement history?
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.
static word meshSubDir
Return the mesh sub-directory name (usually "polyMesh")
void size(const label)
Override size to be inconsistent with allocated storage.
const boolList & flipMap() const
Return face flip map.
label fcIndex(const label i) const
Return the forward circular index, i.e. the next index.
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...
bool headerOk()
Read and check header info.
label count(const ListType &l, typename ListType::const_reference x)
Count the number of occurrences of a value in a list.
void checkMesh() const
Debug: Check coupled mesh for correctness.
void updateMesh(const mapPolyMesh &)
Force recalculation of locally stored data on topological change.
void storeData(const labelList &pointsToStore, const labelList &facesToStore, const labelList &cellsToStore)
Signal points/face/cells for which to store data.
labelList identity(const label len)
Create identity map (map[i] == i) of given length.
Class containing mesh-to-mesh mapping information after a mesh distribution where we send parts of me...
static vector area(const PointField &ps)
Return vector area given face points.
labelList consistentSlowRefinement2(const label maxFaceDiff, const labelList &cellsToRefine, const labelList &facesToCheck) const
Like consistentSlowRefinement but uses different meshWave.
Class containing data for point addition.
label whichFace(const label globalCellID) const
Helper function to re-direct to zone::localID(...)
labelListList setRefinement(const labelList &cells, polyTopoChange &)
Insert refinement. All selected cells will be split into 8.
label otherVertex(const label a) const
Given one vertex, return the other.
Holds information regarding type of cell. Used in inside/outside determination in cellClassification...
labelList findIndices(const ListType &, typename ListType::const_reference, const label start=0)
Find all occurrences of given element. Linear search.
static void listCombineGather(const List< commsStruct > &comms, List< T > &Value, const CombineOp &cop, const int tag, const label comm)
labelList consistentUnrefinement(const labelList &pointsToUnrefine, const bool maxSet) const
Given proposed.
void distributeCellData(List< T > &lst) const
Distribute list of cell data.
label size() const
Return number of elements in table.
scalar level0EdgeLength() const
Typical edge length between unrefined points.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
A face addition data class. A face can be inflated either from a point or from another face and can e...
point centre(const pointField &) const
Return centre (centroid)
const dimensionSet dimLength
void subset(const labelList &pointMap, const labelList &faceMap, const labelList &cellMap)
Update local numbering for subsetted mesh.
hexRef8(const polyMesh &mesh, const bool readHistory=true)
Construct from mesh, read_if_present refinement data.
label refinementCount() const
bool insert(const Key &, const T &newElmt)
Insert a new hashedEntry.
iterator find(const label &)
Find and return an iterator set at the hashedEntry.
void setInstance(const fileName &inst)
void distribute(const mapDistributePolyMesh &)
Force recalculation of locally stored data for mesh distribution.
A topoSetSource to select a faceSet from cells.
An STL-conforming iterator.
Reduction class. If x and y are not equal assign value.
Class containing data for cell addition.
A list of faces which address into the list of points.
A List obtained as a section of another List.
face reverseFace() const
Return face with reverse direction.
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().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))
List< cellShape > cellShapeList
List of cellShapes and PtrList of List of cellShape.
An ordered pair of two objects of type <T> with first() and second() elements.
virtual bool coupled() const
Return true if this patch is geometrically coupled (i.e. faces and.
void combineCells(const label masterCelli, const labelList &combinedCells)
Store combining 8 cells into master.
void set(const PackedList< 1 > &)
Set specified bits.
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
labelList consistentRefinement(const labelList &cellsToRefine, const bool maxSet) const
Given valid mesh and current cell level and proposed.
virtual const fileName & name() const
Return the name of the stream.
const DynamicList< point > & points() const
Points. Shrunk after constructing mesh (or calling of compact())
void clear()
Clear all entries from table.
void append(const T &)
Append an element at the end of the list.
void subset(const labelList &pointMap, const labelList &faceMap, const labelList &cellMap)
Update numbering for subsetting.
bool write(const bool write=true) const
Force writing refinement+history to polyMesh directory.
labelList consistentSlowRefinement(const label maxFaceDiff, const labelList &cellsToRefine, const labelList &facesToCheck, const label maxPointDiff, const labelList &pointsToCheck) const
Like consistentRefinement but slower:
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
Pair< label > labelPair
Label pair.
static const label labelMax
List< label > labelList
A List of labels.
An STL-conforming hash table.
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
errorManip< error > abort(error &err)
void updateMesh(const mapPolyMesh &)
Update local numbering for changed mesh.
Info<< "Finished reading KIVA file"<< endl;cellShapeList cellShapes(nPoints);labelList cellZoning(nPoints, -1);const cellModel &hex=*(cellModeller::lookup("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]=cellShape(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, &mergedCyclicPolyPatch::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]
dimensioned< scalar > magSqr(const dimensioned< Type > &)
vector vec(const pointField &) const
Return the vector (end - start)
void reverse(UList< T > &, const label n)
virtual bool read()
Read object. If global number of visible cells > 0 becomes active.
const labelList & reverseCellMap() const
Reverse cell map.
Type gMax(const FieldField< Field, Type > &f)
static vector centre(const PointField &ps)
Return centre point given face points.
defineTypeNameAndDebug(combustionModel, 0)
static fileCheckTypes fileModificationChecking
Type of file modification checking.
prefixOSstream Perr(cerr, "Perr")
const labelList & pointMap() const
Old point map.
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurrence of given element and return index,.
void storeSplit(const label celli, const labelList &addedCells)
Store splitting of cell into 8.
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
word name(const complex &)
Return a string representation of a complex.
void updateMesh(const mapPolyMesh &)
Update numbering for mesh changes.
void distribute(const mapDistributePolyMesh &)
Update local numbering for mesh redistribution.
const labelList & visibleCells() const
Per cell in the current mesh (i.e. visible) either -1 (unrefined)
Transfers refinement levels such that slow transition between levels is maintained. Used in FaceCellWave.
void setSize(const label)
Reset size of List.
vector point
Point is a vector.
label faceLevel(const label facei) const
Gets level such that the face has four points <= level.
#define WarningInFunction
Report a warning using Foam::Warning.
A cell is defined as a list of faces with extra functionality.
A collection of cell labels.
prefixOSstream Pout(cout, "Pout")
label parentIndex(const label celli) const
Get parent of cell.
A List with indirect addressing.
Direct mesh changes based on v1.3 polyTopoChange syntax.
label start() const
Return start label of this patch in the polyMesh face list.
void flip()
Flip the face in-place.
labelList getSplitPoints() const
Return the points at the centre of top-level split cells.
void setRefinement(const labelList &piercedFaces, const labelList &cellRegion, const labelList &cellRegionMaster, polyTopoChange &) const
Play commands into polyTopoChange to remove faces.
label compatibleRemoves(const labelList &inPiercedFaces, labelList &cellRegion, labelList &cellRegionMaster, labelList &outPiercedFaces) const
Find faces including those with cells which have the same mastercell.
void unset(const PackedList< 1 > &)
Unset specified bits.
dimensioned< scalar > mag(const dimensioned< Type > &)
void resize(const label newSize)
Resize the hash table for efficiency.
const doubleScalar e
Elementary charge.
Mesh consisting of general polyhedral cells.
void checkRefinementLevels(const label maxPointDiff, const labelList &pointsToCheck) const
Debug: Check 2:1 consistency across faces.
A subset of mesh faces organised as a primitive patch.
virtual bool write(const bool write=true) const
Write using setting from DB.
All refinement history. Used in unrefinement.
A patch is a list of labels that address the faces in the global face list.
T & last()
Return the last element of the list.
void clear()
Clear the addressed list, i.e. set the size to zero.
readOption readOpt() const
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
fileName objectPath() const
Return complete path + object name.
void resize(const label nCells)
Extend/shrink storage. additional visibleCells_ elements get.
void transfer(List< T > &)
Transfer the contents of the argument List into this list.
const cellShapeList & cellShapes() const
Utility: get hexes as cell shapes.
static const label labelMin
label nOldPoints() const
Number of old points.
Transfers refinement levels such that slow transition between levels is maintained. Used in FaceCellWave.
label setAction(const topoAction &action)
For compatibility with polyTopoChange: set topological action.