ENH: cell cutting: less verbose. Allow cutting single face. See #631.

This commit is contained in:
mattijs
2017-11-01 17:46:12 +00:00
parent 6f6029d0a6
commit 46e8543653
2 changed files with 155 additions and 88 deletions

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -596,9 +596,12 @@ void Foam::cellCuts::calcFaceCuts() const
if (allVerticesCut)
{
WarningInFunction
<< "Face " << facei << " vertices " << f
<< " has all its vertices cut. Not cutting face." << endl;
if (verbose_ || debug)
{
WarningInFunction
<< "Face " << facei << " vertices " << f
<< " has all its vertices cut. Not cutting face." << endl;
}
cutI = 0;
}
@ -808,13 +811,17 @@ bool Foam::cellCuts::addCut
labelList truncVisited(visited);
truncVisited.setSize(nVisited);
Pout<< "For cell " << celli << " : trying to add duplicate cut " << cut;
labelList cuts(1, cut);
writeCuts(Pout, cuts, loopWeights(cuts));
if (verbose_ || debug)
{
Pout<< "For cell " << celli << " : trying to add duplicate cut "
<< cut;
labelList cuts(1, cut);
writeCuts(Pout, cuts, loopWeights(cuts));
Pout<< " to path:";
writeCuts(Pout, truncVisited, loopWeights(truncVisited));
Pout<< endl;
Pout<< " to path:";
writeCuts(Pout, truncVisited, loopWeights(truncVisited));
Pout<< endl;
}
return false;
}
@ -905,9 +912,12 @@ bool Foam::cellCuts::walkFace
}
else
{
WarningInFunction
<< "In middle of cut. cell:" << celli << " face:" << facei
<< " cuts:" << fCuts << " current cut:" << cut << endl;
if (verbose_ || debug)
{
WarningInFunction
<< "In middle of cut. cell:" << celli << " face:" << facei
<< " cuts:" << fCuts << " current cut:" << cut << endl;
}
return false;
}
@ -1163,7 +1173,7 @@ void Foam::cellCuts::calcCellLoops(const labelList& cutCells)
bool validLoop = false;
// Quick rejection: has enough faces that are cut?
if (nCutFaces[celli] >= 3)
if (nCutFaces[celli] >= 1)
{
const labelList& cFaces = mesh().cells()[celli];
@ -1249,11 +1259,14 @@ void Foam::cellCuts::calcCellLoops(const labelList& cutCells)
{
// Invalid loop. Leave cellLoops_[celli] zero size which
// flags this.
Pout<< "calcCellLoops(const labelList&) : did not find valid"
<< " loop for cell " << celli << endl;
// Dump cell and cuts on cell.
writeUncutOBJ(".", celli);
if (verbose_ || debug)
{
Pout<< "calcCellLoops(const labelList&) :"
<< " did not find valid"
<< " loop for cell " << celli << endl;
// Dump cell and cuts on cell.
writeUncutOBJ(".", celli);
}
cellLoops_[celli].setSize(0);
}
}
@ -1427,12 +1440,15 @@ bool Foam::cellCuts::calcAnchors
if (uncutIndex == -1)
{
WarningInFunction
<< "Invalid loop " << loop << " for cell " << celli << endl
<< "Can not find point on cell which is not cut by loop."
<< endl;
if (verbose_ || debug)
{
WarningInFunction
<< "Invalid loop " << loop << " for cell " << celli << endl
<< "Can not find point on cell which is not cut by loop."
<< endl;
writeOBJ(".", celli, loopPts, labelList(0));
writeOBJ(".", celli, loopPts, labelList(0));
}
return false;
}
@ -1447,12 +1463,15 @@ bool Foam::cellCuts::calcAnchors
{
// All vertices either in loop or in anchor. So split is along single
// face.
WarningInFunction
<< "Invalid loop " << loop << " for cell " << celli << endl
<< "All vertices of cell are either in loop or in anchor set"
<< endl;
if (verbose_ || debug)
{
WarningInFunction
<< "Invalid loop " << loop << " for cell " << celli << endl
<< "All vertices of cell are either in loop or in anchor set"
<< endl;
writeOBJ(".", celli, loopPts, labelList(0));
writeOBJ(".", celli, loopPts, labelList(0));
}
return false;
}
@ -1484,11 +1503,14 @@ bool Foam::cellCuts::calcAnchors
if (uncutIndex != -1)
{
WarningInFunction
<< "Invalid loop " << loop << " for cell " << celli
<< " since it splits the cell into more than two cells" << endl;
if (verbose_ || debug)
{
WarningInFunction
<< "Invalid loop " << loop << " for cell " << celli
<< " since it splits the cell into more than two cells" << endl;
writeOBJ(".", celli, loopPts, connectedPoints);
writeOBJ(".", celli, loopPts, connectedPoints);
}
return false;
}
@ -1528,24 +1550,30 @@ bool Foam::cellCuts::calcAnchors
if (connectedFaces.size() < 3)
{
WarningInFunction
<< "Invalid loop " << loop << " for cell " << celli
<< " since would have too few faces on one side." << nl
<< "All faces:" << cFaces << endl;
if (verbose_ || debug)
{
WarningInFunction
<< "Invalid loop " << loop << " for cell " << celli
<< " since would have too few faces on one side." << nl
<< "All faces:" << cFaces << endl;
writeOBJ(".", celli, loopPts, connectedPoints);
writeOBJ(".", celli, loopPts, connectedPoints);
}
return false;
}
if (otherFaces.size() < 3)
{
WarningInFunction
<< "Invalid loop " << loop << " for cell " << celli
<< " since would have too few faces on one side." << nl
<< "All faces:" << cFaces << endl;
if (verbose_ || debug)
{
WarningInFunction
<< "Invalid loop " << loop << " for cell " << celli
<< " since would have too few faces on one side." << nl
<< "All faces:" << cFaces << endl;
writeOBJ(".", celli, loopPts, otherPoints);
writeOBJ(".", celli, loopPts, otherPoints);
}
return false;
}
@ -1584,13 +1612,16 @@ bool Foam::cellCuts::calcAnchors
if (hasSet1)
{
// Second occurence of set1.
WarningInFunction
<< "Invalid loop " << loop << " for cell " << celli
<< " since face " << f << " would be split into"
<< " more than two faces" << endl;
writeOBJ(".", celli, loopPts, otherPoints);
if (verbose_ || debug)
{
WarningInFunction
<< "Invalid loop " << loop << " for cell "
<< celli
<< " since face " << f << " would be split into"
<< " more than two faces" << endl;
writeOBJ(".", celli, loopPts, otherPoints);
}
return false;
}
@ -1601,13 +1632,16 @@ bool Foam::cellCuts::calcAnchors
if (hasSet2)
{
// Second occurence of set1.
WarningInFunction
<< "Invalid loop " << loop << " for cell " << celli
<< " since face " << f << " would be split into"
<< " more than two faces" << endl;
writeOBJ(".", celli, loopPts, otherPoints);
if (verbose_ || debug)
{
WarningInFunction
<< "Invalid loop " << loop << " for cell "
<< celli
<< " since face " << f << " would be split into"
<< " more than two faces" << endl;
writeOBJ(".", celli, loopPts, otherPoints);
}
return false;
}
@ -1639,12 +1673,16 @@ bool Foam::cellCuts::calcAnchors
if (hasSet1)
{
// Second occurence of set1.
WarningInFunction
<< "Invalid loop " << loop << " for cell " << celli
<< " since face " << f << " would be split into"
<< " more than two faces" << endl;
if (verbose_ || debug)
{
WarningInFunction
<< "Invalid loop " << loop << " for cell "
<< celli
<< " since face " << f << " would be split into"
<< " more than two faces" << endl;
writeOBJ(".", celli, loopPts, otherPoints);
writeOBJ(".", celli, loopPts, otherPoints);
}
return false;
}
@ -1656,13 +1694,16 @@ bool Foam::cellCuts::calcAnchors
if (hasSet2)
{
// Second occurence of set1.
WarningInFunction
<< "Invalid loop " << loop << " for cell " << celli
<< " since face " << f << " would be split into"
<< " more than two faces" << endl;
writeOBJ(".", celli, loopPts, otherPoints);
if (verbose_ || debug)
{
WarningInFunction
<< "Invalid loop " << loop << " for cell "
<< celli
<< " since face " << f << " would be split into"
<< " more than two faces" << endl;
writeOBJ(".", celli, loopPts, otherPoints);
}
return false;
}
@ -2083,9 +2124,12 @@ bool Foam::cellCuts::validLoop
if (faceContainingLoop != -1)
{
WarningInFunction
<< "Found loop on cell " << celli << " with all points"
<< " on face " << faceContainingLoop << endl;
if (verbose_ || debug)
{
WarningInFunction
<< "Found loop on cell " << celli << " with all points"
<< " on face " << faceContainingLoop << endl;
}
//writeOBJ(".", celli, loopPoints(loop, loopWeights), labelList(0));
@ -2137,12 +2181,14 @@ void Foam::cellCuts::setFromCellLoops()
)
{
//writeOBJ(".", celli, loopPoints(celli), anchorPoints);
WarningInFunction
<< "Illegal loop " << loop
<< " when recreating cut-addressing"
<< " from existing cellLoops for cell " << celli
<< endl;
if (verbose_ || debug)
{
WarningInFunction
<< "Illegal loop " << loop
<< " when recreating cut-addressing"
<< " from existing cellLoops for cell " << celli
<< endl;
}
cellLoops_[celli].setSize(0);
cellAnchorPoints_[celli].setSize(0);
@ -2822,10 +2868,12 @@ Foam::cellCuts::cellCuts
const labelList& cutCells,
const labelList& meshVerts,
const labelList& meshEdges,
const scalarField& meshEdgeWeights
const scalarField& meshEdgeWeights,
const bool verbose
)
:
edgeVertex(mesh),
verbose_(verbose),
pointIsCut_(expand(mesh.nPoints(), meshVerts)),
edgeIsCut_(expand(mesh.nEdges(), meshEdges)),
edgeWeight_(expand(mesh.nEdges(), meshEdges, meshEdgeWeights)),
@ -2864,10 +2912,12 @@ Foam::cellCuts::cellCuts
const polyMesh& mesh,
const labelList& meshVerts,
const labelList& meshEdges,
const scalarField& meshEdgeWeights
const scalarField& meshEdgeWeights,
const bool verbose
)
:
edgeVertex(mesh),
verbose_(verbose),
pointIsCut_(expand(mesh.nPoints(), meshVerts)),
edgeIsCut_(expand(mesh.nEdges(), meshEdges)),
edgeWeight_(expand(mesh.nEdges(), meshEdges, meshEdgeWeights)),
@ -2911,10 +2961,12 @@ Foam::cellCuts::cellCuts
const polyMesh& mesh,
const labelList& cellLabels,
const labelListList& cellLoops,
const List<scalarField>& cellEdgeWeights
const List<scalarField>& cellEdgeWeights,
const bool verbose
)
:
edgeVertex(mesh),
verbose_(verbose),
pointIsCut_(mesh.nPoints(), false),
edgeIsCut_(mesh.nEdges(), false),
edgeWeight_(mesh.nEdges(), -GREAT),
@ -2956,10 +3008,12 @@ Foam::cellCuts::cellCuts
(
const polyMesh& mesh,
const cellLooper& cellCutter,
const List<refineCell>& refCells
const List<refineCell>& refCells,
const bool verbose
)
:
edgeVertex(mesh),
verbose_(verbose),
pointIsCut_(mesh.nPoints(), false),
edgeIsCut_(mesh.nEdges(), false),
edgeWeight_(mesh.nEdges(), -GREAT),
@ -3002,10 +3056,12 @@ Foam::cellCuts::cellCuts
const polyMesh& mesh,
const cellLooper& cellCutter,
const labelList& cellLabels,
const List<plane>& cutPlanes
const List<plane>& cutPlanes,
const bool verbose
)
:
edgeVertex(mesh),
verbose_(verbose),
pointIsCut_(mesh.nPoints(), false),
edgeIsCut_(mesh.nEdges(), false),
edgeWeight_(mesh.nEdges(), -GREAT),
@ -3054,10 +3110,12 @@ Foam::cellCuts::cellCuts
const Map<edge>& faceSplitCut,
const labelListList& cellLoops,
const label nLoops,
const labelListList& cellAnchorPoints
const labelListList& cellAnchorPoints,
const bool verbose
)
:
edgeVertex(mesh),
verbose_(verbose),
pointIsCut_(pointIsCut),
edgeIsCut_(edgeIsCut),
edgeWeight_(edgeWeight),

