Go to the documentation of this file.
55 for (
label i = 0; i < nElems; i++)
76 result[labels[
labelI]] =
true;
108 if (!map.found(lst[i]))
127 OFstream cutsStream(dir /
"cell_" +
name(cellI) +
".obj");
129 Pout<<
"Writing cell for time " <<
mesh().time().timeName()
130 <<
" to " << cutsStream.
name() <<
nl;
142 OFstream cutStream(dir /
"cellCuts_" +
name(cellI) +
".obj");
144 Pout<<
"Writing raw cuts on cell for time " <<
mesh().time().timeName()
145 <<
" to " << cutStream.
name() <<
nl;
151 label pointI = cPoints[i];
152 if (pointIsCut_[pointI])
164 label edgeI = cEdges[i];
166 if (edgeIsCut_[edgeI])
170 const scalar
w = edgeWeight_[edgeI];
187 OFstream cutsStream(dir /
"cell_" +
name(cellI) +
".obj");
189 Pout<<
"Writing cell for time " <<
mesh().time().timeName()
190 <<
" to " << cutsStream.
name() <<
nl;
203 OFstream loopStream(dir /
"cellLoop_" +
name(cellI) +
".obj");
205 Pout<<
"Writing loop for time " <<
mesh().time().timeName()
206 <<
" to " << loopStream.
name() <<
nl;
210 writeOBJ(loopStream, loopPoints, vertI);
214 OFstream anchorStream(dir /
"anchors_" +
name(cellI) +
".obj");
216 Pout<<
"Writing anchors for time " <<
mesh().time().timeName()
217 <<
" to " << anchorStream.
name() <<
endl;
238 label faceI = cFaces[cFaceI];
256 <<
"cellCuts : Cannot find face on cell "
257 << cellI <<
" that has both edges " << edgeA <<
' ' << edgeB <<
endl
258 <<
"faces : " << cFaces <<
endl
259 <<
"edgeA : " <<
mesh().edges()[edgeA] <<
endl
260 <<
"edgeB : " <<
mesh().edges()[edgeB] <<
endl
261 <<
"Marking the loop across this cell as invalid" <<
endl;
279 label faceI = cFaces[cFaceI];
296 <<
"cellCuts : Cannot find face on cell "
297 << cellI <<
" that has both edge " << edgeI <<
" and vertex "
299 <<
"faces : " << cFaces <<
endl
300 <<
"edge : " <<
mesh().edges()[edgeI] <<
endl
301 <<
"Marking the loop across this cell as invalid" <<
endl;
319 label faceI = cFaces[cFaceI];
334 <<
"cellCuts : Cannot find face on cell "
335 << cellI <<
" that has vertex " << vertA <<
" and vertex "
337 <<
"faces : " << cFaces <<
endl
338 <<
"Marking the loop across this cell as invalid" <<
endl;
360 const face&
f = faces[faceI];
384 label vMin1 =
f[
f.rcIndex(fp)];
393 startFp =
f.fcIndex(fp);
404 label fp1 =
f.fcIndex(fp);
430 bool allVerticesCut =
true;
434 label fp1 =
f.fcIndex(fp);
449 allVerticesCut =
false;
464 <<
"Face " << faceI <<
" vertices " <<
f
465 <<
" has all its vertices cut. Not cutting face." <<
endl;
471 if (cutI > 1 && cuts[cutI-1] == cuts[0])
494 const edge&
e = edges[fEdges[i]];
498 (
e[0] == v0 &&
e[1] == v1)
499 || (
e[0] == v1 &&
e[1] == v0)
521 label faceI = cFaces[cFaceI];
526 bool allOnFace =
true;
566 const label startCut,
568 const label exclude0,
569 const label exclude1,
571 const label otherCut,
577 label vertI = getVertex(otherCut);
587 otherFaceI != exclude0
588 && otherFaceI != exclude1
592 label oldNVisited = nVisited;
611 nVisited = oldNVisited;
622 const label startCut,
624 const label otherCut,
631 label edgeI = getEdge(otherCut);
636 label oldNVisited = nVisited;
657 nVisited = oldNVisited;
673 if (findPartIndex(visited, nVisited,
cut) != -1)
677 truncVisited.
setSize(nVisited);
679 Pout<<
"For cell " << cellI <<
" : trying to add duplicate cut " <<
cut;
681 writeCuts(
Pout, cuts, loopWeights(cuts));
684 writeCuts(
Pout, truncVisited, loopWeights(truncVisited));
691 visited[nVisited++] =
cut;
703 const label startCut,
708 label& beforeLastCut,
713 const labelList& fCuts = faceCuts()[faceI];
715 if (fCuts.
size() < 2)
721 if (fCuts.
size() == 2)
725 if (!addCut(cellI,
cut, nVisited, visited))
737 if (!addCut(cellI,
cut, nVisited, visited))
754 for (
label i = 0; i < fCuts.
size()-1; i++)
756 if (!addCut(cellI, fCuts[i], nVisited, visited))
761 beforeLastCut = fCuts[fCuts.
size()-2];
762 lastCut = fCuts[fCuts.
size()-1];
764 else if (fCuts[fCuts.
size()-1] ==
cut)
766 for (
label i = fCuts.
size()-1; i >= 1; --i)
768 if (!addCut(cellI, fCuts[i], nVisited, visited))
773 beforeLastCut = fCuts[1];
779 <<
"In middle of cut. cell:" << cellI <<
" face:" << faceI
780 <<
" cuts:" << fCuts <<
" current cut:" <<
cut <<
endl;
795 const label startCut,
805 label beforeLastCut = -1;
810 Pout<<
"For cell:" << cellI <<
" walked across face " << faceI
813 writeCuts(
Pout, cuts, loopWeights(cuts));
837 Pout<<
" to last cut ";
839 writeCuts(
Pout, cuts, loopWeights(cuts));
844 if (lastCut == startCut)
852 truncVisited.
setSize(nVisited);
854 Pout<<
"For cell " << cellI <<
" : found closed path:";
855 writeCuts(
Pout, truncVisited, loopWeights(truncVisited));
856 Pout<<
" closed by " << lastCut <<
endl;
884 if (isEdge(beforeLastCut))
941 getVertex(beforeLastCut),
999 forAll(allFaceCuts, faceI)
1001 const labelList& fCuts = allFaceCuts[faceI];
1003 if (fCuts.
size() ==
mesh().faces()[faceI].size())
1008 if (
mesh().isInternalFace(faceI))
1013 else if (fCuts.
size() >= 2)
1018 if (
mesh().isInternalFace(faceI))
1032 label cellI = cutCells[i];
1034 bool validLoop =
false;
1037 if (nCutFaces[cellI] >= 3)
1043 Pout<<
"cell:" << cellI <<
" cut faces:" <<
endl;
1046 label faceI = cFaces[i];
1047 const labelList& fCuts = allFaceCuts[faceI];
1049 Pout<<
" face:" << faceI <<
" cuts:";
1050 writeCuts(
Pout, fCuts, loopWeights(fCuts));
1060 label faceI = cFaces[cFaceI];
1062 const labelList& fCuts = allFaceCuts[faceI];
1068 if (fCuts.
size() >= 2)
1075 Pout<<
"cell:" << cellI
1076 <<
" start walk at face:" << faceI
1079 writeCuts(
Pout, cuts, loopWeights(cuts));
1114 for (
label i = 0; i < nVisited; i++)
1116 loop[i] = visited[i];
1123 Pout<<
"calcCellLoops(const labelList&) : did not find valid"
1124 <<
" loop for cell " << cellI <<
endl;
1126 writeUncutOBJ(
".", cellI);
1128 cellLoops_[cellI].setSize(0);
1136 cellLoops_[cellI].setSize(0);
1154 if (pointStatus.insert(pointI, status))
1162 label edgeI = pEdges[pEdgeI];
1167 && edgeStatus.insert(edgeI, status)
1174 walkEdges(cellI, v2, status, edgeStatus, pointStatus);
1194 label pointI = cellPoints[i];
1199 &&
findIndex(loop, vertToEVert(pointI)) == -1
1202 newElems[newElemI++] = pointI;
1224 point ctr =
f.centre(loopPts);
1230 forAll(anchorPoints, ptI)
1234 avg /= anchorPoints.
size();
1237 if (((avg - ctr) &
normal) > 0)
1283 edgeStatus.insert(getEdge(
cut), 0);
1287 pointStatus.insert(getVertex(
cut), 0);
1294 label edgeI = cEdges[i];
1295 const edge&
e = edges[edgeI];
1297 if (pointStatus.found(
e[0]) && pointStatus.found(
e[1]))
1299 edgeStatus.insert(edgeI, 0);
1305 label uncutIndex = firstUnique(cPoints, pointStatus);
1307 if (uncutIndex == -1)
1310 <<
"Invalid loop " << loop <<
" for cell " << cellI <<
endl
1311 <<
"Can not find point on cell which is not cut by loop."
1320 walkEdges(cellI, cPoints[uncutIndex], 1, edgeStatus, pointStatus);
1323 uncutIndex = firstUnique(cPoints, pointStatus);
1325 if (uncutIndex == -1)
1330 <<
"Invalid loop " << loop <<
" for cell " << cellI <<
endl
1331 <<
"All vertices of cell are either in loop or in anchor set"
1341 walkEdges(cellI, cPoints[uncutIndex], 2, edgeStatus, pointStatus);
1351 connectedPoints.
append(iter.key());
1353 else if (iter() == 2)
1355 otherPoints.
append(iter.key());
1358 connectedPoints.
shrink();
1362 uncutIndex = firstUnique(cPoints, pointStatus);
1364 if (uncutIndex != -1)
1367 <<
"Invalid loop " << loop <<
" for cell " << cellI
1368 <<
" since it splits the cell into more than two cells" <<
endl;
1370 writeOBJ(
".", cellI, loopPts, connectedPoints);
1382 label pointI = iter.key();
1396 else if (iter() == 2)
1408 if (connectedFaces.
size() < 3)
1411 <<
"Invalid loop " << loop <<
" for cell " << cellI
1412 <<
" since would have too few faces on one side." <<
nl
1413 <<
"All faces:" << cFaces <<
endl;
1415 writeOBJ(
".", cellI, loopPts, connectedPoints);
1420 if (otherFaces.
size() < 3)
1423 <<
"Invalid loop " << loop <<
" for cell " << cellI
1424 <<
" since would have too few faces on one side." <<
nl
1425 <<
"All faces:" << cFaces <<
endl;
1427 writeOBJ(
".", cellI, loopPts, otherPoints);
1440 label faceI = cFaces[i];
1444 bool hasSet1 =
false;
1445 bool hasSet2 =
false;
1447 label prevStat = pointStatus[
f[0]];
1452 label pStat = pointStatus[v0];
1454 if (pStat == prevStat)
1457 else if (pStat == 0)
1461 else if (pStat == 1)
1467 <<
"Invalid loop " << loop <<
" for cell " << cellI
1468 <<
" since face " <<
f <<
" would be split into"
1469 <<
" more than two faces" <<
endl;
1471 writeOBJ(
".", cellI, loopPts, otherPoints);
1478 else if (pStat == 2)
1484 <<
"Invalid loop " << loop <<
" for cell " << cellI
1485 <<
" since face " <<
f <<
" would be split into"
1486 <<
" more than two faces" <<
endl;
1488 writeOBJ(
".", cellI, loopPts, otherPoints);
1504 label v1 =
f.nextLabel(fp);
1507 label eStat = edgeStatus[edgeI];
1509 if (eStat == prevStat)
1512 else if (eStat == 0)
1516 else if (eStat == 1)
1522 <<
"Invalid loop " << loop <<
" for cell " << cellI
1523 <<
" since face " <<
f <<
" would be split into"
1524 <<
" more than two faces" <<
endl;
1526 writeOBJ(
".", cellI, loopPts, otherPoints);
1533 else if (eStat == 2)
1539 <<
"Invalid loop " << loop <<
" for cell " << cellI
1540 <<
" since face " <<
f <<
" would be split into"
1541 <<
" more than two faces" <<
endl;
1543 writeOBJ(
".", cellI, loopPts, otherPoints);
1559 bool loopOk = loopAnchorConsistent(cellI, loopPts, connectedPoints);
1564 bool otherLoopOk = loopAnchorConsistent(cellI, loopPts, otherPoints);
1566 if (loopOk == otherLoopOk)
1572 <<
" For cell:" << cellI
1573 <<
" achorpoints and nonanchorpoints are geometrically"
1574 <<
" on same side!" <<
endl
1575 <<
"cellPoints:" << cPoints <<
endl
1576 <<
"loop:" << loop <<
endl
1577 <<
"anchors:" << connectedPoints <<
endl
1578 <<
"otherPoints:" << otherPoints <<
endl;
1580 writeOBJ(
".", cellI, loopPts, connectedPoints);
1587 anchorPoints.
transfer(connectedPoints);
1588 connectedPoints.
clear();
1592 anchorPoints.
transfer(otherPoints);
1593 otherPoints.
clear();
1609 loopPts[fp] = coord(loop[fp], loopWeights[fp]);
1628 weights[fp] = edgeWeight_[edgeI];
1632 weights[fp] = -GREAT;
1655 if (edgeIsCut_[edgeI])
1661 mag(loopWeights[fp] - edgeWeight_[edgeI])
1697 || (
findIndex(loop, vertToEVert(vertI)) != -1)
1709 label edgeI = fEdges[fEdgeI];
1715 || (
findIndex(loop, edgeToEVert(edgeI)) != -1)
1735 if (loop.
size() < 2)
1742 if (isEdge(loop[cutI]))
1744 label edgeI = getEdge(loop[cutI]);
1746 if (edgeIsCut_[edgeI])
1755 if (pointIsCut_[
e.start()] || pointIsCut_[
e.end()])
1766 label nCuts = countFaceCuts(eFaces[eFaceI], loop);
1779 label vertI = getVertex(loop[cutI]);
1781 if (!pointIsCut_[vertI])
1790 label edgeI = pEdges[pEdgeI];
1792 if (edgeIsCut_[edgeI])
1803 label nCuts = countFaceCuts(
pFaces[pFaceI], loop);
1833 if (loop.
size() < 2)
1842 if (!conservativeValidLoop(cellI, loop))
1851 label nextCut = loop[(fp+1) % loop.
size()];
1854 label meshFaceI = -1;
1862 if (isEdge(nextCut))
1865 label nextEdgeI = getEdge(nextCut);
1868 meshFaceI = edgeEdgeToFace(cellI, edgeI, nextEdgeI);
1870 if (meshFaceI == -1)
1880 label nextVertI = getVertex(nextCut);
1883 if (
e.start() != nextVertI &&
e.end() != nextVertI)
1886 meshFaceI = edgeVertexToFace(cellI, edgeI, nextVertI);
1888 if (meshFaceI == -1)
1901 if (isEdge(nextCut))
1904 label nextEdgeI = getEdge(nextCut);
1908 if (nextE.
start() != vertI && nextE.
end() != vertI)
1911 meshFaceI = edgeVertexToFace(cellI, nextEdgeI, vertI);
1913 if (meshFaceI == -1)
1922 label nextVertI = getVertex(nextCut);
1927 meshFaceI = vertexVertexToFace(cellI, vertI, nextVertI);
1929 if (meshFaceI == -1)
1937 if (meshFaceI != -1)
1945 if (iter == faceSplitCut_.end())
1948 newFaceSplitCut.insert(meshFaceI, cutEdge);
1953 if (iter() != cutEdge)
1962 label faceContainingLoop = loopFace(cellI, loop);
1964 if (faceContainingLoop != -1)
1967 <<
"Found loop on cell " << cellI <<
" with all points"
1968 <<
" on face " << faceContainingLoop <<
endl;
1981 loopPoints(loop, loopWeights),
1993 pointIsCut_ =
false;
1997 faceSplitCut_.clear();
1999 forAll(cellLoops_, cellI)
2001 const labelList& loop = cellLoops_[cellI];
2025 <<
"Illegal loop " << loop
2026 <<
" when recreating cut-addressing"
2027 <<
" from existing cellLoops for cell " << cellI
2030 cellLoops_[cellI].setSize(0);
2031 cellAnchorPoints_[cellI].setSize(0);
2036 cellAnchorPoints_[cellI].transfer(anchorPoints);
2041 faceSplitCut_.insert(iter.key(), iter());
2051 edgeIsCut_[getEdge(
cut)] =
true;
2055 pointIsCut_[getVertex(
cut)] =
true;
2063 forAll(edgeIsCut_, edgeI)
2065 if (!edgeIsCut_[edgeI])
2068 edgeWeight_[edgeI] = -GREAT;
2088 str<<
"# edges of cell " << cellI <<
nl;
2102 loopStr<<
"# looppoints for cell " << cellI <<
nl;
2104 pointField pointsOfLoop = loopPoints(loop, loopWeights);
2115 str <<
' ' << i + 1;
2117 str <<
' ' << 1 <<
nl;
2120 bool okLoop =
false;
2122 if (validEdgeLoop(loop, loopWeights))
2130 validLoop(cellI, loop, loopWeights, faceSplitCuts, anchorPoints);
2135 cellLoops_[cellI] = loop;
2136 cellAnchorPoints_[cellI].
transfer(anchorPoints);
2141 faceSplitCut_.insert(iter.key(), iter());
2154 edgeIsCut_[edgeI] =
true;
2156 edgeWeight_[edgeI] = loopWeights[cutI];
2162 pointIsCut_[vertI] =
true;
2182 pointIsCut_ =
false;
2186 forAll(cellLabels, cellLabelI)
2188 label cellI = cellLabels[cellLabelI];
2190 const labelList& loop = cellLoops[cellLabelI];
2194 const scalarField& loopWeights = cellLoopWeights[cellLabelI];
2196 if (setFromCellLoop(cellI, loop, loopWeights))
2219 pointIsCut_ =
false;
2233 forAll(refCells, refCellI)
2235 const refineCell& refCell = refCells[refCellI];
2261 if (setFromCellLoop(cellI, cellLoop, cellLoopWeights))
2267 cellLoops_[cellI].setSize(0);
2272 invalidCutCells.
append(cellI);
2273 invalidCutLoops.
append(cellLoop);
2274 invalidCutLoopWeights.
append(cellLoopWeights);
2281 cellLoops_[cellI].setSize(0);
2285 if (debug && invalidCutCells.size())
2287 invalidCutCells.
shrink();
2288 invalidCutLoops.
shrink();
2289 invalidCutLoopWeights.
shrink();
2291 fileName cutsFile(
"invalidLoopCells.obj");
2293 Pout<<
"cellCuts : writing inValidLoops cells to " << cutsFile <<
endl;
2306 fileName loopsFile(
"invalidLoops.obj");
2308 Pout<<
"cellCuts : writing inValidLoops loops to " << loopsFile <<
endl;
2314 forAll(invalidCutLoops, i)
2319 loopPoints(invalidCutLoops[i], invalidCutLoopWeights[i]),
2336 pointIsCut_ =
false;
2352 label cellI = cellLabels[i];
2373 if (setFromCellLoop(cellI, cellLoop, cellLoopWeights))
2379 cellLoops_[cellI].setSize(0);
2384 invalidCutCells.
append(cellI);
2385 invalidCutLoops.
append(cellLoop);
2386 invalidCutLoopWeights.
append(cellLoopWeights);
2393 cellLoops_[cellI].setSize(0);
2397 if (debug && invalidCutCells.size())
2399 invalidCutCells.
shrink();
2400 invalidCutLoops.
shrink();
2401 invalidCutLoopWeights.
shrink();
2403 fileName cutsFile(
"invalidLoopCells.obj");
2405 Pout<<
"cellCuts : writing inValidLoops cells to " << cutsFile <<
endl;
2418 fileName loopsFile(
"invalidLoops.obj");
2420 Pout<<
"cellCuts : writing inValidLoops loops to " << loopsFile <<
endl;
2426 forAll(invalidCutLoops, i)
2431 loopPoints(invalidCutLoops[i], invalidCutLoopWeights[i]),
2443 forAll(cellLoops_, cellI)
2445 const labelList& loop = cellLoops_[cellI];
2447 if (loop.
size() && cellAnchorPoints_[cellI].empty())
2455 cellAnchorPoints_[cellI]
2462 Pout<<
"cellAnchorPoints:" <<
endl;
2464 forAll(cellAnchorPoints_, cellI)
2466 if (cellLoops_[cellI].size())
2468 if (cellAnchorPoints_[cellI].empty())
2471 <<
"No anchor points for cut cell " << cellI <<
endl
2477 Pout<<
" cell:" << cellI <<
" anchored at "
2478 << cellAnchorPoints_[cellI] <<
endl;
2486 forAll(cellLoops_, cellI)
2488 if (cellLoops_[cellI].size())
2500 forAll(edgeIsCut_, edgeI)
2502 if (edgeIsCut_[edgeI])
2504 scalar weight = edgeWeight_[edgeI];
2506 if (weight < 0 || weight > 1)
2509 <<
"Weight out of range [0,1]. Edge " << edgeI
2517 edgeWeight_[edgeI] = -GREAT;
2523 calcCellLoops(cutCells);
2528 forAll(cellLoops_, cellI)
2530 const labelList& loop = cellLoops_[cellI];
2534 Pout<<
"cell:" << cellI <<
" ";
2535 writeCuts(
Pout, loop, loopWeights(loop));
2550 forAll(edgeIsCut_, edgeI)
2552 if (edgeIsCut_[edgeI])
2562 <<
"edge:" << edgeI <<
" vertices:"
2564 <<
" weight:" << edgeWeight_[edgeI] <<
" should have been"
2565 <<
" snapped to one of its endpoints"
2571 if (edgeWeight_[edgeI] > - 1)
2574 <<
"edge:" << edgeI <<
" vertices:"
2576 <<
" weight:" << edgeWeight_[edgeI] <<
" is not cut but"
2577 <<
" its weight is not marked invalid"
2584 forAll(cellLoops_, cellI)
2586 const labelList& loop = cellLoops_[cellI];
2594 (isEdge(
cut) && !edgeIsCut_[getEdge(
cut)])
2595 || (!isEdge(
cut) && !pointIsCut_[getVertex(
cut)])
2599 writeCuts(
Pout, cuts, loopWeights(cuts));
2602 <<
"cell:" << cellI <<
" loop:"
2604 <<
" cut:" <<
cut <<
" is not marked as cut"
2611 forAll(cellLoops_, cellI)
2613 const labelList& anchors = cellAnchorPoints_[cellI];
2615 const labelList& loop = cellLoops_[cellI];
2617 if (loop.
size() && anchors.empty())
2620 <<
"cell:" << cellI <<
" loop:" << loop
2621 <<
" has no anchor points"
2637 <<
"cell:" << cellI <<
" loop:" << loop
2638 <<
" anchor points:" << anchors
2639 <<
" anchor:" << getVertex(
cut) <<
" is part of loop"
2649 label faceI = iter.key();
2651 if (
mesh().isInternalFace(faceI))
2656 if (cellLoops_[own].empty() && cellLoops_[nei].empty())
2659 <<
"Internal face:" << faceI <<
" cut by " << iter()
2660 <<
" has owner:" << own
2661 <<
" and neighbour:" << nei
2662 <<
" that are both uncut"
2670 if (cellLoops_[own].empty())
2673 <<
"Boundary face:" << faceI <<
" cut by " << iter()
2674 <<
" has owner:" << own
2700 faceSplitCut_(cutCells.
size()),
2707 Pout<<
"cellCuts : constructor from cut verts and edges" <<
endl;
2710 calcLoopsAndAddressing(cutCells);
2713 orientPlanesAndLoops();
2724 Pout<<
"cellCuts : leaving constructor from cut verts and edges"
2752 Pout<<
"cellCuts : constructor from cellLoops" <<
endl;
2758 orientPlanesAndLoops();
2769 Pout<<
"cellCuts : leaving constructor from cellLoops" <<
endl;
2789 faceSplitCut_(cellLabels.
size()),
2796 Pout<<
"cellCuts : constructor from cellLoops" <<
endl;
2801 setFromCellLoops(cellLabels, cellLoops, cellEdgeWeights);
2804 orientPlanesAndLoops();
2815 Pout<<
"cellCuts : leaving constructor from cellLoops" <<
endl;
2833 faceSplitCut_(refCells.
size()),
2840 Pout<<
"cellCuts : constructor from cellCutter" <<
endl;
2845 setFromCellCutter(cellCutter, refCells);
2848 orientPlanesAndLoops();
2859 Pout<<
"cellCuts : leaving constructor from cellCutter" <<
endl;
2878 faceSplitCut_(cellLabels.
size()),
2885 Pout<<
"cellCuts : constructor from cellCutter with prescribed plane"
2891 setFromCellCutter(cellCutter, cellLabels, cutPlanes);
2894 orientPlanesAndLoops();
2905 Pout<<
"cellCuts : leaving constructor from cellCutter with prescribed"
2906 <<
" plane" <<
endl;
2925 pointIsCut_(pointIsCut),
2926 edgeIsCut_(edgeIsCut),
2927 edgeWeight_(edgeWeight),
2929 faceSplitCut_(faceSplitCut),
2930 cellLoops_(cellLoops),
2932 cellAnchorPoints_(cellAnchorPoints)
2936 Pout<<
"cellCuts : constructor from components" <<
endl;
2937 Pout<<
"cellCuts : leaving constructor from components" <<
endl;
2960 const labelList& loop = cellLoops_[cellI];
2972 loopPts[fp] = coord(
cut, edgeWeight_[edgeI]);
2976 loopPts[fp] = coord(
cut, -GREAT);
2991 cellAnchorPoints_[cellI] =
2994 mesh().cellPoints()[cellI],
2995 cellAnchorPoints_[cellI],
3017 label startVertI = vertI;
3021 const point& pt = loopPts[fp];
3023 os <<
"v " << pt.
x() <<
' ' << pt.
y() <<
' ' << pt.
z() <<
endl;
3031 os <<
' ' << startVertI + fp + 1;
3041 forAll(cellLoops_, cellI)
3043 writeOBJ(os, loopPoints(cellI), vertI);
3050 const labelList& anchors = cellAnchorPoints_[cellI];
3052 writeOBJ(dir, cellI, loopPoints(cellI), anchors);
void flip(const label cellI)
Flip loop for cellI. Updates anchor points as well.
label edgeEdgeToFace(const label cellI, const label edgeA, const label edgeB) const
Find face on cell using the two edges.
scalarField loopWeights(const labelList &loop) const
Returns weights of loop. Inverse of loopPoints.
virtual const pointField & points() const
Return raw points.
labelListList * faceCutsPtr_
Cuts per existing face (includes those along edge of face)
volScalarField w(IOobject("w", runTime.timeName(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE), mesh, dimensionedScalar("w", dimensionSet(0, 0, 0, 0, 0, 0, 0), 0.0))
void calcLoopsAndAddressing(const labelList &cutCells)
Top level driver: adressing calculation and loop detection.
label vertexVertexToFace(const label cellI, const label vertA, const label vertB) const
Find face using two vertices (guaranteed not to be along edge)
boolList edgeIsCut_
Is edge cut.
A class for handling file names.
List< label > labelList
A List of labels.
void calcFaceCuts() const
Calculate faceCuts in face vertex order.
#define forAll(list, i)
Loop across all elements in list.
void writeOBJ(Ostream &os, label &vertI, const tetPoints &tet)
const labelListList & cellPoints() const
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurence of given element and return index,.
void writeOBJ(const fileName &dir, const label cellI, const pointField &loopPoints, const labelList &anchors) const
Debugging: write cell's edges, loop and anchors to directory.
const labelListList & edgeFaces() const
bool walkCell(const label cellI, const label startCut, const label faceI, const label prevCut, label &nVisited, labelList &visited) const
Walk across cuts (cut edges or cut vertices) of cell. Stops when.
An STL-conforming const_iterator.
const labelListList & pointFaces() const
const cellList & cells() const
boolList pointIsCut_
Is mesh point cut.
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
cellCuts(const cellCuts &)
Disallow default bitwise copy construct.
void transfer(List< T > &)
Transfer the contents of the argument List into this list.
Combines edge or vertex in single label. Used to specify cuts across cell circumference.
Ostream & endl(Ostream &os)
Add newline and flush stream.
const edgeList & edges() const
Return mesh edges. Uses calcEdges.
void writeCellOBJ(const fileName &dir, const label cellI) const
debugging:Write edges of cell and loop
dimensioned< scalar > mag(const dimensioned< Type > &)
const labelListList & pointEdges() const
virtual bool cut(const vector &refDir, const label cellI, const boolList &vertIsCut, const boolList &edgeIsCut, const scalarField &edgeWeight, labelList &loop, scalarField &loopWeights) const =0
Create cut along circumference of cellI. Gets current mesh cuts.
Mesh consisting of general polyhedral cells.
static label firstUnique(const labelList &lst, const Map< label > &)
Returns -1 or index of first element of lst that cannot be found.
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
static label edgeToEVert(const primitiveMesh &mesh, const label edgeI)
Convert edgeI to eVert.
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, &oldCyclicPolyPatch::typeName};enum patchTypeNames{ PISTON, VALVE, LINER, CYLINDERHEAD, AXIS, WEDGE, INFLOW, OUTFLOW, PRESIN, PRESOUT, SYMMETRYPLANE, CYCLIC};const char *kivaPatchNames[nBCs]={ "piston", "valve", "liner", "cylinderHead", "axis", "wedge", "inflow", "outflow", "presin", "presout", "symmetryPlane", "cyclic"};List< SLList< face > > pFaces[nBCs]
label end() const
Return end vertex label.
void deleteDemandDrivenData(DataPtr &dataPtr)
static const label labelMin
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Pre-declare SubField and related Field type.
const labelListList & cellEdges() const
const labelListList & faceCuts() const
Cuts per existing face (includes those along edge of face)
void clear()
Clear the addressed list, i.e. set the size to zero.
virtual const labelList & faceOwner() const
Return face owner.
const labelListList & faceEdges() const
Abstract base class. Concrete implementations know how to cut a cell (i.e. determine a loop around th...
void calcCellLoops(const labelList &cutCells)
Determine for every cut cell the face it is cut by.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & shrink()
Shrink the allocated space to the number of elements used.
label loopFace(const label cellI, const labelList &loop) const
Find face on which all cuts are (very rare) or -1.
Patchify triangles based on orientation w.r.t other (triangulated or triangulatable) surfaces.
labelList identity(const label len)
Create identity map (map[i] == i) of given length.
const vector & direction() const
label size() const
Return number of elements in table.
bool conservativeValidLoop(const label cellI, const labelList &loop) const
Determines if loop through cellI consistent with existing.
labelList nonAnchorPoints(const labelList &cellPoints, const labelList &anchorPoints, const labelList &loop) const
Invert anchor point selection.
errorManip< error > abort(error &err)
bool validEdgeLoop(const labelList &loop, const scalarField &loopWeights) const
Check if cut edges in loop are compatible with ones in.
const double e
Elementary charge.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
bool validLoop(const label cellI, const labelList &loop, const scalarField &loopWeights, Map< edge > &newFaceSplitCut, labelList &anchorPoints) const
Check if loop is compatible with existing cut pattern in.
void setSize(const label)
Reset size of List.
bool crossEdge(const label cellI, const label startCut, const label faceI, const label otherCut, label &nVisited, labelList &visited) const
Cross cut (which is edge on faceI) onto next face.
List< labelList > labelListList
A List of labelList.
static boolList expand(const label size, const labelList &labels)
Create boolList with all labels specified set to true.
Container with cells to refine. Refinement given as single direction.
virtual const faceList & faces() const
Return raw faces.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
void setFromCellLoops()
Update basic cut information from cellLoops. Assumes cellLoops_.
bool loopAnchorConsistent(const label cellI, const pointField &loopPts, const labelList &anchorPoints) const
Check anchor points on 'outside' of loop.
label start() const
Return start vertex label.
void writeUncutOBJ(const fileName &, const label cellI) const
Debugging: write cell's edges and any cut vertices and edges.
prefixOSstream Pout(cout, "Pout")
void flipLoopOnly(const label cellI)
Flip loop for cellI. Does not update anchors. Use with care.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
const dimensionedScalar e
Elementary charge.
bool walkFace(const label cellI, const label startCut, const label faceI, const label cut, label &lastCut, label &beforeLastCut, label &nVisited, labelList &visited) const
Walk across faceI following cuts, starting at cut. Stores cuts.
bool insert(const Key &key)
Insert a new entry.
void check() const
Check various consistencies.
label countFaceCuts(const label faceI, const labelList &loop) const
Counts number of cuts on face.
static label findPartIndex(const labelList &, const label n, const label val)
Find value in first n elements of list.
A face is a list of labels corresponding to mesh vertices.
label findEdge(const label faceI, const label v0, const label v1) const
Find edge (or -1) on faceI using vertices v0,v1.
Various functions to operate on Lists.
const fileName & name() const
Return the name of the stream.
void clearOut()
Clear out demand driven storage.
void size(const label)
Override size to be inconsistent with allocated storage.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
bool walkPoint(const label cellI, const label startCut, const label exclude0, const label exclude1, const label otherCut, label &nVisited, labelList &visited) const
Cross otherCut into next faces (not exclude0, exclude1)
void orientPlanesAndLoops()
Set orientation of loops.
pointField loopPoints(const labelList &loop, const scalarField &loopWeights) const
Returns coordinates of points on loop with explicitly provided.
defineTypeNameAndDebug(combustionModel, 0)
#define WarningInFunction
Report a warning using Foam::Warning.
A cell is defined as a list of faces with extra functionality.
void setFromCellCutter(const cellLooper &, const List< refineCell > &refCells)
Cut cells and update basic cut information from cellLoops.
bool setFromCellLoop(const label cellI, const labelList &loop, const scalarField &loopWeights)
Update basic cut information for single cell from cellLoop.
word name(const complex &)
Return a string representation of a complex.
virtual const labelList & faceNeighbour() const
Return face neighbour.
bool calcAnchors(const label cellI, const labelList &loop, const pointField &loopPts, labelList &anchorPoints) const
Determines set of anchor points given a loop. The loop should.
string expand(const string &, const HashTable< string, word, string::hash > &mapping, const char sigil='$')
Expand occurences of variables according to the mapping.
A normal distribution model.
label edgeVertexToFace(const label cellI, const label edgeI, const label vertI) const
Find face on cell using an edge and a vertex.
bool addCut(const label cellI, const label cut, label &nVisited, labelList &visited) const
void walkEdges(const label cellI, const label pointI, const label status, Map< label > &edgeStatus, Map< label > &pointStatus) const
Walk unset edges of single cell from starting point and.
static label vertToEVert(const primitiveMesh &mesh, const label vertI)
Convert pointI to eVert.
static const labelSphericalTensor labelI(1)
Identity labelTensor.
const polyMesh & mesh() const
void reverse(UList< T > &, const label n)