From fd5da91eed8b04d46893650803e33d513b5790b5 Mon Sep 17 00:00:00 2001 From: Henrik Rusche Date: Thu, 12 Dec 2013 01:27:37 +0100 Subject: [PATCH] ENH: Return 'found' only when proper face is found; first candidate may still be retrieved --- .../meshes/meshShapes/cell/oppositeCellFace.C | 6 ++++- .../meshes/meshShapes/face/oppositeFace.H | 2 +- .../layerAdditionRemoval/addCellLayer.C | 8 +++---- .../layerAdditionRemoval.C | 18 +++++++-------- .../layerAdditionRemoval/setLayerPairing.C | 23 ++++++++++++------- 5 files changed, 34 insertions(+), 23 deletions(-) diff --git a/src/OpenFOAM/meshes/meshShapes/cell/oppositeCellFace.C b/src/OpenFOAM/meshes/meshShapes/cell/oppositeCellFace.C index 2a74e032d..5ec696608 100644 --- a/src/OpenFOAM/meshes/meshShapes/cell/oppositeCellFace.C +++ b/src/OpenFOAM/meshes/meshShapes/cell/oppositeCellFace.C @@ -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); } } } diff --git a/src/OpenFOAM/meshes/meshShapes/face/oppositeFace.H b/src/OpenFOAM/meshes/meshShapes/face/oppositeFace.H index 241000237..f6b8347d3 100644 --- a/src/OpenFOAM/meshes/meshShapes/face/oppositeFace.H +++ b/src/OpenFOAM/meshes/meshShapes/face/oppositeFace.H @@ -96,7 +96,7 @@ public: //- Does the opposite face exist? inline bool found() const { - return oppositeIndex_ >= 0; + return size() > 0; } }; diff --git a/src/dynamicMesh/dynamicMesh/polyMeshModifiers/layerAdditionRemoval/addCellLayer.C b/src/dynamicMesh/dynamicMesh/polyMeshModifiers/layerAdditionRemoval/addCellLayer.C index 4da227d43..ee358a4d8 100644 --- a/src/dynamicMesh/dynamicMesh/polyMeshModifiers/layerAdditionRemoval/addCellLayer.C +++ b/src/dynamicMesh/dynamicMesh/polyMeshModifiers/layerAdditionRemoval/addCellLayer.C @@ -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; diff --git a/src/dynamicMesh/dynamicMesh/polyMeshModifiers/layerAdditionRemoval/layerAdditionRemoval.C b/src/dynamicMesh/dynamicMesh/polyMeshModifiers/layerAdditionRemoval/layerAdditionRemoval.C index accf614cc..49738530e 100644 --- a/src/dynamicMesh/dynamicMesh/polyMeshModifiers/layerAdditionRemoval/layerAdditionRemoval.C +++ b/src/dynamicMesh/dynamicMesh/polyMeshModifiers/layerAdditionRemoval/layerAdditionRemoval.C @@ -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; } } diff --git a/src/dynamicMesh/dynamicMesh/polyMeshModifiers/layerAdditionRemoval/setLayerPairing.C b/src/dynamicMesh/dynamicMesh/polyMeshModifiers/layerAdditionRemoval/setLayerPairing.C index 2c2733242..262813115 100644 --- a/src/dynamicMesh/dynamicMesh/polyMeshModifiers/layerAdditionRemoval/setLayerPairing.C +++ b/src/dynamicMesh/dynamicMesh/polyMeshModifiers/layerAdditionRemoval/setLayerPairing.C @@ -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)