From b414e15b0b0e44394077b78f8459938e73a07266 Mon Sep 17 00:00:00 2001 From: mattijs Date: Fri, 21 Jan 2011 10:58:28 +0000 Subject: [PATCH] ENH: meshSearch : avoid unnecessary mag() --- src/meshTools/meshSearch/meshSearch.C | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/meshTools/meshSearch/meshSearch.C b/src/meshTools/meshSearch/meshSearch.C index 4e068489f9..1a83a3720f 100644 --- a/src/meshTools/meshSearch/meshSearch.C +++ b/src/meshTools/meshSearch/meshSearch.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -101,9 +101,11 @@ Foam::label Foam::meshSearch::findNearestCellTree(const point& location) const { const indexedOctree& tree = cellTree(); - scalar span = tree.bb().mag(); - - pointIndexHit info = tree.findNearest(location, Foam::sqr(span)); + pointIndexHit info = tree.findNearest + ( + location, + magSqr(tree.bb().max()-tree.bb().min()) + ); if (!info.hit()) { @@ -178,10 +180,12 @@ Foam::label Foam::meshSearch::findNearestFaceTree(const point& location) const // Search nearest cell centre. const indexedOctree& tree = cellTree(); - scalar span = tree.bb().mag(); - // Search with decent span - pointIndexHit info = tree.findNearest(location, Foam::sqr(span)); + pointIndexHit info = tree.findNearest + ( + location, + magSqr(tree.bb().max()-tree.bb().min()) + ); if (!info.hit()) { @@ -767,12 +771,10 @@ Foam::label Foam::meshSearch::findNearestBoundaryFace { const indexedOctree& tree = boundaryTree(); - scalar span = tree.bb().mag(); - pointIndexHit info = boundaryTree().findNearest ( location, - Foam::sqr(span) + magSqr(tree.bb().max()-tree.bb().min()) ); if (!info.hit())