View File

@ -112,6 +112,10 @@ class cellCuts
{
// Private data
//- Warn for illegal cuts
const bool verbose_;
// Per point/edge status
//- Is mesh point cut
@ -472,7 +476,8 @@ public:
const labelList& cutCells,
const labelList& meshVerts,
const labelList& meshEdges,
const scalarField& meshEdgeWeights
const scalarField& meshEdgeWeights,
const bool verbose = true
);
//- Construct from pattern of cuts. Detect cells to cut.
@ -481,7 +486,8 @@ public:
const polyMesh& mesh,
const labelList& meshVerts,
const labelList& meshEdges,
const scalarField& meshEdgeWeights
const scalarField& meshEdgeWeights,
const bool verbose = true
);
//- Construct from complete cellLoops through specified cells.
@ -492,7 +498,8 @@ public:
const polyMesh& mesh,
const labelList& cellLabels,
const labelListList& cellLoops,
const List<scalarField>& cellEdgeWeights
const List<scalarField>& cellEdgeWeights,
const bool verbose = true
);
//- Construct from list of cells to cut and direction to cut in
@ -501,7 +508,8 @@ public:
(
const polyMesh& mesh,
const cellLooper& cellCutter,
const List<refineCell>& refCells
const List<refineCell>& refCells,
const bool verbose = true
);
//- Construct from list of cells to cut and plane to cut with and
@ -511,7 +519,8 @@ public:
const polyMesh& mesh,
const cellLooper& cellCutter,
const labelList& cellLabels,
const List<plane>& cutPlanes
const List<plane>& cutPlanes,
const bool verbose = true
);
//- Construct from components
@ -524,7 +533,8 @@ public:
const Map<edge>& faceSplitCut,
const labelListList& cellLoops,
const label nLoops,
const labelListList& cellAnchorPoints
const labelListList& cellAnchorPoints,
const bool verbose = true
);
@ -630,7 +640,6 @@ public:
//- debugging:Write edges of cell and loop
void writeCellOBJ(const fileName& dir, const label celli) const;
};