ENH: Return 'found' only when proper face is found; first candidate may still be retrieved

This commit is contained in:
Henrik Rusche 2013-12-12 01:27:37 +01:00
parent f3a9ce3f50
commit fd5da91eed
5 changed files with 34 additions and 23 deletions

View file

@ -69,7 +69,7 @@ Foam::label Foam::cell::opposingFaceLabel
{
bool sharedPoint = false;
// Compare every vertex of the current face agains the
// Compare every vertex of the current face against the
// vertices of the master face
forAll (curFace, pointI)
{
@ -104,6 +104,7 @@ Foam::label Foam::cell::opposingFaceLabel
Info<< "Multiple faces not sharing vertex: "
<< oppositeFaceLabel << " and "
<< curFaceLabels[faceI] << endl;
return -1;
}
}
@ -180,6 +181,9 @@ Foam::oppositeFace Foam::cell::opposingFace
break;
}
}
// None of them matches, return a failure
return oppositeFace(face(0), masterFaceLabel, oppFaceLabel);
}
}
}

View file

@ -96,7 +96,7 @@ public:
//- Does the opposite face exist?
inline bool found() const
{
return oppositeIndex_ >= 0;
return size() > 0;
}
};

View file

@ -53,7 +53,7 @@ void Foam::layerAdditionRemoval::addCellLayer
if (debug)
{
Pout<< "void layerAdditionRemoval::addCellLayer("
Info<< "void layerAdditionRemoval::addCellLayer("
<< "polyTopoChange& ref) const for object " << name() << " : "
<< "Adding cell layer" << endl;
}
@ -75,7 +75,7 @@ void Foam::layerAdditionRemoval::addCellLayer
{
if (debug)
{
Pout<< "void layerAdditionRemoval::addCellLayer("
Info<< "void layerAdditionRemoval::addCellLayer("
<< "polyTopoChange& ref) const "
<< " for object " << name() << " : "
<< "Using edges for point insertion" << endl;
@ -94,7 +94,7 @@ void Foam::layerAdditionRemoval::addCellLayer
{
if (debug)
{
Pout<< "void layerAdditionRemoval::addCellLayer("
Info<< "void layerAdditionRemoval::addCellLayer("
<< "polyTopoChange& ref) const "
<< " for object " << name() << " : "
<< "A valid layer could not be found in front of "
@ -551,7 +551,7 @@ void Foam::layerAdditionRemoval::addCellLayer
if (debug)
{
Pout<< "void layerAdditionRemoval::addCellLayer("
Info<< "void layerAdditionRemoval::addCellLayer("
<< "polyTopoChange& ref) const "
<< " for object " << name() << " : "
<< "Finished adding cell layer" << endl;

View file

@ -329,7 +329,7 @@ bool Foam::layerAdditionRemoval::changeTopology() const
if (debug)
{
Pout<< "bool layerAdditionRemoval::changeTopology() const "
Info<< "bool layerAdditionRemoval::changeTopology() const "
<< " for object " << name() << " : " << nl
<< "Layer thickness: min: " << minDelta
<< " max: " << maxDelta << " avg: " << avgDelta
@ -346,7 +346,7 @@ bool Foam::layerAdditionRemoval::changeTopology() const
{
if (debug)
{
Pout << "First step. No addition/removal" << endl;
Info<< "First step. No addition/removal" << endl;
}
// No topological changes allowed before first mesh motion
@ -373,7 +373,7 @@ bool Foam::layerAdditionRemoval::changeTopology() const
if (debug)
{
Pout<< "bool layerAdditionRemoval::changeTopology() "
Info<< "bool layerAdditionRemoval::changeTopology() "
<< " const for object " << name() << " : "
<< "Triggering layer removal" << endl;
}
@ -405,7 +405,7 @@ bool Foam::layerAdditionRemoval::changeTopology() const
{
if (debug)
{
Pout<< "bool layerAdditionRemoval::changeTopology() const "
Info<< "bool layerAdditionRemoval::changeTopology() const "
<< " for object " << name() << " : "
<< "Triggering layer addition" << endl;
}
@ -440,7 +440,7 @@ void Foam::layerAdditionRemoval::setRefinement(polyTopoChange& ref) const
// Clear addressing. This also resets the addition/removal data
if (debug)
{
Pout<< "layerAdditionRemoval::setRefinement(polyTopoChange& ref) "
Info<< "layerAdditionRemoval::setRefinement(polyTopoChange& ref) "
<< " for object " << name() << " : "
<< "Clearing addressing after layer removal. " << endl;
}
@ -456,7 +456,7 @@ void Foam::layerAdditionRemoval::setRefinement(polyTopoChange& ref) const
// Clear addressing. This also resets the addition/removal data
if (debug)
{
Pout<< "layerAdditionRemoval::setRefinement(polyTopoChange& ref) "
Info<< "layerAdditionRemoval::setRefinement(polyTopoChange& ref) "
<< " for object " << name() << " : "
<< "Clearing addressing after layer addition. " << endl;
}
@ -471,17 +471,17 @@ void Foam::layerAdditionRemoval::updateMesh(const mapPolyMesh&)
{
if (debug)
{
Pout<< "layerAdditionRemoval::updateMesh(const mapPolyMesh&) "
Info<< "layerAdditionRemoval::updateMesh(const mapPolyMesh&) "
<< " for object " << name() << " : "
<< "Clearing addressing on external request. ";
if (pointsPairingPtr_ || facesPairingPtr_)
{
Pout << "Pointers set." << endl;
Info << "Pointers set." << endl;
}
else
{
Pout << "Pointers not set." << endl;
Info << "Pointers not set." << endl;
}
}

View file

@ -124,11 +124,15 @@ bool Foam::layerAdditionRemoval::setLayerPairing() const
// << "curLocalFace: " << curLocalFace << nl
// << "lidFace: " << lidFace
// << " master index: " << lidFace.masterIndex()
// << " oppositeIndex: " << lidFace.oppositeIndex() << endl;
// << " oppositeIndex: " << lidFace.oppositeIndex() << nl
// << "faces[oppositeIndex]: " << faces[lidFace.oppositeIndex()] << endl;
// Grab the opposite face for face collapse addressing
ftc[faceI] = lidFace.oppositeIndex();
// lidFace is only valid in simple cases
const face& lidFace2 = faces[lidFace.oppositeIndex()];
// Using the local face insert the points into the lid list
forAll (curLocalFace, pointI)
{
@ -150,25 +154,25 @@ bool Foam::layerAdditionRemoval::setLayerPairing() const
// arbitray polyhedra!
// HR, 1/May/2011
label curPoint = faces[mf[faceI]][pointI];
const label curPoint = faces[mf[faceI]][pointI];
const labelListList& ppAddr = mesh.pointPoints();
const labelList& p1List = ppAddr[lidFace[pointI]];
const labelList& p1List = ppAddr[lidFace2[pointI]];
const labelList& p2List = ppAddr[ptc[clp]];
bool found = false;
forAll(p1List, p1I)
forAll (p1List, p1I)
{
label p1 = p1List[p1I];
const label p1 = p1List[p1I];
if (p1 != curPoint)
{
forAll(p2List, p2I)
forAll (p2List, p2I)
{
label p2 = p2List[p2I];
if(p1 == p2)
if (p1 == p2)
{
ptc[clp] = p1;
found = true;
@ -177,7 +181,10 @@ bool Foam::layerAdditionRemoval::setLayerPairing() const
}
}
if(found) { break; }
if (found)
{
break;
}
}
if (!found)