View Issue Details

IDProjectCategoryView StatusLast Update
0001102OpenFOAMBugpublic2013-12-06 09:11
Reporterwyldckat Assigned Touser4 
PrioritynormalSeverityminorReproducibilitysometimes
Status resolvedResolutionfixed 
Summary0001102: Bug in Foam::searchableSphere::findNearest
DescriptionThis is somewhat of an odd bug, which I triggered by accident. And after looking at the source code since 1.7.x, it's this way at least since then!

When using snappyHexMesh, with a "searchableSphere", if the centre is located in an identical location to the "sample" point, it will lead to a sigFpe in the method "Foam::searchableSphere::findNearest".

This is because - as implied in the patch provided on the section "Steps To Reproduce" - if the "magN" value is smaller than "ROOTVSMALL" (1e-150 in scalar of type double), it will still try to divide "1/magN".


The curious result is that if by any chance the value for "magN" were indeed "1e-151" or similar, then the "rawPoint" would be located at "1e151", which is a pretty far away point for something that should be nearby ;)
Steps To Reproducediff --git a/src/meshTools/searchableSurface/searchableSphere.C b/src/meshTools/searchableSurface/searchableSphere.C
index 5f3e98a..d9d8538 100644
--- a/src/meshTools/searchableSurface/searchableSphere.C
+++ b/src/meshTools/searchableSurface/searchableSphere.C
@@ -54,7 +54,7 @@ Foam::pointIndexHit Foam::searchableSphere::findNearest
     {
         if (magN < ROOTVSMALL)
         {
- info.rawPoint() = centre_ + vector(1,0,0)/magN*radius_;
+ info.rawPoint() = centre_;
         }
         else
         {
Additional InformationI had a quick look at the other "searchable" geometries and couldn't find anything like this.

But I did accidentally find the method "Foam::face::contactSphereDiameter" in "src/OpenFOAM/meshes/meshShapes/face/faceContactSphere.C" and it relies on the usual mathematical trick:

  vector n1 = n/(magN + SMALL);
TagsNo tags attached.

Activities

user4

2013-12-06 09:11

  ~0002675

fixed in 03f57612cd859b3d2bbd0e70f8d84c2dabd0f00d

Thanks for reporting!

Issue History

Date Modified Username Field Change
2013-12-05 21:50 wyldckat New Issue
2013-12-06 09:11 user4 Note Added: 0002675
2013-12-06 09:11 user4 Status new => resolved
2013-12-06 09:11 user4 Fixed in Version => 2.2.x
2013-12-06 09:11 user4 Resolution open => fixed
2013-12-06 09:11 user4 Assigned To => user4