From 9473b7089562bf43d45cd6fcbdbcf8c829ebca67 Mon Sep 17 00:00:00 2001 From: mattijs Date: Thu, 25 Sep 2008 12:00:20 +0100 Subject: [PATCH] snap to nearest --- .../autoHexMeshDriver/autoSnapDriver.C | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/autoMesh/autoHexMesh/autoHexMeshDriver/autoSnapDriver.C b/src/autoMesh/autoHexMesh/autoHexMeshDriver/autoSnapDriver.C index d7dda063b9..bd0825217a 100644 --- a/src/autoMesh/autoHexMesh/autoHexMeshDriver/autoSnapDriver.C +++ b/src/autoMesh/autoHexMesh/autoHexMeshDriver/autoSnapDriver.C @@ -1059,6 +1059,8 @@ Foam::vectorField Foam::autoSnapDriver::calcNearestSurface // Surfaces with zone information const wordList& faceZoneNames = surfaces.faceZoneNames(); + scalarField minSnapDist(snapDist); + forAll(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. List hitInfo; labelList hitSurface; surfaces.findNearest ( labelList(1, zoneSurfI), - zonePoints, - sqr(4*zoneSnapDist), + pointField(localPoints, zonePointIndices), + sqr(4*scalarField(minSnapDist, zonePointIndices)), hitSurface, hitInfo ); @@ -1093,11 +1092,18 @@ Foam::vectorField Foam::autoSnapDriver::calcNearestSurface forAll(hitInfo, i) { label pointI = zonePointIndices[i]; + if (hitInfo[i].hit()) { patchDisp[pointI] = hitInfo[i].hitPoint() - localPoints[pointI]; + + minSnapDist[pointI] = min + ( + minSnapDist[pointI], + mag(patchDisp[pointI]) + ); } else { @@ -1105,7 +1111,7 @@ Foam::vectorField Foam::autoSnapDriver::calcNearestSurface << "For point:" << pointI << " coordinate:" << localPoints[pointI] << " did not find any surface within:" - << 4*zoneSnapDist[i] + << 4*minSnapDist[pointI] << " meter." << endl; } }