From 7f21cc34ccb8106735f991777344f18e39600b89 Mon Sep 17 00:00:00 2001 From: mattijs <mattijs> Date: Thu, 20 Jun 2013 11:46:18 +0100 Subject: [PATCH] BUG: searachableSphere: handle point on centre --- src/meshTools/searchableSurface/searchableSphere.C | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/meshTools/searchableSurface/searchableSphere.C b/src/meshTools/searchableSurface/searchableSphere.C index 3d17b52d9fd..5c07f0b00d9 100644 --- a/src/meshTools/searchableSurface/searchableSphere.C +++ b/src/meshTools/searchableSurface/searchableSphere.C @@ -48,13 +48,15 @@ Foam::pointIndexHit Foam::searchableSphere::findNearest pointIndexHit info(false, sample, -1); const vector n(sample-centre_); - scalar magN = mag(n); + scalar magSqrN = magSqr(n); - if (nearestDistSqr > sqr(magN-radius_)) + if (nearestDistSqr >= magSqrN) { + scalar magN = Foam::sqrt(magSqrN); + if (magN < ROOTVSMALL) { - info.rawPoint() = centre_ + vector(1,0,0)/magN*radius_; + info.rawPoint() = centre_ + vector(1,0,0)*radius_; } else { -- GitLab