ENH: Making nearestPointClassify query for triangle.

This is to access the face/edge/point status of the nearest at the
same time to ensure a consistent result.

Using getVolumeType query in distanceSurface, not simple normal
dot-product comparison, fails on edges.
This commit is contained in:
graham
2010-10-06 10:25:26 +01:00
parent 0a26787282
commit 6cdbd0ada7
11 changed files with 439 additions and 581 deletions

View File

@ -89,20 +89,29 @@ void Foam::distanceSurface::createGeometry()
if (signed_)
{
vectorField normal;
surfPtr_().getNormal(nearest, normal);
List<searchableSurface::volumeType> volType;
forAll(nearest, i)
surfPtr_().getVolumeType(cc, volType);
forAll(volType, i)
{
vector d(cc[i]-nearest[i].hitPoint());
searchableSurface::volumeType vT = volType[i];
if ((d&normal[i]) > 0)
if (vT == searchableSurface::OUTSIDE)
{
fld[i] = Foam::mag(d);
fld[i] = Foam::mag(cc[i] - nearest[i].hitPoint());
}
else if (vT == searchableSurface::INSIDE)
{
fld[i] = -Foam::mag(cc[i] - nearest[i].hitPoint());
}
else
{
fld[i] = -Foam::mag(d);
FatalErrorIn
(
"void Foam::distanceSurface::createGeometry()"
) << "getVolumeType failure, neither INSIDE or OUTSIDE"
<< exit(FatalError);
}
}
}
@ -132,20 +141,30 @@ void Foam::distanceSurface::createGeometry()
if (signed_)
{
vectorField normal;
surfPtr_().getNormal(nearest, normal);
List<searchableSurface::volumeType> volType;
forAll(nearest, i)
surfPtr_().getVolumeType(cc, volType);
forAll(volType, i)
{
vector d(cc[i]-nearest[i].hitPoint());
searchableSurface::volumeType vT = volType[i];
if ((d&normal[i]) > 0)
if (vT == searchableSurface::OUTSIDE)
{
fld[i] = Foam::mag(d);
fld[i] = Foam::mag(cc[i] - nearest[i].hitPoint());
}
else if (vT == searchableSurface::INSIDE)
{
fld[i] = -Foam::mag(cc[i] - nearest[i].hitPoint());
}
else
{
fld[i] = -Foam::mag(d);
FatalErrorIn
(
"void Foam::distanceSurface::createGeometry()"
) << "getVolumeType failure, "
<< "neither INSIDE or OUTSIDE"
<< exit(FatalError);
}
}
}
@ -179,20 +198,31 @@ void Foam::distanceSurface::createGeometry()
if (signed_)
{
vectorField normal;
surfPtr_().getNormal(nearest, normal);
List<searchableSurface::volumeType> volType;
forAll(nearest, i)
surfPtr_().getVolumeType(pts, volType);
forAll(volType, i)
{
vector d(pts[i]-nearest[i].hitPoint());
searchableSurface::volumeType vT = volType[i];
if ((d&normal[i]) > 0)
if (vT == searchableSurface::OUTSIDE)
{
pointDistance_[i] = Foam::mag(d);
pointDistance_[i] =
Foam::mag(pts[i] - nearest[i].hitPoint());
}
else if (vT == searchableSurface::INSIDE)
{
pointDistance_[i] =
-Foam::mag(pts[i] - nearest[i].hitPoint());
}
else
{
pointDistance_[i] = -Foam::mag(d);
FatalErrorIn
(
"void Foam::distanceSurface::createGeometry()"
) << "getVolumeType failure, neither INSIDE or OUTSIDE"
<< exit(FatalError);
}
}
}