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];
134 label patchID, zoneID, zoneFlip;
136 getFaceInfo(facei, patchID, zoneID, zoneFlip);
140 if ((nei == -1) || (own < nei))
187 const label meshFacei,
188 const label meshPointi,
194 if (mesh_.isInternalFace(meshFacei))
279 void Foam::hexRef8::modFace
288 label patchID, zoneID, zoneFlip;
290 getFaceInfo(facei, patchID, zoneID, zoneFlip);
294 (own != mesh_.faceOwner()[facei])
296 mesh_.isInternalFace(facei)
297 && (nei != mesh_.faceNeighbour()[facei])
299 || (newFace != mesh_.faces()[facei])
302 if ((nei == -1) || (own < nei))
342 Foam::scalar Foam::hexRef8::getLevel0EdgeLength()
const 344 if (cellLevel_.size() != mesh_.nCells())
347 <<
"Number of cells in mesh:" << mesh_.nCells()
348 <<
" does not equal size of cellLevel:" << cellLevel_.size()
350 <<
"This might be because of a restart with inconsistent cellLevel." 357 const scalar great2 =
sqr(great);
374 const label cLevel = cellLevel_[celli];
376 const labelList& cEdges = mesh_.cellEdges(celli);
380 label edgeI = cEdges[i];
382 if (edgeLevel[edgeI] == -1)
384 edgeLevel[edgeI] = cLevel;
386 else if (edgeLevel[edgeI] ==
labelMax)
390 else if (edgeLevel[edgeI] != cLevel)
412 const label eLevel = edgeLevel[edgeI];
414 if (eLevel >= 0 && eLevel <
labelMax)
416 const edge&
e = mesh_.edges()[edgeI];
418 scalar edgeLenSqr =
magSqr(e.
vec(mesh_.points()));
420 typEdgeLenSqr[eLevel] =
min(typEdgeLenSqr[eLevel], edgeLenSqr);
432 Pout<<
"hexRef8::getLevel0EdgeLength() :" 433 <<
" After phase1: Edgelengths (squared) per refinementlevel:" 434 << typEdgeLenSqr <<
endl;
448 const label cLevel = cellLevel_[celli];
450 const labelList& cEdges = mesh_.cellEdges(celli);
454 const edge&
e = mesh_.edges()[cEdges[i]];
456 scalar edgeLenSqr =
magSqr(e.
vec(mesh_.points()));
458 maxEdgeLenSqr[cLevel] =
max(maxEdgeLenSqr[cLevel], edgeLenSqr);
467 Pout<<
"hexRef8::getLevel0EdgeLength() :" 468 <<
" Crappy Edgelengths (squared) per refinementlevel:" 469 << maxEdgeLenSqr <<
endl;
476 forAll(typEdgeLenSqr, levelI)
478 if (typEdgeLenSqr[levelI] == great2 && maxEdgeLenSqr[levelI] >= 0)
480 typEdgeLenSqr[levelI] = maxEdgeLenSqr[levelI];
486 Pout<<
"hexRef8::getLevel0EdgeLength() :" 487 <<
" Final Edgelengths (squared) per refinementlevel:" 488 << typEdgeLenSqr <<
endl;
492 scalar level0Size = -1;
494 forAll(typEdgeLenSqr, levelI)
496 scalar lenSqr = typEdgeLenSqr[levelI];
504 Pout<<
"hexRef8::getLevel0EdgeLength() :" 505 <<
" For level:" << levelI
507 <<
" with equivalent level0 len:" << level0Size
514 if (level0Size == -1)
533 if (cellAnchorPoints[celli].size())
539 return cellAddedCells[celli][index];
546 const face& f = mesh_.faces()[facei];
554 return cellAddedCells[celli][index];
560 Perr<<
"cell:" << celli <<
" anchorPoints:" << cellAnchorPoints[celli]
564 <<
"Could not find point " << pointi
565 <<
" in the anchorPoints for cell " << celli << endl
566 <<
"Does your original mesh obey the 2:1 constraint and" 567 <<
" did you use consistentRefinement to make your cells to refine" 568 <<
" obey this constraint as well?" 580 void Foam::hexRef8::getFaceNeighbours
596 mesh_.faceOwner()[facei],
601 if (mesh_.isInternalFace(facei))
607 mesh_.faceNeighbour()[facei],
626 label level = pointLevel_[f[fp]];
628 if (level < minLevel)
646 label level = pointLevel_[f[fp]];
648 if (level > maxLevel)
662 const label anchorLevel
669 if (pointLevel_[f[fp]] <= anchorLevel)
678 void Foam::hexRef8::dumpCell(
const label celli)
const 681 Pout<<
"hexRef8 : Dumping cell as obj to " << str.
name() <<
endl;
683 const cell& cFaces = mesh_.cells()[celli];
690 const face& f = mesh_.faces()[cFaces[i]];
694 if (pointToObjVert.
insert(f[fp], objVertI))
704 const face& f = mesh_.faces()[cFaces[i]];
708 label pointi = f[fp];
711 str <<
"l " << pointToObjVert[pointi]+1
712 <<
' ' << pointToObjVert[nexPointi]+1 <<
nl;
723 const bool searchForward,
724 const label wantedLevel
731 label pointi = f[fp];
733 if (pointLevel_[pointi] < wantedLevel)
735 dumpCell(mesh_.faceOwner()[facei]);
736 if (mesh_.isInternalFace(facei))
738 dumpCell(mesh_.faceNeighbour()[facei]);
744 <<
" startFp:" << startFp
745 <<
" wantedLevel:" << wantedLevel
748 else if (pointLevel_[pointi] == wantedLevel)
763 dumpCell(mesh_.faceOwner()[facei]);
764 if (mesh_.isInternalFace(facei))
766 dumpCell(mesh_.faceNeighbour()[facei]);
772 <<
" startFp:" << startFp
773 <<
" wantedLevel:" << wantedLevel
782 const face& f = mesh_.faces()[facei];
786 return pointLevel_[f[findMaxLevel(f)]];
790 label ownLevel = cellLevel_[mesh_.faceOwner()[facei]];
792 if (countAnchors(f, ownLevel) == 4)
796 else if (countAnchors(f, ownLevel+1) == 4)
808 void Foam::hexRef8::checkInternalOrientation
821 const vector a(compactFace.
area(compactPoints));
823 const vector dir(neiPt - ownPt);
828 <<
"cell:" << celli <<
" old face:" << facei
829 <<
" newFace:" << newFace <<
endl 830 <<
" coords:" << compactPoints
831 <<
" ownPt:" << ownPt
832 <<
" neiPt:" << neiPt
836 const vector fcToOwn(compactFace.
centre(compactPoints) - ownPt);
838 const scalar
s = (fcToOwn & a) / (dir & a);
840 if (s < 0.1 || s > 0.9)
843 <<
"cell:" << celli <<
" old face:" << facei
844 <<
" newFace:" << newFace <<
endl 845 <<
" coords:" << compactPoints
846 <<
" ownPt:" << ownPt
847 <<
" neiPt:" << neiPt
854 void Foam::hexRef8::checkBoundaryOrientation
860 const point& boundaryPt,
867 const vector a(compactFace.
area(compactPoints));
869 const vector dir(boundaryPt - ownPt);
874 <<
"cell:" << celli <<
" old face:" << facei
875 <<
" newFace:" << newFace
876 <<
" coords:" << compactPoints
877 <<
" ownPt:" << ownPt
878 <<
" boundaryPt:" << boundaryPt
882 const vector fcToOwn(compactFace.
centre(compactPoints) - ownPt);
884 const scalar
s = (fcToOwn&dir) /
magSqr(dir);
886 if (s < 0.7 || s > 1.3)
889 <<
"cell:" << celli <<
" old face:" << facei
890 <<
" newFace:" << newFace
891 <<
" coords:" << compactPoints
892 <<
" ownPt:" << ownPt
893 <<
" boundaryPt:" << boundaryPt
900 void Foam::hexRef8::insertEdgeSplit
908 if (p0 < mesh_.nPoints() && p1 < mesh_.nPoints())
912 if (edgeI != -1 && edgeMidPoint[edgeI] != -1)
914 verts.
append(edgeMidPoint[edgeI]);
928 const bool faceOrder,
929 const label edgeMidPointi,
930 const label anchorPointi,
931 const label faceMidPointi,
940 bool changed =
false;
941 bool haveTwoAnchors =
false;
945 if (edgeMidFnd == midPointToAnchors.
end())
947 midPointToAnchors.
insert(edgeMidPointi,
edge(anchorPointi, -1));
951 edge&
e = edgeMidFnd();
953 if (anchorPointi != e[0])
962 if (e[0] != -1 && e[1] != -1)
964 haveTwoAnchors =
true;
968 bool haveTwoFaceMids =
false;
972 if (faceMidFnd == midPointToFaceMids.
end())
974 midPointToFaceMids.
insert(edgeMidPointi,
edge(faceMidPointi, -1));
978 edge&
e = faceMidFnd();
980 if (faceMidPointi != e[0])
984 e[1] = faceMidPointi;
989 if (e[0] != -1 && e[1] != -1)
991 haveTwoFaceMids =
true;
998 if (changed && haveTwoAnchors && haveTwoFaceMids)
1000 const edge& anchors = midPointToAnchors[edgeMidPointi];
1001 const edge& faceMids = midPointToFaceMids[edgeMidPointi];
1011 if (faceOrder == (mesh_.faceOwner()[facei] == celli))
1013 newFaceVerts.
append(faceMidPointi);
1024 newFaceVerts.
append(edgeMidPointi);
1034 newFaceVerts.
append(otherFaceMidPointi);
1035 newFaceVerts.
append(cellMidPoint[celli]);
1039 newFaceVerts.
append(otherFaceMidPointi);
1049 newFaceVerts.
append(edgeMidPointi);
1059 newFaceVerts.
append(faceMidPointi);
1060 newFaceVerts.
append(cellMidPoint[celli]);
1066 label anchorCell0 = getAnchorCell
1074 label anchorCell1 = getAnchorCell
1087 if (anchorCell0 < anchorCell1)
1092 ownPt = mesh_.points()[anchorPointi];
1093 neiPt = mesh_.points()[anchors.
otherVertex(anchorPointi)];
1102 ownPt = mesh_.points()[anchors.
otherVertex(anchorPointi)];
1103 neiPt = mesh_.points()[anchorPointi];
1110 if (anchorCell0 < anchorCell1)
1112 ownPt = mesh_.points()[anchorPointi];
1113 neiPt = mesh_.points()[anchors.
otherVertex(anchorPointi)];
1117 ownPt = mesh_.points()[anchors.
otherVertex(anchorPointi)];
1118 neiPt = mesh_.points()[anchorPointi];
1121 checkInternalOrientation
1132 return addInternalFace
1149 void Foam::hexRef8::createInternalFaces
1165 const cell& cFaces = mesh_.cells()[celli];
1166 const label cLevel = cellLevel_[celli];
1178 label nFacesAdded = 0;
1182 label facei = cFaces[i];
1184 const face& f = mesh_.faces()[facei];
1185 const labelList& fEdges = mesh_.faceEdges(facei, storage);
1190 label faceMidPointi = -1;
1192 label nAnchors = countAnchors(f, cLevel);
1200 label anchorFp = -1;
1204 if (pointLevel_[f[fp]] <= cLevel)
1212 label edgeMid = findLevel
1220 label faceMid = findLevel
1229 faceMidPointi = f[faceMid];
1231 else if (nAnchors == 4)
1236 faceMidPointi = faceMidPoint[facei];
1240 dumpCell(mesh_.faceOwner()[facei]);
1241 if (mesh_.isInternalFace(facei))
1243 dumpCell(mesh_.faceNeighbour()[facei]);
1247 <<
"nAnchors:" << nAnchors
1248 <<
" facei:" << facei
1260 label point0 = f[fp0];
1262 if (pointLevel_[point0] <= cLevel)
1271 label edgeMidPointi = -1;
1275 if (pointLevel_[f[fp1]] <= cLevel)
1278 label edgeI = fEdges[fp0];
1280 edgeMidPointi = edgeMidPoint[edgeI];
1282 if (edgeMidPointi == -1)
1286 const labelList& cPoints = mesh_.cellPoints(celli);
1289 <<
"cell:" << celli <<
" cLevel:" << cLevel
1290 <<
" cell points:" << cPoints
1293 <<
" face:" << facei
1297 <<
" faceAnchorLevel:" << faceAnchorLevel[facei]
1298 <<
" faceMidPoint:" << faceMidPoint[facei]
1299 <<
" faceMidPointi:" << faceMidPointi
1307 label edgeMid = findLevel(facei, f, fp1,
true, cLevel+1);
1309 edgeMidPointi = f[edgeMid];
1312 label newFacei = storeMidPointInfo
1335 if (nFacesAdded == 12)
1348 if (pointLevel_[f[fpMin1]] <= cLevel)
1351 label edgeI = fEdges[fpMin1];
1353 edgeMidPointi = edgeMidPoint[edgeI];
1355 if (edgeMidPointi == -1)
1359 const labelList& cPoints = mesh_.cellPoints(celli);
1362 <<
"cell:" << celli <<
" cLevel:" << cLevel
1363 <<
" cell points:" << cPoints
1366 <<
" face:" << facei
1370 <<
" faceAnchorLevel:" << faceAnchorLevel[facei]
1371 <<
" faceMidPoint:" << faceMidPoint[facei]
1372 <<
" faceMidPointi:" << faceMidPointi
1380 label edgeMid = findLevel
1389 edgeMidPointi = f[edgeMid];
1392 newFacei = storeMidPointInfo
1415 if (nFacesAdded == 12)
1423 if (nFacesAdded == 12)
1431 void Foam::hexRef8::walkFaceToMid
1436 const label startFp,
1440 const face& f = mesh_.faces()[facei];
1441 const labelList& fEdges = mesh_.faceEdges(facei);
1450 if (edgeMidPoint[fEdges[fp]] >= 0)
1452 faceVerts.
append(edgeMidPoint[fEdges[fp]]);
1457 if (pointLevel_[f[fp]] <= cLevel)
1463 else if (pointLevel_[f[fp]] == cLevel+1)
1470 else if (pointLevel_[f[fp]] == cLevel+2)
1479 void Foam::hexRef8::walkFaceFromMid
1484 const label startFp,
1488 const face& f = mesh_.faces()[facei];
1489 const labelList& fEdges = mesh_.faceEdges(facei);
1495 if (pointLevel_[f[fp]] <= cLevel)
1500 else if (pointLevel_[f[fp]] == cLevel+1)
1506 else if (pointLevel_[f[fp]] == cLevel+2)
1516 if (edgeMidPoint[fEdges[fp]] >= 0)
1518 faceVerts.
append(edgeMidPoint[fEdges[fp]]);
1532 Foam::label Foam::hexRef8::faceConsistentRefinement
1541 for (
label facei = 0; facei < mesh_.nInternalFaces(); facei++)
1543 label own = mesh_.faceOwner()[facei];
1544 label ownLevel = cellLevel_[own] + refineCell.
get(own);
1546 label nei = mesh_.faceNeighbour()[facei];
1547 label neiLevel = cellLevel_[nei] + refineCell.
get(nei);
1549 if (ownLevel > (neiLevel+1))
1553 refineCell.
set(nei);
1557 refineCell.
unset(own);
1561 else if (neiLevel > (ownLevel+1))
1565 refineCell.
set(own);
1569 refineCell.
unset(nei);
1578 labelList neiLevel(mesh_.nFaces()-mesh_.nInternalFaces());
1582 label own = mesh_.faceOwner()[i+mesh_.nInternalFaces()];
1584 neiLevel[i] = cellLevel_[own] + refineCell.
get(own);
1593 label own = mesh_.faceOwner()[i+mesh_.nInternalFaces()];
1594 label ownLevel = cellLevel_[own] + refineCell.
get(own);
1596 if (ownLevel > (neiLevel[i]+1))
1600 refineCell.
unset(own);
1604 else if (neiLevel[i] > (ownLevel+1))
1608 refineCell.
set(own);
1618 void Foam::hexRef8::checkWantedRefinementLevels
1626 refineCell.
set(cellsToRefine[i]);
1629 for (
label facei = 0; facei < mesh_.nInternalFaces(); facei++)
1631 label own = mesh_.faceOwner()[facei];
1632 label ownLevel = cellLevel_[own] + refineCell.
get(own);
1634 label nei = mesh_.faceNeighbour()[facei];
1635 label neiLevel = cellLevel_[nei] + refineCell.
get(nei);
1637 if (
mag(ownLevel-neiLevel) > 1)
1643 <<
" current level:" << cellLevel_[own]
1644 <<
" level after refinement:" << ownLevel
1646 <<
"neighbour cell:" << nei
1647 <<
" current level:" << cellLevel_[nei]
1648 <<
" level after refinement:" << neiLevel
1650 <<
"which does not satisfy 2:1 constraints anymore." 1657 labelList neiLevel(mesh_.nFaces()-mesh_.nInternalFaces());
1661 label own = mesh_.faceOwner()[i+mesh_.nInternalFaces()];
1663 neiLevel[i] = cellLevel_[own] + refineCell.
get(own);
1672 label facei = i + mesh_.nInternalFaces();
1674 label own = mesh_.faceOwner()[facei];
1675 label ownLevel = cellLevel_[own] + refineCell.
get(own);
1677 if (
mag(ownLevel - neiLevel[i]) > 1)
1679 label patchi = mesh_.boundaryMesh().whichPatch(facei);
1683 <<
"Celllevel does not satisfy 2:1 constraint." 1684 <<
" On coupled face " 1686 <<
" on patch " << patchi <<
" " 1687 << mesh_.boundaryMesh()[
patchi].name()
1688 <<
" owner cell " << own
1689 <<
" current level:" << cellLevel_[own]
1690 <<
" level after refinement:" << ownLevel
1692 <<
" (coupled) neighbour cell will get refinement " 1704 Pout<<
"hexRef8::setInstance(const fileName& inst) : " 1705 <<
"Resetting file instance to " << inst <<
endl;
1708 cellLevel_.instance() = inst;
1709 pointLevel_.instance() = inst;
1710 level0Edge_.instance() = inst;
1711 history_.instance() = inst;
1715 void Foam::hexRef8::collectLevelPoints
1724 if (pointLevel_[f[fp]] <= level)
1732 void Foam::hexRef8::collectLevelPoints
1742 label pointi = meshPoints[f[fp]];
1743 if (pointLevel_[pointi] <= level)
1751 bool Foam::hexRef8::matchHexShape
1754 const label cellLevel,
1758 const cell& cFaces = mesh_.cells()[celli];
1769 label facei = cFaces[i];
1770 const face& f = mesh_.faces()[facei];
1773 collectLevelPoints(f, cellLevel, verts);
1774 if (verts.
size() == 4)
1776 if (mesh_.faceOwner()[facei] != celli)
1787 if (quads.
size() < 6)
1793 label facei = cFaces[i];
1794 const face& f = mesh_.faces()[facei];
1802 collectLevelPoints(f, cellLevel, verts);
1803 if (verts.
size() == 1)
1809 label pointi = f[fp];
1810 if (pointLevel_[pointi] == cellLevel+1)
1813 pointFaces.find(pointi);
1814 if (iter != pointFaces.end())
1840 if (pFaces.
size() == 4)
1846 label facei = pFaces[pFacei];
1847 const face& f = mesh_.faces()[facei];
1848 if (mesh_.faceOwner()[facei] == celli)
1850 fourFaces[pFacei] =
f;
1865 if (edgeLoops.size() == 1)
1871 bigFace.meshPoints(),
1872 bigFace.edgeLoops()[0],
1877 if (verts.
size() == 4)
1888 return (quads.
size() == 6);
1902 mesh_.facesInstance(),
1915 mesh_.facesInstance(),
1928 mesh_.facesInstance(),
1940 "refinementHistory",
1941 mesh_.facesInstance(),
1948 (readHistory ? mesh_.nCells() : 0)
1950 faceRemover_(mesh_, great),
1951 savedPointLevel_(0),
1972 <<
"History enabled but number of visible cells " 1975 <<
" is not equal to the number of cells in the mesh " 1982 cellLevel_.
size() != mesh_.nCells()
1983 || pointLevel_.
size() != mesh_.nPoints()
1987 <<
"Restarted from inconsistent cellLevel or pointLevel files." 1991 <<
"Number of cells in mesh:" << mesh_.nCells()
1992 <<
" does not equal size of cellLevel:" << cellLevel_.
size() <<
endl 1993 <<
"Number of points in mesh:" << mesh_.nPoints()
1994 <<
" does not equal size of pointLevel:" << pointLevel_.
size()
2018 const scalar level0Edge
2027 mesh_.facesInstance(),
2040 mesh_.facesInstance(),
2053 mesh_.facesInstance(),
2062 (level0Edge >= 0 ? level0Edge : getLevel0EdgeLength())
2069 "refinementHistory",
2070 mesh_.facesInstance(),
2078 faceRemover_(mesh_, great),
2079 savedPointLevel_(0),
2085 <<
"History enabled but number of visible cells in it " 2087 <<
" is not equal to the number of cells in the mesh " 2093 cellLevel_.
size() != mesh_.nCells()
2094 || pointLevel_.
size() != mesh_.nPoints()
2098 <<
"Incorrect cellLevel or pointLevel size." <<
endl 2099 <<
"Number of cells in mesh:" << mesh_.nCells()
2100 <<
" does not equal size of cellLevel:" << cellLevel_.
size() <<
endl 2101 <<
"Number of points in mesh:" << mesh_.nPoints()
2102 <<
" does not equal size of pointLevel:" << pointLevel_.
size()
2124 const scalar level0Edge
2133 mesh_.facesInstance(),
2146 mesh_.facesInstance(),
2159 mesh_.facesInstance(),
2168 (level0Edge >= 0 ? level0Edge : getLevel0EdgeLength())
2175 "refinementHistory",
2176 mesh_.facesInstance(),
2186 faceRemover_(mesh_, great),
2187 savedPointLevel_(0),
2192 cellLevel_.
size() != mesh_.nCells()
2193 || pointLevel_.
size() != mesh_.nPoints()
2197 <<
"Incorrect cellLevel or pointLevel size." <<
endl 2198 <<
"Number of cells in mesh:" << mesh_.nCells()
2199 <<
" does not equal size of cellLevel:" << cellLevel_.
size() <<
endl 2200 <<
"Number of points in mesh:" << mesh_.nPoints()
2201 <<
" does not equal size of pointLevel:" << pointLevel_.
size()
2234 refineCell.
set(cellsToRefine[i]);
2239 label nChanged = faceConsistentRefinement(maxSet, refineCell);
2245 Pout<<
"hexRef8::consistentRefinement : Changed " << nChanged
2246 <<
" refinement levels due to 2:1 conflicts." 2260 forAll(refineCell, celli)
2262 if (refineCell.
get(celli))
2271 forAll(refineCell, celli)
2273 if (refineCell.
get(celli))
2275 newCellsToRefine[nRefined++] = celli;
2281 checkWantedRefinementLevels(newCellsToRefine);
2284 return newCellsToRefine;
2290 const label maxFaceDiff,
2293 const label maxPointDiff,
2297 const labelList& faceOwner = mesh_.faceOwner();
2298 const labelList& faceNeighbour = mesh_.faceNeighbour();
2301 if (maxFaceDiff <= 0)
2304 <<
"Illegal maxFaceDiff " << maxFaceDiff <<
nl 2323 forAll(allCellInfo, celli)
2329 maxFaceDiff*(cellLevel_[celli]+1),
2330 maxFaceDiff*cellLevel_[celli]
2337 label celli = cellsToRefine[i];
2339 allCellInfo[celli].count() = allCellInfo[celli].refinementCount();
2349 int dummyTrackData = 0;
2357 label facei = facesToCheck[i];
2359 if (allFaceInfo[facei].valid(dummyTrackData))
2363 <<
"Argument facesToCheck seems to have duplicate entries!" 2365 <<
"face:" << facei <<
" occurs at positions " 2373 if (mesh_.isInternalFace(facei))
2378 const refinementData& neiData = allCellInfo[faceNeighbour[facei]];
2381 label faceRefineCount;
2384 faceCount = neiData.
count() + maxFaceDiff;
2385 faceRefineCount = faceCount + maxFaceDiff;
2389 faceCount = ownData.
count() + maxFaceDiff;
2390 faceRefineCount = faceCount + maxFaceDiff;
2393 seedFaces.append(facei);
2394 seedFacesInfo.append
2402 allFaceInfo[facei] = seedFacesInfo.last();
2406 label faceCount = ownData.
count() + maxFaceDiff;
2407 label faceRefineCount = faceCount + maxFaceDiff;
2409 seedFaces.append(facei);
2410 seedFacesInfo.append
2418 allFaceInfo[facei] = seedFacesInfo.last();
2426 forAll(faceNeighbour, facei)
2429 if (!allFaceInfo[facei].valid(dummyTrackData))
2431 label own = faceOwner[facei];
2432 label nei = faceNeighbour[facei];
2436 if (allCellInfo[own].
count() > allCellInfo[nei].
count())
2438 allFaceInfo[facei].updateFace
2448 seedFacesInfo.append(allFaceInfo[facei]);
2450 else if (allCellInfo[own].
count() < allCellInfo[nei].
count())
2452 allFaceInfo[facei].updateFace
2461 seedFaces.append(facei);
2462 seedFacesInfo.append(allFaceInfo[facei]);
2470 for (
label facei = mesh_.nInternalFaces(); facei < mesh_.nFaces(); facei++)
2473 if (!allFaceInfo[facei].valid(dummyTrackData))
2475 label own = faceOwner[facei];
2488 seedFaces.append(facei);
2489 seedFacesInfo.append(faceData);
2507 Pout<<
"hexRef8::consistentSlowRefinement : Seeded " 2508 << seedFaces.size() <<
" faces between cells with different" 2509 <<
" refinement level." <<
endl;
2513 levelCalc.
setFaceInfo(seedFaces.shrink(), seedFacesInfo.shrink());
2515 seedFacesInfo.clear();
2518 levelCalc.
iterate(mesh_.globalData().nTotalFaces()+1);
2526 if (maxPointDiff == -1)
2534 labelList maxPointCount(mesh_.nPoints(), 0);
2536 forAll(maxPointCount, pointi)
2538 label& pLevel = maxPointCount[pointi];
2540 const labelList& pCells = mesh_.pointCells(pointi);
2544 pLevel =
max(pLevel, allCellInfo[pCells[i]].
count());
2565 label pointi = pointsToCheck[i];
2570 const labelList& pCells = mesh_.pointCells(pointi);
2574 label celli = pCells[pCelli];
2582 maxPointCount[pointi]
2583 > cellInfo.
count() + maxFaceDiff*maxPointDiff
2591 const cell& cFaces = mesh_.cells()[celli];
2595 label facei = cFaces[cFacei];
2608 if (faceData.
count() > allFaceInfo[facei].count())
2610 changedFacesInfo.insert(facei, faceData);
2617 label nChanged = changedFacesInfo.size();
2627 seedFaces.setCapacity(changedFacesInfo.size());
2628 seedFacesInfo.setCapacity(changedFacesInfo.size());
2632 seedFaces.append(iter.key());
2633 seedFacesInfo.append(iter());
2640 for (
label facei = 0; facei < mesh_.nInternalFaces(); facei++)
2642 label own = mesh_.faceOwner()[facei];
2645 + (allCellInfo[own].isRefined() ? 1 : 0);
2647 label nei = mesh_.faceNeighbour()[facei];
2650 + (allCellInfo[nei].isRefined() ? 1 : 0);
2652 if (
mag(ownLevel-neiLevel) > 1)
2658 <<
" current level:" << cellLevel_[own]
2659 <<
" current refData:" << allCellInfo[own]
2660 <<
" level after refinement:" << ownLevel
2662 <<
"neighbour cell:" << nei
2663 <<
" current level:" << cellLevel_[nei]
2664 <<
" current refData:" << allCellInfo[nei]
2665 <<
" level after refinement:" << neiLevel
2667 <<
"which does not satisfy 2:1 constraints anymore." <<
nl 2668 <<
"face:" << facei <<
" faceRefData:" << allFaceInfo[facei]
2677 labelList neiLevel(mesh_.nFaces()-mesh_.nInternalFaces());
2678 labelList neiCount(mesh_.nFaces()-mesh_.nInternalFaces());
2679 labelList neiRefCount(mesh_.nFaces()-mesh_.nInternalFaces());
2683 label own = mesh_.faceOwner()[i+mesh_.nInternalFaces()];
2684 neiLevel[i] = cellLevel_[own];
2685 neiCount[i] = allCellInfo[own].count();
2686 neiRefCount[i] = allCellInfo[own].refinementCount();
2697 label facei = i+mesh_.nInternalFaces();
2699 label own = mesh_.faceOwner()[facei];
2702 + (allCellInfo[own].isRefined() ? 1 : 0);
2706 + ((neiCount[i] >= neiRefCount[i]) ? 1 : 0);
2708 if (
mag(ownLevel - nbrLevel) > 1)
2711 label patchi = mesh_.boundaryMesh().whichPatch(facei);
2714 <<
"Celllevel does not satisfy 2:1 constraint." 2715 <<
" On coupled face " 2717 <<
" refData:" << allFaceInfo[facei]
2718 <<
" on patch " << patchi <<
" " 2719 << mesh_.boundaryMesh()[
patchi].name() <<
nl 2720 <<
"owner cell " << own
2721 <<
" current level:" << cellLevel_[own]
2722 <<
" current count:" << allCellInfo[own].count()
2723 <<
" current refCount:" 2724 << allCellInfo[own].refinementCount()
2725 <<
" level after refinement:" << ownLevel
2727 <<
"(coupled) neighbour cell" 2728 <<
" has current level:" << neiLevel[i]
2729 <<
" current count:" << neiCount[i]
2730 <<
" current refCount:" << neiRefCount[i]
2731 <<
" level after refinement:" << nbrLevel
2741 forAll(allCellInfo, celli)
2743 if (allCellInfo[celli].isRefined())
2753 forAll(allCellInfo, celli)
2755 if (allCellInfo[celli].isRefined())
2757 newCellsToRefine[nRefined++] = celli;
2763 Pout<<
"hexRef8::consistentSlowRefinement : From " 2764 << cellsToRefine.
size() <<
" to " << newCellsToRefine.
size()
2765 <<
" cells to refine." <<
endl;
2768 return newCellsToRefine;
2774 const label maxFaceDiff,
2779 const labelList& faceOwner = mesh_.faceOwner();
2780 const labelList& faceNeighbour = mesh_.faceNeighbour();
2782 if (maxFaceDiff <= 0)
2785 <<
"Illegal maxFaceDiff " << maxFaceDiff <<
nl 2804 int dummyTrackData = 0;
2810 label celli = cellsToRefine[i];
2815 mesh_.cellCentres()[celli],
2820 forAll(allCellInfo, celli)
2822 if (!allCellInfo[celli].valid(dummyTrackData))
2827 mesh_.cellCentres()[celli],
2843 label facei = facesToCheck[i];
2845 if (allFaceInfo[facei].valid(dummyTrackData))
2849 <<
"Argument facesToCheck seems to have duplicate entries!" 2851 <<
"face:" << facei <<
" occurs at positions " 2856 label own = faceOwner[facei];
2860 allCellInfo[own].valid(dummyTrackData)
2861 ? allCellInfo[own].originLevel()
2865 if (!mesh_.isInternalFace(facei))
2869 const point& fc = mesh_.faceCentres()[facei];
2878 allFaceInfo[facei].updateFace
2890 label nei = faceNeighbour[facei];
2894 allCellInfo[nei].valid(dummyTrackData)
2895 ? allCellInfo[nei].originLevel()
2899 if (ownLevel == neiLevel)
2944 seedFaces.append(facei);
2945 seedFacesInfo.append(allFaceInfo[facei]);
2952 forAll(faceNeighbour, facei)
2955 if (!allFaceInfo[facei].valid(dummyTrackData))
2957 label own = faceOwner[facei];
2961 allCellInfo[own].valid(dummyTrackData)
2962 ? allCellInfo[own].originLevel()
2966 label nei = faceNeighbour[facei];
2970 allCellInfo[nei].valid(dummyTrackData)
2971 ? allCellInfo[nei].originLevel()
2975 if (ownLevel > neiLevel)
2978 seedFaces.append(facei);
2988 seedFacesInfo.append(allFaceInfo[facei]);
2990 else if (neiLevel > ownLevel)
2992 seedFaces.append(facei);
3002 seedFacesInfo.append(allFaceInfo[facei]);
3008 seedFacesInfo.shrink();
3018 mesh_.globalData().nTotalCells()+1,
3059 label celli = cellsToRefine[i];
3061 allCellInfo[celli].originLevel() =
sizeof(
label)*8-2;
3062 allCellInfo[celli].origin() = cc[celli];
3069 forAll(allCellInfo, celli)
3071 label wanted = allCellInfo[celli].wantedLevel(cc[celli]);
3073 if (wanted > cellLevel_[celli]+1)
3075 refineCell.
set(celli);
3078 faceConsistentRefinement(
true, refineCell);
3082 label nChanged = faceConsistentRefinement(
true, refineCell);
3088 Pout<<
"hexRef8::consistentSlowRefinement2 : Changed " << nChanged
3089 <<
" refinement levels due to 2:1 conflicts." 3102 forAll(refineCell, celli)
3104 if (refineCell[celli])
3113 forAll(refineCell, celli)
3115 if (refineCell[celli])
3117 newCellsToRefine[nRefined++] = celli;
3123 Pout<<
"hexRef8::consistentSlowRefinement2 : From " 3124 << cellsToRefine.
size() <<
" to " << newCellsToRefine.
size()
3125 <<
" cells to refine." <<
endl;
3130 cellSet cellsIn(mesh_,
"cellsToRefineIn", cellsToRefine);
3131 Pout<<
"hexRef8::consistentSlowRefinement2 : writing " 3132 << cellsIn.
size() <<
" to cellSet " 3137 cellSet cellsOut(mesh_,
"cellsToRefineOut", newCellsToRefine);
3138 Pout<<
"hexRef8::consistentSlowRefinement2 : writing " 3139 << cellsOut.
size() <<
" to cellSet " 3146 forAll(newCellsToRefine, i)
3148 refineCell.
set(newCellsToRefine[i]);
3152 label nChanged = faceConsistentRefinement(
true, refineCell);
3157 mesh_,
"cellsToRefineOut2", newCellsToRefine.
size()
3159 forAll(refineCell, celli)
3161 if (refineCell.
get(celli))
3163 cellsOut2.insert(celli);
3166 Pout<<
"hexRef8::consistentSlowRefinement2 : writing " 3167 << cellsOut2.size() <<
" to cellSet " 3168 << cellsOut2.objectPath() <<
endl;
3174 forAll(refineCell, celli)
3176 if (refineCell.
get(celli) && !savedRefineCell.
get(celli))
3180 <<
"Cell:" << celli <<
" cc:" 3181 << mesh_.cellCentres()[celli]
3182 <<
" was not marked for refinement but does not obey" 3183 <<
" 2:1 constraints." 3190 return newCellsToRefine;
3202 Pout<<
"hexRef8::setRefinement :" 3203 <<
" Checking initial mesh just to make sure" <<
endl;
3212 savedPointLevel_.
clear();
3213 savedCellLevel_.
clear();
3218 forAll(cellLevel_, celli)
3220 newCellLevel.append(cellLevel_[celli]);
3223 forAll(pointLevel_, pointi)
3225 newPointLevel.append(pointLevel_[pointi]);
3231 Pout<<
"hexRef8::setRefinement :" 3232 <<
" Allocating " << cellLabels.
size() <<
" cell midpoints." 3240 labelList cellMidPoint(mesh_.nCells(), -1);
3244 label celli = cellLabels[i];
3246 label anchorPointi = mesh_.faces()[mesh_.cells()[celli][0]][0];
3252 mesh_.cellCentres()[celli],
3259 newPointLevel(cellMidPoint[celli]) = cellLevel_[celli]+1;
3265 cellSet splitCells(mesh_,
"splitCells", cellLabels.
size());
3267 forAll(cellMidPoint, celli)
3269 if (cellMidPoint[celli] >= 0)
3271 splitCells.insert(celli);
3275 Pout<<
"hexRef8::setRefinement : Dumping " << splitCells.size()
3276 <<
" cells to split to cellSet " << splitCells.objectPath()
3289 Pout<<
"hexRef8::setRefinement :" 3290 <<
" Allocating edge midpoints." 3299 labelList edgeMidPoint(mesh_.nEdges(), -1);
3302 forAll(cellMidPoint, celli)
3304 if (cellMidPoint[celli] >= 0)
3306 const labelList& cEdges = mesh_.cellEdges(celli);
3310 label edgeI = cEdges[i];
3312 const edge&
e = mesh_.edges()[edgeI];
3316 pointLevel_[e[0]] <= cellLevel_[celli]
3317 && pointLevel_[e[1]] <= cellLevel_[celli]
3320 edgeMidPoint[edgeI] = 12345;
3347 forAll(edgeMidPoint, edgeI)
3349 if (edgeMidPoint[edgeI] >= 0)
3352 edgeMids[edgeI] = mesh_.edges()[edgeI].centre(mesh_.points());
3360 point(-great, -great, -great)
3365 forAll(edgeMidPoint, edgeI)
3367 if (edgeMidPoint[edgeI] >= 0)
3372 const edge&
e = mesh_.edges()[edgeI];
3385 newPointLevel(edgeMidPoint[edgeI]) =
3398 OFstream str(mesh_.time().path()/
"edgeMidPoint.obj");
3400 forAll(edgeMidPoint, edgeI)
3402 if (edgeMidPoint[edgeI] >= 0)
3404 const edge&
e = mesh_.edges()[edgeI];
3410 Pout<<
"hexRef8::setRefinement :" 3411 <<
" Dumping edge centres to split to file " << str.
name() <<
endl;
3421 Pout<<
"hexRef8::setRefinement :" 3422 <<
" Allocating face midpoints." 3428 labelList faceAnchorLevel(mesh_.nFaces());
3430 for (
label facei = 0; facei < mesh_.nFaces(); facei++)
3432 faceAnchorLevel[facei] =
faceLevel(facei);
3437 labelList faceMidPoint(mesh_.nFaces(), -1);
3442 for (
label facei = 0; facei < mesh_.nInternalFaces(); facei++)
3444 if (faceAnchorLevel[facei] >= 0)
3446 label own = mesh_.faceOwner()[facei];
3447 label ownLevel = cellLevel_[own];
3448 label newOwnLevel = ownLevel + (cellMidPoint[own] >= 0 ? 1 : 0);
3450 label nei = mesh_.faceNeighbour()[facei];
3451 label neiLevel = cellLevel_[nei];
3452 label newNeiLevel = neiLevel + (cellMidPoint[nei] >= 0 ? 1 : 0);
3456 newOwnLevel > faceAnchorLevel[facei]
3457 || newNeiLevel > faceAnchorLevel[facei]
3460 faceMidPoint[facei] = 12345;
3473 labelList newNeiLevel(mesh_.nFaces()-mesh_.nInternalFaces());
3477 label own = mesh_.faceOwner()[i+mesh_.nInternalFaces()];
3478 label ownLevel = cellLevel_[own];
3479 label newOwnLevel = ownLevel + (cellMidPoint[own] >= 0 ? 1 : 0);
3481 newNeiLevel[i] = newOwnLevel;
3491 label facei = i+mesh_.nInternalFaces();
3493 if (faceAnchorLevel[facei] >= 0)
3495 label own = mesh_.faceOwner()[facei];
3496 label ownLevel = cellLevel_[own];
3497 label newOwnLevel = ownLevel + (cellMidPoint[own] >= 0 ? 1 : 0);
3501 newOwnLevel > faceAnchorLevel[facei]
3502 || newNeiLevel[i] > faceAnchorLevel[facei]
3505 faceMidPoint[facei] = 12345;
3530 mesh_.nFaces()-mesh_.nInternalFaces(),
3531 point(-great, -great, -great)
3536 label facei = i+mesh_.nInternalFaces();
3538 if (faceMidPoint[facei] >= 0)
3540 bFaceMids[i] = mesh_.faceCentres()[facei];
3550 forAll(faceMidPoint, facei)
3552 if (faceMidPoint[facei] >= 0)
3557 const face& f = mesh_.faces()[facei];
3564 facei < mesh_.nInternalFaces()
3565 ? mesh_.faceCentres()[facei]
3566 : bFaceMids[facei-mesh_.nInternalFaces()]
3576 newPointLevel(faceMidPoint[facei]) = faceAnchorLevel[facei]+1;
3583 faceSet splitFaces(mesh_,
"splitFaces", cellLabels.
size());
3585 forAll(faceMidPoint, facei)
3587 if (faceMidPoint[facei] >= 0)
3589 splitFaces.insert(facei);
3593 Pout<<
"hexRef8::setRefinement : Dumping " << splitFaces.size()
3594 <<
" faces to split to faceSet " << splitFaces.objectPath() <<
endl;
3615 Pout<<
"hexRef8::setRefinement :" 3616 <<
" Finding cell anchorPoints (8 per cell)" 3627 labelList nAnchorPoints(mesh_.nCells(), 0);
3629 forAll(cellMidPoint, celli)
3631 if (cellMidPoint[celli] >= 0)
3633 cellAnchorPoints[celli].
setSize(8);
3637 forAll(pointLevel_, pointi)
3639 const labelList& pCells = mesh_.pointCells(pointi);
3643 label celli = pCells[pCelli];
3647 cellMidPoint[celli] >= 0
3648 && pointLevel_[pointi] <= cellLevel_[celli]
3651 if (nAnchorPoints[celli] == 8)
3656 <<
" of level " << cellLevel_[celli]
3657 <<
" uses more than 8 points of equal or" 3658 <<
" lower level" <<
nl 3659 <<
"Points so far:" << cellAnchorPoints[celli]
3663 cellAnchorPoints[celli][nAnchorPoints[celli]++] = pointi;
3668 forAll(cellMidPoint, celli)
3670 if (cellMidPoint[celli] >= 0)
3672 if (nAnchorPoints[celli] != 8)
3676 const labelList& cPoints = mesh_.cellPoints(celli);
3680 <<
" of level " << cellLevel_[celli]
3681 <<
" does not seem to have 8 points of equal or" 3682 <<
" lower level" <<
endl 3683 <<
"cellPoints:" << cPoints <<
endl 3698 Pout<<
"hexRef8::setRefinement :" 3699 <<
" Adding cells (1 per anchorPoint)" 3706 forAll(cellAnchorPoints, celli)
3708 const labelList& cAnchors = cellAnchorPoints[celli];
3710 if (cAnchors.
size() == 8)
3712 labelList& cAdded = cellAddedCells[celli];
3719 newCellLevel[celli] = cellLevel_[celli]+1;
3722 for (
label i = 1; i < 8; i++)
3732 mesh_.cellZones().whichZone(celli)
3736 newCellLevel(cAdded[i]) = cellLevel_[celli]+1;
3751 Pout<<
"hexRef8::setRefinement :" 3752 <<
" Marking faces to be handled" 3760 forAll(cellMidPoint, celli)
3762 if (cellMidPoint[celli] >= 0)
3764 const cell& cFaces = mesh_.cells()[celli];
3768 affectedFace.set(cFaces[i]);
3773 forAll(faceMidPoint, facei)
3775 if (faceMidPoint[facei] >= 0)
3777 affectedFace.set(facei);
3781 forAll(edgeMidPoint, edgeI)
3783 if (edgeMidPoint[edgeI] >= 0)
3785 const labelList& eFaces = mesh_.edgeFaces(edgeI);
3789 affectedFace.set(eFaces[i]);
3801 Pout<<
"hexRef8::setRefinement : Splitting faces" <<
endl;
3804 forAll(faceMidPoint, facei)
3806 if (faceMidPoint[facei] >= 0 && affectedFace.get(facei))
3812 const face& f = mesh_.faces()[facei];
3816 bool modifiedFace =
false;
3818 label anchorLevel = faceAnchorLevel[facei];
3824 label pointi = f[fp];
3826 if (pointLevel_[pointi] <= anchorLevel)
3832 faceVerts.
append(pointi);
3848 faceVerts.
append(faceMidPoint[facei]);
3881 if (mesh_.isInternalFace(facei))
3883 label oldOwn = mesh_.faceOwner()[facei];
3884 label oldNei = mesh_.faceNeighbour()[facei];
3886 checkInternalOrientation
3891 mesh_.cellCentres()[oldOwn],
3892 mesh_.cellCentres()[oldNei],
3898 label oldOwn = mesh_.faceOwner()[facei];
3900 checkBoundaryOrientation
3905 mesh_.cellCentres()[oldOwn],
3906 mesh_.faceCentres()[facei],
3915 modifiedFace =
true;
3917 modFace(meshMod, facei, newFace, own, nei);
3921 addFace(meshMod, facei, newFace, own, nei);
3927 affectedFace.unset(facei);
3937 Pout<<
"hexRef8::setRefinement :" 3938 <<
" Adding edge splits to unsplit faces" 3945 forAll(edgeMidPoint, edgeI)
3947 if (edgeMidPoint[edgeI] >= 0)
3951 const labelList& eFaces = mesh_.edgeFaces(edgeI, eFacesStorage);
3955 label facei = eFaces[i];
3957 if (faceMidPoint[facei] < 0 && affectedFace.get(facei))
3961 const face& f = mesh_.faces()[facei];
3962 const labelList& fEdges = mesh_.faceEdges
3972 newFaceVerts.append(f[fp]);
3974 label edgeI = fEdges[fp];
3976 if (edgeMidPoint[edgeI] >= 0)
3978 newFaceVerts.
append(edgeMidPoint[edgeI]);
3987 label anchorFp = findMinLevel(f);
4004 if (mesh_.isInternalFace(facei))
4006 label oldOwn = mesh_.faceOwner()[facei];
4007 label oldNei = mesh_.faceNeighbour()[facei];
4009 checkInternalOrientation
4014 mesh_.cellCentres()[oldOwn],
4015 mesh_.cellCentres()[oldNei],
4021 label oldOwn = mesh_.faceOwner()[facei];
4023 checkBoundaryOrientation
4028 mesh_.cellCentres()[oldOwn],
4029 mesh_.faceCentres()[facei],
4035 modFace(meshMod, facei, newFace, own, nei);
4038 affectedFace.unset(facei);
4050 Pout<<
"hexRef8::setRefinement :" 4051 <<
" Changing owner/neighbour for otherwise unaffected faces" 4055 forAll(affectedFace, facei)
4057 if (affectedFace.get(facei))
4059 const face& f = mesh_.faces()[facei];
4063 label anchorFp = findMinLevel(f);
4077 modFace(meshMod, facei, f, own, nei);
4080 affectedFace.unset(facei);
4095 Pout<<
"hexRef8::setRefinement :" 4096 <<
" Create new internal faces for split cells" 4100 forAll(cellMidPoint, celli)
4102 if (cellMidPoint[celli] >= 0)
4127 forAll(cellMidPoint, celli)
4129 if (cellMidPoint[celli] >= 0)
4131 minPointi =
min(minPointi, cellMidPoint[celli]);
4132 maxPointi =
max(maxPointi, cellMidPoint[celli]);
4135 forAll(faceMidPoint, facei)
4137 if (faceMidPoint[facei] >= 0)
4139 minPointi =
min(minPointi, faceMidPoint[facei]);
4140 maxPointi =
max(maxPointi, faceMidPoint[facei]);
4143 forAll(edgeMidPoint, edgeI)
4145 if (edgeMidPoint[edgeI] >= 0)
4147 minPointi =
min(minPointi, edgeMidPoint[edgeI]);
4148 maxPointi =
max(maxPointi, edgeMidPoint[edgeI]);
4152 if (minPointi !=
labelMax && minPointi != mesh_.nPoints())
4155 <<
"Added point labels not consecutive to existing mesh points." 4157 <<
"mesh_.nPoints():" << mesh_.nPoints()
4158 <<
" minPointi:" << minPointi
4159 <<
" maxPointi:" << maxPointi
4164 pointLevel_.
transfer(newPointLevel);
4179 Pout<<
"hexRef8::setRefinement :" 4180 <<
" Updating refinement history to " << cellLevel_.
size()
4181 <<
" cells" <<
endl;
4187 forAll(cellAddedCells, celli)
4189 const labelList& addedCells = cellAddedCells[celli];
4191 if (addedCells.
size())
4205 label celli = cellLabels[i];
4207 refinedCells[i].
transfer(cellAddedCells[celli]);
4210 return refinedCells;
4221 savedPointLevel_.
resize(2*pointsToStore.
size());
4224 label pointi = pointsToStore[i];
4225 savedPointLevel_.
insert(pointi, pointLevel_[pointi]);
4228 savedCellLevel_.
resize(2*cellsToStore.
size());
4231 label celli = cellsToStore[i];
4232 savedCellLevel_.
insert(celli, cellLevel_[celli]);
4241 topoChange(map, dummyMap, dummyMap, dummyMap);
4256 Pout<<
"hexRef8::topoChange :" 4257 <<
" Updating various lists" 4266 Pout<<
"hexRef8::topoChange :" 4269 <<
" nCells:" << mesh_.nCells()
4271 <<
" cellLevel_:" << cellLevel_.
size()
4274 <<
" nPoints:" << mesh_.nPoints()
4276 <<
" pointLevel_:" << pointLevel_.
size()
4280 if (reverseCellMap.
size() == cellLevel_.
size())
4286 reorder(reverseCellMap, mesh_.nCells(), -1, cellLevel_);
4294 forAll(cellMap, newCelli)
4296 label oldCelli = cellMap[newCelli];
4300 newCellLevel[newCelli] = -1;
4304 newCellLevel[newCelli] = cellLevel_[oldCelli];
4314 label newCelli = iter.key();
4315 label storedCelli = iter();
4319 if (fnd == savedCellLevel_.
end())
4322 <<
"Problem : trying to restore old value for new cell " 4323 << newCelli <<
" but cannot find old cell " << storedCelli
4324 <<
" in map of stored values " << savedCellLevel_
4327 cellLevel_[newCelli] = fnd();
4348 if (reversePointMap.
size() == pointLevel_.
size())
4351 reorder(reversePointMap, mesh_.nPoints(), -1, pointLevel_);
4364 if (oldPointi == -1)
4377 newPointLevel[
newPointi] = pointLevel_[oldPointi];
4380 pointLevel_.
transfer(newPointLevel);
4388 label storedPointi = iter();
4392 if (fnd == savedPointLevel_.
end())
4395 <<
"Problem : trying to restore old value for new point " 4396 << newPointi <<
" but cannot find old point " 4398 <<
" in map of stored values " << savedPointLevel_
4430 cellShapesPtr_.clear();
4444 Pout<<
"hexRef8::subset :" 4445 <<
" Updating various lists" 4452 <<
"Subsetting will not work in combination with unrefinement." 4454 <<
"Proceed at your own risk." <<
endl;
4462 forAll(cellMap, newCelli)
4464 newCellLevel[newCelli] = cellLevel_[cellMap[newCelli]];
4473 <<
"cellLevel_ contains illegal value -1 after mapping:" 4488 pointLevel_.
transfer(newPointLevel);
4494 <<
"pointLevel_ contains illegal value -1 after mapping:" 4503 history_.
subset(pointMap, faceMap, cellMap);
4513 cellShapesPtr_.clear();
4521 Pout<<
"hexRef8::distribute :" 4522 <<
" Updating various lists" 4542 cellShapesPtr_.clear();
4548 const scalar smallDim = 1
e-6 * mesh_.bounds().mag();
4552 Pout<<
"hexRef8::checkMesh : Using matching tolerance smallDim:" 4553 << smallDim <<
endl;
4563 labelList nei(mesh_.nFaces()-mesh_.nInternalFaces());
4566 nei[i] = mesh_.faceOwner()[i+mesh_.nInternalFaces()];
4589 label own = mesh_.faceOwner()[facei];
4590 label bFacei = facei-mesh_.nInternalFaces();
4596 <<
"Faces do not seem to be correct across coupled" 4597 <<
" boundaries" <<
endl 4598 <<
"Coupled face " << facei
4599 <<
" between owner " << own
4600 <<
" on patch " << pp.
name()
4601 <<
" and coupled neighbour " << nei[bFacei]
4602 <<
" has two faces connected to it:" 4618 scalarField neiFaceAreas(mesh_.nFaces()-mesh_.nInternalFaces());
4621 neiFaceAreas[i] = mesh_.magFaceAreas()[i+mesh_.nInternalFaces()];
4629 label facei = i+mesh_.nInternalFaces();
4631 const scalar magArea = mesh_.magFaceAreas()[facei];
4633 if (
mag(magArea - neiFaceAreas[i]) > smallDim)
4635 const face& f = mesh_.faces()[facei];
4636 label patchi = mesh_.boundaryMesh().whichPatch(facei);
4638 dumpCell(mesh_.faceOwner()[facei]);
4641 <<
"Faces do not seem to be correct across coupled" 4642 <<
" boundaries" <<
endl 4643 <<
"Coupled face " << facei
4644 <<
" on patch " << patchi
4645 <<
" " << mesh_.boundaryMesh()[
patchi].name()
4647 <<
" has face area:" << magArea
4648 <<
" (coupled) neighbour face area differs:" 4650 <<
" to within tolerance " << smallDim
4660 labelList nVerts(mesh_.nFaces()-mesh_.nInternalFaces());
4664 nVerts[i] = mesh_.faces()[i+mesh_.nInternalFaces()].size();
4672 label facei = i+mesh_.nInternalFaces();
4674 const face& f = mesh_.faces()[facei];
4676 if (f.
size() != nVerts[i])
4678 dumpCell(mesh_.faceOwner()[facei]);
4680 label patchi = mesh_.boundaryMesh().whichPatch(facei);
4683 <<
"Faces do not seem to be correct across coupled" 4684 <<
" boundaries" <<
endl 4685 <<
"Coupled face " << facei
4686 <<
" on patch " << patchi
4687 <<
" " << mesh_.boundaryMesh()[
patchi].name()
4689 <<
" has size:" << f.
size()
4690 <<
" (coupled) neighbour face has size:" 4702 pointField anchorPoints(mesh_.nFaces()-mesh_.nInternalFaces());
4706 label facei = i+mesh_.nInternalFaces();
4707 const point& fc = mesh_.faceCentres()[facei];
4708 const face& f = mesh_.faces()[facei];
4709 const vector anchorVec(mesh_.points()[f[0]] - fc);
4711 anchorPoints[i] = anchorVec;
4721 label facei = i+mesh_.nInternalFaces();
4722 const point& fc = mesh_.faceCentres()[facei];
4723 const face& f = mesh_.faces()[facei];
4724 const vector anchorVec(mesh_.points()[f[0]] - fc);
4726 if (
mag(anchorVec - anchorPoints[i]) > smallDim)
4728 dumpCell(mesh_.faceOwner()[facei]);
4730 label patchi = mesh_.boundaryMesh().whichPatch(facei);
4733 <<
"Faces do not seem to be correct across coupled" 4734 <<
" boundaries" <<
endl 4735 <<
"Coupled face " << facei
4736 <<
" on patch " << patchi
4737 <<
" " << mesh_.boundaryMesh()[
patchi].name()
4739 <<
" has anchor vector:" << anchorVec
4740 <<
" (coupled) neighbour face anchor vector differs:" 4742 <<
" to within tolerance " << smallDim
4750 Pout<<
"hexRef8::checkMesh : Returning" <<
endl;
4757 const label maxPointDiff,
4763 Pout<<
"hexRef8::checkRefinementLevels :" 4764 <<
" Checking 2:1 refinement level" <<
endl;
4769 cellLevel_.
size() != mesh_.nCells()
4770 || pointLevel_.
size() != mesh_.nPoints()
4774 <<
"cellLevel size should be number of cells" 4775 <<
" and pointLevel size should be number of points."<<
nl 4776 <<
"cellLevel:" << cellLevel_.
size()
4777 <<
" mesh.nCells():" << mesh_.nCells() <<
nl 4778 <<
"pointLevel:" << pointLevel_.
size()
4779 <<
" mesh.nPoints():" << mesh_.nPoints()
4789 for (
label facei = 0; facei < mesh_.nInternalFaces(); facei++)
4791 label own = mesh_.faceOwner()[facei];
4792 label nei = mesh_.faceNeighbour()[facei];
4794 if (
mag(cellLevel_[own] - cellLevel_[nei]) > 1)
4800 <<
"Celllevel does not satisfy 2:1 constraint." <<
nl 4801 <<
"On face " << facei <<
" owner cell " << own
4802 <<
" has refinement " << cellLevel_[own]
4803 <<
" neighbour cell " << nei <<
" has refinement " 4810 labelList neiLevel(mesh_.nFaces()-mesh_.nInternalFaces());
4814 label own = mesh_.faceOwner()[i+mesh_.nInternalFaces()];
4816 neiLevel[i] = cellLevel_[own];
4824 label facei = i+mesh_.nInternalFaces();
4826 label own = mesh_.faceOwner()[facei];
4828 if (
mag(cellLevel_[own] - neiLevel[i]) > 1)
4832 label patchi = mesh_.boundaryMesh().whichPatch(facei);
4835 <<
"Celllevel does not satisfy 2:1 constraint." 4836 <<
" On coupled face " << facei
4837 <<
" on patch " << patchi <<
" " 4838 << mesh_.boundaryMesh()[
patchi].name()
4839 <<
" owner cell " << own <<
" has refinement " 4841 <<
" (coupled) neighbour cell has refinement " 4864 forAll(syncPointLevel, pointi)
4866 if (pointLevel_[pointi] != syncPointLevel[pointi])
4869 <<
"PointLevel is not consistent across coupled patches." 4871 <<
"point:" << pointi <<
" coord:" << mesh_.points()[pointi]
4872 <<
" has level " << pointLevel_[pointi]
4873 <<
" whereas the coupled point has level " 4874 << syncPointLevel[pointi]
4882 if (maxPointDiff != -1)
4885 labelList maxPointLevel(mesh_.nPoints(), 0);
4887 forAll(maxPointLevel, pointi)
4889 const labelList& pCells = mesh_.pointCells(pointi);
4891 label& pLevel = maxPointLevel[pointi];
4895 pLevel =
max(pLevel, cellLevel_[pCells[i]]);
4911 label pointi = pointsToCheck[i];
4913 const labelList& pCells = mesh_.pointCells(pointi);
4917 label celli = pCells[i];
4921 mag(cellLevel_[celli]-maxPointLevel[pointi])
4928 <<
"Too big a difference between" 4929 <<
" point-connected cells." <<
nl 4931 <<
" cellLevel:" << cellLevel_[celli]
4932 <<
" uses point:" << pointi
4933 <<
" coord:" << mesh_.points()[pointi]
4934 <<
" which is also used by a cell with level:" 4935 << maxPointLevel[pointi]
5010 if (cellShapesPtr_.empty())
5014 Pout<<
"hexRef8::cellShapes() : calculating splitHex cellShapes." 5015 <<
" cellLevel:" << cellLevel_.
size()
5016 <<
" pointLevel:" << pointLevel_.
size()
5023 label nSplitHex = 0;
5024 label nUnrecognised = 0;
5026 forAll(cellLevel_, celli)
5028 if (meshShapes[celli].model().index() == 0)
5030 label level = cellLevel_[celli];
5034 bool haveQuads = matchHexShape
5044 cellShapesPtr_()[celli] = degenerateMatcher::match(faces);
5055 Pout<<
"hexRef8::cellShapes() :" 5056 <<
" nCells:" << mesh_.nCells() <<
" of which" <<
nl 5057 <<
" primitive:" << (mesh_.nCells()-nSplitHex-nUnrecognised)
5059 <<
" split-hex:" << nSplitHex <<
nl 5060 <<
" poly :" << nUnrecognised <<
nl 5064 return cellShapesPtr_();
5077 Pout<<
"hexRef8::getSplitPoints :" 5078 <<
" Calculating unrefineable points" <<
endl;
5085 <<
"Only call if constructed with history capability" 5093 labelList splitMaster(mesh_.nPoints(), -1);
5094 labelList splitMasterLevel(mesh_.nPoints(), 0);
5099 for (
label pointi = 0; pointi < mesh_.nPoints(); pointi++)
5101 const labelList& pCells = mesh_.pointCells(pointi);
5103 if (pCells.
size() != 8)
5105 splitMaster[pointi] = -2;
5112 forAll(visibleCells, celli)
5114 const labelList& cPoints = mesh_.cellPoints(celli);
5116 if (visibleCells[celli] != -1 && history_.
parentIndex(celli) >= 0)
5123 label pointi = cPoints[i];
5125 label masterCelli = splitMaster[pointi];
5127 if (masterCelli == -1)
5134 splitMaster[pointi] = parentIndex;
5135 splitMasterLevel[pointi] = cellLevel_[celli] - 1;
5137 else if (masterCelli == -2)
5143 (masterCelli != parentIndex)
5144 || (splitMasterLevel[pointi] != cellLevel_[celli] - 1)
5149 splitMaster[pointi] = -2;
5158 label pointi = cPoints[i];
5160 splitMaster[pointi] = -2;
5168 label facei = mesh_.nInternalFaces();
5169 facei < mesh_.nFaces();
5173 const face& f = mesh_.faces()[facei];
5177 splitMaster[f[fp]] = -2;
5184 label nSplitPoints = 0;
5186 forAll(splitMaster, pointi)
5188 if (splitMaster[pointi] >= 0)
5197 forAll(splitMaster, pointi)
5199 if (splitMaster[pointi] >= 0)
5201 splitPoints[nSplitPoints++] = pointi;
5217 Pout<<
"hexRef8::consistentUnrefinement :" 5218 <<
" Determining 2:1 consistent unrefinement" <<
endl;
5224 <<
"maxSet not implemented yet." 5236 forAll(pointsToUnrefine, i)
5238 label pointi = pointsToUnrefine[i];
5240 unrefinePoint.set(pointi);
5251 forAll(unrefinePoint, pointi)
5253 if (unrefinePoint.get(pointi))
5255 const labelList& pCells = mesh_.pointCells(pointi);
5259 unrefineCell.set(pCells[j]);
5272 for (
label facei = 0; facei < mesh_.nInternalFaces(); facei++)
5274 label own = mesh_.faceOwner()[facei];
5275 label ownLevel = cellLevel_[own] - unrefineCell.get(own);
5277 label nei = mesh_.faceNeighbour()[facei];
5278 label neiLevel = cellLevel_[nei] - unrefineCell.get(nei);
5280 if (ownLevel < (neiLevel-1))
5287 unrefineCell.set(nei);
5298 if (unrefineCell.get(own) == 0)
5304 unrefineCell.unset(own);
5308 else if (neiLevel < (ownLevel-1))
5312 unrefineCell.set(own);
5316 if (unrefineCell.get(nei) == 0)
5322 unrefineCell.unset(nei);
5330 labelList neiLevel(mesh_.nFaces()-mesh_.nInternalFaces());
5334 label own = mesh_.faceOwner()[i+mesh_.nInternalFaces()];
5336 neiLevel[i] = cellLevel_[own] - unrefineCell.get(own);
5344 label facei = i+mesh_.nInternalFaces();
5345 label own = mesh_.faceOwner()[facei];
5346 label ownLevel = cellLevel_[own] - unrefineCell.get(own);
5348 if (ownLevel < (neiLevel[i]-1))
5352 if (unrefineCell.get(own) == 0)
5358 unrefineCell.unset(own);
5362 else if (neiLevel[i] < (ownLevel-1))
5366 if (unrefineCell.get(own) == 1)
5372 unrefineCell.set(own);
5382 Pout<<
"hexRef8::consistentUnrefinement :" 5383 <<
" Changed " << nChanged
5384 <<
" refinement levels due to 2:1 conflicts." 5398 forAll(unrefinePoint, pointi)
5400 if (unrefinePoint.get(pointi))
5402 const labelList& pCells = mesh_.pointCells(pointi);
5406 if (!unrefineCell.get(pCells[j]))
5408 unrefinePoint.unset(pointi);
5420 forAll(unrefinePoint, pointi)
5422 if (unrefinePoint.get(pointi))
5431 forAll(unrefinePoint, pointi)
5433 if (unrefinePoint.get(pointi))
5435 newPointsToUnrefine[nSet++] = pointi;
5439 return newPointsToUnrefine;
5452 <<
"Only call if constructed with history capability" 5458 Pout<<
"hexRef8::setUnrefinement :" 5459 <<
" Checking initial mesh just to make sure" <<
endl;
5463 forAll(cellLevel_, celli)
5465 if (cellLevel_[celli] < 0)
5468 <<
"Illegal cell level " << cellLevel_[celli]
5469 <<
" for cell " << celli
5476 pointSet pSet(mesh_,
"splitPoints", splitPointLabels);
5479 cellSet cSet(mesh_,
"splitPointCells", splitPointLabels.
size());
5481 forAll(splitPointLabels, i)
5483 const labelList& pCells = mesh_.pointCells(splitPointLabels[i]);
5487 cSet.insert(pCells[j]);
5492 Pout<<
"hexRef8::setRefinement : Dumping " << pSet.
size()
5494 << cSet.size() <<
" cells for unrefinement to" <<
nl 5496 <<
" cellSet " << cSet.objectPath()
5508 forAll(splitPointLabels, i)
5514 splitFaces.insert(pFaces[j]);
5528 if (facesToRemove.
size() != splitFaces.size())
5531 <<
"Initial set of split points to unrefine does not" 5532 <<
" seem to be consistent or not mid points of refined cells" 5541 forAll(splitPointLabels, i)
5543 label pointi = splitPointLabels[i];
5547 const labelList& pCells = mesh_.pointCells(pointi);
5550 if (pCells.
size() != 8)
5553 <<
"splitPoint " << pointi
5554 <<
" should have 8 cells using it. It has " << pCells
5567 label celli = pCells[j];
5569 label region = cellRegion[celli];
5574 <<
"Initial set of split points to unrefine does not" 5575 <<
" seem to be consistent or not mid points" 5576 <<
" of refined cells" <<
nl 5577 <<
"cell:" << celli <<
" on splitPoint " << pointi
5578 <<
" has no region to be merged into" 5582 if (masterCelli != cellRegionMaster[region])
5585 <<
"cell:" << celli <<
" on splitPoint:" << pointi
5586 <<
" in region " << region
5587 <<
" has master:" << cellRegionMaster[region]
5588 <<
" which is not the lowest numbered cell" 5589 <<
" among the pointCells:" << pCells
5609 forAll(splitPointLabels, i)
5611 label pointi = splitPointLabels[i];
5613 const labelList& pCells = mesh_.pointCells(pointi);
5619 cellLevel_[pCells[j]]--;
5634 if (cellLevel_.
size() != mesh_.nCells())
5637 <<
"Size of cellLevel:" << cellLevel_.
size()
5638 <<
" does not equal number of cells in mesh:" << mesh_.nCells()
5642 if (pointLevel_.
size() != mesh_.nPoints())
5645 <<
"Size of pointLevel:" << pointLevel_.
size()
5646 <<
" does not equal number of points in mesh:" << mesh_.nPoints()
5651 cellLevel_.
write(write)
5652 && pointLevel_.
write(write)
5653 && level0Edge_.
write(write);
5657 writeOk = writeOk && history_.
write(write);
void distribute(const polyDistributionMap &)
Force recalculation of locally stored data for mesh distribution.
fileCheckTypes
Enumeration defining the file checking options.
const fvPatchList & patches
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.
Class containing mesh-to-mesh mapping information after a mesh distribution where we send parts of me...
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
virtual Ostream & write(const char)=0
Write character.
FvWallInfoData< WallInfo, label > 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.
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 setFaceInfo(const labelList &changedFaces, const List< Type > &changedFacesInfo)
Set initial changed faces.
void operator()(label &x, const label y) const
void setUnrefinement(const labelList &splitPointLabels, polyTopoChange &)
Remove some refinement. Needs to be supplied output of.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object of type.
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.
const labelList & pointMap() const
Old point map.
dimensionedScalar sqrt(const dimensionedScalar &ds)
Ostream & endl(Ostream &os)
Add newline and flush stream.
fileName objectPath() const
Return complete path + object name.
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 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.
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)
void distribute(const polyDistributionMap &)
Update local numbering for mesh redistribution.
labelList consistentUnrefinement(const labelList &pointsToUnrefine, const bool maxSet) const
Given proposed.
label size() const
Return number of elements in table.
scalar level0EdgeLength() const
Typical edge length between unrefined points.
label nOldPoints() const
Number of old points.
A face addition data class. A face can be inflated either from a point or from another face and can e...
void topoChange(const polyTopoChangeMap &)
Update local numbering for changed mesh.
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.
bool updateFace(const fvMesh &, const labelPair &thisPatchAndFacei, const label neighbourCelli, const FvWallInfoBase< WallInfo, Derived > &neighbourInfo, const scalar tol, TrackingData &td)
Influence of neighbouring cell.
const labelList & cellMap() const
Old cell map.
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)
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 topoChange(const polyTopoChangeMap &)
Update numbering for mesh changes.
void combineCells(const label masterCelli, const labelList &combinedCells)
Store combining 8 cells into master.
void set(const PackedList< 1 > &)
Set specified bits.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects...
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.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
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.
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
const labelList & reversePointMap() const
Reverse point map.
Pair< label > labelPair
Label pair.
static const label labelMax
List< label > labelList
A List of labels.
An STL-conforming hash table.
errorManip< error > abort(error &err)
void distribute(const polyDistributionMap &)
Update local numbering for mesh redistribution.
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.
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")
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.
const labelList & reverseCellMap() const
Reverse cell map.
void distributeCellData(List< T > &lst) const
Distribute list of cell data.
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.
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.
void distributePointData(List< T > &lst) const
Distribute list of point data.
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.
void topoChange(const polyTopoChangeMap &)
Force recalculation of locally stored data on topological change.
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...
void resize(const label nCells)
Extend/shrink storage. additional visibleCells_ elements get.
label nOldCells() const
Number of old cells.
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
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.