Commit 41f9e71c authored by Henry Weller's avatar Henry Weller
Browse files

dynamicMesh/meshCut: Improved diagnostics and documentation

Patch provided by Bruno Santos
Resolves bug-report http://www.openfoam.org/mantisbt/view.php?id=1960
parent 65c98f27
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -44,7 +44,6 @@ defineTypeNameAndDebug(cellCuts, 0);
// * * * * * * * * * * * * * Private Static Functions * * * * * * * * * * * //
// Find val in first nElems elements of list.
Foam::label Foam::cellCuts::findPartIndex
(
const labelList& elems,
......@@ -96,7 +95,6 @@ Foam::scalarField Foam::cellCuts::expand
}
// Find first point in lst not in map.
Foam::label Foam::cellCuts::firstUnique
(
const labelList& lst,
......@@ -116,7 +114,6 @@ Foam::label Foam::cellCuts::firstUnique
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// Write cell and raw cuts on any of the elements
void Foam::cellCuts::writeUncutOBJ
(
const fileName& dir,
......@@ -223,7 +220,6 @@ void Foam::cellCuts::writeOBJ
}
// Find face on cell using the two edges.
Foam::label Foam::cellCuts::edgeEdgeToFace
(
const label cellI,
......@@ -264,7 +260,6 @@ Foam::label Foam::cellCuts::edgeEdgeToFace
}
// Find face on cell using an edge and a vertex.
Foam::label Foam::cellCuts::edgeVertexToFace
(
const label cellI,
......@@ -304,7 +299,6 @@ Foam::label Foam::cellCuts::edgeVertexToFace
}
// Find face using two vertices (guaranteed not to be along edge)
Foam::label Foam::cellCuts::vertexVertexToFace
(
const label cellI,
......@@ -477,7 +471,6 @@ void Foam::cellCuts::calcFaceCuts() const
}
// Find edge on face using two vertices
Foam::label Foam::cellCuts::findEdge
(
const label faceI,
......@@ -507,7 +500,6 @@ Foam::label Foam::cellCuts::findEdge
}
// Check if there is a face on the cell on which all cuts are.
Foam::label Foam::cellCuts::loopFace
(
const label cellI,
......@@ -559,7 +551,6 @@ Foam::label Foam::cellCuts::loopFace
}
// From point go into connected face
bool Foam::cellCuts::walkPoint
(
const label cellI,
......@@ -615,7 +606,6 @@ bool Foam::cellCuts::walkPoint
}
// Cross cut (which is edge on faceI) onto next face
bool Foam::cellCuts::crossEdge
(
const label cellI,
......@@ -695,8 +685,6 @@ bool Foam::cellCuts::addCut
}
// Walk across faceI, storing cuts as you go. Returns last two cuts visisted.
// Returns true if valid walk.
bool Foam::cellCuts::walkFace
(
const label cellI,
......@@ -787,8 +775,6 @@ bool Foam::cellCuts::walkFace
// Walk across cuts (cut edges or cut vertices) of cell. Stops when hit cut
// already visited. Returns true when loop of 3 or more vertices found.
bool Foam::cellCuts::walkCell
(
const label cellI,
......@@ -982,13 +968,14 @@ bool Foam::cellCuts::walkCell
}
// Determine for every cut cell the loop (= face) it is cut by. Done by starting
// from a cut edge or cut vertex and walking across faces, from cut to cut,
// until starting cut hit.
// If multiple loops are possible across a cell circumference takes the first
// one found.
void Foam::cellCuts::calcCellLoops(const labelList& cutCells)
{
// Determine for every cut cell the loop (= face) it is cut by. Done by
// starting from a cut edge or cut vertex and walking across faces, from
// cut to cut, until starting cut hit.
// If multiple loops are possible across a cell circumference takes the
// first one found.
// Calculate cuts per face.
const labelListList& allFaceCuts = faceCuts();
......@@ -1139,8 +1126,6 @@ void Foam::cellCuts::calcCellLoops(const labelList& cutCells)
}
// Walk unset edges of single cell from starting point and marks visited
// edges and vertices with status.
void Foam::cellCuts::walkEdges
(
const label cellI,
......@@ -1178,7 +1163,6 @@ void Foam::cellCuts::walkEdges
}
// Invert anchor point selection.
Foam::labelList Foam::cellCuts::nonAnchorPoints
(
const labelList& cellPoints,
......@@ -1209,7 +1193,6 @@ Foam::labelList Foam::cellCuts::nonAnchorPoints
}
//- Check anchor points on 'outside' of loop
bool Foam::cellCuts::loopAnchorConsistent
(
const label cellI,
......@@ -1245,10 +1228,6 @@ bool Foam::cellCuts::loopAnchorConsistent
}
// Determines set of anchor points given a loop. The loop should split the
// cell into (one or) two sets of vertices. The set of vertices that is
// on the 'normal' side of the loop is the anchor set.
// Returns true if valid set, false otherwise.
bool Foam::cellCuts::calcAnchors
(
const label cellI,
......@@ -1612,7 +1591,6 @@ Foam::pointField Foam::cellCuts::loopPoints
}
// Returns weights of loop. Inverse of loopPoints.
Foam::scalarField Foam::cellCuts::loopWeights(const labelList& loop) const
{
scalarField weights(loop.size());
......@@ -1636,7 +1614,6 @@ Foam::scalarField Foam::cellCuts::loopWeights(const labelList& loop) const
}
// Check if cut edges in loop are compatible with ones in edgeIsCut_
bool Foam::cellCuts::validEdgeLoop
(
const labelList& loop,
......@@ -1672,15 +1649,16 @@ bool Foam::cellCuts::validEdgeLoop
}
// Counts cuts on face. Includes cuts through vertices and through edges.
// Assumes that if edge is cut both in edgeIsCut and in loop that the position
// of the cut is the same.
Foam::label Foam::cellCuts::countFaceCuts
(
const label faceI,
const labelList& loop
) const
{
// Includes cuts through vertices and through edges.
// Assumes that if edge is cut both in edgeIsCut and in loop that the
// position of the cut is the same.
label nCuts = 0;
// Count cut vertices
......@@ -1723,8 +1701,6 @@ Foam::label Foam::cellCuts::countFaceCuts
}
// Determine compatibility of loop with existing cut pattern. Does not use
// cut-addressing (faceCuts_, cutCuts_)
bool Foam::cellCuts::conservativeValidLoop
(
const label cellI,
......@@ -1816,10 +1792,6 @@ bool Foam::cellCuts::conservativeValidLoop
}
// Determine compatibility of loop with existing cut pattern. Does not use
// derived cut-addressing (faceCuts), only pointIsCut, edgeIsCut.
// Adds any cross-cuts found to newFaceSplitCut and sets cell points on
// one side of the loop in anchorPoints.
bool Foam::cellCuts::validLoop
(
const label cellI,
......@@ -1830,6 +1802,11 @@ bool Foam::cellCuts::validLoop
labelList& anchorPoints
) const
{
// Determine compatibility of loop with existing cut pattern. Does not use
// derived cut-addressing (faceCuts), only pointIsCut, edgeIsCut.
// Adds any cross-cuts found to newFaceSplitCut and sets cell points on
// one side of the loop in anchorPoints.
if (loop.size() < 2)
{
return false;
......@@ -1841,6 +1818,7 @@ bool Foam::cellCuts::validLoop
// cut per face is allowed.
if (!conservativeValidLoop(cellI, loop))
{
Info << "Invalid conservative loop: " << loop << endl;
return false;
}
}
......@@ -1984,9 +1962,6 @@ bool Foam::cellCuts::validLoop
}
// Update basic cut information (pointIsCut, edgeIsCut) from cellLoops.
// Assumes cellLoops_ and edgeWeight_ already set and consistent.
// Does not use any other information.
void Foam::cellCuts::setFromCellLoops()
{
// 'Uncut' edges/vertices that are not used in loops.
......@@ -2071,8 +2046,6 @@ void Foam::cellCuts::setFromCellLoops()
}
// Upate basic cut information from single cellLoop. Returns true if loop
// was valid.
bool Foam::cellCuts::setFromCellLoop
(
const label cellI,
......@@ -2080,6 +2053,9 @@ bool Foam::cellCuts::setFromCellLoop
const scalarField& loopWeights
)
{
// Update basic cut information from single cellLoop. Returns true if loop
// was valid.
// Dump loop for debugging.
if (debug)
{
......@@ -2169,8 +2145,6 @@ bool Foam::cellCuts::setFromCellLoop
}
// Update basic cut information from cellLoops. Checks for consistency with
// existing cut pattern.
void Foam::cellCuts::setFromCellLoops
(
const labelList& cellLabels,
......@@ -2207,8 +2181,6 @@ void Foam::cellCuts::setFromCellLoops
}
// Cut cells and update basic cut information from cellLoops. Checks each loop
// for consistency with existing cut pattern.
void Foam::cellCuts::setFromCellCutter
(
const cellLooper& cellCutter,
......@@ -2266,6 +2238,17 @@ void Foam::cellCuts::setFromCellCutter
{
cellLoops_[cellI].setSize(0);
WarningInFunction
<< "Found loop on cell " << cellI
<< " that resulted in an unexpected bad cut."
<< " Suggestions:" << nl
<< " - Turn on the debug switch for 'cellCuts' to get"
<< " geometry files that identify this cell." << nl
<< " - Also keep in mind to check the defined"
<< " reference directions, as these are most likely the"
<< " origin of the problem."
<< nl << endl;
// Discarded by validLoop
if (debug)
{
......@@ -2324,7 +2307,6 @@ void Foam::cellCuts::setFromCellCutter
}
// Same as one before but cut plane prescribed (instead of just normal)
void Foam::cellCuts::setFromCellCutter
(
const cellLooper& cellCutter,
......@@ -2436,7 +2418,6 @@ void Foam::cellCuts::setFromCellCutter
}
// Set orientation of loops
void Foam::cellCuts::orientPlanesAndLoops()
{
// Determine anchorPoints if not yet done by validLoop.
......@@ -2493,7 +2474,6 @@ void Foam::cellCuts::orientPlanesAndLoops()
}
// Do all: calculate addressing, calculate loops splitting cells
void Foam::cellCuts::calcLoopsAndAddressing(const labelList& cutCells)
{
// Sanity check on weights
......@@ -2682,7 +2662,6 @@ void Foam::cellCuts::check() const
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from cells to cut and pattern of cuts
Foam::cellCuts::cellCuts
(
const polyMesh& mesh,
......@@ -2727,8 +2706,6 @@ Foam::cellCuts::cellCuts
}
// Construct from pattern of cuts. Finds out itself which cells are cut.
// (can go wrong if e.g. all neighbours of cell are refined)
Foam::cellCuts::cellCuts
(
const polyMesh& mesh,
......@@ -2747,6 +2724,9 @@ Foam::cellCuts::cellCuts
nLoops_(-1),
cellAnchorPoints_(mesh.nCells())
{
// Construct from pattern of cuts. Finds out itself which cells are cut.
// (can go wrong if e.g. all neighbours of cell are refined)
if (debug)
{
Pout<< "cellCuts : constructor from cellLoops" << endl;
......@@ -2771,8 +2751,6 @@ Foam::cellCuts::cellCuts
}
// Construct from complete cellLoops. Assumes correct cut pattern.
// Only constructs cut-cut addressing and cellAnchorPoints
Foam::cellCuts::cellCuts
(
const polyMesh& mesh,
......@@ -2817,7 +2795,6 @@ Foam::cellCuts::cellCuts
}
// Construct from list of cells to cut and cell cutter.
Foam::cellCuts::cellCuts
(
const polyMesh& mesh,
......@@ -2861,7 +2838,6 @@ Foam::cellCuts::cellCuts
}
// Construct from list of cells to cut, plane to cut with and cell cutter.
Foam::cellCuts::cellCuts
(
const polyMesh& mesh,
......@@ -2908,7 +2884,6 @@ Foam::cellCuts::cellCuts
}
// Construct from components
Foam::cellCuts::cellCuts
(
const polyMesh& mesh,
......@@ -2980,7 +2955,6 @@ Foam::pointField Foam::cellCuts::loopPoints(const label cellI) const
}
// Flip loop for cell
void Foam::cellCuts::flip(const label cellI)
{
labelList& loop = cellLoops_[cellI];
......@@ -2998,7 +2972,6 @@ void Foam::cellCuts::flip(const label cellI)
}
// Flip loop only
void Foam::cellCuts::flipLoopOnly(const label cellI)
{
labelList& loop = cellLoops_[cellI];
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -277,6 +277,7 @@ class cellCuts
//- Walk across faceI following cuts, starting at cut. Stores cuts
// visited
// Returns true if valid walk.
bool walkFace
(
const label cellI,
......@@ -374,8 +375,8 @@ class cellCuts
const labelList& loop
) const;
//- Determines if loop through cellI consistent with existing
// pattern.
//- Determine compatibility of loop with existing cut pattern.
// Does not use cut-addressing (faceCuts_, cutCuts_)
bool conservativeValidLoop
(
const label cellI,
......@@ -395,8 +396,9 @@ class cellCuts
labelList& anchorPoints
) const;
//- Update basic cut information from cellLoops. Assumes cellLoops_
// already set and consistent.
//- Update basic cut information from cellLoops.
// Assumes cellLoops_ and edgeWeight_ already set and consistent.
// Does not use any other information.
void setFromCellLoops();
//- Update basic cut information for single cell from cellLoop.
......@@ -424,7 +426,8 @@ class cellCuts
const List<refineCell>& refCells
);
//- Same as above but now cut with prescribed plane.
//- Same as above but now cut with prescribed plane (instead of
// just normal).
void setFromCellCutter
(
const cellLooper&,
......@@ -436,6 +439,7 @@ class cellCuts
void orientPlanesAndLoops();
//- Top level driver: adressing calculation and loop detection
// (loops splitting cells).
void calcLoopsAndAddressing(const labelList& cutCells);
//- Check various consistencies.
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -126,10 +126,10 @@ Foam::Map<Foam::label> Foam::refinementIterator::setRefinement
OFstream cutsStream(cutsFile);
labelList refCells(currentRefCells.size());
labelList refCellsDebug(currentRefCells.size());
forAll(currentRefCells, i)
{
refCells[i] = currentRefCells[i].cellNo();
refCellsDebug[i] = currentRefCells[i].cellNo();
}
meshTools::writeOBJ
(
......@@ -137,7 +137,7 @@ Foam::Map<Foam::label> Foam::refinementIterator::setRefinement
mesh().cells(),
mesh().faces(),
mesh().points(),
refCells
refCellsDebug
);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment