mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: vector mag(), magSqr() methods - complementary to dist(), distSqr()
ENH: use direct access to pointHit as point(), use dist(), distSqr() - if the pointHit has already been checked for hit(), can/should simply use point() noexcept access subsequently to avoid redundant checks. Using vector distSqr() methods provides a minor optimization (no itermediate temporary), but can also make for clearer code. ENH: copy construct pointIndexHit with different index - symmetric with constructing from a pointHit with an index STYLE: prefer pointHit point() instead of rawPoint()
This commit is contained in:
committed by
Andrew Heather
parent
5ec435aca3
commit
27c2cdc040
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2019 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -1570,14 +1570,14 @@ Foam::pointIndexHit Foam::dynamicIndexedOctree<Type>::findLine
|
||||
(
|
||||
octantBb,
|
||||
treeVec,
|
||||
hitInfo.rawPoint()
|
||||
hitInfo.point()
|
||||
)
|
||||
);
|
||||
|
||||
if (verbose)
|
||||
{
|
||||
Pout<< "iter:" << i
|
||||
<< " at current:" << hitInfo.rawPoint()
|
||||
<< " at current:" << hitInfo.point()
|
||||
<< " (perturbed:" << startPoint << ")" << endl
|
||||
<< " node:" << nodeI
|
||||
<< " octant:" << octant
|
||||
@ -1612,7 +1612,7 @@ Foam::pointIndexHit Foam::dynamicIndexedOctree<Type>::findLine
|
||||
break;
|
||||
}
|
||||
|
||||
if (hitFaceID == 0 || hitInfo.rawPoint() == treeEnd)
|
||||
if (hitFaceID == 0 || hitInfo.point() == treeEnd)
|
||||
{
|
||||
// endpoint inside the tree. Return miss.
|
||||
break;
|
||||
@ -1625,7 +1625,7 @@ Foam::pointIndexHit Foam::dynamicIndexedOctree<Type>::findLine
|
||||
(
|
||||
octantBb,
|
||||
hitFaceID,
|
||||
hitInfo.rawPoint(),
|
||||
hitInfo.point(),
|
||||
false // push outside of octantBb
|
||||
)
|
||||
);
|
||||
@ -1634,7 +1634,7 @@ Foam::pointIndexHit Foam::dynamicIndexedOctree<Type>::findLine
|
||||
{
|
||||
Pout<< " iter:" << i
|
||||
<< " hit face:" << faceString(hitFaceID)
|
||||
<< " at:" << hitInfo.rawPoint() << nl
|
||||
<< " at:" << hitInfo.point() << nl
|
||||
<< " node:" << nodeI
|
||||
<< " octant:" << octant
|
||||
<< " bb:" << subBbox(nodeI, octant) << nl
|
||||
@ -1665,10 +1665,10 @@ Foam::pointIndexHit Foam::dynamicIndexedOctree<Type>::findLine
|
||||
if (verbose)
|
||||
{
|
||||
const treeBoundBox octantBb(subBbox(nodeI, octant));
|
||||
Pout<< " walked for point:" << hitInfo.rawPoint() << endl
|
||||
Pout<< " walked for point:" << hitInfo.point() << endl
|
||||
<< " to neighbour node:" << nodeI
|
||||
<< " octant:" << octant
|
||||
<< " face:" << faceString(octantBb.faceBits(hitInfo.rawPoint()))
|
||||
<< " face:" << faceString(octantBb.faceBits(hitInfo.point()))
|
||||
<< " of octantBb:" << octantBb << endl
|
||||
<< endl;
|
||||
}
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -84,16 +85,7 @@ bool Foam::dynamicTreeDataPoint::overlaps
|
||||
const scalar radiusSqr
|
||||
) const
|
||||
{
|
||||
const point& p = points_[index];
|
||||
|
||||
const scalar distSqr = magSqr(p - centre);
|
||||
|
||||
if (distSqr <= radiusSqr)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return (centre.distSqr(points_[index]) <= radiusSqr);
|
||||
}
|
||||
|
||||
|
||||
@ -113,7 +105,7 @@ void Foam::dynamicTreeDataPoint::findNearest
|
||||
|
||||
const point& pt = points_[index];
|
||||
|
||||
scalar distSqr = magSqr(pt - sample);
|
||||
const scalar distSqr = sample.distSqr(pt);
|
||||
|
||||
if (distSqr < nearestDistSqr)
|
||||
{
|
||||
@ -137,7 +129,7 @@ void Foam::dynamicTreeDataPoint::findNearest
|
||||
) const
|
||||
{
|
||||
// Best so far
|
||||
scalar nearestDistSqr = magSqr(linePoint - nearestPoint);
|
||||
scalar nearestDistSqr = linePoint.distSqr(nearestPoint);
|
||||
|
||||
forAll(indices, i)
|
||||
{
|
||||
@ -155,7 +147,7 @@ void Foam::dynamicTreeDataPoint::findNearest
|
||||
{
|
||||
nearestDistSqr = distSqr;
|
||||
minIndex = index;
|
||||
linePoint = pHit.rawPoint();
|
||||
linePoint = pHit.point();
|
||||
nearestPoint = shapePt;
|
||||
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user