Skip to content
Snippets Groups Projects
Commit d8777c03 authored by mattijs's avatar mattijs Committed by Andrew Heather
Browse files

BUG: searchableCylinder: incorrect normal

parent 23053702
Branches
Tags
No related merge requests found
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -662,21 +662,61 @@ void Foam::searchableCylinder::getNormal
vector v(info[i].hitPoint() - point1_);
// 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))
{
// above endcap
normal[i] = -unitDir_;
}
else
{
normal[i] = v/mag(v);
}
}
else if (parallel > magDir_)
else if (parallel <= 0.5*magDir_)
{
normal[i] = -unitDir_;
// See if endcap closer or sidewall
if (parallel <= mag(magV-radius_))
{
// above endcap
normal[i] = -unitDir_;
}
else
{
normal[i] = v/mag(v);
}
}
else
else if (parallel <= magDir_)
{
// Remove the parallel component
v -= parallel*unitDir_;
normal[i] = v/mag(v);
// 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);
}
}
}
}
......
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