Commit f7d4e8a8 authored by mattijs's avatar mattijs
Browse files

BUG: searchableExtrudedCircle: incorrect search sphere. Fixes #1567.

parent fdece1d7
......@@ -181,13 +181,35 @@ void Foam::searchableExtrudedCircle::findNearest
forAll(samples, i)
{
info[i] = tree.findNearest(samples[i], nearestDistSqr[i]);
const scalar nearestDist = Foam::sqrt(nearestDistSqr[i]);
const scalar searchDistSqr = Foam::sqr(nearestDist+radius_);
// Find nearest on central edge
info[i] = tree.findNearest(samples[i], searchDistSqr);
if (info[i].hit())
{
const vector d = normalised(samples[i] - info[i].hitPoint());
// Derive distance to nearest surface from distance to nearest edge
const vector d(samples[i] - info[i].hitPoint());
const scalar s(mag(d));
info[i].setPoint(info[i].hitPoint() + d*radius_);
if (s < ROOTVSMALL)
{
// Point is on edge. TBD.
info[i].setMiss();
}
else
{
const scalar distToSurface = radius_-s;
if (mag(distToSurface) > nearestDist)
{
info[i].setMiss();
}
else
{
info[i].setPoint(info[i].hitPoint() + d/s*radius_);
}
}
}
}
}
......
......@@ -38,7 +38,9 @@ Description
\endtable
Note
The edge mesh file is to be located in the constant/geometry directory.
- The edge mesh file is to be located in the constant/geometry directory.
- Can not be used with snappyHexMesh since only implements nearest
searching.
SourceFiles
searchableExtrudedCircle.C
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment