54 for (
label i = 0; i < nElems; i++)
75 result[labels[
labelI]] =
true;
101 const Map<label>& map
106 if (!map.found(lst[i]))
117 void Foam::cellCuts::writeUncutOBJ
124 OFstream cutsStream(dir /
"cell_" +
name(celli) +
".obj");
127 <<
" to " << cutsStream.name() <<
nl;
139 OFstream cutStream(dir /
"cellCuts_" +
name(celli) +
".obj");
142 <<
" to " << cutStream.name() <<
nl;
148 label pointi = cPoints[i];
149 if (pointIsCut_[pointi])
161 label edgeI = cEdges[i];
163 if (edgeIsCut_[edgeI])
167 const scalar w = edgeWeight_[edgeI];
175 void Foam::cellCuts::writeOBJ
184 OFstream cutsStream(dir /
"cell_" +
name(celli) +
".obj");
187 <<
" to " << cutsStream.name() <<
nl;
200 OFstream loopStream(dir /
"cellLoop_" +
name(celli) +
".obj");
203 <<
" to " << loopStream.name() <<
nl;
207 writeOBJ(loopStream, loopPoints, vertI);
211 OFstream anchorStream(dir /
"anchors_" +
name(celli) +
".obj");
214 <<
" to " << anchorStream.name() <<
endl;
234 label facei = cFaces[cFacei];
252 <<
"cellCuts : Cannot find face on cell " 253 << celli <<
" that has both edges " << edgeA <<
' ' << edgeB << endl
254 <<
"faces : " << cFaces << endl
255 <<
"edgeA : " <<
mesh().
edges()[edgeA] << endl
256 <<
"edgeB : " <<
mesh().
edges()[edgeB] << endl
257 <<
"Marking the loop across this cell as invalid" <<
endl;
274 label facei = cFaces[cFacei];
291 <<
"cellCuts : Cannot find face on cell " 292 << celli <<
" that has both edge " << edgeI <<
" and vertex " 294 <<
"faces : " << cFaces << endl
295 <<
"edge : " <<
mesh().
edges()[edgeI] << endl
296 <<
"Marking the loop across this cell as invalid" <<
endl;
313 label facei = cFaces[cFacei];
328 <<
"cellCuts : Cannot find face on cell " 329 << celli <<
" that has vertex " << vertA <<
" and vertex " 331 <<
"faces : " << cFaces << endl
332 <<
"Marking the loop across this cell as invalid" <<
endl;
338 void Foam::cellCuts::calcFaceCuts()
const 354 const face& f = faces[facei];
378 label vMin1 = f[f.rcIndex(fp)];
383 && !edgeIsCut_[
findEdge(facei, v0, vMin1)]
386 cuts[cutI++] = vertToEVert(v0);
387 startFp = f.fcIndex(fp);
398 label fp1 = f.fcIndex(fp);
405 if (edgeIsCut_[edgeI] && !pointIsCut_[v0])
407 cuts[cutI++] = edgeToEVert(edgeI);
424 bool allVerticesCut =
true;
428 label fp1 = f.fcIndex(fp);
438 cuts[cutI++] = vertToEVert(v0);
443 allVerticesCut =
false;
446 if (edgeIsCut_[edgeI])
448 cuts[cutI++] = edgeToEVert(edgeI);
458 <<
"Face " << facei <<
" vertices " << f
459 <<
" has all its vertices cut. Not cutting face." <<
endl;
465 if (cutI > 1 && cuts[cutI-1] == cuts[0])
487 const edge& e = edges[fEdges[i]];
491 (e[0] == v0 && e[1] == v1)
492 || (e[0] == v1 && e[1] == v0)
509 const cell& cFaces =
mesh().
cells()[celli];
513 label facei = cFaces[cFacei];
518 bool allOnFace =
true;
526 if (
findIndex(fEdges, getEdge(cut)) == -1)
554 bool Foam::cellCuts::walkPoint
557 const label startCut,
559 const label exclude0,
560 const label exclude1,
562 const label otherCut,
568 label vertI = getVertex(otherCut);
574 label otherFacei = pFaces[pFacei];
578 otherFacei != exclude0
579 && otherFacei != exclude1
583 label oldNVisited = nVisited;
602 nVisited = oldNVisited;
609 bool Foam::cellCuts::crossEdge
612 const label startCut,
614 const label otherCut,
621 label edgeI = getEdge(otherCut);
626 label oldNVisited = nVisited;
647 nVisited = oldNVisited;
654 bool Foam::cellCuts::addCut
663 if (findPartIndex(visited, nVisited, cut) != -1)
667 truncVisited.setSize(nVisited);
669 Pout<<
"For cell " << celli <<
" : trying to add duplicate cut " << cut;
671 writeCuts(
Pout, cuts, loopWeights(cuts));
674 writeCuts(
Pout, truncVisited, loopWeights(truncVisited));
681 visited[nVisited++] = cut;
688 bool Foam::cellCuts::walkFace
691 const label startCut,
696 label& beforeLastCut,
701 const labelList& fCuts = faceCuts()[facei];
703 if (fCuts.size() < 2)
709 if (fCuts.size() == 2)
713 if (!addCut(celli, cut, nVisited, visited))
725 if (!addCut(celli, cut, nVisited, visited))
742 for (
label i = 0; i < fCuts.size()-1; i++)
744 if (!addCut(celli, fCuts[i], nVisited, visited))
749 beforeLastCut = fCuts[fCuts.size()-2];
750 lastCut = fCuts[fCuts.size()-1];
752 else if (fCuts[fCuts.size()-1] == cut)
754 for (
label i = fCuts.size()-1; i >= 1; --i)
756 if (!addCut(celli, fCuts[i], nVisited, visited))
761 beforeLastCut = fCuts[1];
767 <<
"In middle of cut. cell:" << celli <<
" face:" << facei
768 <<
" cuts:" << fCuts <<
" current cut:" << cut <<
endl;
778 bool Foam::cellCuts::walkCell
781 const label startCut,
791 label beforeLastCut = -1;
796 Pout<<
"For cell:" << celli <<
" walked across face " << facei
799 writeCuts(
Pout, cuts, loopWeights(cuts));
823 Pout<<
" to last cut ";
825 writeCuts(
Pout, cuts, loopWeights(cuts));
830 if (lastCut == startCut)
838 truncVisited.setSize(nVisited);
840 Pout<<
"For cell " << celli <<
" : found closed path:";
841 writeCuts(
Pout, truncVisited, loopWeights(truncVisited));
842 Pout<<
" closed by " << lastCut <<
endl;
870 if (isEdge(beforeLastCut))
927 getVertex(beforeLastCut),
971 void Foam::cellCuts::calcCellLoops(
const labelList& cutCells)
986 forAll(allFaceCuts, facei)
988 const labelList& fCuts = allFaceCuts[facei];
995 if (
mesh().isInternalFace(facei))
1000 else if (fCuts.size() >= 2)
1005 if (
mesh().isInternalFace(facei))
1019 label celli = cutCells[i];
1021 bool validLoop =
false;
1024 if (nCutFaces[celli] >= 3)
1030 Pout<<
"cell:" << celli <<
" cut faces:" <<
endl;
1033 label facei = cFaces[i];
1034 const labelList& fCuts = allFaceCuts[facei];
1036 Pout<<
" face:" << facei <<
" cuts:";
1037 writeCuts(
Pout, fCuts, loopWeights(fCuts));
1047 label facei = cFaces[cFacei];
1049 const labelList& fCuts = allFaceCuts[facei];
1055 if (fCuts.size() >= 2)
1062 Pout<<
"cell:" << celli
1063 <<
" start walk at face:" << facei
1066 writeCuts(
Pout, cuts, loopWeights(cuts));
1101 for (
label i = 0; i < nVisited; i++)
1103 loop[i] = visited[i];
1110 Pout<<
"calcCellLoops(const labelList&) : did not find valid" 1111 <<
" loop for cell " << celli <<
endl;
1113 writeUncutOBJ(
".", celli);
1115 cellLoops_[celli].setSize(0);
1123 cellLoops_[celli].setSize(0);
1129 void Foam::cellCuts::walkEdges
1135 Map<label>& edgeStatus,
1136 Map<label>& pointStatus
1139 if (pointStatus.insert(pointi, status))
1147 label edgeI = pEdges[pEdgeI];
1152 && edgeStatus.insert(edgeI, status)
1159 walkEdges(celli, v2, status, edgeStatus, pointStatus);
1178 label pointi = cellPoints[i];
1183 &&
findIndex(loop, vertToEVert(pointi)) == -1
1186 newElems[newElemI++] = pointi;
1196 bool Foam::cellCuts::loopAnchorConsistent
1213 forAll(anchorPoints, ptI)
1217 avg /= anchorPoints.
size();
1220 if (((avg - ctr) & normal) > 0)
1231 bool Foam::cellCuts::calcAnchors
1258 label cut = loop[i];
1262 edgeStatus.insert(getEdge(cut), 0);
1266 pointStatus.insert(getVertex(cut), 0);
1273 label edgeI = cEdges[i];
1274 const edge& e = edges[edgeI];
1276 if (pointStatus.found(e[0]) && pointStatus.found(e[1]))
1278 edgeStatus.insert(edgeI, 0);
1284 label uncutIndex = firstUnique(cPoints, pointStatus);
1286 if (uncutIndex == -1)
1289 <<
"Invalid loop " << loop <<
" for cell " << celli << endl
1290 <<
"Can not find point on cell which is not cut by loop." 1299 walkEdges(celli, cPoints[uncutIndex], 1, edgeStatus, pointStatus);
1302 uncutIndex = firstUnique(cPoints, pointStatus);
1304 if (uncutIndex == -1)
1309 <<
"Invalid loop " << loop <<
" for cell " << celli << endl
1310 <<
"All vertices of cell are either in loop or in anchor set" 1320 walkEdges(celli, cPoints[uncutIndex], 2, edgeStatus, pointStatus);
1330 connectedPoints.append(iter.key());
1332 else if (iter() == 2)
1334 otherPoints.append(iter.key());
1337 connectedPoints.shrink();
1338 otherPoints.shrink();
1341 uncutIndex = firstUnique(cPoints, pointStatus);
1343 if (uncutIndex != -1)
1346 <<
"Invalid loop " << loop <<
" for cell " << celli
1347 <<
" since it splits the cell into more than two cells" <<
endl;
1349 writeOBJ(
".", celli, loopPts, connectedPoints);
1361 label pointi = iter.key();
1371 connectedFaces.insert(pFaces[pFacei]);
1375 else if (iter() == 2)
1381 otherFaces.insert(pFaces[pFacei]);
1387 if (connectedFaces.size() < 3)
1390 <<
"Invalid loop " << loop <<
" for cell " << celli
1391 <<
" since would have too few faces on one side." <<
nl 1392 <<
"All faces:" << cFaces <<
endl;
1394 writeOBJ(
".", celli, loopPts, connectedPoints);
1399 if (otherFaces.size() < 3)
1402 <<
"Invalid loop " << loop <<
" for cell " << celli
1403 <<
" since would have too few faces on one side." <<
nl 1404 <<
"All faces:" << cFaces <<
endl;
1406 writeOBJ(
".", celli, loopPts, otherPoints);
1419 label facei = cFaces[i];
1423 bool hasSet1 =
false;
1424 bool hasSet2 =
false;
1426 label prevStat = pointStatus[f[0]];
1431 label pStat = pointStatus[v0];
1433 if (pStat == prevStat)
1436 else if (pStat == 0)
1440 else if (pStat == 1)
1446 <<
"Invalid loop " << loop <<
" for cell " << celli
1447 <<
" since face " << f <<
" would be split into" 1448 <<
" more than two faces" <<
endl;
1450 writeOBJ(
".", celli, loopPts, otherPoints);
1457 else if (pStat == 2)
1463 <<
"Invalid loop " << loop <<
" for cell " << celli
1464 <<
" since face " << f <<
" would be split into" 1465 <<
" more than two faces" <<
endl;
1467 writeOBJ(
".", celli, loopPts, otherPoints);
1483 label v1 = f.nextLabel(fp);
1486 label eStat = edgeStatus[edgeI];
1488 if (eStat == prevStat)
1491 else if (eStat == 0)
1495 else if (eStat == 1)
1501 <<
"Invalid loop " << loop <<
" for cell " << celli
1502 <<
" since face " << f <<
" would be split into" 1503 <<
" more than two faces" <<
endl;
1505 writeOBJ(
".", celli, loopPts, otherPoints);
1512 else if (eStat == 2)
1518 <<
"Invalid loop " << loop <<
" for cell " << celli
1519 <<
" since face " << f <<
" would be split into" 1520 <<
" more than two faces" <<
endl;
1522 writeOBJ(
".", celli, loopPts, otherPoints);
1538 bool loopOk = loopAnchorConsistent(celli, loopPts, connectedPoints);
1543 bool otherLoopOk = loopAnchorConsistent(celli, loopPts, otherPoints);
1545 if (loopOk == otherLoopOk)
1551 <<
" For cell:" << celli
1552 <<
" achorpoints and nonanchorpoints are geometrically" 1553 <<
" on same side!" << endl
1554 <<
"cellPoints:" << cPoints << endl
1555 <<
"loop:" << loop << endl
1556 <<
"anchors:" << connectedPoints << endl
1557 <<
"otherPoints:" << otherPoints <<
endl;
1559 writeOBJ(
".", celli, loopPts, connectedPoints);
1566 anchorPoints.
transfer(connectedPoints);
1567 connectedPoints.clear();
1571 anchorPoints.
transfer(otherPoints);
1572 otherPoints.clear();
1588 loopPts[fp] = coord(loop[fp], loopWeights[fp]);
1600 label cut = loop[fp];
1604 label edgeI = getEdge(cut);
1606 weights[fp] = edgeWeight_[edgeI];
1610 weights[fp] = -GREAT;
1617 bool Foam::cellCuts::validEdgeLoop
1625 label cut = loop[fp];
1629 label edgeI = getEdge(cut);
1632 if (edgeIsCut_[edgeI])
1638 mag(loopWeights[fp] - edgeWeight_[edgeI])
1669 label vertI = f[fp];
1675 || (
findIndex(loop, vertToEVert(vertI)) != -1)
1687 label edgeI = fEdges[fEdgeI];
1693 || (
findIndex(loop, edgeToEVert(edgeI)) != -1)
1704 bool Foam::cellCuts::conservativeValidLoop
1711 if (loop.
size() < 2)
1718 if (isEdge(loop[cutI]))
1720 label edgeI = getEdge(loop[cutI]);
1722 if (edgeIsCut_[edgeI])
1731 if (pointIsCut_[e.
start()] || pointIsCut_[e.
end()])
1742 label nCuts = countFaceCuts(eFaces[eFacei], loop);
1755 label vertI = getVertex(loop[cutI]);
1757 if (!pointIsCut_[vertI])
1766 label edgeI = pEdges[pEdgeI];
1768 if (edgeIsCut_[edgeI])
1779 label nCuts = countFaceCuts(pFaces[pFacei], loop);
1795 bool Foam::cellCuts::validLoop
1810 if (loop.
size() < 2)
1819 if (!conservativeValidLoop(celli, loop))
1821 Info <<
"Invalid conservative loop: " << loop <<
endl;
1828 label cut = loop[fp];
1829 label nextCut = loop[(fp+1) % loop.
size()];
1832 label meshFacei = -1;
1836 label edgeI = getEdge(cut);
1840 if (isEdge(nextCut))
1843 label nextEdgeI = getEdge(nextCut);
1846 meshFacei = edgeEdgeToFace(celli, edgeI, nextEdgeI);
1848 if (meshFacei == -1)
1858 label nextVertI = getVertex(nextCut);
1861 if (e.
start() != nextVertI && e.
end() != nextVertI)
1864 meshFacei = edgeVertexToFace(celli, edgeI, nextVertI);
1866 if (meshFacei == -1)
1877 label vertI = getVertex(cut);
1879 if (isEdge(nextCut))
1882 label nextEdgeI = getEdge(nextCut);
1886 if (nextE.
start() != vertI && nextE.
end() != vertI)
1889 meshFacei = edgeVertexToFace(celli, nextEdgeI, vertI);
1891 if (meshFacei == -1)
1900 label nextVertI = getVertex(nextCut);
1905 meshFacei = vertexVertexToFace(celli, vertI, nextVertI);
1907 if (meshFacei == -1)
1915 if (meshFacei != -1)
1919 edge cutEdge(cut, nextCut);
1923 if (iter == faceSplitCut_.end())
1926 newFaceSplitCut.
insert(meshFacei, cutEdge);
1931 if (iter() != cutEdge)
1940 label faceContainingLoop = loopFace(celli, loop);
1942 if (faceContainingLoop != -1)
1945 <<
"Found loop on cell " << celli <<
" with all points" 1946 <<
" on face " << faceContainingLoop <<
endl;
1959 loopPoints(loop, loopWeights),
1965 void Foam::cellCuts::setFromCellLoops()
1968 pointIsCut_ =
false;
1972 faceSplitCut_.clear();
1974 forAll(cellLoops_, celli)
1976 const labelList& loop = cellLoops_[celli];
2000 <<
"Illegal loop " << loop
2001 <<
" when recreating cut-addressing" 2002 <<
" from existing cellLoops for cell " << celli
2005 cellLoops_[celli].setSize(0);
2006 cellAnchorPoints_[celli].setSize(0);
2011 cellAnchorPoints_[celli].transfer(anchorPoints);
2016 faceSplitCut_.insert(iter.key(), iter());
2022 label cut = loop[cutI];
2026 edgeIsCut_[getEdge(cut)] =
true;
2030 pointIsCut_[getVertex(cut)] =
true;
2038 forAll(edgeIsCut_, edgeI)
2040 if (!edgeIsCut_[edgeI])
2043 edgeWeight_[edgeI] = -GREAT;
2049 bool Foam::cellCuts::setFromCellLoop
2064 str<<
"# edges of cell " << celli <<
nl;
2078 loopStr<<
"# looppoints for cell " << celli <<
nl;
2080 pointField pointsOfLoop = loopPoints(loop, loopWeights);
2091 str <<
' ' << i + 1;
2093 str <<
' ' << 1 <<
nl;
2096 bool okLoop =
false;
2098 if (validEdgeLoop(loop, loopWeights))
2106 validLoop(celli, loop, loopWeights, faceSplitCuts, anchorPoints);
2111 cellLoops_[celli] = loop;
2112 cellAnchorPoints_[celli].
transfer(anchorPoints);
2117 faceSplitCut_.insert(iter.key(), iter());
2124 label cut = loop[cutI];
2128 label edgeI = getEdge(cut);
2130 edgeIsCut_[edgeI] =
true;
2132 edgeWeight_[edgeI] = loopWeights[cutI];
2136 label vertI = getVertex(cut);
2138 pointIsCut_[vertI] =
true;
2148 void Foam::cellCuts::setFromCellLoops
2156 pointIsCut_ =
false;
2160 forAll(cellLabels, cellLabelI)
2162 label celli = cellLabels[cellLabelI];
2164 const labelList& loop = cellLoops[cellLabelI];
2168 const scalarField& loopWeights = cellLoopWeights[cellLabelI];
2170 if (setFromCellLoop(celli, loop, loopWeights))
2184 void Foam::cellCuts::setFromCellCutter
2191 pointIsCut_ =
false;
2205 forAll(refCells, refCelli)
2207 const refineCell& refCell = refCells[refCelli];
2233 if (setFromCellLoop(celli, cellLoop, cellLoopWeights))
2239 cellLoops_[celli].setSize(0);
2242 <<
"Found loop on cell " << celli
2243 <<
" that resulted in an unexpected bad cut." <<
nl 2244 <<
" Suggestions:" <<
nl 2245 <<
" - Turn on the debug switch for 'cellCuts' to get" 2246 <<
" geometry files that identify this cell." <<
nl 2247 <<
" - Also keep in mind to check the defined" 2248 <<
" reference directions, as these are most likely the" 2249 <<
" origin of the problem." 2255 invalidCutCells.
append(celli);
2256 invalidCutLoops.
append(cellLoop);
2257 invalidCutLoopWeights.
append(cellLoopWeights);
2264 cellLoops_[celli].setSize(0);
2268 if (debug && invalidCutCells.
size())
2270 invalidCutCells.
shrink();
2271 invalidCutLoops.
shrink();
2272 invalidCutLoopWeights.
shrink();
2274 fileName cutsFile(
"invalidLoopCells.obj");
2276 Pout<<
"cellCuts : writing inValidLoops cells to " << cutsFile <<
endl;
2289 fileName loopsFile(
"invalidLoops.obj");
2291 Pout<<
"cellCuts : writing inValidLoops loops to " << loopsFile <<
endl;
2297 forAll(invalidCutLoops, i)
2302 loopPoints(invalidCutLoops[i], invalidCutLoopWeights[i]),
2310 void Foam::cellCuts::setFromCellCutter
2318 pointIsCut_ =
false;
2334 label celli = cellLabels[i];
2355 if (setFromCellLoop(celli, cellLoop, cellLoopWeights))
2361 cellLoops_[celli].setSize(0);
2366 invalidCutCells.
append(celli);
2367 invalidCutLoops.
append(cellLoop);
2368 invalidCutLoopWeights.
append(cellLoopWeights);
2375 cellLoops_[celli].setSize(0);
2379 if (debug && invalidCutCells.
size())
2381 invalidCutCells.
shrink();
2382 invalidCutLoops.
shrink();
2383 invalidCutLoopWeights.
shrink();
2385 fileName cutsFile(
"invalidLoopCells.obj");
2387 Pout<<
"cellCuts : writing inValidLoops cells to " << cutsFile <<
endl;
2400 fileName loopsFile(
"invalidLoops.obj");
2402 Pout<<
"cellCuts : writing inValidLoops loops to " << loopsFile <<
endl;
2408 forAll(invalidCutLoops, i)
2413 loopPoints(invalidCutLoops[i], invalidCutLoopWeights[i]),
2421 void Foam::cellCuts::orientPlanesAndLoops()
2424 forAll(cellLoops_, celli)
2426 const labelList& loop = cellLoops_[celli];
2428 if (loop.
size() && cellAnchorPoints_[celli].empty())
2436 cellAnchorPoints_[celli]
2443 Pout<<
"cellAnchorPoints:" <<
endl;
2445 forAll(cellAnchorPoints_, celli)
2447 if (cellLoops_[celli].size())
2449 if (cellAnchorPoints_[celli].empty())
2452 <<
"No anchor points for cut cell " << celli << endl
2458 Pout<<
" cell:" << celli <<
" anchored at " 2459 << cellAnchorPoints_[celli] <<
endl;
2467 forAll(cellLoops_, celli)
2469 if (cellLoops_[celli].size())
2477 void Foam::cellCuts::calcLoopsAndAddressing(
const labelList& cutCells)
2480 forAll(edgeIsCut_, edgeI)
2482 if (edgeIsCut_[edgeI])
2484 scalar weight = edgeWeight_[edgeI];
2486 if (weight < 0 || weight > 1)
2489 <<
"Weight out of range [0,1]. Edge " << edgeI
2497 edgeWeight_[edgeI] = -GREAT;
2503 calcCellLoops(cutCells);
2508 forAll(cellLoops_, celli)
2510 const labelList& loop = cellLoops_[celli];
2514 Pout<<
"cell:" << celli <<
" ";
2515 writeCuts(
Pout, loop, loopWeights(loop));
2527 void Foam::cellCuts::check()
const 2530 forAll(edgeIsCut_, edgeI)
2532 if (edgeIsCut_[edgeI])
2542 <<
"edge:" << edgeI <<
" vertices:" 2544 <<
" weight:" << edgeWeight_[edgeI] <<
" should have been" 2545 <<
" snapped to one of its endpoints" 2551 if (edgeWeight_[edgeI] > - 1)
2554 <<
"edge:" << edgeI <<
" vertices:" 2556 <<
" weight:" << edgeWeight_[edgeI] <<
" is not cut but" 2557 <<
" its weight is not marked invalid" 2564 forAll(cellLoops_, celli)
2566 const labelList& loop = cellLoops_[celli];
2570 label cut = loop[i];
2574 (isEdge(cut) && !edgeIsCut_[getEdge(cut)])
2575 || (!isEdge(cut) && !pointIsCut_[getVertex(cut)])
2579 writeCuts(
Pout, cuts, loopWeights(cuts));
2582 <<
"cell:" << celli <<
" loop:" 2584 <<
" cut:" << cut <<
" is not marked as cut" 2591 forAll(cellLoops_, celli)
2593 const labelList& anchors = cellAnchorPoints_[celli];
2595 const labelList& loop = cellLoops_[celli];
2600 <<
"cell:" << celli <<
" loop:" << loop
2601 <<
" has no anchor points" 2608 label cut = loop[i];
2613 &&
findIndex(anchors, getVertex(cut)) != -1
2617 <<
"cell:" << celli <<
" loop:" << loop
2618 <<
" anchor points:" << anchors
2619 <<
" anchor:" << getVertex(cut) <<
" is part of loop" 2629 label facei = iter.key();
2631 if (
mesh().isInternalFace(facei))
2636 if (cellLoops_[own].empty() && cellLoops_[nei].empty())
2639 <<
"Internal face:" << facei <<
" cut by " << iter()
2640 <<
" has owner:" << own
2641 <<
" and neighbour:" << nei
2642 <<
" that are both uncut" 2650 if (cellLoops_[own].empty())
2653 <<
"Boundary face:" << facei <<
" cut by " << iter()
2654 <<
" has owner:" << own
2665 Foam::cellCuts::cellCuts
2677 edgeWeight_(
expand(mesh.
nEdges(), meshEdges, meshEdgeWeights)),
2679 faceSplitCut_(cutCells.
size()),
2680 cellLoops_(mesh.
nCells()),
2682 cellAnchorPoints_(mesh.
nCells())
2686 Pout<<
"cellCuts : constructor from cut verts and edges" <<
endl;
2689 calcLoopsAndAddressing(cutCells);
2692 orientPlanesAndLoops();
2703 Pout<<
"cellCuts : leaving constructor from cut verts and edges" 2709 Foam::cellCuts::cellCuts
2720 edgeWeight_(
expand(mesh.
nEdges(), meshEdges, meshEdgeWeights)),
2722 faceSplitCut_(mesh.
nFaces()/10 + 1),
2723 cellLoops_(mesh.
nCells()),
2725 cellAnchorPoints_(mesh.
nCells())
2732 Pout<<
"cellCuts : constructor from cellLoops" <<
endl;
2738 orientPlanesAndLoops();
2749 Pout<<
"cellCuts : leaving constructor from cellLoops" <<
endl;
2754 Foam::cellCuts::cellCuts
2763 pointIsCut_(mesh.
nPoints(),
false),
2764 edgeIsCut_(mesh.
nEdges(),
false),
2765 edgeWeight_(mesh.
nEdges(), -GREAT),
2767 faceSplitCut_(cellLabels.
size()),
2768 cellLoops_(mesh.
nCells()),
2770 cellAnchorPoints_(mesh.
nCells())
2774 Pout<<
"cellCuts : constructor from cellLoops" <<
endl;
2779 setFromCellLoops(cellLabels, cellLoops, cellEdgeWeights);
2782 orientPlanesAndLoops();
2793 Pout<<
"cellCuts : leaving constructor from cellLoops" <<
endl;
2798 Foam::cellCuts::cellCuts
2806 pointIsCut_(mesh.
nPoints(),
false),
2807 edgeIsCut_(mesh.
nEdges(),
false),
2808 edgeWeight_(mesh.
nEdges(), -GREAT),
2810 faceSplitCut_(refCells.
size()),
2811 cellLoops_(mesh.
nCells()),
2813 cellAnchorPoints_(mesh.
nCells())
2817 Pout<<
"cellCuts : constructor from cellCutter" <<
endl;
2822 setFromCellCutter(cellCutter, refCells);
2825 orientPlanesAndLoops();
2836 Pout<<
"cellCuts : leaving constructor from cellCutter" <<
endl;
2841 Foam::cellCuts::cellCuts
2850 pointIsCut_(mesh.
nPoints(),
false),
2851 edgeIsCut_(mesh.
nEdges(),
false),
2852 edgeWeight_(mesh.
nEdges(), -GREAT),
2854 faceSplitCut_(cellLabels.
size()),
2855 cellLoops_(mesh.
nCells()),
2857 cellAnchorPoints_(mesh.
nCells())
2861 Pout<<
"cellCuts : constructor from cellCutter with prescribed plane" 2867 setFromCellCutter(cellCutter, cellLabels, cutPlanes);
2870 orientPlanesAndLoops();
2881 Pout<<
"cellCuts : leaving constructor from cellCutter with prescribed" 2882 <<
" plane" <<
endl;
2887 Foam::cellCuts::cellCuts
2900 pointIsCut_(pointIsCut),
2901 edgeIsCut_(edgeIsCut),
2902 edgeWeight_(edgeWeight),
2904 faceSplitCut_(faceSplitCut),
2905 cellLoops_(cellLoops),
2907 cellAnchorPoints_(cellAnchorPoints)
2911 Pout<<
"cellCuts : constructor from components" <<
endl;
2912 Pout<<
"cellCuts : leaving constructor from components" <<
endl;
2935 const labelList& loop = cellLoops_[celli];
2941 label cut = loop[fp];
2945 label edgeI = getEdge(cut);
2947 loopPts[fp] = coord(cut, edgeWeight_[edgeI]);
2951 loopPts[fp] = coord(cut, -GREAT);
2965 cellAnchorPoints_[celli] =
2968 mesh().cellPoints()[celli],
2969 cellAnchorPoints_[celli],
2983 void Foam::cellCuts::writeOBJ
2990 label startVertI = vertI;
2994 const point& pt = loopPts[fp];
2996 os <<
"v " << pt.
x() <<
' ' << pt.
y() <<
' ' << pt.
z() <<
endl;
3004 os <<
' ' << startVertI + fp + 1;
3014 forAll(cellLoops_, celli)
3016 writeOBJ(os, loopPoints(celli), vertI);
3023 const labelList& anchors = cellAnchorPoints_[celli];
3025 writeOBJ(dir, celli, loopPoints(celli), anchors);
const labelListList & pointFaces() const
label end() const
Return end vertex label.
List< labelList > labelListList
A List of labelList.
point centre(const pointField &) const
Centre point of face.
#define forAll(list, i)
Loop across all elements in list.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
A class for handling file names.
An STL-conforming const_iterator.
A face is a list of labels corresponding to mesh vertices.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
bool empty() const
Return true if the UList is empty (ie, size() is zero)
const edgeList & edges() const
Return mesh edges. Uses calcEdges.
void size(const label)
Override size to be inconsistent with allocated storage.
const labelListList & cellPoints() const
void flip(const label celli)
Flip loop for celli. Updates anchor points as well.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Abstract base class. Concrete implementations know how to cut a cell (i.e. determine a loop around th...
labelList identity(const label len)
Create identity map (map[i] == i) of given length.
static word timeName(const scalar, const int precision=precision_)
Return time name of given scalar time.
vector normal(const pointField &) const
Vector normal; magnitude is equal to area of face.
const cellList & cells() const
const labelListList & edgeFaces() const
const vector & direction() const
virtual const pointField & points() const
Return raw points.
Various functions to operate on Lists.
List< bool > boolList
Bool container classes.
bool insert(const label &, const T &newElmt)
Insert a new hashedEntry.
vectorField pointField
pointField is a vectorField.
static const labelSphericalTensor labelI(1)
Identity labelTensor.
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
void clearOut()
Clear out demand driven storage.
string expand(const string &, const HashTable< string, word, string::hash > &mapping, const char sigil= '$')
Expand occurences of variables according to the mapping.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
Combines edge or vertex in single label. Used to specify cuts across cell circumference.
List< label > labelList
A List of labels.
const labelListList & pointEdges() const
Container with cells to refine. Refinement given as single direction.
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
errorManip< error > abort(error &err)
An Ostream is an abstract base class for all output systems (streams, files, token lists...
prefixOSstream Pout(cout,"Pout")
label start() const
Return start vertex label.
void reverse(UList< T > &, const label n)
DynamicList< T, SizeInc, SizeMult, SizeDiv > & shrink()
Shrink the allocated space to the number of elements used.
const labelListList & cellEdges() const
defineTypeNameAndDebug(combustionModel, 0)
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurence of given element and return index,.
word name(const complex &)
Return a string representation of a complex.
A normal distribution model.
void setSize(const label)
Reset size of List.
virtual const labelList & faceNeighbour() const
Return face neighbour.
#define WarningInFunction
Report a warning using Foam::Warning.
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.
A cell is defined as a list of faces with extra functionality.
dimensioned< scalar > mag(const dimensioned< Type > &)
Mesh consisting of general polyhedral cells.
virtual const labelList & faceOwner() const
Return face owner.
virtual const faceList & faces() const
Return raw faces.
const labelListList & faceEdges() const
void deleteDemandDrivenData(DataPtr &dataPtr)
void writeCellOBJ(const fileName &dir, const label celli) const
debugging:Write edges of cell and loop
labelList nonAnchorPoints(const labelList &cellPoints, const labelList &anchorPoints, const labelList &loop) const
Invert anchor point selection.
void transfer(List< T > &)
Transfer the contents of the argument List into this list.
static const label labelMin
const Time & time() const
Return the top-level database.
void flipLoopOnly(const label celli)
Flip loop for celli. Does not update anchors. Use with care.