From fd41ce151f90c201e538f6ca66753e3dac27fce9 Mon Sep 17 00:00:00 2001 From: graham Date: Fri, 26 Feb 2010 19:11:09 +0000 Subject: [PATCH] BUG: conformalVoronoiMesh. Possibility of two Delaunay vertices being closer than SMALL when a pointFile is read (and perhaps other situations). When this is detected, deleting one or both of the points. Also adding a check that both Delaunay vertices are internal before looking at them in pointToBeRetained, otherwise there is a risk of a seg-fault or undefined behaviour. --- .../conformalVoronoiMesh.C | 74 +++++++++++++++---- 1 file changed, 59 insertions(+), 15 deletions(-) diff --git a/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C b/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C index 899731755e..8a2c14ab70 100644 --- a/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C +++ b/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C @@ -1278,6 +1278,45 @@ void Foam::conformalVoronoiMesh::move() scalar rABMag = mag(rAB); + if (rABMag < SMALL) + { + // Removal of close points + + if (vA->internalPoint() && vB->internalPoint()) + { + // Only insert a point at the midpoint of + // the short edge if neither attached + // point has already been identified to be + // removed. + + if + ( + pointToBeRetained[vA->index()] == true + && pointToBeRetained[vB->index()] == true + ) + { + pointsToInsert.push_back + ( + toPoint(0.5*(dVA + dVB)) + ); + } + } + + if (vA->internalPoint()) + { + pointToBeRetained[vA->index()] = false; + } + + if (vB->internalPoint()) + { + pointToBeRetained[vB->index()] = false; + } + + // Do not consider this Delaunay edge any further + + continue; + } + forAll(alignmentDirs, aD) { vector& alignmentDir = alignmentDirs[aD]; @@ -1317,11 +1356,11 @@ void Foam::conformalVoronoiMesh::move() vA->internalPoint() && vB->internalPoint() && rABMag - > cvMeshControls().insertionDistCoeff()*targetCellSize + > cvMeshControls().insertionDistCoeff()*targetCellSize && faceArea - > cvMeshControls().faceAreaRatioCoeff()*targetFaceArea + > cvMeshControls().faceAreaRatioCoeff()*targetFaceArea && alignmentDotProd - > cvMeshControls().cosInsertionAcceptanceAngle() + > cvMeshControls().cosInsertionAcceptanceAngle() ) { // Point insertion @@ -1349,24 +1388,29 @@ void Foam::conformalVoronoiMesh::move() ( (vA->internalPoint() || vB->internalPoint()) && rABMag - < cvMeshControls().removalDistCoeff()*targetCellSize + < cvMeshControls().removalDistCoeff()*targetCellSize ) { // Point removal - // Only insert a point at the midpoint of the short edge - // if neither attached point has already been identified - // to be removed. - if - ( - pointToBeRetained[vA->index()] == true - && pointToBeRetained[vB->index()] == true - ) + if (vA->internalPoint() && vB->internalPoint()) { - pointsToInsert.push_back + // Only insert a point at the midpoint of + // the short edge if neither attached + // point has already been identified to be + // removed. + + if ( - toPoint(0.5*(dVA + dVB)) - ); + pointToBeRetained[vA->index()] == true + && pointToBeRetained[vB->index()] == true + ) + { + pointsToInsert.push_back + ( + toPoint(0.5*(dVA + dVB)) + ); + } } if (vA->internalPoint())