BUG: searchableCylinder: incorrect normal

This commit is contained in:
mattijs
2014-07-23 09:17:31 +01:00
committed by Andrew Heather
parent 2305370249
commit d8777c03f1

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -662,23 +662,63 @@ void Foam::searchableCylinder::getNormal
vector v(info[i].hitPoint() - point1_); vector v(info[i].hitPoint() - point1_);
// Decompose sample-point1 into normal and parallel component // Decompose sample-point1 into normal and parallel component
scalar parallel = v & unitDir_; scalar parallel = (v & unitDir_);
if (parallel < 0) // Remove the parallel component and normalise
v -= parallel*unitDir_;
scalar magV = mag(v);
if (parallel <= 0)
{ {
normal[i] = -unitDir_; if ((magV-radius_) < mag(parallel))
}
else if (parallel > magDir_)
{ {
// above endcap
normal[i] = -unitDir_; normal[i] = -unitDir_;
} }
else else
{ {
// Remove the parallel component
v -= parallel*unitDir_;
normal[i] = v/mag(v); normal[i] = v/mag(v);
} }
} }
else if (parallel <= 0.5*magDir_)
{
// See if endcap closer or sidewall
if (parallel <= mag(magV-radius_))
{
// above endcap
normal[i] = -unitDir_;
}
else
{
normal[i] = v/mag(v);
}
}
else if (parallel <= magDir_)
{
// See if endcap closer or sidewall
if ((magDir_-parallel) <= mag(magV-radius_))
{
// above endcap
normal[i] = unitDir_;
}
else
{
normal[i] = v/mag(v);
}
}
else // beyong cylinder
{
if ((magV-radius_) < (parallel-magDir_))
{
// above endcap
normal[i] = unitDir_;
}
else
{
normal[i] = v/mag(v);
}
}
}
} }
} }