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_.boundaryMesh().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,
759 const face compactFace(
identityMap(newFace.size()));
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_.boundaryMesh().whichPatch(facei);
1578 <<
"Celllevel does not satisfy 2:1 constraint."
1579 <<
" On coupled face "
1581 <<
" on patch " <<
patchi <<
" "
1582 << mesh_.boundaryMesh()[
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);
1797 mesh_.facesInstance(),
1810 mesh_.facesInstance(),
1823 mesh_.facesInstance(),
1835 "refinementHistory",
1836 mesh_.facesInstance(),
1843 (readHistory ? mesh_.nCells() : 0)
1845 faceRemover_(mesh_, great),
1846 savedPointLevel_(0),
1867 <<
"History enabled but number of visible cells "
1870 <<
" is not equal to the number of cells in the mesh "
1877 cellLevel_.size() != mesh_.
nCells()
1878 || pointLevel_.size() != mesh_.
nPoints()
1882 <<
"Restarted from inconsistent cellLevel or pointLevel files."
1886 <<
"Number of cells in mesh:" << mesh_.
nCells()
1887 <<
" does not equal size of cellLevel:" << cellLevel_.size() <<
endl
1888 <<
"Number of points in mesh:" << mesh_.
nPoints()
1889 <<
" does not equal size of pointLevel:" << pointLevel_.size()
1913 const scalar level0Edge
1922 mesh_.facesInstance(),
1935 mesh_.facesInstance(),
1948 mesh_.facesInstance(),
1957 (level0Edge >= 0 ? level0Edge : getLevel0EdgeLength())
1964 "refinementHistory",
1965 mesh_.facesInstance(),
1973 faceRemover_(mesh_, great),
1974 savedPointLevel_(0),
1980 <<
"History enabled but number of visible cells in it "
1982 <<
" is not equal to the number of cells in the mesh "
1988 cellLevel_.size() != mesh_.
nCells()
1989 || pointLevel_.size() != mesh_.
nPoints()
1993 <<
"Incorrect cellLevel or pointLevel size." <<
endl
1994 <<
"Number of cells in mesh:" << mesh_.
nCells()
1995 <<
" does not equal size of cellLevel:" << cellLevel_.size() <<
endl
1996 <<
"Number of points in mesh:" << mesh_.
nPoints()
1997 <<
" does not equal size of pointLevel:" << pointLevel_.size()
2019 const scalar level0Edge
2028 mesh_.facesInstance(),
2041 mesh_.facesInstance(),
2054 mesh_.facesInstance(),
2063 (level0Edge >= 0 ? level0Edge : getLevel0EdgeLength())
2070 "refinementHistory",
2071 mesh_.facesInstance(),
2081 faceRemover_(mesh_, great),
2082 savedPointLevel_(0),
2087 cellLevel_.size() != mesh_.
nCells()
2088 || pointLevel_.size() != mesh_.
nPoints()
2092 <<
"Incorrect cellLevel or pointLevel size." <<
endl
2093 <<
"Number of cells in mesh:" << mesh_.
nCells()
2094 <<
" does not equal size of cellLevel:" << cellLevel_.size() <<
endl
2095 <<
"Number of points in mesh:" << mesh_.
nPoints()
2096 <<
" does not equal size of pointLevel:" << pointLevel_.size()
2140 Pout<<
"hexRef8::consistentRefinement : Changed " << nChanged
2141 <<
" refinement levels due to 2:1 conflicts."
2170 newCellsToRefine[nRefined++] = celli;
2176 checkWantedRefinementLevels(newCellsToRefine);
2179 return newCellsToRefine;
2185 const label maxFaceDiff,
2188 const label maxPointDiff,
2192 const labelList& faceOwner = mesh_.faceOwner();
2193 const labelList& faceNeighbour = mesh_.faceNeighbour();
2196 if (maxFaceDiff <= 0)
2199 <<
"Illegal maxFaceDiff " << maxFaceDiff <<
nl
2218 forAll(allCellInfo, celli)
2224 maxFaceDiff*(cellLevel_[celli]+1),
2225 maxFaceDiff*cellLevel_[celli]
2232 label celli = cellsToRefine[i];
2234 allCellInfo[celli].count() = allCellInfo[celli].refinementCount();
2244 int dummyTrackData = 0;
2252 label facei = facesToCheck[i];
2254 if (allFaceInfo[facei].
valid(dummyTrackData))
2258 <<
"Argument facesToCheck seems to have duplicate entries!"
2260 <<
"face:" << facei <<
" occurs at positions "
2268 if (mesh_.isInternalFace(facei))
2273 const refinementData& neiData = allCellInfo[faceNeighbour[facei]];
2276 label faceRefineCount;
2279 faceCount = neiData.
count() + maxFaceDiff;
2280 faceRefineCount = faceCount + maxFaceDiff;
2284 faceCount = ownData.
count() + maxFaceDiff;
2285 faceRefineCount = faceCount + maxFaceDiff;
2297 allFaceInfo[facei] = seedFacesInfo.
last();
2301 label faceCount = ownData.
count() + maxFaceDiff;
2302 label faceRefineCount = faceCount + maxFaceDiff;
2313 allFaceInfo[facei] = seedFacesInfo.
last();
2321 forAll(faceNeighbour, facei)
2324 if (!allFaceInfo[facei].
valid(dummyTrackData))
2326 label own = faceOwner[facei];
2327 label nei = faceNeighbour[facei];
2331 if (allCellInfo[own].
count() > allCellInfo[nei].
count())
2333 allFaceInfo[facei].updateFace
2343 seedFacesInfo.
append(allFaceInfo[facei]);
2345 else if (allCellInfo[own].
count() < allCellInfo[nei].
count())
2347 allFaceInfo[facei].updateFace
2357 seedFacesInfo.
append(allFaceInfo[facei]);
2365 for (
label facei = mesh_.nInternalFaces(); facei < mesh_.nFaces(); facei++)
2368 if (!allFaceInfo[facei].
valid(dummyTrackData))
2370 label own = faceOwner[facei];
2384 seedFacesInfo.
append(faceData);
2402 Pout<<
"hexRef8::consistentSlowRefinement : Seeded "
2403 << seedFaces.
size() <<
" faces between cells with different"
2404 <<
" refinement level." <<
endl;
2410 seedFacesInfo.
clear();
2413 levelCalc.
iterate(mesh_.globalData().nTotalFaces()+1);
2421 if (maxPointDiff == -1)
2429 labelList maxPointCount(mesh_.nPoints(), 0);
2431 forAll(maxPointCount, pointi)
2433 label& pLevel = maxPointCount[pointi];
2435 const labelList& pCells = mesh_.pointCells(pointi);
2439 pLevel =
max(pLevel, allCellInfo[pCells[i]].
count());
2460 label pointi = pointsToCheck[i];
2465 const labelList& pCells = mesh_.pointCells(pointi);
2469 label celli = pCells[pCelli];
2477 maxPointCount[pointi]
2478 >
cellInfo.count() + maxFaceDiff*maxPointDiff
2486 const cell& cFaces = mesh_.cells()[celli];
2490 label facei = cFaces[cFacei];
2503 if (faceData.
count() > allFaceInfo[facei].count())
2505 changedFacesInfo.
insert(facei, faceData);
2512 label nChanged = changedFacesInfo.
size();
2527 seedFaces.
append(iter.key());
2528 seedFacesInfo.
append(iter());
2535 for (
label facei = 0; facei < mesh_.nInternalFaces(); facei++)
2537 label own = mesh_.faceOwner()[facei];
2540 + (allCellInfo[own].isRefined() ? 1 : 0);
2542 label nei = mesh_.faceNeighbour()[facei];
2545 + (allCellInfo[nei].isRefined() ? 1 : 0);
2547 if (
mag(ownLevel-neiLevel) > 1)
2553 <<
" current level:" << cellLevel_[own]
2554 <<
" current refData:" << allCellInfo[own]
2555 <<
" level after refinement:" << ownLevel
2557 <<
"neighbour cell:" << nei
2558 <<
" current level:" << cellLevel_[nei]
2559 <<
" current refData:" << allCellInfo[nei]
2560 <<
" level after refinement:" << neiLevel
2562 <<
"which does not satisfy 2:1 constraints anymore." <<
nl
2563 <<
"face:" << facei <<
" faceRefData:" << allFaceInfo[facei]
2572 labelList neiLevel(mesh_.nFaces()-mesh_.nInternalFaces());
2573 labelList neiCount(mesh_.nFaces()-mesh_.nInternalFaces());
2574 labelList neiRefCount(mesh_.nFaces()-mesh_.nInternalFaces());
2578 label own = mesh_.faceOwner()[i+mesh_.nInternalFaces()];
2579 neiLevel[i] = cellLevel_[own];
2580 neiCount[i] = allCellInfo[own].count();
2581 neiRefCount[i] = allCellInfo[own].refinementCount();
2592 label facei = i+mesh_.nInternalFaces();
2594 label own = mesh_.faceOwner()[facei];
2597 + (allCellInfo[own].isRefined() ? 1 : 0);
2601 + ((neiCount[i] >= neiRefCount[i]) ? 1 : 0);
2603 if (
mag(ownLevel - nbrLevel) > 1)
2606 label patchi = mesh_.boundaryMesh().whichPatch(facei);
2609 <<
"Celllevel does not satisfy 2:1 constraint."
2610 <<
" On coupled face "
2612 <<
" refData:" << allFaceInfo[facei]
2613 <<
" on patch " <<
patchi <<
" "
2614 << mesh_.boundaryMesh()[
patchi].name() <<
nl
2615 <<
"owner cell " << own
2616 <<
" current level:" << cellLevel_[own]
2617 <<
" current count:" << allCellInfo[own].count()
2618 <<
" current refCount:"
2619 << allCellInfo[own].refinementCount()
2620 <<
" level after refinement:" << ownLevel
2622 <<
"(coupled) neighbour cell"
2623 <<
" has current level:" << neiLevel[i]
2624 <<
" current count:" << neiCount[i]
2625 <<
" current refCount:" << neiRefCount[i]
2626 <<
" level after refinement:" << nbrLevel
2636 forAll(allCellInfo, celli)
2638 if (allCellInfo[celli].isRefined())
2648 forAll(allCellInfo, celli)
2650 if (allCellInfo[celli].isRefined())
2652 newCellsToRefine[nRefined++] = celli;
2658 Pout<<
"hexRef8::consistentSlowRefinement : From "
2659 << cellsToRefine.
size() <<
" to " << newCellsToRefine.
size()
2660 <<
" cells to refine." <<
endl;
2663 return newCellsToRefine;
2669 const label maxFaceDiff,
2674 const labelList& faceOwner = mesh_.faceOwner();
2675 const labelList& faceNeighbour = mesh_.faceNeighbour();
2677 if (maxFaceDiff <= 0)
2680 <<
"Illegal maxFaceDiff " << maxFaceDiff <<
nl
2684 const scalar level0Size = 2*maxFaceDiff*level0EdgeLength();
2699 int dummyTrackData = 0;
2705 label celli = cellsToRefine[i];
2710 mesh_.cellCentres()[celli],
2715 forAll(allCellInfo, celli)
2717 if (!allCellInfo[celli].
valid(dummyTrackData))
2722 mesh_.cellCentres()[celli],
2738 label facei = facesToCheck[i];
2740 if (allFaceInfo[facei].
valid(dummyTrackData))
2744 <<
"Argument facesToCheck seems to have duplicate entries!"
2746 <<
"face:" << facei <<
" occurs at positions "
2751 label own = faceOwner[facei];
2755 allCellInfo[own].valid(dummyTrackData)
2756 ? allCellInfo[own].originLevel()
2760 if (!mesh_.isInternalFace(facei))
2764 const point& fc = mesh_.faceCentres()[facei];
2773 allFaceInfo[facei].updateFace
2785 label nei = faceNeighbour[facei];
2789 allCellInfo[nei].valid(dummyTrackData)
2790 ? allCellInfo[nei].originLevel()
2794 if (ownLevel == neiLevel)
2797 allFaceInfo[facei].updateFace
2806 allFaceInfo[facei].updateFace
2819 allFaceInfo[facei].updateFace
2828 allFaceInfo[facei].updateFace
2840 seedFacesInfo.
append(allFaceInfo[facei]);
2847 forAll(faceNeighbour, facei)
2850 if (!allFaceInfo[facei].
valid(dummyTrackData))
2852 label own = faceOwner[facei];
2856 allCellInfo[own].valid(dummyTrackData)
2857 ? allCellInfo[own].originLevel()
2861 label nei = faceNeighbour[facei];
2865 allCellInfo[nei].valid(dummyTrackData)
2866 ? allCellInfo[nei].originLevel()
2870 if (ownLevel > neiLevel)
2874 allFaceInfo[facei].updateFace
2883 seedFacesInfo.
append(allFaceInfo[facei]);
2885 else if (neiLevel > ownLevel)
2888 allFaceInfo[facei].updateFace
2897 seedFacesInfo.
append(allFaceInfo[facei]);
2913 mesh_.globalData().nTotalCells()+1,
2954 label celli = cellsToRefine[i];
2956 allCellInfo[celli].originLevel() =
sizeof(
label)*8-2;
2957 allCellInfo[celli].origin() = cc[celli];
2964 forAll(allCellInfo, celli)
2966 label wanted = allCellInfo[celli].wantedLevel(cc[celli]);
2968 if (wanted > cellLevel_[celli]+1)
2983 Pout<<
"hexRef8::consistentSlowRefinement2 : Changed " << nChanged
2984 <<
" refinement levels due to 2:1 conflicts."
3012 newCellsToRefine[nRefined++] = celli;
3018 Pout<<
"hexRef8::consistentSlowRefinement2 : From "
3019 << cellsToRefine.
size() <<
" to " << newCellsToRefine.
size()
3020 <<
" cells to refine." <<
endl;
3025 cellSet cellsIn(mesh_,
"cellsToRefineIn", cellsToRefine);
3026 Pout<<
"hexRef8::consistentSlowRefinement2 : writing "
3027 << cellsIn.
size() <<
" to cellSet "
3032 cellSet cellsOut(mesh_,
"cellsToRefineOut", newCellsToRefine);
3033 Pout<<
"hexRef8::consistentSlowRefinement2 : writing "
3034 << cellsOut.
size() <<
" to cellSet "
3041 forAll(newCellsToRefine, i)
3052 mesh_,
"cellsToRefineOut2", newCellsToRefine.
size()
3061 Pout<<
"hexRef8::consistentSlowRefinement2 : writing "
3062 << cellsOut2.
size() <<
" to cellSet "
3075 <<
"Cell:" << celli <<
" cc:"
3076 << mesh_.cellCentres()[celli]
3077 <<
" was not marked for refinement but does not obey"
3078 <<
" 2:1 constraints."
3085 return newCellsToRefine;
3097 Pout<<
"hexRef8::setRefinement :"
3098 <<
" Checking initial mesh just to make sure" <<
endl;
3107 savedPointLevel_.clear();
3108 savedCellLevel_.clear();
3113 forAll(cellLevel_, celli)
3115 newCellLevel.
append(cellLevel_[celli]);
3118 forAll(pointLevel_, pointi)
3120 newPointLevel.
append(pointLevel_[pointi]);
3126 Pout<<
"hexRef8::setRefinement :"
3127 <<
" Allocating " << cellLabels.
size() <<
" cell midpoints."
3135 labelList cellMidPoint(mesh_.nCells(), -1);
3139 label celli = cellLabels[i];
3141 label anchorPointi = mesh_.faces()[mesh_.cells()[celli][0]][0];
3143 cellMidPoint[celli] = meshMod.
addPoint
3145 mesh_.cellCentres()[celli],
3150 newPointLevel(cellMidPoint[celli]) = cellLevel_[celli]+1;
3156 cellSet splitCells(mesh_,
"splitCells", cellLabels.
size());
3158 forAll(cellMidPoint, celli)
3160 if (cellMidPoint[celli] >= 0)
3162 splitCells.
insert(celli);
3166 Pout<<
"hexRef8::setRefinement : Dumping " << splitCells.
size()
3167 <<
" cells to split to cellSet " << splitCells.
objectPath()
3180 Pout<<
"hexRef8::setRefinement :"
3181 <<
" Allocating edge midpoints."
3190 labelList edgeMidPoint(mesh_.nEdges(), -1);
3193 forAll(cellMidPoint, celli)
3195 if (cellMidPoint[celli] >= 0)
3197 const labelList& cEdges = mesh_.cellEdges(celli);
3201 label edgeI = cEdges[i];
3203 const edge&
e = mesh_.edges()[edgeI];
3207 pointLevel_[
e[0]] <= cellLevel_[celli]
3208 && pointLevel_[
e[1]] <= cellLevel_[celli]
3211 edgeMidPoint[edgeI] = 12345;
3238 forAll(edgeMidPoint, edgeI)
3240 if (edgeMidPoint[edgeI] >= 0)
3243 edgeMids[edgeI] = mesh_.edges()[edgeI].centre(mesh_.points());
3251 point(-great, -great, -great)
3256 forAll(edgeMidPoint, edgeI)
3258 if (edgeMidPoint[edgeI] >= 0)
3263 const edge&
e = mesh_.edges()[edgeI];
3265 edgeMidPoint[edgeI] = meshMod.
addPoint
3272 newPointLevel(edgeMidPoint[edgeI]) =
3285 OFstream str(mesh_.time().path()/
"edgeMidPoint.obj");
3287 forAll(edgeMidPoint, edgeI)
3289 if (edgeMidPoint[edgeI] >= 0)
3291 const edge&
e = mesh_.edges()[edgeI];
3297 Pout<<
"hexRef8::setRefinement :"
3298 <<
" Dumping edge centres to split to file " << str.
name() <<
endl;
3308 Pout<<
"hexRef8::setRefinement :"
3309 <<
" Allocating face midpoints."
3315 labelList faceAnchorLevel(mesh_.nFaces());
3317 for (
label facei = 0; facei < mesh_.nFaces(); facei++)
3319 faceAnchorLevel[facei] = faceLevel(facei);
3324 labelList faceMidPoint(mesh_.nFaces(), -1);
3329 for (
label facei = 0; facei < mesh_.nInternalFaces(); facei++)
3331 if (faceAnchorLevel[facei] >= 0)
3333 label own = mesh_.faceOwner()[facei];
3334 label ownLevel = cellLevel_[own];
3335 label newOwnLevel = ownLevel + (cellMidPoint[own] >= 0 ? 1 : 0);
3337 label nei = mesh_.faceNeighbour()[facei];
3338 label neiLevel = cellLevel_[nei];
3339 label newNeiLevel = neiLevel + (cellMidPoint[nei] >= 0 ? 1 : 0);
3343 newOwnLevel > faceAnchorLevel[facei]
3344 || newNeiLevel > faceAnchorLevel[facei]
3347 faceMidPoint[facei] = 12345;
3360 labelList newNeiLevel(mesh_.nFaces()-mesh_.nInternalFaces());
3364 label own = mesh_.faceOwner()[i+mesh_.nInternalFaces()];
3365 label ownLevel = cellLevel_[own];
3366 label newOwnLevel = ownLevel + (cellMidPoint[own] >= 0 ? 1 : 0);
3368 newNeiLevel[i] = newOwnLevel;
3378 label facei = i+mesh_.nInternalFaces();
3380 if (faceAnchorLevel[facei] >= 0)
3382 label own = mesh_.faceOwner()[facei];
3383 label ownLevel = cellLevel_[own];
3384 label newOwnLevel = ownLevel + (cellMidPoint[own] >= 0 ? 1 : 0);
3388 newOwnLevel > faceAnchorLevel[facei]
3389 || newNeiLevel[i] > faceAnchorLevel[facei]
3392 faceMidPoint[facei] = 12345;
3417 mesh_.nFaces()-mesh_.nInternalFaces(),
3418 point(-great, -great, -great)
3423 label facei = i+mesh_.nInternalFaces();
3425 if (faceMidPoint[facei] >= 0)
3427 bFaceMids[i] = mesh_.faceCentres()[facei];
3437 forAll(faceMidPoint, facei)
3439 if (faceMidPoint[facei] >= 0)
3444 const face&
f = mesh_.faces()[facei];
3446 faceMidPoint[facei] = meshMod.
addPoint
3449 facei < mesh_.nInternalFaces()
3450 ? mesh_.faceCentres()[facei]
3451 : bFaceMids[facei-mesh_.nInternalFaces()]
3459 newPointLevel(faceMidPoint[facei]) = faceAnchorLevel[facei]+1;
3466 faceSet splitFaces(mesh_,
"splitFaces", cellLabels.
size());
3468 forAll(faceMidPoint, facei)
3470 if (faceMidPoint[facei] >= 0)
3472 splitFaces.
insert(facei);
3476 Pout<<
"hexRef8::setRefinement : Dumping " << splitFaces.
size()
3477 <<
" faces to split to faceSet " << splitFaces.
objectPath() <<
endl;
3498 Pout<<
"hexRef8::setRefinement :"
3499 <<
" Finding cell anchorPoints (8 per cell)"
3510 labelList nAnchorPoints(mesh_.nCells(), 0);
3512 forAll(cellMidPoint, celli)
3514 if (cellMidPoint[celli] >= 0)
3516 cellAnchorPoints[celli].
setSize(8);
3520 forAll(pointLevel_, pointi)
3522 const labelList& pCells = mesh_.pointCells(pointi);
3526 label celli = pCells[pCelli];
3530 cellMidPoint[celli] >= 0
3531 && pointLevel_[pointi] <= cellLevel_[celli]
3534 if (nAnchorPoints[celli] == 8)
3539 <<
" of level " << cellLevel_[celli]
3540 <<
" uses more than 8 points of equal or"
3541 <<
" lower level" <<
nl
3542 <<
"Points so far:" << cellAnchorPoints[celli]
3546 cellAnchorPoints[celli][nAnchorPoints[celli]++] = pointi;
3551 forAll(cellMidPoint, celli)
3553 if (cellMidPoint[celli] >= 0)
3555 if (nAnchorPoints[celli] != 8)
3559 const labelList& cPoints = mesh_.cellPoints(celli);
3563 <<
" of level " << cellLevel_[celli]
3564 <<
" does not seem to have 8 points of equal or"
3565 <<
" lower level" <<
endl
3566 <<
"cellPoints:" << cPoints <<
endl
3581 Pout<<
"hexRef8::setRefinement :"
3582 <<
" Adding cells (1 per anchorPoint)"
3589 forAll(cellAnchorPoints, celli)
3591 const labelList& cAnchors = cellAnchorPoints[celli];
3593 if (cAnchors.
size() == 8)
3595 labelList& cAdded = cellAddedCells[celli];
3602 newCellLevel[celli] = cellLevel_[celli]+1;
3604 for (
label i = 1; i < 8; i++)
3606 cAdded[i] = meshMod.
addCell(celli);
3607 newCellLevel(cAdded[i]) = cellLevel_[celli] + 1;
3622 Pout<<
"hexRef8::setRefinement :"
3623 <<
" Marking faces to be handled"
3631 forAll(cellMidPoint, celli)
3633 if (cellMidPoint[celli] >= 0)
3635 const cell& cFaces = mesh_.cells()[celli];
3639 affectedFace.
set(cFaces[i]);
3644 forAll(faceMidPoint, facei)
3646 if (faceMidPoint[facei] >= 0)
3648 affectedFace.
set(facei);
3652 forAll(edgeMidPoint, edgeI)
3654 if (edgeMidPoint[edgeI] >= 0)
3656 const labelList& eFaces = mesh_.edgeFaces(edgeI);
3660 affectedFace.
set(eFaces[i]);
3672 Pout<<
"hexRef8::setRefinement : Splitting faces" <<
endl;
3675 forAll(faceMidPoint, facei)
3677 if (faceMidPoint[facei] >= 0 && affectedFace.
get(facei))
3683 const face&
f = mesh_.faces()[facei];
3687 bool modifiedFace =
false;
3689 label anchorLevel = faceAnchorLevel[facei];
3697 if (pointLevel_[pointi] <= anchorLevel)
3703 faceVerts.
append(pointi);
3719 faceVerts.
append(faceMidPoint[facei]);
3752 if (mesh_.isInternalFace(facei))
3754 label oldOwn = mesh_.faceOwner()[facei];
3755 label oldNei = mesh_.faceNeighbour()[facei];
3757 checkInternalOrientation
3762 mesh_.cellCentres()[oldOwn],
3763 mesh_.cellCentres()[oldNei],
3769 label oldOwn = mesh_.faceOwner()[facei];
3771 checkBoundaryOrientation
3776 mesh_.cellCentres()[oldOwn],
3777 mesh_.faceCentres()[facei],
3786 modifiedFace =
true;
3788 modifyFace(meshMod, facei, newFace, own, nei);
3792 addFace(meshMod, facei, newFace, own, nei);
3798 affectedFace.
unset(facei);
3808 Pout<<
"hexRef8::setRefinement :"
3809 <<
" Adding edge splits to unsplit faces"
3816 forAll(edgeMidPoint, edgeI)
3818 if (edgeMidPoint[edgeI] >= 0)
3822 const labelList& eFaces = mesh_.edgeFaces(edgeI, eFacesStorage);
3826 label facei = eFaces[i];
3828 if (faceMidPoint[facei] < 0 && affectedFace.
get(facei))
3832 const face&
f = mesh_.faces()[facei];
3833 const labelList& fEdges = mesh_.faceEdges
3845 label edgeI = fEdges[fp];
3847 if (edgeMidPoint[edgeI] >= 0)
3849 newFaceVerts.
append(edgeMidPoint[edgeI]);
3858 label anchorFp = findMinLevel(
f);
3875 if (mesh_.isInternalFace(facei))
3877 label oldOwn = mesh_.faceOwner()[facei];
3878 label oldNei = mesh_.faceNeighbour()[facei];
3880 checkInternalOrientation
3885 mesh_.cellCentres()[oldOwn],
3886 mesh_.cellCentres()[oldNei],
3892 label oldOwn = mesh_.faceOwner()[facei];
3894 checkBoundaryOrientation
3899 mesh_.cellCentres()[oldOwn],
3900 mesh_.faceCentres()[facei],
3906 modifyFace(meshMod, facei, newFace, own, nei);
3909 affectedFace.
unset(facei);
3921 Pout<<
"hexRef8::setRefinement :"
3922 <<
" Changing owner/neighbour for otherwise unaffected faces"
3926 forAll(affectedFace, facei)
3928 if (affectedFace.
get(facei))
3930 const face&
f = mesh_.faces()[facei];
3934 label anchorFp = findMinLevel(
f);
3948 modifyFace(meshMod, facei,
f, own, nei);
3951 affectedFace.
unset(facei);
3966 Pout<<
"hexRef8::setRefinement :"
3967 <<
" Create new internal faces for split cells"
3971 forAll(cellMidPoint, celli)
3973 if (cellMidPoint[celli] >= 0)
3998 forAll(cellMidPoint, celli)
4000 if (cellMidPoint[celli] >= 0)
4002 minPointi =
min(minPointi, cellMidPoint[celli]);
4003 maxPointi =
max(maxPointi, cellMidPoint[celli]);
4006 forAll(faceMidPoint, facei)
4008 if (faceMidPoint[facei] >= 0)
4010 minPointi =
min(minPointi, faceMidPoint[facei]);
4011 maxPointi =
max(maxPointi, faceMidPoint[facei]);
4014 forAll(edgeMidPoint, edgeI)
4016 if (edgeMidPoint[edgeI] >= 0)
4018 minPointi =
min(minPointi, edgeMidPoint[edgeI]);
4019 maxPointi =
max(maxPointi, edgeMidPoint[edgeI]);
4023 if (minPointi !=
labelMax && minPointi != mesh_.nPoints())
4026 <<
"Added point labels not consecutive to existing mesh points."
4028 <<
"mesh_.nPoints():" << mesh_.nPoints()
4029 <<
" minPointi:" << minPointi
4030 <<
" maxPointi:" << maxPointi
4035 pointLevel_.transfer(newPointLevel);
4036 cellLevel_.transfer(newCellLevel);
4039 setInstance(mesh_.facesInstance());
4046 if (history_.active())
4050 Pout<<
"hexRef8::setRefinement :"
4051 <<
" Updating refinement history to " << cellLevel_.size()
4052 <<
" cells" <<
endl;
4056 history_.resize(cellLevel_.size());
4058 forAll(cellAddedCells, celli)
4060 const labelList& addedCells = cellAddedCells[celli];
4062 if (addedCells.
size())
4065 history_.storeSplit(celli, addedCells);
4076 label celli = cellLabels[i];
4078 refinedCells[i].
transfer(cellAddedCells[celli]);
4081 return refinedCells;
4092 savedPointLevel_.resize(2*pointsToStore.
size());
4095 label pointi = pointsToStore[i];
4096 savedPointLevel_.insert(pointi, pointLevel_[pointi]);
4099 savedCellLevel_.
resize(2*cellsToStore.
size());
4102 label celli = cellsToStore[i];
4103 savedCellLevel_.insert(celli, cellLevel_[celli]);
4112 topoChange(map, dummyMap, dummyMap, dummyMap);
4127 Pout<<
"hexRef8::topoChange :"
4128 <<
" Updating various lists"
4137 Pout<<
"hexRef8::topoChange :"
4140 <<
" nCells:" << mesh_.nCells()
4142 <<
" cellLevel_:" << cellLevel_.size()
4145 <<
" nPoints:" << mesh_.nPoints()
4147 <<
" pointLevel_:" << pointLevel_.size()
4151 if (reverseCellMap.
size() == cellLevel_.size())
4157 reorder(reverseCellMap, mesh_.nCells(), -1, cellLevel_);
4165 forAll(cellMap, newCelli)
4167 label oldCelli = cellMap[newCelli];
4171 newCellLevel[newCelli] = -1;
4175 newCellLevel[newCelli] = cellLevel_[oldCelli];
4185 label newCelli = iter.key();
4186 label storedCelli = iter();
4190 if (fnd == savedCellLevel_.
end())
4193 <<
"Problem : trying to restore old value for new cell "
4194 << newCelli <<
" but cannot find old cell " << storedCelli
4195 <<
" in map of stored values " << savedCellLevel_
4198 cellLevel_[newCelli] = fnd();
4207 if (reversePointMap.
size() == pointLevel_.size())
4210 reorder(reversePointMap, mesh_.nPoints(), -1, pointLevel_);
4223 if (oldPointi == -1)
4229 newPointLevel[
newPointi] = pointLevel_[oldPointi];
4232 pointLevel_.
transfer(newPointLevel);
4240 label storedPointi = iter();
4244 if (fnd == savedPointLevel_.
end())
4247 <<
"Problem : trying to restore old value for new point "
4248 <<
newPointi <<
" but cannot find old point "
4250 <<
" in map of stored values " << savedPointLevel_
4258 if (history_.active())
4260 history_.topoChange(map);
4264 setInstance(mesh_.facesInstance());
4267 faceRemover_.topoChange(map);
4270 cellShapesPtr_.clear();
4284 Pout<<
"hexRef8::subset :"
4285 <<
" Updating various lists"
4289 if (history_.active())
4292 <<
"Subsetting will not work in combination with unrefinement."
4294 <<
"Proceed at your own risk." <<
endl;
4302 forAll(cellMap, newCelli)
4304 newCellLevel[newCelli] = cellLevel_[cellMap[newCelli]];
4313 <<
"cellLevel_ contains illegal value -1 after mapping:"
4328 pointLevel_.
transfer(newPointLevel);
4334 <<
"pointLevel_ contains illegal value -1 after mapping:"
4341 if (history_.active())
4343 history_.subset(pointMap,
faceMap, cellMap);
4347 setInstance(mesh_.facesInstance());
4353 cellShapesPtr_.clear();
4361 Pout<<
"hexRef8::distribute :"
4362 <<
" Updating various lists"
4373 if (history_.active())
4375 history_.distribute(map);
4379 faceRemover_.distribute(map);
4382 cellShapesPtr_.clear();
4388 const scalar smallDim = 1
e-6 * mesh_.bounds().mag();
4392 Pout<<
"hexRef8::checkMesh : Using matching tolerance smallDim:"
4393 << smallDim <<
endl;
4403 labelList nei(mesh_.nFaces()-mesh_.nInternalFaces());
4406 nei[i] = mesh_.faceOwner()[i+mesh_.nInternalFaces()];
4429 label own = mesh_.faceOwner()[facei];
4430 label bFacei = facei-mesh_.nInternalFaces();
4436 <<
"Faces do not seem to be correct across coupled"
4437 <<
" boundaries" <<
endl
4438 <<
"Coupled face " << facei
4439 <<
" between owner " << own
4440 <<
" on patch " << pp.
name()
4441 <<
" and coupled neighbour " << nei[bFacei]
4442 <<
" has two faces connected to it:"
4458 scalarField neiFaceAreas(mesh_.nFaces()-mesh_.nInternalFaces());
4461 neiFaceAreas[i] = mesh_.magFaceAreas()[i+mesh_.nInternalFaces()];
4469 label facei = i+mesh_.nInternalFaces();
4471 const scalar magArea = mesh_.magFaceAreas()[facei];
4473 if (
mag(magArea - neiFaceAreas[i]) > smallDim)
4475 const face&
f = mesh_.faces()[facei];
4476 label patchi = mesh_.boundaryMesh().whichPatch(facei);
4478 dumpCell(mesh_.faceOwner()[facei]);
4481 <<
"Faces do not seem to be correct across coupled"
4482 <<
" boundaries" <<
endl
4483 <<
"Coupled face " << facei
4484 <<
" on patch " <<
patchi
4485 <<
" " << mesh_.boundaryMesh()[
patchi].name()
4487 <<
" has face area:" << magArea
4488 <<
" (coupled) neighbour face area differs:"
4490 <<
" to within tolerance " << smallDim
4500 labelList nVerts(mesh_.nFaces()-mesh_.nInternalFaces());
4504 nVerts[i] = mesh_.faces()[i+mesh_.nInternalFaces()].
size();
4512 label facei = i+mesh_.nInternalFaces();
4514 const face&
f = mesh_.faces()[facei];
4516 if (
f.
size() != nVerts[i])
4518 dumpCell(mesh_.faceOwner()[facei]);
4520 label patchi = mesh_.boundaryMesh().whichPatch(facei);
4523 <<
"Faces do not seem to be correct across coupled"
4524 <<
" boundaries" <<
endl
4525 <<
"Coupled face " << facei
4526 <<
" on patch " <<
patchi
4527 <<
" " << mesh_.boundaryMesh()[
patchi].name()
4529 <<
" has size:" <<
f.
size()
4530 <<
" (coupled) neighbour face has size:"
4542 pointField anchorPoints(mesh_.nFaces()-mesh_.nInternalFaces());
4546 label facei = i+mesh_.nInternalFaces();
4547 const point& fc = mesh_.faceCentres()[facei];
4548 const face&
f = mesh_.faces()[facei];
4549 const vector anchorVec(mesh_.points()[
f[0]] - fc);
4551 anchorPoints[i] = anchorVec;
4561 label facei = i+mesh_.nInternalFaces();
4562 const point& fc = mesh_.faceCentres()[facei];
4563 const face&
f = mesh_.faces()[facei];
4564 const vector anchorVec(mesh_.points()[
f[0]] - fc);
4566 if (
mag(anchorVec - anchorPoints[i]) > smallDim)
4568 dumpCell(mesh_.faceOwner()[facei]);
4570 label patchi = mesh_.boundaryMesh().whichPatch(facei);
4573 <<
"Faces do not seem to be correct across coupled"
4574 <<
" boundaries" <<
endl
4575 <<
"Coupled face " << facei
4576 <<
" on patch " <<
patchi
4577 <<
" " << mesh_.boundaryMesh()[
patchi].name()
4579 <<
" has anchor vector:" << anchorVec
4580 <<
" (coupled) neighbour face anchor vector differs:"
4582 <<
" to within tolerance " << smallDim
4590 Pout<<
"hexRef8::checkMesh : Returning" <<
endl;
4597 const label maxPointDiff,
4603 Pout<<
"hexRef8::checkRefinementLevels :"
4604 <<
" Checking 2:1 refinement level" <<
endl;
4609 cellLevel_.size() != mesh_.nCells()
4610 || pointLevel_.size() != mesh_.nPoints()
4614 <<
"cellLevel size should be number of cells"
4615 <<
" and pointLevel size should be number of points."<<
nl
4616 <<
"cellLevel:" << cellLevel_.size()
4617 <<
" mesh.nCells():" << mesh_.nCells() <<
nl
4618 <<
"pointLevel:" << pointLevel_.size()
4619 <<
" mesh.nPoints():" << mesh_.nPoints()
4629 for (
label facei = 0; facei < mesh_.nInternalFaces(); facei++)
4631 label own = mesh_.faceOwner()[facei];
4632 label nei = mesh_.faceNeighbour()[facei];
4634 if (
mag(cellLevel_[own] - cellLevel_[nei]) > 1)
4640 <<
"Celllevel does not satisfy 2:1 constraint." <<
nl
4641 <<
"On face " << facei <<
" owner cell " << own
4642 <<
" has refinement " << cellLevel_[own]
4643 <<
" neighbour cell " << nei <<
" has refinement "
4650 labelList neiLevel(mesh_.nFaces()-mesh_.nInternalFaces());
4654 label own = mesh_.faceOwner()[i+mesh_.nInternalFaces()];
4656 neiLevel[i] = cellLevel_[own];
4664 label facei = i+mesh_.nInternalFaces();
4666 label own = mesh_.faceOwner()[facei];
4668 if (
mag(cellLevel_[own] - neiLevel[i]) > 1)
4672 label patchi = mesh_.boundaryMesh().whichPatch(facei);
4675 <<
"Celllevel does not satisfy 2:1 constraint."
4676 <<
" On coupled face " << facei
4677 <<
" on patch " <<
patchi <<
" "
4678 << mesh_.boundaryMesh()[
patchi].name()
4679 <<
" owner cell " << own <<
" has refinement "
4681 <<
" (coupled) neighbour cell has refinement "
4704 forAll(syncPointLevel, pointi)
4706 if (pointLevel_[pointi] != syncPointLevel[pointi])
4709 <<
"PointLevel is not consistent across coupled patches."
4711 <<
"point:" << pointi <<
" coord:" << mesh_.points()[pointi]
4712 <<
" has level " << pointLevel_[pointi]
4713 <<
" whereas the coupled point has level "
4714 << syncPointLevel[pointi]
4722 if (maxPointDiff != -1)
4725 labelList maxPointLevel(mesh_.nPoints(), 0);
4727 forAll(maxPointLevel, pointi)
4729 const labelList& pCells = mesh_.pointCells(pointi);
4731 label& pLevel = maxPointLevel[pointi];
4735 pLevel =
max(pLevel, cellLevel_[pCells[i]]);
4751 label pointi = pointsToCheck[i];
4753 const labelList& pCells = mesh_.pointCells(pointi);
4757 label celli = pCells[i];
4761 mag(cellLevel_[celli]-maxPointLevel[pointi])
4768 <<
"Too big a difference between"
4769 <<
" point-connected cells." <<
nl
4771 <<
" cellLevel:" << cellLevel_[celli]
4772 <<
" uses point:" << pointi
4773 <<
" coord:" << mesh_.points()[pointi]
4774 <<
" which is also used by a cell with level:"
4775 << maxPointLevel[pointi]
4850 if (cellShapesPtr_.empty())
4854 Pout<<
"hexRef8::cellShapes() : calculating splitHex cellShapes."
4855 <<
" cellLevel:" << cellLevel_.size()
4856 <<
" pointLevel:" << pointLevel_.size()
4863 label nSplitHex = 0;
4864 label nUnrecognised = 0;
4866 forAll(cellLevel_, celli)
4868 if (meshShapes[celli].model().index() == 0)
4870 label level = cellLevel_[celli];
4874 bool haveQuads = matchHexShape
4884 cellShapesPtr_()[celli] = degenerateMatcher::match(faces);
4895 Pout<<
"hexRef8::cellShapes() :"
4896 <<
" nCells:" << mesh_.nCells() <<
" of which" <<
nl
4897 <<
" primitive:" << (mesh_.nCells()-nSplitHex-nUnrecognised)
4899 <<
" split-hex:" << nSplitHex <<
nl
4900 <<
" poly :" << nUnrecognised <<
nl
4904 return cellShapesPtr_();
4912 checkRefinementLevels(-1,
labelList(0));
4917 Pout<<
"hexRef8::getSplitPoints :"
4918 <<
" Calculating unrefineable points" <<
endl;
4922 if (!history_.active())
4925 <<
"Only call if constructed with history capability"
4933 labelList splitMaster(mesh_.nPoints(), -1);
4934 labelList splitMasterLevel(mesh_.nPoints(), 0);
4939 for (
label pointi = 0; pointi < mesh_.nPoints(); pointi++)
4941 const labelList& pCells = mesh_.pointCells(pointi);
4943 if (pCells.
size() != 8)
4945 splitMaster[pointi] = -2;
4950 const labelList& visibleCells = history_.visibleCells();
4952 forAll(visibleCells, celli)
4954 const labelList& cPoints = mesh_.cellPoints(celli);
4956 if (visibleCells[celli] != -1 && history_.parentIndex(celli) >= 0)
4958 label parentIndex = history_.parentIndex(celli);
4963 label pointi = cPoints[i];
4965 label masterCelli = splitMaster[pointi];
4967 if (masterCelli == -1)
4974 splitMaster[pointi] = parentIndex;
4975 splitMasterLevel[pointi] = cellLevel_[celli] - 1;
4977 else if (masterCelli == -2)
4983 (masterCelli != parentIndex)
4984 || (splitMasterLevel[pointi] != cellLevel_[celli] - 1)
4989 splitMaster[pointi] = -2;
4998 label pointi = cPoints[i];
5000 splitMaster[pointi] = -2;
5008 label facei = mesh_.nInternalFaces();
5009 facei < mesh_.nFaces();
5013 const face&
f = mesh_.faces()[facei];
5017 splitMaster[
f[fp]] = -2;
5024 label nSplitPoints = 0;
5026 forAll(splitMaster, pointi)
5028 if (splitMaster[pointi] >= 0)
5037 forAll(splitMaster, pointi)
5039 if (splitMaster[pointi] >= 0)
5041 splitPoints[nSplitPoints++] = pointi;
5057 Pout<<
"hexRef8::consistentUnrefinement :"
5058 <<
" Determining 2:1 consistent unrefinement" <<
endl;
5064 <<
"maxSet not implemented yet."
5076 forAll(pointsToUnrefine, i)
5078 label pointi = pointsToUnrefine[i];
5080 unrefinePoint.
set(pointi);
5091 forAll(unrefinePoint, pointi)
5093 if (unrefinePoint.
get(pointi))
5095 const labelList& pCells = mesh_.pointCells(pointi);
5099 unrefineCell.
set(pCells[j]);
5112 for (
label facei = 0; facei < mesh_.nInternalFaces(); facei++)
5114 label own = mesh_.faceOwner()[facei];
5115 label ownLevel = cellLevel_[own] - unrefineCell.
get(own);
5117 label nei = mesh_.faceNeighbour()[facei];
5118 label neiLevel = cellLevel_[nei] - unrefineCell.
get(nei);
5120 if (ownLevel < (neiLevel-1))
5127 unrefineCell.
set(nei);
5138 if (unrefineCell.
get(own) == 0)
5144 unrefineCell.
unset(own);
5148 else if (neiLevel < (ownLevel-1))
5152 unrefineCell.
set(own);
5156 if (unrefineCell.
get(nei) == 0)
5162 unrefineCell.
unset(nei);
5170 labelList neiLevel(mesh_.nFaces()-mesh_.nInternalFaces());
5174 label own = mesh_.faceOwner()[i+mesh_.nInternalFaces()];
5176 neiLevel[i] = cellLevel_[own] - unrefineCell.
get(own);
5184 label facei = i+mesh_.nInternalFaces();
5185 label own = mesh_.faceOwner()[facei];
5186 label ownLevel = cellLevel_[own] - unrefineCell.
get(own);
5188 if (ownLevel < (neiLevel[i]-1))
5192 if (unrefineCell.
get(own) == 0)
5198 unrefineCell.
unset(own);
5202 else if (neiLevel[i] < (ownLevel-1))
5206 if (unrefineCell.
get(own) == 1)
5212 unrefineCell.
set(own);
5222 Pout<<
"hexRef8::consistentUnrefinement :"
5223 <<
" Changed " << nChanged
5224 <<
" refinement levels due to 2:1 conflicts."
5238 forAll(unrefinePoint, pointi)
5240 if (unrefinePoint.
get(pointi))
5242 const labelList& pCells = mesh_.pointCells(pointi);
5246 if (!unrefineCell.
get(pCells[j]))
5248 unrefinePoint.
unset(pointi);
5260 forAll(unrefinePoint, pointi)
5262 if (unrefinePoint.
get(pointi))
5271 forAll(unrefinePoint, pointi)
5273 if (unrefinePoint.
get(pointi))
5275 newPointsToUnrefine[nSet++] = pointi;
5279 return newPointsToUnrefine;
5289 if (!history_.active())
5292 <<
"Only call if constructed with history capability"
5298 Pout<<
"hexRef8::setUnrefinement :"
5299 <<
" Checking initial mesh just to make sure" <<
endl;
5303 forAll(cellLevel_, celli)
5305 if (cellLevel_[celli] < 0)
5308 <<
"Illegal cell level " << cellLevel_[celli]
5309 <<
" for cell " << celli
5316 pointSet pSet(mesh_,
"splitPoints", splitPointLabels);
5319 cellSet cSet(mesh_,
"splitPointCells", splitPointLabels.
size());
5321 forAll(splitPointLabels, i)
5323 const labelList& pCells = mesh_.pointCells(splitPointLabels[i]);
5332 Pout<<
"hexRef8::setRefinement : Dumping " << pSet.
size()
5334 << cSet.
size() <<
" cells for unrefinement to" <<
nl
5348 forAll(splitPointLabels, i)
5360 faceRemover_.compatibleRemoves
5368 if (facesToRemove.
size() != splitFaces.
size())
5371 <<
"Initial set of split points to unrefine does not"
5372 <<
" seem to be consistent or not mid points of refined cells"
5381 forAll(splitPointLabels, i)
5383 label pointi = splitPointLabels[i];
5387 const labelList& pCells = mesh_.pointCells(pointi);
5390 if (pCells.
size() != 8)
5393 <<
"splitPoint " << pointi
5394 <<
" should have 8 cells using it. It has " << pCells
5407 label celli = pCells[j];
5409 label region = cellRegion[celli];
5414 <<
"Initial set of split points to unrefine does not"
5415 <<
" seem to be consistent or not mid points"
5416 <<
" of refined cells" <<
nl
5417 <<
"cell:" << celli <<
" on splitPoint " << pointi
5418 <<
" has no region to be merged into"
5422 if (masterCelli != cellRegionMaster[region])
5425 <<
"cell:" << celli <<
" on splitPoint:" << pointi
5426 <<
" in region " << region
5427 <<
" has master:" << cellRegionMaster[region]
5428 <<
" which is not the lowest numbered cell"
5429 <<
" among the pointCells:" << pCells
5438 faceRemover_.setRefinement
5449 forAll(splitPointLabels, i)
5451 label pointi = splitPointLabels[i];
5453 const labelList& pCells = mesh_.pointCells(pointi);
5459 cellLevel_[pCells[j]]--;
5462 history_.combineCells(masterCelli, pCells);
5466 setInstance(mesh_.facesInstance());
5474 if (cellLevel_.size() != mesh_.nCells())
5477 <<
"Size of cellLevel:" << cellLevel_.size()
5478 <<
" does not equal number of cells in mesh:" << mesh_.nCells()
5482 if (pointLevel_.size() != mesh_.nPoints())
5485 <<
"Size of pointLevel:" << pointLevel_.size()
5486 <<
" does not equal number of points in mesh:" << mesh_.nPoints()
5491 cellLevel_.write(
write)
5492 && pointLevel_.write(
write)
5493 && level0Edge_.write(
write);
5495 if (history_.active())
5497 writeOk = writeOk && history_.write(
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.
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.
iterator find(const Key &)
Find and return an iterator set at the hashedEntry.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
readOption readOpt() const
static fileCheckTypes fileModificationChecking
Type of file modification checking.
fileCheckTypes
Enumeration defining the file checking options.
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 resize(const label)
Alias for setSize(const label)
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.
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.
labelListList setRefinement(const labelList &cells, polyTopoChange &)
Insert refinement. All selected cells will be split into 8.
void topoChange(const polyTopoChangeMap &)
Update local numbering for changed mesh.
void distribute(const polyDistributionMap &)
Update local numbering for mesh redistribution.
const cellShapeList & cellShapes() const
Utility: get hexes as cell shapes.
bool write(const bool write=true) const
Force writing refinement+history to polyMesh directory.
void setUnrefinement(const labelList &splitPointLabels, polyTopoChange &)
Remove some refinement. Needs to be supplied output of.
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.
void storeData(const labelList &pointsToStore, const labelList &facesToStore, const labelList &cellsToStore)
Signal points/face/cells for which to store data.
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.
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.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
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.name(), 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.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
Ostream & endl(Ostream &os)
Add newline and flush stream.
word name(const bool)
Return a word representation of a bool.
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 dimensionSet dimLength
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)
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
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)
dimensionedScalar sqrt(const dimensionedScalar &ds)
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< scalar > mag(const dimensioned< Type > &)
defineTypeNameAndDebug(combustionModel, 0)
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
prefixOSstream Pout(cout, "Pout")
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.
dimensioned< scalar > magSqr(const dimensioned< Type > &)
Type gMax(const FieldField< Field, Type > &f)
static const label labelMin
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]
static iteratorEnd end()
iteratorEnd set to beyond the end of any HashTable