56 x = (
x ==
y) ?
x : value;
64 void Foam::hexRef8::reorder
85 newElems[newI] = elems[i];
89 elems.transfer(newElems);
97 if (!mesh_.isInternalFace(facei))
99 patchID = mesh_.boundary().whichPatch(facei);
108 polyTopoChange& meshMod,
115 const label patchID = getPatchIndex(facei);
119 if ((nei == -1) || (own < nei))
122 newFacei = meshMod.addFace
135 newFacei = meshMod.addFace
137 newFace.reverseFace(),
151 polyTopoChange& meshMod,
152 const label meshFacei,
153 const label meshPointi,
159 if (mesh_.isInternalFace(meshFacei))
161 return meshMod.addFace
175 return meshMod.addFace
188 void Foam::hexRef8::modifyFace
190 polyTopoChange& meshMod,
197 const label patchID = getPatchIndex(facei);
201 (own != mesh_.faceOwner()[facei])
203 mesh_.isInternalFace(facei)
204 && (nei != mesh_.faceNeighbour()[facei])
206 || (newFace != mesh_.faces()[facei])
209 if ((nei == -1) || (own < nei))
225 newFace.reverseFace(),
237 Foam::scalar Foam::hexRef8::getLevel0EdgeLength()
const
239 if (cellLevel_.size() != mesh_.nCells())
242 <<
"Number of cells in mesh:" << mesh_.nCells()
243 <<
" does not equal size of cellLevel:" << cellLevel_.size()
245 <<
"This might be because of a restart with inconsistent cellLevel."
252 const scalar great2 =
sqr(great);
269 const label cLevel = cellLevel_[celli];
271 const labelList& cEdges = mesh_.cellEdges(celli);
275 label edgeI = cEdges[i];
277 if (edgeLevel[edgeI] == -1)
279 edgeLevel[edgeI] = cLevel;
281 else if (edgeLevel[edgeI] ==
labelMax)
285 else if (edgeLevel[edgeI] != cLevel)
299 ifEqEqOp<labelMax>(),
307 const label eLevel = edgeLevel[edgeI];
309 if (eLevel >= 0 && eLevel <
labelMax)
311 const edge&
e = mesh_.edges()[edgeI];
313 scalar edgeLenSqr =
magSqr(
e.vec(mesh_.points()));
315 typEdgeLenSqr[eLevel] =
min(typEdgeLenSqr[eLevel], edgeLenSqr);
327 Pout<<
"hexRef8::getLevel0EdgeLength() :"
328 <<
" After phase1: Edgelengths (squared) per refinementlevel:"
329 << typEdgeLenSqr <<
endl;
343 const label cLevel = cellLevel_[celli];
345 const labelList& cEdges = mesh_.cellEdges(celli);
349 const edge&
e = mesh_.edges()[cEdges[i]];
351 scalar edgeLenSqr =
magSqr(
e.vec(mesh_.points()));
353 maxEdgeLenSqr[cLevel] =
max(maxEdgeLenSqr[cLevel], edgeLenSqr);
362 Pout<<
"hexRef8::getLevel0EdgeLength() :"
363 <<
" Crappy Edgelengths (squared) per refinementlevel:"
364 << maxEdgeLenSqr <<
endl;
371 forAll(typEdgeLenSqr, levelI)
373 if (typEdgeLenSqr[levelI] == great2 && maxEdgeLenSqr[levelI] >= 0)
375 typEdgeLenSqr[levelI] = maxEdgeLenSqr[levelI];
381 Pout<<
"hexRef8::getLevel0EdgeLength() :"
382 <<
" Final Edgelengths (squared) per refinementlevel:"
383 << typEdgeLenSqr <<
endl;
387 scalar level0Size = -1;
389 forAll(typEdgeLenSqr, levelI)
391 scalar lenSqr = typEdgeLenSqr[levelI];
399 Pout<<
"hexRef8::getLevel0EdgeLength() :"
400 <<
" For level:" << levelI
402 <<
" with equivalent level0 len:" << level0Size
409 if (level0Size == -1)
428 if (cellAnchorPoints[celli].size())
434 return cellAddedCells[celli][index];
441 const face&
f = mesh_.faces()[facei];
449 return cellAddedCells[celli][index];
455 Perr<<
"cell:" << celli <<
" anchorPoints:" << cellAnchorPoints[celli]
459 <<
"Could not find point " << pointi
460 <<
" in the anchorPoints for cell " << celli <<
endl
461 <<
"Does your original mesh obey the 2:1 constraint and"
462 <<
" did you use consistentRefinement to make your cells to refine"
463 <<
" obey this constraint as well?"
475 void Foam::hexRef8::getFaceNeighbours
491 mesh_.faceOwner()[facei],
496 if (mesh_.isInternalFace(facei))
502 mesh_.faceNeighbour()[facei],
521 label level = pointLevel_[
f[fp]];
523 if (level < minLevel)
541 label level = pointLevel_[
f[fp]];
543 if (level > maxLevel)
557 const label anchorLevel
564 if (pointLevel_[
f[fp]] <= anchorLevel)
573 void Foam::hexRef8::dumpCell(
const label celli)
const
575 OFstream str(mesh_.time().path()/
"cell_" +
Foam::name(celli) +
".obj");
576 Pout<<
"hexRef8 : Dumping cell as obj to " << str.
name() <<
endl;
578 const cell& cFaces = mesh_.cells()[celli];
580 Map<label> pointToObjVert;
585 const face&
f = mesh_.faces()[cFaces[i]];
589 if (pointToObjVert.insert(
f[fp], objVertI))
599 const face&
f = mesh_.faces()[cFaces[i]];
606 str <<
"l " << pointToObjVert[pointi]+1
607 <<
' ' << pointToObjVert[nexPointi]+1 <<
nl;
618 const bool searchForward,
619 const label wantedLevel
628 if (pointLevel_[pointi] < wantedLevel)
630 dumpCell(mesh_.faceOwner()[facei]);
631 if (mesh_.isInternalFace(facei))
633 dumpCell(mesh_.faceNeighbour()[facei]);
638 <<
" level:" << UIndirectList<label>(pointLevel_,
f)()
639 <<
" startFp:" << startFp
640 <<
" wantedLevel:" << wantedLevel
643 else if (pointLevel_[pointi] == wantedLevel)
658 dumpCell(mesh_.faceOwner()[facei]);
659 if (mesh_.isInternalFace(facei))
661 dumpCell(mesh_.faceNeighbour()[facei]);
666 <<
" level:" << UIndirectList<label>(pointLevel_,
f)()
667 <<
" startFp:" << startFp
668 <<
" wantedLevel:" << wantedLevel
677 const face&
f = mesh_.faces()[facei];
681 return pointLevel_[
f[findMaxLevel(
f)]];
685 label ownLevel = cellLevel_[mesh_.faceOwner()[facei]];
687 if (countAnchors(
f, ownLevel) == 4)
691 else if (countAnchors(
f, ownLevel+1) == 4)
703 void Foam::hexRef8::checkInternalOrientation
716 const vector a(compactFace.area(compactPoints));
718 const vector dir(neiPt - ownPt);
723 <<
"cell:" << celli <<
" old face:" << facei
724 <<
" newFace:" << newFace <<
endl
725 <<
" coords:" << compactPoints
726 <<
" ownPt:" << ownPt
727 <<
" neiPt:" << neiPt
731 const vector fcToOwn(compactFace.centre(compactPoints) - ownPt);
733 const scalar
s = (fcToOwn & a) / (dir & a);
735 if (s < 0.1 || s > 0.9)
738 <<
"cell:" << celli <<
" old face:" << facei
739 <<
" newFace:" << newFace <<
endl
740 <<
" coords:" << compactPoints
741 <<
" ownPt:" << ownPt
742 <<
" neiPt:" << neiPt
749 void Foam::hexRef8::checkBoundaryOrientation
751 polyTopoChange& meshMod,
755 const point& boundaryPt,
760 const pointField compactPoints(meshMod.points(), newFace);
762 const vector a(compactFace.area(compactPoints));
764 const vector dir(boundaryPt - ownPt);
769 <<
"cell:" << celli <<
" old face:" << facei
770 <<
" newFace:" << newFace
771 <<
" coords:" << compactPoints
772 <<
" ownPt:" << ownPt
773 <<
" boundaryPt:" << boundaryPt
777 const vector fcToOwn(compactFace.centre(compactPoints) - ownPt);
779 const scalar
s = (fcToOwn&dir) /
magSqr(dir);
781 if (s < 0.7 || s > 1.3)
784 <<
"cell:" << celli <<
" old face:" << facei
785 <<
" newFace:" << newFace
786 <<
" coords:" << compactPoints
787 <<
" ownPt:" << ownPt
788 <<
" boundaryPt:" << boundaryPt
795 void Foam::hexRef8::insertEdgeSplit
800 DynamicList<label>& verts
803 if (p0 < mesh_.nPoints() && p1 < mesh_.nPoints())
807 if (edgeI != -1 && edgeMidPoint[edgeI] != -1)
809 verts.append(edgeMidPoint[edgeI]);
823 const bool faceOrder,
824 const label edgeMidPointi,
825 const label anchorPointi,
826 const label faceMidPointi,
828 Map<edge>& midPointToAnchors,
829 Map<edge>& midPointToFaceMids,
830 polyTopoChange& meshMod
835 bool changed =
false;
836 bool haveTwoAnchors =
false;
840 if (edgeMidFnd == midPointToAnchors.end())
842 midPointToAnchors.insert(edgeMidPointi, edge(anchorPointi, -1));
846 edge&
e = edgeMidFnd();
848 if (anchorPointi !=
e[0])
857 if (
e[0] != -1 &&
e[1] != -1)
859 haveTwoAnchors =
true;
863 bool haveTwoFaceMids =
false;
867 if (faceMidFnd == midPointToFaceMids.end())
869 midPointToFaceMids.insert(edgeMidPointi, edge(faceMidPointi, -1));
873 edge&
e = faceMidFnd();
875 if (faceMidPointi !=
e[0])
879 e[1] = faceMidPointi;
884 if (
e[0] != -1 &&
e[1] != -1)
886 haveTwoFaceMids =
true;
893 if (changed && haveTwoAnchors && haveTwoFaceMids)
895 const edge& anchors = midPointToAnchors[edgeMidPointi];
896 const edge& faceMids = midPointToFaceMids[edgeMidPointi];
898 label otherFaceMidPointi = faceMids.otherVertex(faceMidPointi);
905 DynamicList<label> newFaceVerts(4);
906 if (faceOrder == (mesh_.faceOwner()[facei] == celli))
908 newFaceVerts.append(faceMidPointi);
919 newFaceVerts.append(edgeMidPointi);
929 newFaceVerts.append(otherFaceMidPointi);
930 newFaceVerts.append(cellMidPoint[celli]);
934 newFaceVerts.append(otherFaceMidPointi);
944 newFaceVerts.append(edgeMidPointi);
954 newFaceVerts.append(faceMidPointi);
955 newFaceVerts.append(cellMidPoint[celli]);
959 newFace.transfer(newFaceVerts);
961 label anchorCell0 = getAnchorCell
969 label anchorCell1 = getAnchorCell
975 anchors.otherVertex(anchorPointi)
982 if (anchorCell0 < anchorCell1)
987 ownPt = mesh_.points()[anchorPointi];
988 neiPt = mesh_.points()[anchors.otherVertex(anchorPointi)];
997 ownPt = mesh_.points()[anchors.otherVertex(anchorPointi)];
998 neiPt = mesh_.points()[anchorPointi];
1005 if (anchorCell0 < anchorCell1)
1007 ownPt = mesh_.points()[anchorPointi];
1008 neiPt = mesh_.points()[anchors.otherVertex(anchorPointi)];
1012 ownPt = mesh_.points()[anchors.otherVertex(anchorPointi)];
1013 neiPt = mesh_.points()[anchorPointi];
1016 checkInternalOrientation
1027 return addInternalFace
1044 void Foam::hexRef8::createInternalFaces
1054 polyTopoChange& meshMod
1060 const cell& cFaces = mesh_.cells()[celli];
1061 const label cLevel = cellLevel_[celli];
1064 Map<edge> midPointToAnchors(24);
1066 Map<edge> midPointToFaceMids(24);
1069 DynamicList<label> storage;
1073 label nFacesAdded = 0;
1077 label facei = cFaces[i];
1079 const face&
f = mesh_.faces()[facei];
1080 const labelList& fEdges = mesh_.faceEdges(facei, storage);
1085 label faceMidPointi = -1;
1087 label nAnchors = countAnchors(
f, cLevel);
1095 label anchorFp = -1;
1099 if (pointLevel_[
f[fp]] <= cLevel)
1107 label edgeMid = findLevel
1115 label faceMid = findLevel
1124 faceMidPointi =
f[faceMid];
1126 else if (nAnchors == 4)
1131 faceMidPointi = faceMidPoint[facei];
1135 dumpCell(mesh_.faceOwner()[facei]);
1136 if (mesh_.isInternalFace(facei))
1138 dumpCell(mesh_.faceNeighbour()[facei]);
1142 <<
"nAnchors:" << nAnchors
1143 <<
" facei:" << facei
1157 if (pointLevel_[point0] <= cLevel)
1166 label edgeMidPointi = -1;
1170 if (pointLevel_[
f[fp1]] <= cLevel)
1173 label edgeI = fEdges[fp0];
1175 edgeMidPointi = edgeMidPoint[edgeI];
1177 if (edgeMidPointi == -1)
1181 const labelList& cPoints = mesh_.cellPoints(celli);
1184 <<
"cell:" << celli <<
" cLevel:" << cLevel
1185 <<
" cell points:" << cPoints
1187 << UIndirectList<label>(pointLevel_, cPoints)()
1188 <<
" face:" << facei
1191 << UIndirectList<label>(pointLevel_,
f)()
1192 <<
" faceAnchorLevel:" << faceAnchorLevel[facei]
1193 <<
" faceMidPoint:" << faceMidPoint[facei]
1194 <<
" faceMidPointi:" << faceMidPointi
1202 label edgeMid = findLevel(facei,
f, fp1,
true, cLevel+1);
1204 edgeMidPointi =
f[edgeMid];
1207 label newFacei = storeMidPointInfo
1230 if (nFacesAdded == 12)
1243 if (pointLevel_[
f[fpMin1]] <= cLevel)
1246 label edgeI = fEdges[fpMin1];
1248 edgeMidPointi = edgeMidPoint[edgeI];
1250 if (edgeMidPointi == -1)
1254 const labelList& cPoints = mesh_.cellPoints(celli);
1257 <<
"cell:" << celli <<
" cLevel:" << cLevel
1258 <<
" cell points:" << cPoints
1260 << UIndirectList<label>(pointLevel_, cPoints)()
1261 <<
" face:" << facei
1264 << UIndirectList<label>(pointLevel_,
f)()
1265 <<
" faceAnchorLevel:" << faceAnchorLevel[facei]
1266 <<
" faceMidPoint:" << faceMidPoint[facei]
1267 <<
" faceMidPointi:" << faceMidPointi
1275 label edgeMid = findLevel
1284 edgeMidPointi =
f[edgeMid];
1287 newFacei = storeMidPointInfo
1310 if (nFacesAdded == 12)
1318 if (nFacesAdded == 12)
1326 void Foam::hexRef8::walkFaceToMid
1331 const label startFp,
1332 DynamicList<label>& faceVerts
1335 const face&
f = mesh_.faces()[facei];
1336 const labelList& fEdges = mesh_.faceEdges(facei);
1345 if (edgeMidPoint[fEdges[fp]] >= 0)
1347 faceVerts.append(edgeMidPoint[fEdges[fp]]);
1352 if (pointLevel_[
f[fp]] <= cLevel)
1358 else if (pointLevel_[
f[fp]] == cLevel+1)
1361 faceVerts.append(
f[fp]);
1365 else if (pointLevel_[
f[fp]] == cLevel+2)
1368 faceVerts.append(
f[fp]);
1374 void Foam::hexRef8::walkFaceFromMid
1379 const label startFp,
1380 DynamicList<label>& faceVerts
1383 const face&
f = mesh_.faces()[facei];
1384 const labelList& fEdges = mesh_.faceEdges(facei);
1390 if (pointLevel_[
f[fp]] <= cLevel)
1395 else if (pointLevel_[
f[fp]] == cLevel+1)
1398 faceVerts.append(
f[fp]);
1401 else if (pointLevel_[
f[fp]] == cLevel+2)
1411 if (edgeMidPoint[fEdges[fp]] >= 0)
1413 faceVerts.append(edgeMidPoint[fEdges[fp]]);
1422 faceVerts.append(
f[fp]);
1427 Foam::label Foam::hexRef8::faceConsistentRefinement
1430 PackedBoolList& refineCell
1436 for (
label facei = 0; facei < mesh_.nInternalFaces(); facei++)
1438 label own = mesh_.faceOwner()[facei];
1439 label ownLevel = cellLevel_[own] + refineCell.get(own);
1441 label nei = mesh_.faceNeighbour()[facei];
1442 label neiLevel = cellLevel_[nei] + refineCell.get(nei);
1444 if (ownLevel > (neiLevel+1))
1448 refineCell.set(nei);
1452 refineCell.unset(own);
1456 else if (neiLevel > (ownLevel+1))
1460 refineCell.set(own);
1464 refineCell.unset(nei);
1473 labelList neiLevel(mesh_.nFaces()-mesh_.nInternalFaces());
1477 label own = mesh_.faceOwner()[i+mesh_.nInternalFaces()];
1479 neiLevel[i] = cellLevel_[own] + refineCell.get(own);
1488 label own = mesh_.faceOwner()[i+mesh_.nInternalFaces()];
1489 label ownLevel = cellLevel_[own] + refineCell.get(own);
1491 if (ownLevel > (neiLevel[i]+1))
1495 refineCell.unset(own);
1499 else if (neiLevel[i] > (ownLevel+1))
1503 refineCell.set(own);
1513 void Foam::hexRef8::checkWantedRefinementLevels
1518 PackedBoolList refineCell(mesh_.nCells());
1521 refineCell.set(cellsToRefine[i]);
1524 for (
label facei = 0; facei < mesh_.nInternalFaces(); facei++)
1526 label own = mesh_.faceOwner()[facei];
1527 label ownLevel = cellLevel_[own] + refineCell.get(own);
1529 label nei = mesh_.faceNeighbour()[facei];
1530 label neiLevel = cellLevel_[nei] + refineCell.get(nei);
1532 if (
mag(ownLevel-neiLevel) > 1)
1538 <<
" current level:" << cellLevel_[own]
1539 <<
" level after refinement:" << ownLevel
1541 <<
"neighbour cell:" << nei
1542 <<
" current level:" << cellLevel_[nei]
1543 <<
" level after refinement:" << neiLevel
1545 <<
"which does not satisfy 2:1 constraints anymore."
1552 labelList neiLevel(mesh_.nFaces()-mesh_.nInternalFaces());
1556 label own = mesh_.faceOwner()[i+mesh_.nInternalFaces()];
1558 neiLevel[i] = cellLevel_[own] + refineCell.get(own);
1567 label facei = i + mesh_.nInternalFaces();
1569 label own = mesh_.faceOwner()[facei];
1570 label ownLevel = cellLevel_[own] + refineCell.get(own);
1572 if (
mag(ownLevel - neiLevel[i]) > 1)
1574 label patchi = mesh_.boundary().whichPatch(facei);
1578 <<
"Celllevel does not satisfy 2:1 constraint."
1579 <<
" On coupled face "
1581 <<
" on patch " <<
patchi <<
" "
1582 << mesh_.boundary()[
patchi].name()
1583 <<
" owner cell " << own
1584 <<
" current level:" << cellLevel_[own]
1585 <<
" level after refinement:" << ownLevel
1587 <<
" (coupled) neighbour cell will get refinement "
1599 Pout<<
"hexRef8::setInstance(const fileName& inst) : "
1600 <<
"Resetting file instance to " << inst <<
endl;
1603 cellLevel_.instance() = inst;
1604 pointLevel_.instance() = inst;
1605 level0Edge_.instance() = inst;
1606 history_.instance() = inst;
1610 void Foam::hexRef8::collectLevelPoints
1619 if (pointLevel_[
f[fp]] <= level)
1627 void Foam::hexRef8::collectLevelPoints
1632 DynamicList<label>&
points
1637 label pointi = meshPoints[
f[fp]];
1638 if (pointLevel_[pointi] <= level)
1646 bool Foam::hexRef8::matchHexShape
1649 const label cellLevel,
1650 DynamicList<face>& quads
1653 const cell& cFaces = mesh_.cells()[celli];
1656 DynamicList<label> verts(4);
1664 label facei = cFaces[i];
1665 const face&
f = mesh_.faces()[facei];
1668 collectLevelPoints(
f, cellLevel, verts);
1669 if (verts.size() == 4)
1671 if (mesh_.faceOwner()[facei] != celli)
1675 quads.append(
face(0));
1677 quadVerts.transfer(verts);
1682 if (quads.size() < 6)
1684 Map<labelList> pointFaces(2*cFaces.size());
1688 label facei = cFaces[i];
1689 const face&
f = mesh_.faces()[facei];
1697 collectLevelPoints(
f, cellLevel, verts);
1698 if (verts.size() == 1)
1705 if (pointLevel_[pointi] == cellLevel+1)
1708 pointFaces.find(pointi);
1709 if (iter != pointFaces.end())
1742 const face&
f = mesh_.faces()[facei];
1743 if (mesh_.faceOwner()[facei] == celli)
1745 fourFaces[pFacei] =
f;
1749 fourFaces[pFacei] =
f.reverseFace();
1755 SubList<face>(fourFaces, fourFaces.size()),
1760 if (edgeLoops.size() == 1)
1766 bigFace.meshPoints(),
1767 bigFace.edgeLoops()[0],
1772 if (verts.size() == 4)
1774 quads.append(
face(0));
1776 quadVerts.transfer(verts);
1783 return (quads.size() == 6);
1803 mesh_.facesInstance(),
1816 mesh_.facesInstance(),
1829 mesh_.facesInstance(),
1841 "refinementHistory",
1842 mesh_.facesInstance(),
1849 (readHistory ? mesh_.nCells() : 0)
1851 faceRemover_(mesh_, great)
1871 <<
"History enabled but number of visible cells "
1874 <<
" is not equal to the number of cells in the mesh "
1881 cellLevel_.size() != mesh_.
nCells()
1882 || pointLevel_.size() != mesh_.
nPoints()
1886 <<
"Restarted from inconsistent cellLevel or pointLevel files."
1890 <<
"Number of cells in mesh:" << mesh_.
nCells()
1891 <<
" does not equal size of cellLevel:" << cellLevel_.size() <<
endl
1892 <<
"Number of points in mesh:" << mesh_.
nPoints()
1893 <<
" does not equal size of pointLevel:" << pointLevel_.size()
1919 const scalar level0Edge
1934 mesh_.facesInstance(),
1947 mesh_.facesInstance(),
1960 mesh_.facesInstance(),
1969 (level0Edge >= 0 ? level0Edge : getLevel0EdgeLength())
1976 "refinementHistory",
1977 mesh_.facesInstance(),
1985 faceRemover_(mesh_, great)
1990 <<
"History enabled but number of visible cells in it "
1992 <<
" is not equal to the number of cells in the mesh "
1998 cellLevel_.size() != mesh_.
nCells()
1999 || pointLevel_.size() != mesh_.
nPoints()
2003 <<
"Incorrect cellLevel or pointLevel size." <<
endl
2004 <<
"Number of cells in mesh:" << mesh_.
nCells()
2005 <<
" does not equal size of cellLevel:" << cellLevel_.size() <<
endl
2006 <<
"Number of points in mesh:" << mesh_.
nPoints()
2007 <<
" does not equal size of pointLevel:" << pointLevel_.size()
2031 const scalar level0Edge
2046 mesh_.facesInstance(),
2059 mesh_.facesInstance(),
2072 mesh_.facesInstance(),
2081 (level0Edge >= 0 ? level0Edge : getLevel0EdgeLength())
2088 "refinementHistory",
2089 mesh_.facesInstance(),
2099 faceRemover_(mesh_, great)
2103 cellLevel_.size() != mesh_.
nCells()
2104 || pointLevel_.size() != mesh_.
nPoints()
2108 <<
"Incorrect cellLevel or pointLevel size." <<
endl
2109 <<
"Number of cells in mesh:" << mesh_.
nCells()
2110 <<
" does not equal size of cellLevel:" << cellLevel_.size() <<
endl
2111 <<
"Number of points in mesh:" << mesh_.
nPoints()
2112 <<
" does not equal size of pointLevel:" << pointLevel_.size()
2156 Pout<<
"hexRef8::consistentRefinement : Changed " << nChanged
2157 <<
" refinement levels due to 2:1 conflicts."
2186 newCellsToRefine[nRefined++] = celli;
2192 checkWantedRefinementLevels(newCellsToRefine);
2195 return newCellsToRefine;
2201 const label maxFaceDiff,
2204 const label maxPointDiff,
2208 const labelList& faceOwner = mesh_.faceOwner();
2209 const labelList& faceNeighbour = mesh_.faceNeighbour();
2212 if (maxFaceDiff <= 0)
2215 <<
"Illegal maxFaceDiff " << maxFaceDiff <<
nl
2234 forAll(allCellInfo, celli)
2240 maxFaceDiff*(cellLevel_[celli]+1),
2241 maxFaceDiff*cellLevel_[celli]
2248 label celli = cellsToRefine[i];
2250 allCellInfo[celli].count() = allCellInfo[celli].refinementCount();
2260 int dummyTrackData = 0;
2268 label facei = facesToCheck[i];
2270 if (allFaceInfo[facei].
valid(dummyTrackData))
2274 <<
"Argument facesToCheck seems to have duplicate entries!"
2276 <<
"face:" << facei <<
" occurs at positions "
2284 if (mesh_.isInternalFace(facei))
2289 const refinementData& neiData = allCellInfo[faceNeighbour[facei]];
2292 label faceRefineCount;
2295 faceCount = neiData.
count() + maxFaceDiff;
2296 faceRefineCount = faceCount + maxFaceDiff;
2300 faceCount = ownData.
count() + maxFaceDiff;
2301 faceRefineCount = faceCount + maxFaceDiff;
2313 allFaceInfo[facei] = seedFacesInfo.
last();
2317 label faceCount = ownData.
count() + maxFaceDiff;
2318 label faceRefineCount = faceCount + maxFaceDiff;
2329 allFaceInfo[facei] = seedFacesInfo.
last();
2337 forAll(faceNeighbour, facei)
2340 if (!allFaceInfo[facei].
valid(dummyTrackData))
2342 label own = faceOwner[facei];
2343 label nei = faceNeighbour[facei];
2347 if (allCellInfo[own].
count() > allCellInfo[nei].
count())
2349 allFaceInfo[facei].updateFace
2359 seedFacesInfo.
append(allFaceInfo[facei]);
2361 else if (allCellInfo[own].
count() < allCellInfo[nei].
count())
2363 allFaceInfo[facei].updateFace
2373 seedFacesInfo.
append(allFaceInfo[facei]);
2381 for (
label facei = mesh_.nInternalFaces(); facei < mesh_.nFaces(); facei++)
2384 if (!allFaceInfo[facei].
valid(dummyTrackData))
2386 label own = faceOwner[facei];
2400 seedFacesInfo.
append(faceData);
2418 Pout<<
"hexRef8::consistentSlowRefinement : Seeded "
2419 << seedFaces.
size() <<
" faces between cells with different"
2420 <<
" refinement level." <<
endl;
2426 seedFacesInfo.
clear();
2429 levelCalc.
iterate(mesh_.globalData().nTotalFaces()+1);
2437 if (maxPointDiff == -1)
2445 labelList maxPointCount(mesh_.nPoints(), 0);
2447 forAll(maxPointCount, pointi)
2449 label& pLevel = maxPointCount[pointi];
2451 const labelList& pCells = mesh_.pointCells(pointi);
2455 pLevel =
max(pLevel, allCellInfo[pCells[i]].
count());
2476 label pointi = pointsToCheck[i];
2481 const labelList& pCells = mesh_.pointCells(pointi);
2485 label celli = pCells[pCelli];
2493 maxPointCount[pointi]
2494 >
cellInfo.count() + maxFaceDiff*maxPointDiff
2502 const cell& cFaces = mesh_.cells()[celli];
2506 label facei = cFaces[cFacei];
2519 if (faceData.
count() > allFaceInfo[facei].count())
2521 changedFacesInfo.
insert(facei, faceData);
2528 label nChanged = changedFacesInfo.
size();
2543 seedFaces.
append(iter.key());
2544 seedFacesInfo.
append(iter());
2551 for (
label facei = 0; facei < mesh_.nInternalFaces(); facei++)
2553 label own = mesh_.faceOwner()[facei];
2556 + (allCellInfo[own].isRefined() ? 1 : 0);
2558 label nei = mesh_.faceNeighbour()[facei];
2561 + (allCellInfo[nei].isRefined() ? 1 : 0);
2563 if (
mag(ownLevel-neiLevel) > 1)
2569 <<
" current level:" << cellLevel_[own]
2570 <<
" current refData:" << allCellInfo[own]
2571 <<
" level after refinement:" << ownLevel
2573 <<
"neighbour cell:" << nei
2574 <<
" current level:" << cellLevel_[nei]
2575 <<
" current refData:" << allCellInfo[nei]
2576 <<
" level after refinement:" << neiLevel
2578 <<
"which does not satisfy 2:1 constraints anymore." <<
nl
2579 <<
"face:" << facei <<
" faceRefData:" << allFaceInfo[facei]
2588 labelList neiLevel(mesh_.nFaces()-mesh_.nInternalFaces());
2589 labelList neiCount(mesh_.nFaces()-mesh_.nInternalFaces());
2590 labelList neiRefCount(mesh_.nFaces()-mesh_.nInternalFaces());
2594 label own = mesh_.faceOwner()[i+mesh_.nInternalFaces()];
2595 neiLevel[i] = cellLevel_[own];
2596 neiCount[i] = allCellInfo[own].count();
2597 neiRefCount[i] = allCellInfo[own].refinementCount();
2608 label facei = i+mesh_.nInternalFaces();
2610 label own = mesh_.faceOwner()[facei];
2613 + (allCellInfo[own].isRefined() ? 1 : 0);
2617 + ((neiCount[i] >= neiRefCount[i]) ? 1 : 0);
2619 if (
mag(ownLevel - nbrLevel) > 1)
2622 label patchi = mesh_.boundary().whichPatch(facei);
2625 <<
"Celllevel does not satisfy 2:1 constraint."
2626 <<
" On coupled face "
2628 <<
" refData:" << allFaceInfo[facei]
2629 <<
" on patch " <<
patchi <<
" "
2630 << mesh_.boundary()[
patchi].name() <<
nl
2631 <<
"owner cell " << own
2632 <<
" current level:" << cellLevel_[own]
2633 <<
" current count:" << allCellInfo[own].count()
2634 <<
" current refCount:"
2635 << allCellInfo[own].refinementCount()
2636 <<
" level after refinement:" << ownLevel
2638 <<
"(coupled) neighbour cell"
2639 <<
" has current level:" << neiLevel[i]
2640 <<
" current count:" << neiCount[i]
2641 <<
" current refCount:" << neiRefCount[i]
2642 <<
" level after refinement:" << nbrLevel
2652 forAll(allCellInfo, celli)
2654 if (allCellInfo[celli].isRefined())
2664 forAll(allCellInfo, celli)
2666 if (allCellInfo[celli].isRefined())
2668 newCellsToRefine[nRefined++] = celli;
2674 Pout<<
"hexRef8::consistentSlowRefinement : From "
2675 << cellsToRefine.
size() <<
" to " << newCellsToRefine.
size()
2676 <<
" cells to refine." <<
endl;
2679 return newCellsToRefine;
2685 const label maxFaceDiff,
2690 const labelList& faceOwner = mesh_.faceOwner();
2691 const labelList& faceNeighbour = mesh_.faceNeighbour();
2693 if (maxFaceDiff <= 0)
2696 <<
"Illegal maxFaceDiff " << maxFaceDiff <<
nl
2700 const scalar level0Size = 2*maxFaceDiff*level0EdgeLength();
2715 int dummyTrackData = 0;
2721 label celli = cellsToRefine[i];
2726 mesh_.cellCentres()[celli],
2731 forAll(allCellInfo, celli)
2733 if (!allCellInfo[celli].
valid(dummyTrackData))
2738 mesh_.cellCentres()[celli],
2754 label facei = facesToCheck[i];
2756 if (allFaceInfo[facei].
valid(dummyTrackData))
2760 <<
"Argument facesToCheck seems to have duplicate entries!"
2762 <<
"face:" << facei <<
" occurs at positions "
2767 label own = faceOwner[facei];
2771 allCellInfo[own].valid(dummyTrackData)
2772 ? allCellInfo[own].originLevel()
2776 if (!mesh_.isInternalFace(facei))
2780 const point& fc = mesh_.faceCentres()[facei];
2789 allFaceInfo[facei].updateFace
2801 label nei = faceNeighbour[facei];
2805 allCellInfo[nei].valid(dummyTrackData)
2806 ? allCellInfo[nei].originLevel()
2810 if (ownLevel == neiLevel)
2813 allFaceInfo[facei].updateFace
2822 allFaceInfo[facei].updateFace
2835 allFaceInfo[facei].updateFace
2844 allFaceInfo[facei].updateFace
2856 seedFacesInfo.
append(allFaceInfo[facei]);
2863 forAll(faceNeighbour, facei)
2866 if (!allFaceInfo[facei].
valid(dummyTrackData))
2868 label own = faceOwner[facei];
2872 allCellInfo[own].valid(dummyTrackData)
2873 ? allCellInfo[own].originLevel()
2877 label nei = faceNeighbour[facei];
2881 allCellInfo[nei].valid(dummyTrackData)
2882 ? allCellInfo[nei].originLevel()
2886 if (ownLevel > neiLevel)
2890 allFaceInfo[facei].updateFace
2899 seedFacesInfo.
append(allFaceInfo[facei]);
2901 else if (neiLevel > ownLevel)
2904 allFaceInfo[facei].updateFace
2913 seedFacesInfo.
append(allFaceInfo[facei]);
2929 mesh_.globalData().nTotalCells()+1,
2970 label celli = cellsToRefine[i];
2972 allCellInfo[celli].originLevel() =
sizeof(
label)*8-2;
2973 allCellInfo[celli].origin() = cc[celli];
2980 forAll(allCellInfo, celli)
2982 label wanted = allCellInfo[celli].wantedLevel(cc[celli]);
2984 if (wanted > cellLevel_[celli]+1)
2999 Pout<<
"hexRef8::consistentSlowRefinement2 : Changed " << nChanged
3000 <<
" refinement levels due to 2:1 conflicts."
3028 newCellsToRefine[nRefined++] = celli;
3034 Pout<<
"hexRef8::consistentSlowRefinement2 : From "
3035 << cellsToRefine.
size() <<
" to " << newCellsToRefine.
size()
3036 <<
" cells to refine." <<
endl;
3041 cellSet cellsIn(mesh_,
"cellsToRefineIn", cellsToRefine);
3042 Pout<<
"hexRef8::consistentSlowRefinement2 : writing "
3043 << cellsIn.
size() <<
" to cellSet "
3048 cellSet cellsOut(mesh_,
"cellsToRefineOut", newCellsToRefine);
3049 Pout<<
"hexRef8::consistentSlowRefinement2 : writing "
3050 << cellsOut.
size() <<
" to cellSet "
3057 forAll(newCellsToRefine, i)
3068 mesh_,
"cellsToRefineOut2", newCellsToRefine.
size()
3077 Pout<<
"hexRef8::consistentSlowRefinement2 : writing "
3078 << cellsOut2.
size() <<
" to cellSet "
3091 <<
"Cell:" << celli <<
" cc:"
3092 << mesh_.cellCentres()[celli]
3093 <<
" was not marked for refinement but does not obey"
3094 <<
" 2:1 constraints."
3101 return newCellsToRefine;
3113 Pout<<
"hexRef8::setRefinement :"
3114 <<
" Checking initial mesh just to make sure" <<
endl;
3125 forAll(cellLevel_, celli)
3127 newCellLevel.
append(cellLevel_[celli]);
3130 forAll(pointLevel_, pointi)
3132 newPointLevel.
append(pointLevel_[pointi]);
3138 Pout<<
"hexRef8::setRefinement :"
3139 <<
" Allocating " << cellLabels.
size() <<
" cell midpoints."
3147 labelList cellMidPoint(mesh_.nCells(), -1);
3151 label celli = cellLabels[i];
3153 label anchorPointi = mesh_.faces()[mesh_.cells()[celli][0]][0];
3155 cellMidPoint[celli] = meshMod.
addPoint
3157 mesh_.cellCentres()[celli],
3162 newPointLevel(cellMidPoint[celli]) = cellLevel_[celli]+1;
3168 cellSet splitCells(mesh_,
"splitCells", cellLabels.
size());
3170 forAll(cellMidPoint, celli)
3172 if (cellMidPoint[celli] >= 0)
3174 splitCells.
insert(celli);
3178 Pout<<
"hexRef8::setRefinement : Dumping " << splitCells.
size()
3179 <<
" cells to split to cellSet " << splitCells.
objectPath()
3192 Pout<<
"hexRef8::setRefinement :"
3193 <<
" Allocating edge midpoints."
3202 labelList edgeMidPoint(mesh_.nEdges(), -1);
3205 forAll(cellMidPoint, celli)
3207 if (cellMidPoint[celli] >= 0)
3209 const labelList& cEdges = mesh_.cellEdges(celli);
3213 label edgeI = cEdges[i];
3215 const edge&
e = mesh_.edges()[edgeI];
3219 pointLevel_[
e[0]] <= cellLevel_[celli]
3220 && pointLevel_[
e[1]] <= cellLevel_[celli]
3223 edgeMidPoint[edgeI] = 12345;
3250 forAll(edgeMidPoint, edgeI)
3252 if (edgeMidPoint[edgeI] >= 0)
3255 edgeMids[edgeI] = mesh_.edges()[edgeI].centre(mesh_.points());
3263 point(-great, -great, -great)
3268 forAll(edgeMidPoint, edgeI)
3270 if (edgeMidPoint[edgeI] >= 0)
3275 const edge&
e = mesh_.edges()[edgeI];
3277 edgeMidPoint[edgeI] = meshMod.
addPoint
3284 newPointLevel(edgeMidPoint[edgeI]) =
3297 OFstream str(mesh_.time().path()/
"edgeMidPoint.obj");
3299 forAll(edgeMidPoint, edgeI)
3301 if (edgeMidPoint[edgeI] >= 0)
3303 const edge&
e = mesh_.edges()[edgeI];
3309 Pout<<
"hexRef8::setRefinement :"
3310 <<
" Dumping edge centres to split to file " << str.
name() <<
endl;
3320 Pout<<
"hexRef8::setRefinement :"
3321 <<
" Allocating face midpoints."
3327 labelList faceAnchorLevel(mesh_.nFaces());
3329 for (
label facei = 0; facei < mesh_.nFaces(); facei++)
3331 faceAnchorLevel[facei] = faceLevel(facei);
3336 labelList faceMidPoint(mesh_.nFaces(), -1);
3341 for (
label facei = 0; facei < mesh_.nInternalFaces(); facei++)
3343 if (faceAnchorLevel[facei] >= 0)
3345 label own = mesh_.faceOwner()[facei];
3346 label ownLevel = cellLevel_[own];
3347 label newOwnLevel = ownLevel + (cellMidPoint[own] >= 0 ? 1 : 0);
3349 label nei = mesh_.faceNeighbour()[facei];
3350 label neiLevel = cellLevel_[nei];
3351 label newNeiLevel = neiLevel + (cellMidPoint[nei] >= 0 ? 1 : 0);
3355 newOwnLevel >
max(ownLevel, faceAnchorLevel[facei])
3356 || newNeiLevel >
max(neiLevel, faceAnchorLevel[facei])
3359 faceMidPoint[facei] = 12345;
3372 labelList neiLevel(mesh_.nFaces()-mesh_.nInternalFaces());
3373 labelList newNeiLevel(mesh_.nFaces()-mesh_.nInternalFaces());
3377 label own = mesh_.faceOwner()[i+mesh_.nInternalFaces()];
3378 label ownLevel = cellLevel_[own];
3379 label newOwnLevel = ownLevel + (cellMidPoint[own] >= 0 ? 1 : 0);
3381 neiLevel[i] = ownLevel;
3382 newNeiLevel[i] = newOwnLevel;
3393 label facei = i+mesh_.nInternalFaces();
3395 if (faceAnchorLevel[facei] >= 0)
3397 label own = mesh_.faceOwner()[facei];
3398 label ownLevel = cellLevel_[own];
3399 label newOwnLevel = ownLevel + (cellMidPoint[own] >= 0 ? 1 : 0);
3403 newOwnLevel >
max(ownLevel, faceAnchorLevel[facei])
3404 || newNeiLevel[i] >
max(neiLevel[i], faceAnchorLevel[facei])
3407 faceMidPoint[facei] = 12345;
3432 mesh_.nFaces()-mesh_.nInternalFaces(),
3433 point(-great, -great, -great)
3438 label facei = i+mesh_.nInternalFaces();
3440 if (faceMidPoint[facei] >= 0)
3442 bFaceMids[i] = mesh_.faceCentres()[facei];
3452 forAll(faceMidPoint, facei)
3454 if (faceMidPoint[facei] >= 0)
3459 const face&
f = mesh_.faces()[facei];
3461 faceMidPoint[facei] = meshMod.
addPoint
3464 facei < mesh_.nInternalFaces()
3465 ? mesh_.faceCentres()[facei]
3466 : bFaceMids[facei-mesh_.nInternalFaces()]
3474 newPointLevel(faceMidPoint[facei]) = faceAnchorLevel[facei]+1;
3481 faceSet splitFaces(mesh_,
"splitFaces", cellLabels.
size());
3483 forAll(faceMidPoint, facei)
3485 if (faceMidPoint[facei] >= 0)
3487 splitFaces.
insert(facei);
3491 Pout<<
"hexRef8::setRefinement : Dumping " << splitFaces.
size()
3492 <<
" faces to split to faceSet " << splitFaces.
objectPath() <<
endl;
3513 Pout<<
"hexRef8::setRefinement :"
3514 <<
" Finding cell anchorPoints (8 per cell)"
3525 labelList nAnchorPoints(mesh_.nCells(), 0);
3527 forAll(cellMidPoint, celli)
3529 if (cellMidPoint[celli] >= 0)
3531 cellAnchorPoints[celli].
setSize(8);
3535 forAll(pointLevel_, pointi)
3537 const labelList& pCells = mesh_.pointCells(pointi);
3541 label celli = pCells[pCelli];
3545 cellMidPoint[celli] >= 0
3546 && pointLevel_[pointi] <= cellLevel_[celli]
3549 if (nAnchorPoints[celli] == 8)
3554 <<
" of level " << cellLevel_[celli]
3555 <<
" uses more than 8 points of equal or"
3556 <<
" lower level" <<
nl
3557 <<
"Points so far:" << cellAnchorPoints[celli]
3561 cellAnchorPoints[celli][nAnchorPoints[celli]++] = pointi;
3566 forAll(cellMidPoint, celli)
3568 if (cellMidPoint[celli] >= 0)
3570 if (nAnchorPoints[celli] != 8)
3574 const labelList& cPoints = mesh_.cellPoints(celli);
3578 <<
" of level " << cellLevel_[celli]
3579 <<
" does not seem to have 8 points of equal or"
3580 <<
" lower level" <<
endl
3581 <<
"cellPoints:" << cPoints <<
endl
3596 Pout<<
"hexRef8::setRefinement :"
3597 <<
" Adding cells (1 per anchorPoint)"
3604 forAll(cellAnchorPoints, celli)
3606 const labelList& cAnchors = cellAnchorPoints[celli];
3608 if (cAnchors.
size() == 8)
3610 labelList& cAdded = cellAddedCells[celli];
3617 newCellLevel[celli] = cellLevel_[celli]+1;
3619 for (
label i = 1; i < 8; i++)
3621 cAdded[i] = meshMod.
addCell(celli);
3622 newCellLevel(cAdded[i]) = cellLevel_[celli] + 1;
3637 Pout<<
"hexRef8::setRefinement :"
3638 <<
" Marking faces to be handled"
3646 forAll(cellMidPoint, celli)
3648 if (cellMidPoint[celli] >= 0)
3650 const cell& cFaces = mesh_.cells()[celli];
3654 affectedFace.
set(cFaces[i]);
3659 forAll(faceMidPoint, facei)
3661 if (faceMidPoint[facei] >= 0)
3663 affectedFace.
set(facei);
3667 forAll(edgeMidPoint, edgeI)
3669 if (edgeMidPoint[edgeI] >= 0)
3671 const labelList& eFaces = mesh_.edgeFaces(edgeI);
3675 affectedFace.
set(eFaces[i]);
3687 Pout<<
"hexRef8::setRefinement : Splitting faces" <<
endl;
3690 forAll(faceMidPoint, facei)
3692 if (faceMidPoint[facei] >= 0 && affectedFace.
get(facei))
3698 const face&
f = mesh_.faces()[facei];
3702 bool modifiedFace =
false;
3704 label anchorLevel = faceAnchorLevel[facei];
3712 if (pointLevel_[pointi] <= anchorLevel)
3718 faceVerts.
append(pointi);
3734 faceVerts.
append(faceMidPoint[facei]);
3767 if (mesh_.isInternalFace(facei))
3769 label oldOwn = mesh_.faceOwner()[facei];
3770 label oldNei = mesh_.faceNeighbour()[facei];
3772 checkInternalOrientation
3777 mesh_.cellCentres()[oldOwn],
3778 mesh_.cellCentres()[oldNei],
3784 label oldOwn = mesh_.faceOwner()[facei];
3786 checkBoundaryOrientation
3791 mesh_.cellCentres()[oldOwn],
3792 mesh_.faceCentres()[facei],
3801 modifiedFace =
true;
3803 modifyFace(meshMod, facei, newFace, own, nei);
3807 addFace(meshMod, facei, newFace, own, nei);
3813 affectedFace.
unset(facei);
3823 Pout<<
"hexRef8::setRefinement :"
3824 <<
" Adding edge splits to unsplit faces"
3831 forAll(edgeMidPoint, edgeI)
3833 if (edgeMidPoint[edgeI] >= 0)
3837 const labelList& eFaces = mesh_.edgeFaces(edgeI, eFacesStorage);
3841 label facei = eFaces[i];
3843 if (faceMidPoint[facei] < 0 && affectedFace.
get(facei))
3847 const face&
f = mesh_.faces()[facei];
3848 const labelList& fEdges = mesh_.faceEdges
3860 label edgeI = fEdges[fp];
3862 if (edgeMidPoint[edgeI] >= 0)
3864 newFaceVerts.
append(edgeMidPoint[edgeI]);
3873 label anchorFp = findMinLevel(
f);
3890 if (mesh_.isInternalFace(facei))
3892 label oldOwn = mesh_.faceOwner()[facei];
3893 label oldNei = mesh_.faceNeighbour()[facei];
3895 checkInternalOrientation
3900 mesh_.cellCentres()[oldOwn],
3901 mesh_.cellCentres()[oldNei],
3907 label oldOwn = mesh_.faceOwner()[facei];
3909 checkBoundaryOrientation
3914 mesh_.cellCentres()[oldOwn],
3915 mesh_.faceCentres()[facei],
3921 modifyFace(meshMod, facei, newFace, own, nei);
3924 affectedFace.
unset(facei);
3936 Pout<<
"hexRef8::setRefinement :"
3937 <<
" Changing owner/neighbour for otherwise unaffected faces"
3941 forAll(affectedFace, facei)
3943 if (affectedFace.
get(facei))
3945 const face&
f = mesh_.faces()[facei];
3949 label anchorFp = findMinLevel(
f);
3963 modifyFace(meshMod, facei,
f, own, nei);
3966 affectedFace.
unset(facei);
3981 Pout<<
"hexRef8::setRefinement :"
3982 <<
" Create new internal faces for split cells"
3986 forAll(cellMidPoint, celli)
3988 if (cellMidPoint[celli] >= 0)
4013 forAll(cellMidPoint, celli)
4015 if (cellMidPoint[celli] >= 0)
4017 minPointi =
min(minPointi, cellMidPoint[celli]);
4018 maxPointi =
max(maxPointi, cellMidPoint[celli]);
4021 forAll(faceMidPoint, facei)
4023 if (faceMidPoint[facei] >= 0)
4025 minPointi =
min(minPointi, faceMidPoint[facei]);
4026 maxPointi =
max(maxPointi, faceMidPoint[facei]);
4029 forAll(edgeMidPoint, edgeI)
4031 if (edgeMidPoint[edgeI] >= 0)
4033 minPointi =
min(minPointi, edgeMidPoint[edgeI]);
4034 maxPointi =
max(maxPointi, edgeMidPoint[edgeI]);
4038 if (minPointi !=
labelMax && minPointi != mesh_.nPoints())
4041 <<
"Added point labels not consecutive to existing mesh points."
4043 <<
"mesh_.nPoints():" << mesh_.nPoints()
4044 <<
" minPointi:" << minPointi
4045 <<
" maxPointi:" << maxPointi
4050 pointLevel_.transfer(newPointLevel);
4051 cellLevel_.transfer(newCellLevel);
4054 setInstance(mesh_.facesInstance());
4061 if (history_.active())
4065 Pout<<
"hexRef8::setRefinement :"
4066 <<
" Updating refinement history to " << cellLevel_.size()
4067 <<
" cells" <<
endl;
4071 history_.resize(cellLevel_.size());
4073 forAll(cellAddedCells, celli)
4075 const labelList& addedCells = cellAddedCells[celli];
4077 if (addedCells.
size())
4080 history_.storeSplit(celli, addedCells);
4091 label celli = cellLabels[i];
4093 refinedCells[i].
transfer(cellAddedCells[celli]);
4096 return refinedCells;
4105 Pout<<
"hexRef8::topoChange :"
4106 <<
" Updating various lists"
4115 Pout<<
"hexRef8::topoChange :"
4118 <<
" nCells:" << mesh_.nCells()
4120 <<
" cellLevel_:" << cellLevel_.size()
4123 <<
" nPoints:" << mesh_.nPoints()
4125 <<
" pointLevel_:" << pointLevel_.size()
4129 if (reverseCellMap.
size() == cellLevel_.size())
4135 reorder(reverseCellMap, mesh_.nCells(), -1, cellLevel_);
4143 forAll(cellMap, newCelli)
4145 label oldCelli = cellMap[newCelli];
4149 newCellLevel[newCelli] = -1;
4153 newCellLevel[newCelli] = cellLevel_[oldCelli];
4165 if (reversePointMap.
size() == pointLevel_.size())
4168 reorder(reversePointMap, mesh_.nPoints(), -1, pointLevel_);
4181 if (oldPointi == -1)
4187 newPointLevel[
newPointi] = pointLevel_[oldPointi];
4190 pointLevel_.
transfer(newPointLevel);
4195 if (history_.active())
4197 history_.topoChange(map);
4201 setInstance(mesh_.facesInstance());
4204 faceRemover_.topoChange(map);
4207 cellShapesPtr_.clear();
4221 Pout<<
"hexRef8::subset :"
4222 <<
" Updating various lists"
4226 if (history_.active())
4229 <<
"Subsetting will not work in combination with unrefinement."
4231 <<
"Proceed at your own risk." <<
endl;
4239 forAll(cellMap, newCelli)
4241 newCellLevel[newCelli] = cellLevel_[cellMap[newCelli]];
4250 <<
"cellLevel_ contains illegal value -1 after mapping:"
4265 pointLevel_.
transfer(newPointLevel);
4271 <<
"pointLevel_ contains illegal value -1 after mapping:"
4278 if (history_.active())
4280 history_.subset(pointMap,
faceMap, cellMap);
4284 setInstance(mesh_.facesInstance());
4290 cellShapesPtr_.clear();
4313 Pout<<
"hexRef8::distribute :"
4314 <<
" Updating various lists"
4325 if (history_.active())
4327 history_.distribute(map);
4331 faceRemover_.distribute(map);
4334 cellShapesPtr_.clear();
4341 const bool validBoundary
4362 const scalar smallDim = 1
e-6 * mesh_.bounds().mag();
4366 Pout<<
"hexRef8::checkMesh : Using matching tolerance smallDim:"
4367 << smallDim <<
endl;
4377 labelList nei(mesh_.nFaces()-mesh_.nInternalFaces());
4380 nei[i] = mesh_.faceOwner()[i+mesh_.nInternalFaces()];
4403 label own = mesh_.faceOwner()[facei];
4404 label bFacei = facei-mesh_.nInternalFaces();
4410 <<
"Faces do not seem to be correct across coupled"
4411 <<
" boundaries" <<
endl
4412 <<
"Coupled face " << facei
4413 <<
" between owner " << own
4414 <<
" on patch " << pp.
name()
4415 <<
" and coupled neighbour " << nei[bFacei]
4416 <<
" has two faces connected to it:"
4432 scalarField neiFaceAreas(mesh_.nFaces()-mesh_.nInternalFaces());
4435 neiFaceAreas[i] = mesh_.magFaceAreas()[i+mesh_.nInternalFaces()];
4443 label facei = i+mesh_.nInternalFaces();
4445 const scalar magArea = mesh_.magFaceAreas()[facei];
4447 if (
mag(magArea - neiFaceAreas[i]) > smallDim)
4449 const face&
f = mesh_.faces()[facei];
4450 label patchi = mesh_.boundary().whichPatch(facei);
4452 dumpCell(mesh_.faceOwner()[facei]);
4455 <<
"Faces do not seem to be correct across coupled"
4456 <<
" boundaries" <<
endl
4457 <<
"Coupled face " << facei
4458 <<
" on patch " <<
patchi
4459 <<
" " << mesh_.boundary()[
patchi].name()
4461 <<
" has face area:" << magArea
4462 <<
" (coupled) neighbour face area differs:"
4464 <<
" to within tolerance " << smallDim
4474 labelList nVerts(mesh_.nFaces()-mesh_.nInternalFaces());
4478 nVerts[i] = mesh_.faces()[i+mesh_.nInternalFaces()].
size();
4486 label facei = i+mesh_.nInternalFaces();
4488 const face&
f = mesh_.faces()[facei];
4490 if (
f.
size() != nVerts[i])
4492 dumpCell(mesh_.faceOwner()[facei]);
4494 label patchi = mesh_.boundary().whichPatch(facei);
4497 <<
"Faces do not seem to be correct across coupled"
4498 <<
" boundaries" <<
endl
4499 <<
"Coupled face " << facei
4500 <<
" on patch " <<
patchi
4501 <<
" " << mesh_.boundary()[
patchi].name()
4503 <<
" has size:" <<
f.
size()
4504 <<
" (coupled) neighbour face has size:"
4516 pointField anchorPoints(mesh_.nFaces()-mesh_.nInternalFaces());
4520 label facei = i+mesh_.nInternalFaces();
4521 const point& fc = mesh_.faceCentres()[facei];
4522 const face&
f = mesh_.faces()[facei];
4523 const vector anchorVec(mesh_.points()[
f[0]] - fc);
4525 anchorPoints[i] = anchorVec;
4535 label facei = i+mesh_.nInternalFaces();
4536 const point& fc = mesh_.faceCentres()[facei];
4537 const face&
f = mesh_.faces()[facei];
4538 const vector anchorVec(mesh_.points()[
f[0]] - fc);
4540 if (
mag(anchorVec - anchorPoints[i]) > smallDim)
4542 dumpCell(mesh_.faceOwner()[facei]);
4544 label patchi = mesh_.boundary().whichPatch(facei);
4547 <<
"Faces do not seem to be correct across coupled"
4548 <<
" boundaries" <<
endl
4549 <<
"Coupled face " << facei
4550 <<
" on patch " <<
patchi
4551 <<
" " << mesh_.boundary()[
patchi].name()
4553 <<
" has anchor vector:" << anchorVec
4554 <<
" (coupled) neighbour face anchor vector differs:"
4556 <<
" to within tolerance " << smallDim
4564 Pout<<
"hexRef8::checkMesh : Returning" <<
endl;
4571 const label maxPointDiff,
4577 Pout<<
"hexRef8::checkRefinementLevels :"
4578 <<
" Checking 2:1 refinement level" <<
endl;
4583 cellLevel_.size() != mesh_.nCells()
4584 || pointLevel_.size() != mesh_.nPoints()
4588 <<
"cellLevel size should be number of cells"
4589 <<
" and pointLevel size should be number of points."<<
nl
4590 <<
"cellLevel:" << cellLevel_.size()
4591 <<
" mesh.nCells():" << mesh_.nCells() <<
nl
4592 <<
"pointLevel:" << pointLevel_.size()
4593 <<
" mesh.nPoints():" << mesh_.nPoints()
4603 for (
label facei = 0; facei < mesh_.nInternalFaces(); facei++)
4605 label own = mesh_.faceOwner()[facei];
4606 label nei = mesh_.faceNeighbour()[facei];
4608 if (
mag(cellLevel_[own] - cellLevel_[nei]) > 1)
4614 <<
"Celllevel does not satisfy 2:1 constraint." <<
nl
4615 <<
"On face " << facei <<
" owner cell " << own
4616 <<
" has refinement " << cellLevel_[own]
4617 <<
" neighbour cell " << nei <<
" has refinement "
4624 labelList neiLevel(mesh_.nFaces()-mesh_.nInternalFaces());
4628 label own = mesh_.faceOwner()[i+mesh_.nInternalFaces()];
4630 neiLevel[i] = cellLevel_[own];
4638 label facei = i+mesh_.nInternalFaces();
4640 label own = mesh_.faceOwner()[facei];
4642 if (
mag(cellLevel_[own] - neiLevel[i]) > 1)
4646 label patchi = mesh_.boundary().whichPatch(facei);
4649 <<
"Celllevel does not satisfy 2:1 constraint."
4650 <<
" On coupled face " << facei
4651 <<
" on patch " <<
patchi <<
" "
4652 << mesh_.boundary()[
patchi].name()
4653 <<
" owner cell " << own <<
" has refinement "
4655 <<
" (coupled) neighbour cell has refinement "
4678 forAll(syncPointLevel, pointi)
4680 if (pointLevel_[pointi] != syncPointLevel[pointi])
4683 <<
"PointLevel is not consistent across coupled patches."
4685 <<
"point:" << pointi <<
" coord:" << mesh_.points()[pointi]
4686 <<
" has level " << pointLevel_[pointi]
4687 <<
" whereas the coupled point has level "
4688 << syncPointLevel[pointi]
4696 if (maxPointDiff != -1)
4699 labelList maxPointLevel(mesh_.nPoints(), 0);
4701 forAll(maxPointLevel, pointi)
4703 const labelList& pCells = mesh_.pointCells(pointi);
4705 label& pLevel = maxPointLevel[pointi];
4709 pLevel =
max(pLevel, cellLevel_[pCells[i]]);
4725 label pointi = pointsToCheck[i];
4727 const labelList& pCells = mesh_.pointCells(pointi);
4731 label celli = pCells[i];
4735 mag(cellLevel_[celli]-maxPointLevel[pointi])
4742 <<
"Too big a difference between"
4743 <<
" point-connected cells." <<
nl
4745 <<
" cellLevel:" << cellLevel_[celli]
4746 <<
" uses point:" << pointi
4747 <<
" coord:" << mesh_.points()[pointi]
4748 <<
" which is also used by a cell with level:"
4749 << maxPointLevel[pointi]
4824 if (cellShapesPtr_.empty())
4828 Pout<<
"hexRef8::cellShapes() : calculating splitHex cellShapes."
4829 <<
" cellLevel:" << cellLevel_.size()
4830 <<
" pointLevel:" << pointLevel_.size()
4837 label nSplitHex = 0;
4838 label nUnrecognised = 0;
4840 forAll(cellLevel_, celli)
4842 if (meshShapes[celli].model().index() == 0)
4844 label level = cellLevel_[celli];
4848 bool haveQuads = matchHexShape
4858 cellShapesPtr_()[celli] = degenerateMatcher::match(faces);
4869 Pout<<
"hexRef8::cellShapes() :"
4870 <<
" nCells:" << mesh_.nCells() <<
" of which" <<
nl
4871 <<
" primitive:" << (mesh_.nCells()-nSplitHex-nUnrecognised)
4873 <<
" split-hex:" << nSplitHex <<
nl
4874 <<
" poly :" << nUnrecognised <<
nl
4878 return cellShapesPtr_();
4886 checkRefinementLevels(-1,
labelList(0));
4891 Pout<<
"hexRef8::getSplitPoints :"
4892 <<
" Calculating unrefineable points" <<
endl;
4896 if (!history_.active())
4899 <<
"Only call if constructed with history capability"
4907 labelList splitMaster(mesh_.nPoints(), -1);
4908 labelList splitMasterLevel(mesh_.nPoints(), 0);
4913 for (
label pointi = 0; pointi < mesh_.nPoints(); pointi++)
4915 const labelList& pCells = mesh_.pointCells(pointi);
4917 if (pCells.
size() != 8)
4919 splitMaster[pointi] = -2;
4924 const labelList& visibleCells = history_.visibleCells();
4926 forAll(visibleCells, celli)
4928 const labelList& cPoints = mesh_.cellPoints(celli);
4930 if (visibleCells[celli] != -1 && history_.parentIndex(celli) >= 0)
4932 label parentIndex = history_.parentIndex(celli);
4937 label pointi = cPoints[i];
4939 label masterCelli = splitMaster[pointi];
4941 if (masterCelli == -1)
4948 splitMaster[pointi] = parentIndex;
4949 splitMasterLevel[pointi] = cellLevel_[celli] - 1;
4951 else if (masterCelli == -2)
4957 (masterCelli != parentIndex)
4958 || (splitMasterLevel[pointi] != cellLevel_[celli] - 1)
4963 splitMaster[pointi] = -2;
4972 label pointi = cPoints[i];
4974 splitMaster[pointi] = -2;
4982 label facei = mesh_.nInternalFaces();
4983 facei < mesh_.nFaces();
4987 const face&
f = mesh_.faces()[facei];
4991 splitMaster[
f[fp]] = -2;
4998 label nSplitPoints = 0;
5000 forAll(splitMaster, pointi)
5002 if (splitMaster[pointi] >= 0)
5011 forAll(splitMaster, pointi)
5013 if (splitMaster[pointi] >= 0)
5015 splitPoints[nSplitPoints++] = pointi;
5031 Pout<<
"hexRef8::consistentUnrefinement :"
5032 <<
" Determining 2:1 consistent unrefinement" <<
endl;
5038 <<
"maxSet not implemented yet."
5050 forAll(pointsToUnrefine, i)
5052 label pointi = pointsToUnrefine[i];
5054 unrefinePoint.
set(pointi);
5065 forAll(unrefinePoint, pointi)
5067 if (unrefinePoint.
get(pointi))
5069 const labelList& pCells = mesh_.pointCells(pointi);
5073 unrefineCell.
set(pCells[j]);
5086 for (
label facei = 0; facei < mesh_.nInternalFaces(); facei++)
5088 label own = mesh_.faceOwner()[facei];
5089 label ownLevel = cellLevel_[own] - unrefineCell.
get(own);
5091 label nei = mesh_.faceNeighbour()[facei];
5092 label neiLevel = cellLevel_[nei] - unrefineCell.
get(nei);
5094 if (ownLevel < (neiLevel-1))
5101 unrefineCell.
set(nei);
5112 if (unrefineCell.
get(own) == 0)
5118 unrefineCell.
unset(own);
5122 else if (neiLevel < (ownLevel-1))
5126 unrefineCell.
set(own);
5130 if (unrefineCell.
get(nei) == 0)
5136 unrefineCell.
unset(nei);
5144 labelList neiLevel(mesh_.nFaces()-mesh_.nInternalFaces());
5148 label own = mesh_.faceOwner()[i+mesh_.nInternalFaces()];
5150 neiLevel[i] = cellLevel_[own] - unrefineCell.
get(own);
5158 label facei = i+mesh_.nInternalFaces();
5159 label own = mesh_.faceOwner()[facei];
5160 label ownLevel = cellLevel_[own] - unrefineCell.
get(own);
5162 if (ownLevel < (neiLevel[i]-1))
5166 if (unrefineCell.
get(own) == 0)
5172 unrefineCell.
unset(own);
5176 else if (neiLevel[i] < (ownLevel-1))
5180 if (unrefineCell.
get(own) == 1)
5186 unrefineCell.
set(own);
5196 Pout<<
"hexRef8::consistentUnrefinement :"
5197 <<
" Changed " << nChanged
5198 <<
" refinement levels due to 2:1 conflicts."
5212 forAll(unrefinePoint, pointi)
5214 if (unrefinePoint.
get(pointi))
5216 const labelList& pCells = mesh_.pointCells(pointi);
5220 if (!unrefineCell.
get(pCells[j]))
5222 unrefinePoint.
unset(pointi);
5234 forAll(unrefinePoint, pointi)
5236 if (unrefinePoint.
get(pointi))
5245 forAll(unrefinePoint, pointi)
5247 if (unrefinePoint.
get(pointi))
5249 newPointsToUnrefine[nSet++] = pointi;
5253 return newPointsToUnrefine;
5263 if (!history_.active())
5266 <<
"Only call if constructed with history capability"
5272 Pout<<
"hexRef8::setUnrefinement :"
5273 <<
" Checking initial mesh just to make sure" <<
endl;
5277 forAll(cellLevel_, celli)
5279 if (cellLevel_[celli] < 0)
5282 <<
"Illegal cell level " << cellLevel_[celli]
5283 <<
" for cell " << celli
5290 pointSet pSet(mesh_,
"splitPoints", splitPointLabels);
5293 cellSet cSet(mesh_,
"splitPointCells", splitPointLabels.
size());
5295 forAll(splitPointLabels, i)
5297 const labelList& pCells = mesh_.pointCells(splitPointLabels[i]);
5306 Pout<<
"hexRef8::setRefinement : Dumping " << pSet.
size()
5308 << cSet.
size() <<
" cells for unrefinement to" <<
nl
5322 forAll(splitPointLabels, i)
5334 faceRemover_.compatibleRemoves
5342 if (facesToRemove.
size() != splitFaces.
size())
5345 <<
"Initial set of split points to unrefine does not"
5346 <<
" seem to be consistent or not mid points of refined cells"
5355 forAll(splitPointLabels, i)
5357 label pointi = splitPointLabels[i];
5361 const labelList& pCells = mesh_.pointCells(pointi);
5364 if (pCells.
size() != 8)
5367 <<
"splitPoint " << pointi
5368 <<
" should have 8 cells using it. It has " << pCells
5381 label celli = pCells[j];
5388 <<
"Initial set of split points to unrefine does not"
5389 <<
" seem to be consistent or not mid points"
5390 <<
" of refined cells" <<
nl
5391 <<
"cell:" << celli <<
" on splitPoint " << pointi
5392 <<
" has no region to be merged into"
5396 if (masterCelli != cellRegionMaster[
region])
5399 <<
"cell:" << celli <<
" on splitPoint:" << pointi
5400 <<
" in region " <<
region
5401 <<
" has master:" << cellRegionMaster[
region]
5402 <<
" which is not the lowest numbered cell"
5403 <<
" among the pointCells:" << pCells
5412 faceRemover_.setRefinement
5423 forAll(splitPointLabels, i)
5425 label pointi = splitPointLabels[i];
5427 const labelList& pCells = mesh_.pointCells(pointi);
5433 cellLevel_[pCells[j]]--;
5436 history_.combineCells(masterCelli, pCells);
5440 setInstance(mesh_.facesInstance());
5454 if (cellLevel_.size() != mesh_.nCells())
5457 <<
"Size of cellLevel:" << cellLevel_.size()
5458 <<
" does not equal number of cells in mesh:" << mesh_.nCells()
5462 if (pointLevel_.size() != mesh_.nPoints())
5465 <<
"Size of pointLevel:" << pointLevel_.size()
5466 <<
" does not equal number of points in mesh:" << mesh_.nPoints()
5471 cellLevel_.writeObject(fmt, ver, cmp,
write)
5472 && pointLevel_.writeObject(fmt, ver, cmp,
write)
5473 && level0Edge_.writeObject(fmt, ver, cmp,
write);
5475 if (history_.active())
5477 writeOk = writeOk && history_.writeObject(fmt, ver, cmp,
write);
#define forAll(list, i)
Loop across all elements in list.
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object of type.
Templated abstract base-class for demand-driven mesh objects used to automate their allocation to the...
void setCapacity(const label)
Alter the size of the underlying storage.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & shrink()
Shrink the allocated space to the number of elements used.
void clear()
Clear the addressed list, i.e. set the size to zero.
Wave propagation of information through grid. Every iteration information goes through one layer of c...
static scalar propagationTol()
Access to tolerance.
void setFaceInfo(const labelList &changedFaces, const List< Type > &changedFacesInfo)
Set initial changed faces.
virtual label iterate(const label maxIter)
Iterate until no changes or maxIter reached. Returns actual.
bool insert(const Key &key)
Insert a new entry.
An STL-conforming hash table.
List< Key > toc() const
Return the table of contents.
label size() const
Return number of elements in table.
bool insert(const Key &, const T &newElmt)
Insert a new hashedEntry.
friend class iterator
Declare friendship with the iterator.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
writeOption & writeOpt() const
readOption readOpt() const
static fileCheckTypes fileModificationChecking
Type of file modification checking.
fileCheckTypes
Enumeration defining the file checking options.
streamFormat
Enumeration for the format of data in the stream.
compressionType
Enumeration for the format of data in the stream.
void transfer(List< T > &)
Transfer the contents of the argument List into this list.
void append(const T &)
Append an element at the end of the list.
void size(const label)
Override size to be inconsistent with allocated storage.
void clear()
Clear the list, i.e. set size to zero.
void setSize(const label)
Reset size of List.
A HashTable to objects of type <T> with a label key.
const fileName & name() const
Return the name of the stream.
virtual const fileName & name() const
Return the name of the stream.
void set(const PackedList< 1 > &)
Set specified bits.
void unset(const PackedList< 1 > &)
Unset specified bits.
unsigned int get(const label) const
Get value at index I.
static void listCombineGather(const List< commsStruct > &comms, List< T > &Value, const CombineOp &cop, const int tag, const label comm)
static void listCombineScatter(const List< commsStruct > &comms, List< T > &Value, const int tag, const label comm)
Scatter data. Reverse of combineGather.
A List with indirect addressing.
label rcIndex(const label i) const
Return the reverse circular index, i.e. the previous index.
label size() const
Return the number of elements in the UList.
label fcIndex(const label i) const
Return the forward circular index, i.e. the next index.
T & last()
Return the last element of the list.
Holds information regarding type of cell. Used in inside/outside determination in cellClassification.
A collection of cell labels.
A topoSetSource to select a faceSet from cells.
A cell is defined as a list of faces with extra functionality.
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
A face is a list of labels corresponding to mesh vertices.
A class for handling file names.
Refinement of (split) hexes using polyTopoChange.
void checkRefinementLevels(const label maxPointDiff, const labelList &pointsToCheck) const
Debug: Check 2:1 consistency across faces.
virtual bool movePoints()
Correct weighting factors for moving mesh.
labelList consistentSlowRefinement(const label maxFaceDiff, const labelList &cellsToRefine, const labelList &facesToCheck, const label maxPointDiff, const labelList &pointsToCheck) const
Like consistentRefinement but slower:
hexRef8(const polyMesh &mesh, const bool readHistory=true)
Construct from mesh, read_if_present refinement data.
void checkMesh() const
Debug: Check coupled mesh for correctness.
virtual bool writeObject(IOstream::streamFormat, IOstream::versionNumber, IOstream::compressionType, const bool write=true) const
Write using given format, version and compression.
labelListList setRefinement(const labelList &cells, polyTopoChange &)
Insert refinement. All selected cells will be split into 8.
virtual void topoChange(const polyTopoChangeMap &)
Update local numbering for changed mesh.
virtual void distribute(const polyDistributionMap &)
Update local numbering for mesh redistribution.
const cellShapeList & cellShapes() const
Utility: get hexes as cell shapes.
virtual void mapMesh(const polyMeshMap &)
Update from another mesh using the given map.
void setUnrefinement(const labelList &splitPointLabels, polyTopoChange &)
Remove some refinement. Needs to be supplied output of.
virtual void addPatch(const label patchi)
Inserted patch at patchi.
labelList consistentUnrefinement(const labelList &pointsToUnrefine, const bool maxSet) const
Given proposed.
labelList getSplitPoints() const
Return the points at the centre of top-level split cells.
label faceLevel(const label facei) const
Gets level such that the face has four points <= level.
virtual void clear()
Clear.
virtual void reset()
Reset.
virtual void reorderPatches(const labelUList &newToOld, const bool validBoundary)
Reordered/removed trailing patches.
labelList consistentRefinement(const labelList &cellsToRefine, const bool maxSet) const
Given valid mesh and current cell level and proposed.
labelList consistentSlowRefinement2(const label maxFaceDiff, const labelList &cellsToRefine, const labelList &facesToCheck) const
Like consistentSlowRefinement but uses different meshWave.
void subset(const labelList &pointMap, const labelList &faceMap, const labelList &cellMap)
Update local numbering for subsetted mesh.
void setInstance(const fileName &inst)
Reduction class. If x and y are not equal assign value.
void operator()(label &x, const label y) const
const word & name() const
Return name.
Class containing mesh-to-mesh mapping information after a mesh distribution where we send parts of me...
void distributeCellData(List< T > &lst) const
Distribute list of cell data.
void distributePointData(List< T > &lst) const
Distribute list of point data.
Class containing mesh-to-mesh mapping information.
Mesh consisting of general polyhedral cells.
A patch is a list of labels that address the faces in the global face list.
virtual bool coupled() const
Return true if this patch is geometrically coupled (i.e. faces and.
label start() const
Return start label of this patch in the polyMesh face list.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
label nOldCells() const
Number of old cells.
const labelList & cellMap() const
Old cell map.
const labelList & reversePointMap() const
Reverse point map.
const labelList & pointMap() const
Old point map.
const labelList & reverseCellMap() const
Reverse cell map.
label nOldPoints() const
Number of old points.
Direct mesh changes based on v1.3 polyTopoChange syntax.
const DynamicList< point > & points() const
Points. Shrunk after constructing mesh (or calling of compact())
label addCell(const label masterCellID)
Add cell and return new cell index.
label addPoint(const point &, const label masterPointID, const bool inCell)
Add point and return new point index.
Container with cells to refine. Refinement given as single direction.
Transfers refinement levels such that slow transition between levels is maintained....
bool updateFace(const polyMesh &, const label thisFacei, const label neighbourCelli, const refinementData &neighbourInfo, const scalar tol, TrackingData &td)
Influence of neighbouring cell.
Transfers refinement levels such that slow transition between levels is maintained....
All refinement history. Used in unrefinement.
const labelList & visibleCells() const
Per cell in the current mesh (i.e. visible) either -1 (unrefined)
bool active() const
Is there unrefinement history?
virtual bool read()
Read object. If global number of visible cells > 0 becomes active.
fileName objectPath() const
Return complete path + object name.
virtual bool write(const bool write=true) const
Write using setting from DB.
bool headerOk()
Read and check header info.
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(lagrangian::Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< " ";}gmvFile<< nl;forAllConstIter(lagrangian::Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< " ";}gmvFile<< nl;forAllConstIter(lagrangian::Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.name(), lagrangian::cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
const fvPatchList & patches
#define WarningInFunction
Report a warning using Foam::Warning.
bool valid(const PtrList< ModelType > &l)
bool checkMesh(const bool report, const polyMesh &mesh, const dictionary &dict, const labelList &checkFaces, const List< labelPair > &baffles, labelHashSet &wrongFaces)
Check (subset of mesh including baffles) with mesh settings in dict.
void write(std::ostream &os, const bool binary, List< floatScalar > &fField)
Write floats ascii or binary.
errorManipArg< error, int > exit(error &err, const int errNo=1)
prefixOSstream Perr(cerr, "Perr")
List< cellShape > cellShapeList
List of cellShapes and PtrList of List of cellShape.
Pair< label > labelPair
Label pair.
List< label > labelList
A List of labels.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Ostream & endl(Ostream &os)
Add newline and flush stream.
const dimensionSet & dimLength
labelList findIndices(const ListType &, typename ListType::const_reference, const label start=0)
Find all occurrences of given element. Linear search.
errorManip< error > abort(error &err)
const fvMesh & region(const dictionary &dict)
Cast the give dictionary to the corresponding region fvMesh.
vectorField pointField
pointField is a vectorField.
vector point
Point is a vector.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
void reverse(UList< T > &, const label n)
tmp< DimensionedField< typename outerProduct< Type, Type >::type, GeoMesh, Field >> sqr(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
PrimitivePatch< SubList< face >, const pointField & > primitivePatch
Addressing for a faceList slice.
Vector< scalar > vector
A scalar version of the templated Vector.
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
ListType reorder(const label size, const typename ListType::value_type &defaultValue, const labelUList &oldToNew, const ListType &lst)
List< labelList > labelListList
A List of labelList.
dimensioned< Type > min(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
Type gMax(const UList< Type > &f, const label comm)
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
prefixOSstream Pout(cout, "Pout")
tmp< DimensionedField< scalar, GeoMesh, Field > > mag(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurrence of given element and return index,.
label count(const ListType &l, typename ListType::const_reference x)
Count the number of occurrences of a value in a list.
static const label labelMax
labelList identityMap(const label len)
Create identity map (map[i] == i) of given length.
void sqrt(LagrangianPatchField< scalar > &f, const LagrangianPatchField< scalar > &f1)
tmp< DimensionedField< scalar, GeoMesh, Field > > magSqr(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
defineTypeNameAndDebug(atmosphericBoundaryLayer, 0)
static const label labelMin
dimensioned< Type > max(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
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]