From 8ad016dd2c87b0dada685b82ad14885a3295115a Mon Sep 17 00:00:00 2001 From: mattijs <mattijs@hunt.opencfd.co.uk> Date: Tue, 28 Oct 2008 21:11:48 +0000 Subject: [PATCH] small normal tolerance. Fixed indexing error --- .../searchableSurfaceWithGaps.C | 51 +++++++++++++++---- .../searchableSurfaceWithGaps.H | 8 ++- 2 files changed, 48 insertions(+), 11 deletions(-) diff --git a/src/meshTools/searchableSurface/searchableSurfaceWithGaps.C b/src/meshTools/searchableSurface/searchableSurfaceWithGaps.C index 50e851296bd..b41a4409b20 100644 --- a/src/meshTools/searchableSurface/searchableSurfaceWithGaps.C +++ b/src/meshTools/searchableSurface/searchableSurfaceWithGaps.C @@ -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]; } } } diff --git a/src/meshTools/searchableSurface/searchableSurfaceWithGaps.H b/src/meshTools/searchableSurface/searchableSurfaceWithGaps.H index a5392867f15..e88cae68290 100644 --- a/src/meshTools/searchableSurface/searchableSurfaceWithGaps.H +++ b/src/meshTools/searchableSurface/searchableSurfaceWithGaps.H @@ -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 -- GitLab