Skip to content
Snippets Groups Projects
Commit 8ad016dd authored by mattijs's avatar mattijs
Browse files

small normal tolerance. Fixed indexing error

parent 34038022
No related branches found
No related tags found
No related merge requests found
......@@ -26,7 +26,6 @@ License
#include "searchableSurfaceWithGaps.H"
#include "addToRunTimeSelectionTable.H"
#include "SortableList.H"
#include "Time.H"
#include "ListOps.H"
......@@ -82,7 +81,7 @@ Foam::Pair<Foam::vector> Foam::searchableSurfaceWithGaps::offsetVecs
// Do second offset vector perp to original edge and first offset vector
offsets[1] = n ^ offsets[0];
offsets[1] *= gap_/mag(offsets[1]);
offsets[1] *= gap_;
}
return offsets;
......@@ -207,6 +206,10 @@ void Foam::searchableSurfaceWithGaps::findLine
List<pointIndexHit>& info
) const
{
// Test with unperturbed vectors
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
surface().findLine(start, end, info);
// Count number of misses. Determine map
......@@ -215,6 +218,10 @@ void Foam::searchableSurfaceWithGaps::findLine
if (returnReduce(nMiss, sumOp<label>()) > 0)
{
//Pout<< "** retesting with offset0 " << nMiss << " misses out of "
// << start.size() << endl;
// extract segments according to map
pointField compactStart(start, compactMap);
pointField compactEnd(end, compactMap);
......@@ -228,20 +235,36 @@ void Foam::searchableSurfaceWithGaps::findLine
offset1
);
// Test with offset0 perturbed vectors
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// test in pairs: only if both perturbations hit something
// do we accept the hit.
const vectorField smallVec(SMALL*(compactEnd-compactStart));
List<pointIndexHit> plusInfo;
surface().findLine(compactStart+offset0, compactEnd+offset0, plusInfo);
surface().findLine
(
compactStart+offset0-smallVec,
compactEnd+offset0+smallVec,
plusInfo
);
List<pointIndexHit> minInfo;
surface().findLine(compactStart-offset0, compactEnd-offset0, minInfo);
surface().findLine
(
compactStart-offset0-smallVec,
compactEnd-offset0+smallVec,
minInfo
);
// Extract any hits
forAll(plusInfo, i)
{
if (plusInfo[i].hit() && minInfo[i].hit())
{
info[compactMap[i]] = plusInfo[i].hitPoint()-offset0[i];
info[compactMap[i]] = plusInfo[i];
info[compactMap[i]].rawPoint() -= offset0[i];
}
}
......@@ -250,6 +273,12 @@ void Foam::searchableSurfaceWithGaps::findLine
if (returnReduce(nMiss, sumOp<label>()) > 0)
{
//Pout<< "** retesting with offset1 " << nMiss << " misses out of "
// << start.size() << endl;
// Test with offset1 perturbed vectors
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Extract (inplace possible because of order)
forAll(plusMissMap, i)
{
......@@ -266,17 +295,18 @@ void Foam::searchableSurfaceWithGaps::findLine
offset0.setSize(plusMissMap.size());
offset1.setSize(plusMissMap.size());
const vectorField smallVec(SMALL*(compactEnd-compactStart));
surface().findLine
(
compactStart+offset1,
compactEnd+offset1,
compactStart+offset1-smallVec,
compactEnd+offset1+smallVec,
plusInfo
);
surface().findLine
(
compactStart-offset1,
compactEnd-offset1,
compactStart-offset1-smallVec,
compactEnd-offset1+smallVec,
minInfo
);
......@@ -285,7 +315,8 @@ void Foam::searchableSurfaceWithGaps::findLine
{
if (plusInfo[i].hit() && minInfo[i].hit())
{
info[compactMap[i]] = plusInfo[i].hitPoint()-offset1[i];
info[compactMap[i]] = plusInfo[i];
info[compactMap[i]].rawPoint() -= offset1[i];
}
}
}
......
......@@ -27,7 +27,13 @@ Class
Description
searchableSurface using multiple slightly shifted underlying surfaces
to make sure pierces don't go through gaps.
to make sure pierces don't go through gaps:
- shift test vector with two small vectors (of size gap_) perpendicular
to the original.
Test with + and - this vector. Only if both register a hit is it seen
as one.
- extend the test vector slightly (with SMALL) to account for numerical
inaccuracies.
SourceFiles
searchableSurfaceWithGaps.C
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment