snap to nearest

This commit is contained in:
mattijs
2008-09-25 12:00:20 +01:00
parent 16fefa2f14
commit 9473b70895

View File

@ -1059,6 +1059,8 @@ Foam::vectorField Foam::autoSnapDriver::calcNearestSurface
// Surfaces with zone information // Surfaces with zone information
const wordList& faceZoneNames = surfaces.faceZoneNames(); const wordList& faceZoneNames = surfaces.faceZoneNames();
scalarField minSnapDist(snapDist);
forAll(zonedSurfaces, i) forAll(zonedSurfaces, i)
{ {
label zoneSurfI = zonedSurfaces[i]; label zoneSurfI = zonedSurfaces[i];
@ -1075,17 +1077,14 @@ Foam::vectorField Foam::autoSnapDriver::calcNearestSurface
) )
); );
pointField zonePoints(localPoints, zonePointIndices);
scalarField zoneSnapDist(snapDist, zonePointIndices);
// Find nearest for points both on faceZone and pp. // Find nearest for points both on faceZone and pp.
List<pointIndexHit> hitInfo; List<pointIndexHit> hitInfo;
labelList hitSurface; labelList hitSurface;
surfaces.findNearest surfaces.findNearest
( (
labelList(1, zoneSurfI), labelList(1, zoneSurfI),
zonePoints, pointField(localPoints, zonePointIndices),
sqr(4*zoneSnapDist), sqr(4*scalarField(minSnapDist, zonePointIndices)),
hitSurface, hitSurface,
hitInfo hitInfo
); );
@ -1093,11 +1092,18 @@ Foam::vectorField Foam::autoSnapDriver::calcNearestSurface
forAll(hitInfo, i) forAll(hitInfo, i)
{ {
label pointI = zonePointIndices[i]; label pointI = zonePointIndices[i];
if (hitInfo[i].hit()) if (hitInfo[i].hit())
{ {
patchDisp[pointI] = patchDisp[pointI] =
hitInfo[i].hitPoint() hitInfo[i].hitPoint()
- localPoints[pointI]; - localPoints[pointI];
minSnapDist[pointI] = min
(
minSnapDist[pointI],
mag(patchDisp[pointI])
);
} }
else else
{ {
@ -1105,7 +1111,7 @@ Foam::vectorField Foam::autoSnapDriver::calcNearestSurface
<< "For point:" << pointI << "For point:" << pointI
<< " coordinate:" << localPoints[pointI] << " coordinate:" << localPoints[pointI]
<< " did not find any surface within:" << " did not find any surface within:"
<< 4*zoneSnapDist[i] << 4*minSnapDist[pointI]
<< " meter." << endl; << " meter." << endl;
} }
} }