From 4977d93e8ac2bc18beb2d0e2efc54d670a495e62 Mon Sep 17 00:00:00 2001 From: Henry Date: Thu, 1 Jan 2015 13:42:13 +0000 Subject: [PATCH] primitiveMesh::pointInCellBB: Inflate the cell isotropically to handle anisotropic cells more robustly --- src/OpenFOAM/meshes/primitiveMesh/primitiveMesh.H | 11 ++++++----- .../meshes/primitiveMesh/primitiveMeshFindCell.C | 13 +++++-------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/OpenFOAM/meshes/primitiveMesh/primitiveMesh.H b/src/OpenFOAM/meshes/primitiveMesh/primitiveMesh.H index c4ab139ca3..cbff3c4052 100644 --- a/src/OpenFOAM/meshes/primitiveMesh/primitiveMesh.H +++ b/src/OpenFOAM/meshes/primitiveMesh/primitiveMesh.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -755,16 +755,17 @@ public: // Useful derived info - //- Is the point in the cell bounding box, option relative - // tolerance to increase the effective size of the boundBox + //- Return true if the point in the cell bounding box. + // The bounding box may be isotropically inflated by the fraction + // inflationFraction bool pointInCellBB ( const point& p, label celli, - scalar tol = 0 + scalar inflationFraction = 0 ) const; - //- Is the point in the cell + //- Return true if the point is in the cell bool pointInCell(const point& p, label celli) const; //- Find the cell with the nearest cell centre to location diff --git a/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshFindCell.C b/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshFindCell.C index edb261c601..4b6b0dcd0d 100644 --- a/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshFindCell.C +++ b/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshFindCell.C @@ -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 @@ -33,7 +33,7 @@ bool Foam::primitiveMesh::pointInCellBB ( const point& p, label celli, - scalar tol + scalar inflationFraction ) const { boundBox bb @@ -46,13 +46,10 @@ bool Foam::primitiveMesh::pointInCellBB false ); - if (tol > SMALL) + if (inflationFraction > SMALL) { - bb = boundBox - ( - bb.min() - tol*bb.span(), - bb.max() + tol*bb.span() - ); + vector inflation = inflationFraction*vector::one*mag(bb.span()); + bb = boundBox(bb.min() - inflation, bb.max() + inflation); } return bb.contains(p);